aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/hw/nes/nes_nic.c7
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c15
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c14
-rw-r--r--drivers/net/3c505.c7
-rw-r--r--drivers/net/3c523.c7
-rw-r--r--drivers/net/3c527.c6
-rw-r--r--drivers/net/7990.c6
-rw-r--r--drivers/net/8139cp.c6
-rw-r--r--drivers/net/8139too.c6
-rw-r--r--drivers/net/82596.c6
-rw-r--r--drivers/net/Kconfig23
-rw-r--r--drivers/net/Makefile3
-rw-r--r--drivers/net/a2065.c6
-rw-r--r--drivers/net/acenic.c42
-rw-r--r--drivers/net/acenic.h6
-rw-r--r--drivers/net/amd8111e.c6
-rw-r--r--drivers/net/arm/am79c961a.c6
-rw-r--r--drivers/net/arm/at91_ether.c6
-rw-r--r--drivers/net/arm/ixp4xx_eth.c8
-rw-r--r--drivers/net/arm/ks8695net.c10
-rw-r--r--drivers/net/arm/w90p910_ether.c1
-rw-r--r--drivers/net/at1700.c6
-rw-r--r--drivers/net/atl1c/atl1c_main.c7
-rw-r--r--drivers/net/atl1e/atl1e_main.c7
-rw-r--r--drivers/net/atlx/atl2.c7
-rw-r--r--drivers/net/atlx/atlx.c6
-rw-r--r--drivers/net/atp.c6
-rw-r--r--drivers/net/au1000_eth.c6
-rw-r--r--drivers/net/b44.c6
-rw-r--r--drivers/net/bcm63xx_enet.c7
-rw-r--r--drivers/net/benet/be.h9
-rw-r--r--drivers/net/benet/be_cmds.c10
-rw-r--r--drivers/net/benet/be_cmds.h2
-rw-r--r--drivers/net/benet/be_ethtool.c2
-rw-r--r--drivers/net/benet/be_hw.h3
-rw-r--r--drivers/net/benet/be_main.c299
-rw-r--r--drivers/net/bfin_mac.c6
-rw-r--r--drivers/net/bmac.c12
-rw-r--r--drivers/net/bnx2.c5
-rw-r--r--drivers/net/bnx2x_link.c12
-rw-r--r--drivers/net/bnx2x_main.c38
-rw-r--r--drivers/net/bonding/bond_ipv6.c9
-rw-r--r--drivers/net/bonding/bond_main.c176
-rw-r--r--drivers/net/bonding/bonding.h2
-rw-r--r--drivers/net/caif/Kconfig17
-rw-r--r--drivers/net/caif/Makefile12
-rw-r--r--drivers/net/caif/caif_serial.c441
-rw-r--r--drivers/net/can/mcp251x.c14
-rw-r--r--drivers/net/can/sja1000/sja1000_platform.c44
-rw-r--r--drivers/net/cassini.c12
-rw-r--r--drivers/net/chelsio/pm3393.c7
-rw-r--r--drivers/net/cpmac.c16
-rw-r--r--drivers/net/cris/eth_v10.c6
-rw-r--r--drivers/net/cxgb3/xgmac.c8
-rw-r--r--drivers/net/cxgb4/cxgb4_main.c8
-rw-r--r--drivers/net/davinci_emac.c7
-rw-r--r--drivers/net/declance.c6
-rw-r--r--drivers/net/defxx.c6
-rw-r--r--drivers/net/depca.c6
-rw-r--r--drivers/net/dl2k.c6
-rw-r--r--drivers/net/dm9000.c6
-rw-r--r--drivers/net/dnet.c2
-rw-r--r--drivers/net/e100.c189
-rw-r--r--drivers/net/e1000/e1000_hw.c4
-rw-r--r--drivers/net/e1000/e1000_main.c7
-rw-r--r--drivers/net/e1000e/82571.c2
-rw-r--r--drivers/net/e1000e/e1000.h24
-rw-r--r--drivers/net/e1000e/ich8lan.c6
-rw-r--r--drivers/net/e1000e/lib.c21
-rw-r--r--drivers/net/e1000e/netdev.c198
-rw-r--r--drivers/net/eepro.c10
-rw-r--r--drivers/net/eexpress.c6
-rw-r--r--drivers/net/ehea/ehea_main.c6
-rw-r--r--drivers/net/enic/cq_enet_desc.h12
-rw-r--r--drivers/net/enic/enic.h4
-rw-r--r--drivers/net/enic/enic_main.c11
-rw-r--r--drivers/net/enic/vnic_dev.c52
-rw-r--r--drivers/net/enic/vnic_dev.h3
-rw-r--r--drivers/net/enic/vnic_rq.c4
-rw-r--r--drivers/net/enic/vnic_wq.c4
-rw-r--r--drivers/net/epic100.c6
-rw-r--r--drivers/net/ethoc.c6
-rw-r--r--drivers/net/ewrk3.c9
-rw-r--r--drivers/net/fealnx.c6
-rw-r--r--drivers/net/fec.c1138
-rw-r--r--drivers/net/fec_mpc52xx.c7
-rw-r--r--drivers/net/forcedeth.c10
-rw-r--r--drivers/net/fs_enet/mac-fcc.c6
-rw-r--r--drivers/net/fs_enet/mac-fec.c6
-rw-r--r--drivers/net/fs_enet/mac-scc.c6
-rw-r--r--drivers/net/gianfar.c9
-rw-r--r--drivers/net/greth.c7
-rw-r--r--drivers/net/hamachi.c8
-rw-r--r--drivers/net/hamradio/baycom_ser_fdx.c2
-rw-r--r--drivers/net/hp100.c6
-rw-r--r--drivers/net/ibm_newemac/core.c12
-rw-r--r--drivers/net/ibmlana.c8
-rw-r--r--drivers/net/ibmveth.c6
-rw-r--r--drivers/net/igb/e1000_82575.c33
-rw-r--r--drivers/net/igb/e1000_82575.h9
-rw-r--r--drivers/net/igb/e1000_defines.h1
-rw-r--r--drivers/net/igb/e1000_hw.h17
-rw-r--r--drivers/net/igb/igb.h2
-rw-r--r--drivers/net/igb/igb_ethtool.c50
-rw-r--r--drivers/net/igb/igb_main.c123
-rw-r--r--drivers/net/igbvf/netdev.c6
-rw-r--r--drivers/net/ioc3-eth.c6
-rw-r--r--drivers/net/ipg.c11
-rw-r--r--drivers/net/ipg.h109
-rw-r--r--drivers/net/irda/Kconfig6
-rw-r--r--drivers/net/irda/Makefile1
-rw-r--r--drivers/net/irda/ali-ircc.c32
-rw-r--r--drivers/net/irda/irda-usb.c2
-rw-r--r--drivers/net/irda/sh_irda.c865
-rw-r--r--drivers/net/irda/sh_sir.c12
-rw-r--r--drivers/net/irda/vlsi_ir.c4
-rw-r--r--drivers/net/iseries_veth.c6
-rw-r--r--drivers/net/ixgb/ixgb_main.c6
-rw-r--r--drivers/net/ixgbe/ixgbe_82599.c2
-rw-r--r--drivers/net/ixgbe/ixgbe_common.c16
-rw-r--r--drivers/net/ixgbe/ixgbe_common.h5
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c30
-rw-r--r--drivers/net/ixgbe/ixgbe_phy.c4
-rw-r--r--drivers/net/ixgbe/ixgbe_type.h3
-rw-r--r--drivers/net/ixgbevf/ixgbevf_main.c32
-rw-r--r--drivers/net/ixgbevf/vf.c24
-rw-r--r--drivers/net/ixgbevf/vf.h4
-rw-r--r--drivers/net/jme.c6
-rw-r--r--drivers/net/korina.c12
-rw-r--r--drivers/net/ks8842.c8
-rw-r--r--drivers/net/ks8851.c94
-rw-r--r--drivers/net/ks8851_mll.c63
-rw-r--r--drivers/net/ksz884x.c79
-rw-r--r--drivers/net/lib82596.c6
-rw-r--r--drivers/net/lib8390.c6
-rw-r--r--drivers/net/ll_temac.h14
-rw-r--r--drivers/net/ll_temac_main.c153
-rw-r--r--drivers/net/lp486e.c6
-rw-r--r--drivers/net/macb.c6
-rw-r--r--drivers/net/mace.c6
-rw-r--r--drivers/net/macmace.c6
-rw-r--r--drivers/net/macvlan.c13
-rw-r--r--drivers/net/mlx4/en_netdev.c53
-rw-r--r--drivers/net/mlx4/mlx4_en.h3
-rw-r--r--drivers/net/mv643xx_eth.c6
-rw-r--r--drivers/net/myri10ge/myri10ge.c8
-rw-r--r--drivers/net/natsemi.c6
-rw-r--r--drivers/net/netxen/netxen_nic.h1
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c6
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c12
-rw-r--r--drivers/net/netxen/netxen_nic_init.c164
-rw-r--r--drivers/net/netxen/netxen_nic_main.c29
-rw-r--r--drivers/net/ni52.c6
-rw-r--r--drivers/net/niu.c5
-rw-r--r--drivers/net/octeon/octeon_mgmt.c6
-rw-r--r--drivers/net/pci-skeleton.c6
-rw-r--r--drivers/net/pcmcia/3c589_cs.c286
-rw-r--r--drivers/net/pcmcia/axnet_cs.c6
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c6
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c6
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c8
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c6
-rw-r--r--drivers/net/pcnet32.c6
-rw-r--r--drivers/net/phy/bcm63xx.c8
-rw-r--r--drivers/net/phy/broadcom.c16
-rw-r--r--drivers/net/phy/cicada.c8
-rw-r--r--drivers/net/phy/davicom.c9
-rw-r--r--drivers/net/phy/et1011c.c7
-rw-r--r--drivers/net/phy/icplus.c7
-rw-r--r--drivers/net/phy/lxt.c8
-rw-r--r--drivers/net/phy/marvell.c13
-rw-r--r--drivers/net/phy/mdio-bitbang.c60
-rw-r--r--drivers/net/phy/mdio_bus.c4
-rw-r--r--drivers/net/phy/national.c7
-rw-r--r--drivers/net/phy/phy_device.c12
-rw-r--r--drivers/net/phy/qsemi.c7
-rw-r--r--drivers/net/phy/realtek.c7
-rw-r--r--drivers/net/phy/smsc.c11
-rw-r--r--drivers/net/phy/ste10Xp.c8
-rw-r--r--drivers/net/phy/vitesse.c8
-rw-r--r--drivers/net/ppp_generic.c19
-rw-r--r--drivers/net/pppol2tp.c2680
-rw-r--r--drivers/net/ps3_gelic_net.c10
-rw-r--r--drivers/net/ps3_gelic_wireless.c69
-rw-r--r--drivers/net/qla3xxx.c2
-rw-r--r--drivers/net/qlcnic/qlcnic.h21
-rw-r--r--drivers/net/qlcnic/qlcnic_ethtool.c16
-rw-r--r--drivers/net/qlcnic/qlcnic_hdr.h7
-rw-r--r--drivers/net/qlcnic/qlcnic_hw.c131
-rw-r--r--drivers/net/qlcnic/qlcnic_init.c34
-rw-r--r--drivers/net/qlcnic/qlcnic_main.c100
-rw-r--r--drivers/net/qlge/qlge_dbg.c4
-rw-r--r--drivers/net/qlge/qlge_main.c6
-rw-r--r--drivers/net/r6040.c10
-rw-r--r--drivers/net/r8169.c180
-rw-r--r--drivers/net/s2io.c8
-rw-r--r--drivers/net/s6gmac.c1
-rw-r--r--drivers/net/sb1250-mac.c7
-rw-r--r--drivers/net/sc92031.c6
-rw-r--r--drivers/net/sfc/efx.c6
-rw-r--r--drivers/net/sis190.c6
-rw-r--r--drivers/net/sis900.c14
-rw-r--r--drivers/net/skfp/fplustm.c2
-rw-r--r--drivers/net/skfp/pcmplc.c4
-rw-r--r--drivers/net/skfp/skfddi.c12
-rw-r--r--drivers/net/skfp/srf.c2
-rw-r--r--drivers/net/skge.c14
-rw-r--r--drivers/net/sky2.c26
-rw-r--r--drivers/net/sky2.h20
-rw-r--r--drivers/net/smc911x.c19
-rw-r--r--drivers/net/smc9194.c53
-rw-r--r--drivers/net/smc91x.c10
-rw-r--r--drivers/net/smsc911x.c6
-rw-r--r--drivers/net/smsc9420.c6
-rw-r--r--drivers/net/sonic.c6
-rw-r--r--drivers/net/spider_net.c6
-rw-r--r--drivers/net/starfire.c10
-rw-r--r--drivers/net/stmmac/dwmac100.c8
-rw-r--r--drivers/net/stmmac/dwmac1000_core.c6
-rw-r--r--drivers/net/stmmac/stmmac_main.c13
-rw-r--r--drivers/net/sun3_82586.c6
-rw-r--r--drivers/net/sunbmac.c6
-rw-r--r--drivers/net/sundance.c6
-rw-r--r--drivers/net/sungem.c6
-rw-r--r--drivers/net/sunhme.c12
-rw-r--r--drivers/net/sunlance.c6
-rw-r--r--drivers/net/sunqe.c6
-rw-r--r--drivers/net/sunvnet.c8
-rw-r--r--drivers/net/tc35815.c6
-rw-r--r--drivers/net/tehuti.c7
-rw-r--r--drivers/net/tg3.c679
-rw-r--r--drivers/net/tg3.h8
-rw-r--r--drivers/net/tlan.c10
-rw-r--r--drivers/net/tokenring/3c359.c112
-rw-r--r--drivers/net/tokenring/ibmtr.c12
-rw-r--r--drivers/net/tokenring/lanstreamer.c58
-rw-r--r--drivers/net/tokenring/olympic.c74
-rw-r--r--drivers/net/tokenring/tms380tr.c16
-rw-r--r--drivers/net/tsi108_eth.c12
-rw-r--r--drivers/net/tulip/de2104x.c12
-rw-r--r--drivers/net/tulip/de4x5.c14
-rw-r--r--drivers/net/tulip/dmfe.c12
-rw-r--r--drivers/net/tulip/tulip_core.c27
-rw-r--r--drivers/net/tulip/uli526x.c6
-rw-r--r--drivers/net/tulip/winbond-840.c12
-rw-r--r--drivers/net/tulip/xircom_cb.c6
-rw-r--r--drivers/net/typhoon.c6
-rw-r--r--drivers/net/ucc_geth.c10
-rw-r--r--drivers/net/usb/asix.c16
-rw-r--r--drivers/net/usb/catc.c6
-rw-r--r--drivers/net/usb/dm9601.c6
-rw-r--r--drivers/net/usb/mcs7830.c6
-rw-r--r--drivers/net/usb/smsc75xx.c6
-rw-r--r--drivers/net/usb/smsc95xx.c6
-rw-r--r--drivers/net/usb/usbnet.c15
-rw-r--r--drivers/net/via-rhine.c6
-rw-r--r--drivers/net/via-velocity.c120
-rw-r--r--drivers/net/via-velocity.h77
-rw-r--r--drivers/net/virtio_net.c7
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c6
-rw-r--r--drivers/net/vxge/vxge-config.c20
-rw-r--r--drivers/net/vxge/vxge-config.h20
-rw-r--r--drivers/net/vxge/vxge-ethtool.c5
-rw-r--r--drivers/net/vxge/vxge-main.c173
-rw-r--r--drivers/net/vxge/vxge-main.h1
-rw-r--r--drivers/net/vxge/vxge-traffic.c53
-rw-r--r--drivers/net/vxge/vxge-traffic.h50
-rw-r--r--drivers/net/vxge/vxge-version.h4
-rw-r--r--drivers/net/wan/pc300_drv.c2
-rw-r--r--drivers/net/wan/pc300_tty.c2
-rw-r--r--drivers/net/wan/sdla.c2
-rw-r--r--drivers/net/wimax/i2400m/tx.c2
-rw-r--r--drivers/net/wireless/adm8211.c12
-rw-r--r--drivers/net/wireless/airo.c37
-rw-r--r--drivers/net/wireless/ath/Kconfig2
-rw-r--r--drivers/net/wireless/ath/ar9170/main.c14
-rw-r--r--drivers/net/wireless/ath/ath5k/ath5k.h257
-rw-r--r--drivers/net/wireless/ath/ath5k/attach.c5
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c167
-rw-r--r--drivers/net/wireless/ath/ath5k/base.h20
-rw-r--r--drivers/net/wireless/ath/ath5k/caps.c3
-rw-r--r--drivers/net/wireless/ath/ath5k/debug.c212
-rw-r--r--drivers/net/wireless/ath/ath5k/debug.h2
-rw-r--r--drivers/net/wireless/ath/ath5k/desc.c18
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.h88
-rw-r--r--drivers/net/wireless/ath/ath5k/pcu.c306
-rw-r--r--drivers/net/wireless/ath/ath5k/phy.c38
-rw-r--r--drivers/net/wireless/ath/ath5k/qcu.c17
-rw-r--r--drivers/net/wireless/ath/ath5k/reg.h2
-rw-r--r--drivers/net/wireless/ath/ath5k/reset.c38
-rw-r--r--drivers/net/wireless/ath/ath9k/Kconfig21
-rw-r--r--drivers/net/wireless/ath/ath9k/Makefile10
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.c25
-rw-r--r--drivers/net/wireless/ath/ath9k/common.c421
-rw-r--r--drivers/net/wireless/ath/ath9k/common.h17
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c993
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.h105
-rw-r--r--drivers/net/wireless/ath/ath9k/htc.h441
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_beacon.c260
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_init.c713
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c1626
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_txrx.c604
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_hst.c463
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_hst.h246
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c150
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h9
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/initvals.h141
-rw-r--r--drivers/net/wireless/ath/ath9k/mac.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/mac.h26
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.h5
-rw-r--r--drivers/net/wireless/ath/ath9k/reg.h3
-rw-r--r--drivers/net/wireless/ath/ath9k/wmi.c319
-rw-r--r--drivers/net/wireless/ath/ath9k/wmi.h126
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c4
-rw-r--r--drivers/net/wireless/ath/debug.h1
-rw-r--r--drivers/net/wireless/b43/b43.h1
-rw-r--r--drivers/net/wireless/b43/main.c5
-rw-r--r--drivers/net/wireless/b43/phy_n.c463
-rw-r--r--drivers/net/wireless/b43/phy_n.h21
-rw-r--r--drivers/net/wireless/b43/tables_nphy.h9
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2100.c10
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c101
-rw-r--r--drivers/net/wireless/ipw2x00/libipw.h14
-rw-r--r--drivers/net/wireless/ipw2x00/libipw_module.c13
-rw-r--r--drivers/net/wireless/iwlwifi/Makefile2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-hw.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c89
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c64
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c25
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c68
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c25
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ict.c305
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c137
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.h8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c262
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h74
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c520
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h27
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c82
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h113
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-helpers.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-prph.h14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c179
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c648
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.h20
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c117
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c150
-rw-r--r--drivers/net/wireless/iwmc3200wifi/Kconfig9
-rw-r--r--drivers/net/wireless/iwmc3200wifi/Makefile3
-rw-r--r--drivers/net/wireless/iwmc3200wifi/cfg80211.c17
-rw-r--r--drivers/net/wireless/iwmc3200wifi/commands.c14
-rw-r--r--drivers/net/wireless/iwmc3200wifi/commands.h1
-rw-r--r--drivers/net/wireless/iwmc3200wifi/debugfs.c13
-rw-r--r--drivers/net/wireless/iwmc3200wifi/hal.c15
-rw-r--r--drivers/net/wireless/iwmc3200wifi/hal.h5
-rw-r--r--drivers/net/wireless/iwmc3200wifi/iwm.h3
-rw-r--r--drivers/net/wireless/iwmc3200wifi/main.c9
-rw-r--r--drivers/net/wireless/iwmc3200wifi/rx.c76
-rw-r--r--drivers/net/wireless/iwmc3200wifi/trace.c3
-rw-r--r--drivers/net/wireless/iwmc3200wifi/trace.h283
-rw-r--r--drivers/net/wireless/iwmc3200wifi/tx.c8
-rw-r--r--drivers/net/wireless/iwmc3200wifi/umac.h2
-rw-r--r--drivers/net/wireless/libertas/assoc.c22
-rw-r--r--drivers/net/wireless/libertas/dev.h1
-rw-r--r--drivers/net/wireless/libertas/main.c13
-rw-r--r--drivers/net/wireless/libertas/rx.c50
-rw-r--r--drivers/net/wireless/libertas/wext.c4
-rw-r--r--drivers/net/wireless/libertas_tf/main.c14
-rw-r--r--drivers/net/wireless/mwl8k.c24
-rw-r--r--drivers/net/wireless/orinoco/Kconfig13
-rw-r--r--drivers/net/wireless/orinoco/hw.c13
-rw-r--r--drivers/net/wireless/orinoco/hw.h1
-rw-r--r--drivers/net/wireless/orinoco/orinoco_cs.c79
-rw-r--r--drivers/net/wireless/orinoco/wext.c94
-rw-r--r--drivers/net/wireless/p54/main.c1
-rw-r--r--drivers/net/wireless/ray_cs.c224
-rw-r--r--drivers/net/wireless/rndis_wlan.c370
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c93
-rw-r--r--drivers/net/wireless/rtl818x/rtl8180_dev.c6
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_dev.c4
-rw-r--r--drivers/net/wireless/wl12xx/Kconfig24
-rw-r--r--drivers/net/wireless/wl12xx/Makefile6
-rw-r--r--drivers/net/wireless/wl12xx/wl1251.h2
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_boot.c3
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_io.h20
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_main.c4
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_ps.c8
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_sdio.c52
-rw-r--r--drivers/net/wireless/wl12xx/wl1271.h40
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_acx.c33
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_acx.h68
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_boot.c11
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_cmd.c226
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_cmd.h14
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_conf.h330
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_debugfs.c12
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_event.c3
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_init.c4
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_io.c87
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_io.h135
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_main.c855
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_ps.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_rx.c11
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_sdio.c291
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_spi.c250
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_spi.h96
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_testmode.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_tx.c94
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_tx.h7
-rw-r--r--drivers/net/wireless/wl3501_cs.c52
-rw-r--r--drivers/net/wireless/zd1201.c6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c13
-rw-r--r--drivers/net/xilinx_emaclite.c1
-rw-r--r--drivers/net/yellowfin.c12
-rw-r--r--drivers/s390/net/qeth_l2_main.c5
-rw-r--r--drivers/s390/net/qeth_l3_main.c2
-rw-r--r--drivers/scsi/fcoe/fcoe.c18
-rw-r--r--drivers/ssb/driver_chipcommon.c1
-rw-r--r--drivers/staging/arlan/arlan-main.c9
-rw-r--r--drivers/staging/et131x/et131x_netdev.c6
-rw-r--r--drivers/staging/slicoss/slicoss.c6
-rw-r--r--drivers/staging/vt6655/device_main.c6
-rw-r--r--drivers/staging/vt6656/main_usb.c6
-rw-r--r--drivers/staging/wavelan/wavelan.c10
-rw-r--r--drivers/staging/wavelan/wavelan_cs.c12
-rw-r--r--drivers/staging/winbond/wbusb.c6
-rw-r--r--drivers/staging/wlags49_h2/wl_netdev.c12
433 files changed, 17227 insertions, 10057 deletions
diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
index 91fdde382e82..ce9ef6bc865c 100644
--- a/drivers/infiniband/hw/nes/nes_nic.c
+++ b/drivers/infiniband/hw/nes/nes_nic.c
@@ -876,7 +876,7 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
876 if (!mc_all_on) { 876 if (!mc_all_on) {
877 char *addrs; 877 char *addrs;
878 int i; 878 int i;
879 struct dev_mc_list *mcaddr; 879 struct netdev_hw_addr *ha;
880 880
881 addrs = kmalloc(ETH_ALEN * mc_count, GFP_ATOMIC); 881 addrs = kmalloc(ETH_ALEN * mc_count, GFP_ATOMIC);
882 if (!addrs) { 882 if (!addrs) {
@@ -884,9 +884,8 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
884 goto unlock; 884 goto unlock;
885 } 885 }
886 i = 0; 886 i = 0;
887 netdev_for_each_mc_addr(mcaddr, netdev) 887 netdev_for_each_mc_addr(ha, netdev)
888 memcpy(get_addr(addrs, i++), 888 memcpy(get_addr(addrs, i++), ha->addr, ETH_ALEN);
889 mcaddr->dmi_addr, ETH_ALEN);
890 889
891 perfect_filter_register_address = NES_IDX_PERFECT_FILTER_LOW + 890 perfect_filter_register_address = NES_IDX_PERFECT_FILTER_LOW +
892 pft_entries_preallocated * 0x8; 891 pft_entries_preallocated * 0x8;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index d41ea27be5e1..c8a0f7dab5b0 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -767,11 +767,8 @@ void ipoib_mcast_dev_flush(struct net_device *dev)
767 } 767 }
768} 768}
769 769
770static int ipoib_mcast_addr_is_valid(const u8 *addr, unsigned int addrlen, 770static int ipoib_mcast_addr_is_valid(const u8 *addr, const u8 *broadcast)
771 const u8 *broadcast)
772{ 771{
773 if (addrlen != INFINIBAND_ALEN)
774 return 0;
775 /* reserved QPN, prefix, scope */ 772 /* reserved QPN, prefix, scope */
776 if (memcmp(addr, broadcast, 6)) 773 if (memcmp(addr, broadcast, 6))
777 return 0; 774 return 0;
@@ -786,7 +783,7 @@ void ipoib_mcast_restart_task(struct work_struct *work)
786 struct ipoib_dev_priv *priv = 783 struct ipoib_dev_priv *priv =
787 container_of(work, struct ipoib_dev_priv, restart_task); 784 container_of(work, struct ipoib_dev_priv, restart_task);
788 struct net_device *dev = priv->dev; 785 struct net_device *dev = priv->dev;
789 struct dev_mc_list *mclist; 786 struct netdev_hw_addr *ha;
790 struct ipoib_mcast *mcast, *tmcast; 787 struct ipoib_mcast *mcast, *tmcast;
791 LIST_HEAD(remove_list); 788 LIST_HEAD(remove_list);
792 unsigned long flags; 789 unsigned long flags;
@@ -811,15 +808,13 @@ void ipoib_mcast_restart_task(struct work_struct *work)
811 clear_bit(IPOIB_MCAST_FLAG_FOUND, &mcast->flags); 808 clear_bit(IPOIB_MCAST_FLAG_FOUND, &mcast->flags);
812 809
813 /* Mark all of the entries that are found or don't exist */ 810 /* Mark all of the entries that are found or don't exist */
814 netdev_for_each_mc_addr(mclist, dev) { 811 netdev_for_each_mc_addr(ha, dev) {
815 union ib_gid mgid; 812 union ib_gid mgid;
816 813
817 if (!ipoib_mcast_addr_is_valid(mclist->dmi_addr, 814 if (!ipoib_mcast_addr_is_valid(ha->addr, dev->broadcast))
818 mclist->dmi_addrlen,
819 dev->broadcast))
820 continue; 815 continue;
821 816
822 memcpy(mgid.raw, mclist->dmi_addr + 4, sizeof mgid); 817 memcpy(mgid.raw, ha->addr + 4, sizeof mgid);
823 818
824 mcast = __ipoib_mcast_find(dev, &mgid); 819 mcast = __ipoib_mcast_find(dev, &mgid);
825 if (!mcast || test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) { 820 if (!mcast || test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) {
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 441c0642b30a..cccea412088b 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -1109,14 +1109,14 @@ static int dvb_net_feed_stop(struct net_device *dev)
1109} 1109}
1110 1110
1111 1111
1112static int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc) 1112static int dvb_set_mc_filter(struct net_device *dev, unsigned char *addr)
1113{ 1113{
1114 struct dvb_net_priv *priv = netdev_priv(dev); 1114 struct dvb_net_priv *priv = netdev_priv(dev);
1115 1115
1116 if (priv->multi_num == DVB_NET_MULTICAST_MAX) 1116 if (priv->multi_num == DVB_NET_MULTICAST_MAX)
1117 return -ENOMEM; 1117 return -ENOMEM;
1118 1118
1119 memcpy(priv->multi_macs[priv->multi_num], mc->dmi_addr, 6); 1119 memcpy(priv->multi_macs[priv->multi_num], addr, ETH_ALEN);
1120 1120
1121 priv->multi_num++; 1121 priv->multi_num++;
1122 return 0; 1122 return 0;
@@ -1140,8 +1140,7 @@ static void wq_set_multicast_list (struct work_struct *work)
1140 dprintk("%s: allmulti mode\n", dev->name); 1140 dprintk("%s: allmulti mode\n", dev->name);
1141 priv->rx_mode = RX_MODE_ALL_MULTI; 1141 priv->rx_mode = RX_MODE_ALL_MULTI;
1142 } else if (!netdev_mc_empty(dev)) { 1142 } else if (!netdev_mc_empty(dev)) {
1143 int mci; 1143 struct netdev_hw_addr *ha;
1144 struct dev_mc_list *mc;
1145 1144
1146 dprintk("%s: set_mc_list, %d entries\n", 1145 dprintk("%s: set_mc_list, %d entries\n",
1147 dev->name, netdev_mc_count(dev)); 1146 dev->name, netdev_mc_count(dev));
@@ -1149,11 +1148,8 @@ static void wq_set_multicast_list (struct work_struct *work)
1149 priv->rx_mode = RX_MODE_MULTI; 1148 priv->rx_mode = RX_MODE_MULTI;
1150 priv->multi_num = 0; 1149 priv->multi_num = 0;
1151 1150
1152 for (mci = 0, mc=dev->mc_list; 1151 netdev_for_each_mc_addr(ha, dev)
1153 mci < netdev_mc_count(dev); 1152 dvb_set_mc_filter(dev, ha->addr);
1154 mc = mc->next, mci++) {
1155 dvb_set_mc_filter(dev, mc);
1156 }
1157 } 1153 }
1158 1154
1159 netif_addr_unlock_bh(dev); 1155 netif_addr_unlock_bh(dev);
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index 04b5bba19021..81c8b31e629f 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -1216,7 +1216,7 @@ static int elp_close(struct net_device *dev)
1216static void elp_set_mc_list(struct net_device *dev) 1216static void elp_set_mc_list(struct net_device *dev)
1217{ 1217{
1218 elp_device *adapter = netdev_priv(dev); 1218 elp_device *adapter = netdev_priv(dev);
1219 struct dev_mc_list *dmi; 1219 struct netdev_hw_addr *ha;
1220 int i; 1220 int i;
1221 unsigned long flags; 1221 unsigned long flags;
1222 1222
@@ -1231,8 +1231,9 @@ static void elp_set_mc_list(struct net_device *dev)
1231 adapter->tx_pcb.command = CMD_LOAD_MULTICAST_LIST; 1231 adapter->tx_pcb.command = CMD_LOAD_MULTICAST_LIST;
1232 adapter->tx_pcb.length = 6 * netdev_mc_count(dev); 1232 adapter->tx_pcb.length = 6 * netdev_mc_count(dev);
1233 i = 0; 1233 i = 0;
1234 netdev_for_each_mc_addr(dmi, dev) 1234 netdev_for_each_mc_addr(ha, dev)
1235 memcpy(adapter->tx_pcb.data.multicast[i++], dmi->dmi_addr, 6); 1235 memcpy(adapter->tx_pcb.data.multicast[i++],
1236 ha->addr, 6);
1236 adapter->got[CMD_LOAD_MULTICAST_LIST] = 0; 1237 adapter->got[CMD_LOAD_MULTICAST_LIST] = 0;
1237 if (!send_pcb(dev, &adapter->tx_pcb)) 1238 if (!send_pcb(dev, &adapter->tx_pcb))
1238 pr_err("%s: couldn't send set_multicast command\n", dev->name); 1239 pr_err("%s: couldn't send set_multicast command\n", dev->name);
diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c
index beed4fa10c6e..966cb12e1e0a 100644
--- a/drivers/net/3c523.c
+++ b/drivers/net/3c523.c
@@ -625,7 +625,7 @@ static int init586(struct net_device *dev)
625 volatile struct iasetup_cmd_struct *ias_cmd; 625 volatile struct iasetup_cmd_struct *ias_cmd;
626 volatile struct tdr_cmd_struct *tdr_cmd; 626 volatile struct tdr_cmd_struct *tdr_cmd;
627 volatile struct mcsetup_cmd_struct *mc_cmd; 627 volatile struct mcsetup_cmd_struct *mc_cmd;
628 struct dev_mc_list *dmi; 628 struct netdev_hw_addr *ha;
629 int num_addrs = netdev_mc_count(dev); 629 int num_addrs = netdev_mc_count(dev);
630 630
631 ptr = (void *) ((char *) p->scb + sizeof(struct scb_struct)); 631 ptr = (void *) ((char *) p->scb + sizeof(struct scb_struct));
@@ -788,8 +788,9 @@ static int init586(struct net_device *dev)
788 mc_cmd->cmd_link = 0xffff; 788 mc_cmd->cmd_link = 0xffff;
789 mc_cmd->mc_cnt = num_addrs * 6; 789 mc_cmd->mc_cnt = num_addrs * 6;
790 i = 0; 790 i = 0;
791 netdev_for_each_mc_addr(dmi, dev) 791 netdev_for_each_mc_addr(ha, dev)
792 memcpy((char *) mc_cmd->mc_list[i++], dmi->dmi_addr, 6); 792 memcpy((char *) mc_cmd->mc_list[i++],
793 ha->addr, 6);
793 p->scb->cbl_offset = make16(mc_cmd); 794 p->scb->cbl_offset = make16(mc_cmd);
794 p->scb->cmd = CUC_START; 795 p->scb->cmd = CUC_START;
795 elmc_id_attn586(); 796 elmc_id_attn586();
diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c
index 5c07b147ec99..38395dfa4963 100644
--- a/drivers/net/3c527.c
+++ b/drivers/net/3c527.c
@@ -1533,7 +1533,7 @@ static void do_mc32_set_multicast_list(struct net_device *dev, int retry)
1533 { 1533 {
1534 unsigned char block[62]; 1534 unsigned char block[62];
1535 unsigned char *bp; 1535 unsigned char *bp;
1536 struct dev_mc_list *dmc; 1536 struct netdev_hw_addr *ha;
1537 1537
1538 if(retry==0) 1538 if(retry==0)
1539 lp->mc_list_valid = 0; 1539 lp->mc_list_valid = 0;
@@ -1543,8 +1543,8 @@ static void do_mc32_set_multicast_list(struct net_device *dev, int retry)
1543 block[0]=netdev_mc_count(dev); 1543 block[0]=netdev_mc_count(dev);
1544 bp=block+2; 1544 bp=block+2;
1545 1545
1546 netdev_for_each_mc_addr(dmc, dev) { 1546 netdev_for_each_mc_addr(ha, dev) {
1547 memcpy(bp, dmc->dmi_addr, 6); 1547 memcpy(bp, ha->addr, 6);
1548 bp+=6; 1548 bp+=6;
1549 } 1549 }
1550 if(mc32_command_nowait(dev, 2, block, 1550 if(mc32_command_nowait(dev, 2, block,
diff --git a/drivers/net/7990.c b/drivers/net/7990.c
index 4e9a5a20b6a6..818837d8ffe7 100644
--- a/drivers/net/7990.c
+++ b/drivers/net/7990.c
@@ -595,7 +595,7 @@ static void lance_load_multicast (struct net_device *dev)
595 struct lance_private *lp = netdev_priv(dev); 595 struct lance_private *lp = netdev_priv(dev);
596 volatile struct lance_init_block *ib = lp->init_block; 596 volatile struct lance_init_block *ib = lp->init_block;
597 volatile u16 *mcast_table = (u16 *)&ib->filter; 597 volatile u16 *mcast_table = (u16 *)&ib->filter;
598 struct dev_mc_list *dmi; 598 struct netdev_hw_addr *ha;
599 char *addrs; 599 char *addrs;
600 u32 crc; 600 u32 crc;
601 601
@@ -610,8 +610,8 @@ static void lance_load_multicast (struct net_device *dev)
610 ib->filter [1] = 0; 610 ib->filter [1] = 0;
611 611
612 /* Add addresses */ 612 /* Add addresses */
613 netdev_for_each_mc_addr(dmi, dev) { 613 netdev_for_each_mc_addr(ha, dev) {
614 addrs = dmi->dmi_addr; 614 addrs = ha->addr;
615 615
616 /* multicast address? */ 616 /* multicast address? */
617 if (!(*addrs & 1)) 617 if (!(*addrs & 1))
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index 3d4406b16658..e4e2aef11017 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -909,11 +909,11 @@ static void __cp_set_rx_mode (struct net_device *dev)
909 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; 909 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
910 mc_filter[1] = mc_filter[0] = 0xffffffff; 910 mc_filter[1] = mc_filter[0] = 0xffffffff;
911 } else { 911 } else {
912 struct dev_mc_list *mclist; 912 struct netdev_hw_addr *ha;
913 rx_mode = AcceptBroadcast | AcceptMyPhys; 913 rx_mode = AcceptBroadcast | AcceptMyPhys;
914 mc_filter[1] = mc_filter[0] = 0; 914 mc_filter[1] = mc_filter[0] = 0;
915 netdev_for_each_mc_addr(mclist, dev) { 915 netdev_for_each_mc_addr(ha, dev) {
916 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; 916 int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
917 917
918 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); 918 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
919 rx_mode |= AcceptMulticast; 919 rx_mode |= AcceptMulticast;
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index b4efc913978b..f61784c3c4a2 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -2502,11 +2502,11 @@ static void __set_rx_mode (struct net_device *dev)
2502 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; 2502 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
2503 mc_filter[1] = mc_filter[0] = 0xffffffff; 2503 mc_filter[1] = mc_filter[0] = 0xffffffff;
2504 } else { 2504 } else {
2505 struct dev_mc_list *mclist; 2505 struct netdev_hw_addr *ha;
2506 rx_mode = AcceptBroadcast | AcceptMyPhys; 2506 rx_mode = AcceptBroadcast | AcceptMyPhys;
2507 mc_filter[1] = mc_filter[0] = 0; 2507 mc_filter[1] = mc_filter[0] = 0;
2508 netdev_for_each_mc_addr(mclist, dev) { 2508 netdev_for_each_mc_addr(ha, dev) {
2509 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; 2509 int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
2510 2510
2511 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); 2511 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
2512 rx_mode |= AcceptMulticast; 2512 rx_mode |= AcceptMulticast;
diff --git a/drivers/net/82596.c b/drivers/net/82596.c
index f94d17d78bb0..3a28b1f451d9 100644
--- a/drivers/net/82596.c
+++ b/drivers/net/82596.c
@@ -1542,7 +1542,7 @@ static void set_multicast_list(struct net_device *dev)
1542 } 1542 }
1543 1543
1544 if (!netdev_mc_empty(dev)) { 1544 if (!netdev_mc_empty(dev)) {
1545 struct dev_mc_list *dmi; 1545 struct netdev_hw_addr *ha;
1546 unsigned char *cp; 1546 unsigned char *cp;
1547 struct mc_cmd *cmd; 1547 struct mc_cmd *cmd;
1548 1548
@@ -1552,10 +1552,10 @@ static void set_multicast_list(struct net_device *dev)
1552 cmd->cmd.command = CmdMulticastList; 1552 cmd->cmd.command = CmdMulticastList;
1553 cmd->mc_cnt = cnt * ETH_ALEN; 1553 cmd->mc_cnt = cnt * ETH_ALEN;
1554 cp = cmd->mc_addrs; 1554 cp = cmd->mc_addrs;
1555 netdev_for_each_mc_addr(dmi, dev) { 1555 netdev_for_each_mc_addr(ha, dev) {
1556 if (!cnt--) 1556 if (!cnt--)
1557 break; 1557 break;
1558 memcpy(cp, dmi->dmi_addr, ETH_ALEN); 1558 memcpy(cp, ha->addr, ETH_ALEN);
1559 if (i596_debug > 1) 1559 if (i596_debug > 1)
1560 DEB(DEB_MULTI,printk(KERN_INFO "%s: Adding address %pM\n", 1560 DEB(DEB_MULTI,printk(KERN_INFO "%s: Adding address %pM\n",
1561 dev->name, cp)); 1561 dev->name, cp));
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 7b832c727f87..65db201fd77e 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1916,6 +1916,7 @@ config FEC
1916 bool "FEC ethernet controller (of ColdFire and some i.MX CPUs)" 1916 bool "FEC ethernet controller (of ColdFire and some i.MX CPUs)"
1917 depends on M523x || M527x || M5272 || M528x || M520x || M532x || \ 1917 depends on M523x || M527x || M5272 || M528x || M520x || M532x || \
1918 MACH_MX27 || ARCH_MX35 || ARCH_MX25 || ARCH_MX5 1918 MACH_MX27 || ARCH_MX35 || ARCH_MX25 || ARCH_MX5
1919 select PHYLIB
1919 help 1920 help
1920 Say Y here if you want to use the built-in 10/100 Fast ethernet 1921 Say Y here if you want to use the built-in 10/100 Fast ethernet
1921 controller on some Motorola ColdFire and Freescale i.MX processors. 1922 controller on some Motorola ColdFire and Freescale i.MX processors.
@@ -2434,8 +2435,8 @@ config MV643XX_ETH
2434 2435
2435config XILINX_LL_TEMAC 2436config XILINX_LL_TEMAC
2436 tristate "Xilinx LL TEMAC (LocalLink Tri-mode Ethernet MAC) driver" 2437 tristate "Xilinx LL TEMAC (LocalLink Tri-mode Ethernet MAC) driver"
2438 depends on PPC || MICROBLAZE
2437 select PHYLIB 2439 select PHYLIB
2438 depends on PPC_DCR_NATIVE
2439 help 2440 help
2440 This driver supports the Xilinx 10/100/1000 LocalLink TEMAC 2441 This driver supports the Xilinx 10/100/1000 LocalLink TEMAC
2441 core used in Xilinx Spartan and Virtex FPGAs 2442 core used in Xilinx Spartan and Virtex FPGAs
@@ -2618,11 +2619,11 @@ config EHEA
2618 will be called ehea. 2619 will be called ehea.
2619 2620
2620config ENIC 2621config ENIC
2621 tristate "Cisco 10G Ethernet NIC support" 2622 tristate "Cisco VIC Ethernet NIC Support"
2622 depends on PCI && INET 2623 depends on PCI && INET
2623 select INET_LRO 2624 select INET_LRO
2624 help 2625 help
2625 This enables the support for the Cisco 10G Ethernet card. 2626 This enables the support for the Cisco VIC Ethernet card.
2626 2627
2627config IXGBE 2628config IXGBE
2628 tristate "Intel(R) 10GbE PCI Express adapters support" 2629 tristate "Intel(R) 10GbE PCI Express adapters support"
@@ -2862,6 +2863,8 @@ source "drivers/ieee802154/Kconfig"
2862 2863
2863source "drivers/s390/net/Kconfig" 2864source "drivers/s390/net/Kconfig"
2864 2865
2866source "drivers/net/caif/Kconfig"
2867
2865config XEN_NETDEV_FRONTEND 2868config XEN_NETDEV_FRONTEND
2866 tristate "Xen network device frontend driver" 2869 tristate "Xen network device frontend driver"
2867 depends on XEN 2870 depends on XEN
@@ -3180,17 +3183,12 @@ config PPPOATM
3180 3183
3181config PPPOL2TP 3184config PPPOL2TP
3182 tristate "PPP over L2TP (EXPERIMENTAL)" 3185 tristate "PPP over L2TP (EXPERIMENTAL)"
3183 depends on EXPERIMENTAL && PPP && INET 3186 depends on EXPERIMENTAL && L2TP && PPP
3184 help 3187 help
3185 Support for PPP-over-L2TP socket family. L2TP is a protocol 3188 Support for PPP-over-L2TP socket family. L2TP is a protocol
3186 used by ISPs and enterprises to tunnel PPP traffic over UDP 3189 used by ISPs and enterprises to tunnel PPP traffic over UDP
3187 tunnels. L2TP is replacing PPTP for VPN uses. 3190 tunnels. L2TP is replacing PPTP for VPN uses.
3188 3191
3189 This kernel component handles only L2TP data packets: a
3190 userland daemon handles L2TP the control protocol (tunnel
3191 and session setup). One such daemon is OpenL2TP
3192 (http://openl2tp.sourceforge.net/).
3193
3194config SLIP 3192config SLIP
3195 tristate "SLIP (serial line) support" 3193 tristate "SLIP (serial line) support"
3196 ---help--- 3194 ---help---
@@ -3277,15 +3275,14 @@ config NET_FC
3277 "SCSI generic support". 3275 "SCSI generic support".
3278 3276
3279config NETCONSOLE 3277config NETCONSOLE
3280 tristate "Network console logging support (EXPERIMENTAL)" 3278 tristate "Network console logging support"
3281 depends on EXPERIMENTAL
3282 ---help--- 3279 ---help---
3283 If you want to log kernel messages over the network, enable this. 3280 If you want to log kernel messages over the network, enable this.
3284 See <file:Documentation/networking/netconsole.txt> for details. 3281 See <file:Documentation/networking/netconsole.txt> for details.
3285 3282
3286config NETCONSOLE_DYNAMIC 3283config NETCONSOLE_DYNAMIC
3287 bool "Dynamic reconfiguration of logging targets (EXPERIMENTAL)" 3284 bool "Dynamic reconfiguration of logging targets"
3288 depends on NETCONSOLE && SYSFS && EXPERIMENTAL 3285 depends on NETCONSOLE && SYSFS
3289 select CONFIGFS_FS 3286 select CONFIGFS_FS
3290 help 3287 help
3291 This option enables the ability to dynamically reconfigure target 3288 This option enables the ability to dynamically reconfigure target
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index a583b50d9de8..ebf80b983063 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -161,7 +161,7 @@ obj-$(CONFIG_PPP_DEFLATE) += ppp_deflate.o
161obj-$(CONFIG_PPP_BSDCOMP) += bsd_comp.o 161obj-$(CONFIG_PPP_BSDCOMP) += bsd_comp.o
162obj-$(CONFIG_PPP_MPPE) += ppp_mppe.o 162obj-$(CONFIG_PPP_MPPE) += ppp_mppe.o
163obj-$(CONFIG_PPPOE) += pppox.o pppoe.o 163obj-$(CONFIG_PPPOE) += pppox.o pppoe.o
164obj-$(CONFIG_PPPOL2TP) += pppox.o pppol2tp.o 164obj-$(CONFIG_PPPOL2TP) += pppox.o
165 165
166obj-$(CONFIG_SLIP) += slip.o 166obj-$(CONFIG_SLIP) += slip.o
167obj-$(CONFIG_SLHC) += slhc.o 167obj-$(CONFIG_SLHC) += slhc.o
@@ -291,5 +291,6 @@ obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
291obj-$(CONFIG_SFC) += sfc/ 291obj-$(CONFIG_SFC) += sfc/
292 292
293obj-$(CONFIG_WIMAX) += wimax/ 293obj-$(CONFIG_WIMAX) += wimax/
294obj-$(CONFIG_CAIF) += caif/
294 295
295obj-$(CONFIG_OCTEON_MGMT_ETHERNET) += octeon/ 296obj-$(CONFIG_OCTEON_MGMT_ETHERNET) += octeon/
diff --git a/drivers/net/a2065.c b/drivers/net/a2065.c
index bd4d829eca12..7cce643793c3 100644
--- a/drivers/net/a2065.c
+++ b/drivers/net/a2065.c
@@ -603,7 +603,7 @@ static void lance_load_multicast (struct net_device *dev)
603 struct lance_private *lp = netdev_priv(dev); 603 struct lance_private *lp = netdev_priv(dev);
604 volatile struct lance_init_block *ib = lp->init_block; 604 volatile struct lance_init_block *ib = lp->init_block;
605 volatile u16 *mcast_table = (u16 *)&ib->filter; 605 volatile u16 *mcast_table = (u16 *)&ib->filter;
606 struct dev_mc_list *dmi; 606 struct netdev_hw_addr *ha;
607 char *addrs; 607 char *addrs;
608 u32 crc; 608 u32 crc;
609 609
@@ -618,8 +618,8 @@ static void lance_load_multicast (struct net_device *dev)
618 ib->filter [1] = 0; 618 ib->filter [1] = 0;
619 619
620 /* Add addresses */ 620 /* Add addresses */
621 netdev_for_each_mc_addr(dmi, dev) { 621 netdev_for_each_mc_addr(ha, dev) {
622 addrs = dmi->dmi_addr; 622 addrs = ha->addr;
623 623
624 /* multicast address? */ 624 /* multicast address? */
625 if (!(*addrs & 1)) 625 if (!(*addrs & 1))
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c
index 4ae750ef1e10..2dc5f9544c77 100644
--- a/drivers/net/acenic.c
+++ b/drivers/net/acenic.c
@@ -660,7 +660,7 @@ static void __devexit acenic_remove_one(struct pci_dev *pdev)
660 dma_addr_t mapping; 660 dma_addr_t mapping;
661 661
662 ringp = &ap->skb->rx_std_skbuff[i]; 662 ringp = &ap->skb->rx_std_skbuff[i];
663 mapping = pci_unmap_addr(ringp, mapping); 663 mapping = dma_unmap_addr(ringp, mapping);
664 pci_unmap_page(ap->pdev, mapping, 664 pci_unmap_page(ap->pdev, mapping,
665 ACE_STD_BUFSIZE, 665 ACE_STD_BUFSIZE,
666 PCI_DMA_FROMDEVICE); 666 PCI_DMA_FROMDEVICE);
@@ -680,7 +680,7 @@ static void __devexit acenic_remove_one(struct pci_dev *pdev)
680 dma_addr_t mapping; 680 dma_addr_t mapping;
681 681
682 ringp = &ap->skb->rx_mini_skbuff[i]; 682 ringp = &ap->skb->rx_mini_skbuff[i];
683 mapping = pci_unmap_addr(ringp,mapping); 683 mapping = dma_unmap_addr(ringp,mapping);
684 pci_unmap_page(ap->pdev, mapping, 684 pci_unmap_page(ap->pdev, mapping,
685 ACE_MINI_BUFSIZE, 685 ACE_MINI_BUFSIZE,
686 PCI_DMA_FROMDEVICE); 686 PCI_DMA_FROMDEVICE);
@@ -699,7 +699,7 @@ static void __devexit acenic_remove_one(struct pci_dev *pdev)
699 dma_addr_t mapping; 699 dma_addr_t mapping;
700 700
701 ringp = &ap->skb->rx_jumbo_skbuff[i]; 701 ringp = &ap->skb->rx_jumbo_skbuff[i];
702 mapping = pci_unmap_addr(ringp, mapping); 702 mapping = dma_unmap_addr(ringp, mapping);
703 pci_unmap_page(ap->pdev, mapping, 703 pci_unmap_page(ap->pdev, mapping,
704 ACE_JUMBO_BUFSIZE, 704 ACE_JUMBO_BUFSIZE,
705 PCI_DMA_FROMDEVICE); 705 PCI_DMA_FROMDEVICE);
@@ -1682,7 +1682,7 @@ static void ace_load_std_rx_ring(struct ace_private *ap, int nr_bufs)
1682 ACE_STD_BUFSIZE, 1682 ACE_STD_BUFSIZE,
1683 PCI_DMA_FROMDEVICE); 1683 PCI_DMA_FROMDEVICE);
1684 ap->skb->rx_std_skbuff[idx].skb = skb; 1684 ap->skb->rx_std_skbuff[idx].skb = skb;
1685 pci_unmap_addr_set(&ap->skb->rx_std_skbuff[idx], 1685 dma_unmap_addr_set(&ap->skb->rx_std_skbuff[idx],
1686 mapping, mapping); 1686 mapping, mapping);
1687 1687
1688 rd = &ap->rx_std_ring[idx]; 1688 rd = &ap->rx_std_ring[idx];
@@ -1743,7 +1743,7 @@ static void ace_load_mini_rx_ring(struct ace_private *ap, int nr_bufs)
1743 ACE_MINI_BUFSIZE, 1743 ACE_MINI_BUFSIZE,
1744 PCI_DMA_FROMDEVICE); 1744 PCI_DMA_FROMDEVICE);
1745 ap->skb->rx_mini_skbuff[idx].skb = skb; 1745 ap->skb->rx_mini_skbuff[idx].skb = skb;
1746 pci_unmap_addr_set(&ap->skb->rx_mini_skbuff[idx], 1746 dma_unmap_addr_set(&ap->skb->rx_mini_skbuff[idx],
1747 mapping, mapping); 1747 mapping, mapping);
1748 1748
1749 rd = &ap->rx_mini_ring[idx]; 1749 rd = &ap->rx_mini_ring[idx];
@@ -1799,7 +1799,7 @@ static void ace_load_jumbo_rx_ring(struct ace_private *ap, int nr_bufs)
1799 ACE_JUMBO_BUFSIZE, 1799 ACE_JUMBO_BUFSIZE,
1800 PCI_DMA_FROMDEVICE); 1800 PCI_DMA_FROMDEVICE);
1801 ap->skb->rx_jumbo_skbuff[idx].skb = skb; 1801 ap->skb->rx_jumbo_skbuff[idx].skb = skb;
1802 pci_unmap_addr_set(&ap->skb->rx_jumbo_skbuff[idx], 1802 dma_unmap_addr_set(&ap->skb->rx_jumbo_skbuff[idx],
1803 mapping, mapping); 1803 mapping, mapping);
1804 1804
1805 rd = &ap->rx_jumbo_ring[idx]; 1805 rd = &ap->rx_jumbo_ring[idx];
@@ -2012,7 +2012,7 @@ static void ace_rx_int(struct net_device *dev, u32 rxretprd, u32 rxretcsm)
2012 skb = rip->skb; 2012 skb = rip->skb;
2013 rip->skb = NULL; 2013 rip->skb = NULL;
2014 pci_unmap_page(ap->pdev, 2014 pci_unmap_page(ap->pdev,
2015 pci_unmap_addr(rip, mapping), 2015 dma_unmap_addr(rip, mapping),
2016 mapsize, 2016 mapsize,
2017 PCI_DMA_FROMDEVICE); 2017 PCI_DMA_FROMDEVICE);
2018 skb_put(skb, retdesc->size); 2018 skb_put(skb, retdesc->size);
@@ -2077,18 +2077,16 @@ static inline void ace_tx_int(struct net_device *dev,
2077 2077
2078 do { 2078 do {
2079 struct sk_buff *skb; 2079 struct sk_buff *skb;
2080 dma_addr_t mapping;
2081 struct tx_ring_info *info; 2080 struct tx_ring_info *info;
2082 2081
2083 info = ap->skb->tx_skbuff + idx; 2082 info = ap->skb->tx_skbuff + idx;
2084 skb = info->skb; 2083 skb = info->skb;
2085 mapping = pci_unmap_addr(info, mapping);
2086 2084
2087 if (mapping) { 2085 if (dma_unmap_len(info, maplen)) {
2088 pci_unmap_page(ap->pdev, mapping, 2086 pci_unmap_page(ap->pdev, dma_unmap_addr(info, mapping),
2089 pci_unmap_len(info, maplen), 2087 dma_unmap_len(info, maplen),
2090 PCI_DMA_TODEVICE); 2088 PCI_DMA_TODEVICE);
2091 pci_unmap_addr_set(info, mapping, 0); 2089 dma_unmap_len_set(info, maplen, 0);
2092 } 2090 }
2093 2091
2094 if (skb) { 2092 if (skb) {
@@ -2376,14 +2374,12 @@ static int ace_close(struct net_device *dev)
2376 2374
2377 for (i = 0; i < ACE_TX_RING_ENTRIES(ap); i++) { 2375 for (i = 0; i < ACE_TX_RING_ENTRIES(ap); i++) {
2378 struct sk_buff *skb; 2376 struct sk_buff *skb;
2379 dma_addr_t mapping;
2380 struct tx_ring_info *info; 2377 struct tx_ring_info *info;
2381 2378
2382 info = ap->skb->tx_skbuff + i; 2379 info = ap->skb->tx_skbuff + i;
2383 skb = info->skb; 2380 skb = info->skb;
2384 mapping = pci_unmap_addr(info, mapping);
2385 2381
2386 if (mapping) { 2382 if (dma_unmap_len(info, maplen)) {
2387 if (ACE_IS_TIGON_I(ap)) { 2383 if (ACE_IS_TIGON_I(ap)) {
2388 /* NB: TIGON_1 is special, tx_ring is in io space */ 2384 /* NB: TIGON_1 is special, tx_ring is in io space */
2389 struct tx_desc __iomem *tx; 2385 struct tx_desc __iomem *tx;
@@ -2394,10 +2390,10 @@ static int ace_close(struct net_device *dev)
2394 } else 2390 } else
2395 memset(ap->tx_ring + i, 0, 2391 memset(ap->tx_ring + i, 0,
2396 sizeof(struct tx_desc)); 2392 sizeof(struct tx_desc));
2397 pci_unmap_page(ap->pdev, mapping, 2393 pci_unmap_page(ap->pdev, dma_unmap_addr(info, mapping),
2398 pci_unmap_len(info, maplen), 2394 dma_unmap_len(info, maplen),
2399 PCI_DMA_TODEVICE); 2395 PCI_DMA_TODEVICE);
2400 pci_unmap_addr_set(info, mapping, 0); 2396 dma_unmap_len_set(info, maplen, 0);
2401 } 2397 }
2402 if (skb) { 2398 if (skb) {
2403 dev_kfree_skb(skb); 2399 dev_kfree_skb(skb);
@@ -2432,8 +2428,8 @@ ace_map_tx_skb(struct ace_private *ap, struct sk_buff *skb,
2432 2428
2433 info = ap->skb->tx_skbuff + idx; 2429 info = ap->skb->tx_skbuff + idx;
2434 info->skb = tail; 2430 info->skb = tail;
2435 pci_unmap_addr_set(info, mapping, mapping); 2431 dma_unmap_addr_set(info, mapping, mapping);
2436 pci_unmap_len_set(info, maplen, skb->len); 2432 dma_unmap_len_set(info, maplen, skb->len);
2437 return mapping; 2433 return mapping;
2438} 2434}
2439 2435
@@ -2552,8 +2548,8 @@ restart:
2552 } else { 2548 } else {
2553 info->skb = NULL; 2549 info->skb = NULL;
2554 } 2550 }
2555 pci_unmap_addr_set(info, mapping, mapping); 2551 dma_unmap_addr_set(info, mapping, mapping);
2556 pci_unmap_len_set(info, maplen, frag->size); 2552 dma_unmap_len_set(info, maplen, frag->size);
2557 ace_load_tx_bd(ap, desc, mapping, flagsize, vlan_tag); 2553 ace_load_tx_bd(ap, desc, mapping, flagsize, vlan_tag);
2558 } 2554 }
2559 } 2555 }
diff --git a/drivers/net/acenic.h b/drivers/net/acenic.h
index 17079b927ffa..0681da7e8753 100644
--- a/drivers/net/acenic.h
+++ b/drivers/net/acenic.h
@@ -589,7 +589,7 @@ struct ace_info {
589 589
590struct ring_info { 590struct ring_info {
591 struct sk_buff *skb; 591 struct sk_buff *skb;
592 DECLARE_PCI_UNMAP_ADDR(mapping) 592 DEFINE_DMA_UNMAP_ADDR(mapping);
593}; 593};
594 594
595 595
@@ -600,8 +600,8 @@ struct ring_info {
600 */ 600 */
601struct tx_ring_info { 601struct tx_ring_info {
602 struct sk_buff *skb; 602 struct sk_buff *skb;
603 DECLARE_PCI_UNMAP_ADDR(mapping) 603 DEFINE_DMA_UNMAP_ADDR(mapping);
604 DECLARE_PCI_UNMAP_LEN(maplen) 604 DEFINE_DMA_UNMAP_LEN(maplen);
605}; 605};
606 606
607 607
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index b8a59d255b49..d002c764a26c 100644
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -1377,7 +1377,7 @@ list to the device.
1377*/ 1377*/
1378static void amd8111e_set_multicast_list(struct net_device *dev) 1378static void amd8111e_set_multicast_list(struct net_device *dev)
1379{ 1379{
1380 struct dev_mc_list *mc_ptr; 1380 struct netdev_hw_addr *ha;
1381 struct amd8111e_priv *lp = netdev_priv(dev); 1381 struct amd8111e_priv *lp = netdev_priv(dev);
1382 u32 mc_filter[2] ; 1382 u32 mc_filter[2] ;
1383 int bit_num; 1383 int bit_num;
@@ -1408,8 +1408,8 @@ static void amd8111e_set_multicast_list(struct net_device *dev)
1408 /* load all the multicast addresses in the logic filter */ 1408 /* load all the multicast addresses in the logic filter */
1409 lp->options |= OPTION_MULTICAST_ENABLE; 1409 lp->options |= OPTION_MULTICAST_ENABLE;
1410 mc_filter[1] = mc_filter[0] = 0; 1410 mc_filter[1] = mc_filter[0] = 0;
1411 netdev_for_each_mc_addr(mc_ptr, dev) { 1411 netdev_for_each_mc_addr(ha, dev) {
1412 bit_num = (ether_crc_le(ETH_ALEN, mc_ptr->dmi_addr) >> 26) & 0x3f; 1412 bit_num = (ether_crc_le(ETH_ALEN, ha->addr) >> 26) & 0x3f;
1413 mc_filter[bit_num >> 5] |= 1 << (bit_num & 31); 1413 mc_filter[bit_num >> 5] |= 1 << (bit_num & 31);
1414 } 1414 }
1415 amd8111e_writeq(*(u64*)mc_filter,lp->mmio+ LADRF); 1415 amd8111e_writeq(*(u64*)mc_filter,lp->mmio+ LADRF);
diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
index f1f58c5e27bf..a4b5b08276f8 100644
--- a/drivers/net/arm/am79c961a.c
+++ b/drivers/net/arm/am79c961a.c
@@ -383,12 +383,12 @@ static void am79c961_setmulticastlist (struct net_device *dev)
383 } else if (dev->flags & IFF_ALLMULTI) { 383 } else if (dev->flags & IFF_ALLMULTI) {
384 memset(multi_hash, 0xff, sizeof(multi_hash)); 384 memset(multi_hash, 0xff, sizeof(multi_hash));
385 } else { 385 } else {
386 struct dev_mc_list *dmi; 386 struct netdev_hw_addr *ha;
387 387
388 memset(multi_hash, 0x00, sizeof(multi_hash)); 388 memset(multi_hash, 0x00, sizeof(multi_hash));
389 389
390 netdev_for_each_mc_addr(dmi, dev) 390 netdev_for_each_mc_addr(ha, dev)
391 am79c961_mc_hash(dmi->dmi_addr, multi_hash); 391 am79c961_mc_hash(ha->addr, multi_hash);
392 } 392 }
393 393
394 spin_lock_irqsave(&priv->chip_lock, flags); 394 spin_lock_irqsave(&priv->chip_lock, flags);
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
index 8b23d5a175bf..f31e8b6cbf73 100644
--- a/drivers/net/arm/at91_ether.c
+++ b/drivers/net/arm/at91_ether.c
@@ -556,14 +556,14 @@ static int hash_get_index(__u8 *addr)
556 */ 556 */
557static void at91ether_sethashtable(struct net_device *dev) 557static void at91ether_sethashtable(struct net_device *dev)
558{ 558{
559 struct dev_mc_list *curr; 559 struct netdev_hw_addr *ha;
560 unsigned long mc_filter[2]; 560 unsigned long mc_filter[2];
561 unsigned int bitnr; 561 unsigned int bitnr;
562 562
563 mc_filter[0] = mc_filter[1] = 0; 563 mc_filter[0] = mc_filter[1] = 0;
564 564
565 netdev_for_each_mc_addr(curr, dev) { 565 netdev_for_each_mc_addr(ha, dev) {
566 bitnr = hash_get_index(curr->dmi_addr); 566 bitnr = hash_get_index(ha->addr);
567 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31); 567 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
568 } 568 }
569 569
diff --git a/drivers/net/arm/ixp4xx_eth.c b/drivers/net/arm/ixp4xx_eth.c
index 6e2ae1d06df1..f9d168775d06 100644
--- a/drivers/net/arm/ixp4xx_eth.c
+++ b/drivers/net/arm/ixp4xx_eth.c
@@ -735,7 +735,7 @@ static int eth_xmit(struct sk_buff *skb, struct net_device *dev)
735static void eth_set_mcast_list(struct net_device *dev) 735static void eth_set_mcast_list(struct net_device *dev)
736{ 736{
737 struct port *port = netdev_priv(dev); 737 struct port *port = netdev_priv(dev);
738 struct dev_mc_list *mclist; 738 struct netdev_hw_addr *ha;
739 u8 diffs[ETH_ALEN], *addr; 739 u8 diffs[ETH_ALEN], *addr;
740 int i; 740 int i;
741 741
@@ -748,11 +748,11 @@ static void eth_set_mcast_list(struct net_device *dev)
748 memset(diffs, 0, ETH_ALEN); 748 memset(diffs, 0, ETH_ALEN);
749 749
750 addr = NULL; 750 addr = NULL;
751 netdev_for_each_mc_addr(mclist, dev) { 751 netdev_for_each_mc_addr(ha, dev) {
752 if (!addr) 752 if (!addr)
753 addr = mclist->dmi_addr; /* first MAC address */ 753 addr = ha->addr; /* first MAC address */
754 for (i = 0; i < ETH_ALEN; i++) 754 for (i = 0; i < ETH_ALEN; i++)
755 diffs[i] |= addr[i] ^ mclist->dmi_addr[i]; 755 diffs[i] |= addr[i] ^ ha->addr[i];
756 } 756 }
757 757
758 for (i = 0; i < ETH_ALEN; i++) { 758 for (i = 0; i < ETH_ALEN; i++) {
diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c
index e7810b74f396..6ec245c6394b 100644
--- a/drivers/net/arm/ks8695net.c
+++ b/drivers/net/arm/ks8695net.c
@@ -331,16 +331,16 @@ ks8695_init_partial_multicast(struct ks8695_priv *ksp,
331{ 331{
332 u32 low, high; 332 u32 low, high;
333 int i; 333 int i;
334 struct dev_mc_list *dmi; 334 struct netdev_hw_addr *ha;
335 335
336 i = 0; 336 i = 0;
337 netdev_for_each_mc_addr(dmi, ndev) { 337 netdev_for_each_mc_addr(ha, ndev) {
338 /* Ran out of space in chip? */ 338 /* Ran out of space in chip? */
339 BUG_ON(i == KS8695_NR_ADDRESSES); 339 BUG_ON(i == KS8695_NR_ADDRESSES);
340 340
341 low = (dmi->dmi_addr[2] << 24) | (dmi->dmi_addr[3] << 16) | 341 low = (ha->addr[2] << 24) | (ha->addr[3] << 16) |
342 (dmi->dmi_addr[4] << 8) | (dmi->dmi_addr[5]); 342 (ha->addr[4] << 8) | (ha->addr[5]);
343 high = (dmi->dmi_addr[0] << 8) | (dmi->dmi_addr[1]); 343 high = (ha->addr[0] << 8) | (ha->addr[1]);
344 344
345 ks8695_writereg(ksp, KS8695_AAL_(i), low); 345 ks8695_writereg(ksp, KS8695_AAL_(i), low);
346 ks8695_writereg(ksp, KS8695_AAH_(i), AAH_E | high); 346 ks8695_writereg(ksp, KS8695_AAH_(i), AAH_E | high);
diff --git a/drivers/net/arm/w90p910_ether.c b/drivers/net/arm/w90p910_ether.c
index febd813c916d..3302df21d591 100644
--- a/drivers/net/arm/w90p910_ether.c
+++ b/drivers/net/arm/w90p910_ether.c
@@ -743,7 +743,6 @@ static void netdev_rx(struct net_device *dev)
743 return; 743 return;
744 } 744 }
745 745
746 skb->dev = dev;
747 skb_reserve(skb, 2); 746 skb_reserve(skb, 2);
748 skb_put(skb, length); 747 skb_put(skb, length);
749 skb_copy_to_linear_data(skb, data, length); 748 skb_copy_to_linear_data(skb, data, length);
diff --git a/drivers/net/at1700.c b/drivers/net/at1700.c
index 309843ab8869..e2a549a60e25 100644
--- a/drivers/net/at1700.c
+++ b/drivers/net/at1700.c
@@ -848,12 +848,12 @@ set_rx_mode(struct net_device *dev)
848 memset(mc_filter, 0x00, sizeof(mc_filter)); 848 memset(mc_filter, 0x00, sizeof(mc_filter));
849 outb(1, ioaddr + RX_MODE); /* Ignore almost all multicasts. */ 849 outb(1, ioaddr + RX_MODE); /* Ignore almost all multicasts. */
850 } else { 850 } else {
851 struct dev_mc_list *mclist; 851 struct netdev_hw_addr *ha;
852 852
853 memset(mc_filter, 0, sizeof(mc_filter)); 853 memset(mc_filter, 0, sizeof(mc_filter));
854 netdev_for_each_mc_addr(mclist, dev) { 854 netdev_for_each_mc_addr(ha, dev) {
855 unsigned int bit = 855 unsigned int bit =
856 ether_crc_le(ETH_ALEN, mclist->dmi_addr) >> 26; 856 ether_crc_le(ETH_ALEN, ha->addr) >> 26;
857 mc_filter[bit >> 3] |= (1 << bit); 857 mc_filter[bit >> 3] |= (1 << bit);
858 } 858 }
859 outb(0x02, ioaddr + RX_MODE); /* Use normal mode. */ 859 outb(0x02, ioaddr + RX_MODE); /* Use normal mode. */
diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c
index 50dc531a02d8..3d7051135c3a 100644
--- a/drivers/net/atl1c/atl1c_main.c
+++ b/drivers/net/atl1c/atl1c_main.c
@@ -354,7 +354,7 @@ static void atl1c_set_multi(struct net_device *netdev)
354{ 354{
355 struct atl1c_adapter *adapter = netdev_priv(netdev); 355 struct atl1c_adapter *adapter = netdev_priv(netdev);
356 struct atl1c_hw *hw = &adapter->hw; 356 struct atl1c_hw *hw = &adapter->hw;
357 struct dev_mc_list *mc_ptr; 357 struct netdev_hw_addr *ha;
358 u32 mac_ctrl_data; 358 u32 mac_ctrl_data;
359 u32 hash_value; 359 u32 hash_value;
360 360
@@ -377,8 +377,8 @@ static void atl1c_set_multi(struct net_device *netdev)
377 AT_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, 1, 0); 377 AT_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, 1, 0);
378 378
379 /* comoute mc addresses' hash value ,and put it into hash table */ 379 /* comoute mc addresses' hash value ,and put it into hash table */
380 netdev_for_each_mc_addr(mc_ptr, netdev) { 380 netdev_for_each_mc_addr(ha, netdev) {
381 hash_value = atl1c_hash_mc_addr(hw, mc_ptr->dmi_addr); 381 hash_value = atl1c_hash_mc_addr(hw, ha->addr);
382 atl1c_hash_set(hw, hash_value); 382 atl1c_hash_set(hw, hash_value);
383 } 383 }
384} 384}
@@ -1817,7 +1817,6 @@ rrs_checked:
1817 atl1c_clean_rfd(rfd_ring, rrs, rfd_num); 1817 atl1c_clean_rfd(rfd_ring, rrs, rfd_num);
1818 skb_put(skb, length - ETH_FCS_LEN); 1818 skb_put(skb, length - ETH_FCS_LEN);
1819 skb->protocol = eth_type_trans(skb, netdev); 1819 skb->protocol = eth_type_trans(skb, netdev);
1820 skb->dev = netdev;
1821 atl1c_rx_checksum(adapter, skb, rrs); 1820 atl1c_rx_checksum(adapter, skb, rrs);
1822 if (unlikely(adapter->vlgrp) && rrs->word3 & RRS_VLAN_INS) { 1821 if (unlikely(adapter->vlgrp) && rrs->word3 & RRS_VLAN_INS) {
1823 u16 vlan; 1822 u16 vlan;
diff --git a/drivers/net/atl1e/atl1e_main.c b/drivers/net/atl1e/atl1e_main.c
index 73302ae468aa..b6605d433e91 100644
--- a/drivers/net/atl1e/atl1e_main.c
+++ b/drivers/net/atl1e/atl1e_main.c
@@ -284,7 +284,7 @@ static void atl1e_set_multi(struct net_device *netdev)
284{ 284{
285 struct atl1e_adapter *adapter = netdev_priv(netdev); 285 struct atl1e_adapter *adapter = netdev_priv(netdev);
286 struct atl1e_hw *hw = &adapter->hw; 286 struct atl1e_hw *hw = &adapter->hw;
287 struct dev_mc_list *mc_ptr; 287 struct netdev_hw_addr *ha;
288 u32 mac_ctrl_data = 0; 288 u32 mac_ctrl_data = 0;
289 u32 hash_value; 289 u32 hash_value;
290 290
@@ -307,8 +307,8 @@ static void atl1e_set_multi(struct net_device *netdev)
307 AT_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, 1, 0); 307 AT_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, 1, 0);
308 308
309 /* comoute mc addresses' hash value ,and put it into hash table */ 309 /* comoute mc addresses' hash value ,and put it into hash table */
310 netdev_for_each_mc_addr(mc_ptr, netdev) { 310 netdev_for_each_mc_addr(ha, netdev) {
311 hash_value = atl1e_hash_mc_addr(hw, mc_ptr->dmi_addr); 311 hash_value = atl1e_hash_mc_addr(hw, ha->addr);
312 atl1e_hash_set(hw, hash_value); 312 atl1e_hash_set(hw, hash_value);
313 } 313 }
314} 314}
@@ -1428,7 +1428,6 @@ static void atl1e_clean_rx_irq(struct atl1e_adapter *adapter, u8 que,
1428 "Memory squeeze, deferring packet\n"); 1428 "Memory squeeze, deferring packet\n");
1429 goto skip_pkt; 1429 goto skip_pkt;
1430 } 1430 }
1431 skb->dev = netdev;
1432 memcpy(skb->data, (u8 *)(prrs + 1), packet_size); 1431 memcpy(skb->data, (u8 *)(prrs + 1), packet_size);
1433 skb_put(skb, packet_size); 1432 skb_put(skb, packet_size);
1434 skb->protocol = eth_type_trans(skb, netdev); 1433 skb->protocol = eth_type_trans(skb, netdev);
diff --git a/drivers/net/atlx/atl2.c b/drivers/net/atlx/atl2.c
index 7061d7108f08..078d9d1b427c 100644
--- a/drivers/net/atlx/atl2.c
+++ b/drivers/net/atlx/atl2.c
@@ -135,7 +135,7 @@ static void atl2_set_multi(struct net_device *netdev)
135{ 135{
136 struct atl2_adapter *adapter = netdev_priv(netdev); 136 struct atl2_adapter *adapter = netdev_priv(netdev);
137 struct atl2_hw *hw = &adapter->hw; 137 struct atl2_hw *hw = &adapter->hw;
138 struct dev_mc_list *mc_ptr; 138 struct netdev_hw_addr *ha;
139 u32 rctl; 139 u32 rctl;
140 u32 hash_value; 140 u32 hash_value;
141 141
@@ -157,8 +157,8 @@ static void atl2_set_multi(struct net_device *netdev)
157 ATL2_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, 1, 0); 157 ATL2_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, 1, 0);
158 158
159 /* comoute mc addresses' hash value ,and put it into hash table */ 159 /* comoute mc addresses' hash value ,and put it into hash table */
160 netdev_for_each_mc_addr(mc_ptr, netdev) { 160 netdev_for_each_mc_addr(ha, netdev) {
161 hash_value = atl2_hash_mc_addr(hw, mc_ptr->dmi_addr); 161 hash_value = atl2_hash_mc_addr(hw, ha->addr);
162 atl2_hash_set(hw, hash_value); 162 atl2_hash_set(hw, hash_value);
163 } 163 }
164} 164}
@@ -421,7 +421,6 @@ static void atl2_intr_rx(struct atl2_adapter *adapter)
421 netdev->stats.rx_dropped++; 421 netdev->stats.rx_dropped++;
422 break; 422 break;
423 } 423 }
424 skb->dev = netdev;
425 memcpy(skb->data, rxd->packet, rx_size); 424 memcpy(skb->data, rxd->packet, rx_size);
426 skb_put(skb, rx_size); 425 skb_put(skb, rx_size);
427 skb->protocol = eth_type_trans(skb, netdev); 426 skb->protocol = eth_type_trans(skb, netdev);
diff --git a/drivers/net/atlx/atlx.c b/drivers/net/atlx/atlx.c
index 72f3306352e2..f979ea2d6d3c 100644
--- a/drivers/net/atlx/atlx.c
+++ b/drivers/net/atlx/atlx.c
@@ -123,7 +123,7 @@ static void atlx_set_multi(struct net_device *netdev)
123{ 123{
124 struct atlx_adapter *adapter = netdev_priv(netdev); 124 struct atlx_adapter *adapter = netdev_priv(netdev);
125 struct atlx_hw *hw = &adapter->hw; 125 struct atlx_hw *hw = &adapter->hw;
126 struct dev_mc_list *mc_ptr; 126 struct netdev_hw_addr *ha;
127 u32 rctl; 127 u32 rctl;
128 u32 hash_value; 128 u32 hash_value;
129 129
@@ -144,8 +144,8 @@ static void atlx_set_multi(struct net_device *netdev)
144 iowrite32(0, (hw->hw_addr + REG_RX_HASH_TABLE) + (1 << 2)); 144 iowrite32(0, (hw->hw_addr + REG_RX_HASH_TABLE) + (1 << 2));
145 145
146 /* compute mc addresses' hash value ,and put it into hash table */ 146 /* compute mc addresses' hash value ,and put it into hash table */
147 netdev_for_each_mc_addr(mc_ptr, netdev) { 147 netdev_for_each_mc_addr(ha, netdev) {
148 hash_value = atlx_hash_mc_addr(hw, mc_ptr->dmi_addr); 148 hash_value = atlx_hash_mc_addr(hw, ha->addr);
149 atlx_hash_set(hw, hash_value); 149 atlx_hash_set(hw, hash_value);
150 } 150 }
151} 151}
diff --git a/drivers/net/atp.c b/drivers/net/atp.c
index 6ad16205dc17..0d730c8329d4 100644
--- a/drivers/net/atp.c
+++ b/drivers/net/atp.c
@@ -883,11 +883,11 @@ static void set_rx_mode_8012(struct net_device *dev)
883 memset(mc_filter, 0xff, sizeof(mc_filter)); 883 memset(mc_filter, 0xff, sizeof(mc_filter));
884 new_mode = CMR2h_Normal; 884 new_mode = CMR2h_Normal;
885 } else { 885 } else {
886 struct dev_mc_list *mclist; 886 struct netdev_hw_addr *ha;
887 887
888 memset(mc_filter, 0, sizeof(mc_filter)); 888 memset(mc_filter, 0, sizeof(mc_filter));
889 netdev_for_each_mc_addr(mclist, dev) { 889 netdev_for_each_mc_addr(ha, dev) {
890 int filterbit = ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x3f; 890 int filterbit = ether_crc_le(ETH_ALEN, ha->addr) & 0x3f;
891 mc_filter[filterbit >> 5] |= 1 << (filterbit & 31); 891 mc_filter[filterbit >> 5] |= 1 << (filterbit & 31);
892 } 892 }
893 new_mode = CMR2h_Normal; 893 new_mode = CMR2h_Normal;
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 4da191b87b0d..29631593cc23 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -957,12 +957,12 @@ static void au1000_multicast_list(struct net_device *dev)
957 aup->mac->control &= ~MAC_PROMISCUOUS; 957 aup->mac->control &= ~MAC_PROMISCUOUS;
958 printk(KERN_INFO "%s: Pass all multicast\n", dev->name); 958 printk(KERN_INFO "%s: Pass all multicast\n", dev->name);
959 } else { 959 } else {
960 struct dev_mc_list *mclist; 960 struct netdev_hw_addr *ha;
961 u32 mc_filter[2]; /* Multicast hash filter */ 961 u32 mc_filter[2]; /* Multicast hash filter */
962 962
963 mc_filter[1] = mc_filter[0] = 0; 963 mc_filter[1] = mc_filter[0] = 0;
964 netdev_for_each_mc_addr(mclist, dev) 964 netdev_for_each_mc_addr(ha, dev)
965 set_bit(ether_crc(ETH_ALEN, mclist->dmi_addr)>>26, 965 set_bit(ether_crc(ETH_ALEN, ha->addr)>>26,
966 (long *)mc_filter); 966 (long *)mc_filter);
967 aup->mac->multi_hash_high = mc_filter[1]; 967 aup->mac->multi_hash_high = mc_filter[1];
968 aup->mac->multi_hash_low = mc_filter[0]; 968 aup->mac->multi_hash_low = mc_filter[0];
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 332c60356285..b2c5fd7b63af 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -1680,15 +1680,15 @@ static struct net_device_stats *b44_get_stats(struct net_device *dev)
1680 1680
1681static int __b44_load_mcast(struct b44 *bp, struct net_device *dev) 1681static int __b44_load_mcast(struct b44 *bp, struct net_device *dev)
1682{ 1682{
1683 struct dev_mc_list *mclist; 1683 struct netdev_hw_addr *ha;
1684 int i, num_ents; 1684 int i, num_ents;
1685 1685
1686 num_ents = min_t(int, netdev_mc_count(dev), B44_MCAST_TABLE_SIZE); 1686 num_ents = min_t(int, netdev_mc_count(dev), B44_MCAST_TABLE_SIZE);
1687 i = 0; 1687 i = 0;
1688 netdev_for_each_mc_addr(mclist, dev) { 1688 netdev_for_each_mc_addr(ha, dev) {
1689 if (i == num_ents) 1689 if (i == num_ents)
1690 break; 1690 break;
1691 __b44_cam_write(bp, mclist->dmi_addr, i++ + 1); 1691 __b44_cam_write(bp, ha->addr, i++ + 1);
1692 } 1692 }
1693 return i+1; 1693 return i+1;
1694} 1694}
diff --git a/drivers/net/bcm63xx_enet.c b/drivers/net/bcm63xx_enet.c
index 8cdcab7655c0..51733404478e 100644
--- a/drivers/net/bcm63xx_enet.c
+++ b/drivers/net/bcm63xx_enet.c
@@ -340,7 +340,6 @@ static int bcm_enet_receive_queue(struct net_device *dev, int budget)
340 } 340 }
341 341
342 skb_put(skb, len); 342 skb_put(skb, len);
343 skb->dev = dev;
344 skb->protocol = eth_type_trans(skb, dev); 343 skb->protocol = eth_type_trans(skb, dev);
345 priv->stats.rx_packets++; 344 priv->stats.rx_packets++;
346 priv->stats.rx_bytes += len; 345 priv->stats.rx_bytes += len;
@@ -604,7 +603,7 @@ static int bcm_enet_set_mac_address(struct net_device *dev, void *p)
604static void bcm_enet_set_multicast_list(struct net_device *dev) 603static void bcm_enet_set_multicast_list(struct net_device *dev)
605{ 604{
606 struct bcm_enet_priv *priv; 605 struct bcm_enet_priv *priv;
607 struct dev_mc_list *mc_list; 606 struct netdev_hw_addr *ha;
608 u32 val; 607 u32 val;
609 int i; 608 int i;
610 609
@@ -632,14 +631,14 @@ static void bcm_enet_set_multicast_list(struct net_device *dev)
632 } 631 }
633 632
634 i = 0; 633 i = 0;
635 netdev_for_each_mc_addr(mc_list, dev) { 634 netdev_for_each_mc_addr(ha, dev) {
636 u8 *dmi_addr; 635 u8 *dmi_addr;
637 u32 tmp; 636 u32 tmp;
638 637
639 if (i == 3) 638 if (i == 3)
640 break; 639 break;
641 /* update perfect match registers */ 640 /* update perfect match registers */
642 dmi_addr = mc_list->dmi_addr; 641 dmi_addr = ha->addr;
643 tmp = (dmi_addr[2] << 24) | (dmi_addr[3] << 16) | 642 tmp = (dmi_addr[2] << 24) | (dmi_addr[3] << 16) |
644 (dmi_addr[4] << 8) | dmi_addr[5]; 643 (dmi_addr[4] << 8) | dmi_addr[5];
645 enet_writel(priv, tmp, ENET_PML_REG(i + 1)); 644 enet_writel(priv, tmp, ENET_PML_REG(i + 1));
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h
index 8f0752553681..20842c5fd8fb 100644
--- a/drivers/net/benet/be.h
+++ b/drivers/net/benet/be.h
@@ -83,6 +83,8 @@ static inline char *nic_name(struct pci_dev *pdev)
83 83
84#define FW_VER_LEN 32 84#define FW_VER_LEN 32
85 85
86#define BE_MAX_VF 32
87
86struct be_dma_mem { 88struct be_dma_mem {
87 void *va; 89 void *va;
88 dma_addr_t dma; 90 dma_addr_t dma;
@@ -280,8 +282,15 @@ struct be_adapter {
280 u8 port_type; 282 u8 port_type;
281 u8 transceiver; 283 u8 transceiver;
282 u8 generation; /* BladeEngine ASIC generation */ 284 u8 generation; /* BladeEngine ASIC generation */
285
286 bool sriov_enabled;
287 u32 vf_if_handle[BE_MAX_VF];
288 u32 vf_pmac_id[BE_MAX_VF];
289 u8 base_eq_id;
283}; 290};
284 291
292#define be_physfn(adapter) (!adapter->pdev->is_virtfn)
293
285/* BladeEngine Generation numbers */ 294/* BladeEngine Generation numbers */
286#define BE_GEN2 2 295#define BE_GEN2 2
287#define BE_GEN3 3 296#define BE_GEN3 3
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c
index d0ef4ac987cd..da8793026bb1 100644
--- a/drivers/net/benet/be_cmds.c
+++ b/drivers/net/benet/be_cmds.c
@@ -843,7 +843,8 @@ int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q,
843 * Uses mbox 843 * Uses mbox
844 */ 844 */
845int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags, 845int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
846 u8 *mac, bool pmac_invalid, u32 *if_handle, u32 *pmac_id) 846 u8 *mac, bool pmac_invalid, u32 *if_handle, u32 *pmac_id,
847 u32 domain)
847{ 848{
848 struct be_mcc_wrb *wrb; 849 struct be_mcc_wrb *wrb;
849 struct be_cmd_req_if_create *req; 850 struct be_cmd_req_if_create *req;
@@ -860,6 +861,7 @@ int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
860 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, 861 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
861 OPCODE_COMMON_NTWK_INTERFACE_CREATE, sizeof(*req)); 862 OPCODE_COMMON_NTWK_INTERFACE_CREATE, sizeof(*req));
862 863
864 req->hdr.domain = domain;
863 req->capability_flags = cpu_to_le32(cap_flags); 865 req->capability_flags = cpu_to_le32(cap_flags);
864 req->enable_flags = cpu_to_le32(en_flags); 866 req->enable_flags = cpu_to_le32(en_flags);
865 req->pmac_invalid = pmac_invalid; 867 req->pmac_invalid = pmac_invalid;
@@ -1157,13 +1159,13 @@ int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id,
1157 req->interface_id = if_id; 1159 req->interface_id = if_id;
1158 if (netdev) { 1160 if (netdev) {
1159 int i; 1161 int i;
1160 struct dev_mc_list *mc; 1162 struct netdev_hw_addr *ha;
1161 1163
1162 req->num_mac = cpu_to_le16(netdev_mc_count(netdev)); 1164 req->num_mac = cpu_to_le16(netdev_mc_count(netdev));
1163 1165
1164 i = 0; 1166 i = 0;
1165 netdev_for_each_mc_addr(mc, netdev) 1167 netdev_for_each_mc_addr(ha, netdev)
1166 memcpy(req->mac[i].byte, mc->dmi_addr, ETH_ALEN); 1168 memcpy(req->mac[i].byte, ha->addr, ETH_ALEN);
1167 } else { 1169 } else {
1168 req->promiscuous = 1; 1170 req->promiscuous = 1;
1169 } 1171 }
diff --git a/drivers/net/benet/be_cmds.h b/drivers/net/benet/be_cmds.h
index cce61f9a3714..763dc199e337 100644
--- a/drivers/net/benet/be_cmds.h
+++ b/drivers/net/benet/be_cmds.h
@@ -878,7 +878,7 @@ extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr,
878extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id); 878extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id);
879extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, 879extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags,
880 u32 en_flags, u8 *mac, bool pmac_invalid, 880 u32 en_flags, u8 *mac, bool pmac_invalid,
881 u32 *if_handle, u32 *pmac_id); 881 u32 *if_handle, u32 *pmac_id, u32 domain);
882extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle); 882extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle);
883extern int be_cmd_eq_create(struct be_adapter *adapter, 883extern int be_cmd_eq_create(struct be_adapter *adapter,
884 struct be_queue_info *eq, int eq_delay); 884 struct be_queue_info *eq, int eq_delay);
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c
index 51e1065e7897..d488d52d710a 100644
--- a/drivers/net/benet/be_ethtool.c
+++ b/drivers/net/benet/be_ethtool.c
@@ -496,7 +496,7 @@ be_test_ddr_dma(struct be_adapter *adapter)
496 ddrdma_cmd.va = pci_alloc_consistent(adapter->pdev, ddrdma_cmd.size, 496 ddrdma_cmd.va = pci_alloc_consistent(adapter->pdev, ddrdma_cmd.size,
497 &ddrdma_cmd.dma); 497 &ddrdma_cmd.dma);
498 if (!ddrdma_cmd.va) { 498 if (!ddrdma_cmd.va) {
499 dev_err(&adapter->pdev->dev, "Memory allocation failure \n"); 499 dev_err(&adapter->pdev->dev, "Memory allocation failure\n");
500 return -ENOMEM; 500 return -ENOMEM;
501 } 501 }
502 502
diff --git a/drivers/net/benet/be_hw.h b/drivers/net/benet/be_hw.h
index 2d4a4b827637..063026de4957 100644
--- a/drivers/net/benet/be_hw.h
+++ b/drivers/net/benet/be_hw.h
@@ -99,6 +99,9 @@
99/* Number of entries posted */ 99/* Number of entries posted */
100#define DB_MCCQ_NUM_POSTED_SHIFT (16) /* bits 16 - 29 */ 100#define DB_MCCQ_NUM_POSTED_SHIFT (16) /* bits 16 - 29 */
101 101
102/********** SRIOV VF PCICFG OFFSET ********/
103#define SRIOV_VF_PCICFG_OFFSET (4096)
104
102/* Flashrom related descriptors */ 105/* Flashrom related descriptors */
103#define IMAGE_TYPE_FIRMWARE 160 106#define IMAGE_TYPE_FIRMWARE 160
104#define IMAGE_TYPE_BOOTCODE 224 107#define IMAGE_TYPE_BOOTCODE 224
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index ec6ace802256..49d51965312e 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -26,8 +26,11 @@ MODULE_AUTHOR("ServerEngines Corporation");
26MODULE_LICENSE("GPL"); 26MODULE_LICENSE("GPL");
27 27
28static unsigned int rx_frag_size = 2048; 28static unsigned int rx_frag_size = 2048;
29static unsigned int num_vfs;
29module_param(rx_frag_size, uint, S_IRUGO); 30module_param(rx_frag_size, uint, S_IRUGO);
31module_param(num_vfs, uint, S_IRUGO);
30MODULE_PARM_DESC(rx_frag_size, "Size of a fragment that holds rcvd data."); 32MODULE_PARM_DESC(rx_frag_size, "Size of a fragment that holds rcvd data.");
33MODULE_PARM_DESC(num_vfs, "Number of PCI VFs to initialize");
31 34
32static DEFINE_PCI_DEVICE_TABLE(be_dev_ids) = { 35static DEFINE_PCI_DEVICE_TABLE(be_dev_ids) = {
33 { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) }, 36 { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) },
@@ -138,12 +141,19 @@ static int be_mac_addr_set(struct net_device *netdev, void *p)
138 if (!is_valid_ether_addr(addr->sa_data)) 141 if (!is_valid_ether_addr(addr->sa_data))
139 return -EADDRNOTAVAIL; 142 return -EADDRNOTAVAIL;
140 143
144 /* MAC addr configuration will be done in hardware for VFs
145 * by their corresponding PFs. Just copy to netdev addr here
146 */
147 if (!be_physfn(adapter))
148 goto netdev_addr;
149
141 status = be_cmd_pmac_del(adapter, adapter->if_handle, adapter->pmac_id); 150 status = be_cmd_pmac_del(adapter, adapter->if_handle, adapter->pmac_id);
142 if (status) 151 if (status)
143 return status; 152 return status;
144 153
145 status = be_cmd_pmac_add(adapter, (u8 *)addr->sa_data, 154 status = be_cmd_pmac_add(adapter, (u8 *)addr->sa_data,
146 adapter->if_handle, &adapter->pmac_id); 155 adapter->if_handle, &adapter->pmac_id);
156netdev_addr:
147 if (!status) 157 if (!status)
148 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); 158 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
149 159
@@ -386,26 +396,48 @@ static void wrb_fill_hdr(struct be_eth_hdr_wrb *hdr, struct sk_buff *skb,
386 AMAP_SET_BITS(struct amap_eth_hdr_wrb, len, hdr, len); 396 AMAP_SET_BITS(struct amap_eth_hdr_wrb, len, hdr, len);
387} 397}
388 398
399static void unmap_tx_frag(struct pci_dev *pdev, struct be_eth_wrb *wrb,
400 bool unmap_single)
401{
402 dma_addr_t dma;
403
404 be_dws_le_to_cpu(wrb, sizeof(*wrb));
405
406 dma = (u64)wrb->frag_pa_hi << 32 | (u64)wrb->frag_pa_lo;
407 if (dma != 0) {
408 if (unmap_single)
409 pci_unmap_single(pdev, dma, wrb->frag_len,
410 PCI_DMA_TODEVICE);
411 else
412 pci_unmap_page(pdev, dma, wrb->frag_len,
413 PCI_DMA_TODEVICE);
414 }
415}
389 416
390static int make_tx_wrbs(struct be_adapter *adapter, 417static int make_tx_wrbs(struct be_adapter *adapter,
391 struct sk_buff *skb, u32 wrb_cnt, bool dummy_wrb) 418 struct sk_buff *skb, u32 wrb_cnt, bool dummy_wrb)
392{ 419{
393 u64 busaddr; 420 dma_addr_t busaddr;
394 u32 i, copied = 0; 421 int i, copied = 0;
395 struct pci_dev *pdev = adapter->pdev; 422 struct pci_dev *pdev = adapter->pdev;
396 struct sk_buff *first_skb = skb; 423 struct sk_buff *first_skb = skb;
397 struct be_queue_info *txq = &adapter->tx_obj.q; 424 struct be_queue_info *txq = &adapter->tx_obj.q;
398 struct be_eth_wrb *wrb; 425 struct be_eth_wrb *wrb;
399 struct be_eth_hdr_wrb *hdr; 426 struct be_eth_hdr_wrb *hdr;
427 bool map_single = false;
428 u16 map_head;
400 429
401 hdr = queue_head_node(txq); 430 hdr = queue_head_node(txq);
402 atomic_add(wrb_cnt, &txq->used);
403 queue_head_inc(txq); 431 queue_head_inc(txq);
432 map_head = txq->head;
404 433
405 if (skb->len > skb->data_len) { 434 if (skb->len > skb->data_len) {
406 int len = skb->len - skb->data_len; 435 int len = skb->len - skb->data_len;
407 busaddr = pci_map_single(pdev, skb->data, len, 436 busaddr = pci_map_single(pdev, skb->data, len,
408 PCI_DMA_TODEVICE); 437 PCI_DMA_TODEVICE);
438 if (pci_dma_mapping_error(pdev, busaddr))
439 goto dma_err;
440 map_single = true;
409 wrb = queue_head_node(txq); 441 wrb = queue_head_node(txq);
410 wrb_fill(wrb, busaddr, len); 442 wrb_fill(wrb, busaddr, len);
411 be_dws_cpu_to_le(wrb, sizeof(*wrb)); 443 be_dws_cpu_to_le(wrb, sizeof(*wrb));
@@ -419,6 +451,8 @@ static int make_tx_wrbs(struct be_adapter *adapter,
419 busaddr = pci_map_page(pdev, frag->page, 451 busaddr = pci_map_page(pdev, frag->page,
420 frag->page_offset, 452 frag->page_offset,
421 frag->size, PCI_DMA_TODEVICE); 453 frag->size, PCI_DMA_TODEVICE);
454 if (pci_dma_mapping_error(pdev, busaddr))
455 goto dma_err;
422 wrb = queue_head_node(txq); 456 wrb = queue_head_node(txq);
423 wrb_fill(wrb, busaddr, frag->size); 457 wrb_fill(wrb, busaddr, frag->size);
424 be_dws_cpu_to_le(wrb, sizeof(*wrb)); 458 be_dws_cpu_to_le(wrb, sizeof(*wrb));
@@ -438,6 +472,16 @@ static int make_tx_wrbs(struct be_adapter *adapter,
438 be_dws_cpu_to_le(hdr, sizeof(*hdr)); 472 be_dws_cpu_to_le(hdr, sizeof(*hdr));
439 473
440 return copied; 474 return copied;
475dma_err:
476 txq->head = map_head;
477 while (copied) {
478 wrb = queue_head_node(txq);
479 unmap_tx_frag(pdev, wrb, map_single);
480 map_single = false;
481 copied -= wrb->frag_len;
482 queue_head_inc(txq);
483 }
484 return 0;
441} 485}
442 486
443static netdev_tx_t be_xmit(struct sk_buff *skb, 487static netdev_tx_t be_xmit(struct sk_buff *skb,
@@ -462,6 +506,7 @@ static netdev_tx_t be_xmit(struct sk_buff *skb,
462 * *BEFORE* ringing the tx doorbell, so that we serialze the 506 * *BEFORE* ringing the tx doorbell, so that we serialze the
463 * tx compls of the current transmit which'll wake up the queue 507 * tx compls of the current transmit which'll wake up the queue
464 */ 508 */
509 atomic_add(wrb_cnt, &txq->used);
465 if ((BE_MAX_TX_FRAG_COUNT + atomic_read(&txq->used)) >= 510 if ((BE_MAX_TX_FRAG_COUNT + atomic_read(&txq->used)) >=
466 txq->len) { 511 txq->len) {
467 netif_stop_queue(netdev); 512 netif_stop_queue(netdev);
@@ -541,6 +586,9 @@ static void be_vlan_add_vid(struct net_device *netdev, u16 vid)
541{ 586{
542 struct be_adapter *adapter = netdev_priv(netdev); 587 struct be_adapter *adapter = netdev_priv(netdev);
543 588
589 if (!be_physfn(adapter))
590 return;
591
544 adapter->vlan_tag[vid] = 1; 592 adapter->vlan_tag[vid] = 1;
545 adapter->vlans_added++; 593 adapter->vlans_added++;
546 if (adapter->vlans_added <= (adapter->max_vlans + 1)) 594 if (adapter->vlans_added <= (adapter->max_vlans + 1))
@@ -551,6 +599,9 @@ static void be_vlan_rem_vid(struct net_device *netdev, u16 vid)
551{ 599{
552 struct be_adapter *adapter = netdev_priv(netdev); 600 struct be_adapter *adapter = netdev_priv(netdev);
553 601
602 if (!be_physfn(adapter))
603 return;
604
554 adapter->vlan_tag[vid] = 0; 605 adapter->vlan_tag[vid] = 0;
555 vlan_group_set_device(adapter->vlan_grp, vid, NULL); 606 vlan_group_set_device(adapter->vlan_grp, vid, NULL);
556 adapter->vlans_added--; 607 adapter->vlans_added--;
@@ -588,6 +639,28 @@ done:
588 return; 639 return;
589} 640}
590 641
642static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
643{
644 struct be_adapter *adapter = netdev_priv(netdev);
645 int status;
646
647 if (!adapter->sriov_enabled)
648 return -EPERM;
649
650 if (!is_valid_ether_addr(mac) || (vf >= num_vfs))
651 return -EINVAL;
652
653 status = be_cmd_pmac_del(adapter, adapter->vf_if_handle[vf],
654 adapter->vf_pmac_id[vf]);
655
656 status = be_cmd_pmac_add(adapter, mac, adapter->vf_if_handle[vf],
657 &adapter->vf_pmac_id[vf]);
658 if (!status)
659 dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n",
660 mac, vf);
661 return status;
662}
663
591static void be_rx_rate_update(struct be_adapter *adapter) 664static void be_rx_rate_update(struct be_adapter *adapter)
592{ 665{
593 struct be_drvr_stats *stats = drvr_stats(adapter); 666 struct be_drvr_stats *stats = drvr_stats(adapter);
@@ -791,7 +864,6 @@ static void be_rx_compl_process(struct be_adapter *adapter,
791 864
792 skb->truesize = skb->len + sizeof(struct sk_buff); 865 skb->truesize = skb->len + sizeof(struct sk_buff);
793 skb->protocol = eth_type_trans(skb, adapter->netdev); 866 skb->protocol = eth_type_trans(skb, adapter->netdev);
794 skb->dev = adapter->netdev;
795 867
796 vlanf = AMAP_GET_BITS(struct amap_eth_rx_compl, vtp, rxcp); 868 vlanf = AMAP_GET_BITS(struct amap_eth_rx_compl, vtp, rxcp);
797 vtm = AMAP_GET_BITS(struct amap_eth_rx_compl, vtm, rxcp); 869 vtm = AMAP_GET_BITS(struct amap_eth_rx_compl, vtm, rxcp);
@@ -1012,35 +1084,26 @@ static void be_tx_compl_process(struct be_adapter *adapter, u16 last_index)
1012 struct be_eth_wrb *wrb; 1084 struct be_eth_wrb *wrb;
1013 struct sk_buff **sent_skbs = adapter->tx_obj.sent_skb_list; 1085 struct sk_buff **sent_skbs = adapter->tx_obj.sent_skb_list;
1014 struct sk_buff *sent_skb; 1086 struct sk_buff *sent_skb;
1015 u64 busaddr; 1087 u16 cur_index, num_wrbs = 1; /* account for hdr wrb */
1016 u16 cur_index, num_wrbs = 0; 1088 bool unmap_skb_hdr = true;
1017 1089
1018 cur_index = txq->tail; 1090 sent_skb = sent_skbs[txq->tail];
1019 sent_skb = sent_skbs[cur_index];
1020 BUG_ON(!sent_skb); 1091 BUG_ON(!sent_skb);
1021 sent_skbs[cur_index] = NULL; 1092 sent_skbs[txq->tail] = NULL;
1022 wrb = queue_tail_node(txq); 1093
1023 be_dws_le_to_cpu(wrb, sizeof(*wrb)); 1094 /* skip header wrb */
1024 busaddr = ((u64)wrb->frag_pa_hi << 32) | (u64)wrb->frag_pa_lo;
1025 if (busaddr != 0) {
1026 pci_unmap_single(adapter->pdev, busaddr,
1027 wrb->frag_len, PCI_DMA_TODEVICE);
1028 }
1029 num_wrbs++;
1030 queue_tail_inc(txq); 1095 queue_tail_inc(txq);
1031 1096
1032 while (cur_index != last_index) { 1097 do {
1033 cur_index = txq->tail; 1098 cur_index = txq->tail;
1034 wrb = queue_tail_node(txq); 1099 wrb = queue_tail_node(txq);
1035 be_dws_le_to_cpu(wrb, sizeof(*wrb)); 1100 unmap_tx_frag(adapter->pdev, wrb, (unmap_skb_hdr &&
1036 busaddr = ((u64)wrb->frag_pa_hi << 32) | (u64)wrb->frag_pa_lo; 1101 sent_skb->len > sent_skb->data_len));
1037 if (busaddr != 0) { 1102 unmap_skb_hdr = false;
1038 pci_unmap_page(adapter->pdev, busaddr, 1103
1039 wrb->frag_len, PCI_DMA_TODEVICE);
1040 }
1041 num_wrbs++; 1104 num_wrbs++;
1042 queue_tail_inc(txq); 1105 queue_tail_inc(txq);
1043 } 1106 } while (cur_index != last_index);
1044 1107
1045 atomic_sub(num_wrbs, &txq->used); 1108 atomic_sub(num_wrbs, &txq->used);
1046 1109
@@ -1255,6 +1318,8 @@ static int be_tx_queues_create(struct be_adapter *adapter)
1255 /* Ask BE to create Tx Event queue */ 1318 /* Ask BE to create Tx Event queue */
1256 if (be_cmd_eq_create(adapter, eq, adapter->tx_eq.cur_eqd)) 1319 if (be_cmd_eq_create(adapter, eq, adapter->tx_eq.cur_eqd))
1257 goto tx_eq_free; 1320 goto tx_eq_free;
1321 adapter->base_eq_id = adapter->tx_eq.q.id;
1322
1258 /* Alloc TX eth compl queue */ 1323 /* Alloc TX eth compl queue */
1259 cq = &adapter->tx_obj.cq; 1324 cq = &adapter->tx_obj.cq;
1260 if (be_queue_alloc(adapter, cq, TX_CQ_LEN, 1325 if (be_queue_alloc(adapter, cq, TX_CQ_LEN,
@@ -1382,7 +1447,7 @@ rx_eq_free:
1382/* There are 8 evt ids per func. Retruns the evt id's bit number */ 1447/* There are 8 evt ids per func. Retruns the evt id's bit number */
1383static inline int be_evt_bit_get(struct be_adapter *adapter, u32 eq_id) 1448static inline int be_evt_bit_get(struct be_adapter *adapter, u32 eq_id)
1384{ 1449{
1385 return eq_id % 8; 1450 return eq_id - adapter->base_eq_id;
1386} 1451}
1387 1452
1388static irqreturn_t be_intx(int irq, void *dev) 1453static irqreturn_t be_intx(int irq, void *dev)
@@ -1560,6 +1625,28 @@ static void be_msix_enable(struct be_adapter *adapter)
1560 return; 1625 return;
1561} 1626}
1562 1627
1628static void be_sriov_enable(struct be_adapter *adapter)
1629{
1630#ifdef CONFIG_PCI_IOV
1631 int status;
1632 if (be_physfn(adapter) && num_vfs) {
1633 status = pci_enable_sriov(adapter->pdev, num_vfs);
1634 adapter->sriov_enabled = status ? false : true;
1635 }
1636#endif
1637 return;
1638}
1639
1640static void be_sriov_disable(struct be_adapter *adapter)
1641{
1642#ifdef CONFIG_PCI_IOV
1643 if (adapter->sriov_enabled) {
1644 pci_disable_sriov(adapter->pdev);
1645 adapter->sriov_enabled = false;
1646 }
1647#endif
1648}
1649
1563static inline int be_msix_vec_get(struct be_adapter *adapter, u32 eq_id) 1650static inline int be_msix_vec_get(struct be_adapter *adapter, u32 eq_id)
1564{ 1651{
1565 return adapter->msix_entries[ 1652 return adapter->msix_entries[
@@ -1617,6 +1704,9 @@ static int be_irq_register(struct be_adapter *adapter)
1617 status = be_msix_register(adapter); 1704 status = be_msix_register(adapter);
1618 if (status == 0) 1705 if (status == 0)
1619 goto done; 1706 goto done;
1707 /* INTx is not supported for VF */
1708 if (!be_physfn(adapter))
1709 return status;
1620 } 1710 }
1621 1711
1622 /* INTx */ 1712 /* INTx */
@@ -1690,14 +1780,17 @@ static int be_open(struct net_device *netdev)
1690 goto ret_sts; 1780 goto ret_sts;
1691 be_link_status_update(adapter, link_up); 1781 be_link_status_update(adapter, link_up);
1692 1782
1693 status = be_vid_config(adapter); 1783 if (be_physfn(adapter))
1784 status = be_vid_config(adapter);
1694 if (status) 1785 if (status)
1695 goto ret_sts; 1786 goto ret_sts;
1696 1787
1697 status = be_cmd_set_flow_control(adapter, 1788 if (be_physfn(adapter)) {
1698 adapter->tx_fc, adapter->rx_fc); 1789 status = be_cmd_set_flow_control(adapter,
1699 if (status) 1790 adapter->tx_fc, adapter->rx_fc);
1700 goto ret_sts; 1791 if (status)
1792 goto ret_sts;
1793 }
1701 1794
1702 schedule_delayed_work(&adapter->work, msecs_to_jiffies(100)); 1795 schedule_delayed_work(&adapter->work, msecs_to_jiffies(100));
1703ret_sts: 1796ret_sts:
@@ -1723,7 +1816,7 @@ static int be_setup_wol(struct be_adapter *adapter, bool enable)
1723 PCICFG_PM_CONTROL_OFFSET, PCICFG_PM_CONTROL_MASK); 1816 PCICFG_PM_CONTROL_OFFSET, PCICFG_PM_CONTROL_MASK);
1724 if (status) { 1817 if (status) {
1725 dev_err(&adapter->pdev->dev, 1818 dev_err(&adapter->pdev->dev,
1726 "Could not enable Wake-on-lan \n"); 1819 "Could not enable Wake-on-lan\n");
1727 pci_free_consistent(adapter->pdev, cmd.size, cmd.va, 1820 pci_free_consistent(adapter->pdev, cmd.size, cmd.va,
1728 cmd.dma); 1821 cmd.dma);
1729 return status; 1822 return status;
@@ -1745,22 +1838,48 @@ static int be_setup_wol(struct be_adapter *adapter, bool enable)
1745static int be_setup(struct be_adapter *adapter) 1838static int be_setup(struct be_adapter *adapter)
1746{ 1839{
1747 struct net_device *netdev = adapter->netdev; 1840 struct net_device *netdev = adapter->netdev;
1748 u32 cap_flags, en_flags; 1841 u32 cap_flags, en_flags, vf = 0;
1749 int status; 1842 int status;
1843 u8 mac[ETH_ALEN];
1750 1844
1751 cap_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | 1845 cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST;
1752 BE_IF_FLAGS_MCAST_PROMISCUOUS | 1846
1753 BE_IF_FLAGS_PROMISCUOUS | 1847 if (be_physfn(adapter)) {
1754 BE_IF_FLAGS_PASS_L3L4_ERRORS; 1848 cap_flags |= BE_IF_FLAGS_MCAST_PROMISCUOUS |
1755 en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | 1849 BE_IF_FLAGS_PROMISCUOUS |
1756 BE_IF_FLAGS_PASS_L3L4_ERRORS; 1850 BE_IF_FLAGS_PASS_L3L4_ERRORS;
1851 en_flags |= BE_IF_FLAGS_PASS_L3L4_ERRORS;
1852 }
1757 1853
1758 status = be_cmd_if_create(adapter, cap_flags, en_flags, 1854 status = be_cmd_if_create(adapter, cap_flags, en_flags,
1759 netdev->dev_addr, false/* pmac_invalid */, 1855 netdev->dev_addr, false/* pmac_invalid */,
1760 &adapter->if_handle, &adapter->pmac_id); 1856 &adapter->if_handle, &adapter->pmac_id, 0);
1761 if (status != 0) 1857 if (status != 0)
1762 goto do_none; 1858 goto do_none;
1763 1859
1860 if (be_physfn(adapter)) {
1861 while (vf < num_vfs) {
1862 cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED
1863 | BE_IF_FLAGS_BROADCAST;
1864 status = be_cmd_if_create(adapter, cap_flags, en_flags,
1865 mac, true, &adapter->vf_if_handle[vf],
1866 NULL, vf+1);
1867 if (status) {
1868 dev_err(&adapter->pdev->dev,
1869 "Interface Create failed for VF %d\n", vf);
1870 goto if_destroy;
1871 }
1872 vf++;
1873 } while (vf < num_vfs);
1874 } else if (!be_physfn(adapter)) {
1875 status = be_cmd_mac_addr_query(adapter, mac,
1876 MAC_ADDRESS_TYPE_NETWORK, false, adapter->if_handle);
1877 if (!status) {
1878 memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN);
1879 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN);
1880 }
1881 }
1882
1764 status = be_tx_queues_create(adapter); 1883 status = be_tx_queues_create(adapter);
1765 if (status != 0) 1884 if (status != 0)
1766 goto if_destroy; 1885 goto if_destroy;
@@ -1782,6 +1901,9 @@ rx_qs_destroy:
1782tx_qs_destroy: 1901tx_qs_destroy:
1783 be_tx_queues_destroy(adapter); 1902 be_tx_queues_destroy(adapter);
1784if_destroy: 1903if_destroy:
1904 for (vf = 0; vf < num_vfs; vf++)
1905 if (adapter->vf_if_handle[vf])
1906 be_cmd_if_destroy(adapter, adapter->vf_if_handle[vf]);
1785 be_cmd_if_destroy(adapter, adapter->if_handle); 1907 be_cmd_if_destroy(adapter, adapter->if_handle);
1786do_none: 1908do_none:
1787 return status; 1909 return status;
@@ -2061,6 +2183,7 @@ static struct net_device_ops be_netdev_ops = {
2061 .ndo_vlan_rx_register = be_vlan_register, 2183 .ndo_vlan_rx_register = be_vlan_register,
2062 .ndo_vlan_rx_add_vid = be_vlan_add_vid, 2184 .ndo_vlan_rx_add_vid = be_vlan_add_vid,
2063 .ndo_vlan_rx_kill_vid = be_vlan_rem_vid, 2185 .ndo_vlan_rx_kill_vid = be_vlan_rem_vid,
2186 .ndo_set_vf_mac = be_set_vf_mac
2064}; 2187};
2065 2188
2066static void be_netdev_init(struct net_device *netdev) 2189static void be_netdev_init(struct net_device *netdev)
@@ -2102,37 +2225,48 @@ static void be_unmap_pci_bars(struct be_adapter *adapter)
2102 iounmap(adapter->csr); 2225 iounmap(adapter->csr);
2103 if (adapter->db) 2226 if (adapter->db)
2104 iounmap(adapter->db); 2227 iounmap(adapter->db);
2105 if (adapter->pcicfg) 2228 if (adapter->pcicfg && be_physfn(adapter))
2106 iounmap(adapter->pcicfg); 2229 iounmap(adapter->pcicfg);
2107} 2230}
2108 2231
2109static int be_map_pci_bars(struct be_adapter *adapter) 2232static int be_map_pci_bars(struct be_adapter *adapter)
2110{ 2233{
2111 u8 __iomem *addr; 2234 u8 __iomem *addr;
2112 int pcicfg_reg; 2235 int pcicfg_reg, db_reg;
2113
2114 addr = ioremap_nocache(pci_resource_start(adapter->pdev, 2),
2115 pci_resource_len(adapter->pdev, 2));
2116 if (addr == NULL)
2117 return -ENOMEM;
2118 adapter->csr = addr;
2119 2236
2120 addr = ioremap_nocache(pci_resource_start(adapter->pdev, 4), 2237 if (be_physfn(adapter)) {
2121 128 * 1024); 2238 addr = ioremap_nocache(pci_resource_start(adapter->pdev, 2),
2122 if (addr == NULL) 2239 pci_resource_len(adapter->pdev, 2));
2123 goto pci_map_err; 2240 if (addr == NULL)
2124 adapter->db = addr; 2241 return -ENOMEM;
2242 adapter->csr = addr;
2243 }
2125 2244
2126 if (adapter->generation == BE_GEN2) 2245 if (adapter->generation == BE_GEN2) {
2127 pcicfg_reg = 1; 2246 pcicfg_reg = 1;
2128 else 2247 db_reg = 4;
2248 } else {
2129 pcicfg_reg = 0; 2249 pcicfg_reg = 0;
2130 2250 if (be_physfn(adapter))
2131 addr = ioremap_nocache(pci_resource_start(adapter->pdev, pcicfg_reg), 2251 db_reg = 4;
2132 pci_resource_len(adapter->pdev, pcicfg_reg)); 2252 else
2253 db_reg = 0;
2254 }
2255 addr = ioremap_nocache(pci_resource_start(adapter->pdev, db_reg),
2256 pci_resource_len(adapter->pdev, db_reg));
2133 if (addr == NULL) 2257 if (addr == NULL)
2134 goto pci_map_err; 2258 goto pci_map_err;
2135 adapter->pcicfg = addr; 2259 adapter->db = addr;
2260
2261 if (be_physfn(adapter)) {
2262 addr = ioremap_nocache(
2263 pci_resource_start(adapter->pdev, pcicfg_reg),
2264 pci_resource_len(adapter->pdev, pcicfg_reg));
2265 if (addr == NULL)
2266 goto pci_map_err;
2267 adapter->pcicfg = addr;
2268 } else
2269 adapter->pcicfg = adapter->db + SRIOV_VF_PCICFG_OFFSET;
2136 2270
2137 return 0; 2271 return 0;
2138pci_map_err: 2272pci_map_err:
@@ -2246,6 +2380,8 @@ static void __devexit be_remove(struct pci_dev *pdev)
2246 2380
2247 be_ctrl_cleanup(adapter); 2381 be_ctrl_cleanup(adapter);
2248 2382
2383 be_sriov_disable(adapter);
2384
2249 be_msix_disable(adapter); 2385 be_msix_disable(adapter);
2250 2386
2251 pci_set_drvdata(pdev, NULL); 2387 pci_set_drvdata(pdev, NULL);
@@ -2270,16 +2406,20 @@ static int be_get_config(struct be_adapter *adapter)
2270 return status; 2406 return status;
2271 2407
2272 memset(mac, 0, ETH_ALEN); 2408 memset(mac, 0, ETH_ALEN);
2273 status = be_cmd_mac_addr_query(adapter, mac, 2409
2410 if (be_physfn(adapter)) {
2411 status = be_cmd_mac_addr_query(adapter, mac,
2274 MAC_ADDRESS_TYPE_NETWORK, true /*permanent */, 0); 2412 MAC_ADDRESS_TYPE_NETWORK, true /*permanent */, 0);
2275 if (status)
2276 return status;
2277 2413
2278 if (!is_valid_ether_addr(mac)) 2414 if (status)
2279 return -EADDRNOTAVAIL; 2415 return status;
2416
2417 if (!is_valid_ether_addr(mac))
2418 return -EADDRNOTAVAIL;
2280 2419
2281 memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN); 2420 memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN);
2282 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN); 2421 memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN);
2422 }
2283 2423
2284 if (adapter->cap & 0x400) 2424 if (adapter->cap & 0x400)
2285 adapter->max_vlans = BE_NUM_VLANS_SUPPORTED/4; 2425 adapter->max_vlans = BE_NUM_VLANS_SUPPORTED/4;
@@ -2296,6 +2436,7 @@ static int __devinit be_probe(struct pci_dev *pdev,
2296 struct be_adapter *adapter; 2436 struct be_adapter *adapter;
2297 struct net_device *netdev; 2437 struct net_device *netdev;
2298 2438
2439
2299 status = pci_enable_device(pdev); 2440 status = pci_enable_device(pdev);
2300 if (status) 2441 if (status)
2301 goto do_none; 2442 goto do_none;
@@ -2344,24 +2485,28 @@ static int __devinit be_probe(struct pci_dev *pdev,
2344 } 2485 }
2345 } 2486 }
2346 2487
2488 be_sriov_enable(adapter);
2489
2347 status = be_ctrl_init(adapter); 2490 status = be_ctrl_init(adapter);
2348 if (status) 2491 if (status)
2349 goto free_netdev; 2492 goto free_netdev;
2350 2493
2351 /* sync up with fw's ready state */ 2494 /* sync up with fw's ready state */
2352 status = be_cmd_POST(adapter); 2495 if (be_physfn(adapter)) {
2353 if (status) 2496 status = be_cmd_POST(adapter);
2354 goto ctrl_clean; 2497 if (status)
2498 goto ctrl_clean;
2499
2500 status = be_cmd_reset_function(adapter);
2501 if (status)
2502 goto ctrl_clean;
2503 }
2355 2504
2356 /* tell fw we're ready to fire cmds */ 2505 /* tell fw we're ready to fire cmds */
2357 status = be_cmd_fw_init(adapter); 2506 status = be_cmd_fw_init(adapter);
2358 if (status) 2507 if (status)
2359 goto ctrl_clean; 2508 goto ctrl_clean;
2360 2509
2361 status = be_cmd_reset_function(adapter);
2362 if (status)
2363 goto ctrl_clean;
2364
2365 status = be_stats_init(adapter); 2510 status = be_stats_init(adapter);
2366 if (status) 2511 if (status)
2367 goto ctrl_clean; 2512 goto ctrl_clean;
@@ -2391,6 +2536,7 @@ ctrl_clean:
2391 be_ctrl_cleanup(adapter); 2536 be_ctrl_cleanup(adapter);
2392free_netdev: 2537free_netdev:
2393 be_msix_disable(adapter); 2538 be_msix_disable(adapter);
2539 be_sriov_disable(adapter);
2394 free_netdev(adapter->netdev); 2540 free_netdev(adapter->netdev);
2395 pci_set_drvdata(pdev, NULL); 2541 pci_set_drvdata(pdev, NULL);
2396rel_reg: 2542rel_reg:
@@ -2587,6 +2733,13 @@ static int __init be_init_module(void)
2587 rx_frag_size = 2048; 2733 rx_frag_size = 2048;
2588 } 2734 }
2589 2735
2736 if (num_vfs > 32) {
2737 printk(KERN_WARNING DRV_NAME
2738 " : Module param num_vfs must not be greater than 32."
2739 "Using 32\n");
2740 num_vfs = 32;
2741 }
2742
2590 return pci_register_driver(&be_driver); 2743 return pci_register_driver(&be_driver);
2591} 2744}
2592module_init(be_init_module); 2745module_init(be_init_module);
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index 587f93cf03f6..c488cea8f455 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -812,14 +812,14 @@ static void bfin_mac_timeout(struct net_device *dev)
812static void bfin_mac_multicast_hash(struct net_device *dev) 812static void bfin_mac_multicast_hash(struct net_device *dev)
813{ 813{
814 u32 emac_hashhi, emac_hashlo; 814 u32 emac_hashhi, emac_hashlo;
815 struct dev_mc_list *dmi; 815 struct netdev_hw_addr *ha;
816 char *addrs; 816 char *addrs;
817 u32 crc; 817 u32 crc;
818 818
819 emac_hashhi = emac_hashlo = 0; 819 emac_hashhi = emac_hashlo = 0;
820 820
821 netdev_for_each_mc_addr(dmi, dev) { 821 netdev_for_each_mc_addr(ha, dev) {
822 addrs = dmi->dmi_addr; 822 addrs = ha->addr;
823 823
824 /* skip non-multicast addresses */ 824 /* skip non-multicast addresses */
825 if (!(*addrs & 1)) 825 if (!(*addrs & 1))
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c
index 119468e76323..1245e9835765 100644
--- a/drivers/net/bmac.c
+++ b/drivers/net/bmac.c
@@ -971,7 +971,7 @@ bmac_remove_multi(struct net_device *dev,
971 */ 971 */
972static void bmac_set_multicast(struct net_device *dev) 972static void bmac_set_multicast(struct net_device *dev)
973{ 973{
974 struct dev_mc_list *dmi; 974 struct netdev_hw_addr *ha;
975 struct bmac_data *bp = netdev_priv(dev); 975 struct bmac_data *bp = netdev_priv(dev);
976 int num_addrs = netdev_mc_count(dev); 976 int num_addrs = netdev_mc_count(dev);
977 unsigned short rx_cfg; 977 unsigned short rx_cfg;
@@ -1000,8 +1000,8 @@ static void bmac_set_multicast(struct net_device *dev)
1000 rx_cfg = bmac_rx_on(dev, 0, 0); 1000 rx_cfg = bmac_rx_on(dev, 0, 0);
1001 XXDEBUG(("bmac: multi disabled, rx_cfg=%#08x\n", rx_cfg)); 1001 XXDEBUG(("bmac: multi disabled, rx_cfg=%#08x\n", rx_cfg));
1002 } else { 1002 } else {
1003 netdev_for_each_mc_addr(dmi, dev) 1003 netdev_for_each_mc_addr(ha, dev)
1004 bmac_addhash(bp, dmi->dmi_addr); 1004 bmac_addhash(bp, ha->addr);
1005 bmac_update_hash_table_mask(dev, bp); 1005 bmac_update_hash_table_mask(dev, bp);
1006 rx_cfg = bmac_rx_on(dev, 1, 0); 1006 rx_cfg = bmac_rx_on(dev, 1, 0);
1007 XXDEBUG(("bmac: multi enabled, rx_cfg=%#08x\n", rx_cfg)); 1007 XXDEBUG(("bmac: multi enabled, rx_cfg=%#08x\n", rx_cfg));
@@ -1015,7 +1015,7 @@ static void bmac_set_multicast(struct net_device *dev)
1015 1015
1016static void bmac_set_multicast(struct net_device *dev) 1016static void bmac_set_multicast(struct net_device *dev)
1017{ 1017{
1018 struct dev_mc_list *dmi; 1018 struct netdev_hw_addr *ha;
1019 char *addrs; 1019 char *addrs;
1020 int i; 1020 int i;
1021 unsigned short rx_cfg; 1021 unsigned short rx_cfg;
@@ -1039,8 +1039,8 @@ static void bmac_set_multicast(struct net_device *dev)
1039 1039
1040 for(i = 0; i < 4; i++) hash_table[i] = 0; 1040 for(i = 0; i < 4; i++) hash_table[i] = 0;
1041 1041
1042 netdev_for_each_mc_addr(dmi, dev) { 1042 netdev_for_each_mc_addr(ha, dev) {
1043 addrs = dmi->dmi_addr; 1043 addrs = ha->addr;
1044 1044
1045 if(!(*addrs & 1)) 1045 if(!(*addrs & 1))
1046 continue; 1046 continue;
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index a257babd1bb4..802b538502eb 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -3546,7 +3546,6 @@ bnx2_set_rx_mode(struct net_device *dev)
3546 } 3546 }
3547 else { 3547 else {
3548 /* Accept one or more multicast(s). */ 3548 /* Accept one or more multicast(s). */
3549 struct dev_mc_list *mclist;
3550 u32 mc_filter[NUM_MC_HASH_REGISTERS]; 3549 u32 mc_filter[NUM_MC_HASH_REGISTERS];
3551 u32 regidx; 3550 u32 regidx;
3552 u32 bit; 3551 u32 bit;
@@ -3554,8 +3553,8 @@ bnx2_set_rx_mode(struct net_device *dev)
3554 3553
3555 memset(mc_filter, 0, 4 * NUM_MC_HASH_REGISTERS); 3554 memset(mc_filter, 0, 4 * NUM_MC_HASH_REGISTERS);
3556 3555
3557 netdev_for_each_mc_addr(mclist, dev) { 3556 netdev_for_each_mc_addr(ha, dev) {
3558 crc = ether_crc_le(ETH_ALEN, mclist->dmi_addr); 3557 crc = ether_crc_le(ETH_ALEN, ha->addr);
3559 bit = crc & 0xff; 3558 bit = crc & 0xff;
3560 regidx = (bit & 0xe0) >> 5; 3559 regidx = (bit & 0xe0) >> 5;
3561 bit &= 0x1f; 3560 bit &= 0x1f;
diff --git a/drivers/net/bnx2x_link.c b/drivers/net/bnx2x_link.c
index 32e79c359e89..ff70be898765 100644
--- a/drivers/net/bnx2x_link.c
+++ b/drivers/net/bnx2x_link.c
@@ -1594,7 +1594,7 @@ static u8 bnx2x_ext_phy_resolve_fc(struct link_params *params,
1594 MDIO_AN_REG_ADV_PAUSE_MASK) >> 8; 1594 MDIO_AN_REG_ADV_PAUSE_MASK) >> 8;
1595 pause_result |= (lp_pause & 1595 pause_result |= (lp_pause &
1596 MDIO_AN_REG_ADV_PAUSE_MASK) >> 10; 1596 MDIO_AN_REG_ADV_PAUSE_MASK) >> 10;
1597 DP(NETIF_MSG_LINK, "Ext PHY pause result 0x%x \n", 1597 DP(NETIF_MSG_LINK, "Ext PHY pause result 0x%x\n",
1598 pause_result); 1598 pause_result);
1599 bnx2x_pause_resolve(vars, pause_result); 1599 bnx2x_pause_resolve(vars, pause_result);
1600 if (vars->flow_ctrl == BNX2X_FLOW_CTRL_NONE && 1600 if (vars->flow_ctrl == BNX2X_FLOW_CTRL_NONE &&
@@ -1616,7 +1616,7 @@ static u8 bnx2x_ext_phy_resolve_fc(struct link_params *params,
1616 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 7; 1616 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_BOTH) >> 7;
1617 1617
1618 bnx2x_pause_resolve(vars, pause_result); 1618 bnx2x_pause_resolve(vars, pause_result);
1619 DP(NETIF_MSG_LINK, "Ext PHY CL37 pause result 0x%x \n", 1619 DP(NETIF_MSG_LINK, "Ext PHY CL37 pause result 0x%x\n",
1620 pause_result); 1620 pause_result);
1621 } 1621 }
1622 } 1622 }
@@ -1974,7 +1974,7 @@ static u8 bnx2x_link_settings_status(struct link_params *params,
1974 } 1974 }
1975 } 1975 }
1976 1976
1977 DP(NETIF_MSG_LINK, "gp_status 0x%x phy_link_up %x line_speed %x \n", 1977 DP(NETIF_MSG_LINK, "gp_status 0x%x phy_link_up %x line_speed %x\n",
1978 gp_status, vars->phy_link_up, vars->line_speed); 1978 gp_status, vars->phy_link_up, vars->line_speed);
1979 DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x" 1979 DP(NETIF_MSG_LINK, "duplex %x flow_ctrl 0x%x"
1980 " autoneg 0x%x\n", 1980 " autoneg 0x%x\n",
@@ -3852,7 +3852,7 @@ static u8 bnx2x_ext_phy_init(struct link_params *params, struct link_vars *vars)
3852 SPEED_AUTO_NEG) && 3852 SPEED_AUTO_NEG) &&
3853 ((params->speed_cap_mask & 3853 ((params->speed_cap_mask &
3854 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G))) { 3854 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G))) {
3855 DP(NETIF_MSG_LINK, "Setting 1G clause37 \n"); 3855 DP(NETIF_MSG_LINK, "Setting 1G clause37\n");
3856 bnx2x_cl45_write(bp, params->port, ext_phy_type, 3856 bnx2x_cl45_write(bp, params->port, ext_phy_type,
3857 ext_phy_addr, MDIO_AN_DEVAD, 3857 ext_phy_addr, MDIO_AN_DEVAD,
3858 MDIO_AN_REG_ADV, 0x20); 3858 MDIO_AN_REG_ADV, 0x20);
@@ -4234,14 +4234,14 @@ static u8 bnx2x_ext_phy_init(struct link_params *params, struct link_vars *vars)
4234 ext_phy_addr, 4234 ext_phy_addr,
4235 MDIO_PMA_DEVAD, 4235 MDIO_PMA_DEVAD,
4236 MDIO_PMA_REG_10G_CTRL2, &tmp1); 4236 MDIO_PMA_REG_10G_CTRL2, &tmp1);
4237 DP(NETIF_MSG_LINK, "1.7 = 0x%x \n", tmp1); 4237 DP(NETIF_MSG_LINK, "1.7 = 0x%x\n", tmp1);
4238 4238
4239 } else if ((params->req_line_speed == 4239 } else if ((params->req_line_speed ==
4240 SPEED_AUTO_NEG) && 4240 SPEED_AUTO_NEG) &&
4241 ((params->speed_cap_mask & 4241 ((params->speed_cap_mask &
4242 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G))) { 4242 PORT_HW_CFG_SPEED_CAPABILITY_D0_1G))) {
4243 4243
4244 DP(NETIF_MSG_LINK, "Setting 1G clause37 \n"); 4244 DP(NETIF_MSG_LINK, "Setting 1G clause37\n");
4245 bnx2x_cl45_write(bp, params->port, ext_phy_type, 4245 bnx2x_cl45_write(bp, params->port, ext_phy_type,
4246 ext_phy_addr, MDIO_AN_DEVAD, 4246 ext_phy_addr, MDIO_AN_DEVAD,
4247 MDIO_PMA_REG_8727_MISC_CTRL, 0); 4247 MDIO_PMA_REG_8727_MISC_CTRL, 0);
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index 6c042a72d6cc..fa9275c2ef5c 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -57,8 +57,8 @@
57#include "bnx2x_init_ops.h" 57#include "bnx2x_init_ops.h"
58#include "bnx2x_dump.h" 58#include "bnx2x_dump.h"
59 59
60#define DRV_MODULE_VERSION "1.52.1-7" 60#define DRV_MODULE_VERSION "1.52.1-8"
61#define DRV_MODULE_RELDATE "2010/02/28" 61#define DRV_MODULE_RELDATE "2010/04/01"
62#define BNX2X_BC_VER 0x040200 62#define BNX2X_BC_VER 0x040200
63 63
64#include <linux/firmware.h> 64#include <linux/firmware.h>
@@ -1441,12 +1441,12 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1441#ifdef BCM_VLAN 1441#ifdef BCM_VLAN
1442 if ((bp->vlgrp != NULL) && is_vlan_cqe && 1442 if ((bp->vlgrp != NULL) && is_vlan_cqe &&
1443 (!is_not_hwaccel_vlan_cqe)) 1443 (!is_not_hwaccel_vlan_cqe))
1444 vlan_hwaccel_receive_skb(skb, bp->vlgrp, 1444 vlan_gro_receive(&fp->napi, bp->vlgrp,
1445 le16_to_cpu(cqe->fast_path_cqe. 1445 le16_to_cpu(cqe->fast_path_cqe.
1446 vlan_tag)); 1446 vlan_tag), skb);
1447 else 1447 else
1448#endif 1448#endif
1449 netif_receive_skb(skb); 1449 napi_gro_receive(&fp->napi, skb);
1450 } else { 1450 } else {
1451 DP(NETIF_MSG_RX_STATUS, "Failed to allocate new pages" 1451 DP(NETIF_MSG_RX_STATUS, "Failed to allocate new pages"
1452 " - dropping packet!\n"); 1452 " - dropping packet!\n");
@@ -1699,11 +1699,11 @@ reuse_rx:
1699 if ((bp->vlgrp != NULL) && (bp->flags & HW_VLAN_RX_FLAG) && 1699 if ((bp->vlgrp != NULL) && (bp->flags & HW_VLAN_RX_FLAG) &&
1700 (le16_to_cpu(cqe->fast_path_cqe.pars_flags.flags) & 1700 (le16_to_cpu(cqe->fast_path_cqe.pars_flags.flags) &
1701 PARSING_FLAGS_VLAN)) 1701 PARSING_FLAGS_VLAN))
1702 vlan_hwaccel_receive_skb(skb, bp->vlgrp, 1702 vlan_gro_receive(&fp->napi, bp->vlgrp,
1703 le16_to_cpu(cqe->fast_path_cqe.vlan_tag)); 1703 le16_to_cpu(cqe->fast_path_cqe.vlan_tag), skb);
1704 else 1704 else
1705#endif 1705#endif
1706 netif_receive_skb(skb); 1706 napi_gro_receive(&fp->napi, skb);
1707 1707
1708 1708
1709next_rx: 1709next_rx:
@@ -8935,6 +8935,8 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
8935 bp->multi_mode = multi_mode; 8935 bp->multi_mode = multi_mode;
8936 8936
8937 8937
8938 bp->dev->features |= NETIF_F_GRO;
8939
8938 /* Set TPA flags */ 8940 /* Set TPA flags */
8939 if (disable_tpa) { 8941 if (disable_tpa) {
8940 bp->flags &= ~TPA_ENABLE_FLAG; 8942 bp->flags &= ~TPA_ENABLE_FLAG;
@@ -11494,21 +11496,21 @@ static void bnx2x_set_rx_mode(struct net_device *dev)
11494 else { /* some multicasts */ 11496 else { /* some multicasts */
11495 if (CHIP_IS_E1(bp)) { 11497 if (CHIP_IS_E1(bp)) {
11496 int i, old, offset; 11498 int i, old, offset;
11497 struct dev_mc_list *mclist; 11499 struct netdev_hw_addr *ha;
11498 struct mac_configuration_cmd *config = 11500 struct mac_configuration_cmd *config =
11499 bnx2x_sp(bp, mcast_config); 11501 bnx2x_sp(bp, mcast_config);
11500 11502
11501 i = 0; 11503 i = 0;
11502 netdev_for_each_mc_addr(mclist, dev) { 11504 netdev_for_each_mc_addr(ha, dev) {
11503 config->config_table[i]. 11505 config->config_table[i].
11504 cam_entry.msb_mac_addr = 11506 cam_entry.msb_mac_addr =
11505 swab16(*(u16 *)&mclist->dmi_addr[0]); 11507 swab16(*(u16 *)&ha->addr[0]);
11506 config->config_table[i]. 11508 config->config_table[i].
11507 cam_entry.middle_mac_addr = 11509 cam_entry.middle_mac_addr =
11508 swab16(*(u16 *)&mclist->dmi_addr[2]); 11510 swab16(*(u16 *)&ha->addr[2]);
11509 config->config_table[i]. 11511 config->config_table[i].
11510 cam_entry.lsb_mac_addr = 11512 cam_entry.lsb_mac_addr =
11511 swab16(*(u16 *)&mclist->dmi_addr[4]); 11513 swab16(*(u16 *)&ha->addr[4]);
11512 config->config_table[i].cam_entry.flags = 11514 config->config_table[i].cam_entry.flags =
11513 cpu_to_le16(port); 11515 cpu_to_le16(port);
11514 config->config_table[i]. 11516 config->config_table[i].
@@ -11562,18 +11564,18 @@ static void bnx2x_set_rx_mode(struct net_device *dev)
11562 0); 11564 0);
11563 } else { /* E1H */ 11565 } else { /* E1H */
11564 /* Accept one or more multicasts */ 11566 /* Accept one or more multicasts */
11565 struct dev_mc_list *mclist; 11567 struct netdev_hw_addr *ha;
11566 u32 mc_filter[MC_HASH_SIZE]; 11568 u32 mc_filter[MC_HASH_SIZE];
11567 u32 crc, bit, regidx; 11569 u32 crc, bit, regidx;
11568 int i; 11570 int i;
11569 11571
11570 memset(mc_filter, 0, 4 * MC_HASH_SIZE); 11572 memset(mc_filter, 0, 4 * MC_HASH_SIZE);
11571 11573
11572 netdev_for_each_mc_addr(mclist, dev) { 11574 netdev_for_each_mc_addr(ha, dev) {
11573 DP(NETIF_MSG_IFUP, "Adding mcast MAC: %pM\n", 11575 DP(NETIF_MSG_IFUP, "Adding mcast MAC: %pM\n",
11574 mclist->dmi_addr); 11576 ha->addr);
11575 11577
11576 crc = crc32c_le(0, mclist->dmi_addr, ETH_ALEN); 11578 crc = crc32c_le(0, ha->addr, ETH_ALEN);
11577 bit = (crc >> 24) & 0xff; 11579 bit = (crc >> 24) & 0xff;
11578 regidx = bit >> 5; 11580 regidx = bit >> 5;
11579 bit &= 0x1f; 11581 bit &= 0x1f;
diff --git a/drivers/net/bonding/bond_ipv6.c b/drivers/net/bonding/bond_ipv6.c
index 6dd64cf3cb76..969ffed86b9f 100644
--- a/drivers/net/bonding/bond_ipv6.c
+++ b/drivers/net/bonding/bond_ipv6.c
@@ -37,7 +37,6 @@
37static void bond_glean_dev_ipv6(struct net_device *dev, struct in6_addr *addr) 37static void bond_glean_dev_ipv6(struct net_device *dev, struct in6_addr *addr)
38{ 38{
39 struct inet6_dev *idev; 39 struct inet6_dev *idev;
40 struct inet6_ifaddr *ifa;
41 40
42 if (!dev) 41 if (!dev)
43 return; 42 return;
@@ -47,10 +46,12 @@ static void bond_glean_dev_ipv6(struct net_device *dev, struct in6_addr *addr)
47 return; 46 return;
48 47
49 read_lock_bh(&idev->lock); 48 read_lock_bh(&idev->lock);
50 ifa = idev->addr_list; 49 if (!list_empty(&idev->addr_list)) {
51 if (ifa) 50 struct inet6_ifaddr *ifa
51 = list_first_entry(&idev->addr_list,
52 struct inet6_ifaddr, if_list);
52 ipv6_addr_copy(addr, &ifa->addr); 53 ipv6_addr_copy(addr, &ifa->addr);
53 else 54 } else
54 ipv6_addr_set(addr, 0, 0, 0, 0); 55 ipv6_addr_set(addr, 0, 0, 0, 0);
55 56
56 read_unlock_bh(&idev->lock); 57 read_unlock_bh(&idev->lock);
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 0075514bf32f..85e813c7762b 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -762,32 +762,6 @@ static int bond_check_dev_link(struct bonding *bond,
762/*----------------------------- Multicast list ------------------------------*/ 762/*----------------------------- Multicast list ------------------------------*/
763 763
764/* 764/*
765 * Returns 0 if dmi1 and dmi2 are the same, non-0 otherwise
766 */
767static inline int bond_is_dmi_same(const struct dev_mc_list *dmi1,
768 const struct dev_mc_list *dmi2)
769{
770 return memcmp(dmi1->dmi_addr, dmi2->dmi_addr, dmi1->dmi_addrlen) == 0 &&
771 dmi1->dmi_addrlen == dmi2->dmi_addrlen;
772}
773
774/*
775 * returns dmi entry if found, NULL otherwise
776 */
777static struct dev_mc_list *bond_mc_list_find_dmi(struct dev_mc_list *dmi,
778 struct dev_mc_list *mc_list)
779{
780 struct dev_mc_list *idmi;
781
782 for (idmi = mc_list; idmi; idmi = idmi->next) {
783 if (bond_is_dmi_same(dmi, idmi))
784 return idmi;
785 }
786
787 return NULL;
788}
789
790/*
791 * Push the promiscuity flag down to appropriate slaves 765 * Push the promiscuity flag down to appropriate slaves
792 */ 766 */
793static int bond_set_promiscuity(struct bonding *bond, int inc) 767static int bond_set_promiscuity(struct bonding *bond, int inc)
@@ -839,18 +813,18 @@ static int bond_set_allmulti(struct bonding *bond, int inc)
839 * Add a Multicast address to slaves 813 * Add a Multicast address to slaves
840 * according to mode 814 * according to mode
841 */ 815 */
842static void bond_mc_add(struct bonding *bond, void *addr, int alen) 816static void bond_mc_add(struct bonding *bond, void *addr)
843{ 817{
844 if (USES_PRIMARY(bond->params.mode)) { 818 if (USES_PRIMARY(bond->params.mode)) {
845 /* write lock already acquired */ 819 /* write lock already acquired */
846 if (bond->curr_active_slave) 820 if (bond->curr_active_slave)
847 dev_mc_add(bond->curr_active_slave->dev, addr, alen, 0); 821 dev_mc_add(bond->curr_active_slave->dev, addr);
848 } else { 822 } else {
849 struct slave *slave; 823 struct slave *slave;
850 int i; 824 int i;
851 825
852 bond_for_each_slave(bond, slave, i) 826 bond_for_each_slave(bond, slave, i)
853 dev_mc_add(slave->dev, addr, alen, 0); 827 dev_mc_add(slave->dev, addr);
854 } 828 }
855} 829}
856 830
@@ -858,18 +832,17 @@ static void bond_mc_add(struct bonding *bond, void *addr, int alen)
858 * Remove a multicast address from slave 832 * Remove a multicast address from slave
859 * according to mode 833 * according to mode
860 */ 834 */
861static void bond_mc_delete(struct bonding *bond, void *addr, int alen) 835static void bond_mc_del(struct bonding *bond, void *addr)
862{ 836{
863 if (USES_PRIMARY(bond->params.mode)) { 837 if (USES_PRIMARY(bond->params.mode)) {
864 /* write lock already acquired */ 838 /* write lock already acquired */
865 if (bond->curr_active_slave) 839 if (bond->curr_active_slave)
866 dev_mc_delete(bond->curr_active_slave->dev, addr, 840 dev_mc_del(bond->curr_active_slave->dev, addr);
867 alen, 0);
868 } else { 841 } else {
869 struct slave *slave; 842 struct slave *slave;
870 int i; 843 int i;
871 bond_for_each_slave(bond, slave, i) { 844 bond_for_each_slave(bond, slave, i) {
872 dev_mc_delete(slave->dev, addr, alen, 0); 845 dev_mc_del(slave->dev, addr);
873 } 846 }
874 } 847 }
875} 848}
@@ -896,66 +869,22 @@ static void bond_resend_igmp_join_requests(struct bonding *bond)
896} 869}
897 870
898/* 871/*
899 * Totally destroys the mc_list in bond
900 */
901static void bond_mc_list_destroy(struct bonding *bond)
902{
903 struct dev_mc_list *dmi;
904
905 dmi = bond->mc_list;
906 while (dmi) {
907 bond->mc_list = dmi->next;
908 kfree(dmi);
909 dmi = bond->mc_list;
910 }
911
912 bond->mc_list = NULL;
913}
914
915/*
916 * Copy all the Multicast addresses from src to the bonding device dst
917 */
918static int bond_mc_list_copy(struct dev_mc_list *mc_list, struct bonding *bond,
919 gfp_t gfp_flag)
920{
921 struct dev_mc_list *dmi, *new_dmi;
922
923 for (dmi = mc_list; dmi; dmi = dmi->next) {
924 new_dmi = kmalloc(sizeof(struct dev_mc_list), gfp_flag);
925
926 if (!new_dmi) {
927 /* FIXME: Potential memory leak !!! */
928 return -ENOMEM;
929 }
930
931 new_dmi->next = bond->mc_list;
932 bond->mc_list = new_dmi;
933 new_dmi->dmi_addrlen = dmi->dmi_addrlen;
934 memcpy(new_dmi->dmi_addr, dmi->dmi_addr, dmi->dmi_addrlen);
935 new_dmi->dmi_users = dmi->dmi_users;
936 new_dmi->dmi_gusers = dmi->dmi_gusers;
937 }
938
939 return 0;
940}
941
942/*
943 * flush all members of flush->mc_list from device dev->mc_list 872 * flush all members of flush->mc_list from device dev->mc_list
944 */ 873 */
945static void bond_mc_list_flush(struct net_device *bond_dev, 874static void bond_mc_list_flush(struct net_device *bond_dev,
946 struct net_device *slave_dev) 875 struct net_device *slave_dev)
947{ 876{
948 struct bonding *bond = netdev_priv(bond_dev); 877 struct bonding *bond = netdev_priv(bond_dev);
949 struct dev_mc_list *dmi; 878 struct netdev_hw_addr *ha;
950 879
951 for (dmi = bond_dev->mc_list; dmi; dmi = dmi->next) 880 netdev_for_each_mc_addr(ha, bond_dev)
952 dev_mc_delete(slave_dev, dmi->dmi_addr, dmi->dmi_addrlen, 0); 881 dev_mc_del(slave_dev, ha->addr);
953 882
954 if (bond->params.mode == BOND_MODE_8023AD) { 883 if (bond->params.mode == BOND_MODE_8023AD) {
955 /* del lacpdu mc addr from mc list */ 884 /* del lacpdu mc addr from mc list */
956 u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR; 885 u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR;
957 886
958 dev_mc_delete(slave_dev, lacpdu_multicast, ETH_ALEN, 0); 887 dev_mc_del(slave_dev, lacpdu_multicast);
959 } 888 }
960} 889}
961 890
@@ -969,7 +898,7 @@ static void bond_mc_list_flush(struct net_device *bond_dev,
969static void bond_mc_swap(struct bonding *bond, struct slave *new_active, 898static void bond_mc_swap(struct bonding *bond, struct slave *new_active,
970 struct slave *old_active) 899 struct slave *old_active)
971{ 900{
972 struct dev_mc_list *dmi; 901 struct netdev_hw_addr *ha;
973 902
974 if (!USES_PRIMARY(bond->params.mode)) 903 if (!USES_PRIMARY(bond->params.mode))
975 /* nothing to do - mc list is already up-to-date on 904 /* nothing to do - mc list is already up-to-date on
@@ -984,9 +913,8 @@ static void bond_mc_swap(struct bonding *bond, struct slave *new_active,
984 if (bond->dev->flags & IFF_ALLMULTI) 913 if (bond->dev->flags & IFF_ALLMULTI)
985 dev_set_allmulti(old_active->dev, -1); 914 dev_set_allmulti(old_active->dev, -1);
986 915
987 for (dmi = bond->dev->mc_list; dmi; dmi = dmi->next) 916 netdev_for_each_mc_addr(ha, bond->dev)
988 dev_mc_delete(old_active->dev, dmi->dmi_addr, 917 dev_mc_del(old_active->dev, ha->addr);
989 dmi->dmi_addrlen, 0);
990 } 918 }
991 919
992 if (new_active) { 920 if (new_active) {
@@ -997,9 +925,8 @@ static void bond_mc_swap(struct bonding *bond, struct slave *new_active,
997 if (bond->dev->flags & IFF_ALLMULTI) 925 if (bond->dev->flags & IFF_ALLMULTI)
998 dev_set_allmulti(new_active->dev, 1); 926 dev_set_allmulti(new_active->dev, 1);
999 927
1000 for (dmi = bond->dev->mc_list; dmi; dmi = dmi->next) 928 netdev_for_each_mc_addr(ha, bond->dev)
1001 dev_mc_add(new_active->dev, dmi->dmi_addr, 929 dev_mc_add(new_active->dev, ha->addr);
1002 dmi->dmi_addrlen, 0);
1003 bond_resend_igmp_join_requests(bond); 930 bond_resend_igmp_join_requests(bond);
1004 } 931 }
1005} 932}
@@ -1411,7 +1338,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1411 struct bonding *bond = netdev_priv(bond_dev); 1338 struct bonding *bond = netdev_priv(bond_dev);
1412 const struct net_device_ops *slave_ops = slave_dev->netdev_ops; 1339 const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
1413 struct slave *new_slave = NULL; 1340 struct slave *new_slave = NULL;
1414 struct dev_mc_list *dmi; 1341 struct netdev_hw_addr *ha;
1415 struct sockaddr addr; 1342 struct sockaddr addr;
1416 int link_reporting; 1343 int link_reporting;
1417 int old_features = bond_dev->features; 1344 int old_features = bond_dev->features;
@@ -1485,14 +1412,27 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1485 bond_dev->name, 1412 bond_dev->name,
1486 bond_dev->type, slave_dev->type); 1413 bond_dev->type, slave_dev->type);
1487 1414
1488 netdev_bonding_change(bond_dev, NETDEV_BONDING_OLDTYPE); 1415 res = netdev_bonding_change(bond_dev,
1416 NETDEV_PRE_TYPE_CHANGE);
1417 res = notifier_to_errno(res);
1418 if (res) {
1419 pr_err("%s: refused to change device type\n",
1420 bond_dev->name);
1421 res = -EBUSY;
1422 goto err_undo_flags;
1423 }
1424
1425 /* Flush unicast and multicast addresses */
1426 dev_uc_flush(bond_dev);
1427 dev_mc_flush(bond_dev);
1489 1428
1490 if (slave_dev->type != ARPHRD_ETHER) 1429 if (slave_dev->type != ARPHRD_ETHER)
1491 bond_setup_by_slave(bond_dev, slave_dev); 1430 bond_setup_by_slave(bond_dev, slave_dev);
1492 else 1431 else
1493 ether_setup(bond_dev); 1432 ether_setup(bond_dev);
1494 1433
1495 netdev_bonding_change(bond_dev, NETDEV_BONDING_NEWTYPE); 1434 netdev_bonding_change(bond_dev,
1435 NETDEV_POST_TYPE_CHANGE);
1496 } 1436 }
1497 } else if (bond_dev->type != slave_dev->type) { 1437 } else if (bond_dev->type != slave_dev->type) {
1498 pr_err("%s ether type (%d) is different from other slaves (%d), can not enslave it.\n", 1438 pr_err("%s ether type (%d) is different from other slaves (%d), can not enslave it.\n",
@@ -1593,9 +1533,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1593 1533
1594 netif_addr_lock_bh(bond_dev); 1534 netif_addr_lock_bh(bond_dev);
1595 /* upload master's mc_list to new slave */ 1535 /* upload master's mc_list to new slave */
1596 for (dmi = bond_dev->mc_list; dmi; dmi = dmi->next) 1536 netdev_for_each_mc_addr(ha, bond_dev)
1597 dev_mc_add(slave_dev, dmi->dmi_addr, 1537 dev_mc_add(slave_dev, ha->addr);
1598 dmi->dmi_addrlen, 0);
1599 netif_addr_unlock_bh(bond_dev); 1538 netif_addr_unlock_bh(bond_dev);
1600 } 1539 }
1601 1540
@@ -1603,7 +1542,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1603 /* add lacpdu mc addr to mc list */ 1542 /* add lacpdu mc addr to mc list */
1604 u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR; 1543 u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR;
1605 1544
1606 dev_mc_add(slave_dev, lacpdu_multicast, ETH_ALEN, 0); 1545 dev_mc_add(slave_dev, lacpdu_multicast);
1607 } 1546 }
1608 1547
1609 bond_add_vlans_on_slave(bond, slave_dev); 1548 bond_add_vlans_on_slave(bond, slave_dev);
@@ -3905,10 +3844,24 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3905 return res; 3844 return res;
3906} 3845}
3907 3846
3847static bool bond_addr_in_mc_list(unsigned char *addr,
3848 struct netdev_hw_addr_list *list,
3849 int addrlen)
3850{
3851 struct netdev_hw_addr *ha;
3852
3853 netdev_hw_addr_list_for_each(ha, list)
3854 if (!memcmp(ha->addr, addr, addrlen))
3855 return true;
3856
3857 return false;
3858}
3859
3908static void bond_set_multicast_list(struct net_device *bond_dev) 3860static void bond_set_multicast_list(struct net_device *bond_dev)
3909{ 3861{
3910 struct bonding *bond = netdev_priv(bond_dev); 3862 struct bonding *bond = netdev_priv(bond_dev);
3911 struct dev_mc_list *dmi; 3863 struct netdev_hw_addr *ha;
3864 bool found;
3912 3865
3913 /* 3866 /*
3914 * Do promisc before checking multicast_mode 3867 * Do promisc before checking multicast_mode
@@ -3943,20 +3896,25 @@ static void bond_set_multicast_list(struct net_device *bond_dev)
3943 bond->flags = bond_dev->flags; 3896 bond->flags = bond_dev->flags;
3944 3897
3945 /* looking for addresses to add to slaves' mc list */ 3898 /* looking for addresses to add to slaves' mc list */
3946 for (dmi = bond_dev->mc_list; dmi; dmi = dmi->next) { 3899 netdev_for_each_mc_addr(ha, bond_dev) {
3947 if (!bond_mc_list_find_dmi(dmi, bond->mc_list)) 3900 found = bond_addr_in_mc_list(ha->addr, &bond->mc_list,
3948 bond_mc_add(bond, dmi->dmi_addr, dmi->dmi_addrlen); 3901 bond_dev->addr_len);
3902 if (!found)
3903 bond_mc_add(bond, ha->addr);
3949 } 3904 }
3950 3905
3951 /* looking for addresses to delete from slaves' list */ 3906 /* looking for addresses to delete from slaves' list */
3952 for (dmi = bond->mc_list; dmi; dmi = dmi->next) { 3907 netdev_hw_addr_list_for_each(ha, &bond->mc_list) {
3953 if (!bond_mc_list_find_dmi(dmi, bond_dev->mc_list)) 3908 found = bond_addr_in_mc_list(ha->addr, &bond_dev->mc,
3954 bond_mc_delete(bond, dmi->dmi_addr, dmi->dmi_addrlen); 3909 bond_dev->addr_len);
3910 if (!found)
3911 bond_mc_del(bond, ha->addr);
3955 } 3912 }
3956 3913
3957 /* save master's multicast list */ 3914 /* save master's multicast list */
3958 bond_mc_list_destroy(bond); 3915 __hw_addr_flush(&bond->mc_list);
3959 bond_mc_list_copy(bond_dev->mc_list, bond, GFP_ATOMIC); 3916 __hw_addr_add_multiple(&bond->mc_list, &bond_dev->mc,
3917 bond_dev->addr_len, NETDEV_HW_ADDR_T_MULTICAST);
3960 3918
3961 read_unlock(&bond->lock); 3919 read_unlock(&bond->lock);
3962} 3920}
@@ -4550,9 +4508,7 @@ static void bond_uninit(struct net_device *bond_dev)
4550 4508
4551 bond_remove_proc_entry(bond); 4509 bond_remove_proc_entry(bond);
4552 4510
4553 netif_addr_lock_bh(bond_dev); 4511 __hw_addr_flush(&bond->mc_list);
4554 bond_mc_list_destroy(bond);
4555 netif_addr_unlock_bh(bond_dev);
4556} 4512}
4557 4513
4558/*------------------------- Module initialization ---------------------------*/ 4514/*------------------------- Module initialization ---------------------------*/
@@ -4683,13 +4639,13 @@ static int bond_check_params(struct bond_params *params)
4683 } 4639 }
4684 4640
4685 if (num_grat_arp < 0 || num_grat_arp > 255) { 4641 if (num_grat_arp < 0 || num_grat_arp > 255) {
4686 pr_warning("Warning: num_grat_arp (%d) not in range 0-255 so it was reset to 1 \n", 4642 pr_warning("Warning: num_grat_arp (%d) not in range 0-255 so it was reset to 1\n",
4687 num_grat_arp); 4643 num_grat_arp);
4688 num_grat_arp = 1; 4644 num_grat_arp = 1;
4689 } 4645 }
4690 4646
4691 if (num_unsol_na < 0 || num_unsol_na > 255) { 4647 if (num_unsol_na < 0 || num_unsol_na > 255) {
4692 pr_warning("Warning: num_unsol_na (%d) not in range 0-255 so it was reset to 1 \n", 4648 pr_warning("Warning: num_unsol_na (%d) not in range 0-255 so it was reset to 1\n",
4693 num_unsol_na); 4649 num_unsol_na);
4694 num_unsol_na = 1; 4650 num_unsol_na = 1;
4695 } 4651 }
@@ -4924,6 +4880,8 @@ static int bond_init(struct net_device *bond_dev)
4924 list_add_tail(&bond->bond_list, &bn->dev_list); 4880 list_add_tail(&bond->bond_list, &bn->dev_list);
4925 4881
4926 bond_prepare_sysfs_group(bond); 4882 bond_prepare_sysfs_group(bond);
4883
4884 __hw_addr_init(&bond->mc_list);
4927 return 0; 4885 return 0;
4928} 4886}
4929 4887
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 257a7a4dfce9..2aa336720591 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -202,7 +202,7 @@ struct bonding {
202 char proc_file_name[IFNAMSIZ]; 202 char proc_file_name[IFNAMSIZ];
203#endif /* CONFIG_PROC_FS */ 203#endif /* CONFIG_PROC_FS */
204 struct list_head bond_list; 204 struct list_head bond_list;
205 struct dev_mc_list *mc_list; 205 struct netdev_hw_addr_list mc_list;
206 int (*xmit_hash_policy)(struct sk_buff *, int); 206 int (*xmit_hash_policy)(struct sk_buff *, int);
207 __be32 master_ip; 207 __be32 master_ip;
208 u16 flags; 208 u16 flags;
diff --git a/drivers/net/caif/Kconfig b/drivers/net/caif/Kconfig
new file mode 100644
index 000000000000..0b28e0107697
--- /dev/null
+++ b/drivers/net/caif/Kconfig
@@ -0,0 +1,17 @@
1#
2# CAIF physical drivers
3#
4
5if CAIF
6
7comment "CAIF transport drivers"
8
9config CAIF_TTY
10 tristate "CAIF TTY transport driver"
11 default n
12 ---help---
13 The CAIF TTY transport driver is a Line Discipline (ldisc)
14 identified as N_CAIF. When this ldisc is opened from user space
15 it will redirect the TTY's traffic into the CAIF stack.
16
17endif # CAIF
diff --git a/drivers/net/caif/Makefile b/drivers/net/caif/Makefile
new file mode 100644
index 000000000000..52b6d1f826f8
--- /dev/null
+++ b/drivers/net/caif/Makefile
@@ -0,0 +1,12 @@
1ifeq ($(CONFIG_CAIF_DEBUG),1)
2CAIF_DBG_FLAGS := -DDEBUG
3endif
4
5KBUILD_EXTRA_SYMBOLS=net/caif/Module.symvers
6
7ccflags-y := $(CAIF_FLAGS) $(CAIF_DBG_FLAGS)
8clean-dirs:= .tmp_versions
9clean-files:= Module.symvers modules.order *.cmd *~ \
10
11# Serial interface
12obj-$(CONFIG_CAIF_TTY) += caif_serial.o
diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
new file mode 100644
index 000000000000..3502f607117f
--- /dev/null
+++ b/drivers/net/caif/caif_serial.c
@@ -0,0 +1,441 @@
1/*
2 * Copyright (C) ST-Ericsson AB 2010
3 * Author: Sjur Brendeland / sjur.brandeland@stericsson.com
4 * License terms: GNU General Public License (GPL) version 2
5 */
6
7#include <linux/init.h>
8#include <linux/version.h>
9#include <linux/module.h>
10#include <linux/device.h>
11#include <linux/types.h>
12#include <linux/skbuff.h>
13#include <linux/netdevice.h>
14#include <linux/rtnetlink.h>
15#include <linux/tty.h>
16#include <linux/file.h>
17#include <linux/if_arp.h>
18#include <net/caif/caif_device.h>
19#include <net/caif/cfcnfg.h>
20#include <linux/err.h>
21#include <linux/debugfs.h>
22
23MODULE_LICENSE("GPL");
24MODULE_AUTHOR("Sjur Brendeland<sjur.brandeland@stericsson.com>");
25MODULE_DESCRIPTION("CAIF serial device TTY line discipline");
26MODULE_LICENSE("GPL");
27MODULE_ALIAS_LDISC(N_CAIF);
28
29#define SEND_QUEUE_LOW 10
30#define SEND_QUEUE_HIGH 100
31#define CAIF_SENDING 1 /* Bit 1 = 0x02*/
32#define CAIF_FLOW_OFF_SENT 4 /* Bit 4 = 0x10 */
33#define MAX_WRITE_CHUNK 4096
34#define ON 1
35#define OFF 0
36#define CAIF_MAX_MTU 4096
37
38/*This list is protected by the rtnl lock. */
39static LIST_HEAD(ser_list);
40
41static int ser_loop;
42module_param(ser_loop, bool, S_IRUGO);
43MODULE_PARM_DESC(ser_loop, "Run in simulated loopback mode.");
44
45static int ser_use_stx = 1;
46module_param(ser_use_stx, bool, S_IRUGO);
47MODULE_PARM_DESC(ser_use_stx, "STX enabled or not.");
48
49static int ser_use_fcs = 1;
50
51module_param(ser_use_fcs, bool, S_IRUGO);
52MODULE_PARM_DESC(ser_use_fcs, "FCS enabled or not.");
53
54static int ser_write_chunk = MAX_WRITE_CHUNK;
55module_param(ser_write_chunk, int, S_IRUGO);
56
57MODULE_PARM_DESC(ser_write_chunk, "Maximum size of data written to UART.");
58
59static struct dentry *debugfsdir;
60
61static int caif_net_open(struct net_device *dev);
62static int caif_net_close(struct net_device *dev);
63
64struct ser_device {
65 struct caif_dev_common common;
66 struct list_head node;
67 struct net_device *dev;
68 struct sk_buff_head head;
69 struct tty_struct *tty;
70 bool tx_started;
71 unsigned long state;
72 char *tty_name;
73#ifdef CONFIG_DEBUG_FS
74 struct dentry *debugfs_tty_dir;
75 struct debugfs_blob_wrapper tx_blob;
76 struct debugfs_blob_wrapper rx_blob;
77 u8 rx_data[128];
78 u8 tx_data[128];
79 u8 tty_status;
80
81#endif
82};
83
84static void caifdev_setup(struct net_device *dev);
85static void ldisc_tx_wakeup(struct tty_struct *tty);
86#ifdef CONFIG_DEBUG_FS
87static inline void update_tty_status(struct ser_device *ser)
88{
89 ser->tty_status =
90 ser->tty->stopped << 5 |
91 ser->tty->hw_stopped << 4 |
92 ser->tty->flow_stopped << 3 |
93 ser->tty->packet << 2 |
94 ser->tty->low_latency << 1 |
95 ser->tty->warned;
96}
97static inline void debugfs_init(struct ser_device *ser, struct tty_struct *tty)
98{
99 ser->debugfs_tty_dir =
100 debugfs_create_dir(tty->name, debugfsdir);
101 if (!IS_ERR(ser->debugfs_tty_dir)) {
102 debugfs_create_blob("last_tx_msg", S_IRUSR,
103 ser->debugfs_tty_dir,
104 &ser->tx_blob);
105
106 debugfs_create_blob("last_rx_msg", S_IRUSR,
107 ser->debugfs_tty_dir,
108 &ser->rx_blob);
109
110 debugfs_create_x32("ser_state", S_IRUSR,
111 ser->debugfs_tty_dir,
112 (u32 *)&ser->state);
113
114 debugfs_create_x8("tty_status", S_IRUSR,
115 ser->debugfs_tty_dir,
116 &ser->tty_status);
117
118 }
119 ser->tx_blob.data = ser->tx_data;
120 ser->tx_blob.size = 0;
121 ser->rx_blob.data = ser->rx_data;
122 ser->rx_blob.size = 0;
123}
124
125static inline void debugfs_deinit(struct ser_device *ser)
126{
127 debugfs_remove_recursive(ser->debugfs_tty_dir);
128}
129
130static inline void debugfs_rx(struct ser_device *ser, const u8 *data, int size)
131{
132 if (size > sizeof(ser->rx_data))
133 size = sizeof(ser->rx_data);
134 memcpy(ser->rx_data, data, size);
135 ser->rx_blob.data = ser->rx_data;
136 ser->rx_blob.size = size;
137}
138
139static inline void debugfs_tx(struct ser_device *ser, const u8 *data, int size)
140{
141 if (size > sizeof(ser->tx_data))
142 size = sizeof(ser->tx_data);
143 memcpy(ser->tx_data, data, size);
144 ser->tx_blob.data = ser->tx_data;
145 ser->tx_blob.size = size;
146}
147#else
148static inline void debugfs_init(struct ser_device *ser, struct tty_struct *tty)
149{
150}
151
152static inline void debugfs_deinit(struct ser_device *ser)
153{
154}
155
156static inline void update_tty_status(struct ser_device *ser)
157{
158}
159
160static inline void debugfs_rx(struct ser_device *ser, const u8 *data, int size)
161{
162}
163
164static inline void debugfs_tx(struct ser_device *ser, const u8 *data, int size)
165{
166}
167
168#endif
169
170static void ldisc_receive(struct tty_struct *tty, const u8 *data,
171 char *flags, int count)
172{
173 struct sk_buff *skb = NULL;
174 struct ser_device *ser;
175 int ret;
176 u8 *p;
177 ser = tty->disc_data;
178
179 /*
180 * NOTE: flags may contain information about break or overrun.
181 * This is not yet handled.
182 */
183
184
185 /*
186 * Workaround for garbage at start of transmission,
187 * only enable if STX handling is not enabled.
188 */
189 if (!ser->common.use_stx && !ser->tx_started) {
190 dev_info(&ser->dev->dev,
191 "Bytes received before initial transmission -"
192 "bytes discarded.\n");
193 return;
194 }
195
196 BUG_ON(ser->dev == NULL);
197
198 /* Get a suitable caif packet and copy in data. */
199 skb = netdev_alloc_skb(ser->dev, count+1);
200 BUG_ON(skb == NULL);
201 p = skb_put(skb, count);
202 memcpy(p, data, count);
203
204 skb->protocol = htons(ETH_P_CAIF);
205 skb_reset_mac_header(skb);
206 skb->dev = ser->dev;
207 debugfs_rx(ser, data, count);
208 /* Push received packet up the stack. */
209 ret = netif_rx_ni(skb);
210 if (!ret) {
211 ser->dev->stats.rx_packets++;
212 ser->dev->stats.rx_bytes += count;
213 } else
214 ++ser->dev->stats.rx_dropped;
215 update_tty_status(ser);
216}
217
218static int handle_tx(struct ser_device *ser)
219{
220 struct tty_struct *tty;
221 struct sk_buff *skb;
222 int tty_wr, len, room;
223 tty = ser->tty;
224 ser->tx_started = true;
225
226 /* Enter critical section */
227 if (test_and_set_bit(CAIF_SENDING, &ser->state))
228 return 0;
229
230 /* skb_peek is safe because handle_tx is called after skb_queue_tail */
231 while ((skb = skb_peek(&ser->head)) != NULL) {
232
233 /* Make sure you don't write too much */
234 len = skb->len;
235 room = tty_write_room(tty);
236 if (!room)
237 break;
238 if (room > ser_write_chunk)
239 room = ser_write_chunk;
240 if (len > room)
241 len = room;
242
243 /* Write to tty or loopback */
244 if (!ser_loop) {
245 tty_wr = tty->ops->write(tty, skb->data, len);
246 update_tty_status(ser);
247 } else {
248 tty_wr = len;
249 ldisc_receive(tty, skb->data, NULL, len);
250 }
251 ser->dev->stats.tx_packets++;
252 ser->dev->stats.tx_bytes += tty_wr;
253
254 /* Error on TTY ?! */
255 if (tty_wr < 0)
256 goto error;
257 /* Reduce buffer written, and discard if empty */
258 skb_pull(skb, tty_wr);
259 if (skb->len == 0) {
260 struct sk_buff *tmp = skb_dequeue(&ser->head);
261 BUG_ON(tmp != skb);
262 if (in_interrupt())
263 dev_kfree_skb_irq(skb);
264 else
265 kfree_skb(skb);
266 }
267 }
268 /* Send flow off if queue is empty */
269 if (ser->head.qlen <= SEND_QUEUE_LOW &&
270 test_and_clear_bit(CAIF_FLOW_OFF_SENT, &ser->state) &&
271 ser->common.flowctrl != NULL)
272 ser->common.flowctrl(ser->dev, ON);
273 clear_bit(CAIF_SENDING, &ser->state);
274 return 0;
275error:
276 clear_bit(CAIF_SENDING, &ser->state);
277 return tty_wr;
278}
279
280static int caif_xmit(struct sk_buff *skb, struct net_device *dev)
281{
282 struct ser_device *ser;
283 BUG_ON(dev == NULL);
284 ser = netdev_priv(dev);
285
286 /* Send flow off once, on high water mark */
287 if (ser->head.qlen > SEND_QUEUE_HIGH &&
288 !test_and_set_bit(CAIF_FLOW_OFF_SENT, &ser->state) &&
289 ser->common.flowctrl != NULL)
290
291 ser->common.flowctrl(ser->dev, OFF);
292
293 skb_queue_tail(&ser->head, skb);
294 return handle_tx(ser);
295}
296
297
298static void ldisc_tx_wakeup(struct tty_struct *tty)
299{
300 struct ser_device *ser;
301 ser = tty->disc_data;
302 BUG_ON(ser == NULL);
303 BUG_ON(ser->tty != tty);
304 handle_tx(ser);
305}
306
307
308static int ldisc_open(struct tty_struct *tty)
309{
310 struct ser_device *ser;
311 struct net_device *dev;
312 char name[64];
313 int result;
314
315 sprintf(name, "cf%s", tty->name);
316 dev = alloc_netdev(sizeof(*ser), name, caifdev_setup);
317 ser = netdev_priv(dev);
318 ser->tty = tty;
319 ser->dev = dev;
320 debugfs_init(ser, tty);
321 tty->receive_room = N_TTY_BUF_SIZE;
322 tty->disc_data = ser;
323 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
324 rtnl_lock();
325 result = register_netdevice(dev);
326 if (result) {
327 rtnl_unlock();
328 free_netdev(dev);
329 return -ENODEV;
330 }
331
332 list_add(&ser->node, &ser_list);
333 rtnl_unlock();
334 netif_stop_queue(dev);
335 update_tty_status(ser);
336 return 0;
337}
338
339static void ldisc_close(struct tty_struct *tty)
340{
341 struct ser_device *ser = tty->disc_data;
342 /* Remove may be called inside or outside of rtnl_lock */
343 int islocked = rtnl_is_locked();
344 if (!islocked)
345 rtnl_lock();
346 /* device is freed automagically by net-sysfs */
347 dev_close(ser->dev);
348 unregister_netdevice(ser->dev);
349 list_del(&ser->node);
350 debugfs_deinit(ser);
351 if (!islocked)
352 rtnl_unlock();
353}
354
355/* The line discipline structure. */
356static struct tty_ldisc_ops caif_ldisc = {
357 .owner = THIS_MODULE,
358 .magic = TTY_LDISC_MAGIC,
359 .name = "n_caif",
360 .open = ldisc_open,
361 .close = ldisc_close,
362 .receive_buf = ldisc_receive,
363 .write_wakeup = ldisc_tx_wakeup
364};
365
366static int register_ldisc(void)
367{
368 int result;
369 result = tty_register_ldisc(N_CAIF, &caif_ldisc);
370 if (result < 0) {
371 pr_err("cannot register CAIF ldisc=%d err=%d\n", N_CAIF,
372 result);
373 return result;
374 }
375 return result;
376}
377static const struct net_device_ops netdev_ops = {
378 .ndo_open = caif_net_open,
379 .ndo_stop = caif_net_close,
380 .ndo_start_xmit = caif_xmit
381};
382
383static void caifdev_setup(struct net_device *dev)
384{
385 struct ser_device *serdev = netdev_priv(dev);
386 dev->features = 0;
387 dev->netdev_ops = &netdev_ops;
388 dev->type = ARPHRD_CAIF;
389 dev->flags = IFF_POINTOPOINT | IFF_NOARP;
390 dev->mtu = CAIF_MAX_MTU;
391 dev->hard_header_len = CAIF_NEEDED_HEADROOM;
392 dev->tx_queue_len = 0;
393 dev->destructor = free_netdev;
394 skb_queue_head_init(&serdev->head);
395 serdev->common.link_select = CAIF_LINK_LOW_LATENCY;
396 serdev->common.use_frag = true;
397 serdev->common.use_stx = ser_use_stx;
398 serdev->common.use_fcs = ser_use_fcs;
399 serdev->dev = dev;
400}
401
402
403static int caif_net_open(struct net_device *dev)
404{
405 struct ser_device *ser;
406 ser = netdev_priv(dev);
407 netif_wake_queue(dev);
408 return 0;
409}
410
411static int caif_net_close(struct net_device *dev)
412{
413 netif_stop_queue(dev);
414 return 0;
415}
416
417static int __init caif_ser_init(void)
418{
419 int ret;
420 ret = register_ldisc();
421 debugfsdir = debugfs_create_dir("caif_serial", NULL);
422 return ret;
423}
424
425static void __exit caif_ser_exit(void)
426{
427 struct ser_device *ser = NULL;
428 struct list_head *node;
429 struct list_head *_tmp;
430 list_for_each_safe(node, _tmp, &ser_list) {
431 ser = list_entry(node, struct ser_device, node);
432 dev_close(ser->dev);
433 unregister_netdevice(ser->dev);
434 list_del(node);
435 }
436 tty_unregister_ldisc(N_CAIF);
437 debugfs_remove_recursive(debugfsdir);
438}
439
440module_init(caif_ser_init);
441module_exit(caif_ser_exit);
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index f8cc168ec76c..f521579f5adb 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -922,12 +922,16 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi)
922 struct net_device *net; 922 struct net_device *net;
923 struct mcp251x_priv *priv; 923 struct mcp251x_priv *priv;
924 struct mcp251x_platform_data *pdata = spi->dev.platform_data; 924 struct mcp251x_platform_data *pdata = spi->dev.platform_data;
925 int model = spi_get_device_id(spi)->driver_data;
925 int ret = -ENODEV; 926 int ret = -ENODEV;
926 927
927 if (!pdata) 928 if (!pdata)
928 /* Platform data is required for osc freq */ 929 /* Platform data is required for osc freq */
929 goto error_out; 930 goto error_out;
930 931
932 if (model)
933 pdata->model = model;
934
931 /* Allocate can/net device */ 935 /* Allocate can/net device */
932 net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX); 936 net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX);
933 if (!net) { 937 if (!net) {
@@ -1117,6 +1121,15 @@ static int mcp251x_can_resume(struct spi_device *spi)
1117#define mcp251x_can_resume NULL 1121#define mcp251x_can_resume NULL
1118#endif 1122#endif
1119 1123
1124static struct spi_device_id mcp251x_id_table[] = {
1125 { "mcp251x", 0 /* Use pdata.model */ },
1126 { "mcp2510", CAN_MCP251X_MCP2510 },
1127 { "mcp2515", CAN_MCP251X_MCP2515 },
1128 { },
1129};
1130
1131MODULE_DEVICE_TABLE(spi, mcp251x_id_table);
1132
1120static struct spi_driver mcp251x_can_driver = { 1133static struct spi_driver mcp251x_can_driver = {
1121 .driver = { 1134 .driver = {
1122 .name = DEVICE_NAME, 1135 .name = DEVICE_NAME,
@@ -1124,6 +1137,7 @@ static struct spi_driver mcp251x_can_driver = {
1124 .owner = THIS_MODULE, 1137 .owner = THIS_MODULE,
1125 }, 1138 },
1126 1139
1140 .id_table = mcp251x_id_table,
1127 .probe = mcp251x_can_probe, 1141 .probe = mcp251x_can_probe,
1128 .remove = __devexit_p(mcp251x_can_remove), 1142 .remove = __devexit_p(mcp251x_can_remove),
1129 .suspend = mcp251x_can_suspend, 1143 .suspend = mcp251x_can_suspend,
diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
index 628374c2a05f..1083b42ab6cb 100644
--- a/drivers/net/can/sja1000/sja1000_platform.c
+++ b/drivers/net/can/sja1000/sja1000_platform.c
@@ -37,16 +37,36 @@ MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
37MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus"); 37MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the platform bus");
38MODULE_LICENSE("GPL v2"); 38MODULE_LICENSE("GPL v2");
39 39
40static u8 sp_read_reg(const struct sja1000_priv *priv, int reg) 40static u8 sp_read_reg8(const struct sja1000_priv *priv, int reg)
41{ 41{
42 return ioread8(priv->reg_base + reg); 42 return ioread8(priv->reg_base + reg);
43} 43}
44 44
45static void sp_write_reg(const struct sja1000_priv *priv, int reg, u8 val) 45static void sp_write_reg8(const struct sja1000_priv *priv, int reg, u8 val)
46{ 46{
47 iowrite8(val, priv->reg_base + reg); 47 iowrite8(val, priv->reg_base + reg);
48} 48}
49 49
50static u8 sp_read_reg16(const struct sja1000_priv *priv, int reg)
51{
52 return ioread8(priv->reg_base + reg * 2);
53}
54
55static void sp_write_reg16(const struct sja1000_priv *priv, int reg, u8 val)
56{
57 iowrite8(val, priv->reg_base + reg * 2);
58}
59
60static u8 sp_read_reg32(const struct sja1000_priv *priv, int reg)
61{
62 return ioread8(priv->reg_base + reg * 4);
63}
64
65static void sp_write_reg32(const struct sja1000_priv *priv, int reg, u8 val)
66{
67 iowrite8(val, priv->reg_base + reg * 4);
68}
69
50static int sp_probe(struct platform_device *pdev) 70static int sp_probe(struct platform_device *pdev)
51{ 71{
52 int err; 72 int err;
@@ -90,14 +110,28 @@ static int sp_probe(struct platform_device *pdev)
90 priv = netdev_priv(dev); 110 priv = netdev_priv(dev);
91 111
92 dev->irq = res_irq->start; 112 dev->irq = res_irq->start;
93 priv->irq_flags = res_irq->flags & IRQF_TRIGGER_MASK; 113 priv->irq_flags = res_irq->flags & (IRQF_TRIGGER_MASK | IRQF_SHARED);
94 priv->reg_base = addr; 114 priv->reg_base = addr;
95 priv->read_reg = sp_read_reg;
96 priv->write_reg = sp_write_reg;
97 priv->can.clock.freq = pdata->clock; 115 priv->can.clock.freq = pdata->clock;
98 priv->ocr = pdata->ocr; 116 priv->ocr = pdata->ocr;
99 priv->cdr = pdata->cdr; 117 priv->cdr = pdata->cdr;
100 118
119 switch (res_mem->flags & IORESOURCE_MEM_TYPE_MASK) {
120 case IORESOURCE_MEM_32BIT:
121 priv->read_reg = sp_read_reg32;
122 priv->write_reg = sp_write_reg32;
123 break;
124 case IORESOURCE_MEM_16BIT:
125 priv->read_reg = sp_read_reg16;
126 priv->write_reg = sp_write_reg16;
127 break;
128 case IORESOURCE_MEM_8BIT:
129 default:
130 priv->read_reg = sp_read_reg8;
131 priv->write_reg = sp_write_reg8;
132 break;
133 }
134
101 dev_set_drvdata(&pdev->dev, dev); 135 dev_set_drvdata(&pdev->dev, dev);
102 SET_NETDEV_DEV(dev, &pdev->dev); 136 SET_NETDEV_DEV(dev, &pdev->dev);
103 137
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 9bd155e4111c..bd857a20a755 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -2957,20 +2957,20 @@ static void cas_process_mc_list(struct cas *cp)
2957{ 2957{
2958 u16 hash_table[16]; 2958 u16 hash_table[16];
2959 u32 crc; 2959 u32 crc;
2960 struct dev_mc_list *dmi; 2960 struct netdev_hw_addr *ha;
2961 int i = 1; 2961 int i = 1;
2962 2962
2963 memset(hash_table, 0, sizeof(hash_table)); 2963 memset(hash_table, 0, sizeof(hash_table));
2964 netdev_for_each_mc_addr(dmi, cp->dev) { 2964 netdev_for_each_mc_addr(ha, cp->dev) {
2965 if (i <= CAS_MC_EXACT_MATCH_SIZE) { 2965 if (i <= CAS_MC_EXACT_MATCH_SIZE) {
2966 /* use the alternate mac address registers for the 2966 /* use the alternate mac address registers for the
2967 * first 15 multicast addresses 2967 * first 15 multicast addresses
2968 */ 2968 */
2969 writel((dmi->dmi_addr[4] << 8) | dmi->dmi_addr[5], 2969 writel((ha->addr[4] << 8) | ha->addr[5],
2970 cp->regs + REG_MAC_ADDRN(i*3 + 0)); 2970 cp->regs + REG_MAC_ADDRN(i*3 + 0));
2971 writel((dmi->dmi_addr[2] << 8) | dmi->dmi_addr[3], 2971 writel((ha->addr[2] << 8) | ha->addr[3],
2972 cp->regs + REG_MAC_ADDRN(i*3 + 1)); 2972 cp->regs + REG_MAC_ADDRN(i*3 + 1));
2973 writel((dmi->dmi_addr[0] << 8) | dmi->dmi_addr[1], 2973 writel((ha->addr[0] << 8) | ha->addr[1],
2974 cp->regs + REG_MAC_ADDRN(i*3 + 2)); 2974 cp->regs + REG_MAC_ADDRN(i*3 + 2));
2975 i++; 2975 i++;
2976 } 2976 }
@@ -2978,7 +2978,7 @@ static void cas_process_mc_list(struct cas *cp)
2978 /* use hw hash table for the next series of 2978 /* use hw hash table for the next series of
2979 * multicast addresses 2979 * multicast addresses
2980 */ 2980 */
2981 crc = ether_crc_le(ETH_ALEN, dmi->dmi_addr); 2981 crc = ether_crc_le(ETH_ALEN, ha->addr);
2982 crc >>= 24; 2982 crc >>= 24;
2983 hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf)); 2983 hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf));
2984 } 2984 }
diff --git a/drivers/net/chelsio/pm3393.c b/drivers/net/chelsio/pm3393.c
index a6eb30a6e2b9..13fd9628db1d 100644
--- a/drivers/net/chelsio/pm3393.c
+++ b/drivers/net/chelsio/pm3393.c
@@ -376,12 +376,13 @@ static int pm3393_set_rx_mode(struct cmac *cmac, struct t1_rx_mode *rm)
376 rx_mode |= SUNI1x10GEXP_BITMSK_RXXG_MHASH_EN; 376 rx_mode |= SUNI1x10GEXP_BITMSK_RXXG_MHASH_EN;
377 } else if (t1_rx_mode_mc_cnt(rm)) { 377 } else if (t1_rx_mode_mc_cnt(rm)) {
378 /* Accept one or more multicast(s). */ 378 /* Accept one or more multicast(s). */
379 struct dev_mc_list *dmi; 379 struct netdev_hw_addr *ha;
380 int bit; 380 int bit;
381 u16 mc_filter[4] = { 0, }; 381 u16 mc_filter[4] = { 0, };
382 382
383 netdev_for_each_mc_addr(dmi, t1_get_netdev(rm)) { 383 netdev_for_each_mc_addr(ha, t1_get_netdev(rm)) {
384 bit = (ether_crc(ETH_ALEN, dmi->dmi_addr) >> 23) & 0x3f; /* bit[23:28] */ 384 /* bit[23:28] */
385 bit = (ether_crc(ETH_ALEN, ha->addr) >> 23) & 0x3f;
385 mc_filter[bit >> 4] |= 1 << (bit & 0xf); 386 mc_filter[bit >> 4] |= 1 << (bit & 0xf);
386 } 387 }
387 pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW, mc_filter[0]); 388 pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW, mc_filter[0]);
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index 60777fd90b33..bdfff784645c 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -328,7 +328,7 @@ static int cpmac_config(struct net_device *dev, struct ifmap *map)
328 328
329static void cpmac_set_multicast_list(struct net_device *dev) 329static void cpmac_set_multicast_list(struct net_device *dev)
330{ 330{
331 struct dev_mc_list *iter; 331 struct netdev_hw_addr *ha;
332 u8 tmp; 332 u8 tmp;
333 u32 mbp, bit, hash[2] = { 0, }; 333 u32 mbp, bit, hash[2] = { 0, };
334 struct cpmac_priv *priv = netdev_priv(dev); 334 struct cpmac_priv *priv = netdev_priv(dev);
@@ -348,19 +348,19 @@ static void cpmac_set_multicast_list(struct net_device *dev)
348 * cpmac uses some strange mac address hashing 348 * cpmac uses some strange mac address hashing
349 * (not crc32) 349 * (not crc32)
350 */ 350 */
351 netdev_for_each_mc_addr(iter, dev) { 351 netdev_for_each_mc_addr(ha, dev) {
352 bit = 0; 352 bit = 0;
353 tmp = iter->dmi_addr[0]; 353 tmp = ha->addr[0];
354 bit ^= (tmp >> 2) ^ (tmp << 4); 354 bit ^= (tmp >> 2) ^ (tmp << 4);
355 tmp = iter->dmi_addr[1]; 355 tmp = ha->addr[1];
356 bit ^= (tmp >> 4) ^ (tmp << 2); 356 bit ^= (tmp >> 4) ^ (tmp << 2);
357 tmp = iter->dmi_addr[2]; 357 tmp = ha->addr[2];
358 bit ^= (tmp >> 6) ^ tmp; 358 bit ^= (tmp >> 6) ^ tmp;
359 tmp = iter->dmi_addr[3]; 359 tmp = ha->addr[3];
360 bit ^= (tmp >> 2) ^ (tmp << 4); 360 bit ^= (tmp >> 2) ^ (tmp << 4);
361 tmp = iter->dmi_addr[4]; 361 tmp = ha->addr[4];
362 bit ^= (tmp >> 4) ^ (tmp << 2); 362 bit ^= (tmp >> 4) ^ (tmp << 2);
363 tmp = iter->dmi_addr[5]; 363 tmp = ha->addr[5];
364 bit ^= (tmp >> 6) ^ tmp; 364 bit ^= (tmp >> 6) ^ tmp;
365 bit &= 0x3f; 365 bit &= 0x3f;
366 hash[bit / 32] |= 1 << (bit % 32); 366 hash[bit / 32] |= 1 << (bit % 32);
diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
index dd24aadb778c..59110bc119a8 100644
--- a/drivers/net/cris/eth_v10.c
+++ b/drivers/net/cris/eth_v10.c
@@ -1596,16 +1596,16 @@ set_multicast_list(struct net_device *dev)
1596 } else { 1596 } else {
1597 /* MC mode, receive normal and MC packets */ 1597 /* MC mode, receive normal and MC packets */
1598 char hash_ix; 1598 char hash_ix;
1599 struct dev_mc_list *dmi; 1599 struct netdev_hw_addr *ha;
1600 char *baddr; 1600 char *baddr;
1601 1601
1602 lo_bits = 0x00000000ul; 1602 lo_bits = 0x00000000ul;
1603 hi_bits = 0x00000000ul; 1603 hi_bits = 0x00000000ul;
1604 netdev_for_each_mc_addr(dmi, dev) { 1604 netdev_for_each_mc_addr(ha, dev) {
1605 /* Calculate the hash index for the GA registers */ 1605 /* Calculate the hash index for the GA registers */
1606 1606
1607 hash_ix = 0; 1607 hash_ix = 0;
1608 baddr = dmi->dmi_addr; 1608 baddr = ha->addr;
1609 hash_ix ^= (*baddr) & 0x3f; 1609 hash_ix ^= (*baddr) & 0x3f;
1610 hash_ix ^= ((*baddr) >> 6) & 0x03; 1610 hash_ix ^= ((*baddr) >> 6) & 0x03;
1611 ++baddr; 1611 ++baddr;
diff --git a/drivers/net/cxgb3/xgmac.c b/drivers/net/cxgb3/xgmac.c
index c142a2132e9f..3af19a550372 100644
--- a/drivers/net/cxgb3/xgmac.c
+++ b/drivers/net/cxgb3/xgmac.c
@@ -311,16 +311,16 @@ int t3_mac_set_rx_mode(struct cmac *mac, struct net_device *dev)
311 if (dev->flags & IFF_ALLMULTI) 311 if (dev->flags & IFF_ALLMULTI)
312 hash_lo = hash_hi = 0xffffffff; 312 hash_lo = hash_hi = 0xffffffff;
313 else { 313 else {
314 struct dev_mc_list *dmi; 314 struct netdev_hw_addr *ha;
315 int exact_addr_idx = mac->nucast; 315 int exact_addr_idx = mac->nucast;
316 316
317 hash_lo = hash_hi = 0; 317 hash_lo = hash_hi = 0;
318 netdev_for_each_mc_addr(dmi, dev) 318 netdev_for_each_mc_addr(ha, dev)
319 if (exact_addr_idx < EXACT_ADDR_FILTERS) 319 if (exact_addr_idx < EXACT_ADDR_FILTERS)
320 set_addr_filter(mac, exact_addr_idx++, 320 set_addr_filter(mac, exact_addr_idx++,
321 dmi->dmi_addr); 321 ha->addr);
322 else { 322 else {
323 int hash = hash_hw_addr(dmi->dmi_addr); 323 int hash = hash_hw_addr(ha->addr);
324 324
325 if (hash < 32) 325 if (hash < 32)
326 hash_lo |= (1 << hash); 326 hash_lo |= (1 << hash);
diff --git a/drivers/net/cxgb4/cxgb4_main.c b/drivers/net/cxgb4/cxgb4_main.c
index a7e30a23d322..5f582dba928f 100644
--- a/drivers/net/cxgb4/cxgb4_main.c
+++ b/drivers/net/cxgb4/cxgb4_main.c
@@ -240,9 +240,9 @@ static int set_addr_filters(const struct net_device *dev, bool sleep)
240 u16 filt_idx[7]; 240 u16 filt_idx[7];
241 const u8 *addr[7]; 241 const u8 *addr[7];
242 int ret, naddr = 0; 242 int ret, naddr = 0;
243 const struct dev_addr_list *d;
244 const struct netdev_hw_addr *ha; 243 const struct netdev_hw_addr *ha;
245 int uc_cnt = netdev_uc_count(dev); 244 int uc_cnt = netdev_uc_count(dev);
245 int mc_cnt = netdev_mc_count(dev);
246 const struct port_info *pi = netdev_priv(dev); 246 const struct port_info *pi = netdev_priv(dev);
247 247
248 /* first do the secondary unicast addresses */ 248 /* first do the secondary unicast addresses */
@@ -260,9 +260,9 @@ static int set_addr_filters(const struct net_device *dev, bool sleep)
260 } 260 }
261 261
262 /* next set up the multicast addresses */ 262 /* next set up the multicast addresses */
263 netdev_for_each_mc_addr(d, dev) { 263 netdev_for_each_mc_addr(ha, dev) {
264 addr[naddr++] = d->dmi_addr; 264 addr[naddr++] = ha->addr;
265 if (naddr >= ARRAY_SIZE(addr) || d->next == NULL) { 265 if (--mc_cnt == 0 || naddr >= ARRAY_SIZE(addr)) {
266 ret = t4_alloc_mac_filt(pi->adapter, 0, pi->viid, free, 266 ret = t4_alloc_mac_filt(pi->adapter, 0, pi->viid, free,
267 naddr, addr, filt_idx, &mhash, sleep); 267 naddr, addr, filt_idx, &mhash, sleep);
268 if (ret < 0) 268 if (ret < 0)
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 2b8edd2efbf6..1f9df5c6a75a 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -952,13 +952,14 @@ static void emac_dev_mcast_set(struct net_device *ndev)
952 emac_add_mcast(priv, EMAC_ALL_MULTI_SET, NULL); 952 emac_add_mcast(priv, EMAC_ALL_MULTI_SET, NULL);
953 } 953 }
954 if (!netdev_mc_empty(ndev)) { 954 if (!netdev_mc_empty(ndev)) {
955 struct dev_mc_list *mc_ptr; 955 struct netdev_hw_addr *ha;
956
956 mbp_enable = (mbp_enable | EMAC_MBP_RXMCAST); 957 mbp_enable = (mbp_enable | EMAC_MBP_RXMCAST);
957 emac_add_mcast(priv, EMAC_ALL_MULTI_CLR, NULL); 958 emac_add_mcast(priv, EMAC_ALL_MULTI_CLR, NULL);
958 /* program multicast address list into EMAC hardware */ 959 /* program multicast address list into EMAC hardware */
959 netdev_for_each_mc_addr(mc_ptr, ndev) { 960 netdev_for_each_mc_addr(ha, ndev) {
960 emac_add_mcast(priv, EMAC_MULTICAST_ADD, 961 emac_add_mcast(priv, EMAC_MULTICAST_ADD,
961 (u8 *) mc_ptr->dmi_addr); 962 (u8 *) ha->addr);
962 } 963 }
963 } else { 964 } else {
964 mbp_enable = (mbp_enable & ~EMAC_MBP_RXMCAST); 965 mbp_enable = (mbp_enable & ~EMAC_MBP_RXMCAST);
diff --git a/drivers/net/declance.c b/drivers/net/declance.c
index 8cf3cc6f20e2..fb3f0984c289 100644
--- a/drivers/net/declance.c
+++ b/drivers/net/declance.c
@@ -940,7 +940,7 @@ static void lance_load_multicast(struct net_device *dev)
940{ 940{
941 struct lance_private *lp = netdev_priv(dev); 941 struct lance_private *lp = netdev_priv(dev);
942 volatile u16 *ib = (volatile u16 *)dev->mem_start; 942 volatile u16 *ib = (volatile u16 *)dev->mem_start;
943 struct dev_mc_list *dmi; 943 struct netdev_hw_addr *ha;
944 char *addrs; 944 char *addrs;
945 u32 crc; 945 u32 crc;
946 946
@@ -959,8 +959,8 @@ static void lance_load_multicast(struct net_device *dev)
959 *lib_ptr(ib, filter[3], lp->type) = 0; 959 *lib_ptr(ib, filter[3], lp->type) = 0;
960 960
961 /* Add addresses */ 961 /* Add addresses */
962 netdev_for_each_mc_addr(dmi, dev) { 962 netdev_for_each_mc_addr(ha, dev) {
963 addrs = dmi->dmi_addr; 963 addrs = ha->addr;
964 964
965 /* multicast address? */ 965 /* multicast address? */
966 if (!(*addrs & 1)) 966 if (!(*addrs & 1))
diff --git a/drivers/net/defxx.c b/drivers/net/defxx.c
index ed53a8d45f4e..e5667c55844e 100644
--- a/drivers/net/defxx.c
+++ b/drivers/net/defxx.c
@@ -2195,7 +2195,7 @@ static void dfx_ctl_set_multicast_list(struct net_device *dev)
2195{ 2195{
2196 DFX_board_t *bp = netdev_priv(dev); 2196 DFX_board_t *bp = netdev_priv(dev);
2197 int i; /* used as index in for loop */ 2197 int i; /* used as index in for loop */
2198 struct dev_mc_list *dmi; /* ptr to multicast addr entry */ 2198 struct netdev_hw_addr *ha;
2199 2199
2200 /* Enable LLC frame promiscuous mode, if necessary */ 2200 /* Enable LLC frame promiscuous mode, if necessary */
2201 2201
@@ -2241,9 +2241,9 @@ static void dfx_ctl_set_multicast_list(struct net_device *dev)
2241 /* Copy addresses to multicast address table, then update adapter CAM */ 2241 /* Copy addresses to multicast address table, then update adapter CAM */
2242 2242
2243 i = 0; 2243 i = 0;
2244 netdev_for_each_mc_addr(dmi, dev) 2244 netdev_for_each_mc_addr(ha, dev)
2245 memcpy(&bp->mc_table[i++ * FDDI_K_ALEN], 2245 memcpy(&bp->mc_table[i++ * FDDI_K_ALEN],
2246 dmi->dmi_addr, FDDI_K_ALEN); 2246 ha->addr, FDDI_K_ALEN);
2247 2247
2248 if (dfx_ctl_update_cam(bp) != DFX_K_SUCCESS) 2248 if (dfx_ctl_update_cam(bp) != DFX_K_SUCCESS)
2249 { 2249 {
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index 744c1928dfca..a88300a0d1e8 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -1272,7 +1272,7 @@ static void set_multicast_list(struct net_device *dev)
1272static void SetMulticastFilter(struct net_device *dev) 1272static void SetMulticastFilter(struct net_device *dev)
1273{ 1273{
1274 struct depca_private *lp = netdev_priv(dev); 1274 struct depca_private *lp = netdev_priv(dev);
1275 struct dev_mc_list *dmi; 1275 struct netdev_hw_addr *ha;
1276 char *addrs; 1276 char *addrs;
1277 int i, j, bit, byte; 1277 int i, j, bit, byte;
1278 u16 hashcode; 1278 u16 hashcode;
@@ -1287,8 +1287,8 @@ static void SetMulticastFilter(struct net_device *dev)
1287 lp->init_block.mcast_table[i] = 0; 1287 lp->init_block.mcast_table[i] = 0;
1288 } 1288 }
1289 /* Add multicast addresses */ 1289 /* Add multicast addresses */
1290 netdev_for_each_mc_addr(dmi, dev) { 1290 netdev_for_each_mc_addr(ha, dev) {
1291 addrs = dmi->dmi_addr; 1291 addrs = ha->addr;
1292 if ((*addrs & 0x01) == 1) { /* multicast address? */ 1292 if ((*addrs & 0x01) == 1) { /* multicast address? */
1293 crc = ether_crc(ETH_ALEN, addrs); 1293 crc = ether_crc(ETH_ALEN, addrs);
1294 hashcode = (crc & 1); /* hashcode is 6 LSb of CRC ... */ 1294 hashcode = (crc & 1); /* hashcode is 6 LSb of CRC ... */
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c
index b05bad829827..6579225dbd91 100644
--- a/drivers/net/dl2k.c
+++ b/drivers/net/dl2k.c
@@ -1132,14 +1132,14 @@ set_multicast (struct net_device *dev)
1132 /* Receive broadcast and multicast frames */ 1132 /* Receive broadcast and multicast frames */
1133 rx_mode = ReceiveBroadcast | ReceiveMulticast | ReceiveUnicast; 1133 rx_mode = ReceiveBroadcast | ReceiveMulticast | ReceiveUnicast;
1134 } else if (!netdev_mc_empty(dev)) { 1134 } else if (!netdev_mc_empty(dev)) {
1135 struct dev_mc_list *mclist; 1135 struct netdev_hw_addr *ha;
1136 /* Receive broadcast frames and multicast frames filtering 1136 /* Receive broadcast frames and multicast frames filtering
1137 by Hashtable */ 1137 by Hashtable */
1138 rx_mode = 1138 rx_mode =
1139 ReceiveBroadcast | ReceiveMulticastHash | ReceiveUnicast; 1139 ReceiveBroadcast | ReceiveMulticastHash | ReceiveUnicast;
1140 netdev_for_each_mc_addr(mclist, dev) { 1140 netdev_for_each_mc_addr(ha, dev) {
1141 int bit, index = 0; 1141 int bit, index = 0;
1142 int crc = ether_crc_le (ETH_ALEN, mclist->dmi_addr); 1142 int crc = ether_crc_le(ETH_ALEN, ha->addr);
1143 /* The inverted high significant 6 bits of CRC are 1143 /* The inverted high significant 6 bits of CRC are
1144 used as an index to hashtable */ 1144 used as an index to hashtable */
1145 for (bit = 0; bit < 6; bit++) 1145 for (bit = 0; bit < 6; bit++)
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 1c67f1138ca7..989f2beb123b 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -724,7 +724,7 @@ static void
724dm9000_hash_table(struct net_device *dev) 724dm9000_hash_table(struct net_device *dev)
725{ 725{
726 board_info_t *db = netdev_priv(dev); 726 board_info_t *db = netdev_priv(dev);
727 struct dev_mc_list *mcptr; 727 struct netdev_hw_addr *ha;
728 int i, oft; 728 int i, oft;
729 u32 hash_val; 729 u32 hash_val;
730 u16 hash_table[4]; 730 u16 hash_table[4];
@@ -752,8 +752,8 @@ dm9000_hash_table(struct net_device *dev)
752 rcr |= RCR_ALL; 752 rcr |= RCR_ALL;
753 753
754 /* the multicast address in Hash Table : 64 bits */ 754 /* the multicast address in Hash Table : 64 bits */
755 netdev_for_each_mc_addr(mcptr, dev) { 755 netdev_for_each_mc_addr(ha, dev) {
756 hash_val = ether_crc_le(6, mcptr->dmi_addr) & 0x3f; 756 hash_val = ether_crc_le(6, ha->addr) & 0x3f;
757 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16); 757 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
758 } 758 }
759 759
diff --git a/drivers/net/dnet.c b/drivers/net/dnet.c
index 234685213f1a..d51a83e69585 100644
--- a/drivers/net/dnet.c
+++ b/drivers/net/dnet.c
@@ -918,7 +918,7 @@ static int __devinit dnet_probe(struct platform_device *pdev)
918 918
919 dev_info(&pdev->dev, "Dave DNET at 0x%p (0x%08x) irq %d %pM\n", 919 dev_info(&pdev->dev, "Dave DNET at 0x%p (0x%08x) irq %d %pM\n",
920 bp->regs, mem_base, dev->irq, dev->dev_addr); 920 bp->regs, mem_base, dev->irq, dev->dev_addr);
921 dev_info(&pdev->dev, "has %smdio, %sirq, %sgigabit, %sdma \n", 921 dev_info(&pdev->dev, "has %smdio, %sirq, %sgigabit, %sdma\n",
922 (bp->capabilities & DNET_HAS_MDIO) ? "" : "no ", 922 (bp->capabilities & DNET_HAS_MDIO) ? "" : "no ",
923 (bp->capabilities & DNET_HAS_IRQ) ? "" : "no ", 923 (bp->capabilities & DNET_HAS_IRQ) ? "" : "no ",
924 (bp->capabilities & DNET_HAS_GIGABIT) ? "" : "no ", 924 (bp->capabilities & DNET_HAS_GIGABIT) ? "" : "no ",
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index b997e578e58f..3e8d0005540f 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -147,6 +147,8 @@
147 * - add clean lowlevel I/O emulation for cards with MII-lacking PHYs 147 * - add clean lowlevel I/O emulation for cards with MII-lacking PHYs
148 */ 148 */
149 149
150#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
151
150#include <linux/module.h> 152#include <linux/module.h>
151#include <linux/moduleparam.h> 153#include <linux/moduleparam.h>
152#include <linux/kernel.h> 154#include <linux/kernel.h>
@@ -174,7 +176,6 @@
174#define DRV_VERSION "3.5.24-k2"DRV_EXT 176#define DRV_VERSION "3.5.24-k2"DRV_EXT
175#define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver" 177#define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver"
176#define DRV_COPYRIGHT "Copyright(c) 1999-2006 Intel Corporation" 178#define DRV_COPYRIGHT "Copyright(c) 1999-2006 Intel Corporation"
177#define PFX DRV_NAME ": "
178 179
179#define E100_WATCHDOG_PERIOD (2 * HZ) 180#define E100_WATCHDOG_PERIOD (2 * HZ)
180#define E100_NAPI_WEIGHT 16 181#define E100_NAPI_WEIGHT 16
@@ -200,10 +201,6 @@ module_param(use_io, int, 0);
200MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); 201MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
201MODULE_PARM_DESC(eeprom_bad_csum_allow, "Allow bad eeprom checksums"); 202MODULE_PARM_DESC(eeprom_bad_csum_allow, "Allow bad eeprom checksums");
202MODULE_PARM_DESC(use_io, "Force use of i/o access mode"); 203MODULE_PARM_DESC(use_io, "Force use of i/o access mode");
203#define DPRINTK(nlevel, klevel, fmt, args...) \
204 (void)((NETIF_MSG_##nlevel & nic->msg_enable) && \
205 printk(KERN_##klevel PFX "%s: %s: " fmt, nic->netdev->name, \
206 __func__ , ## args))
207 204
208#define INTEL_8255X_ETHERNET_DEVICE(device_id, ich) {\ 205#define INTEL_8255X_ETHERNET_DEVICE(device_id, ich) {\
209 PCI_VENDOR_ID_INTEL, device_id, PCI_ANY_ID, PCI_ANY_ID, \ 206 PCI_VENDOR_ID_INTEL, device_id, PCI_ANY_ID, PCI_ANY_ID, \
@@ -689,12 +686,13 @@ static int e100_self_test(struct nic *nic)
689 686
690 /* Check results of self-test */ 687 /* Check results of self-test */
691 if (nic->mem->selftest.result != 0) { 688 if (nic->mem->selftest.result != 0) {
692 DPRINTK(HW, ERR, "Self-test failed: result=0x%08X\n", 689 netif_err(nic, hw, nic->netdev,
693 nic->mem->selftest.result); 690 "Self-test failed: result=0x%08X\n",
691 nic->mem->selftest.result);
694 return -ETIMEDOUT; 692 return -ETIMEDOUT;
695 } 693 }
696 if (nic->mem->selftest.signature == 0) { 694 if (nic->mem->selftest.signature == 0) {
697 DPRINTK(HW, ERR, "Self-test failed: timed out\n"); 695 netif_err(nic, hw, nic->netdev, "Self-test failed: timed out\n");
698 return -ETIMEDOUT; 696 return -ETIMEDOUT;
699 } 697 }
700 698
@@ -797,7 +795,7 @@ static int e100_eeprom_load(struct nic *nic)
797 /* The checksum, stored in the last word, is calculated such that 795 /* The checksum, stored in the last word, is calculated such that
798 * the sum of words should be 0xBABA */ 796 * the sum of words should be 0xBABA */
799 if (cpu_to_le16(0xBABA - checksum) != nic->eeprom[nic->eeprom_wc - 1]) { 797 if (cpu_to_le16(0xBABA - checksum) != nic->eeprom[nic->eeprom_wc - 1]) {
800 DPRINTK(PROBE, ERR, "EEPROM corrupted\n"); 798 netif_err(nic, probe, nic->netdev, "EEPROM corrupted\n");
801 if (!eeprom_bad_csum_allow) 799 if (!eeprom_bad_csum_allow)
802 return -EAGAIN; 800 return -EAGAIN;
803 } 801 }
@@ -953,8 +951,7 @@ static u16 mdio_ctrl_hw(struct nic *nic, u32 addr, u32 dir, u32 reg, u16 data)
953 udelay(20); 951 udelay(20);
954 } 952 }
955 if (unlikely(!i)) { 953 if (unlikely(!i)) {
956 printk("e100.mdio_ctrl(%s) won't go Ready\n", 954 netdev_err(nic->netdev, "e100.mdio_ctrl won't go Ready\n");
957 nic->netdev->name );
958 spin_unlock_irqrestore(&nic->mdio_lock, flags); 955 spin_unlock_irqrestore(&nic->mdio_lock, flags);
959 return 0; /* No way to indicate timeout error */ 956 return 0; /* No way to indicate timeout error */
960 } 957 }
@@ -966,9 +963,10 @@ static u16 mdio_ctrl_hw(struct nic *nic, u32 addr, u32 dir, u32 reg, u16 data)
966 break; 963 break;
967 } 964 }
968 spin_unlock_irqrestore(&nic->mdio_lock, flags); 965 spin_unlock_irqrestore(&nic->mdio_lock, flags);
969 DPRINTK(HW, DEBUG, 966 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
970 "%s:addr=%d, reg=%d, data_in=0x%04X, data_out=0x%04X\n", 967 "%s:addr=%d, reg=%d, data_in=0x%04X, data_out=0x%04X\n",
971 dir == mdi_read ? "READ" : "WRITE", addr, reg, data, data_out); 968 dir == mdi_read ? "READ" : "WRITE",
969 addr, reg, data, data_out);
972 return (u16)data_out; 970 return (u16)data_out;
973} 971}
974 972
@@ -1028,17 +1026,19 @@ static u16 mdio_ctrl_phy_mii_emulated(struct nic *nic,
1028 return ADVERTISE_10HALF | 1026 return ADVERTISE_10HALF |
1029 ADVERTISE_10FULL; 1027 ADVERTISE_10FULL;
1030 default: 1028 default:
1031 DPRINTK(HW, DEBUG, 1029 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
1032 "%s:addr=%d, reg=%d, data=0x%04X: unimplemented emulation!\n", 1030 "%s:addr=%d, reg=%d, data=0x%04X: unimplemented emulation!\n",
1033 dir == mdi_read ? "READ" : "WRITE", addr, reg, data); 1031 dir == mdi_read ? "READ" : "WRITE",
1032 addr, reg, data);
1034 return 0xFFFF; 1033 return 0xFFFF;
1035 } 1034 }
1036 } else { 1035 } else {
1037 switch (reg) { 1036 switch (reg) {
1038 default: 1037 default:
1039 DPRINTK(HW, DEBUG, 1038 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
1040 "%s:addr=%d, reg=%d, data=0x%04X: unimplemented emulation!\n", 1039 "%s:addr=%d, reg=%d, data=0x%04X: unimplemented emulation!\n",
1041 dir == mdi_read ? "READ" : "WRITE", addr, reg, data); 1040 dir == mdi_read ? "READ" : "WRITE",
1041 addr, reg, data);
1042 return 0xFFFF; 1042 return 0xFFFF;
1043 } 1043 }
1044 } 1044 }
@@ -1155,12 +1155,15 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1155 } 1155 }
1156 } 1156 }
1157 1157
1158 DPRINTK(HW, DEBUG, "[00-07]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", 1158 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
1159 c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); 1159 "[00-07]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
1160 DPRINTK(HW, DEBUG, "[08-15]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", 1160 c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
1161 c[8], c[9], c[10], c[11], c[12], c[13], c[14], c[15]); 1161 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
1162 DPRINTK(HW, DEBUG, "[16-23]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", 1162 "[08-15]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
1163 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]); 1163 c[8], c[9], c[10], c[11], c[12], c[13], c[14], c[15]);
1164 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
1165 "[16-23]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
1166 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
1164} 1167}
1165 1168
1166/************************************************************************* 1169/*************************************************************************
@@ -1253,16 +1256,18 @@ static const struct firmware *e100_request_firmware(struct nic *nic)
1253 err = request_firmware(&fw, fw_name, &nic->pdev->dev); 1256 err = request_firmware(&fw, fw_name, &nic->pdev->dev);
1254 1257
1255 if (err) { 1258 if (err) {
1256 DPRINTK(PROBE, ERR, "Failed to load firmware \"%s\": %d\n", 1259 netif_err(nic, probe, nic->netdev,
1257 fw_name, err); 1260 "Failed to load firmware \"%s\": %d\n",
1261 fw_name, err);
1258 return ERR_PTR(err); 1262 return ERR_PTR(err);
1259 } 1263 }
1260 1264
1261 /* Firmware should be precisely UCODE_SIZE (words) plus three bytes 1265 /* Firmware should be precisely UCODE_SIZE (words) plus three bytes
1262 indicating the offsets for BUNDLESMALL, BUNDLEMAX, INTDELAY */ 1266 indicating the offsets for BUNDLESMALL, BUNDLEMAX, INTDELAY */
1263 if (fw->size != UCODE_SIZE * 4 + 3) { 1267 if (fw->size != UCODE_SIZE * 4 + 3) {
1264 DPRINTK(PROBE, ERR, "Firmware \"%s\" has wrong size %zu\n", 1268 netif_err(nic, probe, nic->netdev,
1265 fw_name, fw->size); 1269 "Firmware \"%s\" has wrong size %zu\n",
1270 fw_name, fw->size);
1266 release_firmware(fw); 1271 release_firmware(fw);
1267 return ERR_PTR(-EINVAL); 1272 return ERR_PTR(-EINVAL);
1268 } 1273 }
@@ -1274,9 +1279,9 @@ static const struct firmware *e100_request_firmware(struct nic *nic)
1274 1279
1275 if (timer >= UCODE_SIZE || bundle >= UCODE_SIZE || 1280 if (timer >= UCODE_SIZE || bundle >= UCODE_SIZE ||
1276 min_size >= UCODE_SIZE) { 1281 min_size >= UCODE_SIZE) {
1277 DPRINTK(PROBE, ERR, 1282 netif_err(nic, probe, nic->netdev,
1278 "\"%s\" has bogus offset values (0x%x,0x%x,0x%x)\n", 1283 "\"%s\" has bogus offset values (0x%x,0x%x,0x%x)\n",
1279 fw_name, timer, bundle, min_size); 1284 fw_name, timer, bundle, min_size);
1280 release_firmware(fw); 1285 release_firmware(fw);
1281 return ERR_PTR(-EINVAL); 1286 return ERR_PTR(-EINVAL);
1282 } 1287 }
@@ -1328,7 +1333,8 @@ static inline int e100_load_ucode_wait(struct nic *nic)
1328 return PTR_ERR(fw); 1333 return PTR_ERR(fw);
1329 1334
1330 if ((err = e100_exec_cb(nic, (void *)fw, e100_setup_ucode))) 1335 if ((err = e100_exec_cb(nic, (void *)fw, e100_setup_ucode)))
1331 DPRINTK(PROBE,ERR, "ucode cmd failed with error %d\n", err); 1336 netif_err(nic, probe, nic->netdev,
1337 "ucode cmd failed with error %d\n", err);
1332 1338
1333 /* must restart cuc */ 1339 /* must restart cuc */
1334 nic->cuc_cmd = cuc_start; 1340 nic->cuc_cmd = cuc_start;
@@ -1348,7 +1354,7 @@ static inline int e100_load_ucode_wait(struct nic *nic)
1348 1354
1349 /* if the command failed, or is not OK, notify and return */ 1355 /* if the command failed, or is not OK, notify and return */
1350 if (!counter || !(cb->status & cpu_to_le16(cb_ok))) { 1356 if (!counter || !(cb->status & cpu_to_le16(cb_ok))) {
1351 DPRINTK(PROBE,ERR, "ucode load failed\n"); 1357 netif_err(nic, probe, nic->netdev, "ucode load failed\n");
1352 err = -EPERM; 1358 err = -EPERM;
1353 } 1359 }
1354 1360
@@ -1386,8 +1392,8 @@ static int e100_phy_check_without_mii(struct nic *nic)
1386 * media is sensed automatically based on how the link partner 1392 * media is sensed automatically based on how the link partner
1387 * is configured. This is, in essence, manual configuration. 1393 * is configured. This is, in essence, manual configuration.
1388 */ 1394 */
1389 DPRINTK(PROBE, INFO, 1395 netif_info(nic, probe, nic->netdev,
1390 "found MII-less i82503 or 80c24 or other PHY\n"); 1396 "found MII-less i82503 or 80c24 or other PHY\n");
1391 1397
1392 nic->mdio_ctrl = mdio_ctrl_phy_mii_emulated; 1398 nic->mdio_ctrl = mdio_ctrl_phy_mii_emulated;
1393 nic->mii.phy_id = 0; /* is this ok for an MII-less PHY? */ 1399 nic->mii.phy_id = 0; /* is this ok for an MII-less PHY? */
@@ -1434,18 +1440,20 @@ static int e100_phy_init(struct nic *nic)
1434 return 0; /* simply return and hope for the best */ 1440 return 0; /* simply return and hope for the best */
1435 else { 1441 else {
1436 /* for unknown cases log a fatal error */ 1442 /* for unknown cases log a fatal error */
1437 DPRINTK(HW, ERR, 1443 netif_err(nic, hw, nic->netdev,
1438 "Failed to locate any known PHY, aborting.\n"); 1444 "Failed to locate any known PHY, aborting\n");
1439 return -EAGAIN; 1445 return -EAGAIN;
1440 } 1446 }
1441 } else 1447 } else
1442 DPRINTK(HW, DEBUG, "phy_addr = %d\n", nic->mii.phy_id); 1448 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
1449 "phy_addr = %d\n", nic->mii.phy_id);
1443 1450
1444 /* Get phy ID */ 1451 /* Get phy ID */
1445 id_lo = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID1); 1452 id_lo = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID1);
1446 id_hi = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID2); 1453 id_hi = mdio_read(netdev, nic->mii.phy_id, MII_PHYSID2);
1447 nic->phy = (u32)id_hi << 16 | (u32)id_lo; 1454 nic->phy = (u32)id_hi << 16 | (u32)id_lo;
1448 DPRINTK(HW, DEBUG, "phy ID = 0x%08X\n", nic->phy); 1455 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
1456 "phy ID = 0x%08X\n", nic->phy);
1449 1457
1450 /* Select the phy and isolate the rest */ 1458 /* Select the phy and isolate the rest */
1451 for (addr = 0; addr < 32; addr++) { 1459 for (addr = 0; addr < 32; addr++) {
@@ -1507,7 +1515,7 @@ static int e100_hw_init(struct nic *nic)
1507 1515
1508 e100_hw_reset(nic); 1516 e100_hw_reset(nic);
1509 1517
1510 DPRINTK(HW, ERR, "e100_hw_init\n"); 1518 netif_err(nic, hw, nic->netdev, "e100_hw_init\n");
1511 if (!in_interrupt() && (err = e100_self_test(nic))) 1519 if (!in_interrupt() && (err = e100_self_test(nic)))
1512 return err; 1520 return err;
1513 1521
@@ -1537,16 +1545,16 @@ static int e100_hw_init(struct nic *nic)
1537static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb) 1545static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1538{ 1546{
1539 struct net_device *netdev = nic->netdev; 1547 struct net_device *netdev = nic->netdev;
1540 struct dev_mc_list *list; 1548 struct netdev_hw_addr *ha;
1541 u16 i, count = min(netdev_mc_count(netdev), E100_MAX_MULTICAST_ADDRS); 1549 u16 i, count = min(netdev_mc_count(netdev), E100_MAX_MULTICAST_ADDRS);
1542 1550
1543 cb->command = cpu_to_le16(cb_multi); 1551 cb->command = cpu_to_le16(cb_multi);
1544 cb->u.multi.count = cpu_to_le16(count * ETH_ALEN); 1552 cb->u.multi.count = cpu_to_le16(count * ETH_ALEN);
1545 i = 0; 1553 i = 0;
1546 netdev_for_each_mc_addr(list, netdev) { 1554 netdev_for_each_mc_addr(ha, netdev) {
1547 if (i == count) 1555 if (i == count)
1548 break; 1556 break;
1549 memcpy(&cb->u.multi.addr[i++ * ETH_ALEN], &list->dmi_addr, 1557 memcpy(&cb->u.multi.addr[i++ * ETH_ALEN], &ha->addr,
1550 ETH_ALEN); 1558 ETH_ALEN);
1551 } 1559 }
1552} 1560}
@@ -1555,8 +1563,9 @@ static void e100_set_multicast_list(struct net_device *netdev)
1555{ 1563{
1556 struct nic *nic = netdev_priv(netdev); 1564 struct nic *nic = netdev_priv(netdev);
1557 1565
1558 DPRINTK(HW, DEBUG, "mc_count=%d, flags=0x%04X\n", 1566 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
1559 netdev_mc_count(netdev), netdev->flags); 1567 "mc_count=%d, flags=0x%04X\n",
1568 netdev_mc_count(netdev), netdev->flags);
1560 1569
1561 if (netdev->flags & IFF_PROMISC) 1570 if (netdev->flags & IFF_PROMISC)
1562 nic->flags |= promiscuous; 1571 nic->flags |= promiscuous;
@@ -1629,7 +1638,8 @@ static void e100_update_stats(struct nic *nic)
1629 1638
1630 1639
1631 if (e100_exec_cmd(nic, cuc_dump_reset, 0)) 1640 if (e100_exec_cmd(nic, cuc_dump_reset, 0))
1632 DPRINTK(TX_ERR, DEBUG, "exec cuc_dump_reset failed\n"); 1641 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev,
1642 "exec cuc_dump_reset failed\n");
1633} 1643}
1634 1644
1635static void e100_adjust_adaptive_ifs(struct nic *nic, int speed, int duplex) 1645static void e100_adjust_adaptive_ifs(struct nic *nic, int speed, int duplex)
@@ -1659,20 +1669,19 @@ static void e100_watchdog(unsigned long data)
1659 struct nic *nic = (struct nic *)data; 1669 struct nic *nic = (struct nic *)data;
1660 struct ethtool_cmd cmd; 1670 struct ethtool_cmd cmd;
1661 1671
1662 DPRINTK(TIMER, DEBUG, "right now = %ld\n", jiffies); 1672 netif_printk(nic, timer, KERN_DEBUG, nic->netdev,
1673 "right now = %ld\n", jiffies);
1663 1674
1664 /* mii library handles link maintenance tasks */ 1675 /* mii library handles link maintenance tasks */
1665 1676
1666 mii_ethtool_gset(&nic->mii, &cmd); 1677 mii_ethtool_gset(&nic->mii, &cmd);
1667 1678
1668 if (mii_link_ok(&nic->mii) && !netif_carrier_ok(nic->netdev)) { 1679 if (mii_link_ok(&nic->mii) && !netif_carrier_ok(nic->netdev)) {
1669 printk(KERN_INFO "e100: %s NIC Link is Up %s Mbps %s Duplex\n", 1680 netdev_info(nic->netdev, "NIC Link is Up %u Mbps %s Duplex\n",
1670 nic->netdev->name, 1681 cmd.speed == SPEED_100 ? 100 : 10,
1671 cmd.speed == SPEED_100 ? "100" : "10", 1682 cmd.duplex == DUPLEX_FULL ? "Full" : "Half");
1672 cmd.duplex == DUPLEX_FULL ? "Full" : "Half");
1673 } else if (!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) { 1683 } else if (!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) {
1674 printk(KERN_INFO "e100: %s NIC Link is Down\n", 1684 netdev_info(nic->netdev, "NIC Link is Down\n");
1675 nic->netdev->name);
1676 } 1685 }
1677 1686
1678 mii_check_link(&nic->mii); 1687 mii_check_link(&nic->mii);
@@ -1732,7 +1741,8 @@ static netdev_tx_t e100_xmit_frame(struct sk_buff *skb,
1732 Issue a NOP command followed by a 1us delay before 1741 Issue a NOP command followed by a 1us delay before
1733 issuing the Tx command. */ 1742 issuing the Tx command. */
1734 if (e100_exec_cmd(nic, cuc_nop, 0)) 1743 if (e100_exec_cmd(nic, cuc_nop, 0))
1735 DPRINTK(TX_ERR, DEBUG, "exec cuc_nop failed\n"); 1744 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev,
1745 "exec cuc_nop failed\n");
1736 udelay(1); 1746 udelay(1);
1737 } 1747 }
1738 1748
@@ -1741,12 +1751,14 @@ static netdev_tx_t e100_xmit_frame(struct sk_buff *skb,
1741 switch (err) { 1751 switch (err) {
1742 case -ENOSPC: 1752 case -ENOSPC:
1743 /* We queued the skb, but now we're out of space. */ 1753 /* We queued the skb, but now we're out of space. */
1744 DPRINTK(TX_ERR, DEBUG, "No space for CB\n"); 1754 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev,
1755 "No space for CB\n");
1745 netif_stop_queue(netdev); 1756 netif_stop_queue(netdev);
1746 break; 1757 break;
1747 case -ENOMEM: 1758 case -ENOMEM:
1748 /* This is a hard error - log it. */ 1759 /* This is a hard error - log it. */
1749 DPRINTK(TX_ERR, DEBUG, "Out of Tx resources, returning skb\n"); 1760 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev,
1761 "Out of Tx resources, returning skb\n");
1750 netif_stop_queue(netdev); 1762 netif_stop_queue(netdev);
1751 return NETDEV_TX_BUSY; 1763 return NETDEV_TX_BUSY;
1752 } 1764 }
@@ -1767,9 +1779,10 @@ static int e100_tx_clean(struct nic *nic)
1767 for (cb = nic->cb_to_clean; 1779 for (cb = nic->cb_to_clean;
1768 cb->status & cpu_to_le16(cb_complete); 1780 cb->status & cpu_to_le16(cb_complete);
1769 cb = nic->cb_to_clean = cb->next) { 1781 cb = nic->cb_to_clean = cb->next) {
1770 DPRINTK(TX_DONE, DEBUG, "cb[%d]->status = 0x%04X\n", 1782 netif_printk(nic, tx_done, KERN_DEBUG, nic->netdev,
1771 (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)), 1783 "cb[%d]->status = 0x%04X\n",
1772 cb->status); 1784 (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)),
1785 cb->status);
1773 1786
1774 if (likely(cb->skb != NULL)) { 1787 if (likely(cb->skb != NULL)) {
1775 dev->stats.tx_packets++; 1788 dev->stats.tx_packets++;
@@ -1912,7 +1925,8 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1912 sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL); 1925 sizeof(struct rfd), PCI_DMA_BIDIRECTIONAL);
1913 rfd_status = le16_to_cpu(rfd->status); 1926 rfd_status = le16_to_cpu(rfd->status);
1914 1927
1915 DPRINTK(RX_STATUS, DEBUG, "status=0x%04X\n", rfd_status); 1928 netif_printk(nic, rx_status, KERN_DEBUG, nic->netdev,
1929 "status=0x%04X\n", rfd_status);
1916 1930
1917 /* If data isn't ready, nothing to indicate */ 1931 /* If data isn't ready, nothing to indicate */
1918 if (unlikely(!(rfd_status & cb_complete))) { 1932 if (unlikely(!(rfd_status & cb_complete))) {
@@ -2123,7 +2137,8 @@ static irqreturn_t e100_intr(int irq, void *dev_id)
2123 struct nic *nic = netdev_priv(netdev); 2137 struct nic *nic = netdev_priv(netdev);
2124 u8 stat_ack = ioread8(&nic->csr->scb.stat_ack); 2138 u8 stat_ack = ioread8(&nic->csr->scb.stat_ack);
2125 2139
2126 DPRINTK(INTR, DEBUG, "stat_ack = 0x%02X\n", stat_ack); 2140 netif_printk(nic, intr, KERN_DEBUG, nic->netdev,
2141 "stat_ack = 0x%02X\n", stat_ack);
2127 2142
2128 if (stat_ack == stat_ack_not_ours || /* Not our interrupt */ 2143 if (stat_ack == stat_ack_not_ours || /* Not our interrupt */
2129 stat_ack == stat_ack_not_present) /* Hardware is ejected */ 2144 stat_ack == stat_ack_not_present) /* Hardware is ejected */
@@ -2263,8 +2278,8 @@ static void e100_tx_timeout_task(struct work_struct *work)
2263 struct nic *nic = container_of(work, struct nic, tx_timeout_task); 2278 struct nic *nic = container_of(work, struct nic, tx_timeout_task);
2264 struct net_device *netdev = nic->netdev; 2279 struct net_device *netdev = nic->netdev;
2265 2280
2266 DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n", 2281 netif_printk(nic, tx_err, KERN_DEBUG, nic->netdev,
2267 ioread8(&nic->csr->scb.status)); 2282 "scb.status=0x%02X\n", ioread8(&nic->csr->scb.status));
2268 e100_down(netdev_priv(netdev)); 2283 e100_down(netdev_priv(netdev));
2269 e100_up(netdev_priv(netdev)); 2284 e100_up(netdev_priv(netdev));
2270} 2285}
@@ -2526,8 +2541,8 @@ static int e100_set_ringparam(struct net_device *netdev,
2526 rfds->count = min(rfds->count, rfds->max); 2541 rfds->count = min(rfds->count, rfds->max);
2527 cbs->count = max(ring->tx_pending, cbs->min); 2542 cbs->count = max(ring->tx_pending, cbs->min);
2528 cbs->count = min(cbs->count, cbs->max); 2543 cbs->count = min(cbs->count, cbs->max);
2529 DPRINTK(DRV, INFO, "Ring Param settings: rx: %d, tx %d\n", 2544 netif_info(nic, drv, nic->netdev, "Ring Param settings: rx: %d, tx %d\n",
2530 rfds->count, cbs->count); 2545 rfds->count, cbs->count);
2531 if (netif_running(netdev)) 2546 if (netif_running(netdev))
2532 e100_up(nic); 2547 e100_up(nic);
2533 2548
@@ -2704,7 +2719,7 @@ static int e100_open(struct net_device *netdev)
2704 2719
2705 netif_carrier_off(netdev); 2720 netif_carrier_off(netdev);
2706 if ((err = e100_up(nic))) 2721 if ((err = e100_up(nic)))
2707 DPRINTK(IFUP, ERR, "Cannot open interface, aborting.\n"); 2722 netif_err(nic, ifup, nic->netdev, "Cannot open interface, aborting\n");
2708 return err; 2723 return err;
2709} 2724}
2710 2725
@@ -2738,7 +2753,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2738 2753
2739 if (!(netdev = alloc_etherdev(sizeof(struct nic)))) { 2754 if (!(netdev = alloc_etherdev(sizeof(struct nic)))) {
2740 if (((1 << debug) - 1) & NETIF_MSG_PROBE) 2755 if (((1 << debug) - 1) & NETIF_MSG_PROBE)
2741 printk(KERN_ERR PFX "Etherdev alloc failed, abort.\n"); 2756 pr_err("Etherdev alloc failed, aborting\n");
2742 return -ENOMEM; 2757 return -ENOMEM;
2743 } 2758 }
2744 2759
@@ -2756,35 +2771,34 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2756 pci_set_drvdata(pdev, netdev); 2771 pci_set_drvdata(pdev, netdev);
2757 2772
2758 if ((err = pci_enable_device(pdev))) { 2773 if ((err = pci_enable_device(pdev))) {
2759 DPRINTK(PROBE, ERR, "Cannot enable PCI device, aborting.\n"); 2774 netif_err(nic, probe, nic->netdev, "Cannot enable PCI device, aborting\n");
2760 goto err_out_free_dev; 2775 goto err_out_free_dev;
2761 } 2776 }
2762 2777
2763 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 2778 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
2764 DPRINTK(PROBE, ERR, "Cannot find proper PCI device " 2779 netif_err(nic, probe, nic->netdev, "Cannot find proper PCI device base address, aborting\n");
2765 "base address, aborting.\n");
2766 err = -ENODEV; 2780 err = -ENODEV;
2767 goto err_out_disable_pdev; 2781 goto err_out_disable_pdev;
2768 } 2782 }
2769 2783
2770 if ((err = pci_request_regions(pdev, DRV_NAME))) { 2784 if ((err = pci_request_regions(pdev, DRV_NAME))) {
2771 DPRINTK(PROBE, ERR, "Cannot obtain PCI resources, aborting.\n"); 2785 netif_err(nic, probe, nic->netdev, "Cannot obtain PCI resources, aborting\n");
2772 goto err_out_disable_pdev; 2786 goto err_out_disable_pdev;
2773 } 2787 }
2774 2788
2775 if ((err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))) { 2789 if ((err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))) {
2776 DPRINTK(PROBE, ERR, "No usable DMA configuration, aborting.\n"); 2790 netif_err(nic, probe, nic->netdev, "No usable DMA configuration, aborting\n");
2777 goto err_out_free_res; 2791 goto err_out_free_res;
2778 } 2792 }
2779 2793
2780 SET_NETDEV_DEV(netdev, &pdev->dev); 2794 SET_NETDEV_DEV(netdev, &pdev->dev);
2781 2795
2782 if (use_io) 2796 if (use_io)
2783 DPRINTK(PROBE, INFO, "using i/o access mode\n"); 2797 netif_info(nic, probe, nic->netdev, "using i/o access mode\n");
2784 2798
2785 nic->csr = pci_iomap(pdev, (use_io ? 1 : 0), sizeof(struct csr)); 2799 nic->csr = pci_iomap(pdev, (use_io ? 1 : 0), sizeof(struct csr));
2786 if (!nic->csr) { 2800 if (!nic->csr) {
2787 DPRINTK(PROBE, ERR, "Cannot map device registers, aborting.\n"); 2801 netif_err(nic, probe, nic->netdev, "Cannot map device registers, aborting\n");
2788 err = -ENOMEM; 2802 err = -ENOMEM;
2789 goto err_out_free_res; 2803 goto err_out_free_res;
2790 } 2804 }
@@ -2818,7 +2832,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2818 INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task); 2832 INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task);
2819 2833
2820 if ((err = e100_alloc(nic))) { 2834 if ((err = e100_alloc(nic))) {
2821 DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n"); 2835 netif_err(nic, probe, nic->netdev, "Cannot alloc driver memory, aborting\n");
2822 goto err_out_iounmap; 2836 goto err_out_iounmap;
2823 } 2837 }
2824 2838
@@ -2831,13 +2845,11 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2831 memcpy(netdev->perm_addr, nic->eeprom, ETH_ALEN); 2845 memcpy(netdev->perm_addr, nic->eeprom, ETH_ALEN);
2832 if (!is_valid_ether_addr(netdev->perm_addr)) { 2846 if (!is_valid_ether_addr(netdev->perm_addr)) {
2833 if (!eeprom_bad_csum_allow) { 2847 if (!eeprom_bad_csum_allow) {
2834 DPRINTK(PROBE, ERR, "Invalid MAC address from " 2848 netif_err(nic, probe, nic->netdev, "Invalid MAC address from EEPROM, aborting\n");
2835 "EEPROM, aborting.\n");
2836 err = -EAGAIN; 2849 err = -EAGAIN;
2837 goto err_out_free; 2850 goto err_out_free;
2838 } else { 2851 } else {
2839 DPRINTK(PROBE, ERR, "Invalid MAC address from EEPROM, " 2852 netif_err(nic, probe, nic->netdev, "Invalid MAC address from EEPROM, you MUST configure one.\n");
2840 "you MUST configure one.\n");
2841 } 2853 }
2842 } 2854 }
2843 2855
@@ -2853,7 +2865,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2853 2865
2854 strcpy(netdev->name, "eth%d"); 2866 strcpy(netdev->name, "eth%d");
2855 if ((err = register_netdev(netdev))) { 2867 if ((err = register_netdev(netdev))) {
2856 DPRINTK(PROBE, ERR, "Cannot register net device, aborting.\n"); 2868 netif_err(nic, probe, nic->netdev, "Cannot register net device, aborting\n");
2857 goto err_out_free; 2869 goto err_out_free;
2858 } 2870 }
2859 nic->cbs_pool = pci_pool_create(netdev->name, 2871 nic->cbs_pool = pci_pool_create(netdev->name,
@@ -2861,9 +2873,10 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2861 nic->params.cbs.max * sizeof(struct cb), 2873 nic->params.cbs.max * sizeof(struct cb),
2862 sizeof(u32), 2874 sizeof(u32),
2863 0); 2875 0);
2864 DPRINTK(PROBE, INFO, "addr 0x%llx, irq %d, MAC addr %pM\n", 2876 netif_info(nic, probe, nic->netdev,
2865 (unsigned long long)pci_resource_start(pdev, use_io ? 1 : 0), 2877 "addr 0x%llx, irq %d, MAC addr %pM\n",
2866 pdev->irq, netdev->dev_addr); 2878 (unsigned long long)pci_resource_start(pdev, use_io ? 1 : 0),
2879 pdev->irq, netdev->dev_addr);
2867 2880
2868 return 0; 2881 return 0;
2869 2882
@@ -3021,7 +3034,7 @@ static pci_ers_result_t e100_io_slot_reset(struct pci_dev *pdev)
3021 struct nic *nic = netdev_priv(netdev); 3034 struct nic *nic = netdev_priv(netdev);
3022 3035
3023 if (pci_enable_device(pdev)) { 3036 if (pci_enable_device(pdev)) {
3024 printk(KERN_ERR "e100: Cannot re-enable PCI device after reset.\n"); 3037 pr_err("Cannot re-enable PCI device after reset\n");
3025 return PCI_ERS_RESULT_DISCONNECT; 3038 return PCI_ERS_RESULT_DISCONNECT;
3026 } 3039 }
3027 pci_set_master(pdev); 3040 pci_set_master(pdev);
@@ -3080,8 +3093,8 @@ static struct pci_driver e100_driver = {
3080static int __init e100_init_module(void) 3093static int __init e100_init_module(void)
3081{ 3094{
3082 if (((1 << debug) - 1) & NETIF_MSG_DRV) { 3095 if (((1 << debug) - 1) & NETIF_MSG_DRV) {
3083 printk(KERN_INFO PFX "%s, %s\n", DRV_DESCRIPTION, DRV_VERSION); 3096 pr_info("%s, %s\n", DRV_DESCRIPTION, DRV_VERSION);
3084 printk(KERN_INFO PFX "%s\n", DRV_COPYRIGHT); 3097 pr_info("%s\n", DRV_COPYRIGHT);
3085 } 3098 }
3086 return pci_register_driver(&e100_driver); 3099 return pci_register_driver(&e100_driver);
3087} 3100}
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index 8d7d87f12827..e2b6e6e7ba6a 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -990,7 +990,7 @@ static s32 e1000_copper_link_preconfig(struct e1000_hw *hw)
990 DEBUGOUT("Error, did not detect valid phy.\n"); 990 DEBUGOUT("Error, did not detect valid phy.\n");
991 return ret_val; 991 return ret_val;
992 } 992 }
993 DEBUGOUT1("Phy ID = %x \n", hw->phy_id); 993 DEBUGOUT1("Phy ID = %x\n", hw->phy_id);
994 994
995 /* Set PHY to class A mode (if necessary) */ 995 /* Set PHY to class A mode (if necessary) */
996 ret_val = e1000_set_phy_mode(hw); 996 ret_val = e1000_set_phy_mode(hw);
@@ -1680,7 +1680,7 @@ static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw)
1680 if (ret_val) 1680 if (ret_val)
1681 return ret_val; 1681 return ret_val;
1682 1682
1683 DEBUGOUT1("M88E1000 PSCR: %x \n", phy_data); 1683 DEBUGOUT1("M88E1000 PSCR: %x\n", phy_data);
1684 1684
1685 /* Need to reset the PHY or these changes will be ignored */ 1685 /* Need to reset the PHY or these changes will be ignored */
1686 mii_ctrl_reg |= MII_CR_RESET; 1686 mii_ctrl_reg |= MII_CR_RESET;
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index b15ece26ed84..47da5fc1e9f4 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -2098,7 +2098,6 @@ static void e1000_set_rx_mode(struct net_device *netdev)
2098 struct e1000_hw *hw = &adapter->hw; 2098 struct e1000_hw *hw = &adapter->hw;
2099 struct netdev_hw_addr *ha; 2099 struct netdev_hw_addr *ha;
2100 bool use_uc = false; 2100 bool use_uc = false;
2101 struct dev_addr_list *mc_ptr;
2102 u32 rctl; 2101 u32 rctl;
2103 u32 hash_value; 2102 u32 hash_value;
2104 int i, rar_entries = E1000_RAR_ENTRIES; 2103 int i, rar_entries = E1000_RAR_ENTRIES;
@@ -2158,17 +2157,17 @@ static void e1000_set_rx_mode(struct net_device *netdev)
2158 2157
2159 WARN_ON(i == rar_entries); 2158 WARN_ON(i == rar_entries);
2160 2159
2161 netdev_for_each_mc_addr(mc_ptr, netdev) { 2160 netdev_for_each_mc_addr(ha, netdev) {
2162 if (i == rar_entries) { 2161 if (i == rar_entries) {
2163 /* load any remaining addresses into the hash table */ 2162 /* load any remaining addresses into the hash table */
2164 u32 hash_reg, hash_bit, mta; 2163 u32 hash_reg, hash_bit, mta;
2165 hash_value = e1000_hash_mc_addr(hw, mc_ptr->da_addr); 2164 hash_value = e1000_hash_mc_addr(hw, ha->addr);
2166 hash_reg = (hash_value >> 5) & 0x7F; 2165 hash_reg = (hash_value >> 5) & 0x7F;
2167 hash_bit = hash_value & 0x1F; 2166 hash_bit = hash_value & 0x1F;
2168 mta = (1 << hash_bit); 2167 mta = (1 << hash_bit);
2169 mcarray[hash_reg] |= mta; 2168 mcarray[hash_reg] |= mta;
2170 } else { 2169 } else {
2171 e1000_rar_set(hw, mc_ptr->da_addr, i++); 2170 e1000_rar_set(hw, ha->addr, i++);
2172 } 2171 }
2173 } 2172 }
2174 2173
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index 712ccc66ba25..4b0016d69530 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -323,7 +323,7 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
323 } 323 }
324 324
325 /* 325 /*
326 * Initialze device specific counter of SMBI acquisition 326 * Initialize device specific counter of SMBI acquisition
327 * timeouts. 327 * timeouts.
328 */ 328 */
329 hw->dev_spec.e82571.smb_counter = 0; 329 hw->dev_spec.e82571.smb_counter = 0;
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 118bdf483593..12648a1cdb78 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -42,25 +42,16 @@
42 42
43struct e1000_info; 43struct e1000_info;
44 44
45#define e_printk(level, adapter, format, arg...) \
46 printk(level "%s: %s: " format, pci_name(adapter->pdev), \
47 adapter->netdev->name, ## arg)
48
49#ifdef DEBUG
50#define e_dbg(format, arg...) \ 45#define e_dbg(format, arg...) \
51 e_printk(KERN_DEBUG , hw->adapter, format, ## arg) 46 netdev_dbg(hw->adapter->netdev, format, ## arg)
52#else
53#define e_dbg(format, arg...) do { (void)(hw); } while (0)
54#endif
55
56#define e_err(format, arg...) \ 47#define e_err(format, arg...) \
57 e_printk(KERN_ERR, adapter, format, ## arg) 48 netdev_err(adapter->netdev, format, ## arg)
58#define e_info(format, arg...) \ 49#define e_info(format, arg...) \
59 e_printk(KERN_INFO, adapter, format, ## arg) 50 netdev_info(adapter->netdev, format, ## arg)
60#define e_warn(format, arg...) \ 51#define e_warn(format, arg...) \
61 e_printk(KERN_WARNING, adapter, format, ## arg) 52 netdev_warn(adapter->netdev, format, ## arg)
62#define e_notice(format, arg...) \ 53#define e_notice(format, arg...) \
63 e_printk(KERN_NOTICE, adapter, format, ## arg) 54 netdev_notice(adapter->netdev, format, ## arg)
64 55
65 56
66/* Interrupt modes, as used by the IntMode parameter */ 57/* Interrupt modes, as used by the IntMode parameter */
@@ -158,6 +149,9 @@ struct e1000_info;
158#define HV_M_STATUS_SPEED_1000 0x0200 149#define HV_M_STATUS_SPEED_1000 0x0200
159#define HV_M_STATUS_LINK_UP 0x0040 150#define HV_M_STATUS_LINK_UP 0x0040
160 151
152/* Time to wait before putting the device into D3 if there's no link (in ms). */
153#define LINK_TIMEOUT 100
154
161enum e1000_boards { 155enum e1000_boards {
162 board_82571, 156 board_82571,
163 board_82572, 157 board_82572,
@@ -369,6 +363,8 @@ struct e1000_adapter {
369 struct work_struct update_phy_task; 363 struct work_struct update_phy_task;
370 struct work_struct led_blink_task; 364 struct work_struct led_blink_task;
371 struct work_struct print_hang_task; 365 struct work_struct print_hang_task;
366
367 bool idle_check;
372}; 368};
373 369
374struct e1000_info { 370struct e1000_info {
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 8b5e157e9c87..5059c22155d9 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -1622,7 +1622,7 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
1622 /* Check if the flash descriptor is valid */ 1622 /* Check if the flash descriptor is valid */
1623 if (hsfsts.hsf_status.fldesvalid == 0) { 1623 if (hsfsts.hsf_status.fldesvalid == 0) {
1624 e_dbg("Flash descriptor invalid. " 1624 e_dbg("Flash descriptor invalid. "
1625 "SW Sequencing must be used."); 1625 "SW Sequencing must be used.\n");
1626 return -E1000_ERR_NVM; 1626 return -E1000_ERR_NVM;
1627 } 1627 }
1628 1628
@@ -1671,7 +1671,7 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
1671 hsfsts.hsf_status.flcdone = 1; 1671 hsfsts.hsf_status.flcdone = 1;
1672 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval); 1672 ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
1673 } else { 1673 } else {
1674 e_dbg("Flash controller busy, cannot get access"); 1674 e_dbg("Flash controller busy, cannot get access\n");
1675 } 1675 }
1676 } 1676 }
1677 1677
@@ -1822,7 +1822,7 @@ static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
1822 continue; 1822 continue;
1823 } else if (hsfsts.hsf_status.flcdone == 0) { 1823 } else if (hsfsts.hsf_status.flcdone == 0) {
1824 e_dbg("Timeout error - flash cycle " 1824 e_dbg("Timeout error - flash cycle "
1825 "did not complete."); 1825 "did not complete.\n");
1826 break; 1826 break;
1827 } 1827 }
1828 } 1828 }
diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index a8b2c0de27c4..b0d2a60aa490 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -1262,24 +1262,21 @@ s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *dup
1262 u32 status; 1262 u32 status;
1263 1263
1264 status = er32(STATUS); 1264 status = er32(STATUS);
1265 if (status & E1000_STATUS_SPEED_1000) { 1265 if (status & E1000_STATUS_SPEED_1000)
1266 *speed = SPEED_1000; 1266 *speed = SPEED_1000;
1267 e_dbg("1000 Mbs, "); 1267 else if (status & E1000_STATUS_SPEED_100)
1268 } else if (status & E1000_STATUS_SPEED_100) {
1269 *speed = SPEED_100; 1268 *speed = SPEED_100;
1270 e_dbg("100 Mbs, "); 1269 else
1271 } else {
1272 *speed = SPEED_10; 1270 *speed = SPEED_10;
1273 e_dbg("10 Mbs, ");
1274 }
1275 1271
1276 if (status & E1000_STATUS_FD) { 1272 if (status & E1000_STATUS_FD)
1277 *duplex = FULL_DUPLEX; 1273 *duplex = FULL_DUPLEX;
1278 e_dbg("Full Duplex\n"); 1274 else
1279 } else {
1280 *duplex = HALF_DUPLEX; 1275 *duplex = HALF_DUPLEX;
1281 e_dbg("Half Duplex\n"); 1276
1282 } 1277 e_dbg("%u Mbps, %s Duplex\n",
1278 *speed == SPEED_1000 ? 1000 : *speed == SPEED_100 ? 100 : 10,
1279 *duplex == FULL_DUPLEX ? "Full" : "Half");
1283 1280
1284 return 0; 1281 return 0;
1285} 1282}
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index e1cceb606576..167b1aedfb42 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -26,6 +26,8 @@
26 26
27*******************************************************************************/ 27*******************************************************************************/
28 28
29#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
30
29#include <linux/module.h> 31#include <linux/module.h>
30#include <linux/types.h> 32#include <linux/types.h>
31#include <linux/init.h> 33#include <linux/init.h>
@@ -44,6 +46,7 @@
44#include <linux/cpu.h> 46#include <linux/cpu.h>
45#include <linux/smp.h> 47#include <linux/smp.h>
46#include <linux/pm_qos_params.h> 48#include <linux/pm_qos_params.h>
49#include <linux/pm_runtime.h>
47#include <linux/aer.h> 50#include <linux/aer.h>
48 51
49#include "e1000.h" 52#include "e1000.h"
@@ -2562,7 +2565,7 @@ static void e1000_set_multi(struct net_device *netdev)
2562{ 2565{
2563 struct e1000_adapter *adapter = netdev_priv(netdev); 2566 struct e1000_adapter *adapter = netdev_priv(netdev);
2564 struct e1000_hw *hw = &adapter->hw; 2567 struct e1000_hw *hw = &adapter->hw;
2565 struct dev_mc_list *mc_ptr; 2568 struct netdev_hw_addr *ha;
2566 u8 *mta_list; 2569 u8 *mta_list;
2567 u32 rctl; 2570 u32 rctl;
2568 int i; 2571 int i;
@@ -2594,9 +2597,8 @@ static void e1000_set_multi(struct net_device *netdev)
2594 2597
2595 /* prepare a packed array of only addresses. */ 2598 /* prepare a packed array of only addresses. */
2596 i = 0; 2599 i = 0;
2597 netdev_for_each_mc_addr(mc_ptr, netdev) 2600 netdev_for_each_mc_addr(ha, netdev)
2598 memcpy(mta_list + (i++ * ETH_ALEN), 2601 memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN);
2599 mc_ptr->dmi_addr, ETH_ALEN);
2600 2602
2601 e1000_update_mc_addr_list(hw, mta_list, i); 2603 e1000_update_mc_addr_list(hw, mta_list, i);
2602 kfree(mta_list); 2604 kfree(mta_list);
@@ -3080,12 +3082,15 @@ static int e1000_open(struct net_device *netdev)
3080{ 3082{
3081 struct e1000_adapter *adapter = netdev_priv(netdev); 3083 struct e1000_adapter *adapter = netdev_priv(netdev);
3082 struct e1000_hw *hw = &adapter->hw; 3084 struct e1000_hw *hw = &adapter->hw;
3085 struct pci_dev *pdev = adapter->pdev;
3083 int err; 3086 int err;
3084 3087
3085 /* disallow open during test */ 3088 /* disallow open during test */
3086 if (test_bit(__E1000_TESTING, &adapter->state)) 3089 if (test_bit(__E1000_TESTING, &adapter->state))
3087 return -EBUSY; 3090 return -EBUSY;
3088 3091
3092 pm_runtime_get_sync(&pdev->dev);
3093
3089 netif_carrier_off(netdev); 3094 netif_carrier_off(netdev);
3090 3095
3091 /* allocate transmit descriptors */ 3096 /* allocate transmit descriptors */
@@ -3146,6 +3151,9 @@ static int e1000_open(struct net_device *netdev)
3146 3151
3147 netif_start_queue(netdev); 3152 netif_start_queue(netdev);
3148 3153
3154 adapter->idle_check = true;
3155 pm_runtime_put(&pdev->dev);
3156
3149 /* fire a link status change interrupt to start the watchdog */ 3157 /* fire a link status change interrupt to start the watchdog */
3150 ew32(ICS, E1000_ICS_LSC); 3158 ew32(ICS, E1000_ICS_LSC);
3151 3159
@@ -3159,6 +3167,7 @@ err_setup_rx:
3159 e1000e_free_tx_resources(adapter); 3167 e1000e_free_tx_resources(adapter);
3160err_setup_tx: 3168err_setup_tx:
3161 e1000e_reset(adapter); 3169 e1000e_reset(adapter);
3170 pm_runtime_put_sync(&pdev->dev);
3162 3171
3163 return err; 3172 return err;
3164} 3173}
@@ -3177,11 +3186,17 @@ err_setup_tx:
3177static int e1000_close(struct net_device *netdev) 3186static int e1000_close(struct net_device *netdev)
3178{ 3187{
3179 struct e1000_adapter *adapter = netdev_priv(netdev); 3188 struct e1000_adapter *adapter = netdev_priv(netdev);
3189 struct pci_dev *pdev = adapter->pdev;
3180 3190
3181 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state)); 3191 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
3182 e1000e_down(adapter); 3192
3193 pm_runtime_get_sync(&pdev->dev);
3194
3195 if (!test_bit(__E1000_DOWN, &adapter->state)) {
3196 e1000e_down(adapter);
3197 e1000_free_irq(adapter);
3198 }
3183 e1000_power_down_phy(adapter); 3199 e1000_power_down_phy(adapter);
3184 e1000_free_irq(adapter);
3185 3200
3186 e1000e_free_tx_resources(adapter); 3201 e1000e_free_tx_resources(adapter);
3187 e1000e_free_rx_resources(adapter); 3202 e1000e_free_rx_resources(adapter);
@@ -3203,6 +3218,8 @@ static int e1000_close(struct net_device *netdev)
3203 if (adapter->flags & FLAG_HAS_AMT) 3218 if (adapter->flags & FLAG_HAS_AMT)
3204 e1000_release_hw_control(adapter); 3219 e1000_release_hw_control(adapter);
3205 3220
3221 pm_runtime_put_sync(&pdev->dev);
3222
3206 return 0; 3223 return 0;
3207} 3224}
3208/** 3225/**
@@ -3547,6 +3564,9 @@ static void e1000_watchdog_task(struct work_struct *work)
3547 3564
3548 link = e1000e_has_link(adapter); 3565 link = e1000e_has_link(adapter);
3549 if ((netif_carrier_ok(netdev)) && link) { 3566 if ((netif_carrier_ok(netdev)) && link) {
3567 /* Cancel scheduled suspend requests. */
3568 pm_runtime_resume(netdev->dev.parent);
3569
3550 e1000e_enable_receives(adapter); 3570 e1000e_enable_receives(adapter);
3551 goto link_up; 3571 goto link_up;
3552 } 3572 }
@@ -3558,6 +3578,10 @@ static void e1000_watchdog_task(struct work_struct *work)
3558 if (link) { 3578 if (link) {
3559 if (!netif_carrier_ok(netdev)) { 3579 if (!netif_carrier_ok(netdev)) {
3560 bool txb2b = 1; 3580 bool txb2b = 1;
3581
3582 /* Cancel scheduled suspend requests. */
3583 pm_runtime_resume(netdev->dev.parent);
3584
3561 /* update snapshot of PHY registers on LSC */ 3585 /* update snapshot of PHY registers on LSC */
3562 e1000_phy_read_status(adapter); 3586 e1000_phy_read_status(adapter);
3563 mac->ops.get_link_up_info(&adapter->hw, 3587 mac->ops.get_link_up_info(&adapter->hw,
@@ -3667,6 +3691,9 @@ static void e1000_watchdog_task(struct work_struct *work)
3667 3691
3668 if (adapter->flags & FLAG_RX_NEEDS_RESTART) 3692 if (adapter->flags & FLAG_RX_NEEDS_RESTART)
3669 schedule_work(&adapter->reset_task); 3693 schedule_work(&adapter->reset_task);
3694 else
3695 pm_schedule_suspend(netdev->dev.parent,
3696 LINK_TIMEOUT);
3670 } 3697 }
3671 } 3698 }
3672 3699
@@ -4464,13 +4491,15 @@ out:
4464 return retval; 4491 return retval;
4465} 4492}
4466 4493
4467static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) 4494static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake,
4495 bool runtime)
4468{ 4496{
4469 struct net_device *netdev = pci_get_drvdata(pdev); 4497 struct net_device *netdev = pci_get_drvdata(pdev);
4470 struct e1000_adapter *adapter = netdev_priv(netdev); 4498 struct e1000_adapter *adapter = netdev_priv(netdev);
4471 struct e1000_hw *hw = &adapter->hw; 4499 struct e1000_hw *hw = &adapter->hw;
4472 u32 ctrl, ctrl_ext, rctl, status; 4500 u32 ctrl, ctrl_ext, rctl, status;
4473 u32 wufc = adapter->wol; 4501 /* Runtime suspend should only enable wakeup for link changes */
4502 u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol;
4474 int retval = 0; 4503 int retval = 0;
4475 4504
4476 netif_device_detach(netdev); 4505 netif_device_detach(netdev);
@@ -4627,43 +4656,21 @@ static void e1000e_disable_l1aspm(struct pci_dev *pdev)
4627 } 4656 }
4628} 4657}
4629 4658
4630#ifdef CONFIG_PM 4659#ifdef CONFIG_PM_OPS
4631static int e1000_suspend(struct pci_dev *pdev, pm_message_t state) 4660static bool e1000e_pm_ready(struct e1000_adapter *adapter)
4632{ 4661{
4633 int retval; 4662 return !!adapter->tx_ring->buffer_info;
4634 bool wake;
4635
4636 retval = __e1000_shutdown(pdev, &wake);
4637 if (!retval)
4638 e1000_complete_shutdown(pdev, true, wake);
4639
4640 return retval;
4641} 4663}
4642 4664
4643static int e1000_resume(struct pci_dev *pdev) 4665static int __e1000_resume(struct pci_dev *pdev)
4644{ 4666{
4645 struct net_device *netdev = pci_get_drvdata(pdev); 4667 struct net_device *netdev = pci_get_drvdata(pdev);
4646 struct e1000_adapter *adapter = netdev_priv(netdev); 4668 struct e1000_adapter *adapter = netdev_priv(netdev);
4647 struct e1000_hw *hw = &adapter->hw; 4669 struct e1000_hw *hw = &adapter->hw;
4648 u32 err; 4670 u32 err;
4649 4671
4650 pci_set_power_state(pdev, PCI_D0);
4651 pci_restore_state(pdev);
4652 pci_save_state(pdev);
4653 e1000e_disable_l1aspm(pdev); 4672 e1000e_disable_l1aspm(pdev);
4654 4673
4655 err = pci_enable_device_mem(pdev);
4656 if (err) {
4657 dev_err(&pdev->dev,
4658 "Cannot enable PCI device from suspend\n");
4659 return err;
4660 }
4661
4662 pci_set_master(pdev);
4663
4664 pci_enable_wake(pdev, PCI_D3hot, 0);
4665 pci_enable_wake(pdev, PCI_D3cold, 0);
4666
4667 e1000e_set_interrupt_capability(adapter); 4674 e1000e_set_interrupt_capability(adapter);
4668 if (netif_running(netdev)) { 4675 if (netif_running(netdev)) {
4669 err = e1000_request_irq(adapter); 4676 err = e1000_request_irq(adapter);
@@ -4721,13 +4728,88 @@ static int e1000_resume(struct pci_dev *pdev)
4721 4728
4722 return 0; 4729 return 0;
4723} 4730}
4724#endif 4731
4732#ifdef CONFIG_PM_SLEEP
4733static int e1000_suspend(struct device *dev)
4734{
4735 struct pci_dev *pdev = to_pci_dev(dev);
4736 int retval;
4737 bool wake;
4738
4739 retval = __e1000_shutdown(pdev, &wake, false);
4740 if (!retval)
4741 e1000_complete_shutdown(pdev, true, wake);
4742
4743 return retval;
4744}
4745
4746static int e1000_resume(struct device *dev)
4747{
4748 struct pci_dev *pdev = to_pci_dev(dev);
4749 struct net_device *netdev = pci_get_drvdata(pdev);
4750 struct e1000_adapter *adapter = netdev_priv(netdev);
4751
4752 if (e1000e_pm_ready(adapter))
4753 adapter->idle_check = true;
4754
4755 return __e1000_resume(pdev);
4756}
4757#endif /* CONFIG_PM_SLEEP */
4758
4759#ifdef CONFIG_PM_RUNTIME
4760static int e1000_runtime_suspend(struct device *dev)
4761{
4762 struct pci_dev *pdev = to_pci_dev(dev);
4763 struct net_device *netdev = pci_get_drvdata(pdev);
4764 struct e1000_adapter *adapter = netdev_priv(netdev);
4765
4766 if (e1000e_pm_ready(adapter)) {
4767 bool wake;
4768
4769 __e1000_shutdown(pdev, &wake, true);
4770 }
4771
4772 return 0;
4773}
4774
4775static int e1000_idle(struct device *dev)
4776{
4777 struct pci_dev *pdev = to_pci_dev(dev);
4778 struct net_device *netdev = pci_get_drvdata(pdev);
4779 struct e1000_adapter *adapter = netdev_priv(netdev);
4780
4781 if (!e1000e_pm_ready(adapter))
4782 return 0;
4783
4784 if (adapter->idle_check) {
4785 adapter->idle_check = false;
4786 if (!e1000e_has_link(adapter))
4787 pm_schedule_suspend(dev, MSEC_PER_SEC);
4788 }
4789
4790 return -EBUSY;
4791}
4792
4793static int e1000_runtime_resume(struct device *dev)
4794{
4795 struct pci_dev *pdev = to_pci_dev(dev);
4796 struct net_device *netdev = pci_get_drvdata(pdev);
4797 struct e1000_adapter *adapter = netdev_priv(netdev);
4798
4799 if (!e1000e_pm_ready(adapter))
4800 return 0;
4801
4802 adapter->idle_check = !dev->power.runtime_auto;
4803 return __e1000_resume(pdev);
4804}
4805#endif /* CONFIG_PM_RUNTIME */
4806#endif /* CONFIG_PM_OPS */
4725 4807
4726static void e1000_shutdown(struct pci_dev *pdev) 4808static void e1000_shutdown(struct pci_dev *pdev)
4727{ 4809{
4728 bool wake = false; 4810 bool wake = false;
4729 4811
4730 __e1000_shutdown(pdev, &wake); 4812 __e1000_shutdown(pdev, &wake, false);
4731 4813
4732 if (system_state == SYSTEM_POWER_OFF) 4814 if (system_state == SYSTEM_POWER_OFF)
4733 e1000_complete_shutdown(pdev, false, wake); 4815 e1000_complete_shutdown(pdev, false, wake);
@@ -4800,8 +4882,8 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4800 result = PCI_ERS_RESULT_DISCONNECT; 4882 result = PCI_ERS_RESULT_DISCONNECT;
4801 } else { 4883 } else {
4802 pci_set_master(pdev); 4884 pci_set_master(pdev);
4885 pdev->state_saved = true;
4803 pci_restore_state(pdev); 4886 pci_restore_state(pdev);
4804 pci_save_state(pdev);
4805 4887
4806 pci_enable_wake(pdev, PCI_D3hot, 0); 4888 pci_enable_wake(pdev, PCI_D3hot, 0);
4807 pci_enable_wake(pdev, PCI_D3cold, 0); 4889 pci_enable_wake(pdev, PCI_D3cold, 0);
@@ -5208,6 +5290,12 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
5208 5290
5209 e1000_print_device_info(adapter); 5291 e1000_print_device_info(adapter);
5210 5292
5293 if (pci_dev_run_wake(pdev)) {
5294 pm_runtime_set_active(&pdev->dev);
5295 pm_runtime_enable(&pdev->dev);
5296 }
5297 pm_schedule_suspend(&pdev->dev, MSEC_PER_SEC);
5298
5211 return 0; 5299 return 0;
5212 5300
5213err_register: 5301err_register:
@@ -5250,12 +5338,16 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
5250{ 5338{
5251 struct net_device *netdev = pci_get_drvdata(pdev); 5339 struct net_device *netdev = pci_get_drvdata(pdev);
5252 struct e1000_adapter *adapter = netdev_priv(netdev); 5340 struct e1000_adapter *adapter = netdev_priv(netdev);
5341 bool down = test_bit(__E1000_DOWN, &adapter->state);
5342
5343 pm_runtime_get_sync(&pdev->dev);
5253 5344
5254 /* 5345 /*
5255 * flush_scheduled work may reschedule our watchdog task, so 5346 * flush_scheduled work may reschedule our watchdog task, so
5256 * explicitly disable watchdog tasks from being rescheduled 5347 * explicitly disable watchdog tasks from being rescheduled
5257 */ 5348 */
5258 set_bit(__E1000_DOWN, &adapter->state); 5349 if (!down)
5350 set_bit(__E1000_DOWN, &adapter->state);
5259 del_timer_sync(&adapter->watchdog_timer); 5351 del_timer_sync(&adapter->watchdog_timer);
5260 del_timer_sync(&adapter->phy_info_timer); 5352 del_timer_sync(&adapter->phy_info_timer);
5261 5353
@@ -5269,8 +5361,17 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
5269 if (!(netdev->flags & IFF_UP)) 5361 if (!(netdev->flags & IFF_UP))
5270 e1000_power_down_phy(adapter); 5362 e1000_power_down_phy(adapter);
5271 5363
5364 /* Don't lie to e1000_close() down the road. */
5365 if (!down)
5366 clear_bit(__E1000_DOWN, &adapter->state);
5272 unregister_netdev(netdev); 5367 unregister_netdev(netdev);
5273 5368
5369 if (pci_dev_run_wake(pdev)) {
5370 pm_runtime_disable(&pdev->dev);
5371 pm_runtime_set_suspended(&pdev->dev);
5372 }
5373 pm_runtime_put_noidle(&pdev->dev);
5374
5274 /* 5375 /*
5275 * Release control of h/w to f/w. If f/w is AMT enabled, this 5376 * Release control of h/w to f/w. If f/w is AMT enabled, this
5276 * would have already happened in close and is redundant. 5377 * would have already happened in close and is redundant.
@@ -5370,16 +5471,22 @@ static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = {
5370}; 5471};
5371MODULE_DEVICE_TABLE(pci, e1000_pci_tbl); 5472MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
5372 5473
5474#ifdef CONFIG_PM_OPS
5475static const struct dev_pm_ops e1000_pm_ops = {
5476 SET_SYSTEM_SLEEP_PM_OPS(e1000_suspend, e1000_resume)
5477 SET_RUNTIME_PM_OPS(e1000_runtime_suspend,
5478 e1000_runtime_resume, e1000_idle)
5479};
5480#endif
5481
5373/* PCI Device API Driver */ 5482/* PCI Device API Driver */
5374static struct pci_driver e1000_driver = { 5483static struct pci_driver e1000_driver = {
5375 .name = e1000e_driver_name, 5484 .name = e1000e_driver_name,
5376 .id_table = e1000_pci_tbl, 5485 .id_table = e1000_pci_tbl,
5377 .probe = e1000_probe, 5486 .probe = e1000_probe,
5378 .remove = __devexit_p(e1000_remove), 5487 .remove = __devexit_p(e1000_remove),
5379#ifdef CONFIG_PM 5488#ifdef CONFIG_PM_OPS
5380 /* Power Management Hooks */ 5489 .driver.pm = &e1000_pm_ops,
5381 .suspend = e1000_suspend,
5382 .resume = e1000_resume,
5383#endif 5490#endif
5384 .shutdown = e1000_shutdown, 5491 .shutdown = e1000_shutdown,
5385 .err_handler = &e1000_err_handler 5492 .err_handler = &e1000_err_handler
@@ -5394,10 +5501,9 @@ static struct pci_driver e1000_driver = {
5394static int __init e1000_init_module(void) 5501static int __init e1000_init_module(void)
5395{ 5502{
5396 int ret; 5503 int ret;
5397 printk(KERN_INFO "%s: Intel(R) PRO/1000 Network Driver - %s\n", 5504 pr_info("Intel(R) PRO/1000 Network Driver - %s\n",
5398 e1000e_driver_name, e1000e_driver_version); 5505 e1000e_driver_version);
5399 printk(KERN_INFO "%s: Copyright (c) 1999 - 2009 Intel Corporation.\n", 5506 pr_info("Copyright (c) 1999 - 2009 Intel Corporation.\n");
5400 e1000e_driver_name);
5401 ret = pci_register_driver(&e1000_driver); 5507 ret = pci_register_driver(&e1000_driver);
5402 5508
5403 return ret; 5509 return ret;
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c
index 1b05bdf62c3c..b01e6997403b 100644
--- a/drivers/net/eepro.c
+++ b/drivers/net/eepro.c
@@ -646,7 +646,7 @@ static void __init printEEPROMInfo(struct net_device *dev)
646 if (GetBit(Word,ee_PortTPE)) printk(KERN_DEBUG "TPE "); 646 if (GetBit(Word,ee_PortTPE)) printk(KERN_DEBUG "TPE ");
647 if (GetBit(Word,ee_PortBNC)) printk(KERN_DEBUG "BNC "); 647 if (GetBit(Word,ee_PortBNC)) printk(KERN_DEBUG "BNC ");
648 if (GetBit(Word,ee_PortAUI)) printk(KERN_DEBUG "AUI "); 648 if (GetBit(Word,ee_PortAUI)) printk(KERN_DEBUG "AUI ");
649 printk(KERN_DEBUG "port(s) \n"); 649 printk(KERN_DEBUG "port(s)\n");
650 650
651 Word = lp->word[6]; 651 Word = lp->word[6];
652 printk(KERN_DEBUG "Word6:\n"); 652 printk(KERN_DEBUG "Word6:\n");
@@ -766,7 +766,7 @@ static int __init eepro_probe1(struct net_device *dev, int autoprobe)
766 /* Grab the region so we can find another board if autoIRQ fails. */ 766 /* Grab the region so we can find another board if autoIRQ fails. */
767 if (!request_region(ioaddr, EEPRO_IO_EXTENT, DRV_NAME)) { 767 if (!request_region(ioaddr, EEPRO_IO_EXTENT, DRV_NAME)) {
768 if (!autoprobe) 768 if (!autoprobe)
769 printk(KERN_WARNING "EEPRO: io-port 0x%04x in use \n", 769 printk(KERN_WARNING "EEPRO: io-port 0x%04x in use\n",
770 ioaddr); 770 ioaddr);
771 return -EBUSY; 771 return -EBUSY;
772 } 772 }
@@ -1287,7 +1287,7 @@ set_multicast_list(struct net_device *dev)
1287 struct eepro_local *lp = netdev_priv(dev); 1287 struct eepro_local *lp = netdev_priv(dev);
1288 short ioaddr = dev->base_addr; 1288 short ioaddr = dev->base_addr;
1289 unsigned short mode; 1289 unsigned short mode;
1290 struct dev_mc_list *dmi; 1290 struct netdev_hw_addr *ha;
1291 int mc_count = netdev_mc_count(dev); 1291 int mc_count = netdev_mc_count(dev);
1292 1292
1293 if (dev->flags&(IFF_ALLMULTI|IFF_PROMISC) || mc_count > 63) 1293 if (dev->flags&(IFF_ALLMULTI|IFF_PROMISC) || mc_count > 63)
@@ -1332,8 +1332,8 @@ set_multicast_list(struct net_device *dev)
1332 outw(0, ioaddr + IO_PORT); 1332 outw(0, ioaddr + IO_PORT);
1333 outw(6 * (mc_count + 1), ioaddr + IO_PORT); 1333 outw(6 * (mc_count + 1), ioaddr + IO_PORT);
1334 1334
1335 netdev_for_each_mc_addr(dmi, dev) { 1335 netdev_for_each_mc_addr(ha, dev) {
1336 eaddrs = (unsigned short *) dmi->dmi_addr; 1336 eaddrs = (unsigned short *) ha->addr;
1337 outw(*eaddrs++, ioaddr + IO_PORT); 1337 outw(*eaddrs++, ioaddr + IO_PORT);
1338 outw(*eaddrs++, ioaddr + IO_PORT); 1338 outw(*eaddrs++, ioaddr + IO_PORT);
1339 outw(*eaddrs++, ioaddr + IO_PORT); 1339 outw(*eaddrs++, ioaddr + IO_PORT);
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c
index 7013dc8a6cbc..b3882fd8db6d 100644
--- a/drivers/net/eexpress.c
+++ b/drivers/net/eexpress.c
@@ -1576,7 +1576,7 @@ static void eexp_hw_init586(struct net_device *dev)
1576 1576
1577static void eexp_setup_filter(struct net_device *dev) 1577static void eexp_setup_filter(struct net_device *dev)
1578{ 1578{
1579 struct dev_mc_list *dmi; 1579 struct netdev_hw_addr *ha;
1580 unsigned short ioaddr = dev->base_addr; 1580 unsigned short ioaddr = dev->base_addr;
1581 int count = netdev_mc_count(dev); 1581 int count = netdev_mc_count(dev);
1582 int i; 1582 int i;
@@ -1589,8 +1589,8 @@ static void eexp_setup_filter(struct net_device *dev)
1589 outw(CONF_NR_MULTICAST & ~31, ioaddr+SM_PTR); 1589 outw(CONF_NR_MULTICAST & ~31, ioaddr+SM_PTR);
1590 outw(6*count, ioaddr+SHADOW(CONF_NR_MULTICAST)); 1590 outw(6*count, ioaddr+SHADOW(CONF_NR_MULTICAST));
1591 i = 0; 1591 i = 0;
1592 netdev_for_each_mc_addr(dmi, dev) { 1592 netdev_for_each_mc_addr(ha, dev) {
1593 unsigned short *data = (unsigned short *) dmi->dmi_addr; 1593 unsigned short *data = (unsigned short *) ha->addr;
1594 1594
1595 if (i == count) 1595 if (i == count)
1596 break; 1596 break;
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index b004eaba3d7b..b97411aaa77c 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -1966,7 +1966,7 @@ static void ehea_add_multicast_entry(struct ehea_port *port, u8 *mc_mac_addr)
1966static void ehea_set_multicast_list(struct net_device *dev) 1966static void ehea_set_multicast_list(struct net_device *dev)
1967{ 1967{
1968 struct ehea_port *port = netdev_priv(dev); 1968 struct ehea_port *port = netdev_priv(dev);
1969 struct dev_mc_list *k_mcl_entry; 1969 struct netdev_hw_addr *ha;
1970 int ret; 1970 int ret;
1971 1971
1972 if (dev->flags & IFF_PROMISC) { 1972 if (dev->flags & IFF_PROMISC) {
@@ -1997,8 +1997,8 @@ static void ehea_set_multicast_list(struct net_device *dev)
1997 goto out; 1997 goto out;
1998 } 1998 }
1999 1999
2000 netdev_for_each_mc_addr(k_mcl_entry, dev) 2000 netdev_for_each_mc_addr(ha, dev)
2001 ehea_add_multicast_entry(port, k_mcl_entry->dmi_addr); 2001 ehea_add_multicast_entry(port, ha->addr);
2002 2002
2003 } 2003 }
2004out: 2004out:
diff --git a/drivers/net/enic/cq_enet_desc.h b/drivers/net/enic/cq_enet_desc.h
index 03dce9ed612c..337d1943af46 100644
--- a/drivers/net/enic/cq_enet_desc.h
+++ b/drivers/net/enic/cq_enet_desc.h
@@ -101,14 +101,18 @@ static inline void cq_enet_rq_desc_dec(struct cq_enet_rq_desc *desc,
101 u8 *tcp_udp_csum_ok, u8 *udp, u8 *tcp, u8 *ipv4_csum_ok, 101 u8 *tcp_udp_csum_ok, u8 *udp, u8 *tcp, u8 *ipv4_csum_ok,
102 u8 *ipv6, u8 *ipv4, u8 *ipv4_fragment, u8 *fcs_ok) 102 u8 *ipv6, u8 *ipv4, u8 *ipv4_fragment, u8 *fcs_ok)
103{ 103{
104 u16 completed_index_flags = le16_to_cpu(desc->completed_index_flags); 104 u16 completed_index_flags;
105 u16 q_number_rss_type_flags = 105 u16 q_number_rss_type_flags;
106 le16_to_cpu(desc->q_number_rss_type_flags); 106 u16 bytes_written_flags;
107 u16 bytes_written_flags = le16_to_cpu(desc->bytes_written_flags);
108 107
109 cq_desc_dec((struct cq_desc *)desc, type, 108 cq_desc_dec((struct cq_desc *)desc, type,
110 color, q_number, completed_index); 109 color, q_number, completed_index);
111 110
111 completed_index_flags = le16_to_cpu(desc->completed_index_flags);
112 q_number_rss_type_flags =
113 le16_to_cpu(desc->q_number_rss_type_flags);
114 bytes_written_flags = le16_to_cpu(desc->bytes_written_flags);
115
112 *ingress_port = (completed_index_flags & 116 *ingress_port = (completed_index_flags &
113 CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT) ? 1 : 0; 117 CQ_ENET_RQ_DESC_FLAGS_INGRESS_PORT) ? 1 : 0;
114 *fcoe = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_FCOE) ? 118 *fcoe = (completed_index_flags & CQ_ENET_RQ_DESC_FLAGS_FCOE) ?
diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h
index ee01f5a6d0d4..5fa56f1e5590 100644
--- a/drivers/net/enic/enic.h
+++ b/drivers/net/enic/enic.h
@@ -33,8 +33,8 @@
33#include "vnic_rss.h" 33#include "vnic_rss.h"
34 34
35#define DRV_NAME "enic" 35#define DRV_NAME "enic"
36#define DRV_DESCRIPTION "Cisco 10G Ethernet Driver" 36#define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver"
37#define DRV_VERSION "1.1.0.241a" 37#define DRV_VERSION "1.3.1.1"
38#define DRV_COPYRIGHT "Copyright 2008-2009 Cisco Systems, Inc" 38#define DRV_COPYRIGHT "Copyright 2008-2009 Cisco Systems, Inc"
39#define PFX DRV_NAME ": " 39#define PFX DRV_NAME ": "
40 40
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index cf098bb636b8..1232887c243d 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -822,14 +822,14 @@ static int enic_set_mac_addr(struct net_device *netdev, char *addr)
822static void enic_set_multicast_list(struct net_device *netdev) 822static void enic_set_multicast_list(struct net_device *netdev)
823{ 823{
824 struct enic *enic = netdev_priv(netdev); 824 struct enic *enic = netdev_priv(netdev);
825 struct dev_mc_list *list; 825 struct netdev_hw_addr *ha;
826 int directed = 1; 826 int directed = 1;
827 int multicast = (netdev->flags & IFF_MULTICAST) ? 1 : 0; 827 int multicast = (netdev->flags & IFF_MULTICAST) ? 1 : 0;
828 int broadcast = (netdev->flags & IFF_BROADCAST) ? 1 : 0; 828 int broadcast = (netdev->flags & IFF_BROADCAST) ? 1 : 0;
829 int promisc = (netdev->flags & IFF_PROMISC) ? 1 : 0; 829 int promisc = (netdev->flags & IFF_PROMISC) ? 1 : 0;
830 unsigned int mc_count = netdev_mc_count(netdev); 830 unsigned int mc_count = netdev_mc_count(netdev);
831 int allmulti = (netdev->flags & IFF_ALLMULTI) || 831 int allmulti = (netdev->flags & IFF_ALLMULTI) ||
832 mc_count > ENIC_MULTICAST_PERFECT_FILTERS; 832 mc_count > ENIC_MULTICAST_PERFECT_FILTERS;
833 unsigned int flags = netdev->flags | (allmulti ? IFF_ALLMULTI : 0); 833 unsigned int flags = netdev->flags | (allmulti ? IFF_ALLMULTI : 0);
834 u8 mc_addr[ENIC_MULTICAST_PERFECT_FILTERS][ETH_ALEN]; 834 u8 mc_addr[ENIC_MULTICAST_PERFECT_FILTERS][ETH_ALEN];
835 unsigned int i, j; 835 unsigned int i, j;
@@ -852,10 +852,10 @@ static void enic_set_multicast_list(struct net_device *netdev)
852 */ 852 */
853 853
854 i = 0; 854 i = 0;
855 netdev_for_each_mc_addr(list, netdev) { 855 netdev_for_each_mc_addr(ha, netdev) {
856 if (i == mc_count) 856 if (i == mc_count)
857 break; 857 break;
858 memcpy(mc_addr[i++], list->dmi_addr, ETH_ALEN); 858 memcpy(mc_addr[i++], ha->addr, ETH_ALEN);
859 } 859 }
860 860
861 for (i = 0; i < enic->mc_count; i++) { 861 for (i = 0; i < enic->mc_count; i++) {
@@ -2058,8 +2058,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
2058 netdev->watchdog_timeo = 2 * HZ; 2058 netdev->watchdog_timeo = 2 * HZ;
2059 netdev->ethtool_ops = &enic_ethtool_ops; 2059 netdev->ethtool_ops = &enic_ethtool_ops;
2060 2060
2061 netdev->features |= NETIF_F_HW_VLAN_TX | 2061 netdev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
2062 NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER;
2063 if (ENIC_SETTING(enic, TXCSUM)) 2062 if (ENIC_SETTING(enic, TXCSUM))
2064 netdev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; 2063 netdev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
2065 if (ENIC_SETTING(enic, TSO)) 2064 if (ENIC_SETTING(enic, TSO))
diff --git a/drivers/net/enic/vnic_dev.c b/drivers/net/enic/vnic_dev.c
index 69b9b70c7da0..cbc0ba953fc6 100644
--- a/drivers/net/enic/vnic_dev.c
+++ b/drivers/net/enic/vnic_dev.c
@@ -573,22 +573,18 @@ int vnic_dev_raise_intr(struct vnic_dev *vdev, u16 intr)
573 return err; 573 return err;
574} 574}
575 575
576int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr) 576int vnic_dev_notify_setcmd(struct vnic_dev *vdev,
577 void *notify_addr, dma_addr_t notify_pa, u16 intr)
577{ 578{
578 u64 a0, a1; 579 u64 a0, a1;
579 int wait = 1000; 580 int wait = 1000;
580 int r; 581 int r;
581 582
582 if (!vdev->notify) { 583 memset(notify_addr, 0, sizeof(struct vnic_devcmd_notify));
583 vdev->notify = pci_alloc_consistent(vdev->pdev, 584 vdev->notify = notify_addr;
584 sizeof(struct vnic_devcmd_notify), 585 vdev->notify_pa = notify_pa;
585 &vdev->notify_pa);
586 if (!vdev->notify)
587 return -ENOMEM;
588 memset(vdev->notify, 0, sizeof(struct vnic_devcmd_notify));
589 }
590 586
591 a0 = vdev->notify_pa; 587 a0 = (u64)notify_pa;
592 a1 = ((u64)intr << 32) & 0x0000ffff00000000ULL; 588 a1 = ((u64)intr << 32) & 0x0000ffff00000000ULL;
593 a1 += sizeof(struct vnic_devcmd_notify); 589 a1 += sizeof(struct vnic_devcmd_notify);
594 590
@@ -597,7 +593,27 @@ int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
597 return r; 593 return r;
598} 594}
599 595
600void vnic_dev_notify_unset(struct vnic_dev *vdev) 596int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
597{
598 void *notify_addr;
599 dma_addr_t notify_pa;
600
601 if (vdev->notify || vdev->notify_pa) {
602 printk(KERN_ERR "notify block %p still allocated",
603 vdev->notify);
604 return -EINVAL;
605 }
606
607 notify_addr = pci_alloc_consistent(vdev->pdev,
608 sizeof(struct vnic_devcmd_notify),
609 &notify_pa);
610 if (!notify_addr)
611 return -ENOMEM;
612
613 return vnic_dev_notify_setcmd(vdev, notify_addr, notify_pa, intr);
614}
615
616void vnic_dev_notify_unsetcmd(struct vnic_dev *vdev)
601{ 617{
602 u64 a0, a1; 618 u64 a0, a1;
603 int wait = 1000; 619 int wait = 1000;
@@ -607,9 +623,23 @@ void vnic_dev_notify_unset(struct vnic_dev *vdev)
607 a1 += sizeof(struct vnic_devcmd_notify); 623 a1 += sizeof(struct vnic_devcmd_notify);
608 624
609 vnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait); 625 vnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait);
626 vdev->notify = NULL;
627 vdev->notify_pa = 0;
610 vdev->notify_sz = 0; 628 vdev->notify_sz = 0;
611} 629}
612 630
631void vnic_dev_notify_unset(struct vnic_dev *vdev)
632{
633 if (vdev->notify) {
634 pci_free_consistent(vdev->pdev,
635 sizeof(struct vnic_devcmd_notify),
636 vdev->notify,
637 vdev->notify_pa);
638 }
639
640 vnic_dev_notify_unsetcmd(vdev);
641}
642
613static int vnic_dev_notify_ready(struct vnic_dev *vdev) 643static int vnic_dev_notify_ready(struct vnic_dev *vdev)
614{ 644{
615 u32 *words; 645 u32 *words;
diff --git a/drivers/net/enic/vnic_dev.h b/drivers/net/enic/vnic_dev.h
index fc5e3eb35a5e..f5be640b0b5c 100644
--- a/drivers/net/enic/vnic_dev.h
+++ b/drivers/net/enic/vnic_dev.h
@@ -107,7 +107,10 @@ void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr);
107void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr); 107void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr);
108int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr); 108int vnic_dev_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
109int vnic_dev_raise_intr(struct vnic_dev *vdev, u16 intr); 109int vnic_dev_raise_intr(struct vnic_dev *vdev, u16 intr);
110int vnic_dev_notify_setcmd(struct vnic_dev *vdev,
111 void *notify_addr, dma_addr_t notify_pa, u16 intr);
110int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr); 112int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
113void vnic_dev_notify_unsetcmd(struct vnic_dev *vdev);
111void vnic_dev_notify_unset(struct vnic_dev *vdev); 114void vnic_dev_notify_unset(struct vnic_dev *vdev);
112int vnic_dev_link_status(struct vnic_dev *vdev); 115int vnic_dev_link_status(struct vnic_dev *vdev);
113u32 vnic_dev_port_speed(struct vnic_dev *vdev); 116u32 vnic_dev_port_speed(struct vnic_dev *vdev);
diff --git a/drivers/net/enic/vnic_rq.c b/drivers/net/enic/vnic_rq.c
index 75583978a5e5..7bcd90373487 100644
--- a/drivers/net/enic/vnic_rq.c
+++ b/drivers/net/enic/vnic_rq.c
@@ -167,10 +167,10 @@ int vnic_rq_disable(struct vnic_rq *rq)
167 iowrite32(0, &rq->ctrl->enable); 167 iowrite32(0, &rq->ctrl->enable);
168 168
169 /* Wait for HW to ACK disable request */ 169 /* Wait for HW to ACK disable request */
170 for (wait = 0; wait < 100; wait++) { 170 for (wait = 0; wait < 1000; wait++) {
171 if (!(ioread32(&rq->ctrl->running))) 171 if (!(ioread32(&rq->ctrl->running)))
172 return 0; 172 return 0;
173 udelay(1); 173 udelay(10);
174 } 174 }
175 175
176 printk(KERN_ERR "Failed to disable RQ[%d]\n", rq->index); 176 printk(KERN_ERR "Failed to disable RQ[%d]\n", rq->index);
diff --git a/drivers/net/enic/vnic_wq.c b/drivers/net/enic/vnic_wq.c
index d2e00e51b7b5..44fc3234d585 100644
--- a/drivers/net/enic/vnic_wq.c
+++ b/drivers/net/enic/vnic_wq.c
@@ -160,10 +160,10 @@ int vnic_wq_disable(struct vnic_wq *wq)
160 iowrite32(0, &wq->ctrl->enable); 160 iowrite32(0, &wq->ctrl->enable);
161 161
162 /* Wait for HW to ACK disable request */ 162 /* Wait for HW to ACK disable request */
163 for (wait = 0; wait < 100; wait++) { 163 for (wait = 0; wait < 1000; wait++) {
164 if (!(ioread32(&wq->ctrl->running))) 164 if (!(ioread32(&wq->ctrl->running)))
165 return 0; 165 return 0;
166 udelay(1); 166 udelay(10);
167 } 167 }
168 168
169 printk(KERN_ERR "Failed to disable WQ[%d]\n", wq->index); 169 printk(KERN_ERR "Failed to disable WQ[%d]\n", wq->index);
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c
index 39c271b6be44..f6584a1ad3bc 100644
--- a/drivers/net/epic100.c
+++ b/drivers/net/epic100.c
@@ -1400,12 +1400,12 @@ static void set_rx_mode(struct net_device *dev)
1400 outl(0x0004, ioaddr + RxCtrl); 1400 outl(0x0004, ioaddr + RxCtrl);
1401 return; 1401 return;
1402 } else { /* Never executed, for now. */ 1402 } else { /* Never executed, for now. */
1403 struct dev_mc_list *mclist; 1403 struct netdev_hw_addr *ha;
1404 1404
1405 memset(mc_filter, 0, sizeof(mc_filter)); 1405 memset(mc_filter, 0, sizeof(mc_filter));
1406 netdev_for_each_mc_addr(mclist, dev) { 1406 netdev_for_each_mc_addr(ha, dev) {
1407 unsigned int bit_nr = 1407 unsigned int bit_nr =
1408 ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x3f; 1408 ether_crc_le(ETH_ALEN, ha->addr) & 0x3f;
1409 mc_filter[bit_nr >> 3] |= (1 << bit_nr); 1409 mc_filter[bit_nr >> 3] |= (1 << bit_nr);
1410 } 1410 }
1411 } 1411 }
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index 209742304e20..f6be5aeaf94c 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -755,7 +755,7 @@ static void ethoc_set_multicast_list(struct net_device *dev)
755{ 755{
756 struct ethoc *priv = netdev_priv(dev); 756 struct ethoc *priv = netdev_priv(dev);
757 u32 mode = ethoc_read(priv, MODER); 757 u32 mode = ethoc_read(priv, MODER);
758 struct dev_mc_list *mc; 758 struct netdev_hw_addr *ha;
759 u32 hash[2] = { 0, 0 }; 759 u32 hash[2] = { 0, 0 };
760 760
761 /* set loopback mode if requested */ 761 /* set loopback mode if requested */
@@ -783,8 +783,8 @@ static void ethoc_set_multicast_list(struct net_device *dev)
783 hash[0] = 0xffffffff; 783 hash[0] = 0xffffffff;
784 hash[1] = 0xffffffff; 784 hash[1] = 0xffffffff;
785 } else { 785 } else {
786 netdev_for_each_mc_addr(mc, dev) { 786 netdev_for_each_mc_addr(ha, dev) {
787 u32 crc = ether_crc(ETH_ALEN, mc->dmi_addr); 787 u32 crc = ether_crc(ETH_ALEN, ha->addr);
788 int bit = (crc >> 26) & 0x3f; 788 int bit = (crc >> 26) & 0x3f;
789 hash[bit >> 5] |= 1 << (bit & 0x1f); 789 hash[bit >> 5] |= 1 << (bit & 0x1f);
790 } 790 }
diff --git a/drivers/net/ewrk3.c b/drivers/net/ewrk3.c
index 91e59f3a9d6d..11ba70f49971 100644
--- a/drivers/net/ewrk3.c
+++ b/drivers/net/ewrk3.c
@@ -1169,7 +1169,7 @@ static void set_multicast_list(struct net_device *dev)
1169static void SetMulticastFilter(struct net_device *dev) 1169static void SetMulticastFilter(struct net_device *dev)
1170{ 1170{
1171 struct ewrk3_private *lp = netdev_priv(dev); 1171 struct ewrk3_private *lp = netdev_priv(dev);
1172 struct dev_mc_list *dmi; 1172 struct netdev_hw_addr *ha;
1173 u_long iobase = dev->base_addr; 1173 u_long iobase = dev->base_addr;
1174 int i; 1174 int i;
1175 char *addrs, bit, byte; 1175 char *addrs, bit, byte;
@@ -1213,8 +1213,8 @@ static void SetMulticastFilter(struct net_device *dev)
1213 } 1213 }
1214 1214
1215 /* Update table */ 1215 /* Update table */
1216 netdev_for_each_mc_addr(dmi, dev) { 1216 netdev_for_each_mc_addr(ha, dev) {
1217 addrs = dmi->dmi_addr; 1217 addrs = ha->addr;
1218 if ((*addrs & 0x01) == 1) { /* multicast address? */ 1218 if ((*addrs & 0x01) == 1) { /* multicast address? */
1219 crc = ether_crc_le(ETH_ALEN, addrs); 1219 crc = ether_crc_le(ETH_ALEN, addrs);
1220 hashcode = crc & ((1 << 9) - 1); /* hashcode is 9 LSb of CRC */ 1220 hashcode = crc & ((1 << 9) - 1); /* hashcode is 9 LSb of CRC */
@@ -1776,8 +1776,7 @@ static int ewrk3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1776 break; 1776 break;
1777 case EWRK3_SET_MCA: /* Set a multicast address */ 1777 case EWRK3_SET_MCA: /* Set a multicast address */
1778 if (capable(CAP_NET_ADMIN)) { 1778 if (capable(CAP_NET_ADMIN)) {
1779 if (ioc->len > 1024) 1779 if (ioc->len > HASH_TABLE_LEN) {
1780 {
1781 status = -EINVAL; 1780 status = -EINVAL;
1782 break; 1781 break;
1783 } 1782 }
diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index 9d5ad08a119f..e8a2705237bf 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -1792,12 +1792,12 @@ static void __set_rx_mode(struct net_device *dev)
1792 memset(mc_filter, 0xff, sizeof(mc_filter)); 1792 memset(mc_filter, 0xff, sizeof(mc_filter));
1793 rx_mode = CR_W_AB | CR_W_AM; 1793 rx_mode = CR_W_AB | CR_W_AM;
1794 } else { 1794 } else {
1795 struct dev_mc_list *mclist; 1795 struct netdev_hw_addr *ha;
1796 1796
1797 memset(mc_filter, 0, sizeof(mc_filter)); 1797 memset(mc_filter, 0, sizeof(mc_filter));
1798 netdev_for_each_mc_addr(mclist, dev) { 1798 netdev_for_each_mc_addr(ha, dev) {
1799 unsigned int bit; 1799 unsigned int bit;
1800 bit = (ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26) ^ 0x3F; 1800 bit = (ether_crc(ETH_ALEN, ha->addr) >> 26) ^ 0x3F;
1801 mc_filter[bit >> 5] |= (1 << bit); 1801 mc_filter[bit >> 5] |= (1 << bit);
1802 } 1802 }
1803 rx_mode = CR_W_AB | CR_W_AM; 1803 rx_mode = CR_W_AB | CR_W_AM;
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 9f98c1c4a344..2b1651aee13f 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -40,6 +40,7 @@
40#include <linux/irq.h> 40#include <linux/irq.h>
41#include <linux/clk.h> 41#include <linux/clk.h>
42#include <linux/platform_device.h> 42#include <linux/platform_device.h>
43#include <linux/phy.h>
43 44
44#include <asm/cacheflush.h> 45#include <asm/cacheflush.h>
45 46
@@ -61,7 +62,6 @@
61 * Define the fixed address of the FEC hardware. 62 * Define the fixed address of the FEC hardware.
62 */ 63 */
63#if defined(CONFIG_M5272) 64#if defined(CONFIG_M5272)
64#define HAVE_mii_link_interrupt
65 65
66static unsigned char fec_mac_default[] = { 66static unsigned char fec_mac_default[] = {
67 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 67 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -86,23 +86,6 @@ static unsigned char fec_mac_default[] = {
86#endif 86#endif
87#endif /* CONFIG_M5272 */ 87#endif /* CONFIG_M5272 */
88 88
89/* Forward declarations of some structures to support different PHYs */
90
91typedef struct {
92 uint mii_data;
93 void (*funct)(uint mii_reg, struct net_device *dev);
94} phy_cmd_t;
95
96typedef struct {
97 uint id;
98 char *name;
99
100 const phy_cmd_t *config;
101 const phy_cmd_t *startup;
102 const phy_cmd_t *ack_int;
103 const phy_cmd_t *shutdown;
104} phy_info_t;
105
106/* The number of Tx and Rx buffers. These are allocated from the page 89/* The number of Tx and Rx buffers. These are allocated from the page
107 * pool. The code may assume these are power of two, so it it best 90 * pool. The code may assume these are power of two, so it it best
108 * to keep them that size. 91 * to keep them that size.
@@ -189,29 +172,21 @@ struct fec_enet_private {
189 uint tx_full; 172 uint tx_full;
190 /* hold while accessing the HW like ringbuffer for tx/rx but not MAC */ 173 /* hold while accessing the HW like ringbuffer for tx/rx but not MAC */
191 spinlock_t hw_lock; 174 spinlock_t hw_lock;
192 /* hold while accessing the mii_list_t() elements */
193 spinlock_t mii_lock;
194
195 uint phy_id;
196 uint phy_id_done;
197 uint phy_status;
198 uint phy_speed;
199 phy_info_t const *phy;
200 struct work_struct phy_task;
201 175
202 uint sequence_done; 176 struct platform_device *pdev;
203 uint mii_phy_task_queued;
204 177
205 uint phy_addr; 178 int opened;
206 179
180 /* Phylib and MDIO interface */
181 struct mii_bus *mii_bus;
182 struct phy_device *phy_dev;
183 int mii_timeout;
184 uint phy_speed;
207 int index; 185 int index;
208 int opened;
209 int link; 186 int link;
210 int old_link;
211 int full_duplex; 187 int full_duplex;
212}; 188};
213 189
214static void fec_enet_mii(struct net_device *dev);
215static irqreturn_t fec_enet_interrupt(int irq, void * dev_id); 190static irqreturn_t fec_enet_interrupt(int irq, void * dev_id);
216static void fec_enet_tx(struct net_device *dev); 191static void fec_enet_tx(struct net_device *dev);
217static void fec_enet_rx(struct net_device *dev); 192static void fec_enet_rx(struct net_device *dev);
@@ -219,67 +194,20 @@ static int fec_enet_close(struct net_device *dev);
219static void fec_restart(struct net_device *dev, int duplex); 194static void fec_restart(struct net_device *dev, int duplex);
220static void fec_stop(struct net_device *dev); 195static void fec_stop(struct net_device *dev);
221 196
197/* FEC MII MMFR bits definition */
198#define FEC_MMFR_ST (1 << 30)
199#define FEC_MMFR_OP_READ (2 << 28)
200#define FEC_MMFR_OP_WRITE (1 << 28)
201#define FEC_MMFR_PA(v) ((v & 0x1f) << 23)
202#define FEC_MMFR_RA(v) ((v & 0x1f) << 18)
203#define FEC_MMFR_TA (2 << 16)
204#define FEC_MMFR_DATA(v) (v & 0xffff)
222 205
223/* MII processing. We keep this as simple as possible. Requests are 206#define FEC_MII_TIMEOUT 10000
224 * placed on the list (if there is room). When the request is finished
225 * by the MII, an optional function may be called.
226 */
227typedef struct mii_list {
228 uint mii_regval;
229 void (*mii_func)(uint val, struct net_device *dev);
230 struct mii_list *mii_next;
231} mii_list_t;
232
233#define NMII 20
234static mii_list_t mii_cmds[NMII];
235static mii_list_t *mii_free;
236static mii_list_t *mii_head;
237static mii_list_t *mii_tail;
238
239static int mii_queue(struct net_device *dev, int request,
240 void (*func)(uint, struct net_device *));
241
242/* Make MII read/write commands for the FEC */
243#define mk_mii_read(REG) (0x60020000 | ((REG & 0x1f) << 18))
244#define mk_mii_write(REG, VAL) (0x50020000 | ((REG & 0x1f) << 18) | \
245 (VAL & 0xffff))
246#define mk_mii_end 0
247 207
248/* Transmitter timeout */ 208/* Transmitter timeout */
249#define TX_TIMEOUT (2 * HZ) 209#define TX_TIMEOUT (2 * HZ)
250 210
251/* Register definitions for the PHY */
252
253#define MII_REG_CR 0 /* Control Register */
254#define MII_REG_SR 1 /* Status Register */
255#define MII_REG_PHYIR1 2 /* PHY Identification Register 1 */
256#define MII_REG_PHYIR2 3 /* PHY Identification Register 2 */
257#define MII_REG_ANAR 4 /* A-N Advertisement Register */
258#define MII_REG_ANLPAR 5 /* A-N Link Partner Ability Register */
259#define MII_REG_ANER 6 /* A-N Expansion Register */
260#define MII_REG_ANNPTR 7 /* A-N Next Page Transmit Register */
261#define MII_REG_ANLPRNPR 8 /* A-N Link Partner Received Next Page Reg. */
262
263/* values for phy_status */
264
265#define PHY_CONF_ANE 0x0001 /* 1 auto-negotiation enabled */
266#define PHY_CONF_LOOP 0x0002 /* 1 loopback mode enabled */
267#define PHY_CONF_SPMASK 0x00f0 /* mask for speed */
268#define PHY_CONF_10HDX 0x0010 /* 10 Mbit half duplex supported */
269#define PHY_CONF_10FDX 0x0020 /* 10 Mbit full duplex supported */
270#define PHY_CONF_100HDX 0x0040 /* 100 Mbit half duplex supported */
271#define PHY_CONF_100FDX 0x0080 /* 100 Mbit full duplex supported */
272
273#define PHY_STAT_LINK 0x0100 /* 1 up - 0 down */
274#define PHY_STAT_FAULT 0x0200 /* 1 remote fault */
275#define PHY_STAT_ANC 0x0400 /* 1 auto-negotiation complete */
276#define PHY_STAT_SPMASK 0xf000 /* mask for speed */
277#define PHY_STAT_10HDX 0x1000 /* 10 Mbit half duplex selected */
278#define PHY_STAT_10FDX 0x2000 /* 10 Mbit full duplex selected */
279#define PHY_STAT_100HDX 0x4000 /* 100 Mbit half duplex selected */
280#define PHY_STAT_100FDX 0x8000 /* 100 Mbit full duplex selected */
281
282
283static int 211static int
284fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) 212fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
285{ 213{
@@ -406,12 +334,6 @@ fec_enet_interrupt(int irq, void * dev_id)
406 ret = IRQ_HANDLED; 334 ret = IRQ_HANDLED;
407 fec_enet_tx(dev); 335 fec_enet_tx(dev);
408 } 336 }
409
410 if (int_events & FEC_ENET_MII) {
411 ret = IRQ_HANDLED;
412 fec_enet_mii(dev);
413 }
414
415 } while (int_events); 337 } while (int_events);
416 338
417 return ret; 339 return ret;
@@ -607,827 +529,311 @@ rx_processing_done:
607 spin_unlock(&fep->hw_lock); 529 spin_unlock(&fep->hw_lock);
608} 530}
609 531
610/* called from interrupt context */ 532/* ------------------------------------------------------------------------- */
611static void 533#ifdef CONFIG_M5272
612fec_enet_mii(struct net_device *dev) 534static void __inline__ fec_get_mac(struct net_device *dev)
613{
614 struct fec_enet_private *fep;
615 mii_list_t *mip;
616
617 fep = netdev_priv(dev);
618 spin_lock(&fep->mii_lock);
619
620 if ((mip = mii_head) == NULL) {
621 printk("MII and no head!\n");
622 goto unlock;
623 }
624
625 if (mip->mii_func != NULL)
626 (*(mip->mii_func))(readl(fep->hwp + FEC_MII_DATA), dev);
627
628 mii_head = mip->mii_next;
629 mip->mii_next = mii_free;
630 mii_free = mip;
631
632 if ((mip = mii_head) != NULL)
633 writel(mip->mii_regval, fep->hwp + FEC_MII_DATA);
634
635unlock:
636 spin_unlock(&fep->mii_lock);
637}
638
639static int
640mii_queue_unlocked(struct net_device *dev, int regval,
641 void (*func)(uint, struct net_device *))
642{ 535{
643 struct fec_enet_private *fep; 536 struct fec_enet_private *fep = netdev_priv(dev);
644 mii_list_t *mip; 537 unsigned char *iap, tmpaddr[ETH_ALEN];
645 int retval;
646
647 /* Add PHY address to register command */
648 fep = netdev_priv(dev);
649 538
650 regval |= fep->phy_addr << 23; 539 if (FEC_FLASHMAC) {
651 retval = 0; 540 /*
652 541 * Get MAC address from FLASH.
653 if ((mip = mii_free) != NULL) { 542 * If it is all 1's or 0's, use the default.
654 mii_free = mip->mii_next; 543 */
655 mip->mii_regval = regval; 544 iap = (unsigned char *)FEC_FLASHMAC;
656 mip->mii_func = func; 545 if ((iap[0] == 0) && (iap[1] == 0) && (iap[2] == 0) &&
657 mip->mii_next = NULL; 546 (iap[3] == 0) && (iap[4] == 0) && (iap[5] == 0))
658 if (mii_head) { 547 iap = fec_mac_default;
659 mii_tail->mii_next = mip; 548 if ((iap[0] == 0xff) && (iap[1] == 0xff) && (iap[2] == 0xff) &&
660 mii_tail = mip; 549 (iap[3] == 0xff) && (iap[4] == 0xff) && (iap[5] == 0xff))
661 } else { 550 iap = fec_mac_default;
662 mii_head = mii_tail = mip;
663 writel(regval, fep->hwp + FEC_MII_DATA);
664 }
665 } else { 551 } else {
666 retval = 1; 552 *((unsigned long *) &tmpaddr[0]) = readl(fep->hwp + FEC_ADDR_LOW);
553 *((unsigned short *) &tmpaddr[4]) = (readl(fep->hwp + FEC_ADDR_HIGH) >> 16);
554 iap = &tmpaddr[0];
667 } 555 }
668 556
669 return retval; 557 memcpy(dev->dev_addr, iap, ETH_ALEN);
670}
671
672static int
673mii_queue(struct net_device *dev, int regval,
674 void (*func)(uint, struct net_device *))
675{
676 struct fec_enet_private *fep;
677 unsigned long flags;
678 int retval;
679 fep = netdev_priv(dev);
680 spin_lock_irqsave(&fep->mii_lock, flags);
681 retval = mii_queue_unlocked(dev, regval, func);
682 spin_unlock_irqrestore(&fep->mii_lock, flags);
683 return retval;
684}
685
686static void mii_do_cmd(struct net_device *dev, const phy_cmd_t *c)
687{
688 if(!c)
689 return;
690 558
691 for (; c->mii_data != mk_mii_end; c++) 559 /* Adjust MAC if using default MAC address */
692 mii_queue(dev, c->mii_data, c->funct); 560 if (iap == fec_mac_default)
561 dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->index;
693} 562}
563#endif
694 564
695static void mii_parse_sr(uint mii_reg, struct net_device *dev) 565/* ------------------------------------------------------------------------- */
696{
697 struct fec_enet_private *fep = netdev_priv(dev);
698 volatile uint *s = &(fep->phy_status);
699 uint status;
700
701 status = *s & ~(PHY_STAT_LINK | PHY_STAT_FAULT | PHY_STAT_ANC);
702
703 if (mii_reg & 0x0004)
704 status |= PHY_STAT_LINK;
705 if (mii_reg & 0x0010)
706 status |= PHY_STAT_FAULT;
707 if (mii_reg & 0x0020)
708 status |= PHY_STAT_ANC;
709 *s = status;
710}
711 566
712static void mii_parse_cr(uint mii_reg, struct net_device *dev) 567/*
568 * Phy section
569 */
570static void fec_enet_adjust_link(struct net_device *dev)
713{ 571{
714 struct fec_enet_private *fep = netdev_priv(dev); 572 struct fec_enet_private *fep = netdev_priv(dev);
715 volatile uint *s = &(fep->phy_status); 573 struct phy_device *phy_dev = fep->phy_dev;
716 uint status; 574 unsigned long flags;
717
718 status = *s & ~(PHY_CONF_ANE | PHY_CONF_LOOP);
719
720 if (mii_reg & 0x1000)
721 status |= PHY_CONF_ANE;
722 if (mii_reg & 0x4000)
723 status |= PHY_CONF_LOOP;
724 *s = status;
725}
726 575
727static void mii_parse_anar(uint mii_reg, struct net_device *dev) 576 int status_change = 0;
728{
729 struct fec_enet_private *fep = netdev_priv(dev);
730 volatile uint *s = &(fep->phy_status);
731 uint status;
732
733 status = *s & ~(PHY_CONF_SPMASK);
734
735 if (mii_reg & 0x0020)
736 status |= PHY_CONF_10HDX;
737 if (mii_reg & 0x0040)
738 status |= PHY_CONF_10FDX;
739 if (mii_reg & 0x0080)
740 status |= PHY_CONF_100HDX;
741 if (mii_reg & 0x00100)
742 status |= PHY_CONF_100FDX;
743 *s = status;
744}
745 577
746/* ------------------------------------------------------------------------- */ 578 spin_lock_irqsave(&fep->hw_lock, flags);
747/* The Level one LXT970 is used by many boards */
748 579
749#define MII_LXT970_MIRROR 16 /* Mirror register */ 580 /* Prevent a state halted on mii error */
750#define MII_LXT970_IER 17 /* Interrupt Enable Register */ 581 if (fep->mii_timeout && phy_dev->state == PHY_HALTED) {
751#define MII_LXT970_ISR 18 /* Interrupt Status Register */ 582 phy_dev->state = PHY_RESUMING;
752#define MII_LXT970_CONFIG 19 /* Configuration Register */ 583 goto spin_unlock;
753#define MII_LXT970_CSR 20 /* Chip Status Register */ 584 }
754 585
755static void mii_parse_lxt970_csr(uint mii_reg, struct net_device *dev) 586 /* Duplex link change */
756{ 587 if (phy_dev->link) {
757 struct fec_enet_private *fep = netdev_priv(dev); 588 if (fep->full_duplex != phy_dev->duplex) {
758 volatile uint *s = &(fep->phy_status); 589 fec_restart(dev, phy_dev->duplex);
759 uint status; 590 status_change = 1;
591 }
592 }
760 593
761 status = *s & ~(PHY_STAT_SPMASK); 594 /* Link on or off change */
762 if (mii_reg & 0x0800) { 595 if (phy_dev->link != fep->link) {
763 if (mii_reg & 0x1000) 596 fep->link = phy_dev->link;
764 status |= PHY_STAT_100FDX; 597 if (phy_dev->link)
598 fec_restart(dev, phy_dev->duplex);
765 else 599 else
766 status |= PHY_STAT_100HDX; 600 fec_stop(dev);
767 } else { 601 status_change = 1;
768 if (mii_reg & 0x1000)
769 status |= PHY_STAT_10FDX;
770 else
771 status |= PHY_STAT_10HDX;
772 } 602 }
773 *s = status;
774}
775
776static phy_cmd_t const phy_cmd_lxt970_config[] = {
777 { mk_mii_read(MII_REG_CR), mii_parse_cr },
778 { mk_mii_read(MII_REG_ANAR), mii_parse_anar },
779 { mk_mii_end, }
780 };
781static phy_cmd_t const phy_cmd_lxt970_startup[] = { /* enable interrupts */
782 { mk_mii_write(MII_LXT970_IER, 0x0002), NULL },
783 { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */
784 { mk_mii_end, }
785 };
786static phy_cmd_t const phy_cmd_lxt970_ack_int[] = {
787 /* read SR and ISR to acknowledge */
788 { mk_mii_read(MII_REG_SR), mii_parse_sr },
789 { mk_mii_read(MII_LXT970_ISR), NULL },
790
791 /* find out the current status */
792 { mk_mii_read(MII_LXT970_CSR), mii_parse_lxt970_csr },
793 { mk_mii_end, }
794 };
795static phy_cmd_t const phy_cmd_lxt970_shutdown[] = { /* disable interrupts */
796 { mk_mii_write(MII_LXT970_IER, 0x0000), NULL },
797 { mk_mii_end, }
798 };
799static phy_info_t const phy_info_lxt970 = {
800 .id = 0x07810000,
801 .name = "LXT970",
802 .config = phy_cmd_lxt970_config,
803 .startup = phy_cmd_lxt970_startup,
804 .ack_int = phy_cmd_lxt970_ack_int,
805 .shutdown = phy_cmd_lxt970_shutdown
806};
807 603
808/* ------------------------------------------------------------------------- */ 604spin_unlock:
809/* The Level one LXT971 is used on some of my custom boards */ 605 spin_unlock_irqrestore(&fep->hw_lock, flags);
810
811/* register definitions for the 971 */
812 606
813#define MII_LXT971_PCR 16 /* Port Control Register */ 607 if (status_change)
814#define MII_LXT971_SR2 17 /* Status Register 2 */ 608 phy_print_status(phy_dev);
815#define MII_LXT971_IER 18 /* Interrupt Enable Register */ 609}
816#define MII_LXT971_ISR 19 /* Interrupt Status Register */
817#define MII_LXT971_LCR 20 /* LED Control Register */
818#define MII_LXT971_TCR 30 /* Transmit Control Register */
819 610
820/* 611/*
821 * I had some nice ideas of running the MDIO faster... 612 * NOTE: a MII transaction is during around 25 us, so polling it...
822 * The 971 should support 8MHz and I tried it, but things acted really
823 * weird, so 2.5 MHz ought to be enough for anyone...
824 */ 613 */
825 614static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
826static void mii_parse_lxt971_sr2(uint mii_reg, struct net_device *dev)
827{ 615{
828 struct fec_enet_private *fep = netdev_priv(dev); 616 struct fec_enet_private *fep = bus->priv;
829 volatile uint *s = &(fep->phy_status); 617 int timeout = FEC_MII_TIMEOUT;
830 uint status;
831 618
832 status = *s & ~(PHY_STAT_SPMASK | PHY_STAT_LINK | PHY_STAT_ANC); 619 fep->mii_timeout = 0;
833 620
834 if (mii_reg & 0x0400) { 621 /* clear MII end of transfer bit*/
835 fep->link = 1; 622 writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT);
836 status |= PHY_STAT_LINK; 623
837 } else { 624 /* start a read op */
838 fep->link = 0; 625 writel(FEC_MMFR_ST | FEC_MMFR_OP_READ |
839 } 626 FEC_MMFR_PA(mii_id) | FEC_MMFR_RA(regnum) |
840 if (mii_reg & 0x0080) 627 FEC_MMFR_TA, fep->hwp + FEC_MII_DATA);
841 status |= PHY_STAT_ANC; 628
842 if (mii_reg & 0x4000) { 629 /* wait for end of transfer */
843 if (mii_reg & 0x0200) 630 while (!(readl(fep->hwp + FEC_IEVENT) & FEC_ENET_MII)) {
844 status |= PHY_STAT_100FDX; 631 cpu_relax();
845 else 632 if (timeout-- < 0) {
846 status |= PHY_STAT_100HDX; 633 fep->mii_timeout = 1;
847 } else { 634 printk(KERN_ERR "FEC: MDIO read timeout\n");
848 if (mii_reg & 0x0200) 635 return -ETIMEDOUT;
849 status |= PHY_STAT_10FDX; 636 }
850 else
851 status |= PHY_STAT_10HDX;
852 } 637 }
853 if (mii_reg & 0x0008)
854 status |= PHY_STAT_FAULT;
855 638
856 *s = status; 639 /* return value */
640 return FEC_MMFR_DATA(readl(fep->hwp + FEC_MII_DATA));
857} 641}
858 642
859static phy_cmd_t const phy_cmd_lxt971_config[] = { 643static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
860 /* limit to 10MBit because my prototype board 644 u16 value)
861 * doesn't work with 100. */
862 { mk_mii_read(MII_REG_CR), mii_parse_cr },
863 { mk_mii_read(MII_REG_ANAR), mii_parse_anar },
864 { mk_mii_read(MII_LXT971_SR2), mii_parse_lxt971_sr2 },
865 { mk_mii_end, }
866 };
867static phy_cmd_t const phy_cmd_lxt971_startup[] = { /* enable interrupts */
868 { mk_mii_write(MII_LXT971_IER, 0x00f2), NULL },
869 { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */
870 { mk_mii_write(MII_LXT971_LCR, 0xd422), NULL }, /* LED config */
871 /* Somehow does the 971 tell me that the link is down
872 * the first read after power-up.
873 * read here to get a valid value in ack_int */
874 { mk_mii_read(MII_REG_SR), mii_parse_sr },
875 { mk_mii_end, }
876 };
877static phy_cmd_t const phy_cmd_lxt971_ack_int[] = {
878 /* acknowledge the int before reading status ! */
879 { mk_mii_read(MII_LXT971_ISR), NULL },
880 /* find out the current status */
881 { mk_mii_read(MII_REG_SR), mii_parse_sr },
882 { mk_mii_read(MII_LXT971_SR2), mii_parse_lxt971_sr2 },
883 { mk_mii_end, }
884 };
885static phy_cmd_t const phy_cmd_lxt971_shutdown[] = { /* disable interrupts */
886 { mk_mii_write(MII_LXT971_IER, 0x0000), NULL },
887 { mk_mii_end, }
888 };
889static phy_info_t const phy_info_lxt971 = {
890 .id = 0x0001378e,
891 .name = "LXT971",
892 .config = phy_cmd_lxt971_config,
893 .startup = phy_cmd_lxt971_startup,
894 .ack_int = phy_cmd_lxt971_ack_int,
895 .shutdown = phy_cmd_lxt971_shutdown
896};
897
898/* ------------------------------------------------------------------------- */
899/* The Quality Semiconductor QS6612 is used on the RPX CLLF */
900
901/* register definitions */
902
903#define MII_QS6612_MCR 17 /* Mode Control Register */
904#define MII_QS6612_FTR 27 /* Factory Test Register */
905#define MII_QS6612_MCO 28 /* Misc. Control Register */
906#define MII_QS6612_ISR 29 /* Interrupt Source Register */
907#define MII_QS6612_IMR 30 /* Interrupt Mask Register */
908#define MII_QS6612_PCR 31 /* 100BaseTx PHY Control Reg. */
909
910static void mii_parse_qs6612_pcr(uint mii_reg, struct net_device *dev)
911{ 645{
912 struct fec_enet_private *fep = netdev_priv(dev); 646 struct fec_enet_private *fep = bus->priv;
913 volatile uint *s = &(fep->phy_status); 647 int timeout = FEC_MII_TIMEOUT;
914 uint status;
915 648
916 status = *s & ~(PHY_STAT_SPMASK); 649 fep->mii_timeout = 0;
917 650
918 switch((mii_reg >> 2) & 7) { 651 /* clear MII end of transfer bit*/
919 case 1: status |= PHY_STAT_10HDX; break; 652 writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT);
920 case 2: status |= PHY_STAT_100HDX; break;
921 case 5: status |= PHY_STAT_10FDX; break;
922 case 6: status |= PHY_STAT_100FDX; break;
923}
924
925 *s = status;
926}
927
928static phy_cmd_t const phy_cmd_qs6612_config[] = {
929 /* The PHY powers up isolated on the RPX,
930 * so send a command to allow operation.
931 */
932 { mk_mii_write(MII_QS6612_PCR, 0x0dc0), NULL },
933
934 /* parse cr and anar to get some info */
935 { mk_mii_read(MII_REG_CR), mii_parse_cr },
936 { mk_mii_read(MII_REG_ANAR), mii_parse_anar },
937 { mk_mii_end, }
938 };
939static phy_cmd_t const phy_cmd_qs6612_startup[] = { /* enable interrupts */
940 { mk_mii_write(MII_QS6612_IMR, 0x003a), NULL },
941 { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */
942 { mk_mii_end, }
943 };
944static phy_cmd_t const phy_cmd_qs6612_ack_int[] = {
945 /* we need to read ISR, SR and ANER to acknowledge */
946 { mk_mii_read(MII_QS6612_ISR), NULL },
947 { mk_mii_read(MII_REG_SR), mii_parse_sr },
948 { mk_mii_read(MII_REG_ANER), NULL },
949
950 /* read pcr to get info */
951 { mk_mii_read(MII_QS6612_PCR), mii_parse_qs6612_pcr },
952 { mk_mii_end, }
953 };
954static phy_cmd_t const phy_cmd_qs6612_shutdown[] = { /* disable interrupts */
955 { mk_mii_write(MII_QS6612_IMR, 0x0000), NULL },
956 { mk_mii_end, }
957 };
958static phy_info_t const phy_info_qs6612 = {
959 .id = 0x00181440,
960 .name = "QS6612",
961 .config = phy_cmd_qs6612_config,
962 .startup = phy_cmd_qs6612_startup,
963 .ack_int = phy_cmd_qs6612_ack_int,
964 .shutdown = phy_cmd_qs6612_shutdown
965};
966
967/* ------------------------------------------------------------------------- */
968/* AMD AM79C874 phy */
969 653
970/* register definitions for the 874 */ 654 /* start a read op */
655 writel(FEC_MMFR_ST | FEC_MMFR_OP_READ |
656 FEC_MMFR_PA(mii_id) | FEC_MMFR_RA(regnum) |
657 FEC_MMFR_TA | FEC_MMFR_DATA(value),
658 fep->hwp + FEC_MII_DATA);
659
660 /* wait for end of transfer */
661 while (!(readl(fep->hwp + FEC_IEVENT) & FEC_ENET_MII)) {
662 cpu_relax();
663 if (timeout-- < 0) {
664 fep->mii_timeout = 1;
665 printk(KERN_ERR "FEC: MDIO write timeout\n");
666 return -ETIMEDOUT;
667 }
668 }
971 669
972#define MII_AM79C874_MFR 16 /* Miscellaneous Feature Register */ 670 return 0;
973#define MII_AM79C874_ICSR 17 /* Interrupt/Status Register */ 671}
974#define MII_AM79C874_DR 18 /* Diagnostic Register */
975#define MII_AM79C874_PMLR 19 /* Power and Loopback Register */
976#define MII_AM79C874_MCR 21 /* ModeControl Register */
977#define MII_AM79C874_DC 23 /* Disconnect Counter */
978#define MII_AM79C874_REC 24 /* Recieve Error Counter */
979 672
980static void mii_parse_am79c874_dr(uint mii_reg, struct net_device *dev) 673static int fec_enet_mdio_reset(struct mii_bus *bus)
981{ 674{
982 struct fec_enet_private *fep = netdev_priv(dev); 675 return 0;
983 volatile uint *s = &(fep->phy_status);
984 uint status;
985
986 status = *s & ~(PHY_STAT_SPMASK | PHY_STAT_ANC);
987
988 if (mii_reg & 0x0080)
989 status |= PHY_STAT_ANC;
990 if (mii_reg & 0x0400)
991 status |= ((mii_reg & 0x0800) ? PHY_STAT_100FDX : PHY_STAT_100HDX);
992 else
993 status |= ((mii_reg & 0x0800) ? PHY_STAT_10FDX : PHY_STAT_10HDX);
994
995 *s = status;
996} 676}
997 677
998static phy_cmd_t const phy_cmd_am79c874_config[] = { 678static int fec_enet_mii_probe(struct net_device *dev)
999 { mk_mii_read(MII_REG_CR), mii_parse_cr },
1000 { mk_mii_read(MII_REG_ANAR), mii_parse_anar },
1001 { mk_mii_read(MII_AM79C874_DR), mii_parse_am79c874_dr },
1002 { mk_mii_end, }
1003 };
1004static phy_cmd_t const phy_cmd_am79c874_startup[] = { /* enable interrupts */
1005 { mk_mii_write(MII_AM79C874_ICSR, 0xff00), NULL },
1006 { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */
1007 { mk_mii_read(MII_REG_SR), mii_parse_sr },
1008 { mk_mii_end, }
1009 };
1010static phy_cmd_t const phy_cmd_am79c874_ack_int[] = {
1011 /* find out the current status */
1012 { mk_mii_read(MII_REG_SR), mii_parse_sr },
1013 { mk_mii_read(MII_AM79C874_DR), mii_parse_am79c874_dr },
1014 /* we only need to read ISR to acknowledge */
1015 { mk_mii_read(MII_AM79C874_ICSR), NULL },
1016 { mk_mii_end, }
1017 };
1018static phy_cmd_t const phy_cmd_am79c874_shutdown[] = { /* disable interrupts */
1019 { mk_mii_write(MII_AM79C874_ICSR, 0x0000), NULL },
1020 { mk_mii_end, }
1021 };
1022static phy_info_t const phy_info_am79c874 = {
1023 .id = 0x00022561,
1024 .name = "AM79C874",
1025 .config = phy_cmd_am79c874_config,
1026 .startup = phy_cmd_am79c874_startup,
1027 .ack_int = phy_cmd_am79c874_ack_int,
1028 .shutdown = phy_cmd_am79c874_shutdown
1029};
1030
1031
1032/* ------------------------------------------------------------------------- */
1033/* Kendin KS8721BL phy */
1034
1035/* register definitions for the 8721 */
1036
1037#define MII_KS8721BL_RXERCR 21
1038#define MII_KS8721BL_ICSR 27
1039#define MII_KS8721BL_PHYCR 31
1040
1041static phy_cmd_t const phy_cmd_ks8721bl_config[] = {
1042 { mk_mii_read(MII_REG_CR), mii_parse_cr },
1043 { mk_mii_read(MII_REG_ANAR), mii_parse_anar },
1044 { mk_mii_end, }
1045 };
1046static phy_cmd_t const phy_cmd_ks8721bl_startup[] = { /* enable interrupts */
1047 { mk_mii_write(MII_KS8721BL_ICSR, 0xff00), NULL },
1048 { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */
1049 { mk_mii_read(MII_REG_SR), mii_parse_sr },
1050 { mk_mii_end, }
1051 };
1052static phy_cmd_t const phy_cmd_ks8721bl_ack_int[] = {
1053 /* find out the current status */
1054 { mk_mii_read(MII_REG_SR), mii_parse_sr },
1055 /* we only need to read ISR to acknowledge */
1056 { mk_mii_read(MII_KS8721BL_ICSR), NULL },
1057 { mk_mii_end, }
1058 };
1059static phy_cmd_t const phy_cmd_ks8721bl_shutdown[] = { /* disable interrupts */
1060 { mk_mii_write(MII_KS8721BL_ICSR, 0x0000), NULL },
1061 { mk_mii_end, }
1062 };
1063static phy_info_t const phy_info_ks8721bl = {
1064 .id = 0x00022161,
1065 .name = "KS8721BL",
1066 .config = phy_cmd_ks8721bl_config,
1067 .startup = phy_cmd_ks8721bl_startup,
1068 .ack_int = phy_cmd_ks8721bl_ack_int,
1069 .shutdown = phy_cmd_ks8721bl_shutdown
1070};
1071
1072/* ------------------------------------------------------------------------- */
1073/* register definitions for the DP83848 */
1074
1075#define MII_DP8384X_PHYSTST 16 /* PHY Status Register */
1076
1077static void mii_parse_dp8384x_sr2(uint mii_reg, struct net_device *dev)
1078{ 679{
1079 struct fec_enet_private *fep = netdev_priv(dev); 680 struct fec_enet_private *fep = netdev_priv(dev);
1080 volatile uint *s = &(fep->phy_status); 681 struct phy_device *phy_dev = NULL;
1081 682 int phy_addr;
1082 *s &= ~(PHY_STAT_SPMASK | PHY_STAT_LINK | PHY_STAT_ANC);
1083
1084 /* Link up */
1085 if (mii_reg & 0x0001) {
1086 fep->link = 1;
1087 *s |= PHY_STAT_LINK;
1088 } else
1089 fep->link = 0;
1090 /* Status of link */
1091 if (mii_reg & 0x0010) /* Autonegotioation complete */
1092 *s |= PHY_STAT_ANC;
1093 if (mii_reg & 0x0002) { /* 10MBps? */
1094 if (mii_reg & 0x0004) /* Full Duplex? */
1095 *s |= PHY_STAT_10FDX;
1096 else
1097 *s |= PHY_STAT_10HDX;
1098 } else { /* 100 Mbps? */
1099 if (mii_reg & 0x0004) /* Full Duplex? */
1100 *s |= PHY_STAT_100FDX;
1101 else
1102 *s |= PHY_STAT_100HDX;
1103 }
1104 if (mii_reg & 0x0008)
1105 *s |= PHY_STAT_FAULT;
1106}
1107
1108static phy_info_t phy_info_dp83848= {
1109 0x020005c9,
1110 "DP83848",
1111 683
1112 (const phy_cmd_t []) { /* config */ 684 /* find the first phy */
1113 { mk_mii_read(MII_REG_CR), mii_parse_cr }, 685 for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
1114 { mk_mii_read(MII_REG_ANAR), mii_parse_anar }, 686 if (fep->mii_bus->phy_map[phy_addr]) {
1115 { mk_mii_read(MII_DP8384X_PHYSTST), mii_parse_dp8384x_sr2 }, 687 phy_dev = fep->mii_bus->phy_map[phy_addr];
1116 { mk_mii_end, } 688 break;
1117 }, 689 }
1118 (const phy_cmd_t []) { /* startup - enable interrupts */ 690 }
1119 { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */
1120 { mk_mii_read(MII_REG_SR), mii_parse_sr },
1121 { mk_mii_end, }
1122 },
1123 (const phy_cmd_t []) { /* ack_int - never happens, no interrupt */
1124 { mk_mii_end, }
1125 },
1126 (const phy_cmd_t []) { /* shutdown */
1127 { mk_mii_end, }
1128 },
1129};
1130 691
1131static phy_info_t phy_info_lan8700 = { 692 if (!phy_dev) {
1132 0x0007C0C, 693 printk(KERN_ERR "%s: no PHY found\n", dev->name);
1133 "LAN8700", 694 return -ENODEV;
1134 (const phy_cmd_t []) { /* config */ 695 }
1135 { mk_mii_read(MII_REG_CR), mii_parse_cr },
1136 { mk_mii_read(MII_REG_ANAR), mii_parse_anar },
1137 { mk_mii_end, }
1138 },
1139 (const phy_cmd_t []) { /* startup */
1140 { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */
1141 { mk_mii_read(MII_REG_SR), mii_parse_sr },
1142 { mk_mii_end, }
1143 },
1144 (const phy_cmd_t []) { /* act_int */
1145 { mk_mii_end, }
1146 },
1147 (const phy_cmd_t []) { /* shutdown */
1148 { mk_mii_end, }
1149 },
1150};
1151/* ------------------------------------------------------------------------- */
1152 696
1153static phy_info_t const * const phy_info[] = { 697 /* attach the mac to the phy */
1154 &phy_info_lxt970, 698 phy_dev = phy_connect(dev, dev_name(&phy_dev->dev),
1155 &phy_info_lxt971, 699 &fec_enet_adjust_link, 0,
1156 &phy_info_qs6612, 700 PHY_INTERFACE_MODE_MII);
1157 &phy_info_am79c874, 701 if (IS_ERR(phy_dev)) {
1158 &phy_info_ks8721bl, 702 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
1159 &phy_info_dp83848, 703 return PTR_ERR(phy_dev);
1160 &phy_info_lan8700, 704 }
1161 NULL
1162};
1163 705
1164/* ------------------------------------------------------------------------- */ 706 /* mask with MAC supported features */
1165#ifdef HAVE_mii_link_interrupt 707 phy_dev->supported &= PHY_BASIC_FEATURES;
1166static irqreturn_t 708 phy_dev->advertising = phy_dev->supported;
1167mii_link_interrupt(int irq, void * dev_id);
1168 709
1169/* 710 fep->phy_dev = phy_dev;
1170 * This is specific to the MII interrupt setup of the M5272EVB. 711 fep->link = 0;
1171 */ 712 fep->full_duplex = 0;
1172static void __inline__ fec_request_mii_intr(struct net_device *dev)
1173{
1174 if (request_irq(66, mii_link_interrupt, IRQF_DISABLED, "fec(MII)", dev) != 0)
1175 printk("FEC: Could not allocate fec(MII) IRQ(66)!\n");
1176}
1177 713
1178static void __inline__ fec_disable_phy_intr(struct net_device *dev) 714 return 0;
1179{
1180 free_irq(66, dev);
1181} 715}
1182#endif
1183 716
1184#ifdef CONFIG_M5272 717static int fec_enet_mii_init(struct platform_device *pdev)
1185static void __inline__ fec_get_mac(struct net_device *dev)
1186{ 718{
719 struct net_device *dev = platform_get_drvdata(pdev);
1187 struct fec_enet_private *fep = netdev_priv(dev); 720 struct fec_enet_private *fep = netdev_priv(dev);
1188 unsigned char *iap, tmpaddr[ETH_ALEN]; 721 int err = -ENXIO, i;
1189 722
1190 if (FEC_FLASHMAC) { 723 fep->mii_timeout = 0;
1191 /*
1192 * Get MAC address from FLASH.
1193 * If it is all 1's or 0's, use the default.
1194 */
1195 iap = (unsigned char *)FEC_FLASHMAC;
1196 if ((iap[0] == 0) && (iap[1] == 0) && (iap[2] == 0) &&
1197 (iap[3] == 0) && (iap[4] == 0) && (iap[5] == 0))
1198 iap = fec_mac_default;
1199 if ((iap[0] == 0xff) && (iap[1] == 0xff) && (iap[2] == 0xff) &&
1200 (iap[3] == 0xff) && (iap[4] == 0xff) && (iap[5] == 0xff))
1201 iap = fec_mac_default;
1202 } else {
1203 *((unsigned long *) &tmpaddr[0]) = readl(fep->hwp + FEC_ADDR_LOW);
1204 *((unsigned short *) &tmpaddr[4]) = (readl(fep->hwp + FEC_ADDR_HIGH) >> 16);
1205 iap = &tmpaddr[0];
1206 }
1207
1208 memcpy(dev->dev_addr, iap, ETH_ALEN);
1209
1210 /* Adjust MAC if using default MAC address */
1211 if (iap == fec_mac_default)
1212 dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->index;
1213}
1214#endif
1215 724
1216/* ------------------------------------------------------------------------- */ 725 /*
1217 726 * Set MII speed to 2.5 MHz (= clk_get_rate() / 2 * phy_speed)
1218static void mii_display_status(struct net_device *dev) 727 */
1219{ 728 fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk), 5000000) << 1;
1220 struct fec_enet_private *fep = netdev_priv(dev); 729 writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
1221 volatile uint *s = &(fep->phy_status);
1222 730
1223 if (!fep->link && !fep->old_link) { 731 fep->mii_bus = mdiobus_alloc();
1224 /* Link is still down - don't print anything */ 732 if (fep->mii_bus == NULL) {
1225 return; 733 err = -ENOMEM;
734 goto err_out;
1226 } 735 }
1227 736
1228 printk("%s: status: ", dev->name); 737 fep->mii_bus->name = "fec_enet_mii_bus";
1229 738 fep->mii_bus->read = fec_enet_mdio_read;
1230 if (!fep->link) { 739 fep->mii_bus->write = fec_enet_mdio_write;
1231 printk("link down"); 740 fep->mii_bus->reset = fec_enet_mdio_reset;
1232 } else { 741 snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id);
1233 printk("link up"); 742 fep->mii_bus->priv = fep;
1234 743 fep->mii_bus->parent = &pdev->dev;
1235 switch(*s & PHY_STAT_SPMASK) { 744
1236 case PHY_STAT_100FDX: printk(", 100MBit Full Duplex"); break; 745 fep->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
1237 case PHY_STAT_100HDX: printk(", 100MBit Half Duplex"); break; 746 if (!fep->mii_bus->irq) {
1238 case PHY_STAT_10FDX: printk(", 10MBit Full Duplex"); break; 747 err = -ENOMEM;
1239 case PHY_STAT_10HDX: printk(", 10MBit Half Duplex"); break; 748 goto err_out_free_mdiobus;
1240 default:
1241 printk(", Unknown speed/duplex");
1242 }
1243
1244 if (*s & PHY_STAT_ANC)
1245 printk(", auto-negotiation complete");
1246 } 749 }
1247 750
1248 if (*s & PHY_STAT_FAULT) 751 for (i = 0; i < PHY_MAX_ADDR; i++)
1249 printk(", remote fault"); 752 fep->mii_bus->irq[i] = PHY_POLL;
1250
1251 printk(".\n");
1252}
1253
1254static void mii_display_config(struct work_struct *work)
1255{
1256 struct fec_enet_private *fep = container_of(work, struct fec_enet_private, phy_task);
1257 struct net_device *dev = fep->netdev;
1258 uint status = fep->phy_status;
1259 753
1260 /* 754 platform_set_drvdata(dev, fep->mii_bus);
1261 ** When we get here, phy_task is already removed from
1262 ** the workqueue. It is thus safe to allow to reuse it.
1263 */
1264 fep->mii_phy_task_queued = 0;
1265 printk("%s: config: auto-negotiation ", dev->name);
1266
1267 if (status & PHY_CONF_ANE)
1268 printk("on");
1269 else
1270 printk("off");
1271 755
1272 if (status & PHY_CONF_100FDX) 756 if (mdiobus_register(fep->mii_bus))
1273 printk(", 100FDX"); 757 goto err_out_free_mdio_irq;
1274 if (status & PHY_CONF_100HDX)
1275 printk(", 100HDX");
1276 if (status & PHY_CONF_10FDX)
1277 printk(", 10FDX");
1278 if (status & PHY_CONF_10HDX)
1279 printk(", 10HDX");
1280 if (!(status & PHY_CONF_SPMASK))
1281 printk(", No speed/duplex selected?");
1282 758
1283 if (status & PHY_CONF_LOOP) 759 if (fec_enet_mii_probe(dev) != 0)
1284 printk(", loopback enabled"); 760 goto err_out_unregister_bus;
1285 761
1286 printk(".\n"); 762 return 0;
1287 763
1288 fep->sequence_done = 1; 764err_out_unregister_bus:
765 mdiobus_unregister(fep->mii_bus);
766err_out_free_mdio_irq:
767 kfree(fep->mii_bus->irq);
768err_out_free_mdiobus:
769 mdiobus_free(fep->mii_bus);
770err_out:
771 return err;
1289} 772}
1290 773
1291static void mii_relink(struct work_struct *work) 774static void fec_enet_mii_remove(struct fec_enet_private *fep)
1292{ 775{
1293 struct fec_enet_private *fep = container_of(work, struct fec_enet_private, phy_task); 776 if (fep->phy_dev)
1294 struct net_device *dev = fep->netdev; 777 phy_disconnect(fep->phy_dev);
1295 int duplex; 778 mdiobus_unregister(fep->mii_bus);
1296 779 kfree(fep->mii_bus->irq);
1297 /* 780 mdiobus_free(fep->mii_bus);
1298 ** When we get here, phy_task is already removed from
1299 ** the workqueue. It is thus safe to allow to reuse it.
1300 */
1301 fep->mii_phy_task_queued = 0;
1302 fep->link = (fep->phy_status & PHY_STAT_LINK) ? 1 : 0;
1303 mii_display_status(dev);
1304 fep->old_link = fep->link;
1305
1306 if (fep->link) {
1307 duplex = 0;
1308 if (fep->phy_status
1309 & (PHY_STAT_100FDX | PHY_STAT_10FDX))
1310 duplex = 1;
1311 fec_restart(dev, duplex);
1312 } else
1313 fec_stop(dev);
1314} 781}
1315 782
1316/* mii_queue_relink is called in interrupt context from mii_link_interrupt */ 783static int fec_enet_get_settings(struct net_device *dev,
1317static void mii_queue_relink(uint mii_reg, struct net_device *dev) 784 struct ethtool_cmd *cmd)
1318{ 785{
1319 struct fec_enet_private *fep = netdev_priv(dev); 786 struct fec_enet_private *fep = netdev_priv(dev);
787 struct phy_device *phydev = fep->phy_dev;
1320 788
1321 /* 789 if (!phydev)
1322 * We cannot queue phy_task twice in the workqueue. It 790 return -ENODEV;
1323 * would cause an endless loop in the workqueue.
1324 * Fortunately, if the last mii_relink entry has not yet been
1325 * executed now, it will do the job for the current interrupt,
1326 * which is just what we want.
1327 */
1328 if (fep->mii_phy_task_queued)
1329 return;
1330 791
1331 fep->mii_phy_task_queued = 1; 792 return phy_ethtool_gset(phydev, cmd);
1332 INIT_WORK(&fep->phy_task, mii_relink);
1333 schedule_work(&fep->phy_task);
1334} 793}
1335 794
1336/* mii_queue_config is called in interrupt context from fec_enet_mii */ 795static int fec_enet_set_settings(struct net_device *dev,
1337static void mii_queue_config(uint mii_reg, struct net_device *dev) 796 struct ethtool_cmd *cmd)
1338{ 797{
1339 struct fec_enet_private *fep = netdev_priv(dev); 798 struct fec_enet_private *fep = netdev_priv(dev);
799 struct phy_device *phydev = fep->phy_dev;
1340 800
1341 if (fep->mii_phy_task_queued) 801 if (!phydev)
1342 return; 802 return -ENODEV;
1343 803
1344 fep->mii_phy_task_queued = 1; 804 return phy_ethtool_sset(phydev, cmd);
1345 INIT_WORK(&fep->phy_task, mii_display_config);
1346 schedule_work(&fep->phy_task);
1347} 805}
1348 806
1349phy_cmd_t const phy_cmd_relink[] = { 807static void fec_enet_get_drvinfo(struct net_device *dev,
1350 { mk_mii_read(MII_REG_CR), mii_queue_relink }, 808 struct ethtool_drvinfo *info)
1351 { mk_mii_end, }
1352 };
1353phy_cmd_t const phy_cmd_config[] = {
1354 { mk_mii_read(MII_REG_CR), mii_queue_config },
1355 { mk_mii_end, }
1356 };
1357
1358/* Read remainder of PHY ID. */
1359static void
1360mii_discover_phy3(uint mii_reg, struct net_device *dev)
1361{ 809{
1362 struct fec_enet_private *fep; 810 struct fec_enet_private *fep = netdev_priv(dev);
1363 int i;
1364
1365 fep = netdev_priv(dev);
1366 fep->phy_id |= (mii_reg & 0xffff);
1367 printk("fec: PHY @ 0x%x, ID 0x%08x", fep->phy_addr, fep->phy_id);
1368
1369 for(i = 0; phy_info[i]; i++) {
1370 if(phy_info[i]->id == (fep->phy_id >> 4))
1371 break;
1372 }
1373
1374 if (phy_info[i])
1375 printk(" -- %s\n", phy_info[i]->name);
1376 else
1377 printk(" -- unknown PHY!\n");
1378 811
1379 fep->phy = phy_info[i]; 812 strcpy(info->driver, fep->pdev->dev.driver->name);
1380 fep->phy_id_done = 1; 813 strcpy(info->version, "Revision: 1.0");
814 strcpy(info->bus_info, dev_name(&dev->dev));
1381} 815}
1382 816
1383/* Scan all of the MII PHY addresses looking for someone to respond 817static struct ethtool_ops fec_enet_ethtool_ops = {
1384 * with a valid ID. This usually happens quickly. 818 .get_settings = fec_enet_get_settings,
1385 */ 819 .set_settings = fec_enet_set_settings,
1386static void 820 .get_drvinfo = fec_enet_get_drvinfo,
1387mii_discover_phy(uint mii_reg, struct net_device *dev) 821 .get_link = ethtool_op_get_link,
1388{ 822};
1389 struct fec_enet_private *fep;
1390 uint phytype;
1391
1392 fep = netdev_priv(dev);
1393
1394 if (fep->phy_addr < 32) {
1395 if ((phytype = (mii_reg & 0xffff)) != 0xffff && phytype != 0) {
1396
1397 /* Got first part of ID, now get remainder */
1398 fep->phy_id = phytype << 16;
1399 mii_queue_unlocked(dev, mk_mii_read(MII_REG_PHYIR2),
1400 mii_discover_phy3);
1401 } else {
1402 fep->phy_addr++;
1403 mii_queue_unlocked(dev, mk_mii_read(MII_REG_PHYIR1),
1404 mii_discover_phy);
1405 }
1406 } else {
1407 printk("FEC: No PHY device found.\n");
1408 /* Disable external MII interface */
1409 writel(0, fep->hwp + FEC_MII_SPEED);
1410 fep->phy_speed = 0;
1411#ifdef HAVE_mii_link_interrupt
1412 fec_disable_phy_intr(dev);
1413#endif
1414 }
1415}
1416 823
1417/* This interrupt occurs when the PHY detects a link change */ 824static int fec_enet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1418#ifdef HAVE_mii_link_interrupt
1419static irqreturn_t
1420mii_link_interrupt(int irq, void * dev_id)
1421{ 825{
1422 struct net_device *dev = dev_id;
1423 struct fec_enet_private *fep = netdev_priv(dev); 826 struct fec_enet_private *fep = netdev_priv(dev);
827 struct phy_device *phydev = fep->phy_dev;
828
829 if (!netif_running(dev))
830 return -EINVAL;
1424 831
1425 mii_do_cmd(dev, fep->phy->ack_int); 832 if (!phydev)
1426 mii_do_cmd(dev, phy_cmd_relink); /* restart and display status */ 833 return -ENODEV;
1427 834
1428 return IRQ_HANDLED; 835 return phy_mii_ioctl(phydev, if_mii(rq), cmd);
1429} 836}
1430#endif
1431 837
1432static void fec_enet_free_buffers(struct net_device *dev) 838static void fec_enet_free_buffers(struct net_device *dev)
1433{ 839{
@@ -1509,35 +915,8 @@ fec_enet_open(struct net_device *dev)
1509 if (ret) 915 if (ret)
1510 return ret; 916 return ret;
1511 917
1512 fep->sequence_done = 0; 918 /* schedule a link state check */
1513 fep->link = 0; 919 phy_start(fep->phy_dev);
1514
1515 fec_restart(dev, 1);
1516
1517 if (fep->phy) {
1518 mii_do_cmd(dev, fep->phy->ack_int);
1519 mii_do_cmd(dev, fep->phy->config);
1520 mii_do_cmd(dev, phy_cmd_config); /* display configuration */
1521
1522 /* Poll until the PHY tells us its configuration
1523 * (not link state).
1524 * Request is initiated by mii_do_cmd above, but answer
1525 * comes by interrupt.
1526 * This should take about 25 usec per register at 2.5 MHz,
1527 * and we read approximately 5 registers.
1528 */
1529 while(!fep->sequence_done)
1530 schedule();
1531
1532 mii_do_cmd(dev, fep->phy->startup);
1533 }
1534
1535 /* Set the initial link state to true. A lot of hardware
1536 * based on this device does not implement a PHY interrupt,
1537 * so we are never notified of link change.
1538 */
1539 fep->link = 1;
1540
1541 netif_start_queue(dev); 920 netif_start_queue(dev);
1542 fep->opened = 1; 921 fep->opened = 1;
1543 return 0; 922 return 0;
@@ -1550,6 +929,7 @@ fec_enet_close(struct net_device *dev)
1550 929
1551 /* Don't know what to do yet. */ 930 /* Don't know what to do yet. */
1552 fep->opened = 0; 931 fep->opened = 0;
932 phy_stop(fep->phy_dev);
1553 netif_stop_queue(dev); 933 netif_stop_queue(dev);
1554 fec_stop(dev); 934 fec_stop(dev);
1555 935
@@ -1574,7 +954,7 @@ fec_enet_close(struct net_device *dev)
1574static void set_multicast_list(struct net_device *dev) 954static void set_multicast_list(struct net_device *dev)
1575{ 955{
1576 struct fec_enet_private *fep = netdev_priv(dev); 956 struct fec_enet_private *fep = netdev_priv(dev);
1577 struct dev_mc_list *dmi; 957 struct netdev_hw_addr *ha;
1578 unsigned int i, bit, data, crc, tmp; 958 unsigned int i, bit, data, crc, tmp;
1579 unsigned char hash; 959 unsigned char hash;
1580 960
@@ -1604,16 +984,16 @@ static void set_multicast_list(struct net_device *dev)
1604 writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH); 984 writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
1605 writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW); 985 writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
1606 986
1607 netdev_for_each_mc_addr(dmi, dev) { 987 netdev_for_each_mc_addr(ha, dev) {
1608 /* Only support group multicast for now */ 988 /* Only support group multicast for now */
1609 if (!(dmi->dmi_addr[0] & 1)) 989 if (!(ha->addr[0] & 1))
1610 continue; 990 continue;
1611 991
1612 /* calculate crc32 value of mac address */ 992 /* calculate crc32 value of mac address */
1613 crc = 0xffffffff; 993 crc = 0xffffffff;
1614 994
1615 for (i = 0; i < dmi->dmi_addrlen; i++) { 995 for (i = 0; i < dev->addr_len; i++) {
1616 data = dmi->dmi_addr[i]; 996 data = ha->addr[i];
1617 for (bit = 0; bit < 8; bit++, data >>= 1) { 997 for (bit = 0; bit < 8; bit++, data >>= 1) {
1618 crc = (crc >> 1) ^ 998 crc = (crc >> 1) ^
1619 (((crc ^ data) & 1) ? CRC32_POLY : 0); 999 (((crc ^ data) & 1) ? CRC32_POLY : 0);
@@ -1666,6 +1046,7 @@ static const struct net_device_ops fec_netdev_ops = {
1666 .ndo_validate_addr = eth_validate_addr, 1046 .ndo_validate_addr = eth_validate_addr,
1667 .ndo_tx_timeout = fec_timeout, 1047 .ndo_tx_timeout = fec_timeout,
1668 .ndo_set_mac_address = fec_set_mac_address, 1048 .ndo_set_mac_address = fec_set_mac_address,
1049 .ndo_do_ioctl = fec_enet_ioctl,
1669}; 1050};
1670 1051
1671 /* 1052 /*
@@ -1689,7 +1070,6 @@ static int fec_enet_init(struct net_device *dev, int index)
1689 } 1070 }
1690 1071
1691 spin_lock_init(&fep->hw_lock); 1072 spin_lock_init(&fep->hw_lock);
1692 spin_lock_init(&fep->mii_lock);
1693 1073
1694 fep->index = index; 1074 fep->index = index;
1695 fep->hwp = (void __iomem *)dev->base_addr; 1075 fep->hwp = (void __iomem *)dev->base_addr;
@@ -1716,20 +1096,10 @@ static int fec_enet_init(struct net_device *dev, int index)
1716 fep->rx_bd_base = cbd_base; 1096 fep->rx_bd_base = cbd_base;
1717 fep->tx_bd_base = cbd_base + RX_RING_SIZE; 1097 fep->tx_bd_base = cbd_base + RX_RING_SIZE;
1718 1098
1719#ifdef HAVE_mii_link_interrupt
1720 fec_request_mii_intr(dev);
1721#endif
1722 /* The FEC Ethernet specific entries in the device structure */ 1099 /* The FEC Ethernet specific entries in the device structure */
1723 dev->watchdog_timeo = TX_TIMEOUT; 1100 dev->watchdog_timeo = TX_TIMEOUT;
1724 dev->netdev_ops = &fec_netdev_ops; 1101 dev->netdev_ops = &fec_netdev_ops;
1725 1102 dev->ethtool_ops = &fec_enet_ethtool_ops;
1726 for (i=0; i<NMII-1; i++)
1727 mii_cmds[i].mii_next = &mii_cmds[i+1];
1728 mii_free = mii_cmds;
1729
1730 /* Set MII speed to 2.5 MHz */
1731 fep->phy_speed = ((((clk_get_rate(fep->clk) / 2 + 4999999)
1732 / 2500000) / 2) & 0x3F) << 1;
1733 1103
1734 /* Initialize the receive buffer descriptors. */ 1104 /* Initialize the receive buffer descriptors. */
1735 bdp = fep->rx_bd_base; 1105 bdp = fep->rx_bd_base;
@@ -1760,13 +1130,6 @@ static int fec_enet_init(struct net_device *dev, int index)
1760 1130
1761 fec_restart(dev, 0); 1131 fec_restart(dev, 0);
1762 1132
1763 /* Queue up command to detect the PHY and initialize the
1764 * remainder of the interface.
1765 */
1766 fep->phy_id_done = 0;
1767 fep->phy_addr = 0;
1768 mii_queue(dev, mk_mii_read(MII_REG_PHYIR1), mii_discover_phy);
1769
1770 return 0; 1133 return 0;
1771} 1134}
1772 1135
@@ -1835,8 +1198,7 @@ fec_restart(struct net_device *dev, int duplex)
1835 writel(0, fep->hwp + FEC_R_DES_ACTIVE); 1198 writel(0, fep->hwp + FEC_R_DES_ACTIVE);
1836 1199
1837 /* Enable interrupts we wish to service */ 1200 /* Enable interrupts we wish to service */
1838 writel(FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII, 1201 writel(FEC_ENET_TXF | FEC_ENET_RXF, fep->hwp + FEC_IMASK);
1839 fep->hwp + FEC_IMASK);
1840} 1202}
1841 1203
1842static void 1204static void
@@ -1859,7 +1221,6 @@ fec_stop(struct net_device *dev)
1859 /* Clear outstanding MII command interrupts. */ 1221 /* Clear outstanding MII command interrupts. */
1860 writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT); 1222 writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT);
1861 1223
1862 writel(FEC_ENET_MII, fep->hwp + FEC_IMASK);
1863 writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); 1224 writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
1864} 1225}
1865 1226
@@ -1891,6 +1252,7 @@ fec_probe(struct platform_device *pdev)
1891 memset(fep, 0, sizeof(*fep)); 1252 memset(fep, 0, sizeof(*fep));
1892 1253
1893 ndev->base_addr = (unsigned long)ioremap(r->start, resource_size(r)); 1254 ndev->base_addr = (unsigned long)ioremap(r->start, resource_size(r));
1255 fep->pdev = pdev;
1894 1256
1895 if (!ndev->base_addr) { 1257 if (!ndev->base_addr) {
1896 ret = -ENOMEM; 1258 ret = -ENOMEM;
@@ -1926,13 +1288,24 @@ fec_probe(struct platform_device *pdev)
1926 if (ret) 1288 if (ret)
1927 goto failed_init; 1289 goto failed_init;
1928 1290
1291 ret = fec_enet_mii_init(pdev);
1292 if (ret)
1293 goto failed_mii_init;
1294
1929 ret = register_netdev(ndev); 1295 ret = register_netdev(ndev);
1930 if (ret) 1296 if (ret)
1931 goto failed_register; 1297 goto failed_register;
1932 1298
1299 printk(KERN_INFO "%s: Freescale FEC PHY driver [%s] "
1300 "(mii_bus:phy_addr=%s, irq=%d)\n", ndev->name,
1301 fep->phy_dev->drv->name, dev_name(&fep->phy_dev->dev),
1302 fep->phy_dev->irq);
1303
1933 return 0; 1304 return 0;
1934 1305
1935failed_register: 1306failed_register:
1307 fec_enet_mii_remove(fep);
1308failed_mii_init:
1936failed_init: 1309failed_init:
1937 clk_disable(fep->clk); 1310 clk_disable(fep->clk);
1938 clk_put(fep->clk); 1311 clk_put(fep->clk);
@@ -1959,6 +1332,7 @@ fec_drv_remove(struct platform_device *pdev)
1959 platform_set_drvdata(pdev, NULL); 1332 platform_set_drvdata(pdev, NULL);
1960 1333
1961 fec_stop(ndev); 1334 fec_stop(ndev);
1335 fec_enet_mii_remove(fep);
1962 clk_disable(fep->clk); 1336 clk_disable(fep->clk);
1963 clk_put(fep->clk); 1337 clk_put(fep->clk);
1964 iounmap((void __iomem *)ndev->base_addr); 1338 iounmap((void __iomem *)ndev->base_addr);
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index 0dbd7219bbde..667ba1391b9d 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -435,7 +435,6 @@ static irqreturn_t mpc52xx_fec_rx_interrupt(int irq, void *dev_id)
435 DMA_FROM_DEVICE); 435 DMA_FROM_DEVICE);
436 length = status & BCOM_FEC_RX_BD_LEN_MASK; 436 length = status & BCOM_FEC_RX_BD_LEN_MASK;
437 skb_put(rskb, length - 4); /* length without CRC32 */ 437 skb_put(rskb, length - 4); /* length without CRC32 */
438 rskb->dev = dev;
439 rskb->protocol = eth_type_trans(rskb, dev); 438 rskb->protocol = eth_type_trans(rskb, dev);
440 netif_rx(rskb); 439 netif_rx(rskb);
441 440
@@ -575,12 +574,12 @@ static void mpc52xx_fec_set_multicast_list(struct net_device *dev)
575 out_be32(&fec->gaddr2, 0xffffffff); 574 out_be32(&fec->gaddr2, 0xffffffff);
576 } else { 575 } else {
577 u32 crc; 576 u32 crc;
578 struct dev_mc_list *dmi; 577 struct netdev_hw_addr *ha;
579 u32 gaddr1 = 0x00000000; 578 u32 gaddr1 = 0x00000000;
580 u32 gaddr2 = 0x00000000; 579 u32 gaddr2 = 0x00000000;
581 580
582 netdev_for_each_mc_addr(dmi, dev) { 581 netdev_for_each_mc_addr(ha, dev) {
583 crc = ether_crc_le(6, dmi->dmi_addr) >> 26; 582 crc = ether_crc_le(6, ha->addr) >> 26;
584 if (crc >= 32) 583 if (crc >= 32)
585 gaddr1 |= 1 << (crc-32); 584 gaddr1 |= 1 << (crc-32);
586 else 585 else
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index ca05e5662029..6a2b64f0a7db 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -3103,12 +3103,14 @@ static void nv_set_multicast(struct net_device *dev)
3103 if (dev->flags & IFF_ALLMULTI) { 3103 if (dev->flags & IFF_ALLMULTI) {
3104 alwaysOn[0] = alwaysOn[1] = alwaysOff[0] = alwaysOff[1] = 0; 3104 alwaysOn[0] = alwaysOn[1] = alwaysOff[0] = alwaysOff[1] = 0;
3105 } else { 3105 } else {
3106 struct dev_mc_list *walk; 3106 struct netdev_hw_addr *ha;
3107 3107
3108 netdev_for_each_mc_addr(walk, dev) { 3108 netdev_for_each_mc_addr(ha, dev) {
3109 unsigned char *addr = ha->addr;
3109 u32 a, b; 3110 u32 a, b;
3110 a = le32_to_cpu(*(__le32 *) walk->dmi_addr); 3111
3111 b = le16_to_cpu(*(__le16 *) (&walk->dmi_addr[4])); 3112 a = le32_to_cpu(*(__le32 *) addr);
3113 b = le16_to_cpu(*(__le16 *) (&addr[4]));
3112 alwaysOn[0] &= a; 3114 alwaysOn[0] &= a;
3113 alwaysOff[0] &= ~a; 3115 alwaysOff[0] &= ~a;
3114 alwaysOn[1] &= b; 3116 alwaysOn[1] &= b;
diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c
index cf4f674f9e2e..b3bad7c15d02 100644
--- a/drivers/net/fs_enet/mac-fcc.c
+++ b/drivers/net/fs_enet/mac-fcc.c
@@ -231,12 +231,12 @@ static void set_multicast_finish(struct net_device *dev)
231 231
232static void set_multicast_list(struct net_device *dev) 232static void set_multicast_list(struct net_device *dev)
233{ 233{
234 struct dev_mc_list *pmc; 234 struct netdev_hw_addr *ha;
235 235
236 if ((dev->flags & IFF_PROMISC) == 0) { 236 if ((dev->flags & IFF_PROMISC) == 0) {
237 set_multicast_start(dev); 237 set_multicast_start(dev);
238 netdev_for_each_mc_addr(pmc, dev) 238 netdev_for_each_mc_addr(ha, dev)
239 set_multicast_one(dev, pmc->dmi_addr); 239 set_multicast_one(dev, ha->addr);
240 set_multicast_finish(dev); 240 set_multicast_finish(dev);
241 } else 241 } else
242 set_promiscuous_mode(dev); 242 set_promiscuous_mode(dev);
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c
index cd2c6cca5f24..75974c6d201b 100644
--- a/drivers/net/fs_enet/mac-fec.c
+++ b/drivers/net/fs_enet/mac-fec.c
@@ -232,12 +232,12 @@ static void set_multicast_finish(struct net_device *dev)
232 232
233static void set_multicast_list(struct net_device *dev) 233static void set_multicast_list(struct net_device *dev)
234{ 234{
235 struct dev_mc_list *pmc; 235 struct netdev_hw_addr *ha;
236 236
237 if ((dev->flags & IFF_PROMISC) == 0) { 237 if ((dev->flags & IFF_PROMISC) == 0) {
238 set_multicast_start(dev); 238 set_multicast_start(dev);
239 netdev_for_each_mc_addr(pmc, dev) 239 netdev_for_each_mc_addr(ha, dev)
240 set_multicast_one(dev, pmc->dmi_addr); 240 set_multicast_one(dev, ha->addr);
241 set_multicast_finish(dev); 241 set_multicast_finish(dev);
242 } else 242 } else
243 set_promiscuous_mode(dev); 243 set_promiscuous_mode(dev);
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c
index c490a466cae1..0ab6a346a193 100644
--- a/drivers/net/fs_enet/mac-scc.c
+++ b/drivers/net/fs_enet/mac-scc.c
@@ -224,12 +224,12 @@ static void set_multicast_finish(struct net_device *dev)
224 224
225static void set_multicast_list(struct net_device *dev) 225static void set_multicast_list(struct net_device *dev)
226{ 226{
227 struct dev_mc_list *pmc; 227 struct netdev_hw_addr *ha;
228 228
229 if ((dev->flags & IFF_PROMISC) == 0) { 229 if ((dev->flags & IFF_PROMISC) == 0) {
230 set_multicast_start(dev); 230 set_multicast_start(dev);
231 netdev_for_each_mc_addr(pmc, dev) 231 netdev_for_each_mc_addr(ha, dev)
232 set_multicast_one(dev, pmc->dmi_addr); 232 set_multicast_one(dev, ha->addr);
233 set_multicast_finish(dev); 233 set_multicast_finish(dev);
234 } else 234 } else
235 set_promiscuous_mode(dev); 235 set_promiscuous_mode(dev);
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 080d1cea5b26..5175233f11f2 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -2798,7 +2798,7 @@ static void adjust_link(struct net_device *dev)
2798 * whenever dev->flags is changed */ 2798 * whenever dev->flags is changed */
2799static void gfar_set_multi(struct net_device *dev) 2799static void gfar_set_multi(struct net_device *dev)
2800{ 2800{
2801 struct dev_mc_list *mc_ptr; 2801 struct netdev_hw_addr *ha;
2802 struct gfar_private *priv = netdev_priv(dev); 2802 struct gfar_private *priv = netdev_priv(dev);
2803 struct gfar __iomem *regs = priv->gfargrp[0].regs; 2803 struct gfar __iomem *regs = priv->gfargrp[0].regs;
2804 u32 tempval; 2804 u32 tempval;
@@ -2871,13 +2871,12 @@ static void gfar_set_multi(struct net_device *dev)
2871 return; 2871 return;
2872 2872
2873 /* Parse the list, and set the appropriate bits */ 2873 /* Parse the list, and set the appropriate bits */
2874 netdev_for_each_mc_addr(mc_ptr, dev) { 2874 netdev_for_each_mc_addr(ha, dev) {
2875 if (idx < em_num) { 2875 if (idx < em_num) {
2876 gfar_set_mac_for_addr(dev, idx, 2876 gfar_set_mac_for_addr(dev, idx, ha->addr);
2877 mc_ptr->dmi_addr);
2878 idx++; 2877 idx++;
2879 } else 2878 } else
2880 gfar_set_hash_for_addr(dev, mc_ptr->dmi_addr); 2879 gfar_set_hash_for_addr(dev, ha->addr);
2881 } 2880 }
2882 } 2881 }
2883 2882
diff --git a/drivers/net/greth.c b/drivers/net/greth.c
index 2b9c1cbc9ec1..fbe6ab6b919b 100644
--- a/drivers/net/greth.c
+++ b/drivers/net/greth.c
@@ -894,7 +894,6 @@ static int greth_rx_gbit(struct net_device *dev, int limit)
894 else 894 else
895 skb->ip_summed = CHECKSUM_NONE; 895 skb->ip_summed = CHECKSUM_NONE;
896 896
897 skb->dev = dev;
898 skb->protocol = eth_type_trans(skb, dev); 897 skb->protocol = eth_type_trans(skb, dev);
899 dev->stats.rx_packets++; 898 dev->stats.rx_packets++;
900 netif_receive_skb(skb); 899 netif_receive_skb(skb);
@@ -989,7 +988,7 @@ static u32 greth_hash_get_index(__u8 *addr)
989 988
990static void greth_set_hash_filter(struct net_device *dev) 989static void greth_set_hash_filter(struct net_device *dev)
991{ 990{
992 struct dev_mc_list *curr; 991 struct netdev_hw_addr *ha;
993 struct greth_private *greth = netdev_priv(dev); 992 struct greth_private *greth = netdev_priv(dev);
994 struct greth_regs *regs = (struct greth_regs *) greth->regs; 993 struct greth_regs *regs = (struct greth_regs *) greth->regs;
995 u32 mc_filter[2]; 994 u32 mc_filter[2];
@@ -997,8 +996,8 @@ static void greth_set_hash_filter(struct net_device *dev)
997 996
998 mc_filter[0] = mc_filter[1] = 0; 997 mc_filter[0] = mc_filter[1] = 0;
999 998
1000 netdev_for_each_mc_addr(curr, dev) { 999 netdev_for_each_mc_addr(ha, dev) {
1001 bitnr = greth_hash_get_index(curr->dmi_addr); 1000 bitnr = greth_hash_get_index(ha->addr);
1002 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31); 1001 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
1003 } 1002 }
1004 1003
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c
index 373546dd0831..2bfcca6d180c 100644
--- a/drivers/net/hamachi.c
+++ b/drivers/net/hamachi.c
@@ -1858,12 +1858,12 @@ static void set_rx_mode(struct net_device *dev)
1858 /* Too many to match, or accept all multicasts. */ 1858 /* Too many to match, or accept all multicasts. */
1859 writew(0x000B, ioaddr + AddrMode); 1859 writew(0x000B, ioaddr + AddrMode);
1860 } else if (!netdev_mc_empty(dev)) { /* Must use the CAM filter. */ 1860 } else if (!netdev_mc_empty(dev)) { /* Must use the CAM filter. */
1861 struct dev_mc_list *mclist; 1861 struct netdev_hw_addr *ha;
1862 int i = 0; 1862 int i = 0;
1863 1863
1864 netdev_for_each_mc_addr(mclist, dev) { 1864 netdev_for_each_mc_addr(ha, dev) {
1865 writel(*(u32*)(mclist->dmi_addr), ioaddr + 0x100 + i*8); 1865 writel(*(u32 *)(ha->addr), ioaddr + 0x100 + i*8);
1866 writel(0x20000 | (*(u16*)&mclist->dmi_addr[4]), 1866 writel(0x20000 | (*(u16 *)&ha->addr[4]),
1867 ioaddr + 0x104 + i*8); 1867 ioaddr + 0x104 + i*8);
1868 i++; 1868 i++;
1869 } 1869 }
diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c
index 0cab992b3d1a..3e25f10cabd6 100644
--- a/drivers/net/hamradio/baycom_ser_fdx.c
+++ b/drivers/net/hamradio/baycom_ser_fdx.c
@@ -429,7 +429,7 @@ static int ser12_open(struct net_device *dev)
429 return -EINVAL; 429 return -EINVAL;
430 } 430 }
431 if (!request_region(dev->base_addr, SER12_EXTENT, "baycom_ser_fdx")) { 431 if (!request_region(dev->base_addr, SER12_EXTENT, "baycom_ser_fdx")) {
432 printk(KERN_WARNING "BAYCOM_SER_FSX: I/O port 0x%04lx busy \n", 432 printk(KERN_WARNING "BAYCOM_SER_FSX: I/O port 0x%04lx busy\n",
433 dev->base_addr); 433 dev->base_addr);
434 return -EACCES; 434 return -EACCES;
435 } 435 }
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c
index b766a69bf0ca..86b2b4332341 100644
--- a/drivers/net/hp100.c
+++ b/drivers/net/hp100.c
@@ -2100,15 +2100,15 @@ static void hp100_set_multicast_list(struct net_device *dev)
2100 } else { 2100 } else {
2101 int i, idx; 2101 int i, idx;
2102 u_char *addrs; 2102 u_char *addrs;
2103 struct dev_mc_list *dmi; 2103 struct netdev_hw_addr *ha;
2104 2104
2105 memset(&lp->hash_bytes, 0x00, 8); 2105 memset(&lp->hash_bytes, 0x00, 8);
2106#ifdef HP100_DEBUG 2106#ifdef HP100_DEBUG
2107 printk("hp100: %s: computing hash filter - mc_count = %i\n", 2107 printk("hp100: %s: computing hash filter - mc_count = %i\n",
2108 dev->name, netdev_mc_count(dev)); 2108 dev->name, netdev_mc_count(dev));
2109#endif 2109#endif
2110 netdev_for_each_mc_addr(dmi, dev) { 2110 netdev_for_each_mc_addr(ha, dev) {
2111 addrs = dmi->dmi_addr; 2111 addrs = ha->addr;
2112 if ((*addrs & 0x01) == 0x01) { /* multicast address? */ 2112 if ((*addrs & 0x01) == 0x01) { /* multicast address? */
2113#ifdef HP100_DEBUG 2113#ifdef HP100_DEBUG
2114 printk("hp100: %s: multicast = %pM, ", 2114 printk("hp100: %s: multicast = %pM, ",
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c
index fb0ac6d7c040..40c78507ef16 100644
--- a/drivers/net/ibm_newemac/core.c
+++ b/drivers/net/ibm_newemac/core.c
@@ -388,18 +388,19 @@ static void emac_hash_mc(struct emac_instance *dev)
388 const int regs = EMAC_XAHT_REGS(dev); 388 const int regs = EMAC_XAHT_REGS(dev);
389 u32 *gaht_base = emac_gaht_base(dev); 389 u32 *gaht_base = emac_gaht_base(dev);
390 u32 gaht_temp[regs]; 390 u32 gaht_temp[regs];
391 struct dev_mc_list *dmi; 391 struct netdev_hw_addr *ha;
392 int i; 392 int i;
393 393
394 DBG(dev, "hash_mc %d" NL, netdev_mc_count(dev->ndev)); 394 DBG(dev, "hash_mc %d" NL, netdev_mc_count(dev->ndev));
395 395
396 memset(gaht_temp, 0, sizeof (gaht_temp)); 396 memset(gaht_temp, 0, sizeof (gaht_temp));
397 397
398 netdev_for_each_mc_addr(dmi, dev->ndev) { 398 netdev_for_each_mc_addr(ha, dev->ndev) {
399 int slot, reg, mask; 399 int slot, reg, mask;
400 DBG2(dev, "mc %pM" NL, dmi->dmi_addr); 400 DBG2(dev, "mc %pM" NL, ha->addr);
401 401
402 slot = EMAC_XAHT_CRC_TO_SLOT(dev, ether_crc(ETH_ALEN, dmi->dmi_addr)); 402 slot = EMAC_XAHT_CRC_TO_SLOT(dev,
403 ether_crc(ETH_ALEN, ha->addr));
403 reg = EMAC_XAHT_SLOT_TO_REG(dev, slot); 404 reg = EMAC_XAHT_SLOT_TO_REG(dev, slot);
404 mask = EMAC_XAHT_SLOT_TO_MASK(dev, slot); 405 mask = EMAC_XAHT_SLOT_TO_MASK(dev, slot);
405 406
@@ -1176,7 +1177,7 @@ static int emac_open(struct net_device *ndev)
1176 netif_carrier_on(dev->ndev); 1177 netif_carrier_on(dev->ndev);
1177 1178
1178 /* Required for Pause packet support in EMAC */ 1179 /* Required for Pause packet support in EMAC */
1179 dev_mc_add(ndev, default_mcast_addr, sizeof(default_mcast_addr), 1); 1180 dev_mc_add_global(ndev, default_mcast_addr);
1180 1181
1181 emac_configure(dev); 1182 emac_configure(dev);
1182 mal_poll_add(dev->mal, &dev->commac); 1183 mal_poll_add(dev->mal, &dev->commac);
@@ -1699,7 +1700,6 @@ static int emac_poll_rx(void *param, int budget)
1699 1700
1700 skb_put(skb, len); 1701 skb_put(skb, len);
1701 push_packet: 1702 push_packet:
1702 skb->dev = dev->ndev;
1703 skb->protocol = eth_type_trans(skb, dev->ndev); 1703 skb->protocol = eth_type_trans(skb, dev->ndev);
1704 emac_rx_csum(dev, skb, ctrl); 1704 emac_rx_csum(dev, skb, ctrl);
1705 1705
diff --git a/drivers/net/ibmlana.c b/drivers/net/ibmlana.c
index b5d0f4e973f7..76949e08ee84 100644
--- a/drivers/net/ibmlana.c
+++ b/drivers/net/ibmlana.c
@@ -385,7 +385,7 @@ static void InitBoard(struct net_device *dev)
385 int camcnt; 385 int camcnt;
386 camentry_t cams[16]; 386 camentry_t cams[16];
387 u32 cammask; 387 u32 cammask;
388 struct dev_mc_list *mcptr; 388 struct netdev_hw_addr *ha;
389 u16 rcrval; 389 u16 rcrval;
390 390
391 /* reset the SONIC */ 391 /* reset the SONIC */
@@ -420,8 +420,8 @@ static void InitBoard(struct net_device *dev)
420 /* start putting the multicast addresses into the CAM list. Stop if 420 /* start putting the multicast addresses into the CAM list. Stop if
421 it is full. */ 421 it is full. */
422 422
423 netdev_for_each_mc_addr(mcptr, dev) { 423 netdev_for_each_mc_addr(ha, dev) {
424 putcam(cams, &camcnt, mcptr->dmi_addr); 424 putcam(cams, &camcnt, ha->addr);
425 if (camcnt == 16) 425 if (camcnt == 16)
426 break; 426 break;
427 } 427 }
@@ -479,7 +479,7 @@ static void InitBoard(struct net_device *dev)
479 /* if still multicast addresses left or ALLMULTI is set, set the multicast 479 /* if still multicast addresses left or ALLMULTI is set, set the multicast
480 enable bit */ 480 enable bit */
481 481
482 if ((dev->flags & IFF_ALLMULTI) || (mcptr != NULL)) 482 if ((dev->flags & IFF_ALLMULTI) || netdev_mc_count(dev) > camcnt)
483 rcrval |= RCREG_AMC; 483 rcrval |= RCREG_AMC;
484 484
485 /* promiscous mode ? */ 485 /* promiscous mode ? */
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 0bc777bac9b4..f468590ed454 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -1072,7 +1072,7 @@ static void ibmveth_set_multicast_list(struct net_device *netdev)
1072 ibmveth_error_printk("h_multicast_ctrl rc=%ld when entering promisc mode\n", lpar_rc); 1072 ibmveth_error_printk("h_multicast_ctrl rc=%ld when entering promisc mode\n", lpar_rc);
1073 } 1073 }
1074 } else { 1074 } else {
1075 struct dev_mc_list *mclist; 1075 struct netdev_hw_addr *ha;
1076 /* clear the filter table & disable filtering */ 1076 /* clear the filter table & disable filtering */
1077 lpar_rc = h_multicast_ctrl(adapter->vdev->unit_address, 1077 lpar_rc = h_multicast_ctrl(adapter->vdev->unit_address,
1078 IbmVethMcastEnableRecv | 1078 IbmVethMcastEnableRecv |
@@ -1083,10 +1083,10 @@ static void ibmveth_set_multicast_list(struct net_device *netdev)
1083 ibmveth_error_printk("h_multicast_ctrl rc=%ld when attempting to clear filter table\n", lpar_rc); 1083 ibmveth_error_printk("h_multicast_ctrl rc=%ld when attempting to clear filter table\n", lpar_rc);
1084 } 1084 }
1085 /* add the addresses to the filter table */ 1085 /* add the addresses to the filter table */
1086 netdev_for_each_mc_addr(mclist, netdev) { 1086 netdev_for_each_mc_addr(ha, netdev) {
1087 // add the multicast address to the filter table 1087 // add the multicast address to the filter table
1088 unsigned long mcast_addr = 0; 1088 unsigned long mcast_addr = 0;
1089 memcpy(((char *)&mcast_addr)+2, mclist->dmi_addr, 6); 1089 memcpy(((char *)&mcast_addr)+2, ha->addr, 6);
1090 lpar_rc = h_multicast_ctrl(adapter->vdev->unit_address, 1090 lpar_rc = h_multicast_ctrl(adapter->vdev->unit_address,
1091 IbmVethMcastAddFilter, 1091 IbmVethMcastAddFilter,
1092 mcast_addr); 1092 mcast_addr);
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index 0bc990ec4a8e..430631f49d9d 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -105,6 +105,12 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
105 case E1000_DEV_ID_82580_COPPER_DUAL: 105 case E1000_DEV_ID_82580_COPPER_DUAL:
106 mac->type = e1000_82580; 106 mac->type = e1000_82580;
107 break; 107 break;
108 case E1000_DEV_ID_I350_COPPER:
109 case E1000_DEV_ID_I350_FIBER:
110 case E1000_DEV_ID_I350_SERDES:
111 case E1000_DEV_ID_I350_SGMII:
112 mac->type = e1000_i350;
113 break;
108 default: 114 default:
109 return -E1000_ERR_MAC_INIT; 115 return -E1000_ERR_MAC_INIT;
110 break; 116 break;
@@ -154,8 +160,10 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
154 mac->rar_entry_count = E1000_RAR_ENTRIES_82576; 160 mac->rar_entry_count = E1000_RAR_ENTRIES_82576;
155 if (mac->type == e1000_82580) 161 if (mac->type == e1000_82580)
156 mac->rar_entry_count = E1000_RAR_ENTRIES_82580; 162 mac->rar_entry_count = E1000_RAR_ENTRIES_82580;
163 if (mac->type == e1000_i350)
164 mac->rar_entry_count = E1000_RAR_ENTRIES_I350;
157 /* reset */ 165 /* reset */
158 if (mac->type == e1000_82580) 166 if (mac->type >= e1000_82580)
159 mac->ops.reset_hw = igb_reset_hw_82580; 167 mac->ops.reset_hw = igb_reset_hw_82580;
160 else 168 else
161 mac->ops.reset_hw = igb_reset_hw_82575; 169 mac->ops.reset_hw = igb_reset_hw_82575;
@@ -226,7 +234,7 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
226 phy->ops.reset = igb_phy_hw_reset_sgmii_82575; 234 phy->ops.reset = igb_phy_hw_reset_sgmii_82575;
227 phy->ops.read_reg = igb_read_phy_reg_sgmii_82575; 235 phy->ops.read_reg = igb_read_phy_reg_sgmii_82575;
228 phy->ops.write_reg = igb_write_phy_reg_sgmii_82575; 236 phy->ops.write_reg = igb_write_phy_reg_sgmii_82575;
229 } else if (hw->mac.type == e1000_82580) { 237 } else if (hw->mac.type >= e1000_82580) {
230 phy->ops.reset = igb_phy_hw_reset; 238 phy->ops.reset = igb_phy_hw_reset;
231 phy->ops.read_reg = igb_read_phy_reg_82580; 239 phy->ops.read_reg = igb_read_phy_reg_82580;
232 phy->ops.write_reg = igb_write_phy_reg_82580; 240 phy->ops.write_reg = igb_write_phy_reg_82580;
@@ -262,6 +270,7 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
262 phy->ops.set_d3_lplu_state = igb_set_d3_lplu_state; 270 phy->ops.set_d3_lplu_state = igb_set_d3_lplu_state;
263 break; 271 break;
264 case I82580_I_PHY_ID: 272 case I82580_I_PHY_ID:
273 case I350_I_PHY_ID:
265 phy->type = e1000_phy_82580; 274 phy->type = e1000_phy_82580;
266 phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_82580; 275 phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_82580;
267 phy->ops.get_cable_length = igb_get_cable_length_82580; 276 phy->ops.get_cable_length = igb_get_cable_length_82580;
@@ -1446,7 +1455,6 @@ void igb_vmdq_set_replication_pf(struct e1000_hw *hw, bool enable)
1446 **/ 1455 **/
1447static s32 igb_read_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 *data) 1456static s32 igb_read_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 *data)
1448{ 1457{
1449 u32 mdicnfg = 0;
1450 s32 ret_val; 1458 s32 ret_val;
1451 1459
1452 1460
@@ -1454,15 +1462,6 @@ static s32 igb_read_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 *data)
1454 if (ret_val) 1462 if (ret_val)
1455 goto out; 1463 goto out;
1456 1464
1457 /*
1458 * We config the phy address in MDICNFG register now. Same bits
1459 * as before. The values in MDIC can be written but will be
1460 * ignored. This allows us to call the old function after
1461 * configuring the PHY address in the new register
1462 */
1463 mdicnfg = (hw->phy.addr << E1000_MDIC_PHY_SHIFT);
1464 wr32(E1000_MDICNFG, mdicnfg);
1465
1466 ret_val = igb_read_phy_reg_mdic(hw, offset, data); 1465 ret_val = igb_read_phy_reg_mdic(hw, offset, data);
1467 1466
1468 hw->phy.ops.release(hw); 1467 hw->phy.ops.release(hw);
@@ -1481,7 +1480,6 @@ out:
1481 **/ 1480 **/
1482static s32 igb_write_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 data) 1481static s32 igb_write_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 data)
1483{ 1482{
1484 u32 mdicnfg = 0;
1485 s32 ret_val; 1483 s32 ret_val;
1486 1484
1487 1485
@@ -1489,15 +1487,6 @@ static s32 igb_write_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 data)
1489 if (ret_val) 1487 if (ret_val)
1490 goto out; 1488 goto out;
1491 1489
1492 /*
1493 * We config the phy address in MDICNFG register now. Same bits
1494 * as before. The values in MDIC can be written but will be
1495 * ignored. This allows us to call the old function after
1496 * configuring the PHY address in the new register
1497 */
1498 mdicnfg = (hw->phy.addr << E1000_MDIC_PHY_SHIFT);
1499 wr32(E1000_MDICNFG, mdicnfg);
1500
1501 ret_val = igb_write_phy_reg_mdic(hw, offset, data); 1490 ret_val = igb_write_phy_reg_mdic(hw, offset, data);
1502 1491
1503 hw->phy.ops.release(hw); 1492 hw->phy.ops.release(hw);
diff --git a/drivers/net/igb/e1000_82575.h b/drivers/net/igb/e1000_82575.h
index fbe1c99c193c..cbd1e1259e4d 100644
--- a/drivers/net/igb/e1000_82575.h
+++ b/drivers/net/igb/e1000_82575.h
@@ -38,9 +38,10 @@ extern void igb_rx_fifo_flush_82575(struct e1000_hw *hw);
38 (ID_LED_DEF1_DEF2 << 4) | \ 38 (ID_LED_DEF1_DEF2 << 4) | \
39 (ID_LED_OFF1_ON2)) 39 (ID_LED_OFF1_ON2))
40 40
41#define E1000_RAR_ENTRIES_82575 16 41#define E1000_RAR_ENTRIES_82575 16
42#define E1000_RAR_ENTRIES_82576 24 42#define E1000_RAR_ENTRIES_82576 24
43#define E1000_RAR_ENTRIES_82580 24 43#define E1000_RAR_ENTRIES_82580 24
44#define E1000_RAR_ENTRIES_I350 32
44 45
45#define E1000_SW_SYNCH_MB 0x00000100 46#define E1000_SW_SYNCH_MB 0x00000100
46#define E1000_STAT_DEV_RST_SET 0x00100000 47#define E1000_STAT_DEV_RST_SET 0x00100000
@@ -52,6 +53,7 @@ extern void igb_rx_fifo_flush_82575(struct e1000_hw *hw);
52#define E1000_SRRCTL_DESCTYPE_ADV_ONEBUF 0x02000000 53#define E1000_SRRCTL_DESCTYPE_ADV_ONEBUF 0x02000000
53#define E1000_SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS 0x0A000000 54#define E1000_SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS 0x0A000000
54#define E1000_SRRCTL_DROP_EN 0x80000000 55#define E1000_SRRCTL_DROP_EN 0x80000000
56#define E1000_SRRCTL_TIMESTAMP 0x40000000
55 57
56#define E1000_MRQC_ENABLE_RSS_4Q 0x00000002 58#define E1000_MRQC_ENABLE_RSS_4Q 0x00000002
57#define E1000_MRQC_ENABLE_VMDQ 0x00000003 59#define E1000_MRQC_ENABLE_VMDQ 0x00000003
@@ -108,6 +110,7 @@ union e1000_adv_rx_desc {
108#define E1000_RXDADV_HDRBUFLEN_MASK 0x7FE0 110#define E1000_RXDADV_HDRBUFLEN_MASK 0x7FE0
109#define E1000_RXDADV_HDRBUFLEN_SHIFT 5 111#define E1000_RXDADV_HDRBUFLEN_SHIFT 5
110#define E1000_RXDADV_STAT_TS 0x10000 /* Pkt was time stamped */ 112#define E1000_RXDADV_STAT_TS 0x10000 /* Pkt was time stamped */
113#define E1000_RXDADV_STAT_TSIP 0x08000 /* timestamp in packet */
111 114
112/* Transmit Descriptor - Advanced */ 115/* Transmit Descriptor - Advanced */
113union e1000_adv_tx_desc { 116union e1000_adv_tx_desc {
diff --git a/drivers/net/igb/e1000_defines.h b/drivers/net/igb/e1000_defines.h
index fe6cf1b696c7..31d24e0e76de 100644
--- a/drivers/net/igb/e1000_defines.h
+++ b/drivers/net/igb/e1000_defines.h
@@ -629,6 +629,7 @@
629#define M88E1111_I_PHY_ID 0x01410CC0 629#define M88E1111_I_PHY_ID 0x01410CC0
630#define IGP03E1000_E_PHY_ID 0x02A80390 630#define IGP03E1000_E_PHY_ID 0x02A80390
631#define I82580_I_PHY_ID 0x015403A0 631#define I82580_I_PHY_ID 0x015403A0
632#define I350_I_PHY_ID 0x015403B0
632#define M88_VENDOR 0x0141 633#define M88_VENDOR 0x0141
633 634
634/* M88E1000 Specific Registers */ 635/* M88E1000 Specific Registers */
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index 82a533f5192a..cb8db78b1a05 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -31,6 +31,7 @@
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/io.h> 33#include <linux/io.h>
34#include <linux/netdevice.h>
34 35
35#include "e1000_regs.h" 36#include "e1000_regs.h"
36#include "e1000_defines.h" 37#include "e1000_defines.h"
@@ -53,6 +54,10 @@ struct e1000_hw;
53#define E1000_DEV_ID_82580_SERDES 0x1510 54#define E1000_DEV_ID_82580_SERDES 0x1510
54#define E1000_DEV_ID_82580_SGMII 0x1511 55#define E1000_DEV_ID_82580_SGMII 0x1511
55#define E1000_DEV_ID_82580_COPPER_DUAL 0x1516 56#define E1000_DEV_ID_82580_COPPER_DUAL 0x1516
57#define E1000_DEV_ID_I350_COPPER 0x1521
58#define E1000_DEV_ID_I350_FIBER 0x1522
59#define E1000_DEV_ID_I350_SERDES 0x1523
60#define E1000_DEV_ID_I350_SGMII 0x1524
56 61
57#define E1000_REVISION_2 2 62#define E1000_REVISION_2 2
58#define E1000_REVISION_4 4 63#define E1000_REVISION_4 4
@@ -72,6 +77,7 @@ enum e1000_mac_type {
72 e1000_82575, 77 e1000_82575,
73 e1000_82576, 78 e1000_82576,
74 e1000_82580, 79 e1000_82580,
80 e1000_i350,
75 e1000_num_macs /* List is 1-based, so subtract 1 for true count. */ 81 e1000_num_macs /* List is 1-based, so subtract 1 for true count. */
76}; 82};
77 83
@@ -502,14 +508,11 @@ struct e1000_hw {
502 u8 revision_id; 508 u8 revision_id;
503}; 509};
504 510
505#ifdef DEBUG 511extern struct net_device *igb_get_hw_dev(struct e1000_hw *hw);
506extern char *igb_get_hw_dev_name(struct e1000_hw *hw);
507#define hw_dbg(format, arg...) \ 512#define hw_dbg(format, arg...) \
508 printk(KERN_DEBUG "%s: " format, igb_get_hw_dev_name(hw), ##arg) 513 netdev_dbg(igb_get_hw_dev(hw), format, ##arg)
509#else 514
510#define hw_dbg(format, arg...)
511#endif
512#endif
513/* These functions must be implemented by drivers */ 515/* These functions must be implemented by drivers */
514s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value); 516s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);
515s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value); 517s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value);
518#endif /* _E1000_HW_H_ */
diff --git a/drivers/net/igb/igb.h b/drivers/net/igb/igb.h
index 3b772b822a5d..7d288ccca1ca 100644
--- a/drivers/net/igb/igb.h
+++ b/drivers/net/igb/igb.h
@@ -107,6 +107,7 @@ struct vf_data_storage {
107#define MAXIMUM_ETHERNET_VLAN_SIZE 1522 107#define MAXIMUM_ETHERNET_VLAN_SIZE 1522
108 108
109/* Supported Rx Buffer Sizes */ 109/* Supported Rx Buffer Sizes */
110#define IGB_RXBUFFER_64 64 /* Used for packet split */
110#define IGB_RXBUFFER_128 128 /* Used for packet split */ 111#define IGB_RXBUFFER_128 128 /* Used for packet split */
111#define IGB_RXBUFFER_1024 1024 112#define IGB_RXBUFFER_1024 1024
112#define IGB_RXBUFFER_2048 2048 113#define IGB_RXBUFFER_2048 2048
@@ -323,6 +324,7 @@ struct igb_adapter {
323 324
324#define IGB_82576_TSYNC_SHIFT 19 325#define IGB_82576_TSYNC_SHIFT 19
325#define IGB_82580_TSYNC_SHIFT 24 326#define IGB_82580_TSYNC_SHIFT 24
327#define IGB_TS_HDR_LEN 16
326enum e1000_state_t { 328enum e1000_state_t {
327 __IGB_TESTING, 329 __IGB_TESTING,
328 __IGB_RESETTING, 330 __IGB_RESETTING,
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c
index a4cead12fd98..1d4ee418226d 100644
--- a/drivers/net/igb/igb_ethtool.c
+++ b/drivers/net/igb/igb_ethtool.c
@@ -901,6 +901,49 @@ struct igb_reg_test {
901#define TABLE64_TEST_LO 5 901#define TABLE64_TEST_LO 5
902#define TABLE64_TEST_HI 6 902#define TABLE64_TEST_HI 6
903 903
904/* i350 reg test */
905static struct igb_reg_test reg_test_i350[] = {
906 { E1000_FCAL, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
907 { E1000_FCAH, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
908 { E1000_FCT, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
909 { E1000_VET, 0x100, 1, PATTERN_TEST, 0xFFFF0000, 0xFFFF0000 },
910 { E1000_RDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
911 { E1000_RDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
912 { E1000_RDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
913 { E1000_RDBAL(4), 0x40, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
914 { E1000_RDBAH(4), 0x40, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
915 { E1000_RDLEN(4), 0x40, 4, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
916 /* RDH is read-only for i350, only test RDT. */
917 { E1000_RDT(0), 0x100, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
918 { E1000_RDT(4), 0x40, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
919 { E1000_FCRTH, 0x100, 1, PATTERN_TEST, 0x0000FFF0, 0x0000FFF0 },
920 { E1000_FCTTV, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
921 { E1000_TIPG, 0x100, 1, PATTERN_TEST, 0x3FFFFFFF, 0x3FFFFFFF },
922 { E1000_TDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
923 { E1000_TDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
924 { E1000_TDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
925 { E1000_TDBAL(4), 0x40, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
926 { E1000_TDBAH(4), 0x40, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
927 { E1000_TDLEN(4), 0x40, 4, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
928 { E1000_TDT(0), 0x100, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
929 { E1000_TDT(4), 0x40, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
930 { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
931 { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB0FE, 0x003FFFFB },
932 { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB0FE, 0xFFFFFFFF },
933 { E1000_TCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
934 { E1000_RA, 0, 16, TABLE64_TEST_LO,
935 0xFFFFFFFF, 0xFFFFFFFF },
936 { E1000_RA, 0, 16, TABLE64_TEST_HI,
937 0xC3FFFFFF, 0xFFFFFFFF },
938 { E1000_RA2, 0, 16, TABLE64_TEST_LO,
939 0xFFFFFFFF, 0xFFFFFFFF },
940 { E1000_RA2, 0, 16, TABLE64_TEST_HI,
941 0xC3FFFFFF, 0xFFFFFFFF },
942 { E1000_MTA, 0, 128, TABLE32_TEST,
943 0xFFFFFFFF, 0xFFFFFFFF },
944 { 0, 0, 0, 0 }
945};
946
904/* 82580 reg test */ 947/* 82580 reg test */
905static struct igb_reg_test reg_test_82580[] = { 948static struct igb_reg_test reg_test_82580[] = {
906 { E1000_FCAL, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF }, 949 { E1000_FCAL, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
@@ -1076,6 +1119,10 @@ static int igb_reg_test(struct igb_adapter *adapter, u64 *data)
1076 u32 i, toggle; 1119 u32 i, toggle;
1077 1120
1078 switch (adapter->hw.mac.type) { 1121 switch (adapter->hw.mac.type) {
1122 case e1000_i350:
1123 test = reg_test_i350;
1124 toggle = 0x7FEFF3FF;
1125 break;
1079 case e1000_82580: 1126 case e1000_82580:
1080 test = reg_test_82580; 1127 test = reg_test_82580;
1081 toggle = 0x7FEFF3FF; 1128 toggle = 0x7FEFF3FF;
@@ -1237,6 +1284,9 @@ static int igb_intr_test(struct igb_adapter *adapter, u64 *data)
1237 case e1000_82580: 1284 case e1000_82580:
1238 ics_mask = 0x77DCFED5; 1285 ics_mask = 0x77DCFED5;
1239 break; 1286 break;
1287 case e1000_i350:
1288 ics_mask = 0x77DCFED5;
1289 break;
1240 default: 1290 default:
1241 ics_mask = 0x7FFFFFFF; 1291 ics_mask = 0x7FFFFFFF;
1242 break; 1292 break;
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 01c65c7447e1..2745e17fd021 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -61,6 +61,10 @@ static const struct e1000_info *igb_info_tbl[] = {
61}; 61};
62 62
63static DEFINE_PCI_DEVICE_TABLE(igb_pci_tbl) = { 63static DEFINE_PCI_DEVICE_TABLE(igb_pci_tbl) = {
64 { PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_COPPER), board_82575 },
65 { PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_FIBER), board_82575 },
66 { PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_SERDES), board_82575 },
67 { PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_SGMII), board_82575 },
64 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_COPPER), board_82575 }, 68 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_COPPER), board_82575 },
65 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_FIBER), board_82575 }, 69 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_FIBER), board_82575 },
66 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_SERDES), board_82575 }, 70 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82580_SERDES), board_82575 },
@@ -222,43 +226,17 @@ static cycle_t igb_read_clock(const struct cyclecounter *tc)
222 return stamp; 226 return stamp;
223} 227}
224 228
225#ifdef DEBUG
226/** 229/**
227 * igb_get_hw_dev_name - return device name string 230 * igb_get_hw_dev - return device
228 * used by hardware layer to print debugging information 231 * used by hardware layer to print debugging information
229 **/ 232 **/
230char *igb_get_hw_dev_name(struct e1000_hw *hw) 233struct net_device *igb_get_hw_dev(struct e1000_hw *hw)
231{ 234{
232 struct igb_adapter *adapter = hw->back; 235 struct igb_adapter *adapter = hw->back;
233 return adapter->netdev->name; 236 return adapter->netdev;
234} 237}
235 238
236/** 239/**
237 * igb_get_time_str - format current NIC and system time as string
238 */
239static char *igb_get_time_str(struct igb_adapter *adapter,
240 char buffer[160])
241{
242 cycle_t hw = adapter->cycles.read(&adapter->cycles);
243 struct timespec nic = ns_to_timespec(timecounter_read(&adapter->clock));
244 struct timespec sys;
245 struct timespec delta;
246 getnstimeofday(&sys);
247
248 delta = timespec_sub(nic, sys);
249
250 sprintf(buffer,
251 "HW %llu, NIC %ld.%09lus, SYS %ld.%09lus, NIC-SYS %lds + %09luns",
252 hw,
253 (long)nic.tv_sec, nic.tv_nsec,
254 (long)sys.tv_sec, sys.tv_nsec,
255 (long)delta.tv_sec, delta.tv_nsec);
256
257 return buffer;
258}
259#endif
260
261/**
262 * igb_init_module - Driver Registration Routine 240 * igb_init_module - Driver Registration Routine
263 * 241 *
264 * igb_init_module is the first routine called when the driver is 242 * igb_init_module is the first routine called when the driver is
@@ -327,6 +305,7 @@ static void igb_cache_ring_register(struct igb_adapter *adapter)
327 } 305 }
328 case e1000_82575: 306 case e1000_82575:
329 case e1000_82580: 307 case e1000_82580:
308 case e1000_i350:
330 default: 309 default:
331 for (; i < adapter->num_rx_queues; i++) 310 for (; i < adapter->num_rx_queues; i++)
332 adapter->rx_ring[i]->reg_idx = rbase_offset + i; 311 adapter->rx_ring[i]->reg_idx = rbase_offset + i;
@@ -470,6 +449,7 @@ static void igb_assign_vector(struct igb_q_vector *q_vector, int msix_vector)
470 q_vector->eims_value = 1 << msix_vector; 449 q_vector->eims_value = 1 << msix_vector;
471 break; 450 break;
472 case e1000_82580: 451 case e1000_82580:
452 case e1000_i350:
473 /* 82580 uses the same table-based approach as 82576 but has fewer 453 /* 82580 uses the same table-based approach as 82576 but has fewer
474 entries as a result we carry over for queues greater than 4. */ 454 entries as a result we carry over for queues greater than 4. */
475 if (rx_queue > IGB_N0_QUEUE) { 455 if (rx_queue > IGB_N0_QUEUE) {
@@ -550,6 +530,7 @@ static void igb_configure_msix(struct igb_adapter *adapter)
550 530
551 case e1000_82576: 531 case e1000_82576:
552 case e1000_82580: 532 case e1000_82580:
533 case e1000_i350:
553 /* Turn on MSI-X capability first, or our settings 534 /* Turn on MSI-X capability first, or our settings
554 * won't stick. And it will take days to debug. */ 535 * won't stick. And it will take days to debug. */
555 wr32(E1000_GPIE, E1000_GPIE_MSIX_MODE | 536 wr32(E1000_GPIE, E1000_GPIE_MSIX_MODE |
@@ -1252,6 +1233,7 @@ void igb_reset(struct igb_adapter *adapter)
1252 * To take effect CTRL.RST is required. 1233 * To take effect CTRL.RST is required.
1253 */ 1234 */
1254 switch (mac->type) { 1235 switch (mac->type) {
1236 case e1000_i350:
1255 case e1000_82580: 1237 case e1000_82580:
1256 pba = rd32(E1000_RXPBS); 1238 pba = rd32(E1000_RXPBS);
1257 pba = igb_rxpbs_adjust_82580(pba); 1239 pba = igb_rxpbs_adjust_82580(pba);
@@ -1824,6 +1806,7 @@ static void igb_init_hw_timer(struct igb_adapter *adapter)
1824 struct e1000_hw *hw = &adapter->hw; 1806 struct e1000_hw *hw = &adapter->hw;
1825 1807
1826 switch (hw->mac.type) { 1808 switch (hw->mac.type) {
1809 case e1000_i350:
1827 case e1000_82580: 1810 case e1000_82580:
1828 memset(&adapter->cycles, 0, sizeof(adapter->cycles)); 1811 memset(&adapter->cycles, 0, sizeof(adapter->cycles));
1829 adapter->cycles.read = igb_read_clock; 1812 adapter->cycles.read = igb_read_clock;
@@ -2337,6 +2320,7 @@ static void igb_setup_mrqc(struct igb_adapter *adapter)
2337 if (adapter->vfs_allocated_count) { 2320 if (adapter->vfs_allocated_count) {
2338 /* 82575 and 82576 supports 2 RSS queues for VMDq */ 2321 /* 82575 and 82576 supports 2 RSS queues for VMDq */
2339 switch (hw->mac.type) { 2322 switch (hw->mac.type) {
2323 case e1000_i350:
2340 case e1000_82580: 2324 case e1000_82580:
2341 num_rx_queues = 1; 2325 num_rx_queues = 1;
2342 shift = 0; 2326 shift = 0;
@@ -2588,6 +2572,8 @@ void igb_configure_rx_ring(struct igb_adapter *adapter,
2588 E1000_SRRCTL_BSIZEPKT_SHIFT; 2572 E1000_SRRCTL_BSIZEPKT_SHIFT;
2589 srrctl |= E1000_SRRCTL_DESCTYPE_ADV_ONEBUF; 2573 srrctl |= E1000_SRRCTL_DESCTYPE_ADV_ONEBUF;
2590 } 2574 }
2575 if (hw->mac.type == e1000_82580)
2576 srrctl |= E1000_SRRCTL_TIMESTAMP;
2591 /* Only set Drop Enable if we are supporting multiple queues */ 2577 /* Only set Drop Enable if we are supporting multiple queues */
2592 if (adapter->vfs_allocated_count || adapter->num_rx_queues > 1) 2578 if (adapter->vfs_allocated_count || adapter->num_rx_queues > 1)
2593 srrctl |= E1000_SRRCTL_DROP_EN; 2579 srrctl |= E1000_SRRCTL_DROP_EN;
@@ -2874,7 +2860,7 @@ static int igb_write_mc_addr_list(struct net_device *netdev)
2874{ 2860{
2875 struct igb_adapter *adapter = netdev_priv(netdev); 2861 struct igb_adapter *adapter = netdev_priv(netdev);
2876 struct e1000_hw *hw = &adapter->hw; 2862 struct e1000_hw *hw = &adapter->hw;
2877 struct dev_mc_list *mc_ptr; 2863 struct netdev_hw_addr *ha;
2878 u8 *mta_list; 2864 u8 *mta_list;
2879 int i; 2865 int i;
2880 2866
@@ -2891,8 +2877,8 @@ static int igb_write_mc_addr_list(struct net_device *netdev)
2891 2877
2892 /* The shared function expects a packed array of only addresses. */ 2878 /* The shared function expects a packed array of only addresses. */
2893 i = 0; 2879 i = 0;
2894 netdev_for_each_mc_addr(mc_ptr, netdev) 2880 netdev_for_each_mc_addr(ha, netdev)
2895 memcpy(mta_list + (i++ * ETH_ALEN), mc_ptr->dmi_addr, ETH_ALEN); 2881 memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN);
2896 2882
2897 igb_update_mc_addr_list(hw, mta_list, i); 2883 igb_update_mc_addr_list(hw, mta_list, i);
2898 kfree(mta_list); 2884 kfree(mta_list);
@@ -3918,6 +3904,9 @@ static int igb_change_mtu(struct net_device *netdev, int new_mtu)
3918 * i.e. RXBUFFER_2048 --> size-4096 slab 3904 * i.e. RXBUFFER_2048 --> size-4096 slab
3919 */ 3905 */
3920 3906
3907 if (adapter->hw.mac.type == e1000_82580)
3908 max_frame += IGB_TS_HDR_LEN;
3909
3921 if (max_frame <= IGB_RXBUFFER_1024) 3910 if (max_frame <= IGB_RXBUFFER_1024)
3922 rx_buffer_len = IGB_RXBUFFER_1024; 3911 rx_buffer_len = IGB_RXBUFFER_1024;
3923 else if (max_frame <= MAXIMUM_ETHERNET_VLAN_SIZE) 3912 else if (max_frame <= MAXIMUM_ETHERNET_VLAN_SIZE)
@@ -3925,6 +3914,14 @@ static int igb_change_mtu(struct net_device *netdev, int new_mtu)
3925 else 3914 else
3926 rx_buffer_len = IGB_RXBUFFER_128; 3915 rx_buffer_len = IGB_RXBUFFER_128;
3927 3916
3917 if ((max_frame == ETH_FRAME_LEN + ETH_FCS_LEN + IGB_TS_HDR_LEN) ||
3918 (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE + IGB_TS_HDR_LEN))
3919 rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE + IGB_TS_HDR_LEN;
3920
3921 if ((adapter->hw.mac.type == e1000_82580) &&
3922 (rx_buffer_len == IGB_RXBUFFER_128))
3923 rx_buffer_len += IGB_RXBUFFER_64;
3924
3928 if (netif_running(netdev)) 3925 if (netif_running(netdev))
3929 igb_down(adapter); 3926 igb_down(adapter);
3930 3927
@@ -5141,7 +5138,7 @@ static inline void igb_rx_checksum_adv(struct igb_ring *ring,
5141 dev_dbg(&ring->pdev->dev, "cksum success: bits %08X\n", status_err); 5138 dev_dbg(&ring->pdev->dev, "cksum success: bits %08X\n", status_err);
5142} 5139}
5143 5140
5144static inline void igb_rx_hwtstamp(struct igb_q_vector *q_vector, u32 staterr, 5141static void igb_rx_hwtstamp(struct igb_q_vector *q_vector, u32 staterr,
5145 struct sk_buff *skb) 5142 struct sk_buff *skb)
5146{ 5143{
5147 struct igb_adapter *adapter = q_vector->adapter; 5144 struct igb_adapter *adapter = q_vector->adapter;
@@ -5159,13 +5156,18 @@ static inline void igb_rx_hwtstamp(struct igb_q_vector *q_vector, u32 staterr,
5159 * If nothing went wrong, then it should have a skb_shared_tx that we 5156 * If nothing went wrong, then it should have a skb_shared_tx that we
5160 * can turn into a skb_shared_hwtstamps. 5157 * can turn into a skb_shared_hwtstamps.
5161 */ 5158 */
5162 if (likely(!(staterr & E1000_RXDADV_STAT_TS))) 5159 if (staterr & E1000_RXDADV_STAT_TSIP) {
5163 return; 5160 u32 *stamp = (u32 *)skb->data;
5164 if (!(rd32(E1000_TSYNCRXCTL) & E1000_TSYNCRXCTL_VALID)) 5161 regval = le32_to_cpu(*(stamp + 2));
5165 return; 5162 regval |= (u64)le32_to_cpu(*(stamp + 3)) << 32;
5163 skb_pull(skb, IGB_TS_HDR_LEN);
5164 } else {
5165 if(!(rd32(E1000_TSYNCRXCTL) & E1000_TSYNCRXCTL_VALID))
5166 return;
5166 5167
5167 regval = rd32(E1000_RXSTMPL); 5168 regval = rd32(E1000_RXSTMPL);
5168 regval |= (u64)rd32(E1000_RXSTMPH) << 32; 5169 regval |= (u64)rd32(E1000_RXSTMPH) << 32;
5170 }
5169 5171
5170 igb_systim_to_hwtstamp(adapter, skb_hwtstamps(skb), regval); 5172 igb_systim_to_hwtstamp(adapter, skb_hwtstamps(skb), regval);
5171} 5173}
@@ -5273,7 +5275,8 @@ send_up:
5273 goto next_desc; 5275 goto next_desc;
5274 } 5276 }
5275 5277
5276 igb_rx_hwtstamp(q_vector, staterr, skb); 5278 if (staterr & (E1000_RXDADV_STAT_TSIP | E1000_RXDADV_STAT_TS))
5279 igb_rx_hwtstamp(q_vector, staterr, skb);
5277 total_bytes += skb->len; 5280 total_bytes += skb->len;
5278 total_packets++; 5281 total_packets++;
5279 5282
@@ -5553,6 +5556,16 @@ static int igb_hwtstamp_ioctl(struct net_device *netdev,
5553 return 0; 5556 return 0;
5554 } 5557 }
5555 5558
5559 /*
5560 * Per-packet timestamping only works if all packets are
5561 * timestamped, so enable timestamping in all packets as
5562 * long as one rx filter was configured.
5563 */
5564 if ((hw->mac.type == e1000_82580) && tsync_rx_ctl) {
5565 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED;
5566 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL;
5567 }
5568
5556 /* enable/disable TX */ 5569 /* enable/disable TX */
5557 regval = rd32(E1000_TSYNCTXCTL); 5570 regval = rd32(E1000_TSYNCTXCTL);
5558 regval &= ~E1000_TSYNCTXCTL_ENABLED; 5571 regval &= ~E1000_TSYNCTXCTL_ENABLED;
@@ -6129,19 +6142,25 @@ static void igb_vmm_control(struct igb_adapter *adapter)
6129 struct e1000_hw *hw = &adapter->hw; 6142 struct e1000_hw *hw = &adapter->hw;
6130 u32 reg; 6143 u32 reg;
6131 6144
6132 /* replication is not supported for 82575 */ 6145 switch (hw->mac.type) {
6133 if (hw->mac.type == e1000_82575) 6146 case e1000_82575:
6147 default:
6148 /* replication is not supported for 82575 */
6134 return; 6149 return;
6135 6150 case e1000_82576:
6136 /* enable replication vlan tag stripping */ 6151 /* notify HW that the MAC is adding vlan tags */
6137 reg = rd32(E1000_RPLOLR); 6152 reg = rd32(E1000_DTXCTL);
6138 reg |= E1000_RPLOLR_STRVLAN; 6153 reg |= E1000_DTXCTL_VLAN_ADDED;
6139 wr32(E1000_RPLOLR, reg); 6154 wr32(E1000_DTXCTL, reg);
6140 6155 case e1000_82580:
6141 /* notify HW that the MAC is adding vlan tags */ 6156 /* enable replication vlan tag stripping */
6142 reg = rd32(E1000_DTXCTL); 6157 reg = rd32(E1000_RPLOLR);
6143 reg |= E1000_DTXCTL_VLAN_ADDED; 6158 reg |= E1000_RPLOLR_STRVLAN;
6144 wr32(E1000_DTXCTL, reg); 6159 wr32(E1000_RPLOLR, reg);
6160 case e1000_i350:
6161 /* none of the above registers are supported by i350 */
6162 break;
6163 }
6145 6164
6146 if (adapter->vfs_allocated_count) { 6165 if (adapter->vfs_allocated_count) {
6147 igb_vmdq_set_loopback_pf(hw, true); 6166 igb_vmdq_set_loopback_pf(hw, true);
diff --git a/drivers/net/igbvf/netdev.c b/drivers/net/igbvf/netdev.c
index b41037ed8083..868855078ebc 100644
--- a/drivers/net/igbvf/netdev.c
+++ b/drivers/net/igbvf/netdev.c
@@ -1397,7 +1397,7 @@ static void igbvf_set_multi(struct net_device *netdev)
1397{ 1397{
1398 struct igbvf_adapter *adapter = netdev_priv(netdev); 1398 struct igbvf_adapter *adapter = netdev_priv(netdev);
1399 struct e1000_hw *hw = &adapter->hw; 1399 struct e1000_hw *hw = &adapter->hw;
1400 struct dev_mc_list *mc_ptr; 1400 struct netdev_hw_addr *ha;
1401 u8 *mta_list = NULL; 1401 u8 *mta_list = NULL;
1402 int i; 1402 int i;
1403 1403
@@ -1412,8 +1412,8 @@ static void igbvf_set_multi(struct net_device *netdev)
1412 1412
1413 /* prepare a packed array of only addresses. */ 1413 /* prepare a packed array of only addresses. */
1414 i = 0; 1414 i = 0;
1415 netdev_for_each_mc_addr(mc_ptr, netdev) 1415 netdev_for_each_mc_addr(ha, netdev)
1416 memcpy(mta_list + (i++ * ETH_ALEN), mc_ptr->dmi_addr, ETH_ALEN); 1416 memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN);
1417 1417
1418 hw->mac.ops.update_mc_addr_list(hw, mta_list, i, 0, 0); 1418 hw->mac.ops.update_mc_addr_list(hw, mta_list, i, 0, 0);
1419 kfree(mta_list); 1419 kfree(mta_list);
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index 70871b9b045a..57d873da9789 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -1664,7 +1664,7 @@ static int ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1664 1664
1665static void ioc3_set_multicast_list(struct net_device *dev) 1665static void ioc3_set_multicast_list(struct net_device *dev)
1666{ 1666{
1667 struct dev_mc_list *dmi; 1667 struct netdev_hw_addr *ha;
1668 struct ioc3_private *ip = netdev_priv(dev); 1668 struct ioc3_private *ip = netdev_priv(dev);
1669 struct ioc3 *ioc3 = ip->regs; 1669 struct ioc3 *ioc3 = ip->regs;
1670 u64 ehar = 0; 1670 u64 ehar = 0;
@@ -1688,8 +1688,8 @@ static void ioc3_set_multicast_list(struct net_device *dev)
1688 ip->ehar_h = 0xffffffff; 1688 ip->ehar_h = 0xffffffff;
1689 ip->ehar_l = 0xffffffff; 1689 ip->ehar_l = 0xffffffff;
1690 } else { 1690 } else {
1691 netdev_for_each_mc_addr(dmi, dev) { 1691 netdev_for_each_mc_addr(ha, dev) {
1692 char *addr = dmi->dmi_addr; 1692 char *addr = ha->addr;
1693 1693
1694 if (!(*addr & 1)) 1694 if (!(*addr & 1))
1695 continue; 1695 continue;
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c
index 150415e83f61..67cfc7d9d895 100644
--- a/drivers/net/ipg.c
+++ b/drivers/net/ipg.c
@@ -569,7 +569,7 @@ static int ipg_config_autoneg(struct net_device *dev)
569static void ipg_nic_set_multicast_list(struct net_device *dev) 569static void ipg_nic_set_multicast_list(struct net_device *dev)
570{ 570{
571 void __iomem *ioaddr = ipg_ioaddr(dev); 571 void __iomem *ioaddr = ipg_ioaddr(dev);
572 struct dev_mc_list *mc_list_ptr; 572 struct netdev_hw_addr *ha;
573 unsigned int hashindex; 573 unsigned int hashindex;
574 u32 hashtable[2]; 574 u32 hashtable[2];
575 u8 receivemode; 575 u8 receivemode;
@@ -608,9 +608,9 @@ static void ipg_nic_set_multicast_list(struct net_device *dev)
608 hashtable[1] = 0x00000000; 608 hashtable[1] = 0x00000000;
609 609
610 /* Cycle through all multicast addresses to filter. */ 610 /* Cycle through all multicast addresses to filter. */
611 netdev_for_each_mc_addr(mc_list_ptr, dev) { 611 netdev_for_each_mc_addr(ha, dev) {
612 /* Calculate CRC result for each multicast address. */ 612 /* Calculate CRC result for each multicast address. */
613 hashindex = crc32_le(0xffffffff, mc_list_ptr->dmi_addr, 613 hashindex = crc32_le(0xffffffff, ha->addr,
614 ETH_ALEN); 614 ETH_ALEN);
615 615
616 /* Use only the least significant 6 bits. */ 616 /* Use only the least significant 6 bits. */
@@ -1547,8 +1547,6 @@ static void ipg_reset_after_host_error(struct work_struct *work)
1547 container_of(work, struct ipg_nic_private, task.work); 1547 container_of(work, struct ipg_nic_private, task.work);
1548 struct net_device *dev = sp->dev; 1548 struct net_device *dev = sp->dev;
1549 1549
1550 IPG_DDEBUG_MSG("DMACtrl = %8.8x\n", ioread32(sp->ioaddr + IPG_DMACTRL));
1551
1552 /* 1550 /*
1553 * Acknowledge HostError interrupt by resetting 1551 * Acknowledge HostError interrupt by resetting
1554 * IPG DMA and HOST. 1552 * IPG DMA and HOST.
@@ -1825,9 +1823,6 @@ static int ipg_nic_stop(struct net_device *dev)
1825 1823
1826 netif_stop_queue(dev); 1824 netif_stop_queue(dev);
1827 1825
1828 IPG_DDEBUG_MSG("RFDlistendCount = %i\n", sp->RFDlistendCount);
1829 IPG_DDEBUG_MSG("RFDListCheckedCount = %i\n", sp->rxdCheckedCount);
1830 IPG_DDEBUG_MSG("EmptyRFDListCount = %i\n", sp->EmptyRFDListCount);
1831 IPG_DUMPTFDLIST(dev); 1826 IPG_DUMPTFDLIST(dev);
1832 1827
1833 do { 1828 do {
diff --git a/drivers/net/ipg.h b/drivers/net/ipg.h
index dfc2541bb556..6ce027355fcf 100644
--- a/drivers/net/ipg.h
+++ b/drivers/net/ipg.h
@@ -29,7 +29,7 @@
29/* GMII based PHY IDs */ 29/* GMII based PHY IDs */
30#define NS 0x2000 30#define NS 0x2000
31#define MARVELL 0x0141 31#define MARVELL 0x0141
32#define ICPLUS_PHY 0x243 32#define ICPLUS_PHY 0x243
33 33
34/* NIC Physical Layer Device MII register fields. */ 34/* NIC Physical Layer Device MII register fields. */
35#define MII_PHY_SELECTOR_IEEE8023 0x0001 35#define MII_PHY_SELECTOR_IEEE8023 0x0001
@@ -96,31 +96,31 @@ enum ipg_regs {
96}; 96};
97 97
98/* Ethernet MIB statistic register offsets. */ 98/* Ethernet MIB statistic register offsets. */
99#define IPG_OCTETRCVOK 0xA8 99#define IPG_OCTETRCVOK 0xA8
100#define IPG_MCSTOCTETRCVDOK 0xAC 100#define IPG_MCSTOCTETRCVDOK 0xAC
101#define IPG_BCSTOCTETRCVOK 0xB0 101#define IPG_BCSTOCTETRCVOK 0xB0
102#define IPG_FRAMESRCVDOK 0xB4 102#define IPG_FRAMESRCVDOK 0xB4
103#define IPG_MCSTFRAMESRCVDOK 0xB8 103#define IPG_MCSTFRAMESRCVDOK 0xB8
104#define IPG_BCSTFRAMESRCVDOK 0xBE 104#define IPG_BCSTFRAMESRCVDOK 0xBE
105#define IPG_MACCONTROLFRAMESRCVD 0xC6 105#define IPG_MACCONTROLFRAMESRCVD 0xC6
106#define IPG_FRAMETOOLONGERRRORS 0xC8 106#define IPG_FRAMETOOLONGERRRORS 0xC8
107#define IPG_INRANGELENGTHERRORS 0xCA 107#define IPG_INRANGELENGTHERRORS 0xCA
108#define IPG_FRAMECHECKSEQERRORS 0xCC 108#define IPG_FRAMECHECKSEQERRORS 0xCC
109#define IPG_FRAMESLOSTRXERRORS 0xCE 109#define IPG_FRAMESLOSTRXERRORS 0xCE
110#define IPG_OCTETXMTOK 0xD0 110#define IPG_OCTETXMTOK 0xD0
111#define IPG_MCSTOCTETXMTOK 0xD4 111#define IPG_MCSTOCTETXMTOK 0xD4
112#define IPG_BCSTOCTETXMTOK 0xD8 112#define IPG_BCSTOCTETXMTOK 0xD8
113#define IPG_FRAMESXMTDOK 0xDC 113#define IPG_FRAMESXMTDOK 0xDC
114#define IPG_MCSTFRAMESXMTDOK 0xE0 114#define IPG_MCSTFRAMESXMTDOK 0xE0
115#define IPG_FRAMESWDEFERREDXMT 0xE4 115#define IPG_FRAMESWDEFERREDXMT 0xE4
116#define IPG_LATECOLLISIONS 0xE8 116#define IPG_LATECOLLISIONS 0xE8
117#define IPG_MULTICOLFRAMES 0xEC 117#define IPG_MULTICOLFRAMES 0xEC
118#define IPG_SINGLECOLFRAMES 0xF0 118#define IPG_SINGLECOLFRAMES 0xF0
119#define IPG_BCSTFRAMESXMTDOK 0xF6 119#define IPG_BCSTFRAMESXMTDOK 0xF6
120#define IPG_CARRIERSENSEERRORS 0xF8 120#define IPG_CARRIERSENSEERRORS 0xF8
121#define IPG_MACCONTROLFRAMESXMTDOK 0xFA 121#define IPG_MACCONTROLFRAMESXMTDOK 0xFA
122#define IPG_FRAMESABORTXSCOLLS 0xFC 122#define IPG_FRAMESABORTXSCOLLS 0xFC
123#define IPG_FRAMESWEXDEFERRAL 0xFE 123#define IPG_FRAMESWEXDEFERRAL 0xFE
124 124
125/* RMON statistic register offsets. */ 125/* RMON statistic register offsets. */
126#define IPG_ETHERSTATSCOLLISIONS 0x100 126#define IPG_ETHERSTATSCOLLISIONS 0x100
@@ -134,8 +134,8 @@ enum ipg_regs {
134#define IPG_ETHERSTATSPKTS1024TO1518OCTESTSTRANSMIT 0x120 134#define IPG_ETHERSTATSPKTS1024TO1518OCTESTSTRANSMIT 0x120
135#define IPG_ETHERSTATSCRCALIGNERRORS 0x124 135#define IPG_ETHERSTATSCRCALIGNERRORS 0x124
136#define IPG_ETHERSTATSUNDERSIZEPKTS 0x128 136#define IPG_ETHERSTATSUNDERSIZEPKTS 0x128
137#define IPG_ETHERSTATSFRAGMENTS 0x12C 137#define IPG_ETHERSTATSFRAGMENTS 0x12C
138#define IPG_ETHERSTATSJABBERS 0x130 138#define IPG_ETHERSTATSJABBERS 0x130
139#define IPG_ETHERSTATSOCTETS 0x134 139#define IPG_ETHERSTATSOCTETS 0x134
140#define IPG_ETHERSTATSPKTS 0x138 140#define IPG_ETHERSTATSPKTS 0x138
141#define IPG_ETHERSTATSPKTS64OCTESTS 0x13C 141#define IPG_ETHERSTATSPKTS64OCTESTS 0x13C
@@ -154,10 +154,10 @@ enum ipg_regs {
154#define IPG_ETHERSTATSDROPEVENTS 0xCE 154#define IPG_ETHERSTATSDROPEVENTS 0xCE
155 155
156/* Serial EEPROM offsets */ 156/* Serial EEPROM offsets */
157#define IPG_EEPROM_CONFIGPARAM 0x00 157#define IPG_EEPROM_CONFIGPARAM 0x00
158#define IPG_EEPROM_ASICCTRL 0x01 158#define IPG_EEPROM_ASICCTRL 0x01
159#define IPG_EEPROM_SUBSYSTEMVENDORID 0x02 159#define IPG_EEPROM_SUBSYSTEMVENDORID 0x02
160#define IPG_EEPROM_SUBSYSTEMID 0x03 160#define IPG_EEPROM_SUBSYSTEMID 0x03
161#define IPG_EEPROM_STATIONADDRESS0 0x10 161#define IPG_EEPROM_STATIONADDRESS0 0x10
162#define IPG_EEPROM_STATIONADDRESS1 0x11 162#define IPG_EEPROM_STATIONADDRESS1 0x11
163#define IPG_EEPROM_STATIONADDRESS2 0x12 163#define IPG_EEPROM_STATIONADDRESS2 0x12
@@ -168,16 +168,16 @@ enum ipg_regs {
168 168
169/* IOBaseAddress */ 169/* IOBaseAddress */
170#define IPG_PIB_RSVD_MASK 0xFFFFFE01 170#define IPG_PIB_RSVD_MASK 0xFFFFFE01
171#define IPG_PIB_IOBASEADDRESS 0xFFFFFF00 171#define IPG_PIB_IOBASEADDRESS 0xFFFFFF00
172#define IPG_PIB_IOBASEADDRIND 0x00000001 172#define IPG_PIB_IOBASEADDRIND 0x00000001
173 173
174/* MemBaseAddress */ 174/* MemBaseAddress */
175#define IPG_PMB_RSVD_MASK 0xFFFFFE07 175#define IPG_PMB_RSVD_MASK 0xFFFFFE07
176#define IPG_PMB_MEMBASEADDRIND 0x00000001 176#define IPG_PMB_MEMBASEADDRIND 0x00000001
177#define IPG_PMB_MEMMAPTYPE 0x00000006 177#define IPG_PMB_MEMMAPTYPE 0x00000006
178#define IPG_PMB_MEMMAPTYPE0 0x00000002 178#define IPG_PMB_MEMMAPTYPE0 0x00000002
179#define IPG_PMB_MEMMAPTYPE1 0x00000004 179#define IPG_PMB_MEMMAPTYPE1 0x00000004
180#define IPG_PMB_MEMBASEADDRESS 0xFFFFFE00 180#define IPG_PMB_MEMBASEADDRESS 0xFFFFFE00
181 181
182/* ConfigStatus */ 182/* ConfigStatus */
183#define IPG_CS_RSVD_MASK 0xFFB0 183#define IPG_CS_RSVD_MASK 0xFFB0
@@ -196,20 +196,20 @@ enum ipg_regs {
196 196
197/* TFDList, TFC */ 197/* TFDList, TFC */
198#define IPG_TFC_RSVD_MASK 0x0000FFFF9FFFFFFF 198#define IPG_TFC_RSVD_MASK 0x0000FFFF9FFFFFFF
199#define IPG_TFC_FRAMEID 0x000000000000FFFF 199#define IPG_TFC_FRAMEID 0x000000000000FFFF
200#define IPG_TFC_WORDALIGN 0x0000000000030000 200#define IPG_TFC_WORDALIGN 0x0000000000030000
201#define IPG_TFC_WORDALIGNTODWORD 0x0000000000000000 201#define IPG_TFC_WORDALIGNTODWORD 0x0000000000000000
202#define IPG_TFC_WORDALIGNTOWORD 0x0000000000020000 202#define IPG_TFC_WORDALIGNTOWORD 0x0000000000020000
203#define IPG_TFC_WORDALIGNDISABLED 0x0000000000030000 203#define IPG_TFC_WORDALIGNDISABLED 0x0000000000030000
204#define IPG_TFC_TCPCHECKSUMENABLE 0x0000000000040000 204#define IPG_TFC_TCPCHECKSUMENABLE 0x0000000000040000
205#define IPG_TFC_UDPCHECKSUMENABLE 0x0000000000080000 205#define IPG_TFC_UDPCHECKSUMENABLE 0x0000000000080000
206#define IPG_TFC_IPCHECKSUMENABLE 0x0000000000100000 206#define IPG_TFC_IPCHECKSUMENABLE 0x0000000000100000
207#define IPG_TFC_FCSAPPENDDISABLE 0x0000000000200000 207#define IPG_TFC_FCSAPPENDDISABLE 0x0000000000200000
208#define IPG_TFC_TXINDICATE 0x0000000000400000 208#define IPG_TFC_TXINDICATE 0x0000000000400000
209#define IPG_TFC_TXDMAINDICATE 0x0000000000800000 209#define IPG_TFC_TXDMAINDICATE 0x0000000000800000
210#define IPG_TFC_FRAGCOUNT 0x000000000F000000 210#define IPG_TFC_FRAGCOUNT 0x000000000F000000
211#define IPG_TFC_VLANTAGINSERT 0x0000000010000000 211#define IPG_TFC_VLANTAGINSERT 0x0000000010000000
212#define IPG_TFC_TFDDONE 0x0000000080000000 212#define IPG_TFC_TFDDONE 0x0000000080000000
213#define IPG_TFC_VID 0x00000FFF00000000 213#define IPG_TFC_VID 0x00000FFF00000000
214#define IPG_TFC_CFI 0x0000100000000000 214#define IPG_TFC_CFI 0x0000100000000000
215#define IPG_TFC_USERPRIORITY 0x0000E00000000000 215#define IPG_TFC_USERPRIORITY 0x0000E00000000000
@@ -217,35 +217,35 @@ enum ipg_regs {
217/* TFDList, FragInfo */ 217/* TFDList, FragInfo */
218#define IPG_TFI_RSVD_MASK 0xFFFF00FFFFFFFFFF 218#define IPG_TFI_RSVD_MASK 0xFFFF00FFFFFFFFFF
219#define IPG_TFI_FRAGADDR 0x000000FFFFFFFFFF 219#define IPG_TFI_FRAGADDR 0x000000FFFFFFFFFF
220#define IPG_TFI_FRAGLEN 0xFFFF000000000000LL 220#define IPG_TFI_FRAGLEN 0xFFFF000000000000LL
221 221
222/* RFD data structure masks. */ 222/* RFD data structure masks. */
223 223
224/* RFDList, RFS */ 224/* RFDList, RFS */
225#define IPG_RFS_RSVD_MASK 0x0000FFFFFFFFFFFF 225#define IPG_RFS_RSVD_MASK 0x0000FFFFFFFFFFFF
226#define IPG_RFS_RXFRAMELEN 0x000000000000FFFF 226#define IPG_RFS_RXFRAMELEN 0x000000000000FFFF
227#define IPG_RFS_RXFIFOOVERRUN 0x0000000000010000 227#define IPG_RFS_RXFIFOOVERRUN 0x0000000000010000
228#define IPG_RFS_RXRUNTFRAME 0x0000000000020000 228#define IPG_RFS_RXRUNTFRAME 0x0000000000020000
229#define IPG_RFS_RXALIGNMENTERROR 0x0000000000040000 229#define IPG_RFS_RXALIGNMENTERROR 0x0000000000040000
230#define IPG_RFS_RXFCSERROR 0x0000000000080000 230#define IPG_RFS_RXFCSERROR 0x0000000000080000
231#define IPG_RFS_RXOVERSIZEDFRAME 0x0000000000100000 231#define IPG_RFS_RXOVERSIZEDFRAME 0x0000000000100000
232#define IPG_RFS_RXLENGTHERROR 0x0000000000200000 232#define IPG_RFS_RXLENGTHERROR 0x0000000000200000
233#define IPG_RFS_VLANDETECTED 0x0000000000400000 233#define IPG_RFS_VLANDETECTED 0x0000000000400000
234#define IPG_RFS_TCPDETECTED 0x0000000000800000 234#define IPG_RFS_TCPDETECTED 0x0000000000800000
235#define IPG_RFS_TCPERROR 0x0000000001000000 235#define IPG_RFS_TCPERROR 0x0000000001000000
236#define IPG_RFS_UDPDETECTED 0x0000000002000000 236#define IPG_RFS_UDPDETECTED 0x0000000002000000
237#define IPG_RFS_UDPERROR 0x0000000004000000 237#define IPG_RFS_UDPERROR 0x0000000004000000
238#define IPG_RFS_IPDETECTED 0x0000000008000000 238#define IPG_RFS_IPDETECTED 0x0000000008000000
239#define IPG_RFS_IPERROR 0x0000000010000000 239#define IPG_RFS_IPERROR 0x0000000010000000
240#define IPG_RFS_FRAMESTART 0x0000000020000000 240#define IPG_RFS_FRAMESTART 0x0000000020000000
241#define IPG_RFS_FRAMEEND 0x0000000040000000 241#define IPG_RFS_FRAMEEND 0x0000000040000000
242#define IPG_RFS_RFDDONE 0x0000000080000000 242#define IPG_RFS_RFDDONE 0x0000000080000000
243#define IPG_RFS_TCI 0x0000FFFF00000000 243#define IPG_RFS_TCI 0x0000FFFF00000000
244 244
245/* RFDList, FragInfo */ 245/* RFDList, FragInfo */
246#define IPG_RFI_RSVD_MASK 0xFFFF00FFFFFFFFFF 246#define IPG_RFI_RSVD_MASK 0xFFFF00FFFFFFFFFF
247#define IPG_RFI_FRAGADDR 0x000000FFFFFFFFFF 247#define IPG_RFI_FRAGADDR 0x000000FFFFFFFFFF
248#define IPG_RFI_FRAGLEN 0xFFFF000000000000LL 248#define IPG_RFI_FRAGLEN 0xFFFF000000000000LL
249 249
250/* I/O Register masks. */ 250/* I/O Register masks. */
251 251
@@ -254,37 +254,37 @@ enum ipg_regs {
254 254
255/* Statistics Mask */ 255/* Statistics Mask */
256#define IPG_SM_ALL 0x0FFFFFFF 256#define IPG_SM_ALL 0x0FFFFFFF
257#define IPG_SM_OCTETRCVOK_FRAMESRCVDOK 0x00000001 257#define IPG_SM_OCTETRCVOK_FRAMESRCVDOK 0x00000001
258#define IPG_SM_MCSTOCTETRCVDOK_MCSTFRAMESRCVDOK 0x00000002 258#define IPG_SM_MCSTOCTETRCVDOK_MCSTFRAMESRCVDOK 0x00000002
259#define IPG_SM_BCSTOCTETRCVDOK_BCSTFRAMESRCVDOK 0x00000004 259#define IPG_SM_BCSTOCTETRCVDOK_BCSTFRAMESRCVDOK 0x00000004
260#define IPG_SM_RXJUMBOFRAMES 0x00000008 260#define IPG_SM_RXJUMBOFRAMES 0x00000008
261#define IPG_SM_TCPCHECKSUMERRORS 0x00000010 261#define IPG_SM_TCPCHECKSUMERRORS 0x00000010
262#define IPG_SM_IPCHECKSUMERRORS 0x00000020 262#define IPG_SM_IPCHECKSUMERRORS 0x00000020
263#define IPG_SM_UDPCHECKSUMERRORS 0x00000040 263#define IPG_SM_UDPCHECKSUMERRORS 0x00000040
264#define IPG_SM_MACCONTROLFRAMESRCVD 0x00000080 264#define IPG_SM_MACCONTROLFRAMESRCVD 0x00000080
265#define IPG_SM_FRAMESTOOLONGERRORS 0x00000100 265#define IPG_SM_FRAMESTOOLONGERRORS 0x00000100
266#define IPG_SM_INRANGELENGTHERRORS 0x00000200 266#define IPG_SM_INRANGELENGTHERRORS 0x00000200
267#define IPG_SM_FRAMECHECKSEQERRORS 0x00000400 267#define IPG_SM_FRAMECHECKSEQERRORS 0x00000400
268#define IPG_SM_FRAMESLOSTRXERRORS 0x00000800 268#define IPG_SM_FRAMESLOSTRXERRORS 0x00000800
269#define IPG_SM_OCTETXMTOK_FRAMESXMTOK 0x00001000 269#define IPG_SM_OCTETXMTOK_FRAMESXMTOK 0x00001000
270#define IPG_SM_MCSTOCTETXMTOK_MCSTFRAMESXMTDOK 0x00002000 270#define IPG_SM_MCSTOCTETXMTOK_MCSTFRAMESXMTDOK 0x00002000
271#define IPG_SM_BCSTOCTETXMTOK_BCSTFRAMESXMTDOK 0x00004000 271#define IPG_SM_BCSTOCTETXMTOK_BCSTFRAMESXMTDOK 0x00004000
272#define IPG_SM_FRAMESWDEFERREDXMT 0x00008000 272#define IPG_SM_FRAMESWDEFERREDXMT 0x00008000
273#define IPG_SM_LATECOLLISIONS 0x00010000 273#define IPG_SM_LATECOLLISIONS 0x00010000
274#define IPG_SM_MULTICOLFRAMES 0x00020000 274#define IPG_SM_MULTICOLFRAMES 0x00020000
275#define IPG_SM_SINGLECOLFRAMES 0x00040000 275#define IPG_SM_SINGLECOLFRAMES 0x00040000
276#define IPG_SM_TXJUMBOFRAMES 0x00080000 276#define IPG_SM_TXJUMBOFRAMES 0x00080000
277#define IPG_SM_CARRIERSENSEERRORS 0x00100000 277#define IPG_SM_CARRIERSENSEERRORS 0x00100000
278#define IPG_SM_MACCONTROLFRAMESXMTD 0x00200000 278#define IPG_SM_MACCONTROLFRAMESXMTD 0x00200000
279#define IPG_SM_FRAMESABORTXSCOLLS 0x00400000 279#define IPG_SM_FRAMESABORTXSCOLLS 0x00400000
280#define IPG_SM_FRAMESWEXDEFERAL 0x00800000 280#define IPG_SM_FRAMESWEXDEFERAL 0x00800000
281 281
282/* Countdown */ 282/* Countdown */
283#define IPG_CD_RSVD_MASK 0x0700FFFF 283#define IPG_CD_RSVD_MASK 0x0700FFFF
284#define IPG_CD_COUNT 0x0000FFFF 284#define IPG_CD_COUNT 0x0000FFFF
285#define IPG_CD_COUNTDOWNSPEED 0x01000000 285#define IPG_CD_COUNTDOWNSPEED 0x01000000
286#define IPG_CD_COUNTDOWNMODE 0x02000000 286#define IPG_CD_COUNTDOWNMODE 0x02000000
287#define IPG_CD_COUNTINTENABLED 0x04000000 287#define IPG_CD_COUNTINTENABLED 0x04000000
288 288
289/* TxDMABurstThresh */ 289/* TxDMABurstThresh */
290#define IPG_TB_RSVD_MASK 0xFF 290#define IPG_TB_RSVD_MASK 0xFF
@@ -653,15 +653,28 @@ enum ipg_regs {
653 * Miscellaneous macros. 653 * Miscellaneous macros.
654 */ 654 */
655 655
656/* Marco for printing debug statements. */ 656/* Macros for printing debug statements. */
657#ifdef IPG_DEBUG 657#ifdef IPG_DEBUG
658# define IPG_DEBUG_MSG(args...) 658# define IPG_DEBUG_MSG(fmt, args...) \
659# define IPG_DDEBUG_MSG(args...) printk(KERN_DEBUG "IPG: " args) 659do { \
660 if (0) \
661 printk(KERN_DEBUG "IPG: " fmt, ##args); \
662} while (0)
663# define IPG_DDEBUG_MSG(fmt, args...) \
664 printk(KERN_DEBUG "IPG: " fmt, ##args)
660# define IPG_DUMPRFDLIST(args) ipg_dump_rfdlist(args) 665# define IPG_DUMPRFDLIST(args) ipg_dump_rfdlist(args)
661# define IPG_DUMPTFDLIST(args) ipg_dump_tfdlist(args) 666# define IPG_DUMPTFDLIST(args) ipg_dump_tfdlist(args)
662#else 667#else
663# define IPG_DEBUG_MSG(args...) 668# define IPG_DEBUG_MSG(fmt, args...) \
664# define IPG_DDEBUG_MSG(args...) 669do { \
670 if (0) \
671 printk(KERN_DEBUG "IPG: " fmt, ##args); \
672} while (0)
673# define IPG_DDEBUG_MSG(fmt, args...) \
674do { \
675 if (0) \
676 printk(KERN_DEBUG "IPG: " fmt, ##args); \
677} while (0)
665# define IPG_DUMPRFDLIST(args) 678# define IPG_DUMPRFDLIST(args)
666# define IPG_DUMPTFDLIST(args) 679# define IPG_DUMPTFDLIST(args)
667#endif 680#endif
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index af10e97345ce..25bb2a015e18 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -397,5 +397,11 @@ config MCS_FIR
397 To compile it as a module, choose M here: the module will be called 397 To compile it as a module, choose M here: the module will be called
398 mcs7780. 398 mcs7780.
399 399
400config SH_IRDA
401 tristate "SuperH IrDA driver"
402 depends on IRDA && ARCH_SHMOBILE
403 help
404 Say Y here if your want to enable SuperH IrDA devices.
405
400endmenu 406endmenu
401 407
diff --git a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile
index e030d47e2793..dfc64537f62f 100644
--- a/drivers/net/irda/Makefile
+++ b/drivers/net/irda/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_VIA_FIR) += via-ircc.o
19obj-$(CONFIG_PXA_FICP) += pxaficp_ir.o 19obj-$(CONFIG_PXA_FICP) += pxaficp_ir.o
20obj-$(CONFIG_MCS_FIR) += mcs7780.o 20obj-$(CONFIG_MCS_FIR) += mcs7780.o
21obj-$(CONFIG_AU1000_FIR) += au1k_ir.o 21obj-$(CONFIG_AU1000_FIR) += au1k_ir.o
22obj-$(CONFIG_SH_IRDA) += sh_irda.o
22# SIR drivers 23# SIR drivers
23obj-$(CONFIG_IRTTY_SIR) += irtty-sir.o sir-dev.o 24obj-$(CONFIG_IRTTY_SIR) += irtty-sir.o sir-dev.o
24obj-$(CONFIG_BFIN_SIR) += bfin_sir.o 25obj-$(CONFIG_BFIN_SIR) += bfin_sir.o
diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
index 12c7b006f767..a32c97e6b39d 100644
--- a/drivers/net/irda/ali-ircc.c
+++ b/drivers/net/irda/ali-ircc.c
@@ -753,18 +753,18 @@ static irqreturn_t ali_ircc_fir_interrupt(struct ali_ircc_cb *self)
753 if(OldMessageCount > ((self->LineStatus+1) & 0x07)) 753 if(OldMessageCount > ((self->LineStatus+1) & 0x07))
754 { 754 {
755 self->rcvFramesOverflow = TRUE; 755 self->rcvFramesOverflow = TRUE;
756 IRDA_DEBUG(1, "%s(), ******* self->rcvFramesOverflow = TRUE ******** \n", __func__); 756 IRDA_DEBUG(1, "%s(), ******* self->rcvFramesOverflow = TRUE ********\n", __func__);
757 } 757 }
758 758
759 if (ali_ircc_dma_receive_complete(self)) 759 if (ali_ircc_dma_receive_complete(self))
760 { 760 {
761 IRDA_DEBUG(1, "%s(), ******* receive complete ******** \n", __func__); 761 IRDA_DEBUG(1, "%s(), ******* receive complete ********\n", __func__);
762 762
763 self->ier = IER_EOM; 763 self->ier = IER_EOM;
764 } 764 }
765 else 765 else
766 { 766 {
767 IRDA_DEBUG(1, "%s(), ******* Not receive complete ******** \n", __func__); 767 IRDA_DEBUG(1, "%s(), ******* Not receive complete ********\n", __func__);
768 768
769 self->ier = IER_EOM | IER_TIMER; 769 self->ier = IER_EOM | IER_TIMER;
770 } 770 }
@@ -777,7 +777,7 @@ static irqreturn_t ali_ircc_fir_interrupt(struct ali_ircc_cb *self)
777 if(OldMessageCount > ((self->LineStatus+1) & 0x07)) 777 if(OldMessageCount > ((self->LineStatus+1) & 0x07))
778 { 778 {
779 self->rcvFramesOverflow = TRUE; 779 self->rcvFramesOverflow = TRUE;
780 IRDA_DEBUG(1, "%s(), ******* self->rcvFramesOverflow = TRUE ******* \n", __func__); 780 IRDA_DEBUG(1, "%s(), ******* self->rcvFramesOverflow = TRUE *******\n", __func__);
781 } 781 }
782 /* Disable Timer */ 782 /* Disable Timer */
783 switch_bank(iobase, BANK1); 783 switch_bank(iobase, BANK1);
@@ -942,7 +942,7 @@ static void ali_ircc_sir_write_wakeup(struct ali_ircc_cb *self)
942 // benjamin 2000/11/10 06:32PM 942 // benjamin 2000/11/10 06:32PM
943 if (self->io.speed > 115200) 943 if (self->io.speed > 115200)
944 { 944 {
945 IRDA_DEBUG(2, "%s(), ali_ircc_change_speed from UART_LSR_TEMT \n", __func__ ); 945 IRDA_DEBUG(2, "%s(), ali_ircc_change_speed from UART_LSR_TEMT\n", __func__ );
946 946
947 self->ier = IER_EOM; 947 self->ier = IER_EOM;
948 // SetCOMInterrupts(self, TRUE); 948 // SetCOMInterrupts(self, TRUE);
@@ -970,7 +970,7 @@ static void ali_ircc_change_speed(struct ali_ircc_cb *self, __u32 baud)
970 970
971 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ ); 971 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __func__ );
972 972
973 IRDA_DEBUG(2, "%s(), setting speed = %d \n", __func__ , baud); 973 IRDA_DEBUG(2, "%s(), setting speed = %d\n", __func__ , baud);
974 974
975 /* This function *must* be called with irq off and spin-lock. 975 /* This function *must* be called with irq off and spin-lock.
976 * - Jean II */ 976 * - Jean II */
@@ -1500,7 +1500,7 @@ static netdev_tx_t ali_ircc_fir_hard_xmit(struct sk_buff *skb,
1500 diff = self->now.tv_usec - self->stamp.tv_usec; 1500 diff = self->now.tv_usec - self->stamp.tv_usec;
1501 /* self->stamp is set from ali_ircc_dma_receive_complete() */ 1501 /* self->stamp is set from ali_ircc_dma_receive_complete() */
1502 1502
1503 IRDA_DEBUG(1, "%s(), ******* diff = %d ******* \n", __func__ , diff); 1503 IRDA_DEBUG(1, "%s(), ******* diff = %d *******\n", __func__ , diff);
1504 1504
1505 if (diff < 0) 1505 if (diff < 0)
1506 diff += 1000000; 1506 diff += 1000000;
@@ -1641,7 +1641,7 @@ static void ali_ircc_dma_xmit(struct ali_ircc_cb *self)
1641 tmp = inb(iobase+FIR_LCR_B); 1641 tmp = inb(iobase+FIR_LCR_B);
1642 tmp &= ~0x20; // Disable SIP 1642 tmp &= ~0x20; // Disable SIP
1643 outb(((unsigned char)(tmp & 0x3f) | LCR_B_TX_MODE) & ~LCR_B_BW, iobase+FIR_LCR_B); 1643 outb(((unsigned char)(tmp & 0x3f) | LCR_B_TX_MODE) & ~LCR_B_BW, iobase+FIR_LCR_B);
1644 IRDA_DEBUG(1, "%s(), ******* Change to TX mode: FIR_LCR_B = 0x%x ******* \n", __func__ , inb(iobase+FIR_LCR_B)); 1644 IRDA_DEBUG(1, "%s(), *** Change to TX mode: FIR_LCR_B = 0x%x ***\n", __func__ , inb(iobase+FIR_LCR_B));
1645 1645
1646 outb(0, iobase+FIR_LSR); 1646 outb(0, iobase+FIR_LSR);
1647 1647
@@ -1768,7 +1768,7 @@ static int ali_ircc_dma_receive(struct ali_ircc_cb *self)
1768 //switch_bank(iobase, BANK0); 1768 //switch_bank(iobase, BANK0);
1769 tmp = inb(iobase+FIR_LCR_B); 1769 tmp = inb(iobase+FIR_LCR_B);
1770 outb((unsigned char)(tmp &0x3f) | LCR_B_RX_MODE | LCR_B_BW , iobase + FIR_LCR_B); // 2000/12/1 05:16PM 1770 outb((unsigned char)(tmp &0x3f) | LCR_B_RX_MODE | LCR_B_BW , iobase + FIR_LCR_B); // 2000/12/1 05:16PM
1771 IRDA_DEBUG(1, "%s(), *** Change To RX mode: FIR_LCR_B = 0x%x *** \n", __func__ , inb(iobase+FIR_LCR_B)); 1771 IRDA_DEBUG(1, "%s(), *** Change To RX mode: FIR_LCR_B = 0x%x ***\n", __func__ , inb(iobase+FIR_LCR_B));
1772 1772
1773 /* Set Rx Threshold */ 1773 /* Set Rx Threshold */
1774 switch_bank(iobase, BANK1); 1774 switch_bank(iobase, BANK1);
@@ -1840,7 +1840,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1840 /* Check for errors */ 1840 /* Check for errors */
1841 if ((status & 0xd8) || self->rcvFramesOverflow || (len==0)) 1841 if ((status & 0xd8) || self->rcvFramesOverflow || (len==0))
1842 { 1842 {
1843 IRDA_DEBUG(0,"%s(), ************* RX Errors ************ \n", __func__ ); 1843 IRDA_DEBUG(0,"%s(), ************* RX Errors ************\n", __func__ );
1844 1844
1845 /* Skip frame */ 1845 /* Skip frame */
1846 self->netdev->stats.rx_errors++; 1846 self->netdev->stats.rx_errors++;
@@ -1850,29 +1850,29 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1850 if (status & LSR_FIFO_UR) 1850 if (status & LSR_FIFO_UR)
1851 { 1851 {
1852 self->netdev->stats.rx_frame_errors++; 1852 self->netdev->stats.rx_frame_errors++;
1853 IRDA_DEBUG(0,"%s(), ************* FIFO Errors ************ \n", __func__ ); 1853 IRDA_DEBUG(0,"%s(), ************* FIFO Errors ************\n", __func__ );
1854 } 1854 }
1855 if (status & LSR_FRAME_ERROR) 1855 if (status & LSR_FRAME_ERROR)
1856 { 1856 {
1857 self->netdev->stats.rx_frame_errors++; 1857 self->netdev->stats.rx_frame_errors++;
1858 IRDA_DEBUG(0,"%s(), ************* FRAME Errors ************ \n", __func__ ); 1858 IRDA_DEBUG(0,"%s(), ************* FRAME Errors ************\n", __func__ );
1859 } 1859 }
1860 1860
1861 if (status & LSR_CRC_ERROR) 1861 if (status & LSR_CRC_ERROR)
1862 { 1862 {
1863 self->netdev->stats.rx_crc_errors++; 1863 self->netdev->stats.rx_crc_errors++;
1864 IRDA_DEBUG(0,"%s(), ************* CRC Errors ************ \n", __func__ ); 1864 IRDA_DEBUG(0,"%s(), ************* CRC Errors ************\n", __func__ );
1865 } 1865 }
1866 1866
1867 if(self->rcvFramesOverflow) 1867 if(self->rcvFramesOverflow)
1868 { 1868 {
1869 self->netdev->stats.rx_frame_errors++; 1869 self->netdev->stats.rx_frame_errors++;
1870 IRDA_DEBUG(0,"%s(), ************* Overran DMA buffer ************ \n", __func__ ); 1870 IRDA_DEBUG(0,"%s(), ************* Overran DMA buffer ************\n", __func__ );
1871 } 1871 }
1872 if(len == 0) 1872 if(len == 0)
1873 { 1873 {
1874 self->netdev->stats.rx_frame_errors++; 1874 self->netdev->stats.rx_frame_errors++;
1875 IRDA_DEBUG(0,"%s(), ********** Receive Frame Size = 0 ********* \n", __func__ ); 1875 IRDA_DEBUG(0,"%s(), ********** Receive Frame Size = 0 *********\n", __func__ );
1876 } 1876 }
1877 } 1877 }
1878 else 1878 else
@@ -1884,7 +1884,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1884 val = inb(iobase+FIR_BSR); 1884 val = inb(iobase+FIR_BSR);
1885 if ((val& BSR_FIFO_NOT_EMPTY)== 0x80) 1885 if ((val& BSR_FIFO_NOT_EMPTY)== 0x80)
1886 { 1886 {
1887 IRDA_DEBUG(0, "%s(), ************* BSR_FIFO_NOT_EMPTY ************ \n", __func__ ); 1887 IRDA_DEBUG(0, "%s(), ************* BSR_FIFO_NOT_EMPTY ************\n", __func__ );
1888 1888
1889 /* Put this entry back in fifo */ 1889 /* Put this entry back in fifo */
1890 st_fifo->head--; 1890 st_fifo->head--;
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index 2c9b3af16612..4441fa3389c2 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -839,7 +839,7 @@ static void irda_usb_receive(struct urb *urb)
839 /* Usually precursor to a hot-unplug on OHCI. */ 839 /* Usually precursor to a hot-unplug on OHCI. */
840 default: 840 default:
841 self->netdev->stats.rx_errors++; 841 self->netdev->stats.rx_errors++;
842 IRDA_DEBUG(0, "%s(), RX status %d, transfer_flags 0x%04X \n", __func__, urb->status, urb->transfer_flags); 842 IRDA_DEBUG(0, "%s(), RX status %d, transfer_flags 0x%04X\n", __func__, urb->status, urb->transfer_flags);
843 break; 843 break;
844 } 844 }
845 /* If we received an error, we don't want to resubmit the 845 /* If we received an error, we don't want to resubmit the
diff --git a/drivers/net/irda/sh_irda.c b/drivers/net/irda/sh_irda.c
new file mode 100644
index 000000000000..9a828b06a57e
--- /dev/null
+++ b/drivers/net/irda/sh_irda.c
@@ -0,0 +1,865 @@
1/*
2 * SuperH IrDA Driver
3 *
4 * Copyright (C) 2010 Renesas Solutions Corp.
5 * Kuninori Morimoto <morimoto.kuninori@renesas.com>
6 *
7 * Based on sh_sir.c
8 * Copyright (C) 2009 Renesas Solutions Corp.
9 * Copyright 2006-2009 Analog Devices Inc.
10 *
11 * 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
13 * published by the Free Software Foundation.
14 */
15
16/*
17 * CAUTION
18 *
19 * This driver is very simple.
20 * So, it doesn't have below support now
21 * - MIR/FIR support
22 * - DMA transfer support
23 * - FIFO mode support
24 */
25#include <linux/module.h>
26#include <linux/platform_device.h>
27#include <linux/clk.h>
28#include <net/irda/wrapper.h>
29#include <net/irda/irda_device.h>
30
31#define DRIVER_NAME "sh_irda"
32
33#if defined(CONFIG_ARCH_SH7367) || defined(CONFIG_ARCH_SH7377)
34#define __IRDARAM_LEN 0x13FF
35#else
36#define __IRDARAM_LEN 0x1039
37#endif
38
39#define IRTMR 0x1F00 /* Transfer mode */
40#define IRCFR 0x1F02 /* Configuration */
41#define IRCTR 0x1F04 /* IR control */
42#define IRTFLR 0x1F20 /* Transmit frame length */
43#define IRTCTR 0x1F22 /* Transmit control */
44#define IRRFLR 0x1F40 /* Receive frame length */
45#define IRRCTR 0x1F42 /* Receive control */
46#define SIRISR 0x1F60 /* SIR-UART mode interrupt source */
47#define SIRIMR 0x1F62 /* SIR-UART mode interrupt mask */
48#define SIRICR 0x1F64 /* SIR-UART mode interrupt clear */
49#define SIRBCR 0x1F68 /* SIR-UART mode baud rate count */
50#define MFIRISR 0x1F70 /* MIR/FIR mode interrupt source */
51#define MFIRIMR 0x1F72 /* MIR/FIR mode interrupt mask */
52#define MFIRICR 0x1F74 /* MIR/FIR mode interrupt clear */
53#define CRCCTR 0x1F80 /* CRC engine control */
54#define CRCIR 0x1F86 /* CRC engine input data */
55#define CRCCR 0x1F8A /* CRC engine calculation */
56#define CRCOR 0x1F8E /* CRC engine output data */
57#define FIFOCP 0x1FC0 /* FIFO current pointer */
58#define FIFOFP 0x1FC2 /* FIFO follow pointer */
59#define FIFORSMSK 0x1FC4 /* FIFO receive status mask */
60#define FIFORSOR 0x1FC6 /* FIFO receive status OR */
61#define FIFOSEL 0x1FC8 /* FIFO select */
62#define FIFORS 0x1FCA /* FIFO receive status */
63#define FIFORFL 0x1FCC /* FIFO receive frame length */
64#define FIFORAMCP 0x1FCE /* FIFO RAM current pointer */
65#define FIFORAMFP 0x1FD0 /* FIFO RAM follow pointer */
66#define BIFCTL 0x1FD2 /* BUS interface control */
67#define IRDARAM 0x0000 /* IrDA buffer RAM */
68#define IRDARAM_LEN __IRDARAM_LEN /* - 8/16/32 (read-only for 32) */
69
70/* IRTMR */
71#define TMD_MASK (0x3 << 14) /* Transfer Mode */
72#define TMD_SIR (0x0 << 14)
73#define TMD_MIR (0x3 << 14)
74#define TMD_FIR (0x2 << 14)
75
76#define FIFORIM (1 << 8) /* FIFO receive interrupt mask */
77#define MIM (1 << 4) /* MIR/FIR Interrupt Mask */
78#define SIM (1 << 0) /* SIR Interrupt Mask */
79#define xIM_MASK (FIFORIM | MIM | SIM)
80
81/* IRCFR */
82#define RTO_SHIFT 8 /* shift for Receive Timeout */
83#define RTO (0x3 << RTO_SHIFT)
84
85/* IRTCTR */
86#define ARMOD (1 << 15) /* Auto-Receive Mode */
87#define TE (1 << 0) /* Transmit Enable */
88
89/* IRRFLR */
90#define RFL_MASK (0x1FFF) /* mask for Receive Frame Length */
91
92/* IRRCTR */
93#define RE (1 << 0) /* Receive Enable */
94
95/*
96 * SIRISR, SIRIMR, SIRICR,
97 * MFIRISR, MFIRIMR, MFIRICR
98 */
99#define FRE (1 << 15) /* Frame Receive End */
100#define TROV (1 << 11) /* Transfer Area Overflow */
101#define xIR_9 (1 << 9)
102#define TOT xIR_9 /* for SIR Timeout */
103#define ABTD xIR_9 /* for MIR/FIR Abort Detection */
104#define xIR_8 (1 << 8)
105#define FER xIR_8 /* for SIR Framing Error */
106#define CRCER xIR_8 /* for MIR/FIR CRC error */
107#define FTE (1 << 7) /* Frame Transmit End */
108#define xIR_MASK (FRE | TROV | xIR_9 | xIR_8 | FTE)
109
110/* SIRBCR */
111#define BRC_MASK (0x3F) /* mask for Baud Rate Count */
112
113/* CRCCTR */
114#define CRC_RST (1 << 15) /* CRC Engine Reset */
115#define CRC_CT_MASK 0x0FFF /* mask for CRC Engine Input Data Count */
116
117/* CRCIR */
118#define CRC_IN_MASK 0x0FFF /* mask for CRC Engine Input Data */
119
120/************************************************************************
121
122
123 enum / structure
124
125
126************************************************************************/
127enum sh_irda_mode {
128 SH_IRDA_NONE = 0,
129 SH_IRDA_SIR,
130 SH_IRDA_MIR,
131 SH_IRDA_FIR,
132};
133
134struct sh_irda_self;
135struct sh_irda_xir_func {
136 int (*xir_fre) (struct sh_irda_self *self);
137 int (*xir_trov) (struct sh_irda_self *self);
138 int (*xir_9) (struct sh_irda_self *self);
139 int (*xir_8) (struct sh_irda_self *self);
140 int (*xir_fte) (struct sh_irda_self *self);
141};
142
143struct sh_irda_self {
144 void __iomem *membase;
145 unsigned int irq;
146 struct clk *clk;
147
148 struct net_device *ndev;
149
150 struct irlap_cb *irlap;
151 struct qos_info qos;
152
153 iobuff_t tx_buff;
154 iobuff_t rx_buff;
155
156 enum sh_irda_mode mode;
157 spinlock_t lock;
158
159 struct sh_irda_xir_func *xir_func;
160};
161
162/************************************************************************
163
164
165 common function
166
167
168************************************************************************/
169static void sh_irda_write(struct sh_irda_self *self, u32 offset, u16 data)
170{
171 unsigned long flags;
172
173 spin_lock_irqsave(&self->lock, flags);
174 iowrite16(data, self->membase + offset);
175 spin_unlock_irqrestore(&self->lock, flags);
176}
177
178static u16 sh_irda_read(struct sh_irda_self *self, u32 offset)
179{
180 unsigned long flags;
181 u16 ret;
182
183 spin_lock_irqsave(&self->lock, flags);
184 ret = ioread16(self->membase + offset);
185 spin_unlock_irqrestore(&self->lock, flags);
186
187 return ret;
188}
189
190static void sh_irda_update_bits(struct sh_irda_self *self, u32 offset,
191 u16 mask, u16 data)
192{
193 unsigned long flags;
194 u16 old, new;
195
196 spin_lock_irqsave(&self->lock, flags);
197 old = ioread16(self->membase + offset);
198 new = (old & ~mask) | data;
199 if (old != new)
200 iowrite16(data, self->membase + offset);
201 spin_unlock_irqrestore(&self->lock, flags);
202}
203
204/************************************************************************
205
206
207 mode function
208
209
210************************************************************************/
211/*=====================================
212 *
213 * common
214 *
215 *=====================================*/
216static void sh_irda_rcv_ctrl(struct sh_irda_self *self, int enable)
217{
218 struct device *dev = &self->ndev->dev;
219
220 sh_irda_update_bits(self, IRRCTR, RE, enable ? RE : 0);
221 dev_dbg(dev, "recv %s\n", enable ? "enable" : "disable");
222}
223
224static int sh_irda_set_timeout(struct sh_irda_self *self, int interval)
225{
226 struct device *dev = &self->ndev->dev;
227
228 if (SH_IRDA_SIR != self->mode)
229 interval = 0;
230
231 if (interval < 0 || interval > 2) {
232 dev_err(dev, "unsupported timeout interval\n");
233 return -EINVAL;
234 }
235
236 sh_irda_update_bits(self, IRCFR, RTO, interval << RTO_SHIFT);
237 return 0;
238}
239
240static int sh_irda_set_baudrate(struct sh_irda_self *self, int baudrate)
241{
242 struct device *dev = &self->ndev->dev;
243 u16 val;
244
245 if (baudrate < 0)
246 return 0;
247
248 if (SH_IRDA_SIR != self->mode) {
249 dev_err(dev, "it is not SIR mode\n");
250 return -EINVAL;
251 }
252
253 /*
254 * Baud rate (bits/s) =
255 * (48 MHz / 26) / (baud rate counter value + 1) x 16
256 */
257 val = (48000000 / 26 / 16 / baudrate) - 1;
258 dev_dbg(dev, "baudrate = %d, val = 0x%02x\n", baudrate, val);
259
260 sh_irda_update_bits(self, SIRBCR, BRC_MASK, val);
261
262 return 0;
263}
264
265static int xir_get_rcv_length(struct sh_irda_self *self)
266{
267 return RFL_MASK & sh_irda_read(self, IRRFLR);
268}
269
270/*=====================================
271 *
272 * NONE MODE
273 *
274 *=====================================*/
275static int xir_fre(struct sh_irda_self *self)
276{
277 struct device *dev = &self->ndev->dev;
278 dev_err(dev, "none mode: frame recv\n");
279 return 0;
280}
281
282static int xir_trov(struct sh_irda_self *self)
283{
284 struct device *dev = &self->ndev->dev;
285 dev_err(dev, "none mode: buffer ram over\n");
286 return 0;
287}
288
289static int xir_9(struct sh_irda_self *self)
290{
291 struct device *dev = &self->ndev->dev;
292 dev_err(dev, "none mode: time over\n");
293 return 0;
294}
295
296static int xir_8(struct sh_irda_self *self)
297{
298 struct device *dev = &self->ndev->dev;
299 dev_err(dev, "none mode: framing error\n");
300 return 0;
301}
302
303static int xir_fte(struct sh_irda_self *self)
304{
305 struct device *dev = &self->ndev->dev;
306 dev_err(dev, "none mode: frame transmit end\n");
307 return 0;
308}
309
310static struct sh_irda_xir_func xir_func = {
311 .xir_fre = xir_fre,
312 .xir_trov = xir_trov,
313 .xir_9 = xir_9,
314 .xir_8 = xir_8,
315 .xir_fte = xir_fte,
316};
317
318/*=====================================
319 *
320 * MIR/FIR MODE
321 *
322 * MIR/FIR are not supported now
323 *=====================================*/
324static struct sh_irda_xir_func mfir_func = {
325 .xir_fre = xir_fre,
326 .xir_trov = xir_trov,
327 .xir_9 = xir_9,
328 .xir_8 = xir_8,
329 .xir_fte = xir_fte,
330};
331
332/*=====================================
333 *
334 * SIR MODE
335 *
336 *=====================================*/
337static int sir_fre(struct sh_irda_self *self)
338{
339 struct device *dev = &self->ndev->dev;
340 u16 data16;
341 u8 *data = (u8 *)&data16;
342 int len = xir_get_rcv_length(self);
343 int i, j;
344
345 if (len > IRDARAM_LEN)
346 len = IRDARAM_LEN;
347
348 dev_dbg(dev, "frame recv length = %d\n", len);
349
350 for (i = 0; i < len; i++) {
351 j = i % 2;
352 if (!j)
353 data16 = sh_irda_read(self, IRDARAM + i);
354
355 async_unwrap_char(self->ndev, &self->ndev->stats,
356 &self->rx_buff, data[j]);
357 }
358 self->ndev->last_rx = jiffies;
359
360 sh_irda_rcv_ctrl(self, 1);
361
362 return 0;
363}
364
365static int sir_trov(struct sh_irda_self *self)
366{
367 struct device *dev = &self->ndev->dev;
368
369 dev_err(dev, "buffer ram over\n");
370 sh_irda_rcv_ctrl(self, 1);
371 return 0;
372}
373
374static int sir_tot(struct sh_irda_self *self)
375{
376 struct device *dev = &self->ndev->dev;
377
378 dev_err(dev, "time over\n");
379 sh_irda_set_baudrate(self, 9600);
380 sh_irda_rcv_ctrl(self, 1);
381 return 0;
382}
383
384static int sir_fer(struct sh_irda_self *self)
385{
386 struct device *dev = &self->ndev->dev;
387
388 dev_err(dev, "framing error\n");
389 sh_irda_rcv_ctrl(self, 1);
390 return 0;
391}
392
393static int sir_fte(struct sh_irda_self *self)
394{
395 struct device *dev = &self->ndev->dev;
396
397 dev_dbg(dev, "frame transmit end\n");
398 netif_wake_queue(self->ndev);
399
400 return 0;
401}
402
403static struct sh_irda_xir_func sir_func = {
404 .xir_fre = sir_fre,
405 .xir_trov = sir_trov,
406 .xir_9 = sir_tot,
407 .xir_8 = sir_fer,
408 .xir_fte = sir_fte,
409};
410
411static void sh_irda_set_mode(struct sh_irda_self *self, enum sh_irda_mode mode)
412{
413 struct device *dev = &self->ndev->dev;
414 struct sh_irda_xir_func *func;
415 const char *name;
416 u16 data;
417
418 switch (mode) {
419 case SH_IRDA_SIR:
420 name = "SIR";
421 data = TMD_SIR;
422 func = &sir_func;
423 break;
424 case SH_IRDA_MIR:
425 name = "MIR";
426 data = TMD_MIR;
427 func = &mfir_func;
428 break;
429 case SH_IRDA_FIR:
430 name = "FIR";
431 data = TMD_FIR;
432 func = &mfir_func;
433 break;
434 default:
435 name = "NONE";
436 data = 0;
437 func = &xir_func;
438 break;
439 }
440
441 self->mode = mode;
442 self->xir_func = func;
443 sh_irda_update_bits(self, IRTMR, TMD_MASK, data);
444
445 dev_dbg(dev, "switch to %s mode", name);
446}
447
448/************************************************************************
449
450
451 irq function
452
453
454************************************************************************/
455static void sh_irda_set_irq_mask(struct sh_irda_self *self)
456{
457 u16 tmr_hole;
458 u16 xir_reg;
459
460 /* set all mask */
461 sh_irda_update_bits(self, IRTMR, xIM_MASK, xIM_MASK);
462 sh_irda_update_bits(self, SIRIMR, xIR_MASK, xIR_MASK);
463 sh_irda_update_bits(self, MFIRIMR, xIR_MASK, xIR_MASK);
464
465 /* clear irq */
466 sh_irda_update_bits(self, SIRICR, xIR_MASK, xIR_MASK);
467 sh_irda_update_bits(self, MFIRICR, xIR_MASK, xIR_MASK);
468
469 switch (self->mode) {
470 case SH_IRDA_SIR:
471 tmr_hole = SIM;
472 xir_reg = SIRIMR;
473 break;
474 case SH_IRDA_MIR:
475 case SH_IRDA_FIR:
476 tmr_hole = MIM;
477 xir_reg = MFIRIMR;
478 break;
479 default:
480 tmr_hole = 0;
481 xir_reg = 0;
482 break;
483 }
484
485 /* open mask */
486 if (xir_reg) {
487 sh_irda_update_bits(self, IRTMR, tmr_hole, 0);
488 sh_irda_update_bits(self, xir_reg, xIR_MASK, 0);
489 }
490}
491
492static irqreturn_t sh_irda_irq(int irq, void *dev_id)
493{
494 struct sh_irda_self *self = dev_id;
495 struct sh_irda_xir_func *func = self->xir_func;
496 u16 isr = sh_irda_read(self, SIRISR);
497
498 /* clear irq */
499 sh_irda_write(self, SIRICR, isr);
500
501 if (isr & FRE)
502 func->xir_fre(self);
503 if (isr & TROV)
504 func->xir_trov(self);
505 if (isr & xIR_9)
506 func->xir_9(self);
507 if (isr & xIR_8)
508 func->xir_8(self);
509 if (isr & FTE)
510 func->xir_fte(self);
511
512 return IRQ_HANDLED;
513}
514
515/************************************************************************
516
517
518 CRC function
519
520
521************************************************************************/
522static void sh_irda_crc_reset(struct sh_irda_self *self)
523{
524 sh_irda_write(self, CRCCTR, CRC_RST);
525}
526
527static void sh_irda_crc_add(struct sh_irda_self *self, u16 data)
528{
529 sh_irda_write(self, CRCIR, data & CRC_IN_MASK);
530}
531
532static u16 sh_irda_crc_cnt(struct sh_irda_self *self)
533{
534 return CRC_CT_MASK & sh_irda_read(self, CRCCTR);
535}
536
537static u16 sh_irda_crc_out(struct sh_irda_self *self)
538{
539 return sh_irda_read(self, CRCOR);
540}
541
542static int sh_irda_crc_init(struct sh_irda_self *self)
543{
544 struct device *dev = &self->ndev->dev;
545 int ret = -EIO;
546 u16 val;
547
548 sh_irda_crc_reset(self);
549
550 sh_irda_crc_add(self, 0xCC);
551 sh_irda_crc_add(self, 0xF5);
552 sh_irda_crc_add(self, 0xF1);
553 sh_irda_crc_add(self, 0xA7);
554
555 val = sh_irda_crc_cnt(self);
556 if (4 != val) {
557 dev_err(dev, "CRC count error %x\n", val);
558 goto crc_init_out;
559 }
560
561 val = sh_irda_crc_out(self);
562 if (0x51DF != val) {
563 dev_err(dev, "CRC result error%x\n", val);
564 goto crc_init_out;
565 }
566
567 ret = 0;
568
569crc_init_out:
570
571 sh_irda_crc_reset(self);
572 return ret;
573}
574
575/************************************************************************
576
577
578 iobuf function
579
580
581************************************************************************/
582static void sh_irda_remove_iobuf(struct sh_irda_self *self)
583{
584 kfree(self->rx_buff.head);
585
586 self->tx_buff.head = NULL;
587 self->tx_buff.data = NULL;
588 self->rx_buff.head = NULL;
589 self->rx_buff.data = NULL;
590}
591
592static int sh_irda_init_iobuf(struct sh_irda_self *self, int rxsize, int txsize)
593{
594 if (self->rx_buff.head ||
595 self->tx_buff.head) {
596 dev_err(&self->ndev->dev, "iobuff has already existed.");
597 return -EINVAL;
598 }
599
600 /* rx_buff */
601 self->rx_buff.head = kmalloc(rxsize, GFP_KERNEL);
602 if (!self->rx_buff.head)
603 return -ENOMEM;
604
605 self->rx_buff.truesize = rxsize;
606 self->rx_buff.in_frame = FALSE;
607 self->rx_buff.state = OUTSIDE_FRAME;
608 self->rx_buff.data = self->rx_buff.head;
609
610 /* tx_buff */
611 self->tx_buff.head = self->membase + IRDARAM;
612 self->tx_buff.truesize = IRDARAM_LEN;
613
614 return 0;
615}
616
617/************************************************************************
618
619
620 net_device_ops function
621
622
623************************************************************************/
624static int sh_irda_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
625{
626 struct sh_irda_self *self = netdev_priv(ndev);
627 struct device *dev = &self->ndev->dev;
628 int speed = irda_get_next_speed(skb);
629 int ret;
630
631 dev_dbg(dev, "hard xmit\n");
632
633 netif_stop_queue(ndev);
634 sh_irda_rcv_ctrl(self, 0);
635
636 ret = sh_irda_set_baudrate(self, speed);
637 if (ret < 0)
638 return ret;
639
640 self->tx_buff.len = 0;
641 if (skb->len) {
642 unsigned long flags;
643
644 spin_lock_irqsave(&self->lock, flags);
645 self->tx_buff.len = async_wrap_skb(skb,
646 self->tx_buff.head,
647 self->tx_buff.truesize);
648 spin_unlock_irqrestore(&self->lock, flags);
649
650 if (self->tx_buff.len > self->tx_buff.truesize)
651 self->tx_buff.len = self->tx_buff.truesize;
652
653 sh_irda_write(self, IRTFLR, self->tx_buff.len);
654 sh_irda_write(self, IRTCTR, ARMOD | TE);
655 }
656
657 dev_kfree_skb(skb);
658
659 return 0;
660}
661
662static int sh_irda_ioctl(struct net_device *ndev, struct ifreq *ifreq, int cmd)
663{
664 /*
665 * FIXME
666 *
667 * This function is needed for irda framework.
668 * But nothing to do now
669 */
670 return 0;
671}
672
673static struct net_device_stats *sh_irda_stats(struct net_device *ndev)
674{
675 struct sh_irda_self *self = netdev_priv(ndev);
676
677 return &self->ndev->stats;
678}
679
680static int sh_irda_open(struct net_device *ndev)
681{
682 struct sh_irda_self *self = netdev_priv(ndev);
683 int err;
684
685 clk_enable(self->clk);
686 err = sh_irda_crc_init(self);
687 if (err)
688 goto open_err;
689
690 sh_irda_set_mode(self, SH_IRDA_SIR);
691 sh_irda_set_timeout(self, 2);
692 sh_irda_set_baudrate(self, 9600);
693
694 self->irlap = irlap_open(ndev, &self->qos, DRIVER_NAME);
695 if (!self->irlap) {
696 err = -ENODEV;
697 goto open_err;
698 }
699
700 netif_start_queue(ndev);
701 sh_irda_rcv_ctrl(self, 1);
702 sh_irda_set_irq_mask(self);
703
704 dev_info(&ndev->dev, "opened\n");
705
706 return 0;
707
708open_err:
709 clk_disable(self->clk);
710
711 return err;
712}
713
714static int sh_irda_stop(struct net_device *ndev)
715{
716 struct sh_irda_self *self = netdev_priv(ndev);
717
718 /* Stop IrLAP */
719 if (self->irlap) {
720 irlap_close(self->irlap);
721 self->irlap = NULL;
722 }
723
724 netif_stop_queue(ndev);
725
726 dev_info(&ndev->dev, "stoped\n");
727
728 return 0;
729}
730
731static const struct net_device_ops sh_irda_ndo = {
732 .ndo_open = sh_irda_open,
733 .ndo_stop = sh_irda_stop,
734 .ndo_start_xmit = sh_irda_hard_xmit,
735 .ndo_do_ioctl = sh_irda_ioctl,
736 .ndo_get_stats = sh_irda_stats,
737};
738
739/************************************************************************
740
741
742 platform_driver function
743
744
745************************************************************************/
746static int __devinit sh_irda_probe(struct platform_device *pdev)
747{
748 struct net_device *ndev;
749 struct sh_irda_self *self;
750 struct resource *res;
751 char clk_name[8];
752 unsigned int irq;
753 int err = -ENOMEM;
754
755 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
756 irq = platform_get_irq(pdev, 0);
757 if (!res || irq < 0) {
758 dev_err(&pdev->dev, "Not enough platform resources.\n");
759 goto exit;
760 }
761
762 ndev = alloc_irdadev(sizeof(*self));
763 if (!ndev)
764 goto exit;
765
766 self = netdev_priv(ndev);
767 self->membase = ioremap_nocache(res->start, resource_size(res));
768 if (!self->membase) {
769 err = -ENXIO;
770 dev_err(&pdev->dev, "Unable to ioremap.\n");
771 goto err_mem_1;
772 }
773
774 err = sh_irda_init_iobuf(self, IRDA_SKB_MAX_MTU, IRDA_SIR_MAX_FRAME);
775 if (err)
776 goto err_mem_2;
777
778 snprintf(clk_name, sizeof(clk_name), "irda%d", pdev->id);
779 self->clk = clk_get(&pdev->dev, clk_name);
780 if (IS_ERR(self->clk)) {
781 dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name);
782 goto err_mem_3;
783 }
784
785 irda_init_max_qos_capabilies(&self->qos);
786
787 ndev->netdev_ops = &sh_irda_ndo;
788 ndev->irq = irq;
789
790 self->ndev = ndev;
791 self->qos.baud_rate.bits &= IR_9600; /* FIXME */
792 self->qos.min_turn_time.bits = 1; /* 10 ms or more */
793 spin_lock_init(&self->lock);
794
795 irda_qos_bits_to_value(&self->qos);
796
797 err = register_netdev(ndev);
798 if (err)
799 goto err_mem_4;
800
801 platform_set_drvdata(pdev, ndev);
802
803 if (request_irq(irq, sh_irda_irq, IRQF_DISABLED, "sh_irda", self)) {
804 dev_warn(&pdev->dev, "Unable to attach sh_irda interrupt\n");
805 goto err_mem_4;
806 }
807
808 dev_info(&pdev->dev, "SuperH IrDA probed\n");
809
810 goto exit;
811
812err_mem_4:
813 clk_put(self->clk);
814err_mem_3:
815 sh_irda_remove_iobuf(self);
816err_mem_2:
817 iounmap(self->membase);
818err_mem_1:
819 free_netdev(ndev);
820exit:
821 return err;
822}
823
824static int __devexit sh_irda_remove(struct platform_device *pdev)
825{
826 struct net_device *ndev = platform_get_drvdata(pdev);
827 struct sh_irda_self *self = netdev_priv(ndev);
828
829 if (!self)
830 return 0;
831
832 unregister_netdev(ndev);
833 clk_put(self->clk);
834 sh_irda_remove_iobuf(self);
835 iounmap(self->membase);
836 free_netdev(ndev);
837 platform_set_drvdata(pdev, NULL);
838
839 return 0;
840}
841
842static struct platform_driver sh_irda_driver = {
843 .probe = sh_irda_probe,
844 .remove = __devexit_p(sh_irda_remove),
845 .driver = {
846 .name = DRIVER_NAME,
847 },
848};
849
850static int __init sh_irda_init(void)
851{
852 return platform_driver_register(&sh_irda_driver);
853}
854
855static void __exit sh_irda_exit(void)
856{
857 platform_driver_unregister(&sh_irda_driver);
858}
859
860module_init(sh_irda_init);
861module_exit(sh_irda_exit);
862
863MODULE_AUTHOR("Kuninori Morimoto <morimoto.kuninori@renesas.com>");
864MODULE_DESCRIPTION("SuperH IrDA driver");
865MODULE_LICENSE("GPL");
diff --git a/drivers/net/irda/sh_sir.c b/drivers/net/irda/sh_sir.c
index d7c983dc91ad..7c17ab8ecc29 100644
--- a/drivers/net/irda/sh_sir.c
+++ b/drivers/net/irda/sh_sir.c
@@ -645,8 +645,10 @@ static int sh_sir_open(struct net_device *ndev)
645 sh_sir_set_baudrate(self, 9600); 645 sh_sir_set_baudrate(self, 9600);
646 646
647 self->irlap = irlap_open(ndev, &self->qos, DRIVER_NAME); 647 self->irlap = irlap_open(ndev, &self->qos, DRIVER_NAME);
648 if (!self->irlap) 648 if (!self->irlap) {
649 err = -ENODEV;
649 goto open_err; 650 goto open_err;
651 }
650 652
651 /* 653 /*
652 * Now enable the interrupt then start the queue 654 * Now enable the interrupt then start the queue
@@ -706,7 +708,6 @@ static int __devinit sh_sir_probe(struct platform_device *pdev)
706 struct sh_sir_self *self; 708 struct sh_sir_self *self;
707 struct resource *res; 709 struct resource *res;
708 char clk_name[8]; 710 char clk_name[8];
709 void __iomem *base;
710 unsigned int irq; 711 unsigned int irq;
711 int err = -ENOMEM; 712 int err = -ENOMEM;
712 713
@@ -721,14 +722,14 @@ static int __devinit sh_sir_probe(struct platform_device *pdev)
721 if (!ndev) 722 if (!ndev)
722 goto exit; 723 goto exit;
723 724
724 base = ioremap_nocache(res->start, resource_size(res)); 725 self = netdev_priv(ndev);
725 if (!base) { 726 self->membase = ioremap_nocache(res->start, resource_size(res));
727 if (!self->membase) {
726 err = -ENXIO; 728 err = -ENXIO;
727 dev_err(&pdev->dev, "Unable to ioremap.\n"); 729 dev_err(&pdev->dev, "Unable to ioremap.\n");
728 goto err_mem_1; 730 goto err_mem_1;
729 } 731 }
730 732
731 self = netdev_priv(ndev);
732 err = sh_sir_init_iobuf(self, IRDA_SKB_MAX_MTU, IRDA_SIR_MAX_FRAME); 733 err = sh_sir_init_iobuf(self, IRDA_SKB_MAX_MTU, IRDA_SIR_MAX_FRAME);
733 if (err) 734 if (err)
734 goto err_mem_2; 735 goto err_mem_2;
@@ -745,7 +746,6 @@ static int __devinit sh_sir_probe(struct platform_device *pdev)
745 ndev->netdev_ops = &sh_sir_ndo; 746 ndev->netdev_ops = &sh_sir_ndo;
746 ndev->irq = irq; 747 ndev->irq = irq;
747 748
748 self->membase = base;
749 self->ndev = ndev; 749 self->ndev = ndev;
750 self->qos.baud_rate.bits &= IR_9600; /* FIXME */ 750 self->qos.baud_rate.bits &= IR_9600; /* FIXME */
751 self->qos.min_turn_time.bits = 1; /* 10 ms or more */ 751 self->qos.min_turn_time.bits = 1; /* 10 ms or more */
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index 209d4bcfaced..e14505272870 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -1742,7 +1742,7 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
1742 vlsi_irda_dev_t *idev; 1742 vlsi_irda_dev_t *idev;
1743 1743
1744 if (!ndev) { 1744 if (!ndev) {
1745 IRDA_ERROR("%s - %s: no netdevice \n", 1745 IRDA_ERROR("%s - %s: no netdevice\n",
1746 __func__, pci_name(pdev)); 1746 __func__, pci_name(pdev));
1747 return 0; 1747 return 0;
1748 } 1748 }
@@ -1781,7 +1781,7 @@ static int vlsi_irda_resume(struct pci_dev *pdev)
1781 vlsi_irda_dev_t *idev; 1781 vlsi_irda_dev_t *idev;
1782 1782
1783 if (!ndev) { 1783 if (!ndev) {
1784 IRDA_ERROR("%s - %s: no netdevice \n", 1784 IRDA_ERROR("%s - %s: no netdevice\n",
1785 __func__, pci_name(pdev)); 1785 __func__, pci_name(pdev));
1786 return 0; 1786 return 0;
1787 } 1787 }
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index e6e972d9b7ca..cd65b8629bcc 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -961,15 +961,15 @@ static void veth_set_multicast_list(struct net_device *dev)
961 (netdev_mc_count(dev) > VETH_MAX_MCAST)) { 961 (netdev_mc_count(dev) > VETH_MAX_MCAST)) {
962 port->promiscuous = 1; 962 port->promiscuous = 1;
963 } else { 963 } else {
964 struct dev_mc_list *dmi; 964 struct netdev_hw_addr *ha;
965 965
966 port->promiscuous = 0; 966 port->promiscuous = 0;
967 967
968 /* Update table */ 968 /* Update table */
969 port->num_mcast = 0; 969 port->num_mcast = 0;
970 970
971 netdev_for_each_mc_addr(dmi, dev) { 971 netdev_for_each_mc_addr(ha, dev) {
972 u8 *addr = dmi->dmi_addr; 972 u8 *addr = ha->addr;
973 u64 xaddr = 0; 973 u64 xaddr = 0;
974 974
975 if (addr[0] & 0x01) {/* multicast address? */ 975 if (addr[0] & 0x01) {/* multicast address? */
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index c9fef65cb98b..912dd1d5772c 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -1058,7 +1058,7 @@ ixgb_set_multi(struct net_device *netdev)
1058{ 1058{
1059 struct ixgb_adapter *adapter = netdev_priv(netdev); 1059 struct ixgb_adapter *adapter = netdev_priv(netdev);
1060 struct ixgb_hw *hw = &adapter->hw; 1060 struct ixgb_hw *hw = &adapter->hw;
1061 struct dev_mc_list *mc_ptr; 1061 struct netdev_hw_addr *ha;
1062 u32 rctl; 1062 u32 rctl;
1063 int i; 1063 int i;
1064 1064
@@ -1089,9 +1089,9 @@ ixgb_set_multi(struct net_device *netdev)
1089 IXGB_WRITE_REG(hw, RCTL, rctl); 1089 IXGB_WRITE_REG(hw, RCTL, rctl);
1090 1090
1091 i = 0; 1091 i = 0;
1092 netdev_for_each_mc_addr(mc_ptr, netdev) 1092 netdev_for_each_mc_addr(ha, netdev)
1093 memcpy(&mta[i++ * IXGB_ETH_LENGTH_OF_ADDRESS], 1093 memcpy(&mta[i++ * IXGB_ETH_LENGTH_OF_ADDRESS],
1094 mc_ptr->dmi_addr, IXGB_ETH_LENGTH_OF_ADDRESS); 1094 ha->addr, IXGB_ETH_LENGTH_OF_ADDRESS);
1095 1095
1096 ixgb_mc_addr_list_update(hw, mta, netdev_mc_count(netdev), 0); 1096 ixgb_mc_addr_list_update(hw, mta, netdev_mc_count(netdev), 0);
1097 } 1097 }
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c
index b405a00817c6..f894bb633040 100644
--- a/drivers/net/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ixgbe/ixgbe_82599.c
@@ -1269,7 +1269,7 @@ s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw)
1269 } 1269 }
1270 if (i >= IXGBE_FDIRCMD_CMD_POLL) { 1270 if (i >= IXGBE_FDIRCMD_CMD_POLL) {
1271 hw_dbg(hw ,"Flow Director previous command isn't complete, " 1271 hw_dbg(hw ,"Flow Director previous command isn't complete, "
1272 "aborting table re-initialization. \n"); 1272 "aborting table re-initialization.\n");
1273 return IXGBE_ERR_FDIR_REINIT_FAILED; 1273 return IXGBE_ERR_FDIR_REINIT_FAILED;
1274 } 1274 }
1275 1275
diff --git a/drivers/net/ixgbe/ixgbe_common.c b/drivers/net/ixgbe/ixgbe_common.c
index eb49020903c1..6eb5814ca7da 100644
--- a/drivers/net/ixgbe/ixgbe_common.c
+++ b/drivers/net/ixgbe/ixgbe_common.c
@@ -1484,26 +1484,24 @@ static void ixgbe_set_mta(struct ixgbe_hw *hw, u8 *mc_addr)
1484/** 1484/**
1485 * ixgbe_update_mc_addr_list_generic - Updates MAC list of multicast addresses 1485 * ixgbe_update_mc_addr_list_generic - Updates MAC list of multicast addresses
1486 * @hw: pointer to hardware structure 1486 * @hw: pointer to hardware structure
1487 * @mc_addr_list: the list of new multicast addresses 1487 * @netdev: pointer to net device structure
1488 * @mc_addr_count: number of addresses
1489 * @next: iterator function to walk the multicast address list
1490 * 1488 *
1491 * The given list replaces any existing list. Clears the MC addrs from receive 1489 * The given list replaces any existing list. Clears the MC addrs from receive
1492 * address registers and the multicast table. Uses unused receive address 1490 * address registers and the multicast table. Uses unused receive address
1493 * registers for the first multicast addresses, and hashes the rest into the 1491 * registers for the first multicast addresses, and hashes the rest into the
1494 * multicast table. 1492 * multicast table.
1495 **/ 1493 **/
1496s32 ixgbe_update_mc_addr_list_generic(struct ixgbe_hw *hw, u8 *mc_addr_list, 1494s32 ixgbe_update_mc_addr_list_generic(struct ixgbe_hw *hw,
1497 u32 mc_addr_count, ixgbe_mc_addr_itr next) 1495 struct net_device *netdev)
1498{ 1496{
1497 struct netdev_hw_addr *ha;
1499 u32 i; 1498 u32 i;
1500 u32 vmdq;
1501 1499
1502 /* 1500 /*
1503 * Set the new number of MC addresses that we are being requested to 1501 * Set the new number of MC addresses that we are being requested to
1504 * use. 1502 * use.
1505 */ 1503 */
1506 hw->addr_ctrl.num_mc_addrs = mc_addr_count; 1504 hw->addr_ctrl.num_mc_addrs = netdev_mc_count(netdev);
1507 hw->addr_ctrl.mta_in_use = 0; 1505 hw->addr_ctrl.mta_in_use = 0;
1508 1506
1509 /* Clear the MTA */ 1507 /* Clear the MTA */
@@ -1512,9 +1510,9 @@ s32 ixgbe_update_mc_addr_list_generic(struct ixgbe_hw *hw, u8 *mc_addr_list,
1512 IXGBE_WRITE_REG(hw, IXGBE_MTA(i), 0); 1510 IXGBE_WRITE_REG(hw, IXGBE_MTA(i), 0);
1513 1511
1514 /* Add the new addresses */ 1512 /* Add the new addresses */
1515 for (i = 0; i < mc_addr_count; i++) { 1513 netdev_for_each_mc_addr(ha, netdev) {
1516 hw_dbg(hw, " Adding the multicast addresses:\n"); 1514 hw_dbg(hw, " Adding the multicast addresses:\n");
1517 ixgbe_set_mta(hw, next(hw, &mc_addr_list, &vmdq)); 1515 ixgbe_set_mta(hw, ha->addr);
1518 } 1516 }
1519 1517
1520 /* Enable mta */ 1518 /* Enable mta */
diff --git a/drivers/net/ixgbe/ixgbe_common.h b/drivers/net/ixgbe/ixgbe_common.h
index 13606d4809c9..264eef575cd6 100644
--- a/drivers/net/ixgbe/ixgbe_common.h
+++ b/drivers/net/ixgbe/ixgbe_common.h
@@ -56,9 +56,8 @@ s32 ixgbe_set_rar_generic(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
56 u32 enable_addr); 56 u32 enable_addr);
57s32 ixgbe_clear_rar_generic(struct ixgbe_hw *hw, u32 index); 57s32 ixgbe_clear_rar_generic(struct ixgbe_hw *hw, u32 index);
58s32 ixgbe_init_rx_addrs_generic(struct ixgbe_hw *hw); 58s32 ixgbe_init_rx_addrs_generic(struct ixgbe_hw *hw);
59s32 ixgbe_update_mc_addr_list_generic(struct ixgbe_hw *hw, u8 *mc_addr_list, 59s32 ixgbe_update_mc_addr_list_generic(struct ixgbe_hw *hw,
60 u32 mc_addr_count, 60 struct net_device *netdev);
61 ixgbe_mc_addr_itr func);
62s32 ixgbe_update_uc_addr_list_generic(struct ixgbe_hw *hw, 61s32 ixgbe_update_uc_addr_list_generic(struct ixgbe_hw *hw,
63 struct net_device *netdev); 62 struct net_device *netdev);
64s32 ixgbe_enable_mc_generic(struct ixgbe_hw *hw); 63s32 ixgbe_enable_mc_generic(struct ixgbe_hw *hw);
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 0c553f6cb534..7216db218442 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -2537,21 +2537,6 @@ static void ixgbe_restore_vlan(struct ixgbe_adapter *adapter)
2537 } 2537 }
2538} 2538}
2539 2539
2540static u8 *ixgbe_addr_list_itr(struct ixgbe_hw *hw, u8 **mc_addr_ptr, u32 *vmdq)
2541{
2542 struct dev_mc_list *mc_ptr;
2543 u8 *addr = *mc_addr_ptr;
2544 *vmdq = 0;
2545
2546 mc_ptr = container_of(addr, struct dev_mc_list, dmi_addr[0]);
2547 if (mc_ptr->next)
2548 *mc_addr_ptr = mc_ptr->next->dmi_addr;
2549 else
2550 *mc_addr_ptr = NULL;
2551
2552 return addr;
2553}
2554
2555/** 2540/**
2556 * ixgbe_set_rx_mode - Unicast, Multicast and Promiscuous mode set 2541 * ixgbe_set_rx_mode - Unicast, Multicast and Promiscuous mode set
2557 * @netdev: network interface device structure 2542 * @netdev: network interface device structure
@@ -2566,8 +2551,6 @@ void ixgbe_set_rx_mode(struct net_device *netdev)
2566 struct ixgbe_adapter *adapter = netdev_priv(netdev); 2551 struct ixgbe_adapter *adapter = netdev_priv(netdev);
2567 struct ixgbe_hw *hw = &adapter->hw; 2552 struct ixgbe_hw *hw = &adapter->hw;
2568 u32 fctrl, vlnctrl; 2553 u32 fctrl, vlnctrl;
2569 u8 *addr_list = NULL;
2570 int addr_count = 0;
2571 2554
2572 /* Check for Promiscuous and All Multicast modes */ 2555 /* Check for Promiscuous and All Multicast modes */
2573 2556
@@ -2596,11 +2579,8 @@ void ixgbe_set_rx_mode(struct net_device *netdev)
2596 hw->mac.ops.update_uc_addr_list(hw, netdev); 2579 hw->mac.ops.update_uc_addr_list(hw, netdev);
2597 2580
2598 /* reprogram multicast list */ 2581 /* reprogram multicast list */
2599 addr_count = netdev_mc_count(netdev); 2582 hw->mac.ops.update_mc_addr_list(hw, netdev);
2600 if (addr_count) 2583
2601 addr_list = netdev->mc_list->dmi_addr;
2602 hw->mac.ops.update_mc_addr_list(hw, addr_list, addr_count,
2603 ixgbe_addr_list_itr);
2604 if (adapter->num_vfs) 2584 if (adapter->num_vfs)
2605 ixgbe_restore_vf_multicasts(adapter); 2585 ixgbe_restore_vf_multicasts(adapter);
2606} 2586}
@@ -3470,12 +3450,12 @@ static inline bool ixgbe_set_fcoe_queues(struct ixgbe_adapter *adapter)
3470 adapter->num_tx_queues = 1; 3450 adapter->num_tx_queues = 1;
3471#ifdef CONFIG_IXGBE_DCB 3451#ifdef CONFIG_IXGBE_DCB
3472 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { 3452 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
3473 DPRINTK(PROBE, INFO, "FCoE enabled with DCB \n"); 3453 DPRINTK(PROBE, INFO, "FCoE enabled with DCB\n");
3474 ixgbe_set_dcb_queues(adapter); 3454 ixgbe_set_dcb_queues(adapter);
3475 } 3455 }
3476#endif 3456#endif
3477 if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) { 3457 if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) {
3478 DPRINTK(PROBE, INFO, "FCoE enabled with RSS \n"); 3458 DPRINTK(PROBE, INFO, "FCoE enabled with RSS\n");
3479 if ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) || 3459 if ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) ||
3480 (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)) 3460 (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE))
3481 ixgbe_set_fdir_queues(adapter); 3461 ixgbe_set_fdir_queues(adapter);
@@ -5091,7 +5071,7 @@ static void ixgbe_fdir_reinit_task(struct work_struct *work)
5091 &(adapter->tx_ring[i]->reinit_state)); 5071 &(adapter->tx_ring[i]->reinit_state));
5092 } else { 5072 } else {
5093 DPRINTK(PROBE, ERR, "failed to finish FDIR re-initialization, " 5073 DPRINTK(PROBE, ERR, "failed to finish FDIR re-initialization, "
5094 "ignored adding FDIR ATR filters \n"); 5074 "ignored adding FDIR ATR filters\n");
5095 } 5075 }
5096 /* Done FDIR Re-initialization, enable transmits */ 5076 /* Done FDIR Re-initialization, enable transmits */
5097 netif_tx_start_all_queues(adapter->netdev); 5077 netif_tx_start_all_queues(adapter->netdev);
diff --git a/drivers/net/ixgbe/ixgbe_phy.c b/drivers/net/ixgbe/ixgbe_phy.c
index 1c1efd386956..d6d5b843d625 100644
--- a/drivers/net/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ixgbe/ixgbe_phy.c
@@ -475,7 +475,7 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
475 msleep(edata); 475 msleep(edata);
476 break; 476 break;
477 case IXGBE_DATA_NL: 477 case IXGBE_DATA_NL:
478 hw_dbg(hw, "DATA: \n"); 478 hw_dbg(hw, "DATA:\n");
479 data_offset++; 479 data_offset++;
480 hw->eeprom.ops.read(hw, data_offset++, 480 hw->eeprom.ops.read(hw, data_offset++,
481 &phy_offset); 481 &phy_offset);
@@ -491,7 +491,7 @@ s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
491 break; 491 break;
492 case IXGBE_CONTROL_NL: 492 case IXGBE_CONTROL_NL:
493 data_offset++; 493 data_offset++;
494 hw_dbg(hw, "CONTROL: \n"); 494 hw_dbg(hw, "CONTROL:\n");
495 if (edata == IXGBE_CONTROL_EOL_NL) { 495 if (edata == IXGBE_CONTROL_EOL_NL) {
496 hw_dbg(hw, "EOL\n"); 496 hw_dbg(hw, "EOL\n");
497 end_data = true; 497 end_data = true;
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h
index 4ec6dc1a5b75..aed4ed665648 100644
--- a/drivers/net/ixgbe/ixgbe_type.h
+++ b/drivers/net/ixgbe/ixgbe_type.h
@@ -2417,8 +2417,7 @@ struct ixgbe_mac_operations {
2417 s32 (*clear_vmdq)(struct ixgbe_hw *, u32, u32); 2417 s32 (*clear_vmdq)(struct ixgbe_hw *, u32, u32);
2418 s32 (*init_rx_addrs)(struct ixgbe_hw *); 2418 s32 (*init_rx_addrs)(struct ixgbe_hw *);
2419 s32 (*update_uc_addr_list)(struct ixgbe_hw *, struct net_device *); 2419 s32 (*update_uc_addr_list)(struct ixgbe_hw *, struct net_device *);
2420 s32 (*update_mc_addr_list)(struct ixgbe_hw *, u8 *, u32, 2420 s32 (*update_mc_addr_list)(struct ixgbe_hw *, struct net_device *);
2421 ixgbe_mc_addr_itr);
2422 s32 (*enable_mc)(struct ixgbe_hw *); 2421 s32 (*enable_mc)(struct ixgbe_hw *);
2423 s32 (*disable_mc)(struct ixgbe_hw *); 2422 s32 (*disable_mc)(struct ixgbe_hw *);
2424 s32 (*clear_vfta)(struct ixgbe_hw *); 2423 s32 (*clear_vfta)(struct ixgbe_hw *);
diff --git a/drivers/net/ixgbevf/ixgbevf_main.c b/drivers/net/ixgbevf/ixgbevf_main.c
index 1bbbef3ee3f4..65cb133a6a1f 100644
--- a/drivers/net/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ixgbevf/ixgbevf_main.c
@@ -1495,22 +1495,6 @@ static void ixgbevf_restore_vlan(struct ixgbevf_adapter *adapter)
1495 } 1495 }
1496} 1496}
1497 1497
1498static u8 *ixgbevf_addr_list_itr(struct ixgbe_hw *hw, u8 **mc_addr_ptr,
1499 u32 *vmdq)
1500{
1501 struct dev_mc_list *mc_ptr;
1502 u8 *addr = *mc_addr_ptr;
1503 *vmdq = 0;
1504
1505 mc_ptr = container_of(addr, struct dev_mc_list, dmi_addr[0]);
1506 if (mc_ptr->next)
1507 *mc_addr_ptr = mc_ptr->next->dmi_addr;
1508 else
1509 *mc_addr_ptr = NULL;
1510
1511 return addr;
1512}
1513
1514/** 1498/**
1515 * ixgbevf_set_rx_mode - Multicast set 1499 * ixgbevf_set_rx_mode - Multicast set
1516 * @netdev: network interface device structure 1500 * @netdev: network interface device structure
@@ -1523,16 +1507,10 @@ static void ixgbevf_set_rx_mode(struct net_device *netdev)
1523{ 1507{
1524 struct ixgbevf_adapter *adapter = netdev_priv(netdev); 1508 struct ixgbevf_adapter *adapter = netdev_priv(netdev);
1525 struct ixgbe_hw *hw = &adapter->hw; 1509 struct ixgbe_hw *hw = &adapter->hw;
1526 u8 *addr_list = NULL;
1527 int addr_count = 0;
1528 1510
1529 /* reprogram multicast list */ 1511 /* reprogram multicast list */
1530 addr_count = netdev_mc_count(netdev);
1531 if (addr_count)
1532 addr_list = netdev->mc_list->dmi_addr;
1533 if (hw->mac.ops.update_mc_addr_list) 1512 if (hw->mac.ops.update_mc_addr_list)
1534 hw->mac.ops.update_mc_addr_list(hw, addr_list, addr_count, 1513 hw->mac.ops.update_mc_addr_list(hw, netdev);
1535 ixgbevf_addr_list_itr);
1536} 1514}
1537 1515
1538static void ixgbevf_napi_enable_all(struct ixgbevf_adapter *adapter) 1516static void ixgbevf_napi_enable_all(struct ixgbevf_adapter *adapter)
@@ -2417,9 +2395,9 @@ static void ixgbevf_watchdog_task(struct work_struct *work)
2417 2395
2418 if (link_up) { 2396 if (link_up) {
2419 if (!netif_carrier_ok(netdev)) { 2397 if (!netif_carrier_ok(netdev)) {
2420 hw_dbg(&adapter->hw, "NIC Link is Up %s, ", 2398 hw_dbg(&adapter->hw, "NIC Link is Up, %u Gbps\n",
2421 ((link_speed == IXGBE_LINK_SPEED_10GB_FULL) ? 2399 (link_speed == IXGBE_LINK_SPEED_10GB_FULL) ?
2422 "10 Gbps\n" : "1 Gbps\n")); 2400 10 : 1);
2423 netif_carrier_on(netdev); 2401 netif_carrier_on(netdev);
2424 netif_tx_wake_all_queues(netdev); 2402 netif_tx_wake_all_queues(netdev);
2425 } else { 2403 } else {
@@ -3481,7 +3459,7 @@ static int __devinit ixgbevf_probe(struct pci_dev *pdev,
3481 3459
3482 hw_dbg(hw, "MAC: %d\n", hw->mac.type); 3460 hw_dbg(hw, "MAC: %d\n", hw->mac.type);
3483 3461
3484 hw_dbg(hw, "LRO is disabled \n"); 3462 hw_dbg(hw, "LRO is disabled\n");
3485 3463
3486 hw_dbg(hw, "Intel(R) 82599 Virtual Function\n"); 3464 hw_dbg(hw, "Intel(R) 82599 Virtual Function\n");
3487 cards_found++; 3465 cards_found++;
diff --git a/drivers/net/ixgbevf/vf.c b/drivers/net/ixgbevf/vf.c
index 4b5dec0ec140..852e9c4fd934 100644
--- a/drivers/net/ixgbevf/vf.c
+++ b/drivers/net/ixgbevf/vf.c
@@ -252,22 +252,18 @@ static s32 ixgbevf_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 *addr,
252/** 252/**
253 * ixgbevf_update_mc_addr_list_vf - Update Multicast addresses 253 * ixgbevf_update_mc_addr_list_vf - Update Multicast addresses
254 * @hw: pointer to the HW structure 254 * @hw: pointer to the HW structure
255 * @mc_addr_list: array of multicast addresses to program 255 * @netdev: pointer to net device structure
256 * @mc_addr_count: number of multicast addresses to program
257 * @next: caller supplied function to return next address in list
258 * 256 *
259 * Updates the Multicast Table Array. 257 * Updates the Multicast Table Array.
260 **/ 258 **/
261static s32 ixgbevf_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 *mc_addr_list, 259static s32 ixgbevf_update_mc_addr_list_vf(struct ixgbe_hw *hw,
262 u32 mc_addr_count, 260 struct net_device *netdev)
263 ixgbe_mc_addr_itr next)
264{ 261{
262 struct netdev_hw_addr *ha;
265 struct ixgbe_mbx_info *mbx = &hw->mbx; 263 struct ixgbe_mbx_info *mbx = &hw->mbx;
266 u32 msgbuf[IXGBE_VFMAILBOX_SIZE]; 264 u32 msgbuf[IXGBE_VFMAILBOX_SIZE];
267 u16 *vector_list = (u16 *)&msgbuf[1]; 265 u16 *vector_list = (u16 *)&msgbuf[1];
268 u32 vector;
269 u32 cnt, i; 266 u32 cnt, i;
270 u32 vmdq;
271 267
272 /* Each entry in the list uses 1 16 bit word. We have 30 268 /* Each entry in the list uses 1 16 bit word. We have 30
273 * 16 bit words available in our HW msg buffer (minus 1 for the 269 * 16 bit words available in our HW msg buffer (minus 1 for the
@@ -278,13 +274,17 @@ static s32 ixgbevf_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 *mc_addr_list,
278 * addresses except for in large enterprise network environments. 274 * addresses except for in large enterprise network environments.
279 */ 275 */
280 276
281 cnt = (mc_addr_count > 30) ? 30 : mc_addr_count; 277 cnt = netdev_mc_count(netdev);
278 if (cnt > 30)
279 cnt = 30;
282 msgbuf[0] = IXGBE_VF_SET_MULTICAST; 280 msgbuf[0] = IXGBE_VF_SET_MULTICAST;
283 msgbuf[0] |= cnt << IXGBE_VT_MSGINFO_SHIFT; 281 msgbuf[0] |= cnt << IXGBE_VT_MSGINFO_SHIFT;
284 282
285 for (i = 0; i < cnt; i++) { 283 i = 0;
286 vector = ixgbevf_mta_vector(hw, next(hw, &mc_addr_list, &vmdq)); 284 netdev_for_each_mc_addr(ha, netdev) {
287 vector_list[i] = vector; 285 if (i == cnt)
286 break;
287 vector_list[i++] = ixgbevf_mta_vector(hw, ha->addr);
288 } 288 }
289 289
290 mbx->ops.write_posted(hw, msgbuf, IXGBE_VFMAILBOX_SIZE); 290 mbx->ops.write_posted(hw, msgbuf, IXGBE_VFMAILBOX_SIZE);
diff --git a/drivers/net/ixgbevf/vf.h b/drivers/net/ixgbevf/vf.h
index 1f31b052d4b4..94b750b8874f 100644
--- a/drivers/net/ixgbevf/vf.h
+++ b/drivers/net/ixgbevf/vf.h
@@ -32,6 +32,7 @@
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/interrupt.h> 33#include <linux/interrupt.h>
34#include <linux/if_ether.h> 34#include <linux/if_ether.h>
35#include <linux/netdevice.h>
35 36
36#include "defines.h" 37#include "defines.h"
37#include "regs.h" 38#include "regs.h"
@@ -62,8 +63,7 @@ struct ixgbe_mac_operations {
62 /* RAR, Multicast, VLAN */ 63 /* RAR, Multicast, VLAN */
63 s32 (*set_rar)(struct ixgbe_hw *, u32, u8 *, u32); 64 s32 (*set_rar)(struct ixgbe_hw *, u32, u8 *, u32);
64 s32 (*init_rx_addrs)(struct ixgbe_hw *); 65 s32 (*init_rx_addrs)(struct ixgbe_hw *);
65 s32 (*update_mc_addr_list)(struct ixgbe_hw *, u8 *, u32, 66 s32 (*update_mc_addr_list)(struct ixgbe_hw *, struct net_device *);
66 ixgbe_mc_addr_itr);
67 s32 (*enable_mc)(struct ixgbe_hw *); 67 s32 (*enable_mc)(struct ixgbe_hw *);
68 s32 (*disable_mc)(struct ixgbe_hw *); 68 s32 (*disable_mc)(struct ixgbe_hw *);
69 s32 (*clear_vfta)(struct ixgbe_hw *); 69 s32 (*clear_vfta)(struct ixgbe_hw *);
diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index c0b59a555384..10e816d2caff 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -2009,12 +2009,12 @@ jme_set_multi(struct net_device *netdev)
2009 } else if (netdev->flags & IFF_ALLMULTI) { 2009 } else if (netdev->flags & IFF_ALLMULTI) {
2010 jme->reg_rxmcs |= RXMCS_ALLMULFRAME; 2010 jme->reg_rxmcs |= RXMCS_ALLMULFRAME;
2011 } else if (netdev->flags & IFF_MULTICAST) { 2011 } else if (netdev->flags & IFF_MULTICAST) {
2012 struct dev_mc_list *mclist; 2012 struct netdev_hw_addr *ha;
2013 int bit_nr; 2013 int bit_nr;
2014 2014
2015 jme->reg_rxmcs |= RXMCS_MULFRAME | RXMCS_MULFILTERED; 2015 jme->reg_rxmcs |= RXMCS_MULFRAME | RXMCS_MULFILTERED;
2016 netdev_for_each_mc_addr(mclist, netdev) { 2016 netdev_for_each_mc_addr(ha, netdev) {
2017 bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) & 0x3F; 2017 bit_nr = ether_crc(ETH_ALEN, ha->addr) & 0x3F;
2018 mc_hash[bit_nr >> 5] |= 1 << (bit_nr & 0x1F); 2018 mc_hash[bit_nr >> 5] |= 1 << (bit_nr & 0x1F);
2019 } 2019 }
2020 2020
diff --git a/drivers/net/korina.c b/drivers/net/korina.c
index 300c2249812d..26bf1b76b997 100644
--- a/drivers/net/korina.c
+++ b/drivers/net/korina.c
@@ -482,7 +482,7 @@ static void korina_multicast_list(struct net_device *dev)
482{ 482{
483 struct korina_private *lp = netdev_priv(dev); 483 struct korina_private *lp = netdev_priv(dev);
484 unsigned long flags; 484 unsigned long flags;
485 struct dev_mc_list *dmi; 485 struct netdev_hw_addr *ha;
486 u32 recognise = ETH_ARC_AB; /* always accept broadcasts */ 486 u32 recognise = ETH_ARC_AB; /* always accept broadcasts */
487 int i; 487 int i;
488 488
@@ -502,8 +502,8 @@ static void korina_multicast_list(struct net_device *dev)
502 for (i = 0; i < 4; i++) 502 for (i = 0; i < 4; i++)
503 hash_table[i] = 0; 503 hash_table[i] = 0;
504 504
505 netdev_for_each_mc_addr(dmi, dev) { 505 netdev_for_each_mc_addr(ha, dev) {
506 char *addrs = dmi->dmi_addr; 506 char *addrs = ha->addr;
507 507
508 if (!(*addrs & 1)) 508 if (!(*addrs & 1))
509 continue; 509 continue;
@@ -1135,7 +1135,7 @@ static int korina_probe(struct platform_device *pdev)
1135 1135
1136 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "korina_regs"); 1136 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "korina_regs");
1137 dev->base_addr = r->start; 1137 dev->base_addr = r->start;
1138 lp->eth_regs = ioremap_nocache(r->start, r->end - r->start); 1138 lp->eth_regs = ioremap_nocache(r->start, resource_size(r));
1139 if (!lp->eth_regs) { 1139 if (!lp->eth_regs) {
1140 printk(KERN_ERR DRV_NAME ": cannot remap registers\n"); 1140 printk(KERN_ERR DRV_NAME ": cannot remap registers\n");
1141 rc = -ENXIO; 1141 rc = -ENXIO;
@@ -1143,7 +1143,7 @@ static int korina_probe(struct platform_device *pdev)
1143 } 1143 }
1144 1144
1145 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "korina_dma_rx"); 1145 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "korina_dma_rx");
1146 lp->rx_dma_regs = ioremap_nocache(r->start, r->end - r->start); 1146 lp->rx_dma_regs = ioremap_nocache(r->start, resource_size(r));
1147 if (!lp->rx_dma_regs) { 1147 if (!lp->rx_dma_regs) {
1148 printk(KERN_ERR DRV_NAME ": cannot remap Rx DMA registers\n"); 1148 printk(KERN_ERR DRV_NAME ": cannot remap Rx DMA registers\n");
1149 rc = -ENXIO; 1149 rc = -ENXIO;
@@ -1151,7 +1151,7 @@ static int korina_probe(struct platform_device *pdev)
1151 } 1151 }
1152 1152
1153 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "korina_dma_tx"); 1153 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "korina_dma_tx");
1154 lp->tx_dma_regs = ioremap_nocache(r->start, r->end - r->start); 1154 lp->tx_dma_regs = ioremap_nocache(r->start, resource_size(r));
1155 if (!lp->tx_dma_regs) { 1155 if (!lp->tx_dma_regs) {
1156 printk(KERN_ERR DRV_NAME ": cannot remap Tx DMA registers\n"); 1156 printk(KERN_ERR DRV_NAME ": cannot remap Tx DMA registers\n");
1157 rc = -ENXIO; 1157 rc = -ENXIO;
diff --git a/drivers/net/ks8842.c b/drivers/net/ks8842.c
index 5c45cb58d023..b91492f4e48a 100644
--- a/drivers/net/ks8842.c
+++ b/drivers/net/ks8842.c
@@ -20,6 +20,8 @@
20 * The Micrel KS8842 behind the timberdale FPGA 20 * The Micrel KS8842 behind the timberdale FPGA
21 */ 21 */
22 22
23#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24
23#include <linux/kernel.h> 25#include <linux/kernel.h>
24#include <linux/module.h> 26#include <linux/module.h>
25#include <linux/platform_device.h> 27#include <linux/platform_device.h>
@@ -525,8 +527,7 @@ static int ks8842_open(struct net_device *netdev)
525 err = request_irq(adapter->irq, ks8842_irq, IRQF_SHARED, DRV_NAME, 527 err = request_irq(adapter->irq, ks8842_irq, IRQF_SHARED, DRV_NAME,
526 adapter); 528 adapter);
527 if (err) { 529 if (err) {
528 printk(KERN_ERR "Failed to request IRQ: %d: %d\n", 530 pr_err("Failed to request IRQ: %d: %d\n", adapter->irq, err);
529 adapter->irq, err);
530 return err; 531 return err;
531 } 532 }
532 533
@@ -668,8 +669,7 @@ static int __devinit ks8842_probe(struct platform_device *pdev)
668 669
669 platform_set_drvdata(pdev, netdev); 670 platform_set_drvdata(pdev, netdev);
670 671
671 printk(KERN_INFO DRV_NAME 672 pr_info("Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n",
672 " Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n",
673 (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7); 673 (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7);
674 674
675 return 0; 675 return 0;
diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c
index 13cc1ca261d9..4dcd61f81ec2 100644
--- a/drivers/net/ks8851.c
+++ b/drivers/net/ks8851.c
@@ -9,6 +9,8 @@
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11 11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#define DEBUG 14#define DEBUG
13 15
14#include <linux/module.h> 16#include <linux/module.h>
@@ -125,11 +127,6 @@ struct ks8851_net {
125 127
126static int msg_enable; 128static int msg_enable;
127 129
128#define ks_info(_ks, _msg...) dev_info(&(_ks)->spidev->dev, _msg)
129#define ks_warn(_ks, _msg...) dev_warn(&(_ks)->spidev->dev, _msg)
130#define ks_dbg(_ks, _msg...) dev_dbg(&(_ks)->spidev->dev, _msg)
131#define ks_err(_ks, _msg...) dev_err(&(_ks)->spidev->dev, _msg)
132
133/* shift for byte-enable data */ 130/* shift for byte-enable data */
134#define BYTE_EN(_x) ((_x) << 2) 131#define BYTE_EN(_x) ((_x) << 2)
135 132
@@ -167,7 +164,7 @@ static void ks8851_wrreg16(struct ks8851_net *ks, unsigned reg, unsigned val)
167 164
168 ret = spi_sync(ks->spidev, msg); 165 ret = spi_sync(ks->spidev, msg);
169 if (ret < 0) 166 if (ret < 0)
170 ks_err(ks, "spi_sync() failed\n"); 167 netdev_err(ks->netdev, "spi_sync() failed\n");
171} 168}
172 169
173/** 170/**
@@ -197,7 +194,7 @@ static void ks8851_wrreg8(struct ks8851_net *ks, unsigned reg, unsigned val)
197 194
198 ret = spi_sync(ks->spidev, msg); 195 ret = spi_sync(ks->spidev, msg);
199 if (ret < 0) 196 if (ret < 0)
200 ks_err(ks, "spi_sync() failed\n"); 197 netdev_err(ks->netdev, "spi_sync() failed\n");
201} 198}
202 199
203/** 200/**
@@ -263,7 +260,7 @@ static void ks8851_rdreg(struct ks8851_net *ks, unsigned op,
263 260
264 ret = spi_sync(ks->spidev, msg); 261 ret = spi_sync(ks->spidev, msg);
265 if (ret < 0) 262 if (ret < 0)
266 ks_err(ks, "read: spi_sync() failed\n"); 263 netdev_err(ks->netdev, "read: spi_sync() failed\n");
267 else if (ks8851_rx_1msg(ks)) 264 else if (ks8851_rx_1msg(ks))
268 memcpy(rxb, trx + 2, rxl); 265 memcpy(rxb, trx + 2, rxl);
269 else 266 else
@@ -417,8 +414,8 @@ static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned len)
417 u8 txb[1]; 414 u8 txb[1];
418 int ret; 415 int ret;
419 416
420 if (netif_msg_rx_status(ks)) 417 netif_dbg(ks, rx_status, ks->netdev,
421 ks_dbg(ks, "%s: %d@%p\n", __func__, len, buff); 418 "%s: %d@%p\n", __func__, len, buff);
422 419
423 /* set the operation we're issuing */ 420 /* set the operation we're issuing */
424 txb[0] = KS_SPIOP_RXFIFO; 421 txb[0] = KS_SPIOP_RXFIFO;
@@ -434,7 +431,7 @@ static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned len)
434 431
435 ret = spi_sync(ks->spidev, msg); 432 ret = spi_sync(ks->spidev, msg);
436 if (ret < 0) 433 if (ret < 0)
437 ks_err(ks, "%s: spi_sync() failed\n", __func__); 434 netdev_err(ks->netdev, "%s: spi_sync() failed\n", __func__);
438} 435}
439 436
440/** 437/**
@@ -446,10 +443,11 @@ static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned len)
446*/ 443*/
447static void ks8851_dbg_dumpkkt(struct ks8851_net *ks, u8 *rxpkt) 444static void ks8851_dbg_dumpkkt(struct ks8851_net *ks, u8 *rxpkt)
448{ 445{
449 ks_dbg(ks, "pkt %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x\n", 446 netdev_dbg(ks->netdev,
450 rxpkt[4], rxpkt[5], rxpkt[6], rxpkt[7], 447 "pkt %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x\n",
451 rxpkt[8], rxpkt[9], rxpkt[10], rxpkt[11], 448 rxpkt[4], rxpkt[5], rxpkt[6], rxpkt[7],
452 rxpkt[12], rxpkt[13], rxpkt[14], rxpkt[15]); 449 rxpkt[8], rxpkt[9], rxpkt[10], rxpkt[11],
450 rxpkt[12], rxpkt[13], rxpkt[14], rxpkt[15]);
453} 451}
454 452
455/** 453/**
@@ -471,8 +469,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
471 469
472 rxfc = ks8851_rdreg8(ks, KS_RXFC); 470 rxfc = ks8851_rdreg8(ks, KS_RXFC);
473 471
474 if (netif_msg_rx_status(ks)) 472 netif_dbg(ks, rx_status, ks->netdev,
475 ks_dbg(ks, "%s: %d packets\n", __func__, rxfc); 473 "%s: %d packets\n", __func__, rxfc);
476 474
477 /* Currently we're issuing a read per packet, but we could possibly 475 /* Currently we're issuing a read per packet, but we could possibly
478 * improve the code by issuing a single read, getting the receive 476 * improve the code by issuing a single read, getting the receive
@@ -489,9 +487,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
489 rxstat = rxh & 0xffff; 487 rxstat = rxh & 0xffff;
490 rxlen = rxh >> 16; 488 rxlen = rxh >> 16;
491 489
492 if (netif_msg_rx_status(ks)) 490 netif_dbg(ks, rx_status, ks->netdev,
493 ks_dbg(ks, "rx: stat 0x%04x, len 0x%04x\n", 491 "rx: stat 0x%04x, len 0x%04x\n", rxstat, rxlen);
494 rxstat, rxlen);
495 492
496 /* the length of the packet includes the 32bit CRC */ 493 /* the length of the packet includes the 32bit CRC */
497 494
@@ -553,9 +550,8 @@ static void ks8851_irq_work(struct work_struct *work)
553 550
554 status = ks8851_rdreg16(ks, KS_ISR); 551 status = ks8851_rdreg16(ks, KS_ISR);
555 552
556 if (netif_msg_intr(ks)) 553 netif_dbg(ks, intr, ks->netdev,
557 dev_dbg(&ks->spidev->dev, "%s: status 0x%04x\n", 554 "%s: status 0x%04x\n", __func__, status);
558 __func__, status);
559 555
560 if (status & IRQ_LCI) { 556 if (status & IRQ_LCI) {
561 /* should do something about checking link status */ 557 /* should do something about checking link status */
@@ -582,8 +578,8 @@ static void ks8851_irq_work(struct work_struct *work)
582 * system */ 578 * system */
583 ks->tx_space = ks8851_rdreg16(ks, KS_TXMIR); 579 ks->tx_space = ks8851_rdreg16(ks, KS_TXMIR);
584 580
585 if (netif_msg_intr(ks)) 581 netif_dbg(ks, intr, ks->netdev,
586 ks_dbg(ks, "%s: txspace %d\n", __func__, ks->tx_space); 582 "%s: txspace %d\n", __func__, ks->tx_space);
587 } 583 }
588 584
589 if (status & IRQ_RXI) 585 if (status & IRQ_RXI)
@@ -659,9 +655,8 @@ static void ks8851_wrpkt(struct ks8851_net *ks, struct sk_buff *txp, bool irq)
659 unsigned fid = 0; 655 unsigned fid = 0;
660 int ret; 656 int ret;
661 657
662 if (netif_msg_tx_queued(ks)) 658 netif_dbg(ks, tx_queued, ks->netdev, "%s: skb %p, %d@%p, irq %d\n",
663 dev_dbg(&ks->spidev->dev, "%s: skb %p, %d@%p, irq %d\n", 659 __func__, txp, txp->len, txp->data, irq);
664 __func__, txp, txp->len, txp->data, irq);
665 660
666 fid = ks->fid++; 661 fid = ks->fid++;
667 fid &= TXFR_TXFID_MASK; 662 fid &= TXFR_TXFID_MASK;
@@ -685,7 +680,7 @@ static void ks8851_wrpkt(struct ks8851_net *ks, struct sk_buff *txp, bool irq)
685 680
686 ret = spi_sync(ks->spidev, msg); 681 ret = spi_sync(ks->spidev, msg);
687 if (ret < 0) 682 if (ret < 0)
688 ks_err(ks, "%s: spi_sync() failed\n", __func__); 683 netdev_err(ks->netdev, "%s: spi_sync() failed\n", __func__);
689} 684}
690 685
691/** 686/**
@@ -744,8 +739,7 @@ static void ks8851_set_powermode(struct ks8851_net *ks, unsigned pwrmode)
744{ 739{
745 unsigned pmecr; 740 unsigned pmecr;
746 741
747 if (netif_msg_hw(ks)) 742 netif_dbg(ks, hw, ks->netdev, "setting power mode %d\n", pwrmode);
748 ks_dbg(ks, "setting power mode %d\n", pwrmode);
749 743
750 pmecr = ks8851_rdreg16(ks, KS_PMECR); 744 pmecr = ks8851_rdreg16(ks, KS_PMECR);
751 pmecr &= ~PMECR_PM_MASK; 745 pmecr &= ~PMECR_PM_MASK;
@@ -769,8 +763,7 @@ static int ks8851_net_open(struct net_device *dev)
769 * else at the moment */ 763 * else at the moment */
770 mutex_lock(&ks->lock); 764 mutex_lock(&ks->lock);
771 765
772 if (netif_msg_ifup(ks)) 766 netif_dbg(ks, ifup, ks->netdev, "opening\n");
773 ks_dbg(ks, "opening %s\n", dev->name);
774 767
775 /* bring chip out of any power saving mode it was in */ 768 /* bring chip out of any power saving mode it was in */
776 ks8851_set_powermode(ks, PMECR_PM_NORMAL); 769 ks8851_set_powermode(ks, PMECR_PM_NORMAL);
@@ -826,8 +819,7 @@ static int ks8851_net_open(struct net_device *dev)
826 819
827 netif_start_queue(ks->netdev); 820 netif_start_queue(ks->netdev);
828 821
829 if (netif_msg_ifup(ks)) 822 netif_dbg(ks, ifup, ks->netdev, "network device up\n");
830 ks_dbg(ks, "network device %s up\n", dev->name);
831 823
832 mutex_unlock(&ks->lock); 824 mutex_unlock(&ks->lock);
833 return 0; 825 return 0;
@@ -845,8 +837,7 @@ static int ks8851_net_stop(struct net_device *dev)
845{ 837{
846 struct ks8851_net *ks = netdev_priv(dev); 838 struct ks8851_net *ks = netdev_priv(dev);
847 839
848 if (netif_msg_ifdown(ks)) 840 netif_info(ks, ifdown, dev, "shutting down\n");
849 ks_info(ks, "%s: shutting down\n", dev->name);
850 841
851 netif_stop_queue(dev); 842 netif_stop_queue(dev);
852 843
@@ -874,8 +865,8 @@ static int ks8851_net_stop(struct net_device *dev)
874 while (!skb_queue_empty(&ks->txq)) { 865 while (!skb_queue_empty(&ks->txq)) {
875 struct sk_buff *txb = skb_dequeue(&ks->txq); 866 struct sk_buff *txb = skb_dequeue(&ks->txq);
876 867
877 if (netif_msg_ifdown(ks)) 868 netif_dbg(ks, ifdown, ks->netdev,
878 ks_dbg(ks, "%s: freeing txb %p\n", __func__, txb); 869 "%s: freeing txb %p\n", __func__, txb);
879 870
880 dev_kfree_skb(txb); 871 dev_kfree_skb(txb);
881 } 872 }
@@ -904,9 +895,8 @@ static netdev_tx_t ks8851_start_xmit(struct sk_buff *skb,
904 unsigned needed = calc_txlen(skb->len); 895 unsigned needed = calc_txlen(skb->len);
905 netdev_tx_t ret = NETDEV_TX_OK; 896 netdev_tx_t ret = NETDEV_TX_OK;
906 897
907 if (netif_msg_tx_queued(ks)) 898 netif_dbg(ks, tx_queued, ks->netdev,
908 ks_dbg(ks, "%s: skb %p, %d@%p\n", __func__, 899 "%s: skb %p, %d@%p\n", __func__, skb, skb->len, skb->data);
909 skb, skb->len, skb->data);
910 900
911 spin_lock(&ks->statelock); 901 spin_lock(&ks->statelock);
912 902
@@ -966,13 +956,13 @@ static void ks8851_set_rx_mode(struct net_device *dev)
966 rxctrl.rxcr1 = (RXCR1_RXME | RXCR1_RXAE | 956 rxctrl.rxcr1 = (RXCR1_RXME | RXCR1_RXAE |
967 RXCR1_RXPAFMA | RXCR1_RXMAFMA); 957 RXCR1_RXPAFMA | RXCR1_RXMAFMA);
968 } else if (dev->flags & IFF_MULTICAST && !netdev_mc_empty(dev)) { 958 } else if (dev->flags & IFF_MULTICAST && !netdev_mc_empty(dev)) {
969 struct dev_mc_list *mcptr; 959 struct netdev_hw_addr *ha;
970 u32 crc; 960 u32 crc;
971 961
972 /* accept some multicast */ 962 /* accept some multicast */
973 963
974 netdev_for_each_mc_addr(mcptr, dev) { 964 netdev_for_each_mc_addr(ha, dev) {
975 crc = ether_crc(ETH_ALEN, mcptr->dmi_addr); 965 crc = ether_crc(ETH_ALEN, ha->addr);
976 crc >>= (32 - 6); /* get top six bits */ 966 crc >>= (32 - 6); /* get top six bits */
977 967
978 rxctrl.mchash[crc >> 4] |= (1 << (crc & 0xf)); 968 rxctrl.mchash[crc >> 4] |= (1 << (crc & 0xf));
@@ -1185,17 +1175,17 @@ static int ks8851_read_selftest(struct ks8851_net *ks)
1185 rd = ks8851_rdreg16(ks, KS_MBIR); 1175 rd = ks8851_rdreg16(ks, KS_MBIR);
1186 1176
1187 if ((rd & both_done) != both_done) { 1177 if ((rd & both_done) != both_done) {
1188 ks_warn(ks, "Memory selftest not finished\n"); 1178 netdev_warn(ks->netdev, "Memory selftest not finished\n");
1189 return 0; 1179 return 0;
1190 } 1180 }
1191 1181
1192 if (rd & MBIR_TXMBFA) { 1182 if (rd & MBIR_TXMBFA) {
1193 ks_err(ks, "TX memory selftest fail\n"); 1183 netdev_err(ks->netdev, "TX memory selftest fail\n");
1194 ret |= 1; 1184 ret |= 1;
1195 } 1185 }
1196 1186
1197 if (rd & MBIR_RXMBFA) { 1187 if (rd & MBIR_RXMBFA) {
1198 ks_err(ks, "RX memory selftest fail\n"); 1188 netdev_err(ks->netdev, "RX memory selftest fail\n");
1199 ret |= 2; 1189 ret |= 2;
1200 } 1190 }
1201 1191
@@ -1293,9 +1283,9 @@ static int __devinit ks8851_probe(struct spi_device *spi)
1293 goto err_netdev; 1283 goto err_netdev;
1294 } 1284 }
1295 1285
1296 dev_info(&spi->dev, "revision %d, MAC %pM, IRQ %d\n", 1286 netdev_info(ndev, "revision %d, MAC %pM, IRQ %d\n",
1297 CIDER_REV_GET(ks8851_rdreg16(ks, KS_CIDER)), 1287 CIDER_REV_GET(ks8851_rdreg16(ks, KS_CIDER)),
1298 ndev->dev_addr, ndev->irq); 1288 ndev->dev_addr, ndev->irq);
1299 1289
1300 return 0; 1290 return 0;
1301 1291
@@ -1314,7 +1304,7 @@ static int __devexit ks8851_remove(struct spi_device *spi)
1314 struct ks8851_net *priv = dev_get_drvdata(&spi->dev); 1304 struct ks8851_net *priv = dev_get_drvdata(&spi->dev);
1315 1305
1316 if (netif_msg_drv(priv)) 1306 if (netif_msg_drv(priv))
1317 dev_info(&spi->dev, "remove"); 1307 dev_info(&spi->dev, "remove\n");
1318 1308
1319 unregister_netdev(priv->netdev); 1309 unregister_netdev(priv->netdev);
1320 free_irq(spi->irq, priv); 1310 free_irq(spi->irq, priv);
diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c
index 84b0e15831f9..70a3d98f4bd7 100644
--- a/drivers/net/ks8851_mll.c
+++ b/drivers/net/ks8851_mll.c
@@ -21,6 +21,8 @@
21 * KS8851 16bit MLL chip from Micrel Inc. 21 * KS8851 16bit MLL chip from Micrel Inc.
22 */ 22 */
23 23
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25
24#include <linux/module.h> 26#include <linux/module.h>
25#include <linux/kernel.h> 27#include <linux/kernel.h>
26#include <linux/netdevice.h> 28#include <linux/netdevice.h>
@@ -360,7 +362,6 @@ static u8 KS_DEFAULT_MAC_ADDRESS[] = { 0x00, 0x10, 0xA1, 0x86, 0x95, 0x11 };
360 362
361#define MAX_MCAST_LST 32 363#define MAX_MCAST_LST 32
362#define HW_MCAST_SIZE 8 364#define HW_MCAST_SIZE 8
363#define MAC_ADDR_LEN 6
364 365
365/** 366/**
366 * union ks_tx_hdr - tx header data 367 * union ks_tx_hdr - tx header data
@@ -448,7 +449,7 @@ struct ks_net {
448 u16 promiscuous; 449 u16 promiscuous;
449 u16 all_mcast; 450 u16 all_mcast;
450 u16 mcast_lst_size; 451 u16 mcast_lst_size;
451 u8 mcast_lst[MAX_MCAST_LST][MAC_ADDR_LEN]; 452 u8 mcast_lst[MAX_MCAST_LST][ETH_ALEN];
452 u8 mcast_bits[HW_MCAST_SIZE]; 453 u8 mcast_bits[HW_MCAST_SIZE];
453 u8 mac_addr[6]; 454 u8 mac_addr[6];
454 u8 fid; 455 u8 fid;
@@ -458,11 +459,6 @@ struct ks_net {
458 459
459static int msg_enable; 460static int msg_enable;
460 461
461#define ks_info(_ks, _msg...) dev_info(&(_ks)->pdev->dev, _msg)
462#define ks_warn(_ks, _msg...) dev_warn(&(_ks)->pdev->dev, _msg)
463#define ks_dbg(_ks, _msg...) dev_dbg(&(_ks)->pdev->dev, _msg)
464#define ks_err(_ks, _msg...) dev_err(&(_ks)->pdev->dev, _msg)
465
466#define BE3 0x8000 /* Byte Enable 3 */ 462#define BE3 0x8000 /* Byte Enable 3 */
467#define BE2 0x4000 /* Byte Enable 2 */ 463#define BE2 0x4000 /* Byte Enable 2 */
468#define BE1 0x2000 /* Byte Enable 1 */ 464#define BE1 0x2000 /* Byte Enable 1 */
@@ -624,8 +620,7 @@ static void ks_set_powermode(struct ks_net *ks, unsigned pwrmode)
624{ 620{
625 unsigned pmecr; 621 unsigned pmecr;
626 622
627 if (netif_msg_hw(ks)) 623 netif_dbg(ks, hw, ks->netdev, "setting power mode %d\n", pwrmode);
628 ks_dbg(ks, "setting power mode %d\n", pwrmode);
629 624
630 ks_rdreg16(ks, KS_GRR); 625 ks_rdreg16(ks, KS_GRR);
631 pmecr = ks_rdreg16(ks, KS_PMECR); 626 pmecr = ks_rdreg16(ks, KS_PMECR);
@@ -805,11 +800,10 @@ static void ks_rcv(struct ks_net *ks, struct net_device *netdev)
805 /* read data block including CRC 4 bytes */ 800 /* read data block including CRC 4 bytes */
806 ks_read_qmu(ks, (u16 *)skb->data, frame_hdr->len); 801 ks_read_qmu(ks, (u16 *)skb->data, frame_hdr->len);
807 skb_put(skb, frame_hdr->len); 802 skb_put(skb, frame_hdr->len);
808 skb->dev = netdev;
809 skb->protocol = eth_type_trans(skb, netdev); 803 skb->protocol = eth_type_trans(skb, netdev);
810 netif_rx(skb); 804 netif_rx(skb);
811 } else { 805 } else {
812 printk(KERN_ERR "%s: err:skb alloc\n", __func__); 806 pr_err("%s: err:skb alloc\n", __func__);
813 ks_wrreg16(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF)); 807 ks_wrreg16(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF));
814 if (skb) 808 if (skb)
815 dev_kfree_skb_irq(skb); 809 dev_kfree_skb_irq(skb);
@@ -836,9 +830,8 @@ static void ks_update_link_status(struct net_device *netdev, struct ks_net *ks)
836 netif_carrier_off(netdev); 830 netif_carrier_off(netdev);
837 link_up_status = false; 831 link_up_status = false;
838 } 832 }
839 if (netif_msg_link(ks)) 833 netif_dbg(ks, link, ks->netdev,
840 ks_dbg(ks, "%s: %s\n", 834 "%s: %s\n", __func__, link_up_status ? "UP" : "DOWN");
841 __func__, link_up_status ? "UP" : "DOWN");
842} 835}
843 836
844/** 837/**
@@ -908,15 +901,13 @@ static int ks_net_open(struct net_device *netdev)
908 * else at the moment. 901 * else at the moment.
909 */ 902 */
910 903
911 if (netif_msg_ifup(ks)) 904 netif_dbg(ks, ifup, ks->netdev, "%s - entry\n", __func__);
912 ks_dbg(ks, "%s - entry\n", __func__);
913 905
914 /* reset the HW */ 906 /* reset the HW */
915 err = request_irq(ks->irq, ks_irq, KS_INT_FLAGS, DRV_NAME, netdev); 907 err = request_irq(ks->irq, ks_irq, KS_INT_FLAGS, DRV_NAME, netdev);
916 908
917 if (err) { 909 if (err) {
918 printk(KERN_ERR "Failed to request IRQ: %d: %d\n", 910 pr_err("Failed to request IRQ: %d: %d\n", ks->irq, err);
919 ks->irq, err);
920 return err; 911 return err;
921 } 912 }
922 913
@@ -929,8 +920,7 @@ static int ks_net_open(struct net_device *netdev)
929 ks_enable_qmu(ks); 920 ks_enable_qmu(ks);
930 netif_start_queue(ks->netdev); 921 netif_start_queue(ks->netdev);
931 922
932 if (netif_msg_ifup(ks)) 923 netif_dbg(ks, ifup, ks->netdev, "network device up\n");
933 ks_dbg(ks, "network device %s up\n", netdev->name);
934 924
935 return 0; 925 return 0;
936} 926}
@@ -947,8 +937,7 @@ static int ks_net_stop(struct net_device *netdev)
947{ 937{
948 struct ks_net *ks = netdev_priv(netdev); 938 struct ks_net *ks = netdev_priv(netdev);
949 939
950 if (netif_msg_ifdown(ks)) 940 netif_info(ks, ifdown, netdev, "shutting down\n");
951 ks_info(ks, "%s: shutting down\n", netdev->name);
952 941
953 netif_stop_queue(netdev); 942 netif_stop_queue(netdev);
954 943
@@ -1180,7 +1169,7 @@ static void ks_set_mcast(struct ks_net *ks, u16 mcast)
1180static void ks_set_rx_mode(struct net_device *netdev) 1169static void ks_set_rx_mode(struct net_device *netdev)
1181{ 1170{
1182 struct ks_net *ks = netdev_priv(netdev); 1171 struct ks_net *ks = netdev_priv(netdev);
1183 struct dev_mc_list *ptr; 1172 struct netdev_hw_addr *ha;
1184 1173
1185 /* Turn on/off promiscuous mode. */ 1174 /* Turn on/off promiscuous mode. */
1186 if ((netdev->flags & IFF_PROMISC) == IFF_PROMISC) 1175 if ((netdev->flags & IFF_PROMISC) == IFF_PROMISC)
@@ -1197,13 +1186,12 @@ static void ks_set_rx_mode(struct net_device *netdev)
1197 if (netdev_mc_count(netdev) <= MAX_MCAST_LST) { 1186 if (netdev_mc_count(netdev) <= MAX_MCAST_LST) {
1198 int i = 0; 1187 int i = 0;
1199 1188
1200 netdev_for_each_mc_addr(ptr, netdev) { 1189 netdev_for_each_mc_addr(ha, netdev) {
1201 if (!(*ptr->dmi_addr & 1)) 1190 if (!(*ha->addr & 1))
1202 continue; 1191 continue;
1203 if (i >= MAX_MCAST_LST) 1192 if (i >= MAX_MCAST_LST)
1204 break; 1193 break;
1205 memcpy(ks->mcast_lst[i++], ptr->dmi_addr, 1194 memcpy(ks->mcast_lst[i++], ha->addr, ETH_ALEN);
1206 MAC_ADDR_LEN);
1207 } 1195 }
1208 ks->mcast_lst_size = (u8)i; 1196 ks->mcast_lst_size = (u8)i;
1209 ks_set_grpaddr(ks); 1197 ks_set_grpaddr(ks);
@@ -1429,21 +1417,21 @@ static int ks_read_selftest(struct ks_net *ks)
1429 rd = ks_rdreg16(ks, KS_MBIR); 1417 rd = ks_rdreg16(ks, KS_MBIR);
1430 1418
1431 if ((rd & both_done) != both_done) { 1419 if ((rd & both_done) != both_done) {
1432 ks_warn(ks, "Memory selftest not finished\n"); 1420 netdev_warn(ks->netdev, "Memory selftest not finished\n");
1433 return 0; 1421 return 0;
1434 } 1422 }
1435 1423
1436 if (rd & MBIR_TXMBFA) { 1424 if (rd & MBIR_TXMBFA) {
1437 ks_err(ks, "TX memory selftest fails\n"); 1425 netdev_err(ks->netdev, "TX memory selftest fails\n");
1438 ret |= 1; 1426 ret |= 1;
1439 } 1427 }
1440 1428
1441 if (rd & MBIR_RXMBFA) { 1429 if (rd & MBIR_RXMBFA) {
1442 ks_err(ks, "RX memory selftest fails\n"); 1430 netdev_err(ks->netdev, "RX memory selftest fails\n");
1443 ret |= 2; 1431 ret |= 2;
1444 } 1432 }
1445 1433
1446 ks_info(ks, "the selftest passes\n"); 1434 netdev_info(ks->netdev, "the selftest passes\n");
1447 return ret; 1435 return ret;
1448} 1436}
1449 1437
@@ -1514,7 +1502,7 @@ static int ks_hw_init(struct ks_net *ks)
1514 ks->frame_head_info = (struct type_frame_head *) \ 1502 ks->frame_head_info = (struct type_frame_head *) \
1515 kmalloc(MHEADER_SIZE, GFP_KERNEL); 1503 kmalloc(MHEADER_SIZE, GFP_KERNEL);
1516 if (!ks->frame_head_info) { 1504 if (!ks->frame_head_info) {
1517 printk(KERN_ERR "Error: Fail to allocate frame memory\n"); 1505 pr_err("Error: Fail to allocate frame memory\n");
1518 return false; 1506 return false;
1519 } 1507 }
1520 1508
@@ -1580,7 +1568,7 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
1580 ks->mii.mdio_read = ks_phy_read; 1568 ks->mii.mdio_read = ks_phy_read;
1581 ks->mii.mdio_write = ks_phy_write; 1569 ks->mii.mdio_write = ks_phy_write;
1582 1570
1583 ks_info(ks, "message enable is %d\n", msg_enable); 1571 netdev_info(netdev, "message enable is %d\n", msg_enable);
1584 /* set the default message enable */ 1572 /* set the default message enable */
1585 ks->msg_enable = netif_msg_init(msg_enable, (NETIF_MSG_DRV | 1573 ks->msg_enable = netif_msg_init(msg_enable, (NETIF_MSG_DRV |
1586 NETIF_MSG_PROBE | 1574 NETIF_MSG_PROBE |
@@ -1589,13 +1577,13 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
1589 1577
1590 /* simple check for a valid chip being connected to the bus */ 1578 /* simple check for a valid chip being connected to the bus */
1591 if ((ks_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) { 1579 if ((ks_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) {
1592 ks_err(ks, "failed to read device ID\n"); 1580 netdev_err(netdev, "failed to read device ID\n");
1593 err = -ENODEV; 1581 err = -ENODEV;
1594 goto err_register; 1582 goto err_register;
1595 } 1583 }
1596 1584
1597 if (ks_read_selftest(ks)) { 1585 if (ks_read_selftest(ks)) {
1598 ks_err(ks, "failed to read device ID\n"); 1586 netdev_err(netdev, "failed to read device ID\n");
1599 err = -ENODEV; 1587 err = -ENODEV;
1600 goto err_register; 1588 goto err_register;
1601 } 1589 }
@@ -1626,9 +1614,8 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
1626 1614
1627 id = ks_rdreg16(ks, KS_CIDER); 1615 id = ks_rdreg16(ks, KS_CIDER);
1628 1616
1629 printk(KERN_INFO DRV_NAME 1617 netdev_info(netdev, "Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n",
1630 " Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n", 1618 (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7);
1631 (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7);
1632 return 0; 1619 return 0;
1633 1620
1634err_register: 1621err_register:
diff --git a/drivers/net/ksz884x.c b/drivers/net/ksz884x.c
index 6c5327af1bf9..097796423b52 100644
--- a/drivers/net/ksz884x.c
+++ b/drivers/net/ksz884x.c
@@ -14,10 +14,11 @@
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 */ 15 */
16 16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
17#include <linux/init.h> 19#include <linux/init.h>
18#include <linux/kernel.h> 20#include <linux/kernel.h>
19#include <linux/module.h> 21#include <linux/module.h>
20#include <linux/version.h>
21#include <linux/ioport.h> 22#include <linux/ioport.h>
22#include <linux/pci.h> 23#include <linux/pci.h>
23#include <linux/proc_fs.h> 24#include <linux/proc_fs.h>
@@ -1483,11 +1484,6 @@ struct dev_priv {
1483 int promiscuous; 1484 int promiscuous;
1484}; 1485};
1485 1486
1486#define ks_info(_ks, _msg...) dev_info(&(_ks)->pdev->dev, _msg)
1487#define ks_warn(_ks, _msg...) dev_warn(&(_ks)->pdev->dev, _msg)
1488#define ks_dbg(_ks, _msg...) dev_dbg(&(_ks)->pdev->dev, _msg)
1489#define ks_err(_ks, _msg...) dev_err(&(_ks)->pdev->dev, _msg)
1490
1491#define DRV_NAME "KSZ884X PCI" 1487#define DRV_NAME "KSZ884X PCI"
1492#define DEVICE_NAME "KSZ884x PCI" 1488#define DEVICE_NAME "KSZ884x PCI"
1493#define DRV_VERSION "1.0.0" 1489#define DRV_VERSION "1.0.0"
@@ -3834,7 +3830,7 @@ static void ksz_check_desc_num(struct ksz_desc_info *info)
3834 alloc >>= 1; 3830 alloc >>= 1;
3835 } 3831 }
3836 if (alloc != 1 || shift < MIN_DESC_SHIFT) { 3832 if (alloc != 1 || shift < MIN_DESC_SHIFT) {
3837 printk(KERN_ALERT "Hardware descriptor numbers not right!\n"); 3833 pr_alert("Hardware descriptor numbers not right!\n");
3838 while (alloc) { 3834 while (alloc) {
3839 shift++; 3835 shift++;
3840 alloc >>= 1; 3836 alloc >>= 1;
@@ -4545,8 +4541,7 @@ static int ksz_alloc_mem(struct dev_info *adapter)
4545 (((sizeof(struct ksz_hw_desc) + DESC_ALIGNMENT - 1) / 4541 (((sizeof(struct ksz_hw_desc) + DESC_ALIGNMENT - 1) /
4546 DESC_ALIGNMENT) * DESC_ALIGNMENT); 4542 DESC_ALIGNMENT) * DESC_ALIGNMENT);
4547 if (hw->rx_desc_info.size != sizeof(struct ksz_hw_desc)) 4543 if (hw->rx_desc_info.size != sizeof(struct ksz_hw_desc))
4548 printk(KERN_ALERT 4544 pr_alert("Hardware descriptor size not right!\n");
4549 "Hardware descriptor size not right!\n");
4550 ksz_check_desc_num(&hw->rx_desc_info); 4545 ksz_check_desc_num(&hw->rx_desc_info);
4551 ksz_check_desc_num(&hw->tx_desc_info); 4546 ksz_check_desc_num(&hw->tx_desc_info);
4552 4547
@@ -5048,8 +5043,6 @@ static inline int rx_proc(struct net_device *dev, struct ksz_hw* hw,
5048 dma_buf->skb->data, packet_len); 5043 dma_buf->skb->data, packet_len);
5049 } while (0); 5044 } while (0);
5050 5045
5051 skb->dev = dev;
5052
5053 skb->protocol = eth_type_trans(skb, dev); 5046 skb->protocol = eth_type_trans(skb, dev);
5054 5047
5055 if (hw->rx_cfg & (DMA_RX_CSUM_UDP | DMA_RX_CSUM_TCP)) 5048 if (hw->rx_cfg & (DMA_RX_CSUM_UDP | DMA_RX_CSUM_TCP))
@@ -5319,10 +5312,10 @@ static irqreturn_t netdev_intr(int irq, void *dev_id)
5319 u32 data; 5312 u32 data;
5320 5313
5321 hw->intr_mask &= ~KS884X_INT_TX_STOPPED; 5314 hw->intr_mask &= ~KS884X_INT_TX_STOPPED;
5322 printk(KERN_INFO "Tx stopped\n"); 5315 pr_info("Tx stopped\n");
5323 data = readl(hw->io + KS_DMA_TX_CTRL); 5316 data = readl(hw->io + KS_DMA_TX_CTRL);
5324 if (!(data & DMA_TX_ENABLE)) 5317 if (!(data & DMA_TX_ENABLE))
5325 printk(KERN_INFO "Tx disabled\n"); 5318 pr_info("Tx disabled\n");
5326 break; 5319 break;
5327 } 5320 }
5328 } while (0); 5321 } while (0);
@@ -5495,6 +5488,18 @@ static int prepare_hardware(struct net_device *dev)
5495 return 0; 5488 return 0;
5496} 5489}
5497 5490
5491static void set_media_state(struct net_device *dev, int media_state)
5492{
5493 struct dev_priv *priv = netdev_priv(dev);
5494
5495 if (media_state == priv->media_state)
5496 netif_carrier_on(dev);
5497 else
5498 netif_carrier_off(dev);
5499 netif_info(priv, link, dev, "link %s\n",
5500 media_state == priv->media_state ? "on" : "off");
5501}
5502
5498/** 5503/**
5499 * netdev_open - open network device 5504 * netdev_open - open network device
5500 * @dev: Network device. 5505 * @dev: Network device.
@@ -5584,15 +5589,7 @@ static int netdev_open(struct net_device *dev)
5584 5589
5585 priv->media_state = port->linked->state; 5590 priv->media_state = port->linked->state;
5586 5591
5587 if (media_connected == priv->media_state) 5592 set_media_state(dev, media_connected);
5588 netif_carrier_on(dev);
5589 else
5590 netif_carrier_off(dev);
5591 if (netif_msg_link(priv))
5592 printk(KERN_INFO "%s link %s\n", dev->name,
5593 (media_connected == priv->media_state ?
5594 "on" : "off"));
5595
5596 netif_start_queue(dev); 5593 netif_start_queue(dev);
5597 5594
5598 return 0; 5595 return 0;
@@ -5766,7 +5763,7 @@ static void netdev_set_rx_mode(struct net_device *dev)
5766 struct dev_priv *priv = netdev_priv(dev); 5763 struct dev_priv *priv = netdev_priv(dev);
5767 struct dev_info *hw_priv = priv->adapter; 5764 struct dev_info *hw_priv = priv->adapter;
5768 struct ksz_hw *hw = &hw_priv->hw; 5765 struct ksz_hw *hw = &hw_priv->hw;
5769 struct dev_mc_list *mc_ptr; 5766 struct netdev_hw_addr *ha;
5770 int multicast = (dev->flags & IFF_ALLMULTI); 5767 int multicast = (dev->flags & IFF_ALLMULTI);
5771 5768
5772 dev_set_promiscuous(dev, priv, hw, (dev->flags & IFF_PROMISC)); 5769 dev_set_promiscuous(dev, priv, hw, (dev->flags & IFF_PROMISC));
@@ -5783,7 +5780,7 @@ static void netdev_set_rx_mode(struct net_device *dev)
5783 int i = 0; 5780 int i = 0;
5784 5781
5785 /* List too big to support so turn on all multicast mode. */ 5782 /* List too big to support so turn on all multicast mode. */
5786 if (dev->mc_count > MAX_MULTICAST_LIST) { 5783 if (netdev_mc_count(dev) > MAX_MULTICAST_LIST) {
5787 if (MAX_MULTICAST_LIST != hw->multi_list_size) { 5784 if (MAX_MULTICAST_LIST != hw->multi_list_size) {
5788 hw->multi_list_size = MAX_MULTICAST_LIST; 5785 hw->multi_list_size = MAX_MULTICAST_LIST;
5789 ++hw->all_multi; 5786 ++hw->all_multi;
@@ -5792,13 +5789,12 @@ static void netdev_set_rx_mode(struct net_device *dev)
5792 return; 5789 return;
5793 } 5790 }
5794 5791
5795 netdev_for_each_mc_addr(mc_ptr, dev) { 5792 netdev_for_each_mc_addr(ha, dev) {
5796 if (!(*mc_ptr->dmi_addr & 1)) 5793 if (!(*ha->addr & 1))
5797 continue; 5794 continue;
5798 if (i >= MAX_MULTICAST_LIST) 5795 if (i >= MAX_MULTICAST_LIST)
5799 break; 5796 break;
5800 memcpy(hw->multi_list[i++], mc_ptr->dmi_addr, 5797 memcpy(hw->multi_list[i++], ha->addr, MAC_ADDR_LEN);
5801 MAC_ADDR_LEN);
5802 } 5798 }
5803 hw->multi_list_size = (u8) i; 5799 hw->multi_list_size = (u8) i;
5804 hw_set_grp_addr(hw); 5800 hw_set_grp_addr(hw);
@@ -6682,16 +6678,8 @@ static void update_link(struct net_device *dev, struct dev_priv *priv,
6682{ 6678{
6683 if (priv->media_state != port->linked->state) { 6679 if (priv->media_state != port->linked->state) {
6684 priv->media_state = port->linked->state; 6680 priv->media_state = port->linked->state;
6685 if (netif_running(dev)) { 6681 if (netif_running(dev))
6686 if (media_connected == priv->media_state) 6682 set_media_state(dev, media_connected);
6687 netif_carrier_on(dev);
6688 else
6689 netif_carrier_off(dev);
6690 if (netif_msg_link(priv))
6691 printk(KERN_INFO "%s link %s\n", dev->name,
6692 (media_connected == priv->media_state ?
6693 "on" : "off"));
6694 }
6695 } 6683 }
6696} 6684}
6697 6685
@@ -6985,7 +6973,7 @@ static int __init pcidev_init(struct pci_dev *pdev,
6985 int pi; 6973 int pi;
6986 int port_count; 6974 int port_count;
6987 int result; 6975 int result;
6988 char banner[80]; 6976 char banner[sizeof(version)];
6989 struct ksz_switch *sw = NULL; 6977 struct ksz_switch *sw = NULL;
6990 6978
6991 result = pci_enable_device(pdev); 6979 result = pci_enable_device(pdev);
@@ -7009,10 +6997,9 @@ static int __init pcidev_init(struct pci_dev *pdev,
7009 6997
7010 result = -ENOMEM; 6998 result = -ENOMEM;
7011 6999
7012 info = kmalloc(sizeof(struct platform_info), GFP_KERNEL); 7000 info = kzalloc(sizeof(struct platform_info), GFP_KERNEL);
7013 if (!info) 7001 if (!info)
7014 goto pcidev_init_dev_err; 7002 goto pcidev_init_dev_err;
7015 memset(info, 0, sizeof(struct platform_info));
7016 7003
7017 hw_priv = &info->dev_info; 7004 hw_priv = &info->dev_info;
7018 hw_priv->pdev = pdev; 7005 hw_priv->pdev = pdev;
@@ -7026,15 +7013,15 @@ static int __init pcidev_init(struct pci_dev *pdev,
7026 cnt = hw_init(hw); 7013 cnt = hw_init(hw);
7027 if (!cnt) { 7014 if (!cnt) {
7028 if (msg_enable & NETIF_MSG_PROBE) 7015 if (msg_enable & NETIF_MSG_PROBE)
7029 printk(KERN_ALERT "chip not detected\n"); 7016 pr_alert("chip not detected\n");
7030 result = -ENODEV; 7017 result = -ENODEV;
7031 goto pcidev_init_alloc_err; 7018 goto pcidev_init_alloc_err;
7032 } 7019 }
7033 7020
7034 sprintf(banner, "%s\n", version); 7021 snprintf(banner, sizeof(banner), "%s", version);
7035 banner[13] = cnt + '0'; 7022 banner[13] = cnt + '0'; /* Replace x in "Micrel KSZ884x" */
7036 ks_info(hw_priv, "%s", banner); 7023 dev_info(&hw_priv->pdev->dev, "%s\n", banner);
7037 ks_dbg(hw_priv, "Mem = %p; IRQ = %d\n", hw->io, pdev->irq); 7024 dev_dbg(&hw_priv->pdev->dev, "Mem = %p; IRQ = %d\n", hw->io, pdev->irq);
7038 7025
7039 /* Assume device is KSZ8841. */ 7026 /* Assume device is KSZ8841. */
7040 hw->dev_count = 1; 7027 hw->dev_count = 1;
diff --git a/drivers/net/lib82596.c b/drivers/net/lib82596.c
index 443c39a3732f..fddaf921885e 100644
--- a/drivers/net/lib82596.c
+++ b/drivers/net/lib82596.c
@@ -1388,7 +1388,7 @@ static void set_multicast_list(struct net_device *dev)
1388 } 1388 }
1389 1389
1390 if (!netdev_mc_empty(dev)) { 1390 if (!netdev_mc_empty(dev)) {
1391 struct dev_mc_list *dmi; 1391 struct netdev_hw_addr *ha;
1392 unsigned char *cp; 1392 unsigned char *cp;
1393 struct mc_cmd *cmd; 1393 struct mc_cmd *cmd;
1394 1394
@@ -1396,10 +1396,10 @@ static void set_multicast_list(struct net_device *dev)
1396 cmd->cmd.command = SWAP16(CmdMulticastList); 1396 cmd->cmd.command = SWAP16(CmdMulticastList);
1397 cmd->mc_cnt = SWAP16(netdev_mc_count(dev) * 6); 1397 cmd->mc_cnt = SWAP16(netdev_mc_count(dev) * 6);
1398 cp = cmd->mc_addrs; 1398 cp = cmd->mc_addrs;
1399 netdev_for_each_mc_addr(dmi, dev) { 1399 netdev_for_each_mc_addr(ha, dev) {
1400 if (!cnt--) 1400 if (!cnt--)
1401 break; 1401 break;
1402 memcpy(cp, dmi->dmi_addr, 6); 1402 memcpy(cp, ha->addr, 6);
1403 if (i596_debug > 1) 1403 if (i596_debug > 1)
1404 DEB(DEB_MULTI, 1404 DEB(DEB_MULTI,
1405 printk(KERN_DEBUG 1405 printk(KERN_DEBUG
diff --git a/drivers/net/lib8390.c b/drivers/net/lib8390.c
index 56f66f485400..526dc9cbc3c6 100644
--- a/drivers/net/lib8390.c
+++ b/drivers/net/lib8390.c
@@ -905,10 +905,10 @@ static struct net_device_stats *__ei_get_stats(struct net_device *dev)
905 905
906static inline void make_mc_bits(u8 *bits, struct net_device *dev) 906static inline void make_mc_bits(u8 *bits, struct net_device *dev)
907{ 907{
908 struct dev_mc_list *dmi; 908 struct netdev_hw_addr *ha;
909 909
910 netdev_for_each_mc_addr(dmi, dev) { 910 netdev_for_each_mc_addr(ha, dev) {
911 u32 crc = ether_crc(ETH_ALEN, dmi->dmi_addr); 911 u32 crc = ether_crc(ETH_ALEN, ha->addr);
912 /* 912 /*
913 * The 8390 uses the 6 most significant bits of the 913 * The 8390 uses the 6 most significant bits of the
914 * CRC to index the multicast table. 914 * CRC to index the multicast table.
diff --git a/drivers/net/ll_temac.h b/drivers/net/ll_temac.h
index 1af66a1e6911..c03358434acb 100644
--- a/drivers/net/ll_temac.h
+++ b/drivers/net/ll_temac.h
@@ -5,8 +5,11 @@
5#include <linux/netdevice.h> 5#include <linux/netdevice.h>
6#include <linux/of.h> 6#include <linux/of.h>
7#include <linux/spinlock.h> 7#include <linux/spinlock.h>
8
9#ifdef CONFIG_PPC_DCR
8#include <asm/dcr.h> 10#include <asm/dcr.h>
9#include <asm/dcr-regs.h> 11#include <asm/dcr-regs.h>
12#endif
10 13
11/* packet size info */ 14/* packet size info */
12#define XTE_HDR_SIZE 14 /* size of Ethernet header */ 15#define XTE_HDR_SIZE 14 /* size of Ethernet header */
@@ -290,9 +293,6 @@ This option defaults to enabled (set) */
290 293
291#define TX_CONTROL_CALC_CSUM_MASK 1 294#define TX_CONTROL_CALC_CSUM_MASK 1
292 295
293#define XTE_ALIGN 32
294#define BUFFER_ALIGN(adr) ((XTE_ALIGN - ((u32) adr)) % XTE_ALIGN)
295
296#define MULTICAST_CAM_TABLE_NUM 4 296#define MULTICAST_CAM_TABLE_NUM 4
297 297
298/* TX/RX CURDESC_PTR points to first descriptor */ 298/* TX/RX CURDESC_PTR points to first descriptor */
@@ -335,9 +335,15 @@ struct temac_local {
335 struct mii_bus *mii_bus; /* MII bus reference */ 335 struct mii_bus *mii_bus; /* MII bus reference */
336 int mdio_irqs[PHY_MAX_ADDR]; /* IRQs table for MDIO bus */ 336 int mdio_irqs[PHY_MAX_ADDR]; /* IRQs table for MDIO bus */
337 337
338 /* IO registers and IRQs */ 338 /* IO registers, dma functions and IRQs */
339 void __iomem *regs; 339 void __iomem *regs;
340 void __iomem *sdma_regs;
341#ifdef CONFIG_PPC_DCR
340 dcr_host_t sdma_dcrs; 342 dcr_host_t sdma_dcrs;
343#endif
344 u32 (*dma_in)(struct temac_local *, int);
345 void (*dma_out)(struct temac_local *, int, u32);
346
341 int tx_irq; 347 int tx_irq;
342 int rx_irq; 348 int rx_irq;
343 int emac_num; 349 int emac_num;
diff --git a/drivers/net/ll_temac_main.c b/drivers/net/ll_temac_main.c
index a18e3485476e..b6edb2fd0a8a 100644
--- a/drivers/net/ll_temac_main.c
+++ b/drivers/net/ll_temac_main.c
@@ -20,9 +20,6 @@
20 * or rx, so this should be okay. 20 * or rx, so this should be okay.
21 * 21 *
22 * TODO: 22 * TODO:
23 * - Fix driver to work on more than just Virtex5. Right now the driver
24 * assumes that the locallink DMA registers are accessed via DCR
25 * instructions.
26 * - Factor out locallink DMA code into separate driver 23 * - Factor out locallink DMA code into separate driver
27 * - Fix multicast assignment. 24 * - Fix multicast assignment.
28 * - Fix support for hardware checksumming. 25 * - Fix support for hardware checksumming.
@@ -115,17 +112,86 @@ void temac_indirect_out32(struct temac_local *lp, int reg, u32 value)
115 temac_iow(lp, XTE_CTL0_OFFSET, CNTLREG_WRITE_ENABLE_MASK | reg); 112 temac_iow(lp, XTE_CTL0_OFFSET, CNTLREG_WRITE_ENABLE_MASK | reg);
116} 113}
117 114
115/**
116 * temac_dma_in32 - Memory mapped DMA read, this function expects a
117 * register input that is based on DCR word addresses which
118 * are then converted to memory mapped byte addresses
119 */
118static u32 temac_dma_in32(struct temac_local *lp, int reg) 120static u32 temac_dma_in32(struct temac_local *lp, int reg)
119{ 121{
120 return dcr_read(lp->sdma_dcrs, reg); 122 return in_be32((u32 *)(lp->sdma_regs + (reg << 2)));
121} 123}
122 124
125/**
126 * temac_dma_out32 - Memory mapped DMA read, this function expects a
127 * register input that is based on DCR word addresses which
128 * are then converted to memory mapped byte addresses
129 */
123static void temac_dma_out32(struct temac_local *lp, int reg, u32 value) 130static void temac_dma_out32(struct temac_local *lp, int reg, u32 value)
124{ 131{
132 out_be32((u32 *)(lp->sdma_regs + (reg << 2)), value);
133}
134
135/* DMA register access functions can be DCR based or memory mapped.
136 * The PowerPC 440 is DCR based, the PowerPC 405 and MicroBlaze are both
137 * memory mapped.
138 */
139#ifdef CONFIG_PPC_DCR
140
141/**
142 * temac_dma_dcr_in32 - DCR based DMA read
143 */
144static u32 temac_dma_dcr_in(struct temac_local *lp, int reg)
145{
146 return dcr_read(lp->sdma_dcrs, reg);
147}
148
149/**
150 * temac_dma_dcr_out32 - DCR based DMA write
151 */
152static void temac_dma_dcr_out(struct temac_local *lp, int reg, u32 value)
153{
125 dcr_write(lp->sdma_dcrs, reg, value); 154 dcr_write(lp->sdma_dcrs, reg, value);
126} 155}
127 156
128/** 157/**
158 * temac_dcr_setup - If the DMA is DCR based, then setup the address and
159 * I/O functions
160 */
161static int temac_dcr_setup(struct temac_local *lp, struct of_device *op,
162 struct device_node *np)
163{
164 unsigned int dcrs;
165
166 /* setup the dcr address mapping if it's in the device tree */
167
168 dcrs = dcr_resource_start(np, 0);
169 if (dcrs != 0) {
170 lp->sdma_dcrs = dcr_map(np, dcrs, dcr_resource_len(np, 0));
171 lp->dma_in = temac_dma_dcr_in;
172 lp->dma_out = temac_dma_dcr_out;
173 dev_dbg(&op->dev, "DCR base: %x\n", dcrs);
174 return 0;
175 }
176 /* no DCR in the device tree, indicate a failure */
177 return -1;
178}
179
180#else
181
182/*
183 * temac_dcr_setup - This is a stub for when DCR is not supported,
184 * such as with MicroBlaze
185 */
186static int temac_dcr_setup(struct temac_local *lp, struct of_device *op,
187 struct device_node *np)
188{
189 return -1;
190}
191
192#endif
193
194/**
129 * temac_dma_bd_init - Setup buffer descriptor rings 195 * temac_dma_bd_init - Setup buffer descriptor rings
130 */ 196 */
131static int temac_dma_bd_init(struct net_device *ndev) 197static int temac_dma_bd_init(struct net_device *ndev)
@@ -155,14 +221,14 @@ static int temac_dma_bd_init(struct net_device *ndev)
155 lp->rx_bd_v[i].next = lp->rx_bd_p + 221 lp->rx_bd_v[i].next = lp->rx_bd_p +
156 sizeof(*lp->rx_bd_v) * ((i + 1) % RX_BD_NUM); 222 sizeof(*lp->rx_bd_v) * ((i + 1) % RX_BD_NUM);
157 223
158 skb = alloc_skb(XTE_MAX_JUMBO_FRAME_SIZE 224 skb = netdev_alloc_skb_ip_align(ndev,
159 + XTE_ALIGN, GFP_ATOMIC); 225 XTE_MAX_JUMBO_FRAME_SIZE);
226
160 if (skb == 0) { 227 if (skb == 0) {
161 dev_err(&ndev->dev, "alloc_skb error %d\n", i); 228 dev_err(&ndev->dev, "alloc_skb error %d\n", i);
162 return -1; 229 return -1;
163 } 230 }
164 lp->rx_skb[i] = skb; 231 lp->rx_skb[i] = skb;
165 skb_reserve(skb, BUFFER_ALIGN(skb->data));
166 /* returns physical address of skb->data */ 232 /* returns physical address of skb->data */
167 lp->rx_bd_v[i].phys = dma_map_single(ndev->dev.parent, 233 lp->rx_bd_v[i].phys = dma_map_single(ndev->dev.parent,
168 skb->data, 234 skb->data,
@@ -172,23 +238,23 @@ static int temac_dma_bd_init(struct net_device *ndev)
172 lp->rx_bd_v[i].app0 = STS_CTRL_APP0_IRQONEND; 238 lp->rx_bd_v[i].app0 = STS_CTRL_APP0_IRQONEND;
173 } 239 }
174 240
175 temac_dma_out32(lp, TX_CHNL_CTRL, 0x10220400 | 241 lp->dma_out(lp, TX_CHNL_CTRL, 0x10220400 |
176 CHNL_CTRL_IRQ_EN | 242 CHNL_CTRL_IRQ_EN |
177 CHNL_CTRL_IRQ_DLY_EN | 243 CHNL_CTRL_IRQ_DLY_EN |
178 CHNL_CTRL_IRQ_COAL_EN); 244 CHNL_CTRL_IRQ_COAL_EN);
179 /* 0x10220483 */ 245 /* 0x10220483 */
180 /* 0x00100483 */ 246 /* 0x00100483 */
181 temac_dma_out32(lp, RX_CHNL_CTRL, 0xff010000 | 247 lp->dma_out(lp, RX_CHNL_CTRL, 0xff010000 |
182 CHNL_CTRL_IRQ_EN | 248 CHNL_CTRL_IRQ_EN |
183 CHNL_CTRL_IRQ_DLY_EN | 249 CHNL_CTRL_IRQ_DLY_EN |
184 CHNL_CTRL_IRQ_COAL_EN | 250 CHNL_CTRL_IRQ_COAL_EN |
185 CHNL_CTRL_IRQ_IOE); 251 CHNL_CTRL_IRQ_IOE);
186 /* 0xff010283 */ 252 /* 0xff010283 */
187 253
188 temac_dma_out32(lp, RX_CURDESC_PTR, lp->rx_bd_p); 254 lp->dma_out(lp, RX_CURDESC_PTR, lp->rx_bd_p);
189 temac_dma_out32(lp, RX_TAILDESC_PTR, 255 lp->dma_out(lp, RX_TAILDESC_PTR,
190 lp->rx_bd_p + (sizeof(*lp->rx_bd_v) * (RX_BD_NUM - 1))); 256 lp->rx_bd_p + (sizeof(*lp->rx_bd_v) * (RX_BD_NUM - 1)));
191 temac_dma_out32(lp, TX_CURDESC_PTR, lp->tx_bd_p); 257 lp->dma_out(lp, TX_CURDESC_PTR, lp->tx_bd_p);
192 258
193 return 0; 259 return 0;
194} 260}
@@ -250,20 +316,20 @@ static void temac_set_multicast_list(struct net_device *ndev)
250 temac_indirect_out32(lp, XTE_AFM_OFFSET, XTE_AFM_EPPRM_MASK); 316 temac_indirect_out32(lp, XTE_AFM_OFFSET, XTE_AFM_EPPRM_MASK);
251 dev_info(&ndev->dev, "Promiscuous mode enabled.\n"); 317 dev_info(&ndev->dev, "Promiscuous mode enabled.\n");
252 } else if (!netdev_mc_empty(ndev)) { 318 } else if (!netdev_mc_empty(ndev)) {
253 struct dev_mc_list *mclist; 319 struct netdev_hw_addr *ha;
254 320
255 i = 0; 321 i = 0;
256 netdev_for_each_mc_addr(mclist, ndev) { 322 netdev_for_each_mc_addr(ha, ndev) {
257 if (i >= MULTICAST_CAM_TABLE_NUM) 323 if (i >= MULTICAST_CAM_TABLE_NUM)
258 break; 324 break;
259 multi_addr_msw = ((mclist->dmi_addr[3] << 24) | 325 multi_addr_msw = ((ha->addr[3] << 24) |
260 (mclist->dmi_addr[2] << 16) | 326 (ha->addr[2] << 16) |
261 (mclist->dmi_addr[1] << 8) | 327 (ha->addr[1] << 8) |
262 (mclist->dmi_addr[0])); 328 (ha->addr[0]));
263 temac_indirect_out32(lp, XTE_MAW0_OFFSET, 329 temac_indirect_out32(lp, XTE_MAW0_OFFSET,
264 multi_addr_msw); 330 multi_addr_msw);
265 multi_addr_lsw = ((mclist->dmi_addr[5] << 8) | 331 multi_addr_lsw = ((ha->addr[5] << 8) |
266 (mclist->dmi_addr[4]) | (i << 16)); 332 (ha->addr[4]) | (i << 16));
267 temac_indirect_out32(lp, XTE_MAW1_OFFSET, 333 temac_indirect_out32(lp, XTE_MAW1_OFFSET,
268 multi_addr_lsw); 334 multi_addr_lsw);
269 i++; 335 i++;
@@ -426,9 +492,9 @@ static void temac_device_reset(struct net_device *ndev)
426 temac_indirect_out32(lp, XTE_RXC1_OFFSET, val & ~XTE_RXC1_RXEN_MASK); 492 temac_indirect_out32(lp, XTE_RXC1_OFFSET, val & ~XTE_RXC1_RXEN_MASK);
427 493
428 /* Reset Local Link (DMA) */ 494 /* Reset Local Link (DMA) */
429 temac_dma_out32(lp, DMA_CONTROL_REG, DMA_CONTROL_RST); 495 lp->dma_out(lp, DMA_CONTROL_REG, DMA_CONTROL_RST);
430 timeout = 1000; 496 timeout = 1000;
431 while (temac_dma_in32(lp, DMA_CONTROL_REG) & DMA_CONTROL_RST) { 497 while (lp->dma_in(lp, DMA_CONTROL_REG) & DMA_CONTROL_RST) {
432 udelay(1); 498 udelay(1);
433 if (--timeout == 0) { 499 if (--timeout == 0) {
434 dev_err(&ndev->dev, 500 dev_err(&ndev->dev,
@@ -436,7 +502,7 @@ static void temac_device_reset(struct net_device *ndev)
436 break; 502 break;
437 } 503 }
438 } 504 }
439 temac_dma_out32(lp, DMA_CONTROL_REG, DMA_TAIL_ENABLE); 505 lp->dma_out(lp, DMA_CONTROL_REG, DMA_TAIL_ENABLE);
440 506
441 temac_dma_bd_init(ndev); 507 temac_dma_bd_init(ndev);
442 508
@@ -597,7 +663,7 @@ static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
597 lp->tx_bd_tail = 0; 663 lp->tx_bd_tail = 0;
598 664
599 /* Kick off the transfer */ 665 /* Kick off the transfer */
600 temac_dma_out32(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */ 666 lp->dma_out(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */
601 667
602 return NETDEV_TX_OK; 668 return NETDEV_TX_OK;
603} 669}
@@ -639,16 +705,15 @@ static void ll_temac_recv(struct net_device *ndev)
639 ndev->stats.rx_packets++; 705 ndev->stats.rx_packets++;
640 ndev->stats.rx_bytes += length; 706 ndev->stats.rx_bytes += length;
641 707
642 new_skb = alloc_skb(XTE_MAX_JUMBO_FRAME_SIZE + XTE_ALIGN, 708 new_skb = netdev_alloc_skb_ip_align(ndev,
643 GFP_ATOMIC); 709 XTE_MAX_JUMBO_FRAME_SIZE);
710
644 if (new_skb == 0) { 711 if (new_skb == 0) {
645 dev_err(&ndev->dev, "no memory for new sk_buff\n"); 712 dev_err(&ndev->dev, "no memory for new sk_buff\n");
646 spin_unlock_irqrestore(&lp->rx_lock, flags); 713 spin_unlock_irqrestore(&lp->rx_lock, flags);
647 return; 714 return;
648 } 715 }
649 716
650 skb_reserve(new_skb, BUFFER_ALIGN(new_skb->data));
651
652 cur_p->app0 = STS_CTRL_APP0_IRQONEND; 717 cur_p->app0 = STS_CTRL_APP0_IRQONEND;
653 cur_p->phys = dma_map_single(ndev->dev.parent, new_skb->data, 718 cur_p->phys = dma_map_single(ndev->dev.parent, new_skb->data,
654 XTE_MAX_JUMBO_FRAME_SIZE, 719 XTE_MAX_JUMBO_FRAME_SIZE,
@@ -663,7 +728,7 @@ static void ll_temac_recv(struct net_device *ndev)
663 cur_p = &lp->rx_bd_v[lp->rx_bd_ci]; 728 cur_p = &lp->rx_bd_v[lp->rx_bd_ci];
664 bdstat = cur_p->app0; 729 bdstat = cur_p->app0;
665 } 730 }
666 temac_dma_out32(lp, RX_TAILDESC_PTR, tail_p); 731 lp->dma_out(lp, RX_TAILDESC_PTR, tail_p);
667 732
668 spin_unlock_irqrestore(&lp->rx_lock, flags); 733 spin_unlock_irqrestore(&lp->rx_lock, flags);
669} 734}
@@ -674,8 +739,8 @@ static irqreturn_t ll_temac_tx_irq(int irq, void *_ndev)
674 struct temac_local *lp = netdev_priv(ndev); 739 struct temac_local *lp = netdev_priv(ndev);
675 unsigned int status; 740 unsigned int status;
676 741
677 status = temac_dma_in32(lp, TX_IRQ_REG); 742 status = lp->dma_in(lp, TX_IRQ_REG);
678 temac_dma_out32(lp, TX_IRQ_REG, status); 743 lp->dma_out(lp, TX_IRQ_REG, status);
679 744
680 if (status & (IRQ_COAL | IRQ_DLY)) 745 if (status & (IRQ_COAL | IRQ_DLY))
681 temac_start_xmit_done(lp->ndev); 746 temac_start_xmit_done(lp->ndev);
@@ -692,8 +757,8 @@ static irqreturn_t ll_temac_rx_irq(int irq, void *_ndev)
692 unsigned int status; 757 unsigned int status;
693 758
694 /* Read and clear the status registers */ 759 /* Read and clear the status registers */
695 status = temac_dma_in32(lp, RX_IRQ_REG); 760 status = lp->dma_in(lp, RX_IRQ_REG);
696 temac_dma_out32(lp, RX_IRQ_REG, status); 761 lp->dma_out(lp, RX_IRQ_REG, status);
697 762
698 if (status & (IRQ_COAL | IRQ_DLY)) 763 if (status & (IRQ_COAL | IRQ_DLY))
699 ll_temac_recv(lp->ndev); 764 ll_temac_recv(lp->ndev);
@@ -794,7 +859,7 @@ static ssize_t temac_show_llink_regs(struct device *dev,
794 int i, len = 0; 859 int i, len = 0;
795 860
796 for (i = 0; i < 0x11; i++) 861 for (i = 0; i < 0x11; i++)
797 len += sprintf(buf + len, "%.8x%s", temac_dma_in32(lp, i), 862 len += sprintf(buf + len, "%.8x%s", lp->dma_in(lp, i),
798 (i % 8) == 7 ? "\n" : " "); 863 (i % 8) == 7 ? "\n" : " ");
799 len += sprintf(buf + len, "\n"); 864 len += sprintf(buf + len, "\n");
800 865
@@ -820,7 +885,6 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
820 struct net_device *ndev; 885 struct net_device *ndev;
821 const void *addr; 886 const void *addr;
822 int size, rc = 0; 887 int size, rc = 0;
823 unsigned int dcrs;
824 888
825 /* Init network device structure */ 889 /* Init network device structure */
826 ndev = alloc_etherdev(sizeof(*lp)); 890 ndev = alloc_etherdev(sizeof(*lp));
@@ -870,13 +934,20 @@ temac_of_probe(struct of_device *op, const struct of_device_id *match)
870 goto nodev; 934 goto nodev;
871 } 935 }
872 936
873 dcrs = dcr_resource_start(np, 0); 937 /* Setup the DMA register accesses, could be DCR or memory mapped */
874 if (dcrs == 0) { 938 if (temac_dcr_setup(lp, op, np)) {
875 dev_err(&op->dev, "could not get DMA register address\n"); 939
876 goto nodev; 940 /* no DCR in the device tree, try non-DCR */
941 lp->sdma_regs = of_iomap(np, 0);
942 if (lp->sdma_regs) {
943 lp->dma_in = temac_dma_in32;
944 lp->dma_out = temac_dma_out32;
945 dev_dbg(&op->dev, "MEM base: %p\n", lp->sdma_regs);
946 } else {
947 dev_err(&op->dev, "unable to map DMA registers\n");
948 goto nodev;
949 }
877 } 950 }
878 lp->sdma_dcrs = dcr_map(np, dcrs, dcr_resource_len(np, 0));
879 dev_dbg(&op->dev, "DCR base: %x\n", dcrs);
880 951
881 lp->rx_irq = irq_of_parse_and_map(np, 0); 952 lp->rx_irq = irq_of_parse_and_map(np, 0);
882 lp->tx_irq = irq_of_parse_and_map(np, 1); 953 lp->tx_irq = irq_of_parse_and_map(np, 1);
diff --git a/drivers/net/lp486e.c b/drivers/net/lp486e.c
index 3e3cc04defd0..72379c5439dc 100644
--- a/drivers/net/lp486e.c
+++ b/drivers/net/lp486e.c
@@ -1256,7 +1256,7 @@ static void set_multicast_list(struct net_device *dev) {
1256 dev->name, netdev_mc_count(dev)); 1256 dev->name, netdev_mc_count(dev));
1257 1257
1258 if (!netdev_mc_empty(dev)) { 1258 if (!netdev_mc_empty(dev)) {
1259 struct dev_mc_list *dmi; 1259 struct netdev_hw_addr *ha;
1260 char *cp; 1260 char *cp;
1261 cmd = kmalloc(sizeof(struct i596_cmd) + 2 + 1261 cmd = kmalloc(sizeof(struct i596_cmd) + 2 +
1262 netdev_mc_count(dev) * 6, GFP_ATOMIC); 1262 netdev_mc_count(dev) * 6, GFP_ATOMIC);
@@ -1267,8 +1267,8 @@ static void set_multicast_list(struct net_device *dev) {
1267 cmd->command = CmdMulticastList; 1267 cmd->command = CmdMulticastList;
1268 *((unsigned short *) (cmd + 1)) = netdev_mc_count(dev) * 6; 1268 *((unsigned short *) (cmd + 1)) = netdev_mc_count(dev) * 6;
1269 cp = ((char *)(cmd + 1))+2; 1269 cp = ((char *)(cmd + 1))+2;
1270 netdev_for_each_mc_addr(dmi, dev) { 1270 netdev_for_each_mc_addr(ha, dev) {
1271 memcpy(cp, dmi->dmi_addr, 6); 1271 memcpy(cp, ha->addr, 6);
1272 cp += 6; 1272 cp += 6;
1273 } 1273 }
1274 if (i596_debug & LOG_SRCDST) 1274 if (i596_debug & LOG_SRCDST)
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index c8a18a6203c8..eab121945d7c 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -882,15 +882,15 @@ static int hash_get_index(__u8 *addr)
882 */ 882 */
883static void macb_sethashtable(struct net_device *dev) 883static void macb_sethashtable(struct net_device *dev)
884{ 884{
885 struct dev_mc_list *curr; 885 struct netdev_hw_addr *ha;
886 unsigned long mc_filter[2]; 886 unsigned long mc_filter[2];
887 unsigned int bitnr; 887 unsigned int bitnr;
888 struct macb *bp = netdev_priv(dev); 888 struct macb *bp = netdev_priv(dev);
889 889
890 mc_filter[0] = mc_filter[1] = 0; 890 mc_filter[0] = mc_filter[1] = 0;
891 891
892 netdev_for_each_mc_addr(curr, dev) { 892 netdev_for_each_mc_addr(ha, dev) {
893 bitnr = hash_get_index(curr->dmi_addr); 893 bitnr = hash_get_index(ha->addr);
894 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31); 894 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
895 } 895 }
896 896
diff --git a/drivers/net/mace.c b/drivers/net/mace.c
index ab5f0bf6d1ae..2328a7399dcb 100644
--- a/drivers/net/mace.c
+++ b/drivers/net/mace.c
@@ -598,7 +598,7 @@ static void mace_set_multicast(struct net_device *dev)
598 mp->maccc |= PROM; 598 mp->maccc |= PROM;
599 } else { 599 } else {
600 unsigned char multicast_filter[8]; 600 unsigned char multicast_filter[8];
601 struct dev_mc_list *dmi; 601 struct netdev_hw_addr *ha;
602 602
603 if (dev->flags & IFF_ALLMULTI) { 603 if (dev->flags & IFF_ALLMULTI) {
604 for (i = 0; i < 8; i++) 604 for (i = 0; i < 8; i++)
@@ -606,8 +606,8 @@ static void mace_set_multicast(struct net_device *dev)
606 } else { 606 } else {
607 for (i = 0; i < 8; i++) 607 for (i = 0; i < 8; i++)
608 multicast_filter[i] = 0; 608 multicast_filter[i] = 0;
609 netdev_for_each_mc_addr(dmi, dev) { 609 netdev_for_each_mc_addr(ha, dev) {
610 crc = ether_crc_le(6, dmi->dmi_addr); 610 crc = ether_crc_le(6, ha->addr);
611 i = crc >> 26; /* bit number in multicast_filter */ 611 i = crc >> 26; /* bit number in multicast_filter */
612 multicast_filter[i >> 3] |= 1 << (i & 7); 612 multicast_filter[i >> 3] |= 1 << (i & 7);
613 } 613 }
diff --git a/drivers/net/macmace.c b/drivers/net/macmace.c
index 13ba8f4afb7e..8a50c67e5928 100644
--- a/drivers/net/macmace.c
+++ b/drivers/net/macmace.c
@@ -508,7 +508,7 @@ static void mace_set_multicast(struct net_device *dev)
508 mb->maccc |= PROM; 508 mb->maccc |= PROM;
509 } else { 509 } else {
510 unsigned char multicast_filter[8]; 510 unsigned char multicast_filter[8];
511 struct dev_mc_list *dmi; 511 struct netdev_hw_addr *ha;
512 512
513 if (dev->flags & IFF_ALLMULTI) { 513 if (dev->flags & IFF_ALLMULTI) {
514 for (i = 0; i < 8; i++) { 514 for (i = 0; i < 8; i++) {
@@ -517,8 +517,8 @@ static void mace_set_multicast(struct net_device *dev)
517 } else { 517 } else {
518 for (i = 0; i < 8; i++) 518 for (i = 0; i < 8; i++)
519 multicast_filter[i] = 0; 519 multicast_filter[i] = 0;
520 netdev_for_each_mc_addr(dmi, dev) { 520 netdev_for_each_mc_addr(ha, dev) {
521 crc = ether_crc_le(6, dmi->dmi_addr); 521 crc = ether_crc_le(6, ha->addr);
522 /* bit number in multicast_filter */ 522 /* bit number in multicast_filter */
523 i = crc >> 26; 523 i = crc >> 26;
524 multicast_filter[i >> 3] |= 1 << (i & 7); 524 multicast_filter[i >> 3] |= 1 << (i & 7);
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 40faa368b07a..9a939d828b47 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -282,7 +282,7 @@ static int macvlan_open(struct net_device *dev)
282 if (macvlan_addr_busy(vlan->port, dev->dev_addr)) 282 if (macvlan_addr_busy(vlan->port, dev->dev_addr))
283 goto out; 283 goto out;
284 284
285 err = dev_unicast_add(lowerdev, dev->dev_addr); 285 err = dev_uc_add(lowerdev, dev->dev_addr);
286 if (err < 0) 286 if (err < 0)
287 goto out; 287 goto out;
288 if (dev->flags & IFF_ALLMULTI) { 288 if (dev->flags & IFF_ALLMULTI) {
@@ -294,7 +294,7 @@ static int macvlan_open(struct net_device *dev)
294 return 0; 294 return 0;
295 295
296del_unicast: 296del_unicast:
297 dev_unicast_delete(lowerdev, dev->dev_addr); 297 dev_uc_del(lowerdev, dev->dev_addr);
298out: 298out:
299 return err; 299 return err;
300} 300}
@@ -308,7 +308,7 @@ static int macvlan_stop(struct net_device *dev)
308 if (dev->flags & IFF_ALLMULTI) 308 if (dev->flags & IFF_ALLMULTI)
309 dev_set_allmulti(lowerdev, -1); 309 dev_set_allmulti(lowerdev, -1);
310 310
311 dev_unicast_delete(lowerdev, dev->dev_addr); 311 dev_uc_del(lowerdev, dev->dev_addr);
312 312
313 macvlan_hash_del(vlan); 313 macvlan_hash_del(vlan);
314 return 0; 314 return 0;
@@ -332,11 +332,11 @@ static int macvlan_set_mac_address(struct net_device *dev, void *p)
332 if (macvlan_addr_busy(vlan->port, addr->sa_data)) 332 if (macvlan_addr_busy(vlan->port, addr->sa_data))
333 return -EBUSY; 333 return -EBUSY;
334 334
335 err = dev_unicast_add(lowerdev, addr->sa_data); 335 err = dev_uc_add(lowerdev, addr->sa_data);
336 if (err) 336 if (err)
337 return err; 337 return err;
338 338
339 dev_unicast_delete(lowerdev, dev->dev_addr); 339 dev_uc_del(lowerdev, dev->dev_addr);
340 340
341 macvlan_hash_change_addr(vlan, addr->sa_data); 341 macvlan_hash_change_addr(vlan, addr->sa_data);
342 } 342 }
@@ -748,6 +748,9 @@ static int macvlan_device_event(struct notifier_block *unused,
748 list_for_each_entry_safe(vlan, next, &port->vlans, list) 748 list_for_each_entry_safe(vlan, next, &port->vlans, list)
749 vlan->dev->rtnl_link_ops->dellink(vlan->dev, NULL); 749 vlan->dev->rtnl_link_ops->dellink(vlan->dev, NULL);
750 break; 750 break;
751 case NETDEV_PRE_TYPE_CHANGE:
752 /* Forbid underlaying device to change its type. */
753 return NOTIFY_BAD;
751 } 754 }
752 return NOTIFY_DONE; 755 return NOTIFY_DONE;
753} 756}
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index c48b0f4b17b7..455464223b43 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -160,39 +160,29 @@ static void mlx4_en_do_set_mac(struct work_struct *work)
160static void mlx4_en_clear_list(struct net_device *dev) 160static void mlx4_en_clear_list(struct net_device *dev)
161{ 161{
162 struct mlx4_en_priv *priv = netdev_priv(dev); 162 struct mlx4_en_priv *priv = netdev_priv(dev);
163 struct dev_mc_list *plist = priv->mc_list;
164 struct dev_mc_list *next;
165 163
166 while (plist) { 164 kfree(priv->mc_addrs);
167 next = plist->next; 165 priv->mc_addrs_cnt = 0;
168 kfree(plist);
169 plist = next;
170 }
171 priv->mc_list = NULL;
172} 166}
173 167
174static void mlx4_en_cache_mclist(struct net_device *dev) 168static void mlx4_en_cache_mclist(struct net_device *dev)
175{ 169{
176 struct mlx4_en_priv *priv = netdev_priv(dev); 170 struct mlx4_en_priv *priv = netdev_priv(dev);
177 struct dev_mc_list *mclist; 171 struct netdev_hw_addr *ha;
178 struct dev_mc_list *tmp; 172 char *mc_addrs;
179 struct dev_mc_list *plist = NULL; 173 int mc_addrs_cnt = netdev_mc_count(dev);
180 174 int i;
181 for (mclist = dev->mc_list; mclist; mclist = mclist->next) { 175
182 tmp = kmalloc(sizeof(struct dev_mc_list), GFP_ATOMIC); 176 mc_addrs = kmalloc(mc_addrs_cnt * ETH_ALEN, GFP_ATOMIC);
183 if (!tmp) { 177 if (!mc_addrs) {
184 en_err(priv, "failed to allocate multicast list\n"); 178 en_err(priv, "failed to allocate multicast list\n");
185 mlx4_en_clear_list(dev); 179 return;
186 return;
187 }
188 memcpy(tmp, mclist, sizeof(struct dev_mc_list));
189 tmp->next = NULL;
190 if (plist)
191 plist->next = tmp;
192 else
193 priv->mc_list = tmp;
194 plist = tmp;
195 } 180 }
181 i = 0;
182 netdev_for_each_mc_addr(ha, dev)
183 memcpy(mc_addrs + i++ * ETH_ALEN, ha->addr, ETH_ALEN);
184 priv->mc_addrs = mc_addrs;
185 priv->mc_addrs_cnt = mc_addrs_cnt;
196} 186}
197 187
198 188
@@ -212,7 +202,6 @@ static void mlx4_en_do_set_multicast(struct work_struct *work)
212 mcast_task); 202 mcast_task);
213 struct mlx4_en_dev *mdev = priv->mdev; 203 struct mlx4_en_dev *mdev = priv->mdev;
214 struct net_device *dev = priv->dev; 204 struct net_device *dev = priv->dev;
215 struct dev_mc_list *mclist;
216 u64 mcast_addr = 0; 205 u64 mcast_addr = 0;
217 int err; 206 int err;
218 207
@@ -288,6 +277,8 @@ static void mlx4_en_do_set_multicast(struct work_struct *work)
288 if (err) 277 if (err)
289 en_err(priv, "Failed disabling multicast filter\n"); 278 en_err(priv, "Failed disabling multicast filter\n");
290 } else { 279 } else {
280 int i;
281
291 err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0, 282 err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0,
292 0, MLX4_MCAST_DISABLE); 283 0, MLX4_MCAST_DISABLE);
293 if (err) 284 if (err)
@@ -302,8 +293,9 @@ static void mlx4_en_do_set_multicast(struct work_struct *work)
302 netif_tx_lock_bh(dev); 293 netif_tx_lock_bh(dev);
303 mlx4_en_cache_mclist(dev); 294 mlx4_en_cache_mclist(dev);
304 netif_tx_unlock_bh(dev); 295 netif_tx_unlock_bh(dev);
305 for (mclist = priv->mc_list; mclist; mclist = mclist->next) { 296 for (i = 0; i < priv->mc_addrs_cnt; i++) {
306 mcast_addr = mlx4_en_mac_to_u64(mclist->dmi_addr); 297 mcast_addr =
298 mlx4_en_mac_to_u64(priv->mc_addrs + i * ETH_ALEN);
307 mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 299 mlx4_SET_MCAST_FLTR(mdev->dev, priv->port,
308 mcast_addr, 0, MLX4_MCAST_CONFIG); 300 mcast_addr, 0, MLX4_MCAST_CONFIG);
309 } 301 }
@@ -511,7 +503,7 @@ static void mlx4_en_do_get_stats(struct work_struct *work)
511 503
512 err = mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 0); 504 err = mlx4_en_DUMP_ETH_STATS(mdev, priv->port, 0);
513 if (err) 505 if (err)
514 en_dbg(HW, priv, "Could not update stats \n"); 506 en_dbg(HW, priv, "Could not update stats\n");
515 507
516 mutex_lock(&mdev->state_lock); 508 mutex_lock(&mdev->state_lock);
517 if (mdev->device_up) { 509 if (mdev->device_up) {
@@ -984,7 +976,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
984 priv->flags = prof->flags; 976 priv->flags = prof->flags;
985 priv->tx_ring_num = prof->tx_ring_num; 977 priv->tx_ring_num = prof->tx_ring_num;
986 priv->rx_ring_num = prof->rx_ring_num; 978 priv->rx_ring_num = prof->rx_ring_num;
987 priv->mc_list = NULL;
988 priv->mac_index = -1; 979 priv->mac_index = -1;
989 priv->msg_enable = MLX4_EN_MSG_LEVEL; 980 priv->msg_enable = MLX4_EN_MSG_LEVEL;
990 spin_lock_init(&priv->stats_lock); 981 spin_lock_init(&priv->stats_lock);
diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h
index 82c3ebc584e3..b55e46c8b682 100644
--- a/drivers/net/mlx4/mlx4_en.h
+++ b/drivers/net/mlx4/mlx4_en.h
@@ -492,7 +492,8 @@ struct mlx4_en_priv {
492 struct mlx4_en_perf_stats pstats; 492 struct mlx4_en_perf_stats pstats;
493 struct mlx4_en_pkt_stats pkstats; 493 struct mlx4_en_pkt_stats pkstats;
494 struct mlx4_en_port_stats port_stats; 494 struct mlx4_en_port_stats port_stats;
495 struct dev_mc_list *mc_list; 495 char *mc_addrs;
496 int mc_addrs_cnt;
496 struct mlx4_en_stat_out_mbox hw_stats; 497 struct mlx4_en_stat_out_mbox hw_stats;
497}; 498};
498 499
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index c97b6e4365a9..d5ebe43b0e65 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -1769,7 +1769,7 @@ static void mv643xx_eth_program_multicast_filter(struct net_device *dev)
1769 struct mv643xx_eth_private *mp = netdev_priv(dev); 1769 struct mv643xx_eth_private *mp = netdev_priv(dev);
1770 u32 *mc_spec; 1770 u32 *mc_spec;
1771 u32 *mc_other; 1771 u32 *mc_other;
1772 struct dev_addr_list *addr; 1772 struct netdev_hw_addr *ha;
1773 int i; 1773 int i;
1774 1774
1775 if (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) { 1775 if (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) {
@@ -1794,8 +1794,8 @@ oom:
1794 memset(mc_spec, 0, 0x100); 1794 memset(mc_spec, 0, 0x100);
1795 memset(mc_other, 0, 0x100); 1795 memset(mc_other, 0, 0x100);
1796 1796
1797 netdev_for_each_mc_addr(addr, dev) { 1797 netdev_for_each_mc_addr(ha, dev) {
1798 u8 *a = addr->da_addr; 1798 u8 *a = ha->addr;
1799 u32 *table; 1799 u32 *table;
1800 int entry; 1800 int entry;
1801 1801
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index e84dd3ee9c5a..6d33adf988dc 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -3001,7 +3001,7 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
3001{ 3001{
3002 struct myri10ge_priv *mgp = netdev_priv(dev); 3002 struct myri10ge_priv *mgp = netdev_priv(dev);
3003 struct myri10ge_cmd cmd; 3003 struct myri10ge_cmd cmd;
3004 struct dev_mc_list *mc_list; 3004 struct netdev_hw_addr *ha;
3005 __be32 data[2] = { 0, 0 }; 3005 __be32 data[2] = { 0, 0 };
3006 int err; 3006 int err;
3007 3007
@@ -3038,8 +3038,8 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
3038 } 3038 }
3039 3039
3040 /* Walk the multicast list, and add each address */ 3040 /* Walk the multicast list, and add each address */
3041 netdev_for_each_mc_addr(mc_list, dev) { 3041 netdev_for_each_mc_addr(ha, dev) {
3042 memcpy(data, &mc_list->dmi_addr, 6); 3042 memcpy(data, &ha->addr, 6);
3043 cmd.data0 = ntohl(data[0]); 3043 cmd.data0 = ntohl(data[0]);
3044 cmd.data1 = ntohl(data[1]); 3044 cmd.data1 = ntohl(data[1]);
3045 err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP, 3045 err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP,
@@ -3047,7 +3047,7 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
3047 3047
3048 if (err != 0) { 3048 if (err != 0) {
3049 netdev_err(dev, "Failed MXGEFW_JOIN_MULTICAST_GROUP, error status:%d %pM\n", 3049 netdev_err(dev, "Failed MXGEFW_JOIN_MULTICAST_GROUP, error status:%d %pM\n",
3050 err, mc_list->dmi_addr); 3050 err, ha->addr);
3051 goto abort; 3051 goto abort;
3052 } 3052 }
3053 } 3053 }
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index e52038783245..9250bf6573ec 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -2493,12 +2493,12 @@ static void __set_rx_mode(struct net_device *dev)
2493 rx_mode = RxFilterEnable | AcceptBroadcast 2493 rx_mode = RxFilterEnable | AcceptBroadcast
2494 | AcceptAllMulticast | AcceptMyPhys; 2494 | AcceptAllMulticast | AcceptMyPhys;
2495 } else { 2495 } else {
2496 struct dev_mc_list *mclist; 2496 struct netdev_hw_addr *ha;
2497 int i; 2497 int i;
2498 2498
2499 memset(mc_filter, 0, sizeof(mc_filter)); 2499 memset(mc_filter, 0, sizeof(mc_filter));
2500 netdev_for_each_mc_addr(mclist, dev) { 2500 netdev_for_each_mc_addr(ha, dev) {
2501 int b = (ether_crc(ETH_ALEN, mclist->dmi_addr) >> 23) & 0x1ff; 2501 int b = (ether_crc(ETH_ALEN, ha->addr) >> 23) & 0x1ff;
2502 mc_filter[b/8] |= (1 << (b & 0x07)); 2502 mc_filter[b/8] |= (1 << (b & 0x07));
2503 } 2503 }
2504 rx_mode = RxFilterEnable | AcceptBroadcast 2504 rx_mode = RxFilterEnable | AcceptBroadcast
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 0f703838e21a..174ac8ef82fa 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -420,7 +420,6 @@ struct status_desc {
420} __attribute__ ((aligned(16))); 420} __attribute__ ((aligned(16)));
421 421
422/* UNIFIED ROMIMAGE *************************/ 422/* UNIFIED ROMIMAGE *************************/
423#define NX_UNI_FW_MIN_SIZE 0xc8000
424#define NX_UNI_DIR_SECT_PRODUCT_TBL 0x0 423#define NX_UNI_DIR_SECT_PRODUCT_TBL 0x0
425#define NX_UNI_DIR_SECT_BOOTLD 0x6 424#define NX_UNI_DIR_SECT_BOOTLD 0x6
426#define NX_UNI_DIR_SECT_FW 0x7 425#define NX_UNI_DIR_SECT_FW 0x7
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index f8499e56cbee..aecba787f7c8 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -703,6 +703,11 @@ netxen_nic_get_ethtool_stats(struct net_device *dev,
703 } 703 }
704} 704}
705 705
706static u32 netxen_nic_get_tx_csum(struct net_device *dev)
707{
708 return dev->features & NETIF_F_IP_CSUM;
709}
710
706static u32 netxen_nic_get_rx_csum(struct net_device *dev) 711static u32 netxen_nic_get_rx_csum(struct net_device *dev)
707{ 712{
708 struct netxen_adapter *adapter = netdev_priv(dev); 713 struct netxen_adapter *adapter = netdev_priv(dev);
@@ -909,6 +914,7 @@ const struct ethtool_ops netxen_nic_ethtool_ops = {
909 .set_ringparam = netxen_nic_set_ringparam, 914 .set_ringparam = netxen_nic_set_ringparam,
910 .get_pauseparam = netxen_nic_get_pauseparam, 915 .get_pauseparam = netxen_nic_get_pauseparam,
911 .set_pauseparam = netxen_nic_set_pauseparam, 916 .set_pauseparam = netxen_nic_set_pauseparam,
917 .get_tx_csum = netxen_nic_get_tx_csum,
912 .set_tx_csum = ethtool_op_set_tx_csum, 918 .set_tx_csum = ethtool_op_set_tx_csum,
913 .set_sg = ethtool_op_set_sg, 919 .set_sg = ethtool_op_set_sg,
914 .get_tso = netxen_nic_get_tso, 920 .get_tso = netxen_nic_get_tso,
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index a945591298a8..781ca893ee0a 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -537,7 +537,7 @@ netxen_nic_set_mcast_addr(struct netxen_adapter *adapter,
537void netxen_p2_nic_set_multi(struct net_device *netdev) 537void netxen_p2_nic_set_multi(struct net_device *netdev)
538{ 538{
539 struct netxen_adapter *adapter = netdev_priv(netdev); 539 struct netxen_adapter *adapter = netdev_priv(netdev);
540 struct dev_mc_list *mc_ptr; 540 struct netdev_hw_addr *ha;
541 u8 null_addr[6]; 541 u8 null_addr[6];
542 int i; 542 int i;
543 543
@@ -571,8 +571,8 @@ void netxen_p2_nic_set_multi(struct net_device *netdev)
571 netxen_nic_enable_mcast_filter(adapter); 571 netxen_nic_enable_mcast_filter(adapter);
572 572
573 i = 0; 573 i = 0;
574 netdev_for_each_mc_addr(mc_ptr, netdev) 574 netdev_for_each_mc_addr(ha, netdev)
575 netxen_nic_set_mcast_addr(adapter, i++, mc_ptr->dmi_addr); 575 netxen_nic_set_mcast_addr(adapter, i++, ha->addr);
576 576
577 /* Clear out remaining addresses */ 577 /* Clear out remaining addresses */
578 while (i < adapter->max_mc_count) 578 while (i < adapter->max_mc_count)
@@ -680,7 +680,7 @@ static int nx_p3_nic_add_mac(struct netxen_adapter *adapter,
680void netxen_p3_nic_set_multi(struct net_device *netdev) 680void netxen_p3_nic_set_multi(struct net_device *netdev)
681{ 681{
682 struct netxen_adapter *adapter = netdev_priv(netdev); 682 struct netxen_adapter *adapter = netdev_priv(netdev);
683 struct dev_mc_list *mc_ptr; 683 struct netdev_hw_addr *ha;
684 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 684 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
685 u32 mode = VPORT_MISS_MODE_DROP; 685 u32 mode = VPORT_MISS_MODE_DROP;
686 LIST_HEAD(del_list); 686 LIST_HEAD(del_list);
@@ -707,8 +707,8 @@ void netxen_p3_nic_set_multi(struct net_device *netdev)
707 } 707 }
708 708
709 if (!netdev_mc_empty(netdev)) { 709 if (!netdev_mc_empty(netdev)) {
710 netdev_for_each_mc_addr(mc_ptr, netdev) 710 netdev_for_each_mc_addr(ha, netdev)
711 nx_p3_nic_add_mac(adapter, mc_ptr->dmi_addr, &del_list); 711 nx_p3_nic_add_mac(adapter, ha->addr, &del_list);
712 } 712 }
713 713
714send_fw_cmd: 714send_fw_cmd:
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 7eb925a9f36e..ecb6eed1d8e2 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -613,22 +613,123 @@ static struct uni_table_desc *nx_get_table_desc(const u8 *unirom, int section)
613 return NULL; 613 return NULL;
614} 614}
615 615
616#define QLCNIC_FILEHEADER_SIZE (14 * 4)
617
616static int 618static int
617nx_set_product_offs(struct netxen_adapter *adapter) 619netxen_nic_validate_header(struct netxen_adapter *adapter)
618{ 620 {
619 struct uni_table_desc *ptab_descr;
620 const u8 *unirom = adapter->fw->data; 621 const u8 *unirom = adapter->fw->data;
621 uint32_t i; 622 struct uni_table_desc *directory = (struct uni_table_desc *) &unirom[0];
623 u32 fw_file_size = adapter->fw->size;
624 u32 tab_size;
622 __le32 entries; 625 __le32 entries;
626 __le32 entry_size;
627
628 if (fw_file_size < QLCNIC_FILEHEADER_SIZE)
629 return -EINVAL;
630
631 entries = cpu_to_le32(directory->num_entries);
632 entry_size = cpu_to_le32(directory->entry_size);
633 tab_size = cpu_to_le32(directory->findex) + (entries * entry_size);
634
635 if (fw_file_size < tab_size)
636 return -EINVAL;
637
638 return 0;
639}
640
641static int
642netxen_nic_validate_bootld(struct netxen_adapter *adapter)
643{
644 struct uni_table_desc *tab_desc;
645 struct uni_data_desc *descr;
646 const u8 *unirom = adapter->fw->data;
647 __le32 idx = cpu_to_le32(*((int *)&unirom[adapter->file_prd_off] +
648 NX_UNI_BOOTLD_IDX_OFF));
649 u32 offs;
650 u32 tab_size;
651 u32 data_size;
652
653 tab_desc = nx_get_table_desc(unirom, NX_UNI_DIR_SECT_BOOTLD);
654
655 if (!tab_desc)
656 return -EINVAL;
657
658 tab_size = cpu_to_le32(tab_desc->findex) +
659 (cpu_to_le32(tab_desc->entry_size) * (idx + 1));
660
661 if (adapter->fw->size < tab_size)
662 return -EINVAL;
663
664 offs = cpu_to_le32(tab_desc->findex) +
665 (cpu_to_le32(tab_desc->entry_size) * (idx));
666 descr = (struct uni_data_desc *)&unirom[offs];
667
668 data_size = cpu_to_le32(descr->findex) + cpu_to_le32(descr->size);
669
670 if (adapter->fw->size < data_size)
671 return -EINVAL;
623 672
673 return 0;
674}
675
676static int
677netxen_nic_validate_fw(struct netxen_adapter *adapter)
678{
679 struct uni_table_desc *tab_desc;
680 struct uni_data_desc *descr;
681 const u8 *unirom = adapter->fw->data;
682 __le32 idx = cpu_to_le32(*((int *)&unirom[adapter->file_prd_off] +
683 NX_UNI_FIRMWARE_IDX_OFF));
684 u32 offs;
685 u32 tab_size;
686 u32 data_size;
687
688 tab_desc = nx_get_table_desc(unirom, NX_UNI_DIR_SECT_FW);
689
690 if (!tab_desc)
691 return -EINVAL;
692
693 tab_size = cpu_to_le32(tab_desc->findex) +
694 (cpu_to_le32(tab_desc->entry_size) * (idx + 1));
695
696 if (adapter->fw->size < tab_size)
697 return -EINVAL;
698
699 offs = cpu_to_le32(tab_desc->findex) +
700 (cpu_to_le32(tab_desc->entry_size) * (idx));
701 descr = (struct uni_data_desc *)&unirom[offs];
702 data_size = cpu_to_le32(descr->findex) + cpu_to_le32(descr->size);
703
704 if (adapter->fw->size < data_size)
705 return -EINVAL;
706
707 return 0;
708}
709
710
711static int
712netxen_nic_validate_product_offs(struct netxen_adapter *adapter)
713{
714 struct uni_table_desc *ptab_descr;
715 const u8 *unirom = adapter->fw->data;
624 int mn_present = (NX_IS_REVISION_P2(adapter->ahw.revision_id)) ? 716 int mn_present = (NX_IS_REVISION_P2(adapter->ahw.revision_id)) ?
625 1 : netxen_p3_has_mn(adapter); 717 1 : netxen_p3_has_mn(adapter);
718 __le32 entries;
719 __le32 entry_size;
720 u32 tab_size;
721 u32 i;
626 722
627 ptab_descr = nx_get_table_desc(unirom, NX_UNI_DIR_SECT_PRODUCT_TBL); 723 ptab_descr = nx_get_table_desc(unirom, NX_UNI_DIR_SECT_PRODUCT_TBL);
628 if (ptab_descr == NULL) 724 if (ptab_descr == NULL)
629 return -1; 725 return -EINVAL;
630 726
631 entries = cpu_to_le32(ptab_descr->num_entries); 727 entries = cpu_to_le32(ptab_descr->num_entries);
728 entry_size = cpu_to_le32(ptab_descr->entry_size);
729 tab_size = cpu_to_le32(ptab_descr->findex) + (entries * entry_size);
730
731 if (adapter->fw->size < tab_size)
732 return -EINVAL;
632 733
633nomn: 734nomn:
634 for (i = 0; i < entries; i++) { 735 for (i = 0; i < entries; i++) {
@@ -657,9 +758,38 @@ nomn:
657 goto nomn; 758 goto nomn;
658 } 759 }
659 760
660 return -1; 761 return -EINVAL;
661} 762}
662 763
764static int
765netxen_nic_validate_unified_romimage(struct netxen_adapter *adapter)
766{
767 if (netxen_nic_validate_header(adapter)) {
768 dev_err(&adapter->pdev->dev,
769 "unified image: header validation failed\n");
770 return -EINVAL;
771 }
772
773 if (netxen_nic_validate_product_offs(adapter)) {
774 dev_err(&adapter->pdev->dev,
775 "unified image: product validation failed\n");
776 return -EINVAL;
777 }
778
779 if (netxen_nic_validate_bootld(adapter)) {
780 dev_err(&adapter->pdev->dev,
781 "unified image: bootld validation failed\n");
782 return -EINVAL;
783 }
784
785 if (netxen_nic_validate_fw(adapter)) {
786 dev_err(&adapter->pdev->dev,
787 "unified image: firmware validation failed\n");
788 return -EINVAL;
789 }
790
791 return 0;
792}
663 793
664static struct uni_data_desc *nx_get_data_desc(struct netxen_adapter *adapter, 794static struct uni_data_desc *nx_get_data_desc(struct netxen_adapter *adapter,
665 u32 section, u32 idx_offset) 795 u32 section, u32 idx_offset)
@@ -889,6 +1019,16 @@ netxen_load_firmware(struct netxen_adapter *adapter)
889 1019
890 flashaddr += 8; 1020 flashaddr += 8;
891 } 1021 }
1022
1023 size = (__force u32)nx_get_fw_size(adapter) % 8;
1024 if (size) {
1025 data = cpu_to_le64(ptr64[i]);
1026
1027 if (adapter->pci_mem_write(adapter,
1028 flashaddr, data))
1029 return -EIO;
1030 }
1031
892 } else { 1032 } else {
893 u64 data; 1033 u64 data;
894 u32 hi, lo; 1034 u32 hi, lo;
@@ -933,27 +1073,23 @@ static int
933netxen_validate_firmware(struct netxen_adapter *adapter) 1073netxen_validate_firmware(struct netxen_adapter *adapter)
934{ 1074{
935 __le32 val; 1075 __le32 val;
936 u32 ver, min_ver, bios, min_size; 1076 u32 ver, min_ver, bios;
937 struct pci_dev *pdev = adapter->pdev; 1077 struct pci_dev *pdev = adapter->pdev;
938 const struct firmware *fw = adapter->fw; 1078 const struct firmware *fw = adapter->fw;
939 u8 fw_type = adapter->fw_type; 1079 u8 fw_type = adapter->fw_type;
940 1080
941 if (fw_type == NX_UNIFIED_ROMIMAGE) { 1081 if (fw_type == NX_UNIFIED_ROMIMAGE) {
942 if (nx_set_product_offs(adapter)) 1082 if (netxen_nic_validate_unified_romimage(adapter))
943 return -EINVAL; 1083 return -EINVAL;
944
945 min_size = NX_UNI_FW_MIN_SIZE;
946 } else { 1084 } else {
947 val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_MAGIC_OFFSET]); 1085 val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_MAGIC_OFFSET]);
948 if ((__force u32)val != NETXEN_BDINFO_MAGIC) 1086 if ((__force u32)val != NETXEN_BDINFO_MAGIC)
949 return -EINVAL; 1087 return -EINVAL;
950 1088
951 min_size = NX_FW_MIN_SIZE; 1089 if (fw->size < NX_FW_MIN_SIZE)
1090 return -EINVAL;
952 } 1091 }
953 1092
954 if (fw->size < min_size)
955 return -EINVAL;
956
957 val = nx_get_fw_version(adapter); 1093 val = nx_get_fw_version(adapter);
958 1094
959 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) 1095 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 01808b28d1b6..9e82061c0235 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -781,15 +781,22 @@ netxen_check_options(struct netxen_adapter *adapter)
781 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { 781 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
782 adapter->msix_supported = !!use_msi_x; 782 adapter->msix_supported = !!use_msi_x;
783 adapter->rss_supported = !!use_msi_x; 783 adapter->rss_supported = !!use_msi_x;
784 } else if (adapter->fw_version >= NETXEN_VERSION_CODE(3, 4, 336)) { 784 } else {
785 switch (adapter->ahw.board_type) { 785 u32 flashed_ver = 0;
786 case NETXEN_BRDTYPE_P2_SB31_10G: 786 netxen_rom_fast_read(adapter,
787 case NETXEN_BRDTYPE_P2_SB31_10G_CX4: 787 NX_FW_VERSION_OFFSET, (int *)&flashed_ver);
788 adapter->msix_supported = !!use_msi_x; 788 flashed_ver = NETXEN_DECODE_VERSION(flashed_ver);
789 adapter->rss_supported = !!use_msi_x; 789
790 break; 790 if (flashed_ver >= NETXEN_VERSION_CODE(3, 4, 336)) {
791 default: 791 switch (adapter->ahw.board_type) {
792 break; 792 case NETXEN_BRDTYPE_P2_SB31_10G:
793 case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
794 adapter->msix_supported = !!use_msi_x;
795 adapter->rss_supported = !!use_msi_x;
796 break;
797 default:
798 break;
799 }
793 } 800 }
794 } 801 }
795 802
@@ -2303,6 +2310,7 @@ netxen_fwinit_work(struct work_struct *work)
2303 } 2310 }
2304 break; 2311 break;
2305 2312
2313 case NX_DEV_NEED_RESET:
2306 case NX_DEV_INITALIZING: 2314 case NX_DEV_INITALIZING:
2307 if (++adapter->fw_wait_cnt < FW_POLL_THRESH) { 2315 if (++adapter->fw_wait_cnt < FW_POLL_THRESH) {
2308 netxen_schedule_work(adapter, 2316 netxen_schedule_work(adapter,
@@ -2346,6 +2354,9 @@ netxen_detach_work(struct work_struct *work)
2346 2354
2347 ref_cnt = nx_decr_dev_ref_cnt(adapter); 2355 ref_cnt = nx_decr_dev_ref_cnt(adapter);
2348 2356
2357 if (ref_cnt == -EIO)
2358 goto err_ret;
2359
2349 delay = (ref_cnt == 0) ? 0 : (2 * FW_POLL_DELAY); 2360 delay = (ref_cnt == 0) ? 0 : (2 * FW_POLL_DELAY);
2350 2361
2351 adapter->fw_wait_cnt = 0; 2362 adapter->fw_wait_cnt = 0;
diff --git a/drivers/net/ni52.c b/drivers/net/ni52.c
index 05c29c2cef2a..a76fabe26292 100644
--- a/drivers/net/ni52.c
+++ b/drivers/net/ni52.c
@@ -596,7 +596,7 @@ static int init586(struct net_device *dev)
596 struct iasetup_cmd_struct __iomem *ias_cmd; 596 struct iasetup_cmd_struct __iomem *ias_cmd;
597 struct tdr_cmd_struct __iomem *tdr_cmd; 597 struct tdr_cmd_struct __iomem *tdr_cmd;
598 struct mcsetup_cmd_struct __iomem *mc_cmd; 598 struct mcsetup_cmd_struct __iomem *mc_cmd;
599 struct dev_mc_list *dmi; 599 struct netdev_hw_addr *ha;
600 int num_addrs = netdev_mc_count(dev); 600 int num_addrs = netdev_mc_count(dev);
601 601
602 ptr = p->scb + 1; 602 ptr = p->scb + 1;
@@ -725,8 +725,8 @@ static int init586(struct net_device *dev)
725 writew(num_addrs * 6, &mc_cmd->mc_cnt); 725 writew(num_addrs * 6, &mc_cmd->mc_cnt);
726 726
727 i = 0; 727 i = 0;
728 netdev_for_each_mc_addr(dmi, dev) 728 netdev_for_each_mc_addr(ha, dev)
729 memcpy_toio(mc_cmd->mc_list[i++], dmi->dmi_addr, 6); 729 memcpy_toio(mc_cmd->mc_list[i++], ha->addr, 6);
730 730
731 writew(make16(mc_cmd), &p->scb->cbl_offset); 731 writew(make16(mc_cmd), &p->scb->cbl_offset);
732 writeb(CUC_START, &p->scb->cmd_cuc); 732 writeb(CUC_START, &p->scb->cmd_cuc);
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 0678f3106cbc..7b52c466cf48 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -6313,7 +6313,6 @@ static void niu_set_rx_mode(struct net_device *dev)
6313{ 6313{
6314 struct niu *np = netdev_priv(dev); 6314 struct niu *np = netdev_priv(dev);
6315 int i, alt_cnt, err; 6315 int i, alt_cnt, err;
6316 struct dev_addr_list *addr;
6317 struct netdev_hw_addr *ha; 6316 struct netdev_hw_addr *ha;
6318 unsigned long flags; 6317 unsigned long flags;
6319 u16 hash[16] = { 0, }; 6318 u16 hash[16] = { 0, };
@@ -6365,8 +6364,8 @@ static void niu_set_rx_mode(struct net_device *dev)
6365 for (i = 0; i < 16; i++) 6364 for (i = 0; i < 16; i++)
6366 hash[i] = 0xffff; 6365 hash[i] = 0xffff;
6367 } else if (!netdev_mc_empty(dev)) { 6366 } else if (!netdev_mc_empty(dev)) {
6368 netdev_for_each_mc_addr(addr, dev) { 6367 netdev_for_each_mc_addr(ha, dev) {
6369 u32 crc = ether_crc_le(ETH_ALEN, addr->da_addr); 6368 u32 crc = ether_crc_le(ETH_ALEN, ha->addr);
6370 6369
6371 crc >>= 24; 6370 crc >>= 24;
6372 hash[crc >> 4] |= (1 << (15 - (crc & 0xf))); 6371 hash[crc >> 4] |= (1 << (15 - (crc & 0xf)));
diff --git a/drivers/net/octeon/octeon_mgmt.c b/drivers/net/octeon/octeon_mgmt.c
index be368e5cbf75..ee894ed35f7f 100644
--- a/drivers/net/octeon/octeon_mgmt.c
+++ b/drivers/net/octeon/octeon_mgmt.c
@@ -474,7 +474,7 @@ static void octeon_mgmt_set_rx_filtering(struct net_device *netdev)
474 unsigned int cam_mode = 1; /* 1 - Accept on CAM match */ 474 unsigned int cam_mode = 1; /* 1 - Accept on CAM match */
475 unsigned int multicast_mode = 1; /* 1 - Reject all multicast. */ 475 unsigned int multicast_mode = 1; /* 1 - Reject all multicast. */
476 struct octeon_mgmt_cam_state cam_state; 476 struct octeon_mgmt_cam_state cam_state;
477 struct dev_addr_list *list; 477 struct netdev_hw_addr *ha;
478 struct list_head *pos; 478 struct list_head *pos;
479 int available_cam_entries; 479 int available_cam_entries;
480 480
@@ -510,8 +510,8 @@ static void octeon_mgmt_set_rx_filtering(struct net_device *netdev)
510 } 510 }
511 } 511 }
512 if (multicast_mode == 0) { 512 if (multicast_mode == 0) {
513 netdev_for_each_mc_addr(list, netdev) 513 netdev_for_each_mc_addr(ha, netdev)
514 octeon_mgmt_cam_state_add(&cam_state, list->da_addr); 514 octeon_mgmt_cam_state_add(&cam_state, ha->addr);
515 } 515 }
516 516
517 517
diff --git a/drivers/net/pci-skeleton.c b/drivers/net/pci-skeleton.c
index 36785853a149..dc3b4c7914fd 100644
--- a/drivers/net/pci-skeleton.c
+++ b/drivers/net/pci-skeleton.c
@@ -1813,12 +1813,12 @@ static void netdrv_set_rx_mode(struct net_device *dev)
1813 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; 1813 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
1814 mc_filter[1] = mc_filter[0] = 0xffffffff; 1814 mc_filter[1] = mc_filter[0] = 0xffffffff;
1815 } else { 1815 } else {
1816 struct dev_mc_list *mclist; 1816 struct netdev_hw_addr *ha;
1817 1817
1818 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; 1818 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
1819 mc_filter[1] = mc_filter[0] = 0; 1819 mc_filter[1] = mc_filter[0] = 0;
1820 netdev_for_each_mc_addr(mclist, dev) { 1820 netdev_for_each_mc_addr(ha, dev) {
1821 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; 1821 int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
1822 1822
1823 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); 1823 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
1824 } 1824 }
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 091e0b00043e..580977f56ad0 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -1,20 +1,20 @@
1/*====================================================================== 1/*======================================================================
2 2
3 A PCMCIA ethernet driver for the 3com 3c589 card. 3 A PCMCIA ethernet driver for the 3com 3c589 card.
4 4
5 Copyright (C) 1999 David A. Hinds -- dahinds@users.sourceforge.net 5 Copyright (C) 1999 David A. Hinds -- dahinds@users.sourceforge.net
6 6
7 3c589_cs.c 1.162 2001/10/13 00:08:50 7 3c589_cs.c 1.162 2001/10/13 00:08:50
8 8
9 The network driver code is based on Donald Becker's 3c589 code: 9 The network driver code is based on Donald Becker's 3c589 code:
10 10
11 Written 1994 by Donald Becker. 11 Written 1994 by Donald Becker.
12 Copyright 1993 United States Government as represented by the 12 Copyright 1993 United States Government as represented by the
13 Director, National Security Agency. This software may be used and 13 Director, National Security Agency. This software may be used and
14 distributed according to the terms of the GNU General Public License, 14 distributed according to the terms of the GNU General Public License,
15 incorporated herein by reference. 15 incorporated herein by reference.
16 Donald Becker may be reached at becker@scyld.com 16 Donald Becker may be reached at becker@scyld.com
17 17
18 Updated for 2.5.x by Alan Cox <alan@lxorguk.ukuu.org.uk> 18 Updated for 2.5.x by Alan Cox <alan@lxorguk.ukuu.org.uk>
19 19
20======================================================================*/ 20======================================================================*/
@@ -69,31 +69,54 @@
69/* The top five bits written to EL3_CMD are a command, the lower 69/* The top five bits written to EL3_CMD are a command, the lower
70 11 bits are the parameter, if applicable. */ 70 11 bits are the parameter, if applicable. */
71enum c509cmd { 71enum c509cmd {
72 TotalReset = 0<<11, SelectWindow = 1<<11, StartCoax = 2<<11, 72 TotalReset = 0<<11,
73 RxDisable = 3<<11, RxEnable = 4<<11, RxReset = 5<<11, RxDiscard = 8<<11, 73 SelectWindow = 1<<11,
74 TxEnable = 9<<11, TxDisable = 10<<11, TxReset = 11<<11, 74 StartCoax = 2<<11,
75 FakeIntr = 12<<11, AckIntr = 13<<11, SetIntrEnb = 14<<11, 75 RxDisable = 3<<11,
76 SetStatusEnb = 15<<11, SetRxFilter = 16<<11, SetRxThreshold = 17<<11, 76 RxEnable = 4<<11,
77 SetTxThreshold = 18<<11, SetTxStart = 19<<11, StatsEnable = 21<<11, 77 RxReset = 5<<11,
78 StatsDisable = 22<<11, StopCoax = 23<<11, 78 RxDiscard = 8<<11,
79 TxEnable = 9<<11,
80 TxDisable = 10<<11,
81 TxReset = 11<<11,
82 FakeIntr = 12<<11,
83 AckIntr = 13<<11,
84 SetIntrEnb = 14<<11,
85 SetStatusEnb = 15<<11,
86 SetRxFilter = 16<<11,
87 SetRxThreshold = 17<<11,
88 SetTxThreshold = 18<<11,
89 SetTxStart = 19<<11,
90 StatsEnable = 21<<11,
91 StatsDisable = 22<<11,
92 StopCoax = 23<<11
79}; 93};
80 94
81enum c509status { 95enum c509status {
82 IntLatch = 0x0001, AdapterFailure = 0x0002, TxComplete = 0x0004, 96 IntLatch = 0x0001,
83 TxAvailable = 0x0008, RxComplete = 0x0010, RxEarly = 0x0020, 97 AdapterFailure = 0x0002,
84 IntReq = 0x0040, StatsFull = 0x0080, CmdBusy = 0x1000 98 TxComplete = 0x0004,
99 TxAvailable = 0x0008,
100 RxComplete = 0x0010,
101 RxEarly = 0x0020,
102 IntReq = 0x0040,
103 StatsFull = 0x0080,
104 CmdBusy = 0x1000
85}; 105};
86 106
87/* The SetRxFilter command accepts the following classes: */ 107/* The SetRxFilter command accepts the following classes: */
88enum RxFilter { 108enum RxFilter {
89 RxStation = 1, RxMulticast = 2, RxBroadcast = 4, RxProm = 8 109 RxStation = 1,
110 RxMulticast = 2,
111 RxBroadcast = 4,
112 RxProm = 8
90}; 113};
91 114
92/* Register window 1 offsets, the window used in normal operation. */ 115/* Register window 1 offsets, the window used in normal operation. */
93#define TX_FIFO 0x00 116#define TX_FIFO 0x00
94#define RX_FIFO 0x00 117#define RX_FIFO 0x00
95#define RX_STATUS 0x08 118#define RX_STATUS 0x08
96#define TX_STATUS 0x0B 119#define TX_STATUS 0x0B
97#define TX_FREE 0x0C /* Remaining free bytes in Tx buffer. */ 120#define TX_FREE 0x0C /* Remaining free bytes in Tx buffer. */
98 121
99#define WN0_IRQ 0x08 /* Window 0: Set IRQ line in bits 12-15. */ 122#define WN0_IRQ 0x08 /* Window 0: Set IRQ line in bits 12-15. */
@@ -106,13 +129,13 @@ enum RxFilter {
106 129
107struct el3_private { 130struct el3_private {
108 struct pcmcia_device *p_dev; 131 struct pcmcia_device *p_dev;
109 dev_node_t node; 132 dev_node_t node;
110 /* For transceiver monitoring */ 133 /* For transceiver monitoring */
111 struct timer_list media; 134 struct timer_list media;
112 u16 media_status; 135 u16 media_status;
113 u16 fast_poll; 136 u16 fast_poll;
114 unsigned long last_irq; 137 unsigned long last_irq;
115 spinlock_t lock; 138 spinlock_t lock;
116}; 139};
117 140
118static const char *if_names[] = { "auto", "10baseT", "10base2", "AUI" }; 141static const char *if_names[] = { "auto", "10baseT", "10base2", "AUI" };
@@ -164,15 +187,15 @@ static void tc589_detach(struct pcmcia_device *p_dev);
164======================================================================*/ 187======================================================================*/
165 188
166static const struct net_device_ops el3_netdev_ops = { 189static const struct net_device_ops el3_netdev_ops = {
167 .ndo_open = el3_open, 190 .ndo_open = el3_open,
168 .ndo_stop = el3_close, 191 .ndo_stop = el3_close,
169 .ndo_start_xmit = el3_start_xmit, 192 .ndo_start_xmit = el3_start_xmit,
170 .ndo_tx_timeout = el3_tx_timeout, 193 .ndo_tx_timeout = el3_tx_timeout,
171 .ndo_set_config = el3_config, 194 .ndo_set_config = el3_config,
172 .ndo_get_stats = el3_get_stats, 195 .ndo_get_stats = el3_get_stats,
173 .ndo_set_multicast_list = set_multicast_list, 196 .ndo_set_multicast_list = set_multicast_list,
174 .ndo_change_mtu = eth_change_mtu, 197 .ndo_change_mtu = eth_change_mtu,
175 .ndo_set_mac_address = eth_mac_addr, 198 .ndo_set_mac_address = eth_mac_addr,
176 .ndo_validate_addr = eth_validate_addr, 199 .ndo_validate_addr = eth_validate_addr,
177}; 200};
178 201
@@ -236,7 +259,7 @@ static void tc589_detach(struct pcmcia_device *link)
236 tc589_config() is scheduled to run after a CARD_INSERTION event 259 tc589_config() is scheduled to run after a CARD_INSERTION event
237 is received, to configure the PCMCIA socket, and to make the 260 is received, to configure the PCMCIA socket, and to make the
238 ethernet device available to the system. 261 ethernet device available to the system.
239 262
240======================================================================*/ 263======================================================================*/
241 264
242static int tc589_config(struct pcmcia_device *link) 265static int tc589_config(struct pcmcia_device *link)
@@ -249,7 +272,7 @@ static int tc589_config(struct pcmcia_device *link)
249 char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; 272 char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
250 u8 *buf; 273 u8 *buf;
251 size_t len; 274 size_t len;
252 275
253 dev_dbg(&link->dev, "3c589_config\n"); 276 dev_dbg(&link->dev, "3c589_config\n");
254 277
255 phys_addr = (__be16 *)dev->dev_addr; 278 phys_addr = (__be16 *)dev->dev_addr;
@@ -278,7 +301,7 @@ static int tc589_config(struct pcmcia_device *link)
278 ret = pcmcia_request_configuration(link, &link->conf); 301 ret = pcmcia_request_configuration(link, &link->conf);
279 if (ret) 302 if (ret)
280 goto failed; 303 goto failed;
281 304
282 dev->irq = link->irq.AssignedIRQ; 305 dev->irq = link->irq.AssignedIRQ;
283 dev->base_addr = link->io.BasePort1; 306 dev->base_addr = link->io.BasePort1;
284 ioaddr = dev->base_addr; 307 ioaddr = dev->base_addr;
@@ -312,7 +335,7 @@ static int tc589_config(struct pcmcia_device *link)
312 dev->if_port = if_port; 335 dev->if_port = if_port;
313 else 336 else
314 printk(KERN_ERR "3c589_cs: invalid if_port requested\n"); 337 printk(KERN_ERR "3c589_cs: invalid if_port requested\n");
315 338
316 link->dev_node = &lp->node; 339 link->dev_node = &lp->node;
317 SET_NETDEV_DEV(dev, &link->dev); 340 SET_NETDEV_DEV(dev, &link->dev);
318 341
@@ -324,13 +347,12 @@ static int tc589_config(struct pcmcia_device *link)
324 347
325 strcpy(lp->node.dev_name, dev->name); 348 strcpy(lp->node.dev_name, dev->name);
326 349
327 printk(KERN_INFO "%s: 3Com 3c%s, io %#3lx, irq %d, " 350 netdev_info(dev, "3Com 3c%s, io %#3lx, irq %d, hw_addr %pM\n",
328 "hw_addr %pM\n", 351 (multi ? "562" : "589"), dev->base_addr, dev->irq,
329 dev->name, (multi ? "562" : "589"), dev->base_addr, dev->irq, 352 dev->dev_addr);
330 dev->dev_addr); 353 netdev_info(dev, " %dK FIFO split %s Rx:Tx, %s xcvr\n",
331 printk(KERN_INFO " %dK FIFO split %s Rx:Tx, %s xcvr\n", 354 (fifo & 7) ? 32 : 8, ram_split[(fifo >> 16) & 3],
332 (fifo & 7) ? 32 : 8, ram_split[(fifo >> 16) & 3], 355 if_names[dev->if_port]);
333 if_names[dev->if_port]);
334 return 0; 356 return 0;
335 357
336failed: 358failed:
@@ -343,7 +365,7 @@ failed:
343 After a card is removed, tc589_release() will unregister the net 365 After a card is removed, tc589_release() will unregister the net
344 device, and release the PCMCIA configuration. If the device is 366 device, and release the PCMCIA configuration. If the device is
345 still open, this will be postponed until it is closed. 367 still open, this will be postponed until it is closed.
346 368
347======================================================================*/ 369======================================================================*/
348 370
349static void tc589_release(struct pcmcia_device *link) 371static void tc589_release(struct pcmcia_device *link)
@@ -365,7 +387,7 @@ static int tc589_resume(struct pcmcia_device *link)
365{ 387{
366 struct net_device *dev = link->priv; 388 struct net_device *dev = link->priv;
367 389
368 if (link->open) { 390 if (link->open) {
369 tc589_reset(dev); 391 tc589_reset(dev);
370 netif_device_attach(dev); 392 netif_device_attach(dev);
371 } 393 }
@@ -385,8 +407,7 @@ static void tc589_wait_for_completion(struct net_device *dev, int cmd)
385 while (--i > 0) 407 while (--i > 0)
386 if (!(inw(dev->base_addr + EL3_STATUS) & 0x1000)) break; 408 if (!(inw(dev->base_addr + EL3_STATUS) & 0x1000)) break;
387 if (i == 0) 409 if (i == 0)
388 printk(KERN_WARNING "%s: command 0x%04x did not complete!\n", 410 netdev_warn(dev, "command 0x%04x did not complete!\n", cmd);
389 dev->name, cmd);
390} 411}
391 412
392/* 413/*
@@ -412,7 +433,7 @@ static void tc589_set_xcvr(struct net_device *dev, int if_port)
412{ 433{
413 struct el3_private *lp = netdev_priv(dev); 434 struct el3_private *lp = netdev_priv(dev);
414 unsigned int ioaddr = dev->base_addr; 435 unsigned int ioaddr = dev->base_addr;
415 436
416 EL3WINDOW(0); 437 EL3WINDOW(0);
417 switch (if_port) { 438 switch (if_port) {
418 case 0: case 1: outw(0, ioaddr + 6); break; 439 case 0: case 1: outw(0, ioaddr + 6); break;
@@ -435,14 +456,13 @@ static void dump_status(struct net_device *dev)
435{ 456{
436 unsigned int ioaddr = dev->base_addr; 457 unsigned int ioaddr = dev->base_addr;
437 EL3WINDOW(1); 458 EL3WINDOW(1);
438 printk(KERN_INFO " irq status %04x, rx status %04x, tx status " 459 netdev_info(dev, " irq status %04x, rx status %04x, tx status %02x tx free %04x\n",
439 "%02x tx free %04x\n", inw(ioaddr+EL3_STATUS), 460 inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS),
440 inw(ioaddr+RX_STATUS), inb(ioaddr+TX_STATUS), 461 inb(ioaddr+TX_STATUS), inw(ioaddr+TX_FREE));
441 inw(ioaddr+TX_FREE));
442 EL3WINDOW(4); 462 EL3WINDOW(4);
443 printk(KERN_INFO " diagnostics: fifo %04x net %04x ethernet %04x" 463 netdev_info(dev, " diagnostics: fifo %04x net %04x ethernet %04x media %04x\n",
444 " media %04x\n", inw(ioaddr+0x04), inw(ioaddr+0x06), 464 inw(ioaddr+0x04), inw(ioaddr+0x06), inw(ioaddr+0x08),
445 inw(ioaddr+0x08), inw(ioaddr+0x0a)); 465 inw(ioaddr+0x0a));
446 EL3WINDOW(1); 466 EL3WINDOW(1);
447} 467}
448 468
@@ -451,18 +471,18 @@ static void tc589_reset(struct net_device *dev)
451{ 471{
452 unsigned int ioaddr = dev->base_addr; 472 unsigned int ioaddr = dev->base_addr;
453 int i; 473 int i;
454 474
455 EL3WINDOW(0); 475 EL3WINDOW(0);
456 outw(0x0001, ioaddr + 4); /* Activate board. */ 476 outw(0x0001, ioaddr + 4); /* Activate board. */
457 outw(0x3f00, ioaddr + 8); /* Set the IRQ line. */ 477 outw(0x3f00, ioaddr + 8); /* Set the IRQ line. */
458 478
459 /* Set the station address in window 2. */ 479 /* Set the station address in window 2. */
460 EL3WINDOW(2); 480 EL3WINDOW(2);
461 for (i = 0; i < 6; i++) 481 for (i = 0; i < 6; i++)
462 outb(dev->dev_addr[i], ioaddr + i); 482 outb(dev->dev_addr[i], ioaddr + i);
463 483
464 tc589_set_xcvr(dev, dev->if_port); 484 tc589_set_xcvr(dev, dev->if_port);
465 485
466 /* Switch to the stats window, and clear all stats by reading. */ 486 /* Switch to the stats window, and clear all stats by reading. */
467 outw(StatsDisable, ioaddr + EL3_CMD); 487 outw(StatsDisable, ioaddr + EL3_CMD);
468 EL3WINDOW(6); 488 EL3WINDOW(6);
@@ -470,7 +490,7 @@ static void tc589_reset(struct net_device *dev)
470 inb(ioaddr+i); 490 inb(ioaddr+i);
471 inw(ioaddr + 10); 491 inw(ioaddr + 10);
472 inw(ioaddr + 12); 492 inw(ioaddr + 12);
473 493
474 /* Switch to register set 1 for normal use. */ 494 /* Switch to register set 1 for normal use. */
475 EL3WINDOW(1); 495 EL3WINDOW(1);
476 496
@@ -504,8 +524,7 @@ static int el3_config(struct net_device *dev, struct ifmap *map)
504 if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) { 524 if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) {
505 if (map->port <= 3) { 525 if (map->port <= 3) {
506 dev->if_port = map->port; 526 dev->if_port = map->port;
507 printk(KERN_INFO "%s: switched to %s port\n", 527 netdev_info(dev, "switched to %s port\n", if_names[dev->if_port]);
508 dev->name, if_names[dev->if_port]);
509 tc589_set_xcvr(dev, dev->if_port); 528 tc589_set_xcvr(dev, dev->if_port);
510 } else 529 } else
511 return -EINVAL; 530 return -EINVAL;
@@ -517,13 +536,13 @@ static int el3_open(struct net_device *dev)
517{ 536{
518 struct el3_private *lp = netdev_priv(dev); 537 struct el3_private *lp = netdev_priv(dev);
519 struct pcmcia_device *link = lp->p_dev; 538 struct pcmcia_device *link = lp->p_dev;
520 539
521 if (!pcmcia_dev_present(link)) 540 if (!pcmcia_dev_present(link))
522 return -ENODEV; 541 return -ENODEV;
523 542
524 link->open++; 543 link->open++;
525 netif_start_queue(dev); 544 netif_start_queue(dev);
526 545
527 tc589_reset(dev); 546 tc589_reset(dev);
528 init_timer(&lp->media); 547 init_timer(&lp->media);
529 lp->media.function = &media_check; 548 lp->media.function = &media_check;
@@ -533,15 +552,15 @@ static int el3_open(struct net_device *dev)
533 552
534 dev_dbg(&link->dev, "%s: opened, status %4.4x.\n", 553 dev_dbg(&link->dev, "%s: opened, status %4.4x.\n",
535 dev->name, inw(dev->base_addr + EL3_STATUS)); 554 dev->name, inw(dev->base_addr + EL3_STATUS));
536 555
537 return 0; 556 return 0;
538} 557}
539 558
540static void el3_tx_timeout(struct net_device *dev) 559static void el3_tx_timeout(struct net_device *dev)
541{ 560{
542 unsigned int ioaddr = dev->base_addr; 561 unsigned int ioaddr = dev->base_addr;
543 562
544 printk(KERN_WARNING "%s: Transmit timed out!\n", dev->name); 563 netdev_warn(dev, "Transmit timed out!\n");
545 dump_status(dev); 564 dump_status(dev);
546 dev->stats.tx_errors++; 565 dev->stats.tx_errors++;
547 dev->trans_start = jiffies; 566 dev->trans_start = jiffies;
@@ -555,19 +574,18 @@ static void pop_tx_status(struct net_device *dev)
555{ 574{
556 unsigned int ioaddr = dev->base_addr; 575 unsigned int ioaddr = dev->base_addr;
557 int i; 576 int i;
558 577
559 /* Clear the Tx status stack. */ 578 /* Clear the Tx status stack. */
560 for (i = 32; i > 0; i--) { 579 for (i = 32; i > 0; i--) {
561 u_char tx_status = inb(ioaddr + TX_STATUS); 580 u_char tx_status = inb(ioaddr + TX_STATUS);
562 if (!(tx_status & 0x84)) break; 581 if (!(tx_status & 0x84)) break;
563 /* reset transmitter on jabber error or underrun */ 582 /* reset transmitter on jabber error or underrun */
564 if (tx_status & 0x30) 583 if (tx_status & 0x30)
565 tc589_wait_for_completion(dev, TxReset); 584 tc589_wait_for_completion(dev, TxReset);
566 if (tx_status & 0x38) { 585 if (tx_status & 0x38) {
567 pr_debug("%s: transmit error: status 0x%02x\n", 586 netdev_dbg(dev, "transmit error: status 0x%02x\n", tx_status);
568 dev->name, tx_status); 587 outw(TxEnable, ioaddr + EL3_CMD);
569 outw(TxEnable, ioaddr + EL3_CMD); 588 dev->stats.tx_aborted_errors++;
570 dev->stats.tx_aborted_errors++;
571 } 589 }
572 outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ 590 outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */
573 } 591 }
@@ -580,11 +598,10 @@ static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
580 struct el3_private *priv = netdev_priv(dev); 598 struct el3_private *priv = netdev_priv(dev);
581 unsigned long flags; 599 unsigned long flags;
582 600
583 pr_debug("%s: el3_start_xmit(length = %ld) called, " 601 netdev_dbg(dev, "el3_start_xmit(length = %ld) called, status %4.4x.\n",
584 "status %4.4x.\n", dev->name, (long)skb->len, 602 (long)skb->len, inw(ioaddr + EL3_STATUS));
585 inw(ioaddr + EL3_STATUS));
586 603
587 spin_lock_irqsave(&priv->lock, flags); 604 spin_lock_irqsave(&priv->lock, flags);
588 605
589 dev->stats.tx_bytes += skb->len; 606 dev->stats.tx_bytes += skb->len;
590 607
@@ -602,9 +619,9 @@ static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
602 } 619 }
603 620
604 pop_tx_status(dev); 621 pop_tx_status(dev);
605 spin_unlock_irqrestore(&priv->lock, flags); 622 spin_unlock_irqrestore(&priv->lock, flags);
606 dev_kfree_skb(skb); 623 dev_kfree_skb(skb);
607 624
608 return NETDEV_TX_OK; 625 return NETDEV_TX_OK;
609} 626}
610 627
@@ -616,37 +633,32 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
616 unsigned int ioaddr; 633 unsigned int ioaddr;
617 __u16 status; 634 __u16 status;
618 int i = 0, handled = 1; 635 int i = 0, handled = 1;
619 636
620 if (!netif_device_present(dev)) 637 if (!netif_device_present(dev))
621 return IRQ_NONE; 638 return IRQ_NONE;
622 639
623 ioaddr = dev->base_addr; 640 ioaddr = dev->base_addr;
624 641
625 pr_debug("%s: interrupt, status %4.4x.\n", 642 netdev_dbg(dev, "interrupt, status %4.4x.\n", inw(ioaddr + EL3_STATUS));
626 dev->name, inw(ioaddr + EL3_STATUS));
627 643
628 spin_lock(&lp->lock); 644 spin_lock(&lp->lock);
629 while ((status = inw(ioaddr + EL3_STATUS)) & 645 while ((status = inw(ioaddr + EL3_STATUS)) &
630 (IntLatch | RxComplete | StatsFull)) { 646 (IntLatch | RxComplete | StatsFull)) {
631 if ((status & 0xe000) != 0x2000) { 647 if ((status & 0xe000) != 0x2000) {
632 pr_debug("%s: interrupt from dead card\n", dev->name); 648 netdev_dbg(dev, "interrupt from dead card\n");
633 handled = 0; 649 handled = 0;
634 break; 650 break;
635 } 651 }
636
637 if (status & RxComplete) 652 if (status & RxComplete)
638 el3_rx(dev); 653 el3_rx(dev);
639
640 if (status & TxAvailable) { 654 if (status & TxAvailable) {
641 pr_debug(" TX room bit was handled.\n"); 655 netdev_dbg(dev, " TX room bit was handled.\n");
642 /* There's room in the FIFO for a full-sized packet. */ 656 /* There's room in the FIFO for a full-sized packet. */
643 outw(AckIntr | TxAvailable, ioaddr + EL3_CMD); 657 outw(AckIntr | TxAvailable, ioaddr + EL3_CMD);
644 netif_wake_queue(dev); 658 netif_wake_queue(dev);
645 } 659 }
646
647 if (status & TxComplete) 660 if (status & TxComplete)
648 pop_tx_status(dev); 661 pop_tx_status(dev);
649
650 if (status & (AdapterFailure | RxEarly | StatsFull)) { 662 if (status & (AdapterFailure | RxEarly | StatsFull)) {
651 /* Handle all uncommon interrupts. */ 663 /* Handle all uncommon interrupts. */
652 if (status & StatsFull) /* Empty statistics. */ 664 if (status & StatsFull) /* Empty statistics. */
@@ -660,8 +672,8 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
660 EL3WINDOW(4); 672 EL3WINDOW(4);
661 fifo_diag = inw(ioaddr + 4); 673 fifo_diag = inw(ioaddr + 4);
662 EL3WINDOW(1); 674 EL3WINDOW(1);
663 printk(KERN_WARNING "%s: adapter failure, FIFO diagnostic" 675 netdev_warn(dev, "adapter failure, FIFO diagnostic register %04x.\n",
664 " register %04x.\n", dev->name, fifo_diag); 676 fifo_diag);
665 if (fifo_diag & 0x0400) { 677 if (fifo_diag & 0x0400) {
666 /* Tx overrun */ 678 /* Tx overrun */
667 tc589_wait_for_completion(dev, TxReset); 679 tc589_wait_for_completion(dev, TxReset);
@@ -676,22 +688,20 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
676 outw(AckIntr | AdapterFailure, ioaddr + EL3_CMD); 688 outw(AckIntr | AdapterFailure, ioaddr + EL3_CMD);
677 } 689 }
678 } 690 }
679
680 if (++i > 10) { 691 if (++i > 10) {
681 printk(KERN_ERR "%s: infinite loop in interrupt, " 692 netdev_err(dev, "infinite loop in interrupt, status %4.4x.\n",
682 "status %4.4x.\n", dev->name, status); 693 status);
683 /* Clear all interrupts */ 694 /* Clear all interrupts */
684 outw(AckIntr | 0xFF, ioaddr + EL3_CMD); 695 outw(AckIntr | 0xFF, ioaddr + EL3_CMD);
685 break; 696 break;
686 } 697 }
687 /* Acknowledge the IRQ. */ 698 /* Acknowledge the IRQ. */
688 outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD); 699 outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD);
689 } 700 }
690
691 lp->last_irq = jiffies; 701 lp->last_irq = jiffies;
692 spin_unlock(&lp->lock); 702 spin_unlock(&lp->lock);
693 pr_debug("%s: exiting interrupt, status %4.4x.\n", 703 netdev_dbg(dev, "exiting interrupt, status %4.4x.\n",
694 dev->name, inw(ioaddr + EL3_STATUS)); 704 inw(ioaddr + EL3_STATUS));
695 return IRQ_RETVAL(handled); 705 return IRQ_RETVAL(handled);
696} 706}
697 707
@@ -710,7 +720,7 @@ static void media_check(unsigned long arg)
710 if ((inw(ioaddr + EL3_STATUS) & IntLatch) && 720 if ((inw(ioaddr + EL3_STATUS) & IntLatch) &&
711 (inb(ioaddr + EL3_TIMER) == 0xff)) { 721 (inb(ioaddr + EL3_TIMER) == 0xff)) {
712 if (!lp->fast_poll) 722 if (!lp->fast_poll)
713 printk(KERN_WARNING "%s: interrupt(s) dropped!\n", dev->name); 723 netdev_warn(dev, "interrupt(s) dropped!\n");
714 724
715 local_irq_save(flags); 725 local_irq_save(flags);
716 el3_interrupt(dev->irq, dev); 726 el3_interrupt(dev->irq, dev);
@@ -727,7 +737,7 @@ static void media_check(unsigned long arg)
727 737
728 /* lp->lock guards the EL3 window. Window should always be 1 except 738 /* lp->lock guards the EL3 window. Window should always be 1 except
729 when the lock is held */ 739 when the lock is held */
730 spin_lock_irqsave(&lp->lock, flags); 740 spin_lock_irqsave(&lp->lock, flags);
731 EL3WINDOW(4); 741 EL3WINDOW(4);
732 media = inw(ioaddr+WN4_MEDIA) & 0xc810; 742 media = inw(ioaddr+WN4_MEDIA) & 0xc810;
733 743
@@ -747,32 +757,30 @@ static void media_check(unsigned long arg)
747 if (media != lp->media_status) { 757 if (media != lp->media_status) {
748 if ((media & lp->media_status & 0x8000) && 758 if ((media & lp->media_status & 0x8000) &&
749 ((lp->media_status ^ media) & 0x0800)) 759 ((lp->media_status ^ media) & 0x0800))
750 printk(KERN_INFO "%s: %s link beat\n", dev->name, 760 netdev_info(dev, "%s link beat\n",
751 (lp->media_status & 0x0800 ? "lost" : "found")); 761 (lp->media_status & 0x0800 ? "lost" : "found"));
752 else if ((media & lp->media_status & 0x4000) && 762 else if ((media & lp->media_status & 0x4000) &&
753 ((lp->media_status ^ media) & 0x0010)) 763 ((lp->media_status ^ media) & 0x0010))
754 printk(KERN_INFO "%s: coax cable %s\n", dev->name, 764 netdev_info(dev, "coax cable %s\n",
755 (lp->media_status & 0x0010 ? "ok" : "problem")); 765 (lp->media_status & 0x0010 ? "ok" : "problem"));
756 if (dev->if_port == 0) { 766 if (dev->if_port == 0) {
757 if (media & 0x8000) { 767 if (media & 0x8000) {
758 if (media & 0x0800) 768 if (media & 0x0800)
759 printk(KERN_INFO "%s: flipped to 10baseT\n", 769 netdev_info(dev, "flipped to 10baseT\n");
760 dev->name);
761 else 770 else
762 tc589_set_xcvr(dev, 2); 771 tc589_set_xcvr(dev, 2);
763 } else if (media & 0x4000) { 772 } else if (media & 0x4000) {
764 if (media & 0x0010) 773 if (media & 0x0010)
765 tc589_set_xcvr(dev, 1); 774 tc589_set_xcvr(dev, 1);
766 else 775 else
767 printk(KERN_INFO "%s: flipped to 10base2\n", 776 netdev_info(dev, "flipped to 10base2\n");
768 dev->name);
769 } 777 }
770 } 778 }
771 lp->media_status = media; 779 lp->media_status = media;
772 } 780 }
773 781
774 EL3WINDOW(1); 782 EL3WINDOW(1);
775 spin_unlock_irqrestore(&lp->lock, flags); 783 spin_unlock_irqrestore(&lp->lock, flags);
776 784
777reschedule: 785reschedule:
778 lp->media.expires = jiffies + HZ; 786 lp->media.expires = jiffies + HZ;
@@ -786,7 +794,7 @@ static struct net_device_stats *el3_get_stats(struct net_device *dev)
786 struct pcmcia_device *link = lp->p_dev; 794 struct pcmcia_device *link = lp->p_dev;
787 795
788 if (pcmcia_dev_present(link)) { 796 if (pcmcia_dev_present(link)) {
789 spin_lock_irqsave(&lp->lock, flags); 797 spin_lock_irqsave(&lp->lock, flags);
790 update_stats(dev); 798 update_stats(dev);
791 spin_unlock_irqrestore(&lp->lock, flags); 799 spin_unlock_irqrestore(&lp->lock, flags);
792 } 800 }
@@ -798,21 +806,21 @@ static struct net_device_stats *el3_get_stats(struct net_device *dev)
798 single-threaded if the device is active. This is expected to be a rare 806 single-threaded if the device is active. This is expected to be a rare
799 operation, and it's simpler for the rest of the driver to assume that 807 operation, and it's simpler for the rest of the driver to assume that
800 window 1 is always valid rather than use a special window-state variable. 808 window 1 is always valid rather than use a special window-state variable.
801 809
802 Caller must hold the lock for this 810 Caller must hold the lock for this
803*/ 811*/
804static void update_stats(struct net_device *dev) 812static void update_stats(struct net_device *dev)
805{ 813{
806 unsigned int ioaddr = dev->base_addr; 814 unsigned int ioaddr = dev->base_addr;
807 815
808 pr_debug("%s: updating the statistics.\n", dev->name); 816 netdev_dbg(dev, "updating the statistics.\n");
809 /* Turn off statistics updates while reading. */ 817 /* Turn off statistics updates while reading. */
810 outw(StatsDisable, ioaddr + EL3_CMD); 818 outw(StatsDisable, ioaddr + EL3_CMD);
811 /* Switch to the stats window, and read everything. */ 819 /* Switch to the stats window, and read everything. */
812 EL3WINDOW(6); 820 EL3WINDOW(6);
813 dev->stats.tx_carrier_errors += inb(ioaddr + 0); 821 dev->stats.tx_carrier_errors += inb(ioaddr + 0);
814 dev->stats.tx_heartbeat_errors += inb(ioaddr + 1); 822 dev->stats.tx_heartbeat_errors += inb(ioaddr + 1);
815 /* Multiple collisions. */ inb(ioaddr + 2); 823 /* Multiple collisions. */ inb(ioaddr + 2);
816 dev->stats.collisions += inb(ioaddr + 3); 824 dev->stats.collisions += inb(ioaddr + 3);
817 dev->stats.tx_window_errors += inb(ioaddr + 4); 825 dev->stats.tx_window_errors += inb(ioaddr + 4);
818 dev->stats.rx_fifo_errors += inb(ioaddr + 5); 826 dev->stats.rx_fifo_errors += inb(ioaddr + 5);
@@ -821,7 +829,7 @@ static void update_stats(struct net_device *dev)
821 /* Tx deferrals */ inb(ioaddr + 8); 829 /* Tx deferrals */ inb(ioaddr + 8);
822 /* Rx octets */ inw(ioaddr + 10); 830 /* Rx octets */ inw(ioaddr + 10);
823 /* Tx octets */ inw(ioaddr + 12); 831 /* Tx octets */ inw(ioaddr + 12);
824 832
825 /* Back to window 1, and turn statistics back on. */ 833 /* Back to window 1, and turn statistics back on. */
826 EL3WINDOW(1); 834 EL3WINDOW(1);
827 outw(StatsEnable, ioaddr + EL3_CMD); 835 outw(StatsEnable, ioaddr + EL3_CMD);
@@ -832,9 +840,9 @@ static int el3_rx(struct net_device *dev)
832 unsigned int ioaddr = dev->base_addr; 840 unsigned int ioaddr = dev->base_addr;
833 int worklimit = 32; 841 int worklimit = 32;
834 short rx_status; 842 short rx_status;
835 843
836 pr_debug("%s: in rx_packet(), status %4.4x, rx_status %4.4x.\n", 844 netdev_dbg(dev, "in rx_packet(), status %4.4x, rx_status %4.4x.\n",
837 dev->name, inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS)); 845 inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS));
838 while (!((rx_status = inw(ioaddr + RX_STATUS)) & 0x8000) && 846 while (!((rx_status = inw(ioaddr + RX_STATUS)) & 0x8000) &&
839 worklimit > 0) { 847 worklimit > 0) {
840 worklimit--; 848 worklimit--;
@@ -852,11 +860,11 @@ static int el3_rx(struct net_device *dev)
852 } else { 860 } else {
853 short pkt_len = rx_status & 0x7ff; 861 short pkt_len = rx_status & 0x7ff;
854 struct sk_buff *skb; 862 struct sk_buff *skb;
855 863
856 skb = dev_alloc_skb(pkt_len+5); 864 skb = dev_alloc_skb(pkt_len+5);
857 865
858 pr_debug(" Receiving packet size %d status %4.4x.\n", 866 netdev_dbg(dev, " Receiving packet size %d status %4.4x.\n",
859 pkt_len, rx_status); 867 pkt_len, rx_status);
860 if (skb != NULL) { 868 if (skb != NULL) {
861 skb_reserve(skb, 2); 869 skb_reserve(skb, 2);
862 insl(ioaddr+RX_FIFO, skb_put(skb, pkt_len), 870 insl(ioaddr+RX_FIFO, skb_put(skb, pkt_len),
@@ -866,8 +874,8 @@ static int el3_rx(struct net_device *dev)
866 dev->stats.rx_packets++; 874 dev->stats.rx_packets++;
867 dev->stats.rx_bytes += pkt_len; 875 dev->stats.rx_bytes += pkt_len;
868 } else { 876 } else {
869 pr_debug("%s: couldn't allocate a sk_buff of" 877 netdev_dbg(dev, "couldn't allocate a sk_buff of size %d.\n",
870 " size %d.\n", dev->name, pkt_len); 878 pkt_len);
871 dev->stats.rx_dropped++; 879 dev->stats.rx_dropped++;
872 } 880 }
873 } 881 }
@@ -875,7 +883,7 @@ static int el3_rx(struct net_device *dev)
875 tc589_wait_for_completion(dev, RxDiscard); 883 tc589_wait_for_completion(dev, RxDiscard);
876 } 884 }
877 if (worklimit == 0) 885 if (worklimit == 0)
878 printk(KERN_WARNING "%s: too much work in el3_rx!\n", dev->name); 886 netdev_warn(dev, "too much work in el3_rx!\n");
879 return 0; 887 return 0;
880} 888}
881 889
@@ -906,17 +914,17 @@ static int el3_close(struct net_device *dev)
906 struct el3_private *lp = netdev_priv(dev); 914 struct el3_private *lp = netdev_priv(dev);
907 struct pcmcia_device *link = lp->p_dev; 915 struct pcmcia_device *link = lp->p_dev;
908 unsigned int ioaddr = dev->base_addr; 916 unsigned int ioaddr = dev->base_addr;
909 917
910 dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name); 918 dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name);
911 919
912 if (pcmcia_dev_present(link)) { 920 if (pcmcia_dev_present(link)) {
913 /* Turn off statistics ASAP. We update dev->stats below. */ 921 /* Turn off statistics ASAP. We update dev->stats below. */
914 outw(StatsDisable, ioaddr + EL3_CMD); 922 outw(StatsDisable, ioaddr + EL3_CMD);
915 923
916 /* Disable the receiver and transmitter. */ 924 /* Disable the receiver and transmitter. */
917 outw(RxDisable, ioaddr + EL3_CMD); 925 outw(RxDisable, ioaddr + EL3_CMD);
918 outw(TxDisable, ioaddr + EL3_CMD); 926 outw(TxDisable, ioaddr + EL3_CMD);
919 927
920 if (dev->if_port == 2) 928 if (dev->if_port == 2)
921 /* Turn off thinnet power. Green! */ 929 /* Turn off thinnet power. Green! */
922 outw(StopCoax, ioaddr + EL3_CMD); 930 outw(StopCoax, ioaddr + EL3_CMD);
@@ -925,12 +933,12 @@ static int el3_close(struct net_device *dev)
925 EL3WINDOW(4); 933 EL3WINDOW(4);
926 outw(0, ioaddr + WN4_MEDIA); 934 outw(0, ioaddr + WN4_MEDIA);
927 } 935 }
928 936
929 /* Switching back to window 0 disables the IRQ. */ 937 /* Switching back to window 0 disables the IRQ. */
930 EL3WINDOW(0); 938 EL3WINDOW(0);
931 /* But we explicitly zero the IRQ line select anyway. */ 939 /* But we explicitly zero the IRQ line select anyway. */
932 outw(0x0f00, ioaddr + WN0_IRQ); 940 outw(0x0f00, ioaddr + WN0_IRQ);
933 941
934 /* Check if the card still exists */ 942 /* Check if the card still exists */
935 if ((inw(ioaddr+EL3_STATUS) & 0xe000) == 0x2000) 943 if ((inw(ioaddr+EL3_STATUS) & 0xe000) == 0x2000)
936 update_stats(dev); 944 update_stats(dev);
@@ -939,7 +947,7 @@ static int el3_close(struct net_device *dev)
939 link->open--; 947 link->open--;
940 netif_stop_queue(dev); 948 netif_stop_queue(dev);
941 del_timer_sync(&lp->media); 949 del_timer_sync(&lp->media);
942 950
943 return 0; 951 return 0;
944} 952}
945 953
@@ -961,7 +969,7 @@ static struct pcmcia_driver tc589_driver = {
961 }, 969 },
962 .probe = tc589_probe, 970 .probe = tc589_probe,
963 .remove = tc589_detach, 971 .remove = tc589_detach,
964 .id_table = tc589_ids, 972 .id_table = tc589_ids,
965 .suspend = tc589_suspend, 973 .suspend = tc589_suspend,
966 .resume = tc589_resume, 974 .resume = tc589_resume,
967}; 975};
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 09291e60d309..333cb3344d54 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -1623,11 +1623,11 @@ static struct net_device_stats *get_stats(struct net_device *dev)
1623 1623
1624static inline void make_mc_bits(u8 *bits, struct net_device *dev) 1624static inline void make_mc_bits(u8 *bits, struct net_device *dev)
1625{ 1625{
1626 struct dev_mc_list *dmi; 1626 struct netdev_hw_addr *ha;
1627 u32 crc; 1627 u32 crc;
1628 1628
1629 netdev_for_each_mc_addr(dmi, dev) { 1629 netdev_for_each_mc_addr(ha, dev) {
1630 crc = ether_crc(ETH_ALEN, dmi->dmi_addr); 1630 crc = ether_crc(ETH_ALEN, ha->addr);
1631 /* 1631 /*
1632 * The 8390 uses the 6 most significant bits of the 1632 * The 8390 uses the 6 most significant bits of the
1633 * CRC to index the multicast table. 1633 * CRC to index the multicast table.
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index b9dc80b9d04a..6734f7d6da98 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -1196,11 +1196,11 @@ static void set_rx_mode(struct net_device *dev)
1196 memset(mc_filter, 0x00, sizeof(mc_filter)); 1196 memset(mc_filter, 0x00, sizeof(mc_filter));
1197 outb(1, ioaddr + RX_MODE); /* Ignore almost all multicasts. */ 1197 outb(1, ioaddr + RX_MODE); /* Ignore almost all multicasts. */
1198 } else { 1198 } else {
1199 struct dev_mc_list *mclist; 1199 struct netdev_hw_addr *ha;
1200 1200
1201 memset(mc_filter, 0, sizeof(mc_filter)); 1201 memset(mc_filter, 0, sizeof(mc_filter));
1202 netdev_for_each_mc_addr(mclist, dev) { 1202 netdev_for_each_mc_addr(ha, dev) {
1203 unsigned int bit = ether_crc_le(ETH_ALEN, mclist->dmi_addr) >> 26; 1203 unsigned int bit = ether_crc_le(ETH_ALEN, ha->addr) >> 26;
1204 mc_filter[bit >> 3] |= (1 << (bit & 7)); 1204 mc_filter[bit >> 3] |= (1 << (bit & 7));
1205 } 1205 }
1206 outb(2, ioaddr + RX_MODE); /* Use normal mode. */ 1206 outb(2, ioaddr + RX_MODE); /* Use normal mode. */
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index c717b143f11a..c516c1996354 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -1475,7 +1475,7 @@ static void set_multicast_list(struct net_device *dev)
1475{ 1475{
1476 mace_private *lp = netdev_priv(dev); 1476 mace_private *lp = netdev_priv(dev);
1477 int adr[ETHER_ADDR_LEN] = {0}; /* Ethernet address */ 1477 int adr[ETHER_ADDR_LEN] = {0}; /* Ethernet address */
1478 struct dev_mc_list *dmi; 1478 struct netdev_hw_addr *ha;
1479 1479
1480#ifdef PCMCIA_DEBUG 1480#ifdef PCMCIA_DEBUG
1481 { 1481 {
@@ -1495,8 +1495,8 @@ static void set_multicast_list(struct net_device *dev)
1495 if (num_addrs > 0) { 1495 if (num_addrs > 0) {
1496 /* Calculate multicast logical address filter */ 1496 /* Calculate multicast logical address filter */
1497 memset(lp->multicast_ladrf, 0, MACE_LADRF_LEN); 1497 memset(lp->multicast_ladrf, 0, MACE_LADRF_LEN);
1498 netdev_for_each_mc_addr(dmi, dev) { 1498 netdev_for_each_mc_addr(ha, dev) {
1499 memcpy(adr, dmi->dmi_addr, ETHER_ADDR_LEN); 1499 memcpy(adr, ha->addr, ETHER_ADDR_LEN);
1500 BuildLAF(lp->multicast_ladrf, adr); 1500 BuildLAF(lp->multicast_ladrf, adr);
1501 } 1501 }
1502 } 1502 }
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index ff7eb9116b6a..ad2267646187 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -1618,12 +1618,12 @@ static void set_rx_mode(struct net_device *dev)
1618 rx_cfg_setting = RxStripCRC | RxEnable | RxAllMulti; 1618 rx_cfg_setting = RxStripCRC | RxEnable | RxAllMulti;
1619 else { 1619 else {
1620 if (!netdev_mc_empty(dev)) { 1620 if (!netdev_mc_empty(dev)) {
1621 struct dev_mc_list *mc_addr; 1621 struct netdev_hw_addr *ha;
1622 1622
1623 netdev_for_each_mc_addr(mc_addr, dev) { 1623 netdev_for_each_mc_addr(ha, dev) {
1624 u_int position = ether_crc(6, mc_addr->dmi_addr); 1624 u_int position = ether_crc(6, ha->addr);
1625#ifndef final_version /* Verify multicast address. */ 1625#ifndef final_version /* Verify multicast address. */
1626 if ((mc_addr->dmi_addr[0] & 1) == 0) 1626 if ((ha->addr[0] & 1) == 0)
1627 continue; 1627 continue;
1628#endif 1628#endif
1629 multicast_table[position >> 29] |= 1 << ((position >> 26) & 7); 1629 multicast_table[position >> 29] |= 1 << ((position >> 26) & 7);
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index 4d1802e457be..656be931207a 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -1398,7 +1398,7 @@ static void set_addresses(struct net_device *dev)
1398{ 1398{
1399 unsigned int ioaddr = dev->base_addr; 1399 unsigned int ioaddr = dev->base_addr;
1400 local_info_t *lp = netdev_priv(dev); 1400 local_info_t *lp = netdev_priv(dev);
1401 struct dev_mc_list *dmi; 1401 struct netdev_hw_addr *ha;
1402 struct set_address_info sa_info; 1402 struct set_address_info sa_info;
1403 int i; 1403 int i;
1404 1404
@@ -1413,10 +1413,10 @@ static void set_addresses(struct net_device *dev)
1413 1413
1414 set_address(&sa_info, dev->dev_addr); 1414 set_address(&sa_info, dev->dev_addr);
1415 i = 0; 1415 i = 0;
1416 netdev_for_each_mc_addr(dmi, dev) { 1416 netdev_for_each_mc_addr(ha, dev) {
1417 if (i++ == 9) 1417 if (i++ == 9)
1418 break; 1418 break;
1419 set_address(&sa_info, dmi->dmi_addr); 1419 set_address(&sa_info, ha->addr);
1420 } 1420 }
1421 while (i++ < 9) 1421 while (i++ < 9)
1422 set_address(&sa_info, dev->dev_addr); 1422 set_address(&sa_info, dev->dev_addr);
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 084d78dd1637..a2254f749a9a 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -2590,7 +2590,7 @@ static void pcnet32_load_multicast(struct net_device *dev)
2590 struct pcnet32_private *lp = netdev_priv(dev); 2590 struct pcnet32_private *lp = netdev_priv(dev);
2591 volatile struct pcnet32_init_block *ib = lp->init_block; 2591 volatile struct pcnet32_init_block *ib = lp->init_block;
2592 volatile __le16 *mcast_table = (__le16 *)ib->filter; 2592 volatile __le16 *mcast_table = (__le16 *)ib->filter;
2593 struct dev_mc_list *dmi; 2593 struct netdev_hw_addr *ha;
2594 unsigned long ioaddr = dev->base_addr; 2594 unsigned long ioaddr = dev->base_addr;
2595 char *addrs; 2595 char *addrs;
2596 int i; 2596 int i;
@@ -2611,8 +2611,8 @@ static void pcnet32_load_multicast(struct net_device *dev)
2611 ib->filter[1] = 0; 2611 ib->filter[1] = 0;
2612 2612
2613 /* Add addresses */ 2613 /* Add addresses */
2614 netdev_for_each_mc_addr(dmi, dev) { 2614 netdev_for_each_mc_addr(ha, dev) {
2615 addrs = dmi->dmi_addr; 2615 addrs = ha->addr;
2616 2616
2617 /* multicast address? */ 2617 /* multicast address? */
2618 if (!(*addrs & 1)) 2618 if (!(*addrs & 1))
diff --git a/drivers/net/phy/bcm63xx.c b/drivers/net/phy/bcm63xx.c
index 4fed95e8350e..ac5e49861dbd 100644
--- a/drivers/net/phy/bcm63xx.c
+++ b/drivers/net/phy/bcm63xx.c
@@ -130,3 +130,11 @@ static void __exit bcm63xx_phy_exit(void)
130 130
131module_init(bcm63xx_phy_init); 131module_init(bcm63xx_phy_init);
132module_exit(bcm63xx_phy_exit); 132module_exit(bcm63xx_phy_exit);
133
134static struct mdio_device_id bcm63xx_tbl[] = {
135 { 0x00406000, 0xfffffc00 },
136 { 0x002bdc00, 0xfffffc00 },
137 { }
138};
139
140MODULE_DEVICE_TABLE(mdio, bcm64xx_tbl);
diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
index f482fc4f8cf1..cecdbbd549ec 100644
--- a/drivers/net/phy/broadcom.c
+++ b/drivers/net/phy/broadcom.c
@@ -908,3 +908,19 @@ static void __exit broadcom_exit(void)
908 908
909module_init(broadcom_init); 909module_init(broadcom_init);
910module_exit(broadcom_exit); 910module_exit(broadcom_exit);
911
912static struct mdio_device_id broadcom_tbl[] = {
913 { 0x00206070, 0xfffffff0 },
914 { 0x002060e0, 0xfffffff0 },
915 { 0x002060c0, 0xfffffff0 },
916 { 0x002060b0, 0xfffffff0 },
917 { 0x0143bca0, 0xfffffff0 },
918 { 0x0143bcb0, 0xfffffff0 },
919 { PHY_ID_BCM50610, 0xfffffff0 },
920 { PHY_ID_BCM50610M, 0xfffffff0 },
921 { PHY_ID_BCM57780, 0xfffffff0 },
922 { PHY_ID_BCMAC131, 0xfffffff0 },
923 { }
924};
925
926MODULE_DEVICE_TABLE(mdio, broadcom_tbl);
diff --git a/drivers/net/phy/cicada.c b/drivers/net/phy/cicada.c
index a1bd599c8a5b..efc608f35d10 100644
--- a/drivers/net/phy/cicada.c
+++ b/drivers/net/phy/cicada.c
@@ -159,3 +159,11 @@ static void __exit cicada_exit(void)
159 159
160module_init(cicada_init); 160module_init(cicada_init);
161module_exit(cicada_exit); 161module_exit(cicada_exit);
162
163static struct mdio_device_id cicada_tbl[] = {
164 { 0x000fc410, 0x000ffff0 },
165 { 0x000fc440, 0x000fffc0 },
166 { }
167};
168
169MODULE_DEVICE_TABLE(mdio, cicada_tbl);
diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c
index d926168bc780..e02b18cb0d30 100644
--- a/drivers/net/phy/davicom.c
+++ b/drivers/net/phy/davicom.c
@@ -219,3 +219,12 @@ static void __exit davicom_exit(void)
219 219
220module_init(davicom_init); 220module_init(davicom_init);
221module_exit(davicom_exit); 221module_exit(davicom_exit);
222
223static struct mdio_device_id davicom_tbl[] = {
224 { 0x0181b880, 0x0ffffff0 },
225 { 0x0181b8a0, 0x0ffffff0 },
226 { 0x00181b80, 0x0ffffff0 },
227 { }
228};
229
230MODULE_DEVICE_TABLE(mdio, davicom_tbl);
diff --git a/drivers/net/phy/et1011c.c b/drivers/net/phy/et1011c.c
index b031fa21f1aa..500f0fd2c138 100644
--- a/drivers/net/phy/et1011c.c
+++ b/drivers/net/phy/et1011c.c
@@ -111,3 +111,10 @@ static void __exit et1011c_exit(void)
111 111
112module_init(et1011c_init); 112module_init(et1011c_init);
113module_exit(et1011c_exit); 113module_exit(et1011c_exit);
114
115static struct mdio_device_id et1011c_tbl[] = {
116 { 0x0282f014, 0xfffffff0 },
117 { }
118};
119
120MODULE_DEVICE_TABLE(mdio, et1011c_tbl);
diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c
index af3f1f2a9f87..e661e9078a7d 100644
--- a/drivers/net/phy/icplus.c
+++ b/drivers/net/phy/icplus.c
@@ -132,3 +132,10 @@ static void __exit ip175c_exit(void)
132 132
133module_init(ip175c_init); 133module_init(ip175c_init);
134module_exit(ip175c_exit); 134module_exit(ip175c_exit);
135
136static struct mdio_device_id icplus_tbl[] = {
137 { 0x02430d80, 0x0ffffff0 },
138 { }
139};
140
141MODULE_DEVICE_TABLE(mdio, icplus_tbl);
diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c
index 4cf3324ba166..1d94f1d610e4 100644
--- a/drivers/net/phy/lxt.c
+++ b/drivers/net/phy/lxt.c
@@ -174,3 +174,11 @@ static void __exit lxt_exit(void)
174 174
175module_init(lxt_init); 175module_init(lxt_init);
176module_exit(lxt_exit); 176module_exit(lxt_exit);
177
178static struct mdio_device_id lxt_tbl[] = {
179 { 0x78100000, 0xfffffff0 },
180 { 0x001378e0, 0xfffffff0 },
181 { }
182};
183
184MODULE_DEVICE_TABLE(mdio, lxt_tbl);
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 65ed385c2ceb..c7e5b9f12861 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -649,3 +649,16 @@ static void __exit marvell_exit(void)
649 649
650module_init(marvell_init); 650module_init(marvell_init);
651module_exit(marvell_exit); 651module_exit(marvell_exit);
652
653static struct mdio_device_id marvell_tbl[] = {
654 { 0x01410c60, 0xfffffff0 },
655 { 0x01410c90, 0xfffffff0 },
656 { 0x01410cc0, 0xfffffff0 },
657 { 0x01410e10, 0xfffffff0 },
658 { 0x01410cb0, 0xfffffff0 },
659 { 0x01410cd0, 0xfffffff0 },
660 { 0x01410e30, 0xfffffff0 },
661 { }
662};
663
664MODULE_DEVICE_TABLE(mdio, marvell_tbl);
diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
index 2576055b350b..0ff06617a4ab 100644
--- a/drivers/net/phy/mdio-bitbang.c
+++ b/drivers/net/phy/mdio-bitbang.c
@@ -23,8 +23,13 @@
23#include <linux/types.h> 23#include <linux/types.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25 25
26#define MDIO_READ 1 26#define MDIO_READ 2
27#define MDIO_WRITE 0 27#define MDIO_WRITE 1
28
29#define MDIO_C45 (1<<15)
30#define MDIO_C45_ADDR (MDIO_C45 | 0)
31#define MDIO_C45_READ (MDIO_C45 | 3)
32#define MDIO_C45_WRITE (MDIO_C45 | 1)
28 33
29#define MDIO_SETUP_TIME 10 34#define MDIO_SETUP_TIME 10
30#define MDIO_HOLD_TIME 10 35#define MDIO_HOLD_TIME 10
@@ -90,7 +95,7 @@ static u16 mdiobb_get_num(struct mdiobb_ctrl *ctrl, int bits)
90/* Utility to send the preamble, address, and 95/* Utility to send the preamble, address, and
91 * register (common to read and write). 96 * register (common to read and write).
92 */ 97 */
93static void mdiobb_cmd(struct mdiobb_ctrl *ctrl, int read, u8 phy, u8 reg) 98static void mdiobb_cmd(struct mdiobb_ctrl *ctrl, int op, u8 phy, u8 reg)
94{ 99{
95 const struct mdiobb_ops *ops = ctrl->ops; 100 const struct mdiobb_ops *ops = ctrl->ops;
96 int i; 101 int i;
@@ -109,23 +114,56 @@ static void mdiobb_cmd(struct mdiobb_ctrl *ctrl, int read, u8 phy, u8 reg)
109 for (i = 0; i < 32; i++) 114 for (i = 0; i < 32; i++)
110 mdiobb_send_bit(ctrl, 1); 115 mdiobb_send_bit(ctrl, 1);
111 116
112 /* send the start bit (01) and the read opcode (10) or write (10) */ 117 /* send the start bit (01) and the read opcode (10) or write (10).
118 Clause 45 operation uses 00 for the start and 11, 10 for
119 read/write */
113 mdiobb_send_bit(ctrl, 0); 120 mdiobb_send_bit(ctrl, 0);
114 mdiobb_send_bit(ctrl, 1); 121 if (op & MDIO_C45)
115 mdiobb_send_bit(ctrl, read); 122 mdiobb_send_bit(ctrl, 0);
116 mdiobb_send_bit(ctrl, !read); 123 else
124 mdiobb_send_bit(ctrl, 1);
125 mdiobb_send_bit(ctrl, (op >> 1) & 1);
126 mdiobb_send_bit(ctrl, (op >> 0) & 1);
117 127
118 mdiobb_send_num(ctrl, phy, 5); 128 mdiobb_send_num(ctrl, phy, 5);
119 mdiobb_send_num(ctrl, reg, 5); 129 mdiobb_send_num(ctrl, reg, 5);
120} 130}
121 131
132/* In clause 45 mode all commands are prefixed by MDIO_ADDR to specify the
133 lower 16 bits of the 21 bit address. This transfer is done identically to a
134 MDIO_WRITE except for a different code. To enable clause 45 mode or
135 MII_ADDR_C45 into the address. Theoretically clause 45 and normal devices
136 can exist on the same bus. Normal devices should ignore the MDIO_ADDR
137 phase. */
138static int mdiobb_cmd_addr(struct mdiobb_ctrl *ctrl, int phy, u32 addr)
139{
140 unsigned int dev_addr = (addr >> 16) & 0x1F;
141 unsigned int reg = addr & 0xFFFF;
142 mdiobb_cmd(ctrl, MDIO_C45_ADDR, phy, dev_addr);
143
144 /* send the turnaround (10) */
145 mdiobb_send_bit(ctrl, 1);
146 mdiobb_send_bit(ctrl, 0);
147
148 mdiobb_send_num(ctrl, reg, 16);
149
150 ctrl->ops->set_mdio_dir(ctrl, 0);
151 mdiobb_get_bit(ctrl);
152
153 return dev_addr;
154}
122 155
123static int mdiobb_read(struct mii_bus *bus, int phy, int reg) 156static int mdiobb_read(struct mii_bus *bus, int phy, int reg)
124{ 157{
125 struct mdiobb_ctrl *ctrl = bus->priv; 158 struct mdiobb_ctrl *ctrl = bus->priv;
126 int ret, i; 159 int ret, i;
127 160
128 mdiobb_cmd(ctrl, MDIO_READ, phy, reg); 161 if (reg & MII_ADDR_C45) {
162 reg = mdiobb_cmd_addr(ctrl, phy, reg);
163 mdiobb_cmd(ctrl, MDIO_C45_READ, phy, reg);
164 } else
165 mdiobb_cmd(ctrl, MDIO_READ, phy, reg);
166
129 ctrl->ops->set_mdio_dir(ctrl, 0); 167 ctrl->ops->set_mdio_dir(ctrl, 0);
130 168
131 /* check the turnaround bit: the PHY should be driving it to zero */ 169 /* check the turnaround bit: the PHY should be driving it to zero */
@@ -148,7 +186,11 @@ static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
148{ 186{
149 struct mdiobb_ctrl *ctrl = bus->priv; 187 struct mdiobb_ctrl *ctrl = bus->priv;
150 188
151 mdiobb_cmd(ctrl, MDIO_WRITE, phy, reg); 189 if (reg & MII_ADDR_C45) {
190 reg = mdiobb_cmd_addr(ctrl, phy, reg);
191 mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, reg);
192 } else
193 mdiobb_cmd(ctrl, MDIO_WRITE, phy, reg);
152 194
153 /* send the turnaround (10) */ 195 /* send the turnaround (10) */
154 mdiobb_send_bit(ctrl, 1); 196 mdiobb_send_bit(ctrl, 1);
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index e17b70291bbc..6a6b8199a0d6 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -208,7 +208,7 @@ EXPORT_SYMBOL(mdiobus_scan);
208 * because the bus read/write functions may wait for an interrupt 208 * because the bus read/write functions may wait for an interrupt
209 * to conclude the operation. 209 * to conclude the operation.
210 */ 210 */
211int mdiobus_read(struct mii_bus *bus, int addr, u16 regnum) 211int mdiobus_read(struct mii_bus *bus, int addr, u32 regnum)
212{ 212{
213 int retval; 213 int retval;
214 214
@@ -233,7 +233,7 @@ EXPORT_SYMBOL(mdiobus_read);
233 * because the bus read/write functions may wait for an interrupt 233 * because the bus read/write functions may wait for an interrupt
234 * to conclude the operation. 234 * to conclude the operation.
235 */ 235 */
236int mdiobus_write(struct mii_bus *bus, int addr, u16 regnum, u16 val) 236int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val)
237{ 237{
238 int err; 238 int err;
239 239
diff --git a/drivers/net/phy/national.c b/drivers/net/phy/national.c
index 6c636eb72089..729ab29ba28c 100644
--- a/drivers/net/phy/national.c
+++ b/drivers/net/phy/national.c
@@ -153,3 +153,10 @@ MODULE_LICENSE("GPL");
153 153
154module_init(ns_init); 154module_init(ns_init);
155module_exit(ns_exit); 155module_exit(ns_exit);
156
157static struct mdio_device_id ns_tbl[] = {
158 { DP83865_PHY_ID, 0xfffffff0 },
159 { }
160};
161
162MODULE_DEVICE_TABLE(mdio, ns_tbl);
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index db1794546c56..1a99bb244106 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -149,6 +149,7 @@ EXPORT_SYMBOL(phy_scan_fixups);
149struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id) 149struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
150{ 150{
151 struct phy_device *dev; 151 struct phy_device *dev;
152
152 /* We allocate the device, and initialize the 153 /* We allocate the device, and initialize the
153 * default values */ 154 * default values */
154 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 155 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
@@ -179,6 +180,17 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
179 mutex_init(&dev->lock); 180 mutex_init(&dev->lock);
180 INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine); 181 INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine);
181 182
183 /* Request the appropriate module unconditionally; don't
184 bother trying to do so only if it isn't already loaded,
185 because that gets complicated. A hotplug event would have
186 done an unconditional modprobe anyway.
187 We don't do normal hotplug because it won't work for MDIO
188 -- because it relies on the device staying around for long
189 enough for the driver to get loaded. With MDIO, the NIC
190 driver will get bored and give up as soon as it finds that
191 there's no driver _already_ loaded. */
192 request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT, MDIO_ID_ARGS(phy_id));
193
182 return dev; 194 return dev;
183} 195}
184EXPORT_SYMBOL(phy_device_create); 196EXPORT_SYMBOL(phy_device_create);
diff --git a/drivers/net/phy/qsemi.c b/drivers/net/phy/qsemi.c
index 23062d067231..3ec9610ee520 100644
--- a/drivers/net/phy/qsemi.c
+++ b/drivers/net/phy/qsemi.c
@@ -138,3 +138,10 @@ static void __exit qs6612_exit(void)
138 138
139module_init(qs6612_init); 139module_init(qs6612_init);
140module_exit(qs6612_exit); 140module_exit(qs6612_exit);
141
142static struct mdio_device_id qs6612_tbl[] = {
143 { 0x00181440, 0xfffffff0 },
144 { }
145};
146
147MODULE_DEVICE_TABLE(mdio, qs6612_tbl);
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index a052a6744a51..f567c0e1aaa1 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -78,3 +78,10 @@ static void __exit realtek_exit(void)
78 78
79module_init(realtek_init); 79module_init(realtek_init);
80module_exit(realtek_exit); 80module_exit(realtek_exit);
81
82static struct mdio_device_id realtek_tbl[] = {
83 { 0x001cc912, 0x001fffff },
84 { }
85};
86
87MODULE_DEVICE_TABLE(mdio, realtek_tbl);
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index ed2644a57500..78fa988256fc 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -253,3 +253,14 @@ MODULE_LICENSE("GPL");
253 253
254module_init(smsc_init); 254module_init(smsc_init);
255module_exit(smsc_exit); 255module_exit(smsc_exit);
256
257static struct mdio_device_id smsc_tbl[] = {
258 { 0x0007c0a0, 0xfffffff0 },
259 { 0x0007c0b0, 0xfffffff0 },
260 { 0x0007c0c0, 0xfffffff0 },
261 { 0x0007c0d0, 0xfffffff0 },
262 { 0x0007c0f0, 0xfffffff0 },
263 { }
264};
265
266MODULE_DEVICE_TABLE(mdio, smsc_tbl);
diff --git a/drivers/net/phy/ste10Xp.c b/drivers/net/phy/ste10Xp.c
index 6bdb0d53aaf9..72290099e5e1 100644
--- a/drivers/net/phy/ste10Xp.c
+++ b/drivers/net/phy/ste10Xp.c
@@ -132,6 +132,14 @@ static void __exit ste10Xp_exit(void)
132module_init(ste10Xp_init); 132module_init(ste10Xp_init);
133module_exit(ste10Xp_exit); 133module_exit(ste10Xp_exit);
134 134
135static struct mdio_device_id ste10Xp_tbl[] = {
136 { STE101P_PHY_ID, 0xfffffff0 },
137 { STE100P_PHY_ID, 0xffffffff },
138 { }
139};
140
141MODULE_DEVICE_TABLE(mdio, ste10Xp_tbl);
142
135MODULE_DESCRIPTION("STMicroelectronics STe10Xp PHY driver"); 143MODULE_DESCRIPTION("STMicroelectronics STe10Xp PHY driver");
136MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>"); 144MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>");
137MODULE_LICENSE("GPL"); 145MODULE_LICENSE("GPL");
diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
index dd3b2447e85a..45cce50a2799 100644
--- a/drivers/net/phy/vitesse.c
+++ b/drivers/net/phy/vitesse.c
@@ -191,3 +191,11 @@ static void __exit vsc82xx_exit(void)
191 191
192module_init(vsc82xx_init); 192module_init(vsc82xx_init);
193module_exit(vsc82xx_exit); 193module_exit(vsc82xx_exit);
194
195static struct mdio_device_id vitesse_tbl[] = {
196 { PHY_ID_VSC8244, 0x000fffc0 },
197 { PHY_ID_VSC8221, 0x000ffff0 },
198 { }
199};
200
201MODULE_DEVICE_TABLE(mdio, vitesse_tbl);
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 6d61602208c1..8a0dd8a843a9 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -2163,6 +2163,24 @@ int ppp_unit_number(struct ppp_channel *chan)
2163} 2163}
2164 2164
2165/* 2165/*
2166 * Return the PPP device interface name of a channel.
2167 */
2168char *ppp_dev_name(struct ppp_channel *chan)
2169{
2170 struct channel *pch = chan->ppp;
2171 char *name = NULL;
2172
2173 if (pch) {
2174 read_lock_bh(&pch->upl);
2175 if (pch->ppp && pch->ppp->dev)
2176 name = pch->ppp->dev->name;
2177 read_unlock_bh(&pch->upl);
2178 }
2179 return name;
2180}
2181
2182
2183/*
2166 * Disconnect a channel from the generic layer. 2184 * Disconnect a channel from the generic layer.
2167 * This must be called in process context. 2185 * This must be called in process context.
2168 */ 2186 */
@@ -2890,6 +2908,7 @@ EXPORT_SYMBOL(ppp_register_channel);
2890EXPORT_SYMBOL(ppp_unregister_channel); 2908EXPORT_SYMBOL(ppp_unregister_channel);
2891EXPORT_SYMBOL(ppp_channel_index); 2909EXPORT_SYMBOL(ppp_channel_index);
2892EXPORT_SYMBOL(ppp_unit_number); 2910EXPORT_SYMBOL(ppp_unit_number);
2911EXPORT_SYMBOL(ppp_dev_name);
2893EXPORT_SYMBOL(ppp_input); 2912EXPORT_SYMBOL(ppp_input);
2894EXPORT_SYMBOL(ppp_input_error); 2913EXPORT_SYMBOL(ppp_input_error);
2895EXPORT_SYMBOL(ppp_output_wakeup); 2914EXPORT_SYMBOL(ppp_output_wakeup);
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
deleted file mode 100644
index 449a9825200d..000000000000
--- a/drivers/net/pppol2tp.c
+++ /dev/null
@@ -1,2680 +0,0 @@
1/*****************************************************************************
2 * Linux PPP over L2TP (PPPoX/PPPoL2TP) Sockets
3 *
4 * PPPoX --- Generic PPP encapsulation socket family
5 * PPPoL2TP --- PPP over L2TP (RFC 2661)
6 *
7 * Version: 1.0.0
8 *
9 * Authors: Martijn van Oosterhout <kleptog@svana.org>
10 * James Chapman (jchapman@katalix.com)
11 * Contributors:
12 * Michal Ostrowski <mostrows@speakeasy.net>
13 * Arnaldo Carvalho de Melo <acme@xconectiva.com.br>
14 * David S. Miller (davem@redhat.com)
15 *
16 * License:
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version
20 * 2 of the License, or (at your option) any later version.
21 *
22 */
23
24/* This driver handles only L2TP data frames; control frames are handled by a
25 * userspace application.
26 *
27 * To send data in an L2TP session, userspace opens a PPPoL2TP socket and
28 * attaches it to a bound UDP socket with local tunnel_id / session_id and
29 * peer tunnel_id / session_id set. Data can then be sent or received using
30 * regular socket sendmsg() / recvmsg() calls. Kernel parameters of the socket
31 * can be read or modified using ioctl() or [gs]etsockopt() calls.
32 *
33 * When a PPPoL2TP socket is connected with local and peer session_id values
34 * zero, the socket is treated as a special tunnel management socket.
35 *
36 * Here's example userspace code to create a socket for sending/receiving data
37 * over an L2TP session:-
38 *
39 * struct sockaddr_pppol2tp sax;
40 * int fd;
41 * int session_fd;
42 *
43 * fd = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OL2TP);
44 *
45 * sax.sa_family = AF_PPPOX;
46 * sax.sa_protocol = PX_PROTO_OL2TP;
47 * sax.pppol2tp.fd = tunnel_fd; // bound UDP socket
48 * sax.pppol2tp.addr.sin_addr.s_addr = addr->sin_addr.s_addr;
49 * sax.pppol2tp.addr.sin_port = addr->sin_port;
50 * sax.pppol2tp.addr.sin_family = AF_INET;
51 * sax.pppol2tp.s_tunnel = tunnel_id;
52 * sax.pppol2tp.s_session = session_id;
53 * sax.pppol2tp.d_tunnel = peer_tunnel_id;
54 * sax.pppol2tp.d_session = peer_session_id;
55 *
56 * session_fd = connect(fd, (struct sockaddr *)&sax, sizeof(sax));
57 *
58 * A pppd plugin that allows PPP traffic to be carried over L2TP using
59 * this driver is available from the OpenL2TP project at
60 * http://openl2tp.sourceforge.net.
61 */
62
63#include <linux/module.h>
64#include <linux/string.h>
65#include <linux/list.h>
66#include <asm/uaccess.h>
67
68#include <linux/kernel.h>
69#include <linux/spinlock.h>
70#include <linux/kthread.h>
71#include <linux/sched.h>
72#include <linux/slab.h>
73#include <linux/errno.h>
74#include <linux/jiffies.h>
75
76#include <linux/netdevice.h>
77#include <linux/net.h>
78#include <linux/inetdevice.h>
79#include <linux/skbuff.h>
80#include <linux/init.h>
81#include <linux/ip.h>
82#include <linux/udp.h>
83#include <linux/if_pppox.h>
84#include <linux/if_pppol2tp.h>
85#include <net/sock.h>
86#include <linux/ppp_channel.h>
87#include <linux/ppp_defs.h>
88#include <linux/if_ppp.h>
89#include <linux/file.h>
90#include <linux/hash.h>
91#include <linux/sort.h>
92#include <linux/proc_fs.h>
93#include <linux/nsproxy.h>
94#include <net/net_namespace.h>
95#include <net/netns/generic.h>
96#include <net/dst.h>
97#include <net/ip.h>
98#include <net/udp.h>
99#include <net/xfrm.h>
100
101#include <asm/byteorder.h>
102#include <asm/atomic.h>
103
104
105#define PPPOL2TP_DRV_VERSION "V1.0"
106
107/* L2TP header constants */
108#define L2TP_HDRFLAG_T 0x8000
109#define L2TP_HDRFLAG_L 0x4000
110#define L2TP_HDRFLAG_S 0x0800
111#define L2TP_HDRFLAG_O 0x0200
112#define L2TP_HDRFLAG_P 0x0100
113
114#define L2TP_HDR_VER_MASK 0x000F
115#define L2TP_HDR_VER 0x0002
116
117/* Space for UDP, L2TP and PPP headers */
118#define PPPOL2TP_HEADER_OVERHEAD 40
119
120/* Just some random numbers */
121#define L2TP_TUNNEL_MAGIC 0x42114DDA
122#define L2TP_SESSION_MAGIC 0x0C04EB7D
123
124#define PPPOL2TP_HASH_BITS 4
125#define PPPOL2TP_HASH_SIZE (1 << PPPOL2TP_HASH_BITS)
126
127/* Default trace flags */
128#define PPPOL2TP_DEFAULT_DEBUG_FLAGS 0
129
130#define PRINTK(_mask, _type, _lvl, _fmt, args...) \
131 do { \
132 if ((_mask) & (_type)) \
133 printk(_lvl "PPPOL2TP: " _fmt, ##args); \
134 } while(0)
135
136/* Number of bytes to build transmit L2TP headers.
137 * Unfortunately the size is different depending on whether sequence numbers
138 * are enabled.
139 */
140#define PPPOL2TP_L2TP_HDR_SIZE_SEQ 10
141#define PPPOL2TP_L2TP_HDR_SIZE_NOSEQ 6
142
143struct pppol2tp_tunnel;
144
145/* Describes a session. It is the sk_user_data field in the PPPoL2TP
146 * socket. Contains information to determine incoming packets and transmit
147 * outgoing ones.
148 */
149struct pppol2tp_session
150{
151 int magic; /* should be
152 * L2TP_SESSION_MAGIC */
153 int owner; /* pid that opened the socket */
154
155 struct sock *sock; /* Pointer to the session
156 * PPPoX socket */
157 struct sock *tunnel_sock; /* Pointer to the tunnel UDP
158 * socket */
159
160 struct pppol2tp_addr tunnel_addr; /* Description of tunnel */
161
162 struct pppol2tp_tunnel *tunnel; /* back pointer to tunnel
163 * context */
164
165 char name[20]; /* "sess xxxxx/yyyyy", where
166 * x=tunnel_id, y=session_id */
167 int mtu;
168 int mru;
169 int flags; /* accessed by PPPIOCGFLAGS.
170 * Unused. */
171 unsigned recv_seq:1; /* expect receive packets with
172 * sequence numbers? */
173 unsigned send_seq:1; /* send packets with sequence
174 * numbers? */
175 unsigned lns_mode:1; /* behave as LNS? LAC enables
176 * sequence numbers under
177 * control of LNS. */
178 int debug; /* bitmask of debug message
179 * categories */
180 int reorder_timeout; /* configured reorder timeout
181 * (in jiffies) */
182 u16 nr; /* session NR state (receive) */
183 u16 ns; /* session NR state (send) */
184 struct sk_buff_head reorder_q; /* receive reorder queue */
185 struct pppol2tp_ioc_stats stats;
186 struct hlist_node hlist; /* Hash list node */
187};
188
189/* The sk_user_data field of the tunnel's UDP socket. It contains info to track
190 * all the associated sessions so incoming packets can be sorted out
191 */
192struct pppol2tp_tunnel
193{
194 int magic; /* Should be L2TP_TUNNEL_MAGIC */
195 rwlock_t hlist_lock; /* protect session_hlist */
196 struct hlist_head session_hlist[PPPOL2TP_HASH_SIZE];
197 /* hashed list of sessions,
198 * hashed by id */
199 int debug; /* bitmask of debug message
200 * categories */
201 char name[12]; /* "tunl xxxxx" */
202 struct pppol2tp_ioc_stats stats;
203
204 void (*old_sk_destruct)(struct sock *);
205
206 struct sock *sock; /* Parent socket */
207 struct list_head list; /* Keep a list of all open
208 * prepared sockets */
209 struct net *pppol2tp_net; /* the net we belong to */
210
211 atomic_t ref_count;
212};
213
214/* Private data stored for received packets in the skb.
215 */
216struct pppol2tp_skb_cb {
217 u16 ns;
218 u16 nr;
219 u16 has_seq;
220 u16 length;
221 unsigned long expires;
222};
223
224#define PPPOL2TP_SKB_CB(skb) ((struct pppol2tp_skb_cb *) &skb->cb[sizeof(struct inet_skb_parm)])
225
226static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb);
227static void pppol2tp_tunnel_free(struct pppol2tp_tunnel *tunnel);
228
229static atomic_t pppol2tp_tunnel_count;
230static atomic_t pppol2tp_session_count;
231static struct ppp_channel_ops pppol2tp_chan_ops = { pppol2tp_xmit , NULL };
232static const struct proto_ops pppol2tp_ops;
233
234/* per-net private data for this module */
235static int pppol2tp_net_id __read_mostly;
236struct pppol2tp_net {
237 struct list_head pppol2tp_tunnel_list;
238 rwlock_t pppol2tp_tunnel_list_lock;
239};
240
241static inline struct pppol2tp_net *pppol2tp_pernet(struct net *net)
242{
243 BUG_ON(!net);
244
245 return net_generic(net, pppol2tp_net_id);
246}
247
248/* Helpers to obtain tunnel/session contexts from sockets.
249 */
250static inline struct pppol2tp_session *pppol2tp_sock_to_session(struct sock *sk)
251{
252 struct pppol2tp_session *session;
253
254 if (sk == NULL)
255 return NULL;
256
257 sock_hold(sk);
258 session = (struct pppol2tp_session *)(sk->sk_user_data);
259 if (session == NULL) {
260 sock_put(sk);
261 goto out;
262 }
263
264 BUG_ON(session->magic != L2TP_SESSION_MAGIC);
265out:
266 return session;
267}
268
269static inline struct pppol2tp_tunnel *pppol2tp_sock_to_tunnel(struct sock *sk)
270{
271 struct pppol2tp_tunnel *tunnel;
272
273 if (sk == NULL)
274 return NULL;
275
276 sock_hold(sk);
277 tunnel = (struct pppol2tp_tunnel *)(sk->sk_user_data);
278 if (tunnel == NULL) {
279 sock_put(sk);
280 goto out;
281 }
282
283 BUG_ON(tunnel->magic != L2TP_TUNNEL_MAGIC);
284out:
285 return tunnel;
286}
287
288/* Tunnel reference counts. Incremented per session that is added to
289 * the tunnel.
290 */
291static inline void pppol2tp_tunnel_inc_refcount(struct pppol2tp_tunnel *tunnel)
292{
293 atomic_inc(&tunnel->ref_count);
294}
295
296static inline void pppol2tp_tunnel_dec_refcount(struct pppol2tp_tunnel *tunnel)
297{
298 if (atomic_dec_and_test(&tunnel->ref_count))
299 pppol2tp_tunnel_free(tunnel);
300}
301
302/* Session hash list.
303 * The session_id SHOULD be random according to RFC2661, but several
304 * L2TP implementations (Cisco and Microsoft) use incrementing
305 * session_ids. So we do a real hash on the session_id, rather than a
306 * simple bitmask.
307 */
308static inline struct hlist_head *
309pppol2tp_session_id_hash(struct pppol2tp_tunnel *tunnel, u16 session_id)
310{
311 unsigned long hash_val = (unsigned long) session_id;
312 return &tunnel->session_hlist[hash_long(hash_val, PPPOL2TP_HASH_BITS)];
313}
314
315/* Lookup a session by id
316 */
317static struct pppol2tp_session *
318pppol2tp_session_find(struct pppol2tp_tunnel *tunnel, u16 session_id)
319{
320 struct hlist_head *session_list =
321 pppol2tp_session_id_hash(tunnel, session_id);
322 struct pppol2tp_session *session;
323 struct hlist_node *walk;
324
325 read_lock_bh(&tunnel->hlist_lock);
326 hlist_for_each_entry(session, walk, session_list, hlist) {
327 if (session->tunnel_addr.s_session == session_id) {
328 read_unlock_bh(&tunnel->hlist_lock);
329 return session;
330 }
331 }
332 read_unlock_bh(&tunnel->hlist_lock);
333
334 return NULL;
335}
336
337/* Lookup a tunnel by id
338 */
339static struct pppol2tp_tunnel *pppol2tp_tunnel_find(struct net *net, u16 tunnel_id)
340{
341 struct pppol2tp_tunnel *tunnel;
342 struct pppol2tp_net *pn = pppol2tp_pernet(net);
343
344 read_lock_bh(&pn->pppol2tp_tunnel_list_lock);
345 list_for_each_entry(tunnel, &pn->pppol2tp_tunnel_list, list) {
346 if (tunnel->stats.tunnel_id == tunnel_id) {
347 read_unlock_bh(&pn->pppol2tp_tunnel_list_lock);
348 return tunnel;
349 }
350 }
351 read_unlock_bh(&pn->pppol2tp_tunnel_list_lock);
352
353 return NULL;
354}
355
356/*****************************************************************************
357 * Receive data handling
358 *****************************************************************************/
359
360/* Queue a skb in order. We come here only if the skb has an L2TP sequence
361 * number.
362 */
363static void pppol2tp_recv_queue_skb(struct pppol2tp_session *session, struct sk_buff *skb)
364{
365 struct sk_buff *skbp;
366 struct sk_buff *tmp;
367 u16 ns = PPPOL2TP_SKB_CB(skb)->ns;
368
369 spin_lock_bh(&session->reorder_q.lock);
370 skb_queue_walk_safe(&session->reorder_q, skbp, tmp) {
371 if (PPPOL2TP_SKB_CB(skbp)->ns > ns) {
372 __skb_queue_before(&session->reorder_q, skbp, skb);
373 PRINTK(session->debug, PPPOL2TP_MSG_SEQ, KERN_DEBUG,
374 "%s: pkt %hu, inserted before %hu, reorder_q len=%d\n",
375 session->name, ns, PPPOL2TP_SKB_CB(skbp)->ns,
376 skb_queue_len(&session->reorder_q));
377 session->stats.rx_oos_packets++;
378 goto out;
379 }
380 }
381
382 __skb_queue_tail(&session->reorder_q, skb);
383
384out:
385 spin_unlock_bh(&session->reorder_q.lock);
386}
387
388/* Dequeue a single skb.
389 */
390static void pppol2tp_recv_dequeue_skb(struct pppol2tp_session *session, struct sk_buff *skb)
391{
392 struct pppol2tp_tunnel *tunnel = session->tunnel;
393 int length = PPPOL2TP_SKB_CB(skb)->length;
394 struct sock *session_sock = NULL;
395
396 /* We're about to requeue the skb, so return resources
397 * to its current owner (a socket receive buffer).
398 */
399 skb_orphan(skb);
400
401 tunnel->stats.rx_packets++;
402 tunnel->stats.rx_bytes += length;
403 session->stats.rx_packets++;
404 session->stats.rx_bytes += length;
405
406 if (PPPOL2TP_SKB_CB(skb)->has_seq) {
407 /* Bump our Nr */
408 session->nr++;
409 PRINTK(session->debug, PPPOL2TP_MSG_SEQ, KERN_DEBUG,
410 "%s: updated nr to %hu\n", session->name, session->nr);
411 }
412
413 /* If the socket is bound, send it in to PPP's input queue. Otherwise
414 * queue it on the session socket.
415 */
416 session_sock = session->sock;
417 if (session_sock->sk_state & PPPOX_BOUND) {
418 struct pppox_sock *po;
419 PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG,
420 "%s: recv %d byte data frame, passing to ppp\n",
421 session->name, length);
422
423 /* We need to forget all info related to the L2TP packet
424 * gathered in the skb as we are going to reuse the same
425 * skb for the inner packet.
426 * Namely we need to:
427 * - reset xfrm (IPSec) information as it applies to
428 * the outer L2TP packet and not to the inner one
429 * - release the dst to force a route lookup on the inner
430 * IP packet since skb->dst currently points to the dst
431 * of the UDP tunnel
432 * - reset netfilter information as it doesn't apply
433 * to the inner packet either
434 */
435 secpath_reset(skb);
436 skb_dst_drop(skb);
437 nf_reset(skb);
438
439 po = pppox_sk(session_sock);
440 ppp_input(&po->chan, skb);
441 } else {
442 PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_INFO,
443 "%s: socket not bound\n", session->name);
444
445 /* Not bound. Nothing we can do, so discard. */
446 session->stats.rx_errors++;
447 kfree_skb(skb);
448 }
449
450 sock_put(session->sock);
451}
452
453/* Dequeue skbs from the session's reorder_q, subject to packet order.
454 * Skbs that have been in the queue for too long are simply discarded.
455 */
456static void pppol2tp_recv_dequeue(struct pppol2tp_session *session)
457{
458 struct sk_buff *skb;
459 struct sk_buff *tmp;
460
461 /* If the pkt at the head of the queue has the nr that we
462 * expect to send up next, dequeue it and any other
463 * in-sequence packets behind it.
464 */
465 spin_lock_bh(&session->reorder_q.lock);
466 skb_queue_walk_safe(&session->reorder_q, skb, tmp) {
467 if (time_after(jiffies, PPPOL2TP_SKB_CB(skb)->expires)) {
468 session->stats.rx_seq_discards++;
469 session->stats.rx_errors++;
470 PRINTK(session->debug, PPPOL2TP_MSG_SEQ, KERN_DEBUG,
471 "%s: oos pkt %hu len %d discarded (too old), "
472 "waiting for %hu, reorder_q_len=%d\n",
473 session->name, PPPOL2TP_SKB_CB(skb)->ns,
474 PPPOL2TP_SKB_CB(skb)->length, session->nr,
475 skb_queue_len(&session->reorder_q));
476 __skb_unlink(skb, &session->reorder_q);
477 kfree_skb(skb);
478 sock_put(session->sock);
479 continue;
480 }
481
482 if (PPPOL2TP_SKB_CB(skb)->has_seq) {
483 if (PPPOL2TP_SKB_CB(skb)->ns != session->nr) {
484 PRINTK(session->debug, PPPOL2TP_MSG_SEQ, KERN_DEBUG,
485 "%s: holding oos pkt %hu len %d, "
486 "waiting for %hu, reorder_q_len=%d\n",
487 session->name, PPPOL2TP_SKB_CB(skb)->ns,
488 PPPOL2TP_SKB_CB(skb)->length, session->nr,
489 skb_queue_len(&session->reorder_q));
490 goto out;
491 }
492 }
493 __skb_unlink(skb, &session->reorder_q);
494
495 /* Process the skb. We release the queue lock while we
496 * do so to let other contexts process the queue.
497 */
498 spin_unlock_bh(&session->reorder_q.lock);
499 pppol2tp_recv_dequeue_skb(session, skb);
500 spin_lock_bh(&session->reorder_q.lock);
501 }
502
503out:
504 spin_unlock_bh(&session->reorder_q.lock);
505}
506
507static inline int pppol2tp_verify_udp_checksum(struct sock *sk,
508 struct sk_buff *skb)
509{
510 struct udphdr *uh = udp_hdr(skb);
511 u16 ulen = ntohs(uh->len);
512 struct inet_sock *inet;
513 __wsum psum;
514
515 if (sk->sk_no_check || skb_csum_unnecessary(skb) || !uh->check)
516 return 0;
517
518 inet = inet_sk(sk);
519 psum = csum_tcpudp_nofold(inet->inet_saddr, inet->inet_daddr, ulen,
520 IPPROTO_UDP, 0);
521
522 if ((skb->ip_summed == CHECKSUM_COMPLETE) &&
523 !csum_fold(csum_add(psum, skb->csum)))
524 return 0;
525
526 skb->csum = psum;
527
528 return __skb_checksum_complete(skb);
529}
530
531/* Internal receive frame. Do the real work of receiving an L2TP data frame
532 * here. The skb is not on a list when we get here.
533 * Returns 0 if the packet was a data packet and was successfully passed on.
534 * Returns 1 if the packet was not a good data packet and could not be
535 * forwarded. All such packets are passed up to userspace to deal with.
536 */
537static int pppol2tp_recv_core(struct sock *sock, struct sk_buff *skb)
538{
539 struct pppol2tp_session *session = NULL;
540 struct pppol2tp_tunnel *tunnel;
541 unsigned char *ptr, *optr;
542 u16 hdrflags;
543 u16 tunnel_id, session_id;
544 int length;
545 int offset;
546
547 tunnel = pppol2tp_sock_to_tunnel(sock);
548 if (tunnel == NULL)
549 goto no_tunnel;
550
551 if (tunnel->sock && pppol2tp_verify_udp_checksum(tunnel->sock, skb))
552 goto discard_bad_csum;
553
554 /* UDP always verifies the packet length. */
555 __skb_pull(skb, sizeof(struct udphdr));
556
557 /* Short packet? */
558 if (!pskb_may_pull(skb, 12)) {
559 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_INFO,
560 "%s: recv short packet (len=%d)\n", tunnel->name, skb->len);
561 goto error;
562 }
563
564 /* Point to L2TP header */
565 optr = ptr = skb->data;
566
567 /* Get L2TP header flags */
568 hdrflags = ntohs(*(__be16*)ptr);
569
570 /* Trace packet contents, if enabled */
571 if (tunnel->debug & PPPOL2TP_MSG_DATA) {
572 length = min(16u, skb->len);
573 if (!pskb_may_pull(skb, length))
574 goto error;
575
576 printk(KERN_DEBUG "%s: recv: ", tunnel->name);
577
578 offset = 0;
579 do {
580 printk(" %02X", ptr[offset]);
581 } while (++offset < length);
582
583 printk("\n");
584 }
585
586 /* Get length of L2TP packet */
587 length = skb->len;
588
589 /* If type is control packet, it is handled by userspace. */
590 if (hdrflags & L2TP_HDRFLAG_T) {
591 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG,
592 "%s: recv control packet, len=%d\n", tunnel->name, length);
593 goto error;
594 }
595
596 /* Skip flags */
597 ptr += 2;
598
599 /* If length is present, skip it */
600 if (hdrflags & L2TP_HDRFLAG_L)
601 ptr += 2;
602
603 /* Extract tunnel and session ID */
604 tunnel_id = ntohs(*(__be16 *) ptr);
605 ptr += 2;
606 session_id = ntohs(*(__be16 *) ptr);
607 ptr += 2;
608
609 /* Find the session context */
610 session = pppol2tp_session_find(tunnel, session_id);
611 if (!session) {
612 /* Not found? Pass to userspace to deal with */
613 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_INFO,
614 "%s: no socket found (%hu/%hu). Passing up.\n",
615 tunnel->name, tunnel_id, session_id);
616 goto error;
617 }
618 sock_hold(session->sock);
619
620 /* The ref count on the socket was increased by the above call since
621 * we now hold a pointer to the session. Take care to do sock_put()
622 * when exiting this function from now on...
623 */
624
625 /* Handle the optional sequence numbers. If we are the LAC,
626 * enable/disable sequence numbers under the control of the LNS. If
627 * no sequence numbers present but we were expecting them, discard
628 * frame.
629 */
630 if (hdrflags & L2TP_HDRFLAG_S) {
631 u16 ns, nr;
632 ns = ntohs(*(__be16 *) ptr);
633 ptr += 2;
634 nr = ntohs(*(__be16 *) ptr);
635 ptr += 2;
636
637 /* Received a packet with sequence numbers. If we're the LNS,
638 * check if we sre sending sequence numbers and if not,
639 * configure it so.
640 */
641 if ((!session->lns_mode) && (!session->send_seq)) {
642 PRINTK(session->debug, PPPOL2TP_MSG_SEQ, KERN_INFO,
643 "%s: requested to enable seq numbers by LNS\n",
644 session->name);
645 session->send_seq = -1;
646 }
647
648 /* Store L2TP info in the skb */
649 PPPOL2TP_SKB_CB(skb)->ns = ns;
650 PPPOL2TP_SKB_CB(skb)->nr = nr;
651 PPPOL2TP_SKB_CB(skb)->has_seq = 1;
652
653 PRINTK(session->debug, PPPOL2TP_MSG_SEQ, KERN_DEBUG,
654 "%s: recv data ns=%hu, nr=%hu, session nr=%hu\n",
655 session->name, ns, nr, session->nr);
656 } else {
657 /* No sequence numbers.
658 * If user has configured mandatory sequence numbers, discard.
659 */
660 if (session->recv_seq) {
661 PRINTK(session->debug, PPPOL2TP_MSG_SEQ, KERN_WARNING,
662 "%s: recv data has no seq numbers when required. "
663 "Discarding\n", session->name);
664 session->stats.rx_seq_discards++;
665 goto discard;
666 }
667
668 /* If we're the LAC and we're sending sequence numbers, the
669 * LNS has requested that we no longer send sequence numbers.
670 * If we're the LNS and we're sending sequence numbers, the
671 * LAC is broken. Discard the frame.
672 */
673 if ((!session->lns_mode) && (session->send_seq)) {
674 PRINTK(session->debug, PPPOL2TP_MSG_SEQ, KERN_INFO,
675 "%s: requested to disable seq numbers by LNS\n",
676 session->name);
677 session->send_seq = 0;
678 } else if (session->send_seq) {
679 PRINTK(session->debug, PPPOL2TP_MSG_SEQ, KERN_WARNING,
680 "%s: recv data has no seq numbers when required. "
681 "Discarding\n", session->name);
682 session->stats.rx_seq_discards++;
683 goto discard;
684 }
685
686 /* Store L2TP info in the skb */
687 PPPOL2TP_SKB_CB(skb)->has_seq = 0;
688 }
689
690 /* If offset bit set, skip it. */
691 if (hdrflags & L2TP_HDRFLAG_O) {
692 offset = ntohs(*(__be16 *)ptr);
693 ptr += 2 + offset;
694 }
695
696 offset = ptr - optr;
697 if (!pskb_may_pull(skb, offset))
698 goto discard;
699
700 __skb_pull(skb, offset);
701
702 /* Skip PPP header, if present. In testing, Microsoft L2TP clients
703 * don't send the PPP header (PPP header compression enabled), but
704 * other clients can include the header. So we cope with both cases
705 * here. The PPP header is always FF03 when using L2TP.
706 *
707 * Note that skb->data[] isn't dereferenced from a u16 ptr here since
708 * the field may be unaligned.
709 */
710 if (!pskb_may_pull(skb, 2))
711 goto discard;
712
713 if ((skb->data[0] == 0xff) && (skb->data[1] == 0x03))
714 skb_pull(skb, 2);
715
716 /* Prepare skb for adding to the session's reorder_q. Hold
717 * packets for max reorder_timeout or 1 second if not
718 * reordering.
719 */
720 PPPOL2TP_SKB_CB(skb)->length = length;
721 PPPOL2TP_SKB_CB(skb)->expires = jiffies +
722 (session->reorder_timeout ? session->reorder_timeout : HZ);
723
724 /* Add packet to the session's receive queue. Reordering is done here, if
725 * enabled. Saved L2TP protocol info is stored in skb->sb[].
726 */
727 if (PPPOL2TP_SKB_CB(skb)->has_seq) {
728 if (session->reorder_timeout != 0) {
729 /* Packet reordering enabled. Add skb to session's
730 * reorder queue, in order of ns.
731 */
732 pppol2tp_recv_queue_skb(session, skb);
733 } else {
734 /* Packet reordering disabled. Discard out-of-sequence
735 * packets
736 */
737 if (PPPOL2TP_SKB_CB(skb)->ns != session->nr) {
738 session->stats.rx_seq_discards++;
739 PRINTK(session->debug, PPPOL2TP_MSG_SEQ, KERN_DEBUG,
740 "%s: oos pkt %hu len %d discarded, "
741 "waiting for %hu, reorder_q_len=%d\n",
742 session->name, PPPOL2TP_SKB_CB(skb)->ns,
743 PPPOL2TP_SKB_CB(skb)->length, session->nr,
744 skb_queue_len(&session->reorder_q));
745 goto discard;
746 }
747 skb_queue_tail(&session->reorder_q, skb);
748 }
749 } else {
750 /* No sequence numbers. Add the skb to the tail of the
751 * reorder queue. This ensures that it will be
752 * delivered after all previous sequenced skbs.
753 */
754 skb_queue_tail(&session->reorder_q, skb);
755 }
756
757 /* Try to dequeue as many skbs from reorder_q as we can. */
758 pppol2tp_recv_dequeue(session);
759 sock_put(sock);
760
761 return 0;
762
763discard:
764 session->stats.rx_errors++;
765 kfree_skb(skb);
766 sock_put(session->sock);
767 sock_put(sock);
768
769 return 0;
770
771discard_bad_csum:
772 LIMIT_NETDEBUG("%s: UDP: bad checksum\n", tunnel->name);
773 UDP_INC_STATS_USER(&init_net, UDP_MIB_INERRORS, 0);
774 tunnel->stats.rx_errors++;
775 kfree_skb(skb);
776 sock_put(sock);
777
778 return 0;
779
780error:
781 /* Put UDP header back */
782 __skb_push(skb, sizeof(struct udphdr));
783 sock_put(sock);
784
785no_tunnel:
786 return 1;
787}
788
789/* UDP encapsulation receive handler. See net/ipv4/udp.c.
790 * Return codes:
791 * 0 : success.
792 * <0: error
793 * >0: skb should be passed up to userspace as UDP.
794 */
795static int pppol2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
796{
797 struct pppol2tp_tunnel *tunnel;
798
799 tunnel = pppol2tp_sock_to_tunnel(sk);
800 if (tunnel == NULL)
801 goto pass_up;
802
803 PRINTK(tunnel->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG,
804 "%s: received %d bytes\n", tunnel->name, skb->len);
805
806 if (pppol2tp_recv_core(sk, skb))
807 goto pass_up_put;
808
809 sock_put(sk);
810 return 0;
811
812pass_up_put:
813 sock_put(sk);
814pass_up:
815 return 1;
816}
817
818/* Receive message. This is the recvmsg for the PPPoL2TP socket.
819 */
820static int pppol2tp_recvmsg(struct kiocb *iocb, struct socket *sock,
821 struct msghdr *msg, size_t len,
822 int flags)
823{
824 int err;
825 struct sk_buff *skb;
826 struct sock *sk = sock->sk;
827
828 err = -EIO;
829 if (sk->sk_state & PPPOX_BOUND)
830 goto end;
831
832 msg->msg_namelen = 0;
833
834 err = 0;
835 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
836 flags & MSG_DONTWAIT, &err);
837 if (!skb)
838 goto end;
839
840 if (len > skb->len)
841 len = skb->len;
842 else if (len < skb->len)
843 msg->msg_flags |= MSG_TRUNC;
844
845 err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, len);
846 if (likely(err == 0))
847 err = len;
848
849 kfree_skb(skb);
850end:
851 return err;
852}
853
854/************************************************************************
855 * Transmit handling
856 ***********************************************************************/
857
858/* Tell how big L2TP headers are for a particular session. This
859 * depends on whether sequence numbers are being used.
860 */
861static inline int pppol2tp_l2tp_header_len(struct pppol2tp_session *session)
862{
863 if (session->send_seq)
864 return PPPOL2TP_L2TP_HDR_SIZE_SEQ;
865
866 return PPPOL2TP_L2TP_HDR_SIZE_NOSEQ;
867}
868
869/* Build an L2TP header for the session into the buffer provided.
870 */
871static void pppol2tp_build_l2tp_header(struct pppol2tp_session *session,
872 void *buf)
873{
874 __be16 *bufp = buf;
875 u16 flags = L2TP_HDR_VER;
876
877 if (session->send_seq)
878 flags |= L2TP_HDRFLAG_S;
879
880 /* Setup L2TP header.
881 * FIXME: Can this ever be unaligned? Is direct dereferencing of
882 * 16-bit header fields safe here for all architectures?
883 */
884 *bufp++ = htons(flags);
885 *bufp++ = htons(session->tunnel_addr.d_tunnel);
886 *bufp++ = htons(session->tunnel_addr.d_session);
887 if (session->send_seq) {
888 *bufp++ = htons(session->ns);
889 *bufp++ = 0;
890 session->ns++;
891 PRINTK(session->debug, PPPOL2TP_MSG_SEQ, KERN_DEBUG,
892 "%s: updated ns to %hu\n", session->name, session->ns);
893 }
894}
895
896/* This is the sendmsg for the PPPoL2TP pppol2tp_session socket. We come here
897 * when a user application does a sendmsg() on the session socket. L2TP and
898 * PPP headers must be inserted into the user's data.
899 */
900static int pppol2tp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
901 size_t total_len)
902{
903 static const unsigned char ppph[2] = { 0xff, 0x03 };
904 struct sock *sk = sock->sk;
905 struct inet_sock *inet;
906 __wsum csum;
907 struct sk_buff *skb;
908 int error;
909 int hdr_len;
910 struct pppol2tp_session *session;
911 struct pppol2tp_tunnel *tunnel;
912 struct udphdr *uh;
913 unsigned int len;
914 struct sock *sk_tun;
915 u16 udp_len;
916
917 error = -ENOTCONN;
918 if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED))
919 goto error;
920
921 /* Get session and tunnel contexts */
922 error = -EBADF;
923 session = pppol2tp_sock_to_session(sk);
924 if (session == NULL)
925 goto error;
926
927 sk_tun = session->tunnel_sock;
928 tunnel = pppol2tp_sock_to_tunnel(sk_tun);
929 if (tunnel == NULL)
930 goto error_put_sess;
931
932 /* What header length is configured for this session? */
933 hdr_len = pppol2tp_l2tp_header_len(session);
934
935 /* Allocate a socket buffer */
936 error = -ENOMEM;
937 skb = sock_wmalloc(sk, NET_SKB_PAD + sizeof(struct iphdr) +
938 sizeof(struct udphdr) + hdr_len +
939 sizeof(ppph) + total_len,
940 0, GFP_KERNEL);
941 if (!skb)
942 goto error_put_sess_tun;
943
944 /* Reserve space for headers. */
945 skb_reserve(skb, NET_SKB_PAD);
946 skb_reset_network_header(skb);
947 skb_reserve(skb, sizeof(struct iphdr));
948 skb_reset_transport_header(skb);
949
950 /* Build UDP header */
951 inet = inet_sk(sk_tun);
952 udp_len = hdr_len + sizeof(ppph) + total_len;
953 uh = (struct udphdr *) skb->data;
954 uh->source = inet->inet_sport;
955 uh->dest = inet->inet_dport;
956 uh->len = htons(udp_len);
957 uh->check = 0;
958 skb_put(skb, sizeof(struct udphdr));
959
960 /* Build L2TP header */
961 pppol2tp_build_l2tp_header(session, skb->data);
962 skb_put(skb, hdr_len);
963
964 /* Add PPP header */
965 skb->data[0] = ppph[0];
966 skb->data[1] = ppph[1];
967 skb_put(skb, 2);
968
969 /* Copy user data into skb */
970 error = memcpy_fromiovec(skb->data, m->msg_iov, total_len);
971 if (error < 0) {
972 kfree_skb(skb);
973 goto error_put_sess_tun;
974 }
975 skb_put(skb, total_len);
976
977 /* Calculate UDP checksum if configured to do so */
978 if (sk_tun->sk_no_check == UDP_CSUM_NOXMIT)
979 skb->ip_summed = CHECKSUM_NONE;
980 else if (!(skb_dst(skb)->dev->features & NETIF_F_V4_CSUM)) {
981 skb->ip_summed = CHECKSUM_COMPLETE;
982 csum = skb_checksum(skb, 0, udp_len, 0);
983 uh->check = csum_tcpudp_magic(inet->inet_saddr,
984 inet->inet_daddr,
985 udp_len, IPPROTO_UDP, csum);
986 if (uh->check == 0)
987 uh->check = CSUM_MANGLED_0;
988 } else {
989 skb->ip_summed = CHECKSUM_PARTIAL;
990 skb->csum_start = skb_transport_header(skb) - skb->head;
991 skb->csum_offset = offsetof(struct udphdr, check);
992 uh->check = ~csum_tcpudp_magic(inet->inet_saddr,
993 inet->inet_daddr,
994 udp_len, IPPROTO_UDP, 0);
995 }
996
997 /* Debug */
998 if (session->send_seq)
999 PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG,
1000 "%s: send %Zd bytes, ns=%hu\n", session->name,
1001 total_len, session->ns - 1);
1002 else
1003 PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG,
1004 "%s: send %Zd bytes\n", session->name, total_len);
1005
1006 if (session->debug & PPPOL2TP_MSG_DATA) {
1007 int i;
1008 unsigned char *datap = skb->data;
1009
1010 printk(KERN_DEBUG "%s: xmit:", session->name);
1011 for (i = 0; i < total_len; i++) {
1012 printk(" %02X", *datap++);
1013 if (i == 15) {
1014 printk(" ...");
1015 break;
1016 }
1017 }
1018 printk("\n");
1019 }
1020
1021 /* Queue the packet to IP for output */
1022 len = skb->len;
1023 error = ip_queue_xmit(skb, 1);
1024
1025 /* Update stats */
1026 if (error >= 0) {
1027 tunnel->stats.tx_packets++;
1028 tunnel->stats.tx_bytes += len;
1029 session->stats.tx_packets++;
1030 session->stats.tx_bytes += len;
1031 } else {
1032 tunnel->stats.tx_errors++;
1033 session->stats.tx_errors++;
1034 }
1035
1036 return error;
1037
1038error_put_sess_tun:
1039 sock_put(session->tunnel_sock);
1040error_put_sess:
1041 sock_put(sk);
1042error:
1043 return error;
1044}
1045
1046/* Automatically called when the skb is freed.
1047 */
1048static void pppol2tp_sock_wfree(struct sk_buff *skb)
1049{
1050 sock_put(skb->sk);
1051}
1052
1053/* For data skbs that we transmit, we associate with the tunnel socket
1054 * but don't do accounting.
1055 */
1056static inline void pppol2tp_skb_set_owner_w(struct sk_buff *skb, struct sock *sk)
1057{
1058 sock_hold(sk);
1059 skb->sk = sk;
1060 skb->destructor = pppol2tp_sock_wfree;
1061}
1062
1063/* Transmit function called by generic PPP driver. Sends PPP frame
1064 * over PPPoL2TP socket.
1065 *
1066 * This is almost the same as pppol2tp_sendmsg(), but rather than
1067 * being called with a msghdr from userspace, it is called with a skb
1068 * from the kernel.
1069 *
1070 * The supplied skb from ppp doesn't have enough headroom for the
1071 * insertion of L2TP, UDP and IP headers so we need to allocate more
1072 * headroom in the skb. This will create a cloned skb. But we must be
1073 * careful in the error case because the caller will expect to free
1074 * the skb it supplied, not our cloned skb. So we take care to always
1075 * leave the original skb unfreed if we return an error.
1076 */
1077static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
1078{
1079 static const u8 ppph[2] = { 0xff, 0x03 };
1080 struct sock *sk = (struct sock *) chan->private;
1081 struct sock *sk_tun;
1082 int hdr_len;
1083 u16 udp_len;
1084 struct pppol2tp_session *session;
1085 struct pppol2tp_tunnel *tunnel;
1086 int rc;
1087 int headroom;
1088 int data_len = skb->len;
1089 struct inet_sock *inet;
1090 __wsum csum;
1091 struct udphdr *uh;
1092 unsigned int len;
1093 int old_headroom;
1094 int new_headroom;
1095
1096 if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED))
1097 goto abort;
1098
1099 /* Get session and tunnel contexts from the socket */
1100 session = pppol2tp_sock_to_session(sk);
1101 if (session == NULL)
1102 goto abort;
1103
1104 sk_tun = session->tunnel_sock;
1105 if (sk_tun == NULL)
1106 goto abort_put_sess;
1107 tunnel = pppol2tp_sock_to_tunnel(sk_tun);
1108 if (tunnel == NULL)
1109 goto abort_put_sess;
1110
1111 /* What header length is configured for this session? */
1112 hdr_len = pppol2tp_l2tp_header_len(session);
1113
1114 /* Check that there's enough headroom in the skb to insert IP,
1115 * UDP and L2TP and PPP headers. If not enough, expand it to
1116 * make room. Adjust truesize.
1117 */
1118 headroom = NET_SKB_PAD + sizeof(struct iphdr) +
1119 sizeof(struct udphdr) + hdr_len + sizeof(ppph);
1120 old_headroom = skb_headroom(skb);
1121 if (skb_cow_head(skb, headroom))
1122 goto abort_put_sess_tun;
1123
1124 new_headroom = skb_headroom(skb);
1125 skb_orphan(skb);
1126 skb->truesize += new_headroom - old_headroom;
1127
1128 /* Setup PPP header */
1129 __skb_push(skb, sizeof(ppph));
1130 skb->data[0] = ppph[0];
1131 skb->data[1] = ppph[1];
1132
1133 /* Setup L2TP header */
1134 pppol2tp_build_l2tp_header(session, __skb_push(skb, hdr_len));
1135
1136 udp_len = sizeof(struct udphdr) + hdr_len + sizeof(ppph) + data_len;
1137
1138 /* Setup UDP header */
1139 inet = inet_sk(sk_tun);
1140 __skb_push(skb, sizeof(*uh));
1141 skb_reset_transport_header(skb);
1142 uh = udp_hdr(skb);
1143 uh->source = inet->inet_sport;
1144 uh->dest = inet->inet_dport;
1145 uh->len = htons(udp_len);
1146 uh->check = 0;
1147
1148 /* Debug */
1149 if (session->send_seq)
1150 PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG,
1151 "%s: send %d bytes, ns=%hu\n", session->name,
1152 data_len, session->ns - 1);
1153 else
1154 PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG,
1155 "%s: send %d bytes\n", session->name, data_len);
1156
1157 if (session->debug & PPPOL2TP_MSG_DATA) {
1158 int i;
1159 unsigned char *datap = skb->data;
1160
1161 printk(KERN_DEBUG "%s: xmit:", session->name);
1162 for (i = 0; i < data_len; i++) {
1163 printk(" %02X", *datap++);
1164 if (i == 31) {
1165 printk(" ...");
1166 break;
1167 }
1168 }
1169 printk("\n");
1170 }
1171
1172 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
1173 IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED |
1174 IPSKB_REROUTED);
1175 nf_reset(skb);
1176
1177 /* Get routing info from the tunnel socket */
1178 skb_dst_drop(skb);
1179 skb_dst_set(skb, dst_clone(__sk_dst_get(sk_tun)));
1180 pppol2tp_skb_set_owner_w(skb, sk_tun);
1181
1182 /* Calculate UDP checksum if configured to do so */
1183 if (sk_tun->sk_no_check == UDP_CSUM_NOXMIT)
1184 skb->ip_summed = CHECKSUM_NONE;
1185 else if ((skb_dst(skb) && skb_dst(skb)->dev) &&
1186 (!(skb_dst(skb)->dev->features & NETIF_F_V4_CSUM))) {
1187 skb->ip_summed = CHECKSUM_COMPLETE;
1188 csum = skb_checksum(skb, 0, udp_len, 0);
1189 uh->check = csum_tcpudp_magic(inet->inet_saddr,
1190 inet->inet_daddr,
1191 udp_len, IPPROTO_UDP, csum);
1192 if (uh->check == 0)
1193 uh->check = CSUM_MANGLED_0;
1194 } else {
1195 skb->ip_summed = CHECKSUM_PARTIAL;
1196 skb->csum_start = skb_transport_header(skb) - skb->head;
1197 skb->csum_offset = offsetof(struct udphdr, check);
1198 uh->check = ~csum_tcpudp_magic(inet->inet_saddr,
1199 inet->inet_daddr,
1200 udp_len, IPPROTO_UDP, 0);
1201 }
1202
1203 /* Queue the packet to IP for output */
1204 len = skb->len;
1205 rc = ip_queue_xmit(skb, 1);
1206
1207 /* Update stats */
1208 if (rc >= 0) {
1209 tunnel->stats.tx_packets++;
1210 tunnel->stats.tx_bytes += len;
1211 session->stats.tx_packets++;
1212 session->stats.tx_bytes += len;
1213 } else {
1214 tunnel->stats.tx_errors++;
1215 session->stats.tx_errors++;
1216 }
1217
1218 sock_put(sk_tun);
1219 sock_put(sk);
1220 return 1;
1221
1222abort_put_sess_tun:
1223 sock_put(sk_tun);
1224abort_put_sess:
1225 sock_put(sk);
1226abort:
1227 /* Free the original skb */
1228 kfree_skb(skb);
1229 return 1;
1230}
1231
1232/*****************************************************************************
1233 * Session (and tunnel control) socket create/destroy.
1234 *****************************************************************************/
1235
1236/* When the tunnel UDP socket is closed, all the attached sockets need to go
1237 * too.
1238 */
1239static void pppol2tp_tunnel_closeall(struct pppol2tp_tunnel *tunnel)
1240{
1241 int hash;
1242 struct hlist_node *walk;
1243 struct hlist_node *tmp;
1244 struct pppol2tp_session *session;
1245 struct sock *sk;
1246
1247 BUG_ON(tunnel == NULL);
1248
1249 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1250 "%s: closing all sessions...\n", tunnel->name);
1251
1252 write_lock_bh(&tunnel->hlist_lock);
1253 for (hash = 0; hash < PPPOL2TP_HASH_SIZE; hash++) {
1254again:
1255 hlist_for_each_safe(walk, tmp, &tunnel->session_hlist[hash]) {
1256 struct sk_buff *skb;
1257
1258 session = hlist_entry(walk, struct pppol2tp_session, hlist);
1259
1260 sk = session->sock;
1261
1262 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1263 "%s: closing session\n", session->name);
1264
1265 hlist_del_init(&session->hlist);
1266
1267 /* Since we should hold the sock lock while
1268 * doing any unbinding, we need to release the
1269 * lock we're holding before taking that lock.
1270 * Hold a reference to the sock so it doesn't
1271 * disappear as we're jumping between locks.
1272 */
1273 sock_hold(sk);
1274 write_unlock_bh(&tunnel->hlist_lock);
1275 lock_sock(sk);
1276
1277 if (sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND)) {
1278 pppox_unbind_sock(sk);
1279 sk->sk_state = PPPOX_DEAD;
1280 sk->sk_state_change(sk);
1281 }
1282
1283 /* Purge any queued data */
1284 skb_queue_purge(&sk->sk_receive_queue);
1285 skb_queue_purge(&sk->sk_write_queue);
1286 while ((skb = skb_dequeue(&session->reorder_q))) {
1287 kfree_skb(skb);
1288 sock_put(sk);
1289 }
1290
1291 release_sock(sk);
1292 sock_put(sk);
1293
1294 /* Now restart from the beginning of this hash
1295 * chain. We always remove a session from the
1296 * list so we are guaranteed to make forward
1297 * progress.
1298 */
1299 write_lock_bh(&tunnel->hlist_lock);
1300 goto again;
1301 }
1302 }
1303 write_unlock_bh(&tunnel->hlist_lock);
1304}
1305
1306/* Really kill the tunnel.
1307 * Come here only when all sessions have been cleared from the tunnel.
1308 */
1309static void pppol2tp_tunnel_free(struct pppol2tp_tunnel *tunnel)
1310{
1311 struct pppol2tp_net *pn = pppol2tp_pernet(tunnel->pppol2tp_net);
1312
1313 /* Remove from socket list */
1314 write_lock_bh(&pn->pppol2tp_tunnel_list_lock);
1315 list_del_init(&tunnel->list);
1316 write_unlock_bh(&pn->pppol2tp_tunnel_list_lock);
1317
1318 atomic_dec(&pppol2tp_tunnel_count);
1319 kfree(tunnel);
1320}
1321
1322/* Tunnel UDP socket destruct hook.
1323 * The tunnel context is deleted only when all session sockets have been
1324 * closed.
1325 */
1326static void pppol2tp_tunnel_destruct(struct sock *sk)
1327{
1328 struct pppol2tp_tunnel *tunnel;
1329
1330 tunnel = sk->sk_user_data;
1331 if (tunnel == NULL)
1332 goto end;
1333
1334 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1335 "%s: closing...\n", tunnel->name);
1336
1337 /* Close all sessions */
1338 pppol2tp_tunnel_closeall(tunnel);
1339
1340 /* No longer an encapsulation socket. See net/ipv4/udp.c */
1341 (udp_sk(sk))->encap_type = 0;
1342 (udp_sk(sk))->encap_rcv = NULL;
1343
1344 /* Remove hooks into tunnel socket */
1345 tunnel->sock = NULL;
1346 sk->sk_destruct = tunnel->old_sk_destruct;
1347 sk->sk_user_data = NULL;
1348
1349 /* Call original (UDP) socket descructor */
1350 if (sk->sk_destruct != NULL)
1351 (*sk->sk_destruct)(sk);
1352
1353 pppol2tp_tunnel_dec_refcount(tunnel);
1354
1355end:
1356 return;
1357}
1358
1359/* Really kill the session socket. (Called from sock_put() if
1360 * refcnt == 0.)
1361 */
1362static void pppol2tp_session_destruct(struct sock *sk)
1363{
1364 struct pppol2tp_session *session = NULL;
1365
1366 if (sk->sk_user_data != NULL) {
1367 struct pppol2tp_tunnel *tunnel;
1368
1369 session = sk->sk_user_data;
1370 if (session == NULL)
1371 goto out;
1372
1373 BUG_ON(session->magic != L2TP_SESSION_MAGIC);
1374
1375 /* Don't use pppol2tp_sock_to_tunnel() here to
1376 * get the tunnel context because the tunnel
1377 * socket might have already been closed (its
1378 * sk->sk_user_data will be NULL) so use the
1379 * session's private tunnel ptr instead.
1380 */
1381 tunnel = session->tunnel;
1382 if (tunnel != NULL) {
1383 BUG_ON(tunnel->magic != L2TP_TUNNEL_MAGIC);
1384
1385 /* If session_id is zero, this is a null
1386 * session context, which was created for a
1387 * socket that is being used only to manage
1388 * tunnels.
1389 */
1390 if (session->tunnel_addr.s_session != 0) {
1391 /* Delete the session socket from the
1392 * hash
1393 */
1394 write_lock_bh(&tunnel->hlist_lock);
1395 hlist_del_init(&session->hlist);
1396 write_unlock_bh(&tunnel->hlist_lock);
1397
1398 atomic_dec(&pppol2tp_session_count);
1399 }
1400
1401 /* This will delete the tunnel context if this
1402 * is the last session on the tunnel.
1403 */
1404 session->tunnel = NULL;
1405 session->tunnel_sock = NULL;
1406 pppol2tp_tunnel_dec_refcount(tunnel);
1407 }
1408 }
1409
1410 kfree(session);
1411out:
1412 return;
1413}
1414
1415/* Called when the PPPoX socket (session) is closed.
1416 */
1417static int pppol2tp_release(struct socket *sock)
1418{
1419 struct sock *sk = sock->sk;
1420 struct pppol2tp_session *session;
1421 int error;
1422
1423 if (!sk)
1424 return 0;
1425
1426 error = -EBADF;
1427 lock_sock(sk);
1428 if (sock_flag(sk, SOCK_DEAD) != 0)
1429 goto error;
1430
1431 pppox_unbind_sock(sk);
1432
1433 /* Signal the death of the socket. */
1434 sk->sk_state = PPPOX_DEAD;
1435 sock_orphan(sk);
1436 sock->sk = NULL;
1437
1438 session = pppol2tp_sock_to_session(sk);
1439
1440 /* Purge any queued data */
1441 skb_queue_purge(&sk->sk_receive_queue);
1442 skb_queue_purge(&sk->sk_write_queue);
1443 if (session != NULL) {
1444 struct sk_buff *skb;
1445 while ((skb = skb_dequeue(&session->reorder_q))) {
1446 kfree_skb(skb);
1447 sock_put(sk);
1448 }
1449 sock_put(sk);
1450 }
1451
1452 release_sock(sk);
1453
1454 /* This will delete the session context via
1455 * pppol2tp_session_destruct() if the socket's refcnt drops to
1456 * zero.
1457 */
1458 sock_put(sk);
1459
1460 return 0;
1461
1462error:
1463 release_sock(sk);
1464 return error;
1465}
1466
1467/* Internal function to prepare a tunnel (UDP) socket to have PPPoX
1468 * sockets attached to it.
1469 */
1470static struct sock *pppol2tp_prepare_tunnel_socket(struct net *net,
1471 int fd, u16 tunnel_id, int *error)
1472{
1473 int err;
1474 struct socket *sock = NULL;
1475 struct sock *sk;
1476 struct pppol2tp_tunnel *tunnel;
1477 struct pppol2tp_net *pn;
1478 struct sock *ret = NULL;
1479
1480 /* Get the tunnel UDP socket from the fd, which was opened by
1481 * the userspace L2TP daemon.
1482 */
1483 err = -EBADF;
1484 sock = sockfd_lookup(fd, &err);
1485 if (!sock) {
1486 PRINTK(-1, PPPOL2TP_MSG_CONTROL, KERN_ERR,
1487 "tunl %hu: sockfd_lookup(fd=%d) returned %d\n",
1488 tunnel_id, fd, err);
1489 goto err;
1490 }
1491
1492 sk = sock->sk;
1493
1494 /* Quick sanity checks */
1495 err = -EPROTONOSUPPORT;
1496 if (sk->sk_protocol != IPPROTO_UDP) {
1497 PRINTK(-1, PPPOL2TP_MSG_CONTROL, KERN_ERR,
1498 "tunl %hu: fd %d wrong protocol, got %d, expected %d\n",
1499 tunnel_id, fd, sk->sk_protocol, IPPROTO_UDP);
1500 goto err;
1501 }
1502 err = -EAFNOSUPPORT;
1503 if (sock->ops->family != AF_INET) {
1504 PRINTK(-1, PPPOL2TP_MSG_CONTROL, KERN_ERR,
1505 "tunl %hu: fd %d wrong family, got %d, expected %d\n",
1506 tunnel_id, fd, sock->ops->family, AF_INET);
1507 goto err;
1508 }
1509
1510 err = -ENOTCONN;
1511
1512 /* Check if this socket has already been prepped */
1513 tunnel = (struct pppol2tp_tunnel *)sk->sk_user_data;
1514 if (tunnel != NULL) {
1515 /* User-data field already set */
1516 err = -EBUSY;
1517 BUG_ON(tunnel->magic != L2TP_TUNNEL_MAGIC);
1518
1519 /* This socket has already been prepped */
1520 ret = tunnel->sock;
1521 goto out;
1522 }
1523
1524 /* This socket is available and needs prepping. Create a new tunnel
1525 * context and init it.
1526 */
1527 sk->sk_user_data = tunnel = kzalloc(sizeof(struct pppol2tp_tunnel), GFP_KERNEL);
1528 if (sk->sk_user_data == NULL) {
1529 err = -ENOMEM;
1530 goto err;
1531 }
1532
1533 tunnel->magic = L2TP_TUNNEL_MAGIC;
1534 sprintf(&tunnel->name[0], "tunl %hu", tunnel_id);
1535
1536 tunnel->stats.tunnel_id = tunnel_id;
1537 tunnel->debug = PPPOL2TP_DEFAULT_DEBUG_FLAGS;
1538
1539 /* Hook on the tunnel socket destructor so that we can cleanup
1540 * if the tunnel socket goes away.
1541 */
1542 tunnel->old_sk_destruct = sk->sk_destruct;
1543 sk->sk_destruct = pppol2tp_tunnel_destruct;
1544
1545 tunnel->sock = sk;
1546 sk->sk_allocation = GFP_ATOMIC;
1547
1548 /* Misc init */
1549 rwlock_init(&tunnel->hlist_lock);
1550
1551 /* The net we belong to */
1552 tunnel->pppol2tp_net = net;
1553 pn = pppol2tp_pernet(net);
1554
1555 /* Add tunnel to our list */
1556 INIT_LIST_HEAD(&tunnel->list);
1557 write_lock_bh(&pn->pppol2tp_tunnel_list_lock);
1558 list_add(&tunnel->list, &pn->pppol2tp_tunnel_list);
1559 write_unlock_bh(&pn->pppol2tp_tunnel_list_lock);
1560 atomic_inc(&pppol2tp_tunnel_count);
1561
1562 /* Bump the reference count. The tunnel context is deleted
1563 * only when this drops to zero.
1564 */
1565 pppol2tp_tunnel_inc_refcount(tunnel);
1566
1567 /* Mark socket as an encapsulation socket. See net/ipv4/udp.c */
1568 (udp_sk(sk))->encap_type = UDP_ENCAP_L2TPINUDP;
1569 (udp_sk(sk))->encap_rcv = pppol2tp_udp_encap_recv;
1570
1571 ret = tunnel->sock;
1572
1573 *error = 0;
1574out:
1575 if (sock)
1576 sockfd_put(sock);
1577
1578 return ret;
1579
1580err:
1581 *error = err;
1582 goto out;
1583}
1584
1585static struct proto pppol2tp_sk_proto = {
1586 .name = "PPPOL2TP",
1587 .owner = THIS_MODULE,
1588 .obj_size = sizeof(struct pppox_sock),
1589};
1590
1591/* socket() handler. Initialize a new struct sock.
1592 */
1593static int pppol2tp_create(struct net *net, struct socket *sock)
1594{
1595 int error = -ENOMEM;
1596 struct sock *sk;
1597
1598 sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppol2tp_sk_proto);
1599 if (!sk)
1600 goto out;
1601
1602 sock_init_data(sock, sk);
1603
1604 sock->state = SS_UNCONNECTED;
1605 sock->ops = &pppol2tp_ops;
1606
1607 sk->sk_backlog_rcv = pppol2tp_recv_core;
1608 sk->sk_protocol = PX_PROTO_OL2TP;
1609 sk->sk_family = PF_PPPOX;
1610 sk->sk_state = PPPOX_NONE;
1611 sk->sk_type = SOCK_STREAM;
1612 sk->sk_destruct = pppol2tp_session_destruct;
1613
1614 error = 0;
1615
1616out:
1617 return error;
1618}
1619
1620/* connect() handler. Attach a PPPoX socket to a tunnel UDP socket
1621 */
1622static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
1623 int sockaddr_len, int flags)
1624{
1625 struct sock *sk = sock->sk;
1626 struct sockaddr_pppol2tp *sp = (struct sockaddr_pppol2tp *) uservaddr;
1627 struct pppox_sock *po = pppox_sk(sk);
1628 struct sock *tunnel_sock = NULL;
1629 struct pppol2tp_session *session = NULL;
1630 struct pppol2tp_tunnel *tunnel;
1631 struct dst_entry *dst;
1632 int error = 0;
1633
1634 lock_sock(sk);
1635
1636 error = -EINVAL;
1637 if (sp->sa_protocol != PX_PROTO_OL2TP)
1638 goto end;
1639
1640 /* Check for already bound sockets */
1641 error = -EBUSY;
1642 if (sk->sk_state & PPPOX_CONNECTED)
1643 goto end;
1644
1645 /* We don't supporting rebinding anyway */
1646 error = -EALREADY;
1647 if (sk->sk_user_data)
1648 goto end; /* socket is already attached */
1649
1650 /* Don't bind if s_tunnel is 0 */
1651 error = -EINVAL;
1652 if (sp->pppol2tp.s_tunnel == 0)
1653 goto end;
1654
1655 /* Special case: prepare tunnel socket if s_session and
1656 * d_session is 0. Otherwise look up tunnel using supplied
1657 * tunnel id.
1658 */
1659 if ((sp->pppol2tp.s_session == 0) && (sp->pppol2tp.d_session == 0)) {
1660 tunnel_sock = pppol2tp_prepare_tunnel_socket(sock_net(sk),
1661 sp->pppol2tp.fd,
1662 sp->pppol2tp.s_tunnel,
1663 &error);
1664 if (tunnel_sock == NULL)
1665 goto end;
1666
1667 sock_hold(tunnel_sock);
1668 tunnel = tunnel_sock->sk_user_data;
1669 } else {
1670 tunnel = pppol2tp_tunnel_find(sock_net(sk), sp->pppol2tp.s_tunnel);
1671
1672 /* Error if we can't find the tunnel */
1673 error = -ENOENT;
1674 if (tunnel == NULL)
1675 goto end;
1676
1677 tunnel_sock = tunnel->sock;
1678 }
1679
1680 /* Check that this session doesn't already exist */
1681 error = -EEXIST;
1682 session = pppol2tp_session_find(tunnel, sp->pppol2tp.s_session);
1683 if (session != NULL)
1684 goto end;
1685
1686 /* Allocate and initialize a new session context. */
1687 session = kzalloc(sizeof(struct pppol2tp_session), GFP_KERNEL);
1688 if (session == NULL) {
1689 error = -ENOMEM;
1690 goto end;
1691 }
1692
1693 skb_queue_head_init(&session->reorder_q);
1694
1695 session->magic = L2TP_SESSION_MAGIC;
1696 session->owner = current->pid;
1697 session->sock = sk;
1698 session->tunnel = tunnel;
1699 session->tunnel_sock = tunnel_sock;
1700 session->tunnel_addr = sp->pppol2tp;
1701 sprintf(&session->name[0], "sess %hu/%hu",
1702 session->tunnel_addr.s_tunnel,
1703 session->tunnel_addr.s_session);
1704
1705 session->stats.tunnel_id = session->tunnel_addr.s_tunnel;
1706 session->stats.session_id = session->tunnel_addr.s_session;
1707
1708 INIT_HLIST_NODE(&session->hlist);
1709
1710 /* Inherit debug options from tunnel */
1711 session->debug = tunnel->debug;
1712
1713 /* Default MTU must allow space for UDP/L2TP/PPP
1714 * headers.
1715 */
1716 session->mtu = session->mru = 1500 - PPPOL2TP_HEADER_OVERHEAD;
1717
1718 /* If PMTU discovery was enabled, use the MTU that was discovered */
1719 dst = sk_dst_get(sk);
1720 if (dst != NULL) {
1721 u32 pmtu = dst_mtu(__sk_dst_get(sk));
1722 if (pmtu != 0)
1723 session->mtu = session->mru = pmtu -
1724 PPPOL2TP_HEADER_OVERHEAD;
1725 dst_release(dst);
1726 }
1727
1728 /* Special case: if source & dest session_id == 0x0000, this socket is
1729 * being created to manage the tunnel. Don't add the session to the
1730 * session hash list, just set up the internal context for use by
1731 * ioctl() and sockopt() handlers.
1732 */
1733 if ((session->tunnel_addr.s_session == 0) &&
1734 (session->tunnel_addr.d_session == 0)) {
1735 error = 0;
1736 sk->sk_user_data = session;
1737 goto out_no_ppp;
1738 }
1739
1740 /* Get tunnel context from the tunnel socket */
1741 tunnel = pppol2tp_sock_to_tunnel(tunnel_sock);
1742 if (tunnel == NULL) {
1743 error = -EBADF;
1744 goto end;
1745 }
1746
1747 /* Right now, because we don't have a way to push the incoming skb's
1748 * straight through the UDP layer, the only header we need to worry
1749 * about is the L2TP header. This size is different depending on
1750 * whether sequence numbers are enabled for the data channel.
1751 */
1752 po->chan.hdrlen = PPPOL2TP_L2TP_HDR_SIZE_NOSEQ;
1753
1754 po->chan.private = sk;
1755 po->chan.ops = &pppol2tp_chan_ops;
1756 po->chan.mtu = session->mtu;
1757
1758 error = ppp_register_net_channel(sock_net(sk), &po->chan);
1759 if (error)
1760 goto end_put_tun;
1761
1762 /* This is how we get the session context from the socket. */
1763 sk->sk_user_data = session;
1764
1765 /* Add session to the tunnel's hash list */
1766 write_lock_bh(&tunnel->hlist_lock);
1767 hlist_add_head(&session->hlist,
1768 pppol2tp_session_id_hash(tunnel,
1769 session->tunnel_addr.s_session));
1770 write_unlock_bh(&tunnel->hlist_lock);
1771
1772 atomic_inc(&pppol2tp_session_count);
1773
1774out_no_ppp:
1775 pppol2tp_tunnel_inc_refcount(tunnel);
1776 sk->sk_state = PPPOX_CONNECTED;
1777 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1778 "%s: created\n", session->name);
1779
1780end_put_tun:
1781 sock_put(tunnel_sock);
1782end:
1783 release_sock(sk);
1784
1785 if (error != 0) {
1786 if (session)
1787 PRINTK(session->debug,
1788 PPPOL2TP_MSG_CONTROL, KERN_WARNING,
1789 "%s: connect failed: %d\n",
1790 session->name, error);
1791 else
1792 PRINTK(-1, PPPOL2TP_MSG_CONTROL, KERN_WARNING,
1793 "connect failed: %d\n", error);
1794 }
1795
1796 return error;
1797}
1798
1799/* getname() support.
1800 */
1801static int pppol2tp_getname(struct socket *sock, struct sockaddr *uaddr,
1802 int *usockaddr_len, int peer)
1803{
1804 int len = sizeof(struct sockaddr_pppol2tp);
1805 struct sockaddr_pppol2tp sp;
1806 int error = 0;
1807 struct pppol2tp_session *session;
1808
1809 error = -ENOTCONN;
1810 if (sock->sk->sk_state != PPPOX_CONNECTED)
1811 goto end;
1812
1813 session = pppol2tp_sock_to_session(sock->sk);
1814 if (session == NULL) {
1815 error = -EBADF;
1816 goto end;
1817 }
1818
1819 sp.sa_family = AF_PPPOX;
1820 sp.sa_protocol = PX_PROTO_OL2TP;
1821 memcpy(&sp.pppol2tp, &session->tunnel_addr,
1822 sizeof(struct pppol2tp_addr));
1823
1824 memcpy(uaddr, &sp, len);
1825
1826 *usockaddr_len = len;
1827
1828 error = 0;
1829 sock_put(sock->sk);
1830
1831end:
1832 return error;
1833}
1834
1835/****************************************************************************
1836 * ioctl() handlers.
1837 *
1838 * The PPPoX socket is created for L2TP sessions: tunnels have their own UDP
1839 * sockets. However, in order to control kernel tunnel features, we allow
1840 * userspace to create a special "tunnel" PPPoX socket which is used for
1841 * control only. Tunnel PPPoX sockets have session_id == 0 and simply allow
1842 * the user application to issue L2TP setsockopt(), getsockopt() and ioctl()
1843 * calls.
1844 ****************************************************************************/
1845
1846/* Session ioctl helper.
1847 */
1848static int pppol2tp_session_ioctl(struct pppol2tp_session *session,
1849 unsigned int cmd, unsigned long arg)
1850{
1851 struct ifreq ifr;
1852 int err = 0;
1853 struct sock *sk = session->sock;
1854 int val = (int) arg;
1855
1856 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_DEBUG,
1857 "%s: pppol2tp_session_ioctl(cmd=%#x, arg=%#lx)\n",
1858 session->name, cmd, arg);
1859
1860 sock_hold(sk);
1861
1862 switch (cmd) {
1863 case SIOCGIFMTU:
1864 err = -ENXIO;
1865 if (!(sk->sk_state & PPPOX_CONNECTED))
1866 break;
1867
1868 err = -EFAULT;
1869 if (copy_from_user(&ifr, (void __user *) arg, sizeof(struct ifreq)))
1870 break;
1871 ifr.ifr_mtu = session->mtu;
1872 if (copy_to_user((void __user *) arg, &ifr, sizeof(struct ifreq)))
1873 break;
1874
1875 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1876 "%s: get mtu=%d\n", session->name, session->mtu);
1877 err = 0;
1878 break;
1879
1880 case SIOCSIFMTU:
1881 err = -ENXIO;
1882 if (!(sk->sk_state & PPPOX_CONNECTED))
1883 break;
1884
1885 err = -EFAULT;
1886 if (copy_from_user(&ifr, (void __user *) arg, sizeof(struct ifreq)))
1887 break;
1888
1889 session->mtu = ifr.ifr_mtu;
1890
1891 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1892 "%s: set mtu=%d\n", session->name, session->mtu);
1893 err = 0;
1894 break;
1895
1896 case PPPIOCGMRU:
1897 err = -ENXIO;
1898 if (!(sk->sk_state & PPPOX_CONNECTED))
1899 break;
1900
1901 err = -EFAULT;
1902 if (put_user(session->mru, (int __user *) arg))
1903 break;
1904
1905 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1906 "%s: get mru=%d\n", session->name, session->mru);
1907 err = 0;
1908 break;
1909
1910 case PPPIOCSMRU:
1911 err = -ENXIO;
1912 if (!(sk->sk_state & PPPOX_CONNECTED))
1913 break;
1914
1915 err = -EFAULT;
1916 if (get_user(val,(int __user *) arg))
1917 break;
1918
1919 session->mru = val;
1920 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1921 "%s: set mru=%d\n", session->name, session->mru);
1922 err = 0;
1923 break;
1924
1925 case PPPIOCGFLAGS:
1926 err = -EFAULT;
1927 if (put_user(session->flags, (int __user *) arg))
1928 break;
1929
1930 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1931 "%s: get flags=%d\n", session->name, session->flags);
1932 err = 0;
1933 break;
1934
1935 case PPPIOCSFLAGS:
1936 err = -EFAULT;
1937 if (get_user(val, (int __user *) arg))
1938 break;
1939 session->flags = val;
1940 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1941 "%s: set flags=%d\n", session->name, session->flags);
1942 err = 0;
1943 break;
1944
1945 case PPPIOCGL2TPSTATS:
1946 err = -ENXIO;
1947 if (!(sk->sk_state & PPPOX_CONNECTED))
1948 break;
1949
1950 if (copy_to_user((void __user *) arg, &session->stats,
1951 sizeof(session->stats)))
1952 break;
1953 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
1954 "%s: get L2TP stats\n", session->name);
1955 err = 0;
1956 break;
1957
1958 default:
1959 err = -ENOSYS;
1960 break;
1961 }
1962
1963 sock_put(sk);
1964
1965 return err;
1966}
1967
1968/* Tunnel ioctl helper.
1969 *
1970 * Note the special handling for PPPIOCGL2TPSTATS below. If the ioctl data
1971 * specifies a session_id, the session ioctl handler is called. This allows an
1972 * application to retrieve session stats via a tunnel socket.
1973 */
1974static int pppol2tp_tunnel_ioctl(struct pppol2tp_tunnel *tunnel,
1975 unsigned int cmd, unsigned long arg)
1976{
1977 int err = 0;
1978 struct sock *sk = tunnel->sock;
1979 struct pppol2tp_ioc_stats stats_req;
1980
1981 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_DEBUG,
1982 "%s: pppol2tp_tunnel_ioctl(cmd=%#x, arg=%#lx)\n", tunnel->name,
1983 cmd, arg);
1984
1985 sock_hold(sk);
1986
1987 switch (cmd) {
1988 case PPPIOCGL2TPSTATS:
1989 err = -ENXIO;
1990 if (!(sk->sk_state & PPPOX_CONNECTED))
1991 break;
1992
1993 if (copy_from_user(&stats_req, (void __user *) arg,
1994 sizeof(stats_req))) {
1995 err = -EFAULT;
1996 break;
1997 }
1998 if (stats_req.session_id != 0) {
1999 /* resend to session ioctl handler */
2000 struct pppol2tp_session *session =
2001 pppol2tp_session_find(tunnel, stats_req.session_id);
2002 if (session != NULL)
2003 err = pppol2tp_session_ioctl(session, cmd, arg);
2004 else
2005 err = -EBADR;
2006 break;
2007 }
2008#ifdef CONFIG_XFRM
2009 tunnel->stats.using_ipsec = (sk->sk_policy[0] || sk->sk_policy[1]) ? 1 : 0;
2010#endif
2011 if (copy_to_user((void __user *) arg, &tunnel->stats,
2012 sizeof(tunnel->stats))) {
2013 err = -EFAULT;
2014 break;
2015 }
2016 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2017 "%s: get L2TP stats\n", tunnel->name);
2018 err = 0;
2019 break;
2020
2021 default:
2022 err = -ENOSYS;
2023 break;
2024 }
2025
2026 sock_put(sk);
2027
2028 return err;
2029}
2030
2031/* Main ioctl() handler.
2032 * Dispatch to tunnel or session helpers depending on the socket.
2033 */
2034static int pppol2tp_ioctl(struct socket *sock, unsigned int cmd,
2035 unsigned long arg)
2036{
2037 struct sock *sk = sock->sk;
2038 struct pppol2tp_session *session;
2039 struct pppol2tp_tunnel *tunnel;
2040 int err;
2041
2042 if (!sk)
2043 return 0;
2044
2045 err = -EBADF;
2046 if (sock_flag(sk, SOCK_DEAD) != 0)
2047 goto end;
2048
2049 err = -ENOTCONN;
2050 if ((sk->sk_user_data == NULL) ||
2051 (!(sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND))))
2052 goto end;
2053
2054 /* Get session context from the socket */
2055 err = -EBADF;
2056 session = pppol2tp_sock_to_session(sk);
2057 if (session == NULL)
2058 goto end;
2059
2060 /* Special case: if session's session_id is zero, treat ioctl as a
2061 * tunnel ioctl
2062 */
2063 if ((session->tunnel_addr.s_session == 0) &&
2064 (session->tunnel_addr.d_session == 0)) {
2065 err = -EBADF;
2066 tunnel = pppol2tp_sock_to_tunnel(session->tunnel_sock);
2067 if (tunnel == NULL)
2068 goto end_put_sess;
2069
2070 err = pppol2tp_tunnel_ioctl(tunnel, cmd, arg);
2071 sock_put(session->tunnel_sock);
2072 goto end_put_sess;
2073 }
2074
2075 err = pppol2tp_session_ioctl(session, cmd, arg);
2076
2077end_put_sess:
2078 sock_put(sk);
2079end:
2080 return err;
2081}
2082
2083/*****************************************************************************
2084 * setsockopt() / getsockopt() support.
2085 *
2086 * The PPPoX socket is created for L2TP sessions: tunnels have their own UDP
2087 * sockets. In order to control kernel tunnel features, we allow userspace to
2088 * create a special "tunnel" PPPoX socket which is used for control only.
2089 * Tunnel PPPoX sockets have session_id == 0 and simply allow the user
2090 * application to issue L2TP setsockopt(), getsockopt() and ioctl() calls.
2091 *****************************************************************************/
2092
2093/* Tunnel setsockopt() helper.
2094 */
2095static int pppol2tp_tunnel_setsockopt(struct sock *sk,
2096 struct pppol2tp_tunnel *tunnel,
2097 int optname, int val)
2098{
2099 int err = 0;
2100
2101 switch (optname) {
2102 case PPPOL2TP_SO_DEBUG:
2103 tunnel->debug = val;
2104 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2105 "%s: set debug=%x\n", tunnel->name, tunnel->debug);
2106 break;
2107
2108 default:
2109 err = -ENOPROTOOPT;
2110 break;
2111 }
2112
2113 return err;
2114}
2115
2116/* Session setsockopt helper.
2117 */
2118static int pppol2tp_session_setsockopt(struct sock *sk,
2119 struct pppol2tp_session *session,
2120 int optname, int val)
2121{
2122 int err = 0;
2123
2124 switch (optname) {
2125 case PPPOL2TP_SO_RECVSEQ:
2126 if ((val != 0) && (val != 1)) {
2127 err = -EINVAL;
2128 break;
2129 }
2130 session->recv_seq = val ? -1 : 0;
2131 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2132 "%s: set recv_seq=%d\n", session->name,
2133 session->recv_seq);
2134 break;
2135
2136 case PPPOL2TP_SO_SENDSEQ:
2137 if ((val != 0) && (val != 1)) {
2138 err = -EINVAL;
2139 break;
2140 }
2141 session->send_seq = val ? -1 : 0;
2142 {
2143 struct sock *ssk = session->sock;
2144 struct pppox_sock *po = pppox_sk(ssk);
2145 po->chan.hdrlen = val ? PPPOL2TP_L2TP_HDR_SIZE_SEQ :
2146 PPPOL2TP_L2TP_HDR_SIZE_NOSEQ;
2147 }
2148 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2149 "%s: set send_seq=%d\n", session->name, session->send_seq);
2150 break;
2151
2152 case PPPOL2TP_SO_LNSMODE:
2153 if ((val != 0) && (val != 1)) {
2154 err = -EINVAL;
2155 break;
2156 }
2157 session->lns_mode = val ? -1 : 0;
2158 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2159 "%s: set lns_mode=%d\n", session->name,
2160 session->lns_mode);
2161 break;
2162
2163 case PPPOL2TP_SO_DEBUG:
2164 session->debug = val;
2165 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2166 "%s: set debug=%x\n", session->name, session->debug);
2167 break;
2168
2169 case PPPOL2TP_SO_REORDERTO:
2170 session->reorder_timeout = msecs_to_jiffies(val);
2171 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2172 "%s: set reorder_timeout=%d\n", session->name,
2173 session->reorder_timeout);
2174 break;
2175
2176 default:
2177 err = -ENOPROTOOPT;
2178 break;
2179 }
2180
2181 return err;
2182}
2183
2184/* Main setsockopt() entry point.
2185 * Does API checks, then calls either the tunnel or session setsockopt
2186 * handler, according to whether the PPPoL2TP socket is a for a regular
2187 * session or the special tunnel type.
2188 */
2189static int pppol2tp_setsockopt(struct socket *sock, int level, int optname,
2190 char __user *optval, unsigned int optlen)
2191{
2192 struct sock *sk = sock->sk;
2193 struct pppol2tp_session *session = sk->sk_user_data;
2194 struct pppol2tp_tunnel *tunnel;
2195 int val;
2196 int err;
2197
2198 if (level != SOL_PPPOL2TP)
2199 return udp_prot.setsockopt(sk, level, optname, optval, optlen);
2200
2201 if (optlen < sizeof(int))
2202 return -EINVAL;
2203
2204 if (get_user(val, (int __user *)optval))
2205 return -EFAULT;
2206
2207 err = -ENOTCONN;
2208 if (sk->sk_user_data == NULL)
2209 goto end;
2210
2211 /* Get session context from the socket */
2212 err = -EBADF;
2213 session = pppol2tp_sock_to_session(sk);
2214 if (session == NULL)
2215 goto end;
2216
2217 /* Special case: if session_id == 0x0000, treat as operation on tunnel
2218 */
2219 if ((session->tunnel_addr.s_session == 0) &&
2220 (session->tunnel_addr.d_session == 0)) {
2221 err = -EBADF;
2222 tunnel = pppol2tp_sock_to_tunnel(session->tunnel_sock);
2223 if (tunnel == NULL)
2224 goto end_put_sess;
2225
2226 err = pppol2tp_tunnel_setsockopt(sk, tunnel, optname, val);
2227 sock_put(session->tunnel_sock);
2228 } else
2229 err = pppol2tp_session_setsockopt(sk, session, optname, val);
2230
2231 err = 0;
2232
2233end_put_sess:
2234 sock_put(sk);
2235end:
2236 return err;
2237}
2238
2239/* Tunnel getsockopt helper. Called with sock locked.
2240 */
2241static int pppol2tp_tunnel_getsockopt(struct sock *sk,
2242 struct pppol2tp_tunnel *tunnel,
2243 int optname, int *val)
2244{
2245 int err = 0;
2246
2247 switch (optname) {
2248 case PPPOL2TP_SO_DEBUG:
2249 *val = tunnel->debug;
2250 PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2251 "%s: get debug=%x\n", tunnel->name, tunnel->debug);
2252 break;
2253
2254 default:
2255 err = -ENOPROTOOPT;
2256 break;
2257 }
2258
2259 return err;
2260}
2261
2262/* Session getsockopt helper. Called with sock locked.
2263 */
2264static int pppol2tp_session_getsockopt(struct sock *sk,
2265 struct pppol2tp_session *session,
2266 int optname, int *val)
2267{
2268 int err = 0;
2269
2270 switch (optname) {
2271 case PPPOL2TP_SO_RECVSEQ:
2272 *val = session->recv_seq;
2273 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2274 "%s: get recv_seq=%d\n", session->name, *val);
2275 break;
2276
2277 case PPPOL2TP_SO_SENDSEQ:
2278 *val = session->send_seq;
2279 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2280 "%s: get send_seq=%d\n", session->name, *val);
2281 break;
2282
2283 case PPPOL2TP_SO_LNSMODE:
2284 *val = session->lns_mode;
2285 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2286 "%s: get lns_mode=%d\n", session->name, *val);
2287 break;
2288
2289 case PPPOL2TP_SO_DEBUG:
2290 *val = session->debug;
2291 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2292 "%s: get debug=%d\n", session->name, *val);
2293 break;
2294
2295 case PPPOL2TP_SO_REORDERTO:
2296 *val = (int) jiffies_to_msecs(session->reorder_timeout);
2297 PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
2298 "%s: get reorder_timeout=%d\n", session->name, *val);
2299 break;
2300
2301 default:
2302 err = -ENOPROTOOPT;
2303 }
2304
2305 return err;
2306}
2307
2308/* Main getsockopt() entry point.
2309 * Does API checks, then calls either the tunnel or session getsockopt
2310 * handler, according to whether the PPPoX socket is a for a regular session
2311 * or the special tunnel type.
2312 */
2313static int pppol2tp_getsockopt(struct socket *sock, int level,
2314 int optname, char __user *optval, int __user *optlen)
2315{
2316 struct sock *sk = sock->sk;
2317 struct pppol2tp_session *session = sk->sk_user_data;
2318 struct pppol2tp_tunnel *tunnel;
2319 int val, len;
2320 int err;
2321
2322 if (level != SOL_PPPOL2TP)
2323 return udp_prot.getsockopt(sk, level, optname, optval, optlen);
2324
2325 if (get_user(len, (int __user *) optlen))
2326 return -EFAULT;
2327
2328 len = min_t(unsigned int, len, sizeof(int));
2329
2330 if (len < 0)
2331 return -EINVAL;
2332
2333 err = -ENOTCONN;
2334 if (sk->sk_user_data == NULL)
2335 goto end;
2336
2337 /* Get the session context */
2338 err = -EBADF;
2339 session = pppol2tp_sock_to_session(sk);
2340 if (session == NULL)
2341 goto end;
2342
2343 /* Special case: if session_id == 0x0000, treat as operation on tunnel */
2344 if ((session->tunnel_addr.s_session == 0) &&
2345 (session->tunnel_addr.d_session == 0)) {
2346 err = -EBADF;
2347 tunnel = pppol2tp_sock_to_tunnel(session->tunnel_sock);
2348 if (tunnel == NULL)
2349 goto end_put_sess;
2350
2351 err = pppol2tp_tunnel_getsockopt(sk, tunnel, optname, &val);
2352 sock_put(session->tunnel_sock);
2353 } else
2354 err = pppol2tp_session_getsockopt(sk, session, optname, &val);
2355
2356 err = -EFAULT;
2357 if (put_user(len, (int __user *) optlen))
2358 goto end_put_sess;
2359
2360 if (copy_to_user((void __user *) optval, &val, len))
2361 goto end_put_sess;
2362
2363 err = 0;
2364
2365end_put_sess:
2366 sock_put(sk);
2367end:
2368 return err;
2369}
2370
2371/*****************************************************************************
2372 * /proc filesystem for debug
2373 *****************************************************************************/
2374
2375#ifdef CONFIG_PROC_FS
2376
2377#include <linux/seq_file.h>
2378
2379struct pppol2tp_seq_data {
2380 struct seq_net_private p;
2381 struct pppol2tp_tunnel *tunnel; /* current tunnel */
2382 struct pppol2tp_session *session; /* NULL means get first session in tunnel */
2383};
2384
2385static struct pppol2tp_session *next_session(struct pppol2tp_tunnel *tunnel, struct pppol2tp_session *curr)
2386{
2387 struct pppol2tp_session *session = NULL;
2388 struct hlist_node *walk;
2389 int found = 0;
2390 int next = 0;
2391 int i;
2392
2393 read_lock_bh(&tunnel->hlist_lock);
2394 for (i = 0; i < PPPOL2TP_HASH_SIZE; i++) {
2395 hlist_for_each_entry(session, walk, &tunnel->session_hlist[i], hlist) {
2396 if (curr == NULL) {
2397 found = 1;
2398 goto out;
2399 }
2400 if (session == curr) {
2401 next = 1;
2402 continue;
2403 }
2404 if (next) {
2405 found = 1;
2406 goto out;
2407 }
2408 }
2409 }
2410out:
2411 read_unlock_bh(&tunnel->hlist_lock);
2412 if (!found)
2413 session = NULL;
2414
2415 return session;
2416}
2417
2418static struct pppol2tp_tunnel *next_tunnel(struct pppol2tp_net *pn,
2419 struct pppol2tp_tunnel *curr)
2420{
2421 struct pppol2tp_tunnel *tunnel = NULL;
2422
2423 read_lock_bh(&pn->pppol2tp_tunnel_list_lock);
2424 if (list_is_last(&curr->list, &pn->pppol2tp_tunnel_list)) {
2425 goto out;
2426 }
2427 tunnel = list_entry(curr->list.next, struct pppol2tp_tunnel, list);
2428out:
2429 read_unlock_bh(&pn->pppol2tp_tunnel_list_lock);
2430
2431 return tunnel;
2432}
2433
2434static void *pppol2tp_seq_start(struct seq_file *m, loff_t *offs)
2435{
2436 struct pppol2tp_seq_data *pd = SEQ_START_TOKEN;
2437 struct pppol2tp_net *pn;
2438 loff_t pos = *offs;
2439
2440 if (!pos)
2441 goto out;
2442
2443 BUG_ON(m->private == NULL);
2444 pd = m->private;
2445 pn = pppol2tp_pernet(seq_file_net(m));
2446
2447 if (pd->tunnel == NULL) {
2448 if (!list_empty(&pn->pppol2tp_tunnel_list))
2449 pd->tunnel = list_entry(pn->pppol2tp_tunnel_list.next, struct pppol2tp_tunnel, list);
2450 } else {
2451 pd->session = next_session(pd->tunnel, pd->session);
2452 if (pd->session == NULL) {
2453 pd->tunnel = next_tunnel(pn, pd->tunnel);
2454 }
2455 }
2456
2457 /* NULL tunnel and session indicates end of list */
2458 if ((pd->tunnel == NULL) && (pd->session == NULL))
2459 pd = NULL;
2460
2461out:
2462 return pd;
2463}
2464
2465static void *pppol2tp_seq_next(struct seq_file *m, void *v, loff_t *pos)
2466{
2467 (*pos)++;
2468 return NULL;
2469}
2470
2471static void pppol2tp_seq_stop(struct seq_file *p, void *v)
2472{
2473 /* nothing to do */
2474}
2475
2476static void pppol2tp_seq_tunnel_show(struct seq_file *m, void *v)
2477{
2478 struct pppol2tp_tunnel *tunnel = v;
2479
2480 seq_printf(m, "\nTUNNEL '%s', %c %d\n",
2481 tunnel->name,
2482 (tunnel == tunnel->sock->sk_user_data) ? 'Y':'N',
2483 atomic_read(&tunnel->ref_count) - 1);
2484 seq_printf(m, " %08x %llu/%llu/%llu %llu/%llu/%llu\n",
2485 tunnel->debug,
2486 (unsigned long long)tunnel->stats.tx_packets,
2487 (unsigned long long)tunnel->stats.tx_bytes,
2488 (unsigned long long)tunnel->stats.tx_errors,
2489 (unsigned long long)tunnel->stats.rx_packets,
2490 (unsigned long long)tunnel->stats.rx_bytes,
2491 (unsigned long long)tunnel->stats.rx_errors);
2492}
2493
2494static void pppol2tp_seq_session_show(struct seq_file *m, void *v)
2495{
2496 struct pppol2tp_session *session = v;
2497
2498 seq_printf(m, " SESSION '%s' %08X/%d %04X/%04X -> "
2499 "%04X/%04X %d %c\n",
2500 session->name,
2501 ntohl(session->tunnel_addr.addr.sin_addr.s_addr),
2502 ntohs(session->tunnel_addr.addr.sin_port),
2503 session->tunnel_addr.s_tunnel,
2504 session->tunnel_addr.s_session,
2505 session->tunnel_addr.d_tunnel,
2506 session->tunnel_addr.d_session,
2507 session->sock->sk_state,
2508 (session == session->sock->sk_user_data) ?
2509 'Y' : 'N');
2510 seq_printf(m, " %d/%d/%c/%c/%s %08x %u\n",
2511 session->mtu, session->mru,
2512 session->recv_seq ? 'R' : '-',
2513 session->send_seq ? 'S' : '-',
2514 session->lns_mode ? "LNS" : "LAC",
2515 session->debug,
2516 jiffies_to_msecs(session->reorder_timeout));
2517 seq_printf(m, " %hu/%hu %llu/%llu/%llu %llu/%llu/%llu\n",
2518 session->nr, session->ns,
2519 (unsigned long long)session->stats.tx_packets,
2520 (unsigned long long)session->stats.tx_bytes,
2521 (unsigned long long)session->stats.tx_errors,
2522 (unsigned long long)session->stats.rx_packets,
2523 (unsigned long long)session->stats.rx_bytes,
2524 (unsigned long long)session->stats.rx_errors);
2525}
2526
2527static int pppol2tp_seq_show(struct seq_file *m, void *v)
2528{
2529 struct pppol2tp_seq_data *pd = v;
2530
2531 /* display header on line 1 */
2532 if (v == SEQ_START_TOKEN) {
2533 seq_puts(m, "PPPoL2TP driver info, " PPPOL2TP_DRV_VERSION "\n");
2534 seq_puts(m, "TUNNEL name, user-data-ok session-count\n");
2535 seq_puts(m, " debug tx-pkts/bytes/errs rx-pkts/bytes/errs\n");
2536 seq_puts(m, " SESSION name, addr/port src-tid/sid "
2537 "dest-tid/sid state user-data-ok\n");
2538 seq_puts(m, " mtu/mru/rcvseq/sendseq/lns debug reorderto\n");
2539 seq_puts(m, " nr/ns tx-pkts/bytes/errs rx-pkts/bytes/errs\n");
2540 goto out;
2541 }
2542
2543 /* Show the tunnel or session context.
2544 */
2545 if (pd->session == NULL)
2546 pppol2tp_seq_tunnel_show(m, pd->tunnel);
2547 else
2548 pppol2tp_seq_session_show(m, pd->session);
2549
2550out:
2551 return 0;
2552}
2553
2554static const struct seq_operations pppol2tp_seq_ops = {
2555 .start = pppol2tp_seq_start,
2556 .next = pppol2tp_seq_next,
2557 .stop = pppol2tp_seq_stop,
2558 .show = pppol2tp_seq_show,
2559};
2560
2561/* Called when our /proc file is opened. We allocate data for use when
2562 * iterating our tunnel / session contexts and store it in the private
2563 * data of the seq_file.
2564 */
2565static int pppol2tp_proc_open(struct inode *inode, struct file *file)
2566{
2567 return seq_open_net(inode, file, &pppol2tp_seq_ops,
2568 sizeof(struct pppol2tp_seq_data));
2569}
2570
2571static const struct file_operations pppol2tp_proc_fops = {
2572 .owner = THIS_MODULE,
2573 .open = pppol2tp_proc_open,
2574 .read = seq_read,
2575 .llseek = seq_lseek,
2576 .release = seq_release_net,
2577};
2578
2579#endif /* CONFIG_PROC_FS */
2580
2581/*****************************************************************************
2582 * Init and cleanup
2583 *****************************************************************************/
2584
2585static const struct proto_ops pppol2tp_ops = {
2586 .family = AF_PPPOX,
2587 .owner = THIS_MODULE,
2588 .release = pppol2tp_release,
2589 .bind = sock_no_bind,
2590 .connect = pppol2tp_connect,
2591 .socketpair = sock_no_socketpair,
2592 .accept = sock_no_accept,
2593 .getname = pppol2tp_getname,
2594 .poll = datagram_poll,
2595 .listen = sock_no_listen,
2596 .shutdown = sock_no_shutdown,
2597 .setsockopt = pppol2tp_setsockopt,
2598 .getsockopt = pppol2tp_getsockopt,
2599 .sendmsg = pppol2tp_sendmsg,
2600 .recvmsg = pppol2tp_recvmsg,
2601 .mmap = sock_no_mmap,
2602 .ioctl = pppox_ioctl,
2603};
2604
2605static struct pppox_proto pppol2tp_proto = {
2606 .create = pppol2tp_create,
2607 .ioctl = pppol2tp_ioctl
2608};
2609
2610static __net_init int pppol2tp_init_net(struct net *net)
2611{
2612 struct pppol2tp_net *pn = pppol2tp_pernet(net);
2613 struct proc_dir_entry *pde;
2614
2615 INIT_LIST_HEAD(&pn->pppol2tp_tunnel_list);
2616 rwlock_init(&pn->pppol2tp_tunnel_list_lock);
2617
2618 pde = proc_net_fops_create(net, "pppol2tp", S_IRUGO, &pppol2tp_proc_fops);
2619#ifdef CONFIG_PROC_FS
2620 if (!pde)
2621 return -ENOMEM;
2622#endif
2623
2624 return 0;
2625}
2626
2627static __net_exit void pppol2tp_exit_net(struct net *net)
2628{
2629 proc_net_remove(net, "pppol2tp");
2630}
2631
2632static struct pernet_operations pppol2tp_net_ops = {
2633 .init = pppol2tp_init_net,
2634 .exit = pppol2tp_exit_net,
2635 .id = &pppol2tp_net_id,
2636 .size = sizeof(struct pppol2tp_net),
2637};
2638
2639static int __init pppol2tp_init(void)
2640{
2641 int err;
2642
2643 err = proto_register(&pppol2tp_sk_proto, 0);
2644 if (err)
2645 goto out;
2646 err = register_pppox_proto(PX_PROTO_OL2TP, &pppol2tp_proto);
2647 if (err)
2648 goto out_unregister_pppol2tp_proto;
2649
2650 err = register_pernet_device(&pppol2tp_net_ops);
2651 if (err)
2652 goto out_unregister_pppox_proto;
2653
2654 printk(KERN_INFO "PPPoL2TP kernel driver, %s\n",
2655 PPPOL2TP_DRV_VERSION);
2656
2657out:
2658 return err;
2659out_unregister_pppox_proto:
2660 unregister_pppox_proto(PX_PROTO_OL2TP);
2661out_unregister_pppol2tp_proto:
2662 proto_unregister(&pppol2tp_sk_proto);
2663 goto out;
2664}
2665
2666static void __exit pppol2tp_exit(void)
2667{
2668 unregister_pppox_proto(PX_PROTO_OL2TP);
2669 unregister_pernet_device(&pppol2tp_net_ops);
2670 proto_unregister(&pppol2tp_sk_proto);
2671}
2672
2673module_init(pppol2tp_init);
2674module_exit(pppol2tp_exit);
2675
2676MODULE_AUTHOR("Martijn van Oosterhout <kleptog@svana.org>, "
2677 "James Chapman <jchapman@katalix.com>");
2678MODULE_DESCRIPTION("PPP over L2TP over UDP");
2679MODULE_LICENSE("GPL");
2680MODULE_VERSION(PPPOL2TP_DRV_VERSION);
diff --git a/drivers/net/ps3_gelic_net.c b/drivers/net/ps3_gelic_net.c
index a849f6f23a17..fed5df9c5ea1 100644
--- a/drivers/net/ps3_gelic_net.c
+++ b/drivers/net/ps3_gelic_net.c
@@ -326,7 +326,7 @@ static int gelic_descr_prepare_rx(struct gelic_card *card,
326 unsigned int bufsize; 326 unsigned int bufsize;
327 327
328 if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE) 328 if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE)
329 dev_info(ctodev(card), "%s: ERROR status \n", __func__); 329 dev_info(ctodev(card), "%s: ERROR status\n", __func__);
330 /* we need to round up the buffer size to a multiple of 128 */ 330 /* we need to round up the buffer size to a multiple of 128 */
331 bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN); 331 bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN);
332 332
@@ -546,7 +546,7 @@ out:
546void gelic_net_set_multi(struct net_device *netdev) 546void gelic_net_set_multi(struct net_device *netdev)
547{ 547{
548 struct gelic_card *card = netdev_card(netdev); 548 struct gelic_card *card = netdev_card(netdev);
549 struct dev_mc_list *mc; 549 struct netdev_hw_addr *ha;
550 unsigned int i; 550 unsigned int i;
551 uint8_t *p; 551 uint8_t *p;
552 u64 addr; 552 u64 addr;
@@ -580,9 +580,9 @@ void gelic_net_set_multi(struct net_device *netdev)
580 } 580 }
581 581
582 /* set multicast addresses */ 582 /* set multicast addresses */
583 netdev_for_each_mc_addr(mc, netdev) { 583 netdev_for_each_mc_addr(ha, netdev) {
584 addr = 0; 584 addr = 0;
585 p = mc->dmi_addr; 585 p = ha->addr;
586 for (i = 0; i < ETH_ALEN; i++) { 586 for (i = 0; i < ETH_ALEN; i++) {
587 addr <<= 8; 587 addr <<= 8;
588 addr |= *p++; 588 addr |= *p++;
@@ -1434,7 +1434,7 @@ static void gelic_net_tx_timeout_task(struct work_struct *work)
1434 container_of(work, struct gelic_card, tx_timeout_task); 1434 container_of(work, struct gelic_card, tx_timeout_task);
1435 struct net_device *netdev = card->netdev[GELIC_PORT_ETHERNET_0]; 1435 struct net_device *netdev = card->netdev[GELIC_PORT_ETHERNET_0];
1436 1436
1437 dev_info(ctodev(card), "%s:Timed out. Restarting... \n", __func__); 1437 dev_info(ctodev(card), "%s:Timed out. Restarting...\n", __func__);
1438 1438
1439 if (!(netdev->flags & IFF_UP)) 1439 if (!(netdev->flags & IFF_UP))
1440 goto out; 1440 goto out;
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c
index 2663b2fdc0bb..a9153a3481e1 100644
--- a/drivers/net/ps3_gelic_wireless.c
+++ b/drivers/net/ps3_gelic_wireless.c
@@ -527,7 +527,7 @@ static void gelic_wl_parse_ie(u8 *data, size_t len,
527 u8 item_len; 527 u8 item_len;
528 u8 item_id; 528 u8 item_id;
529 529
530 pr_debug("%s: data=%p len=%ld \n", __func__, 530 pr_debug("%s: data=%p len=%ld\n", __func__,
531 data, len); 531 data, len);
532 memset(ie_info, 0, sizeof(struct ie_info)); 532 memset(ie_info, 0, sizeof(struct ie_info));
533 533
@@ -978,7 +978,7 @@ static int gelic_wl_set_essid(struct net_device *netdev,
978 pr_debug("%s: essid = '%s'\n", __func__, extra); 978 pr_debug("%s: essid = '%s'\n", __func__, extra);
979 set_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat); 979 set_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat);
980 } else { 980 } else {
981 pr_debug("%s: ESSID any \n", __func__); 981 pr_debug("%s: ESSID any\n", __func__);
982 clear_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat); 982 clear_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat);
983 } 983 }
984 set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat); 984 set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
@@ -986,7 +986,7 @@ static int gelic_wl_set_essid(struct net_device *netdev,
986 986
987 987
988 gelic_wl_try_associate(netdev); /* FIXME */ 988 gelic_wl_try_associate(netdev); /* FIXME */
989 pr_debug("%s: -> \n", __func__); 989 pr_debug("%s: ->\n", __func__);
990 return 0; 990 return 0;
991} 991}
992 992
@@ -997,7 +997,7 @@ static int gelic_wl_get_essid(struct net_device *netdev,
997 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev)); 997 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
998 unsigned long irqflag; 998 unsigned long irqflag;
999 999
1000 pr_debug("%s: <- \n", __func__); 1000 pr_debug("%s: <-\n", __func__);
1001 mutex_lock(&wl->assoc_stat_lock); 1001 mutex_lock(&wl->assoc_stat_lock);
1002 spin_lock_irqsave(&wl->lock, irqflag); 1002 spin_lock_irqsave(&wl->lock, irqflag);
1003 if (test_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat) || 1003 if (test_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat) ||
@@ -1010,7 +1010,7 @@ static int gelic_wl_get_essid(struct net_device *netdev,
1010 1010
1011 mutex_unlock(&wl->assoc_stat_lock); 1011 mutex_unlock(&wl->assoc_stat_lock);
1012 spin_unlock_irqrestore(&wl->lock, irqflag); 1012 spin_unlock_irqrestore(&wl->lock, irqflag);
1013 pr_debug("%s: -> len=%d \n", __func__, data->essid.length); 1013 pr_debug("%s: -> len=%d\n", __func__, data->essid.length);
1014 1014
1015 return 0; 1015 return 0;
1016} 1016}
@@ -1027,7 +1027,7 @@ static int gelic_wl_set_encode(struct net_device *netdev,
1027 int key_index, index_specified; 1027 int key_index, index_specified;
1028 int ret = 0; 1028 int ret = 0;
1029 1029
1030 pr_debug("%s: <- \n", __func__); 1030 pr_debug("%s: <-\n", __func__);
1031 flags = enc->flags & IW_ENCODE_FLAGS; 1031 flags = enc->flags & IW_ENCODE_FLAGS;
1032 key_index = enc->flags & IW_ENCODE_INDEX; 1032 key_index = enc->flags & IW_ENCODE_INDEX;
1033 1033
@@ -1086,7 +1086,7 @@ static int gelic_wl_set_encode(struct net_device *netdev,
1086 set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat); 1086 set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
1087done: 1087done:
1088 spin_unlock_irqrestore(&wl->lock, irqflag); 1088 spin_unlock_irqrestore(&wl->lock, irqflag);
1089 pr_debug("%s: -> \n", __func__); 1089 pr_debug("%s: ->\n", __func__);
1090 return ret; 1090 return ret;
1091} 1091}
1092 1092
@@ -1100,7 +1100,7 @@ static int gelic_wl_get_encode(struct net_device *netdev,
1100 unsigned int key_index, index_specified; 1100 unsigned int key_index, index_specified;
1101 int ret = 0; 1101 int ret = 0;
1102 1102
1103 pr_debug("%s: <- \n", __func__); 1103 pr_debug("%s: <-\n", __func__);
1104 key_index = enc->flags & IW_ENCODE_INDEX; 1104 key_index = enc->flags & IW_ENCODE_INDEX;
1105 pr_debug("%s: flag=%#x point=%p len=%d extra=%p\n", __func__, 1105 pr_debug("%s: flag=%#x point=%p len=%d extra=%p\n", __func__,
1106 enc->flags, enc->pointer, enc->length, extra); 1106 enc->flags, enc->pointer, enc->length, extra);
@@ -1214,7 +1214,7 @@ static int gelic_wl_set_encodeext(struct net_device *netdev,
1214 int key_index; 1214 int key_index;
1215 int ret = 0; 1215 int ret = 0;
1216 1216
1217 pr_debug("%s: <- \n", __func__); 1217 pr_debug("%s: <-\n", __func__);
1218 flags = enc->flags & IW_ENCODE_FLAGS; 1218 flags = enc->flags & IW_ENCODE_FLAGS;
1219 alg = ext->alg; 1219 alg = ext->alg;
1220 key_index = enc->flags & IW_ENCODE_INDEX; 1220 key_index = enc->flags & IW_ENCODE_INDEX;
@@ -1287,7 +1287,7 @@ static int gelic_wl_set_encodeext(struct net_device *netdev,
1287 } 1287 }
1288done: 1288done:
1289 spin_unlock_irqrestore(&wl->lock, irqflag); 1289 spin_unlock_irqrestore(&wl->lock, irqflag);
1290 pr_debug("%s: -> \n", __func__); 1290 pr_debug("%s: ->\n", __func__);
1291 return ret; 1291 return ret;
1292} 1292}
1293 1293
@@ -1303,7 +1303,7 @@ static int gelic_wl_get_encodeext(struct net_device *netdev,
1303 int ret = 0; 1303 int ret = 0;
1304 int max_key_len; 1304 int max_key_len;
1305 1305
1306 pr_debug("%s: <- \n", __func__); 1306 pr_debug("%s: <-\n", __func__);
1307 1307
1308 max_key_len = enc->length - sizeof(struct iw_encode_ext); 1308 max_key_len = enc->length - sizeof(struct iw_encode_ext);
1309 if (max_key_len < 0) 1309 if (max_key_len < 0)
@@ -1358,7 +1358,7 @@ static int gelic_wl_get_encodeext(struct net_device *netdev,
1358 } 1358 }
1359out: 1359out:
1360 spin_unlock_irqrestore(&wl->lock, irqflag); 1360 spin_unlock_irqrestore(&wl->lock, irqflag);
1361 pr_debug("%s: -> \n", __func__); 1361 pr_debug("%s: ->\n", __func__);
1362 return ret; 1362 return ret;
1363} 1363}
1364/* SIOC{S,G}IWMODE */ 1364/* SIOC{S,G}IWMODE */
@@ -1369,7 +1369,7 @@ static int gelic_wl_set_mode(struct net_device *netdev,
1369 __u32 mode = data->mode; 1369 __u32 mode = data->mode;
1370 int ret; 1370 int ret;
1371 1371
1372 pr_debug("%s: <- \n", __func__); 1372 pr_debug("%s: <-\n", __func__);
1373 if (mode == IW_MODE_INFRA) 1373 if (mode == IW_MODE_INFRA)
1374 ret = 0; 1374 ret = 0;
1375 else 1375 else
@@ -1383,7 +1383,7 @@ static int gelic_wl_get_mode(struct net_device *netdev,
1383 union iwreq_data *data, char *extra) 1383 union iwreq_data *data, char *extra)
1384{ 1384{
1385 __u32 *mode = &data->mode; 1385 __u32 *mode = &data->mode;
1386 pr_debug("%s: <- \n", __func__); 1386 pr_debug("%s: <-\n", __func__);
1387 *mode = IW_MODE_INFRA; 1387 *mode = IW_MODE_INFRA;
1388 pr_debug("%s: ->\n", __func__); 1388 pr_debug("%s: ->\n", __func__);
1389 return 0; 1389 return 0;
@@ -2021,7 +2021,7 @@ static int gelic_wl_associate_bss(struct gelic_wl_info *wl,
2021 2021
2022 if (!rc) { 2022 if (!rc) {
2023 /* timeouted. Maybe key or cyrpt mode is wrong */ 2023 /* timeouted. Maybe key or cyrpt mode is wrong */
2024 pr_info("%s: connect timeout \n", __func__); 2024 pr_info("%s: connect timeout\n", __func__);
2025 cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_DISASSOC, 2025 cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_DISASSOC,
2026 NULL, 0); 2026 NULL, 0);
2027 kfree(cmd); 2027 kfree(cmd);
@@ -2062,7 +2062,7 @@ static void gelic_wl_connected_event(struct gelic_wl_info *wl,
2062 } 2062 }
2063 2063
2064 if (desired_event == event) { 2064 if (desired_event == event) {
2065 pr_debug("%s: completed \n", __func__); 2065 pr_debug("%s: completed\n", __func__);
2066 complete(&wl->assoc_done); 2066 complete(&wl->assoc_done);
2067 netif_carrier_on(port_to_netdev(wl_port(wl))); 2067 netif_carrier_on(port_to_netdev(wl_port(wl)));
2068 } else 2068 } else
@@ -2279,26 +2279,25 @@ void gelic_wl_interrupt(struct net_device *netdev, u64 status)
2279/* 2279/*
2280 * driver helpers 2280 * driver helpers
2281 */ 2281 */
2282#define IW_IOCTL(n) [(n) - SIOCSIWCOMMIT]
2283static const iw_handler gelic_wl_wext_handler[] = 2282static const iw_handler gelic_wl_wext_handler[] =
2284{ 2283{
2285 IW_IOCTL(SIOCGIWNAME) = gelic_wl_get_name, 2284 IW_HANDLER(SIOCGIWNAME, gelic_wl_get_name),
2286 IW_IOCTL(SIOCGIWRANGE) = gelic_wl_get_range, 2285 IW_HANDLER(SIOCGIWRANGE, gelic_wl_get_range),
2287 IW_IOCTL(SIOCSIWSCAN) = gelic_wl_set_scan, 2286 IW_HANDLER(SIOCSIWSCAN, gelic_wl_set_scan),
2288 IW_IOCTL(SIOCGIWSCAN) = gelic_wl_get_scan, 2287 IW_HANDLER(SIOCGIWSCAN, gelic_wl_get_scan),
2289 IW_IOCTL(SIOCSIWAUTH) = gelic_wl_set_auth, 2288 IW_HANDLER(SIOCSIWAUTH, gelic_wl_set_auth),
2290 IW_IOCTL(SIOCGIWAUTH) = gelic_wl_get_auth, 2289 IW_HANDLER(SIOCGIWAUTH, gelic_wl_get_auth),
2291 IW_IOCTL(SIOCSIWESSID) = gelic_wl_set_essid, 2290 IW_HANDLER(SIOCSIWESSID, gelic_wl_set_essid),
2292 IW_IOCTL(SIOCGIWESSID) = gelic_wl_get_essid, 2291 IW_HANDLER(SIOCGIWESSID, gelic_wl_get_essid),
2293 IW_IOCTL(SIOCSIWENCODE) = gelic_wl_set_encode, 2292 IW_HANDLER(SIOCSIWENCODE, gelic_wl_set_encode),
2294 IW_IOCTL(SIOCGIWENCODE) = gelic_wl_get_encode, 2293 IW_HANDLER(SIOCGIWENCODE, gelic_wl_get_encode),
2295 IW_IOCTL(SIOCSIWAP) = gelic_wl_set_ap, 2294 IW_HANDLER(SIOCSIWAP, gelic_wl_set_ap),
2296 IW_IOCTL(SIOCGIWAP) = gelic_wl_get_ap, 2295 IW_HANDLER(SIOCGIWAP, gelic_wl_get_ap),
2297 IW_IOCTL(SIOCSIWENCODEEXT) = gelic_wl_set_encodeext, 2296 IW_HANDLER(SIOCSIWENCODEEXT, gelic_wl_set_encodeext),
2298 IW_IOCTL(SIOCGIWENCODEEXT) = gelic_wl_get_encodeext, 2297 IW_HANDLER(SIOCGIWENCODEEXT, gelic_wl_get_encodeext),
2299 IW_IOCTL(SIOCSIWMODE) = gelic_wl_set_mode, 2298 IW_HANDLER(SIOCSIWMODE, gelic_wl_set_mode),
2300 IW_IOCTL(SIOCGIWMODE) = gelic_wl_get_mode, 2299 IW_HANDLER(SIOCGIWMODE, gelic_wl_get_mode),
2301 IW_IOCTL(SIOCGIWNICKN) = gelic_wl_get_nick, 2300 IW_HANDLER(SIOCGIWNICKN, gelic_wl_get_nick),
2302}; 2301};
2303 2302
2304static const struct iw_handler_def gelic_wl_wext_handler_def = { 2303static const struct iw_handler_def gelic_wl_wext_handler_def = {
@@ -2317,7 +2316,7 @@ static struct net_device * __devinit gelic_wl_alloc(struct gelic_card *card)
2317 pr_debug("%s:start\n", __func__); 2316 pr_debug("%s:start\n", __func__);
2318 netdev = alloc_etherdev(sizeof(struct gelic_port) + 2317 netdev = alloc_etherdev(sizeof(struct gelic_port) +
2319 sizeof(struct gelic_wl_info)); 2318 sizeof(struct gelic_wl_info));
2320 pr_debug("%s: netdev =%p card=%p \np", __func__, netdev, card); 2319 pr_debug("%s: netdev =%p card=%p\n", __func__, netdev, card);
2321 if (!netdev) 2320 if (!netdev)
2322 return NULL; 2321 return NULL;
2323 2322
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index 4ef0afbcbe1b..fc11ad3f64b0 100644
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -2258,7 +2258,7 @@ static int ql_tx_rx_clean(struct ql3_adapter *qdev,
2258 "%x.\n", 2258 "%x.\n",
2259 ndev->name, net_rsp->opcode); 2259 ndev->name, net_rsp->opcode);
2260 printk(KERN_ERR PFX 2260 printk(KERN_ERR PFX
2261 "0x%08lx 0x%08lx 0x%08lx 0x%08lx \n", 2261 "0x%08lx 0x%08lx 0x%08lx 0x%08lx\n",
2262 (unsigned long int)tmp[0], 2262 (unsigned long int)tmp[0],
2263 (unsigned long int)tmp[1], 2263 (unsigned long int)tmp[1],
2264 (unsigned long int)tmp[2], 2264 (unsigned long int)tmp[2],
diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h
index 0da94b208db1..28c148cbe37b 100644
--- a/drivers/net/qlcnic/qlcnic.h
+++ b/drivers/net/qlcnic/qlcnic.h
@@ -51,8 +51,8 @@
51 51
52#define _QLCNIC_LINUX_MAJOR 5 52#define _QLCNIC_LINUX_MAJOR 5
53#define _QLCNIC_LINUX_MINOR 0 53#define _QLCNIC_LINUX_MINOR 0
54#define _QLCNIC_LINUX_SUBVERSION 0 54#define _QLCNIC_LINUX_SUBVERSION 1
55#define QLCNIC_LINUX_VERSIONID "5.0.0" 55#define QLCNIC_LINUX_VERSIONID "5.0.1"
56 56
57#define QLCNIC_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c)) 57#define QLCNIC_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c))
58#define _major(v) (((v) >> 24) & 0xff) 58#define _major(v) (((v) >> 24) & 0xff)
@@ -958,8 +958,10 @@ struct qlcnic_adapter {
958 u8 dev_state; 958 u8 dev_state;
959 u8 diag_test; 959 u8 diag_test;
960 u8 diag_cnt; 960 u8 diag_cnt;
961 u8 reset_ack_timeo;
962 u8 dev_init_timeo;
961 u8 rsrd1; 963 u8 rsrd1;
962 u16 rsrd2; 964 u16 msg_enable;
963 965
964 u8 mac_addr[ETH_ALEN]; 966 u8 mac_addr[ETH_ALEN];
965 967
@@ -994,6 +996,11 @@ u32 qlcnic_hw_read_wx_2M(struct qlcnic_adapter *adapter, ulong off);
994int qlcnic_hw_write_wx_2M(struct qlcnic_adapter *, ulong off, u32 data); 996int qlcnic_hw_write_wx_2M(struct qlcnic_adapter *, ulong off, u32 data);
995int qlcnic_pci_mem_write_2M(struct qlcnic_adapter *, u64 off, u64 data); 997int qlcnic_pci_mem_write_2M(struct qlcnic_adapter *, u64 off, u64 data);
996int qlcnic_pci_mem_read_2M(struct qlcnic_adapter *, u64 off, u64 *data); 998int qlcnic_pci_mem_read_2M(struct qlcnic_adapter *, u64 off, u64 *data);
999void qlcnic_pci_camqm_read_2M(struct qlcnic_adapter *, u64, u64 *);
1000void qlcnic_pci_camqm_write_2M(struct qlcnic_adapter *, u64, u64);
1001
1002#define ADDR_IN_RANGE(addr, low, high) \
1003 (((addr) < (high)) && ((addr) >= (low)))
997 1004
998#define QLCRD32(adapter, off) \ 1005#define QLCRD32(adapter, off) \
999 (qlcnic_hw_read_wx_2M(adapter, off)) 1006 (qlcnic_hw_read_wx_2M(adapter, off))
@@ -1035,6 +1042,7 @@ int qlcnic_need_fw_reset(struct qlcnic_adapter *adapter);
1035void qlcnic_request_firmware(struct qlcnic_adapter *adapter); 1042void qlcnic_request_firmware(struct qlcnic_adapter *adapter);
1036void qlcnic_release_firmware(struct qlcnic_adapter *adapter); 1043void qlcnic_release_firmware(struct qlcnic_adapter *adapter);
1037int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter); 1044int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter);
1045void qlcnic_setup_idc_param(struct qlcnic_adapter *adapter);
1038 1046
1039int qlcnic_rom_fast_read(struct qlcnic_adapter *adapter, int addr, int *valp); 1047int qlcnic_rom_fast_read(struct qlcnic_adapter *adapter, int addr, int *valp);
1040int qlcnic_rom_fast_read_words(struct qlcnic_adapter *adapter, int addr, 1048int qlcnic_rom_fast_read_words(struct qlcnic_adapter *adapter, int addr,
@@ -1128,4 +1136,11 @@ static inline u32 qlcnic_tx_avail(struct qlcnic_host_tx_ring *tx_ring)
1128 1136
1129extern const struct ethtool_ops qlcnic_ethtool_ops; 1137extern const struct ethtool_ops qlcnic_ethtool_ops;
1130 1138
1139#define QLCDB(adapter, lvl, _fmt, _args...) do { \
1140 if (NETIF_MSG_##lvl & adapter->msg_enable) \
1141 printk(KERN_INFO "%s: %s: " _fmt, \
1142 dev_name(&adapter->pdev->dev), \
1143 __func__, ##_args); \
1144 } while (0)
1145
1131#endif /* __QLCNIC_H_ */ 1146#endif /* __QLCNIC_H_ */
diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c
index f83e15fe3e1b..08d6f105371f 100644
--- a/drivers/net/qlcnic/qlcnic_ethtool.c
+++ b/drivers/net/qlcnic/qlcnic_ethtool.c
@@ -998,6 +998,20 @@ static int qlcnic_set_flags(struct net_device *netdev, u32 data)
998 return 0; 998 return 0;
999} 999}
1000 1000
1001static u32 qlcnic_get_msglevel(struct net_device *netdev)
1002{
1003 struct qlcnic_adapter *adapter = netdev_priv(netdev);
1004
1005 return adapter->msg_enable;
1006}
1007
1008static void qlcnic_set_msglevel(struct net_device *netdev, u32 msglvl)
1009{
1010 struct qlcnic_adapter *adapter = netdev_priv(netdev);
1011
1012 adapter->msg_enable = msglvl;
1013}
1014
1001const struct ethtool_ops qlcnic_ethtool_ops = { 1015const struct ethtool_ops qlcnic_ethtool_ops = {
1002 .get_settings = qlcnic_get_settings, 1016 .get_settings = qlcnic_get_settings,
1003 .set_settings = qlcnic_set_settings, 1017 .set_settings = qlcnic_set_settings,
@@ -1029,4 +1043,6 @@ const struct ethtool_ops qlcnic_ethtool_ops = {
1029 .get_flags = ethtool_op_get_flags, 1043 .get_flags = ethtool_op_get_flags,
1030 .set_flags = qlcnic_set_flags, 1044 .set_flags = qlcnic_set_flags,
1031 .phys_id = qlcnic_blink_led, 1045 .phys_id = qlcnic_blink_led,
1046 .set_msglevel = qlcnic_set_msglevel,
1047 .get_msglevel = qlcnic_get_msglevel,
1032}; 1048};
diff --git a/drivers/net/qlcnic/qlcnic_hdr.h b/drivers/net/qlcnic/qlcnic_hdr.h
index 0469f84360a4..51fa3fbcf58a 100644
--- a/drivers/net/qlcnic/qlcnic_hdr.h
+++ b/drivers/net/qlcnic/qlcnic_hdr.h
@@ -435,9 +435,10 @@ enum {
435#define QLCNIC_PCI_MS_2M (0x80000) 435#define QLCNIC_PCI_MS_2M (0x80000)
436#define QLCNIC_PCI_OCM0_2M (0x000c0000UL) 436#define QLCNIC_PCI_OCM0_2M (0x000c0000UL)
437#define QLCNIC_PCI_CRBSPACE (0x06000000UL) 437#define QLCNIC_PCI_CRBSPACE (0x06000000UL)
438#define QLCNIC_PCI_CAMQM (0x04800000UL)
439#define QLCNIC_PCI_CAMQM_END (0x04800800UL)
438#define QLCNIC_PCI_2MB_SIZE (0x00200000UL) 440#define QLCNIC_PCI_2MB_SIZE (0x00200000UL)
439#define QLCNIC_PCI_CAMQM_2M_BASE (0x000ff800UL) 441#define QLCNIC_PCI_CAMQM_2M_BASE (0x000ff800UL)
440#define QLCNIC_PCI_CAMQM_2M_END (0x04800800UL)
441 442
442#define QLCNIC_CRB_CAM QLCNIC_PCI_CRB_WINDOW(QLCNIC_HW_PX_MAP_CRB_CAM) 443#define QLCNIC_CRB_CAM QLCNIC_PCI_CRB_WINDOW(QLCNIC_HW_PX_MAP_CRB_CAM)
443 444
@@ -448,7 +449,7 @@ enum {
448#define QLCNIC_ADDR_OCM1 (0x0000000200400000ULL) 449#define QLCNIC_ADDR_OCM1 (0x0000000200400000ULL)
449#define QLCNIC_ADDR_OCM1_MAX (0x00000002004fffffULL) 450#define QLCNIC_ADDR_OCM1_MAX (0x00000002004fffffULL)
450#define QLCNIC_ADDR_QDR_NET (0x0000000300000000ULL) 451#define QLCNIC_ADDR_QDR_NET (0x0000000300000000ULL)
451#define QLCNIC_ADDR_QDR_NET_MAX_P3 (0x0000000303ffffffULL) 452#define QLCNIC_ADDR_QDR_NET_MAX (0x0000000307ffffffULL)
452 453
453/* 454/*
454 * Register offsets for MN 455 * Register offsets for MN
@@ -694,6 +695,8 @@ enum {
694#define QLCNIC_CRB_DRV_SCRATCH (QLCNIC_CAM_RAM(0x148)) 695#define QLCNIC_CRB_DRV_SCRATCH (QLCNIC_CAM_RAM(0x148))
695#define QLCNIC_CRB_DEV_PARTITION_INFO (QLCNIC_CAM_RAM(0x14c)) 696#define QLCNIC_CRB_DEV_PARTITION_INFO (QLCNIC_CAM_RAM(0x14c))
696#define QLCNIC_CRB_DRV_IDC_VER (QLCNIC_CAM_RAM(0x14c)) 697#define QLCNIC_CRB_DRV_IDC_VER (QLCNIC_CAM_RAM(0x14c))
698#define QLCNIC_ROM_DEV_INIT_TIMEOUT (0x3e885c)
699#define QLCNIC_ROM_DRV_RESET_TIMEOUT (0x3e8860)
697 700
698 /* Device State */ 701 /* Device State */
699#define QLCNIC_DEV_COLD 1 702#define QLCNIC_DEV_COLD 1
diff --git a/drivers/net/qlcnic/qlcnic_hw.c b/drivers/net/qlcnic/qlcnic_hw.c
index da00e162b6d3..9a1daa4ebe22 100644
--- a/drivers/net/qlcnic/qlcnic_hw.c
+++ b/drivers/net/qlcnic/qlcnic_hw.c
@@ -53,21 +53,6 @@ static inline void writeq(u64 val, void __iomem *addr)
53} 53}
54#endif 54#endif
55 55
56#define ADDR_IN_RANGE(addr, low, high) \
57 (((addr) < (high)) && ((addr) >= (low)))
58
59#define PCI_OFFSET_FIRST_RANGE(adapter, off) \
60 ((adapter)->ahw.pci_base0 + (off))
61
62static void __iomem *pci_base_offset(struct qlcnic_adapter *adapter,
63 unsigned long off)
64{
65 if (ADDR_IN_RANGE(off, FIRST_PAGE_GROUP_START, FIRST_PAGE_GROUP_END))
66 return PCI_OFFSET_FIRST_RANGE(adapter, off);
67
68 return NULL;
69}
70
71static const struct crb_128M_2M_block_map 56static const struct crb_128M_2M_block_map
72crb_128M_2M_map[64] __cacheline_aligned_in_smp = { 57crb_128M_2M_map[64] __cacheline_aligned_in_smp = {
73 {{{0, 0, 0, 0} } }, /* 0: PCI */ 58 {{{0, 0, 0, 0} } }, /* 0: PCI */
@@ -309,8 +294,12 @@ qlcnic_pcie_sem_lock(struct qlcnic_adapter *adapter, int sem, u32 id_reg)
309 done = QLCRD32(adapter, QLCNIC_PCIE_REG(PCIE_SEM_LOCK(sem))); 294 done = QLCRD32(adapter, QLCNIC_PCIE_REG(PCIE_SEM_LOCK(sem)));
310 if (done == 1) 295 if (done == 1)
311 break; 296 break;
312 if (++timeout >= QLCNIC_PCIE_SEM_TIMEOUT) 297 if (++timeout >= QLCNIC_PCIE_SEM_TIMEOUT) {
298 dev_err(&adapter->pdev->dev,
299 "Failed to acquire sem=%d lock;reg_id=%d\n",
300 sem, id_reg);
313 return -EIO; 301 return -EIO;
302 }
314 msleep(1); 303 msleep(1);
315 } 304 }
316 305
@@ -426,7 +415,7 @@ static int qlcnic_nic_add_mac(struct qlcnic_adapter *adapter, u8 *addr)
426void qlcnic_set_multi(struct net_device *netdev) 415void qlcnic_set_multi(struct net_device *netdev)
427{ 416{
428 struct qlcnic_adapter *adapter = netdev_priv(netdev); 417 struct qlcnic_adapter *adapter = netdev_priv(netdev);
429 struct dev_mc_list *mc_ptr; 418 struct netdev_hw_addr *ha;
430 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 419 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
431 u32 mode = VPORT_MISS_MODE_DROP; 420 u32 mode = VPORT_MISS_MODE_DROP;
432 421
@@ -445,8 +434,8 @@ void qlcnic_set_multi(struct net_device *netdev)
445 } 434 }
446 435
447 if (!netdev_mc_empty(netdev)) { 436 if (!netdev_mc_empty(netdev)) {
448 netdev_for_each_mc_addr(mc_ptr, netdev) { 437 netdev_for_each_mc_addr(ha, netdev) {
449 qlcnic_nic_add_mac(adapter, mc_ptr->dmi_addr); 438 qlcnic_nic_add_mac(adapter, ha->addr);
450 } 439 }
451 } 440 }
452 441
@@ -874,13 +863,6 @@ qlcnic_pci_set_window_2M(struct qlcnic_adapter *adapter,
874 u64 addr, u32 *start) 863 u64 addr, u32 *start)
875{ 864{
876 u32 window; 865 u32 window;
877 struct pci_dev *pdev = adapter->pdev;
878
879 if ((addr & 0x00ff800) == 0xff800) {
880 if (printk_ratelimit())
881 dev_warn(&pdev->dev, "QM access not handled\n");
882 return -EIO;
883 }
884 866
885 window = OCM_WIN_P3P(addr); 867 window = OCM_WIN_P3P(addr);
886 868
@@ -897,8 +879,7 @@ static int
897qlcnic_pci_mem_access_direct(struct qlcnic_adapter *adapter, u64 off, 879qlcnic_pci_mem_access_direct(struct qlcnic_adapter *adapter, u64 off,
898 u64 *data, int op) 880 u64 *data, int op)
899{ 881{
900 void __iomem *addr, *mem_ptr = NULL; 882 void __iomem *addr;
901 resource_size_t mem_base;
902 int ret; 883 int ret;
903 u32 start; 884 u32 start;
904 885
@@ -908,21 +889,8 @@ qlcnic_pci_mem_access_direct(struct qlcnic_adapter *adapter, u64 off,
908 if (ret != 0) 889 if (ret != 0)
909 goto unlock; 890 goto unlock;
910 891
911 addr = pci_base_offset(adapter, start); 892 addr = adapter->ahw.pci_base0 + start;
912 if (addr)
913 goto noremap;
914 893
915 mem_base = pci_resource_start(adapter->pdev, 0) + (start & PAGE_MASK);
916
917 mem_ptr = ioremap(mem_base, PAGE_SIZE);
918 if (mem_ptr == NULL) {
919 ret = -EIO;
920 goto unlock;
921 }
922
923 addr = mem_ptr + (start & (PAGE_SIZE - 1));
924
925noremap:
926 if (op == 0) /* read */ 894 if (op == 0) /* read */
927 *data = readq(addr); 895 *data = readq(addr);
928 else /* write */ 896 else /* write */
@@ -931,11 +899,31 @@ noremap:
931unlock: 899unlock:
932 mutex_unlock(&adapter->ahw.mem_lock); 900 mutex_unlock(&adapter->ahw.mem_lock);
933 901
934 if (mem_ptr)
935 iounmap(mem_ptr);
936 return ret; 902 return ret;
937} 903}
938 904
905void
906qlcnic_pci_camqm_read_2M(struct qlcnic_adapter *adapter, u64 off, u64 *data)
907{
908 void __iomem *addr = adapter->ahw.pci_base0 +
909 QLCNIC_PCI_CAMQM_2M_BASE + (off - QLCNIC_PCI_CAMQM);
910
911 mutex_lock(&adapter->ahw.mem_lock);
912 *data = readq(addr);
913 mutex_unlock(&adapter->ahw.mem_lock);
914}
915
916void
917qlcnic_pci_camqm_write_2M(struct qlcnic_adapter *adapter, u64 off, u64 data)
918{
919 void __iomem *addr = adapter->ahw.pci_base0 +
920 QLCNIC_PCI_CAMQM_2M_BASE + (off - QLCNIC_PCI_CAMQM);
921
922 mutex_lock(&adapter->ahw.mem_lock);
923 writeq(data, addr);
924 mutex_unlock(&adapter->ahw.mem_lock);
925}
926
939#define MAX_CTL_CHECK 1000 927#define MAX_CTL_CHECK 1000
940 928
941int 929int
@@ -944,7 +932,6 @@ qlcnic_pci_mem_write_2M(struct qlcnic_adapter *adapter,
944{ 932{
945 int i, j, ret; 933 int i, j, ret;
946 u32 temp, off8; 934 u32 temp, off8;
947 u64 stride;
948 void __iomem *mem_crb; 935 void __iomem *mem_crb;
949 936
950 /* Only 64-bit aligned access */ 937 /* Only 64-bit aligned access */
@@ -953,7 +940,7 @@ qlcnic_pci_mem_write_2M(struct qlcnic_adapter *adapter,
953 940
954 /* P3 onward, test agent base for MIU and SIU is same */ 941 /* P3 onward, test agent base for MIU and SIU is same */
955 if (ADDR_IN_RANGE(off, QLCNIC_ADDR_QDR_NET, 942 if (ADDR_IN_RANGE(off, QLCNIC_ADDR_QDR_NET,
956 QLCNIC_ADDR_QDR_NET_MAX_P3)) { 943 QLCNIC_ADDR_QDR_NET_MAX)) {
957 mem_crb = qlcnic_get_ioaddr(adapter, 944 mem_crb = qlcnic_get_ioaddr(adapter,
958 QLCNIC_CRB_QDR_NET+MIU_TEST_AGT_BASE); 945 QLCNIC_CRB_QDR_NET+MIU_TEST_AGT_BASE);
959 goto correct; 946 goto correct;
@@ -971,9 +958,7 @@ qlcnic_pci_mem_write_2M(struct qlcnic_adapter *adapter,
971 return -EIO; 958 return -EIO;
972 959
973correct: 960correct:
974 stride = QLCNIC_IS_REVISION_P3P(adapter->ahw.revision_id) ? 16 : 8; 961 off8 = off & ~0xf;
975
976 off8 = off & ~(stride-1);
977 962
978 mutex_lock(&adapter->ahw.mem_lock); 963 mutex_lock(&adapter->ahw.mem_lock);
979 964
@@ -981,30 +966,28 @@ correct:
981 writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI)); 966 writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI));
982 967
983 i = 0; 968 i = 0;
984 if (stride == 16) { 969 writel(TA_CTL_ENABLE, (mem_crb + TEST_AGT_CTRL));
985 writel(TA_CTL_ENABLE, (mem_crb + TEST_AGT_CTRL)); 970 writel((TA_CTL_START | TA_CTL_ENABLE),
986 writel((TA_CTL_START | TA_CTL_ENABLE), 971 (mem_crb + TEST_AGT_CTRL));
987 (mem_crb + TEST_AGT_CTRL));
988
989 for (j = 0; j < MAX_CTL_CHECK; j++) {
990 temp = readl(mem_crb + TEST_AGT_CTRL);
991 if ((temp & TA_CTL_BUSY) == 0)
992 break;
993 }
994 972
995 if (j >= MAX_CTL_CHECK) { 973 for (j = 0; j < MAX_CTL_CHECK; j++) {
996 ret = -EIO; 974 temp = readl(mem_crb + TEST_AGT_CTRL);
997 goto done; 975 if ((temp & TA_CTL_BUSY) == 0)
998 } 976 break;
977 }
999 978
1000 i = (off & 0xf) ? 0 : 2; 979 if (j >= MAX_CTL_CHECK) {
1001 writel(readl(mem_crb + MIU_TEST_AGT_RDDATA(i)), 980 ret = -EIO;
1002 mem_crb + MIU_TEST_AGT_WRDATA(i)); 981 goto done;
1003 writel(readl(mem_crb + MIU_TEST_AGT_RDDATA(i+1)),
1004 mem_crb + MIU_TEST_AGT_WRDATA(i+1));
1005 i = (off & 0xf) ? 2 : 0;
1006 } 982 }
1007 983
984 i = (off & 0xf) ? 0 : 2;
985 writel(readl(mem_crb + MIU_TEST_AGT_RDDATA(i)),
986 mem_crb + MIU_TEST_AGT_WRDATA(i));
987 writel(readl(mem_crb + MIU_TEST_AGT_RDDATA(i+1)),
988 mem_crb + MIU_TEST_AGT_WRDATA(i+1));
989 i = (off & 0xf) ? 2 : 0;
990
1008 writel(data & 0xffffffff, 991 writel(data & 0xffffffff,
1009 mem_crb + MIU_TEST_AGT_WRDATA(i)); 992 mem_crb + MIU_TEST_AGT_WRDATA(i));
1010 writel((data >> 32) & 0xffffffff, 993 writel((data >> 32) & 0xffffffff,
@@ -1040,7 +1023,7 @@ qlcnic_pci_mem_read_2M(struct qlcnic_adapter *adapter,
1040{ 1023{
1041 int j, ret; 1024 int j, ret;
1042 u32 temp, off8; 1025 u32 temp, off8;
1043 u64 val, stride; 1026 u64 val;
1044 void __iomem *mem_crb; 1027 void __iomem *mem_crb;
1045 1028
1046 /* Only 64-bit aligned access */ 1029 /* Only 64-bit aligned access */
@@ -1049,7 +1032,7 @@ qlcnic_pci_mem_read_2M(struct qlcnic_adapter *adapter,
1049 1032
1050 /* P3 onward, test agent base for MIU and SIU is same */ 1033 /* P3 onward, test agent base for MIU and SIU is same */
1051 if (ADDR_IN_RANGE(off, QLCNIC_ADDR_QDR_NET, 1034 if (ADDR_IN_RANGE(off, QLCNIC_ADDR_QDR_NET,
1052 QLCNIC_ADDR_QDR_NET_MAX_P3)) { 1035 QLCNIC_ADDR_QDR_NET_MAX)) {
1053 mem_crb = qlcnic_get_ioaddr(adapter, 1036 mem_crb = qlcnic_get_ioaddr(adapter,
1054 QLCNIC_CRB_QDR_NET+MIU_TEST_AGT_BASE); 1037 QLCNIC_CRB_QDR_NET+MIU_TEST_AGT_BASE);
1055 goto correct; 1038 goto correct;
@@ -1069,9 +1052,7 @@ qlcnic_pci_mem_read_2M(struct qlcnic_adapter *adapter,
1069 return -EIO; 1052 return -EIO;
1070 1053
1071correct: 1054correct:
1072 stride = QLCNIC_IS_REVISION_P3P(adapter->ahw.revision_id) ? 16 : 8; 1055 off8 = off & ~0xf;
1073
1074 off8 = off & ~(stride-1);
1075 1056
1076 mutex_lock(&adapter->ahw.mem_lock); 1057 mutex_lock(&adapter->ahw.mem_lock);
1077 1058
@@ -1093,7 +1074,7 @@ correct:
1093 ret = -EIO; 1074 ret = -EIO;
1094 } else { 1075 } else {
1095 off8 = MIU_TEST_AGT_RDDATA_LO; 1076 off8 = MIU_TEST_AGT_RDDATA_LO;
1096 if ((stride == 16) && (off & 0xf)) 1077 if (off & 0xf)
1097 off8 = MIU_TEST_AGT_RDDATA_UPPER_LO; 1078 off8 = MIU_TEST_AGT_RDDATA_UPPER_LO;
1098 1079
1099 temp = readl(mem_crb + off8 + 4); 1080 temp = readl(mem_crb + off8 + 4);
diff --git a/drivers/net/qlcnic/qlcnic_init.c b/drivers/net/qlcnic/qlcnic_init.c
index 7c34e4e29b3f..89c64e8ec849 100644
--- a/drivers/net/qlcnic/qlcnic_init.c
+++ b/drivers/net/qlcnic/qlcnic_init.c
@@ -529,6 +529,22 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter)
529 return 0; 529 return 0;
530} 530}
531 531
532void
533qlcnic_setup_idc_param(struct qlcnic_adapter *adapter) {
534
535 int timeo;
536
537 if (qlcnic_rom_fast_read(adapter, QLCNIC_ROM_DEV_INIT_TIMEOUT, &timeo))
538 timeo = 30;
539
540 adapter->dev_init_timeo = timeo;
541
542 if (qlcnic_rom_fast_read(adapter, QLCNIC_ROM_DRV_RESET_TIMEOUT, &timeo))
543 timeo = 10;
544
545 adapter->reset_ack_timeo = timeo;
546}
547
532static int 548static int
533qlcnic_has_mn(struct qlcnic_adapter *adapter) 549qlcnic_has_mn(struct qlcnic_adapter *adapter)
534{ 550{
@@ -611,7 +627,7 @@ qlcnic_validate_bootld(struct qlcnic_adapter *adapter)
611 return -EINVAL; 627 return -EINVAL;
612 628
613 tab_size = cpu_to_le32(tab_desc->findex) + 629 tab_size = cpu_to_le32(tab_desc->findex) +
614 (cpu_to_le32(tab_desc->entry_size * (idx + 1))); 630 (cpu_to_le32(tab_desc->entry_size) * (idx + 1));
615 631
616 if (adapter->fw->size < tab_size) 632 if (adapter->fw->size < tab_size)
617 return -EINVAL; 633 return -EINVAL;
@@ -620,7 +636,7 @@ qlcnic_validate_bootld(struct qlcnic_adapter *adapter)
620 (cpu_to_le32(tab_desc->entry_size) * (idx)); 636 (cpu_to_le32(tab_desc->entry_size) * (idx));
621 descr = (struct uni_data_desc *)&unirom[offs]; 637 descr = (struct uni_data_desc *)&unirom[offs];
622 638
623 data_size = descr->findex + cpu_to_le32(descr->size); 639 data_size = cpu_to_le32(descr->findex) + cpu_to_le32(descr->size);
624 640
625 if (adapter->fw->size < data_size) 641 if (adapter->fw->size < data_size)
626 return -EINVAL; 642 return -EINVAL;
@@ -646,7 +662,7 @@ qlcnic_validate_fw(struct qlcnic_adapter *adapter)
646 return -EINVAL; 662 return -EINVAL;
647 663
648 tab_size = cpu_to_le32(tab_desc->findex) + 664 tab_size = cpu_to_le32(tab_desc->findex) +
649 (cpu_to_le32(tab_desc->entry_size * (idx + 1))); 665 (cpu_to_le32(tab_desc->entry_size) * (idx + 1));
650 666
651 if (adapter->fw->size < tab_size) 667 if (adapter->fw->size < tab_size)
652 return -EINVAL; 668 return -EINVAL;
@@ -654,7 +670,7 @@ qlcnic_validate_fw(struct qlcnic_adapter *adapter)
654 offs = cpu_to_le32(tab_desc->findex) + 670 offs = cpu_to_le32(tab_desc->findex) +
655 (cpu_to_le32(tab_desc->entry_size) * (idx)); 671 (cpu_to_le32(tab_desc->entry_size) * (idx));
656 descr = (struct uni_data_desc *)&unirom[offs]; 672 descr = (struct uni_data_desc *)&unirom[offs];
657 data_size = descr->findex + cpu_to_le32(descr->size); 673 data_size = cpu_to_le32(descr->findex) + cpu_to_le32(descr->size);
658 674
659 if (adapter->fw->size < data_size) 675 if (adapter->fw->size < data_size)
660 return -EINVAL; 676 return -EINVAL;
@@ -949,6 +965,16 @@ qlcnic_load_firmware(struct qlcnic_adapter *adapter)
949 965
950 flashaddr += 8; 966 flashaddr += 8;
951 } 967 }
968
969 size = (__force u32)qlcnic_get_fw_size(adapter) % 8;
970 if (size) {
971 data = cpu_to_le64(ptr64[i]);
972
973 if (qlcnic_pci_mem_write_2M(adapter,
974 flashaddr, data))
975 return -EIO;
976 }
977
952 } else { 978 } else {
953 u64 data; 979 u64 data;
954 u32 hi, lo; 980 u32 hi, lo;
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index fc721564e69e..7ae464085b0d 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -649,7 +649,10 @@ qlcnic_start_firmware(struct qlcnic_adapter *adapter)
649 if (err) 649 if (err)
650 return err; 650 return err;
651 651
652 if (!qlcnic_can_start_firmware(adapter)) 652 err = qlcnic_can_start_firmware(adapter);
653 if (err < 0)
654 return err;
655 else if (!err)
653 goto wait_init; 656 goto wait_init;
654 657
655 first_boot = QLCRD32(adapter, QLCNIC_CAM_RAM(0x1fc)); 658 first_boot = QLCRD32(adapter, QLCNIC_CAM_RAM(0x1fc));
@@ -949,11 +952,11 @@ void qlcnic_diag_free_res(struct net_device *netdev, int max_sds_rings)
949 adapter->max_sds_rings = max_sds_rings; 952 adapter->max_sds_rings = max_sds_rings;
950 953
951 if (qlcnic_attach(adapter)) 954 if (qlcnic_attach(adapter))
952 return; 955 goto out;
953 956
954 if (netif_running(netdev)) 957 if (netif_running(netdev))
955 __qlcnic_up(adapter, netdev); 958 __qlcnic_up(adapter, netdev);
956 959out:
957 netif_device_attach(netdev); 960 netif_device_attach(netdev);
958} 961}
959 962
@@ -975,8 +978,10 @@ int qlcnic_diag_alloc_res(struct net_device *netdev, int test)
975 adapter->diag_test = test; 978 adapter->diag_test = test;
976 979
977 ret = qlcnic_attach(adapter); 980 ret = qlcnic_attach(adapter);
978 if (ret) 981 if (ret) {
982 netif_device_attach(netdev);
979 return ret; 983 return ret;
984 }
980 985
981 if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) { 986 if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) {
982 for (ring = 0; ring < adapter->max_sds_rings; ring++) { 987 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
@@ -1009,16 +1014,12 @@ qlcnic_reset_context(struct qlcnic_adapter *adapter)
1009 if (netif_running(netdev)) { 1014 if (netif_running(netdev)) {
1010 err = qlcnic_attach(adapter); 1015 err = qlcnic_attach(adapter);
1011 if (!err) 1016 if (!err)
1012 err = __qlcnic_up(adapter, netdev); 1017 __qlcnic_up(adapter, netdev);
1013
1014 if (err)
1015 goto done;
1016 } 1018 }
1017 1019
1018 netif_device_attach(netdev); 1020 netif_device_attach(netdev);
1019 } 1021 }
1020 1022
1021done:
1022 clear_bit(__QLCNIC_RESETTING, &adapter->state); 1023 clear_bit(__QLCNIC_RESETTING, &adapter->state);
1023 return err; 1024 return err;
1024} 1025}
@@ -1138,6 +1139,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1138 goto err_out_iounmap; 1139 goto err_out_iounmap;
1139 } 1140 }
1140 1141
1142 qlcnic_setup_idc_param(adapter);
1141 1143
1142 err = qlcnic_start_firmware(adapter); 1144 err = qlcnic_start_firmware(adapter);
1143 if (err) 1145 if (err)
@@ -1333,6 +1335,7 @@ err_out_detach:
1333 qlcnic_detach(adapter); 1335 qlcnic_detach(adapter);
1334err_out: 1336err_out:
1335 qlcnic_clr_all_drv_state(adapter); 1337 qlcnic_clr_all_drv_state(adapter);
1338 netif_device_attach(netdev);
1336 return err; 1339 return err;
1337} 1340}
1338#endif 1341#endif
@@ -1738,6 +1741,7 @@ static void qlcnic_tx_timeout_task(struct work_struct *work)
1738request_reset: 1741request_reset:
1739 adapter->need_fw_reset = 1; 1742 adapter->need_fw_reset = 1;
1740 clear_bit(__QLCNIC_RESETTING, &adapter->state); 1743 clear_bit(__QLCNIC_RESETTING, &adapter->state);
1744 QLCDB(adapter, DRV, "Resetting adapter\n");
1741} 1745}
1742 1746
1743static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev) 1747static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev)
@@ -2027,7 +2031,7 @@ static int
2027qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) 2031qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
2028{ 2032{
2029 u32 val, prev_state; 2033 u32 val, prev_state;
2030 int cnt = 0; 2034 u8 dev_init_timeo = adapter->dev_init_timeo;
2031 int portnum = adapter->portnum; 2035 int portnum = adapter->portnum;
2032 2036
2033 if (qlcnic_api_lock(adapter)) 2037 if (qlcnic_api_lock(adapter))
@@ -2042,6 +2046,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
2042 } 2046 }
2043 2047
2044 prev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); 2048 prev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
2049 QLCDB(adapter, HW, "Device state = %u\n", prev_state);
2045 2050
2046 switch (prev_state) { 2051 switch (prev_state) {
2047 case QLCNIC_DEV_COLD: 2052 case QLCNIC_DEV_COLD:
@@ -2072,13 +2077,17 @@ start_fw:
2072 } 2077 }
2073 2078
2074 qlcnic_api_unlock(adapter); 2079 qlcnic_api_unlock(adapter);
2075 msleep(1000); 2080
2076 while ((QLCRD32(adapter, QLCNIC_CRB_DEV_STATE) != QLCNIC_DEV_READY) && 2081 do {
2077 ++cnt < 20)
2078 msleep(1000); 2082 msleep(1000);
2083 } while ((QLCRD32(adapter, QLCNIC_CRB_DEV_STATE) != QLCNIC_DEV_READY)
2084 && --dev_init_timeo);
2079 2085
2080 if (cnt >= 20) 2086 if (!dev_init_timeo) {
2087 dev_err(&adapter->pdev->dev,
2088 "Waiting for device to initialize timeout\n");
2081 return -1; 2089 return -1;
2090 }
2082 2091
2083 if (qlcnic_api_lock(adapter)) 2092 if (qlcnic_api_lock(adapter))
2084 return -1; 2093 return -1;
@@ -2099,17 +2108,16 @@ qlcnic_fwinit_work(struct work_struct *work)
2099 struct qlcnic_adapter, fw_work.work); 2108 struct qlcnic_adapter, fw_work.work);
2100 int dev_state; 2109 int dev_state;
2101 2110
2102 if (++adapter->fw_wait_cnt > FW_POLL_THRESH)
2103 goto err_ret;
2104
2105 if (test_bit(__QLCNIC_START_FW, &adapter->state)) { 2111 if (test_bit(__QLCNIC_START_FW, &adapter->state)) {
2106 2112
2107 if (qlcnic_check_drv_state(adapter)) { 2113 if (qlcnic_check_drv_state(adapter) &&
2114 (adapter->fw_wait_cnt++ < adapter->reset_ack_timeo)) {
2108 qlcnic_schedule_work(adapter, 2115 qlcnic_schedule_work(adapter,
2109 qlcnic_fwinit_work, FW_POLL_DELAY); 2116 qlcnic_fwinit_work, FW_POLL_DELAY);
2110 return; 2117 return;
2111 } 2118 }
2112 2119
2120 QLCDB(adapter, DRV, "Resetting FW\n");
2113 if (!qlcnic_start_firmware(adapter)) { 2121 if (!qlcnic_start_firmware(adapter)) {
2114 qlcnic_schedule_work(adapter, qlcnic_attach_work, 0); 2122 qlcnic_schedule_work(adapter, qlcnic_attach_work, 0);
2115 return; 2123 return;
@@ -2118,7 +2126,15 @@ qlcnic_fwinit_work(struct work_struct *work)
2118 goto err_ret; 2126 goto err_ret;
2119 } 2127 }
2120 2128
2129 if (adapter->fw_wait_cnt++ > (adapter->dev_init_timeo / 2)) {
2130 dev_err(&adapter->pdev->dev,
2131 "Waiting for device to reset timeout\n");
2132 goto err_ret;
2133 }
2134
2121 dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); 2135 dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
2136 QLCDB(adapter, HW, "Func waiting: Device state=%d\n", dev_state);
2137
2122 switch (dev_state) { 2138 switch (dev_state) {
2123 case QLCNIC_DEV_READY: 2139 case QLCNIC_DEV_READY:
2124 if (!qlcnic_start_firmware(adapter)) { 2140 if (!qlcnic_start_firmware(adapter)) {
@@ -2135,6 +2151,7 @@ qlcnic_fwinit_work(struct work_struct *work)
2135 } 2151 }
2136 2152
2137err_ret: 2153err_ret:
2154 netif_device_attach(adapter->netdev);
2138 qlcnic_clr_all_drv_state(adapter); 2155 qlcnic_clr_all_drv_state(adapter);
2139} 2156}
2140 2157
@@ -2171,6 +2188,9 @@ qlcnic_detach_work(struct work_struct *work)
2171 return; 2188 return;
2172 2189
2173err_ret: 2190err_ret:
2191 dev_err(&adapter->pdev->dev, "detach failed; status=%d temp=%d\n",
2192 status, adapter->temp);
2193 netif_device_attach(netdev);
2174 qlcnic_clr_all_drv_state(adapter); 2194 qlcnic_clr_all_drv_state(adapter);
2175 2195
2176} 2196}
@@ -2188,6 +2208,7 @@ qlcnic_dev_request_reset(struct qlcnic_adapter *adapter)
2188 if (state != QLCNIC_DEV_INITALIZING && state != QLCNIC_DEV_NEED_RESET) { 2208 if (state != QLCNIC_DEV_INITALIZING && state != QLCNIC_DEV_NEED_RESET) {
2189 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_NEED_RESET); 2209 QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_NEED_RESET);
2190 set_bit(__QLCNIC_START_FW, &adapter->state); 2210 set_bit(__QLCNIC_START_FW, &adapter->state);
2211 QLCDB(adapter, DRV, "NEED_RESET state set\n");
2191 } 2212 }
2192 2213
2193 qlcnic_api_unlock(adapter); 2214 qlcnic_api_unlock(adapter);
@@ -2232,9 +2253,8 @@ qlcnic_attach_work(struct work_struct *work)
2232 qlcnic_config_indev_addr(netdev, NETDEV_UP); 2253 qlcnic_config_indev_addr(netdev, NETDEV_UP);
2233 } 2254 }
2234 2255
2235 netif_device_attach(netdev);
2236
2237done: 2256done:
2257 netif_device_attach(netdev);
2238 adapter->fw_fail_cnt = 0; 2258 adapter->fw_fail_cnt = 0;
2239 clear_bit(__QLCNIC_RESETTING, &adapter->state); 2259 clear_bit(__QLCNIC_RESETTING, &adapter->state);
2240 2260
@@ -2284,8 +2304,11 @@ detach:
2284 QLCNIC_DEV_NEED_RESET; 2304 QLCNIC_DEV_NEED_RESET;
2285 2305
2286 if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) && 2306 if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) &&
2287 !test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) 2307 !test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) {
2308
2288 qlcnic_schedule_work(adapter, qlcnic_detach_work, 0); 2309 qlcnic_schedule_work(adapter, qlcnic_detach_work, 0);
2310 QLCDB(adapter, DRV, "fw recovery scheduled.\n");
2311 }
2289 2312
2290 return 1; 2313 return 1;
2291} 2314}
@@ -2386,14 +2409,21 @@ static int
2386qlcnic_sysfs_validate_crb(struct qlcnic_adapter *adapter, 2409qlcnic_sysfs_validate_crb(struct qlcnic_adapter *adapter,
2387 loff_t offset, size_t size) 2410 loff_t offset, size_t size)
2388{ 2411{
2412 size_t crb_size = 4;
2413
2389 if (!(adapter->flags & QLCNIC_DIAG_ENABLED)) 2414 if (!(adapter->flags & QLCNIC_DIAG_ENABLED))
2390 return -EIO; 2415 return -EIO;
2391 2416
2392 if ((size != 4) || (offset & 0x3)) 2417 if (offset < QLCNIC_PCI_CRBSPACE) {
2393 return -EINVAL; 2418 if (ADDR_IN_RANGE(offset, QLCNIC_PCI_CAMQM,
2419 QLCNIC_PCI_CAMQM_END))
2420 crb_size = 8;
2421 else
2422 return -EINVAL;
2423 }
2394 2424
2395 if (offset < QLCNIC_PCI_CRBSPACE) 2425 if ((size != crb_size) || (offset & (crb_size-1)))
2396 return -EINVAL; 2426 return -EINVAL;
2397 2427
2398 return 0; 2428 return 0;
2399} 2429}
@@ -2405,14 +2435,20 @@ qlcnic_sysfs_read_crb(struct kobject *kobj, struct bin_attribute *attr,
2405 struct device *dev = container_of(kobj, struct device, kobj); 2435 struct device *dev = container_of(kobj, struct device, kobj);
2406 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 2436 struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
2407 u32 data; 2437 u32 data;
2438 u64 qmdata;
2408 int ret; 2439 int ret;
2409 2440
2410 ret = qlcnic_sysfs_validate_crb(adapter, offset, size); 2441 ret = qlcnic_sysfs_validate_crb(adapter, offset, size);
2411 if (ret != 0) 2442 if (ret != 0)
2412 return ret; 2443 return ret;
2413 2444
2414 data = QLCRD32(adapter, offset); 2445 if (ADDR_IN_RANGE(offset, QLCNIC_PCI_CAMQM, QLCNIC_PCI_CAMQM_END)) {
2415 memcpy(buf, &data, size); 2446 qlcnic_pci_camqm_read_2M(adapter, offset, &qmdata);
2447 memcpy(buf, &qmdata, size);
2448 } else {
2449 data = QLCRD32(adapter, offset);
2450 memcpy(buf, &data, size);
2451 }
2416 return size; 2452 return size;
2417} 2453}
2418 2454
@@ -2423,14 +2459,20 @@ qlcnic_sysfs_write_crb(struct kobject *kobj, struct bin_attribute *attr,
2423 struct device *dev = container_of(kobj, struct device, kobj); 2459 struct device *dev = container_of(kobj, struct device, kobj);
2424 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 2460 struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
2425 u32 data; 2461 u32 data;
2462 u64 qmdata;
2426 int ret; 2463 int ret;
2427 2464
2428 ret = qlcnic_sysfs_validate_crb(adapter, offset, size); 2465 ret = qlcnic_sysfs_validate_crb(adapter, offset, size);
2429 if (ret != 0) 2466 if (ret != 0)
2430 return ret; 2467 return ret;
2431 2468
2432 memcpy(&data, buf, size); 2469 if (ADDR_IN_RANGE(offset, QLCNIC_PCI_CAMQM, QLCNIC_PCI_CAMQM_END)) {
2433 QLCWR32(adapter, offset, data); 2470 memcpy(&qmdata, buf, size);
2471 qlcnic_pci_camqm_write_2M(adapter, offset, qmdata);
2472 } else {
2473 memcpy(&data, buf, size);
2474 QLCWR32(adapter, offset, data);
2475 }
2434 return size; 2476 return size;
2435} 2477}
2436 2478
diff --git a/drivers/net/qlge/qlge_dbg.c b/drivers/net/qlge/qlge_dbg.c
index ff8550d2ca82..947a7aa2400e 100644
--- a/drivers/net/qlge/qlge_dbg.c
+++ b/drivers/net/qlge/qlge_dbg.c
@@ -1338,7 +1338,7 @@ void ql_mpi_core_to_log(struct work_struct *work)
1338 1338
1339 for (i = 0; i < count; i += 8) { 1339 for (i = 0; i < count; i += 8) {
1340 printk(KERN_ERR "%.08x: %.08x %.08x %.08x %.08x %.08x " 1340 printk(KERN_ERR "%.08x: %.08x %.08x %.08x %.08x %.08x "
1341 "%.08x %.08x %.08x \n", i, 1341 "%.08x %.08x %.08x\n", i,
1342 tmp[i + 0], 1342 tmp[i + 0],
1343 tmp[i + 1], 1343 tmp[i + 1],
1344 tmp[i + 2], 1344 tmp[i + 2],
@@ -2056,7 +2056,7 @@ void ql_dump_ob_mac_iocb(struct ob_mac_iocb_req *ob_mac_iocb)
2056 ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_LSO ? "LSO" : "", 2056 ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_LSO ? "LSO" : "",
2057 ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_UC ? "UC" : "", 2057 ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_UC ? "UC" : "",
2058 ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_TC ? "TC" : ""); 2058 ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_TC ? "TC" : "");
2059 printk(KERN_ERR PFX "flags3 = %s %s %s \n", 2059 printk(KERN_ERR PFX "flags3 = %s %s %s\n",
2060 ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_IC ? "IC" : "", 2060 ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_IC ? "IC" : "",
2061 ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_DFP ? "DFP" : "", 2061 ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_DFP ? "DFP" : "",
2062 ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_V ? "V" : ""); 2062 ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_V ? "V" : "");
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index fd34f266c0a8..76df96813a7b 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -4207,7 +4207,7 @@ static struct net_device_stats *qlge_get_stats(struct net_device
4207static void qlge_set_multicast_list(struct net_device *ndev) 4207static void qlge_set_multicast_list(struct net_device *ndev)
4208{ 4208{
4209 struct ql_adapter *qdev = (struct ql_adapter *)netdev_priv(ndev); 4209 struct ql_adapter *qdev = (struct ql_adapter *)netdev_priv(ndev);
4210 struct dev_mc_list *mc_ptr; 4210 struct netdev_hw_addr *ha;
4211 int i, status; 4211 int i, status;
4212 4212
4213 status = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK); 4213 status = ql_sem_spinlock(qdev, SEM_RT_IDX_MASK);
@@ -4271,8 +4271,8 @@ static void qlge_set_multicast_list(struct net_device *ndev)
4271 if (status) 4271 if (status)
4272 goto exit; 4272 goto exit;
4273 i = 0; 4273 i = 0;
4274 netdev_for_each_mc_addr(mc_ptr, ndev) { 4274 netdev_for_each_mc_addr(ha, ndev) {
4275 if (ql_set_mac_addr_reg(qdev, (u8 *) mc_ptr->dmi_addr, 4275 if (ql_set_mac_addr_reg(qdev, (u8 *) ha->addr,
4276 MAC_ADDR_TYPE_MULTI_MAC, i)) { 4276 MAC_ADDR_TYPE_MULTI_MAC, i)) {
4277 netif_err(qdev, hw, qdev->ndev, 4277 netif_err(qdev, hw, qdev->ndev,
4278 "Failed to loadmulticast address.\n"); 4278 "Failed to loadmulticast address.\n");
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index 15d5373dc8f3..f5a0e963e688 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -938,7 +938,7 @@ static void r6040_multicast_list(struct net_device *dev)
938 u16 *adrp; 938 u16 *adrp;
939 u16 reg; 939 u16 reg;
940 unsigned long flags; 940 unsigned long flags;
941 struct dev_mc_list *dmi; 941 struct netdev_hw_addr *ha;
942 int i; 942 int i;
943 943
944 /* MAC Address */ 944 /* MAC Address */
@@ -973,8 +973,8 @@ static void r6040_multicast_list(struct net_device *dev)
973 for (i = 0; i < 4; i++) 973 for (i = 0; i < 4; i++)
974 hash_table[i] = 0; 974 hash_table[i] = 0;
975 975
976 netdev_for_each_mc_addr(dmi, dev) { 976 netdev_for_each_mc_addr(ha, dev) {
977 char *addrs = dmi->dmi_addr; 977 char *addrs = ha->addr;
978 978
979 if (!(*addrs & 1)) 979 if (!(*addrs & 1))
980 continue; 980 continue;
@@ -994,9 +994,9 @@ static void r6040_multicast_list(struct net_device *dev)
994 } 994 }
995 /* Multicast Address 1~4 case */ 995 /* Multicast Address 1~4 case */
996 i = 0; 996 i = 0;
997 netdev_for_each_mc_addr(dmi, dev) { 997 netdev_for_each_mc_addr(ha, dev) {
998 if (i < MCAST_MAX) { 998 if (i < MCAST_MAX) {
999 adrp = (u16 *) dmi->dmi_addr; 999 adrp = (u16 *) ha->addr;
1000 iowrite16(adrp[0], ioaddr + MID_1L + 8 * i); 1000 iowrite16(adrp[0], ioaddr + MID_1L + 8 * i);
1001 iowrite16(adrp[1], ioaddr + MID_1M + 8 * i); 1001 iowrite16(adrp[1], ioaddr + MID_1M + 8 * i);
1002 iowrite16(adrp[2], ioaddr + MID_1H + 8 * i); 1002 iowrite16(adrp[2], ioaddr + MID_1H + 8 * i);
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index dbb1f5a1824c..340da3915b96 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -23,6 +23,7 @@
23#include <linux/tcp.h> 23#include <linux/tcp.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
26#include <linux/pm_runtime.h>
26 27
27#include <asm/system.h> 28#include <asm/system.h>
28#include <asm/io.h> 29#include <asm/io.h>
@@ -509,6 +510,7 @@ struct rtl8169_private {
509 510
510 struct mii_if_info mii; 511 struct mii_if_info mii;
511 struct rtl8169_counters counters; 512 struct rtl8169_counters counters;
513 u32 saved_wolopts;
512}; 514};
513 515
514MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>"); 516MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>");
@@ -748,53 +750,61 @@ static void rtl8169_check_link_status(struct net_device *dev,
748 750
749 spin_lock_irqsave(&tp->lock, flags); 751 spin_lock_irqsave(&tp->lock, flags);
750 if (tp->link_ok(ioaddr)) { 752 if (tp->link_ok(ioaddr)) {
753 /* This is to cancel a scheduled suspend if there's one. */
754 pm_request_resume(&tp->pci_dev->dev);
751 netif_carrier_on(dev); 755 netif_carrier_on(dev);
752 netif_info(tp, ifup, dev, "link up\n"); 756 netif_info(tp, ifup, dev, "link up\n");
753 } else { 757 } else {
754 netif_carrier_off(dev); 758 netif_carrier_off(dev);
755 netif_info(tp, ifdown, dev, "link down\n"); 759 netif_info(tp, ifdown, dev, "link down\n");
760 pm_schedule_suspend(&tp->pci_dev->dev, 100);
756 } 761 }
757 spin_unlock_irqrestore(&tp->lock, flags); 762 spin_unlock_irqrestore(&tp->lock, flags);
758} 763}
759 764
760static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 765#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST)
766
767static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
761{ 768{
762 struct rtl8169_private *tp = netdev_priv(dev);
763 void __iomem *ioaddr = tp->mmio_addr; 769 void __iomem *ioaddr = tp->mmio_addr;
764 u8 options; 770 u8 options;
765 771 u32 wolopts = 0;
766 wol->wolopts = 0;
767
768#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST)
769 wol->supported = WAKE_ANY;
770
771 spin_lock_irq(&tp->lock);
772 772
773 options = RTL_R8(Config1); 773 options = RTL_R8(Config1);
774 if (!(options & PMEnable)) 774 if (!(options & PMEnable))
775 goto out_unlock; 775 return 0;
776 776
777 options = RTL_R8(Config3); 777 options = RTL_R8(Config3);
778 if (options & LinkUp) 778 if (options & LinkUp)
779 wol->wolopts |= WAKE_PHY; 779 wolopts |= WAKE_PHY;
780 if (options & MagicPacket) 780 if (options & MagicPacket)
781 wol->wolopts |= WAKE_MAGIC; 781 wolopts |= WAKE_MAGIC;
782 782
783 options = RTL_R8(Config5); 783 options = RTL_R8(Config5);
784 if (options & UWF) 784 if (options & UWF)
785 wol->wolopts |= WAKE_UCAST; 785 wolopts |= WAKE_UCAST;
786 if (options & BWF) 786 if (options & BWF)
787 wol->wolopts |= WAKE_BCAST; 787 wolopts |= WAKE_BCAST;
788 if (options & MWF) 788 if (options & MWF)
789 wol->wolopts |= WAKE_MCAST; 789 wolopts |= WAKE_MCAST;
790 790
791out_unlock: 791 return wolopts;
792 spin_unlock_irq(&tp->lock);
793} 792}
794 793
795static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 794static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
796{ 795{
797 struct rtl8169_private *tp = netdev_priv(dev); 796 struct rtl8169_private *tp = netdev_priv(dev);
797
798 spin_lock_irq(&tp->lock);
799
800 wol->supported = WAKE_ANY;
801 wol->wolopts = __rtl8169_get_wol(tp);
802
803 spin_unlock_irq(&tp->lock);
804}
805
806static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
807{
798 void __iomem *ioaddr = tp->mmio_addr; 808 void __iomem *ioaddr = tp->mmio_addr;
799 unsigned int i; 809 unsigned int i;
800 static const struct { 810 static const struct {
@@ -811,23 +821,29 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
811 { WAKE_ANY, Config5, LanWake } 821 { WAKE_ANY, Config5, LanWake }
812 }; 822 };
813 823
814 spin_lock_irq(&tp->lock);
815
816 RTL_W8(Cfg9346, Cfg9346_Unlock); 824 RTL_W8(Cfg9346, Cfg9346_Unlock);
817 825
818 for (i = 0; i < ARRAY_SIZE(cfg); i++) { 826 for (i = 0; i < ARRAY_SIZE(cfg); i++) {
819 u8 options = RTL_R8(cfg[i].reg) & ~cfg[i].mask; 827 u8 options = RTL_R8(cfg[i].reg) & ~cfg[i].mask;
820 if (wol->wolopts & cfg[i].opt) 828 if (wolopts & cfg[i].opt)
821 options |= cfg[i].mask; 829 options |= cfg[i].mask;
822 RTL_W8(cfg[i].reg, options); 830 RTL_W8(cfg[i].reg, options);
823 } 831 }
824 832
825 RTL_W8(Cfg9346, Cfg9346_Lock); 833 RTL_W8(Cfg9346, Cfg9346_Lock);
834}
835
836static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
837{
838 struct rtl8169_private *tp = netdev_priv(dev);
839
840 spin_lock_irq(&tp->lock);
826 841
827 if (wol->wolopts) 842 if (wol->wolopts)
828 tp->features |= RTL_FEATURE_WOL; 843 tp->features |= RTL_FEATURE_WOL;
829 else 844 else
830 tp->features &= ~RTL_FEATURE_WOL; 845 tp->features &= ~RTL_FEATURE_WOL;
846 __rtl8169_set_wol(tp, wol->wolopts);
831 device_set_wakeup_enable(&tp->pci_dev->dev, wol->wolopts); 847 device_set_wakeup_enable(&tp->pci_dev->dev, wol->wolopts);
832 848
833 spin_unlock_irq(&tp->lock); 849 spin_unlock_irq(&tp->lock);
@@ -1042,14 +1058,14 @@ static void rtl8169_vlan_rx_register(struct net_device *dev,
1042} 1058}
1043 1059
1044static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, 1060static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc,
1045 struct sk_buff *skb) 1061 struct sk_buff *skb, int polling)
1046{ 1062{
1047 u32 opts2 = le32_to_cpu(desc->opts2); 1063 u32 opts2 = le32_to_cpu(desc->opts2);
1048 struct vlan_group *vlgrp = tp->vlgrp; 1064 struct vlan_group *vlgrp = tp->vlgrp;
1049 int ret; 1065 int ret;
1050 1066
1051 if (vlgrp && (opts2 & RxVlanTag)) { 1067 if (vlgrp && (opts2 & RxVlanTag)) {
1052 vlan_hwaccel_receive_skb(skb, vlgrp, swab16(opts2 & 0xffff)); 1068 __vlan_hwaccel_rx(skb, vlgrp, swab16(opts2 & 0xffff), polling);
1053 ret = 0; 1069 ret = 0;
1054 } else 1070 } else
1055 ret = -1; 1071 ret = -1;
@@ -1066,7 +1082,7 @@ static inline u32 rtl8169_tx_vlan_tag(struct rtl8169_private *tp,
1066} 1082}
1067 1083
1068static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, 1084static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc,
1069 struct sk_buff *skb) 1085 struct sk_buff *skb, int polling)
1070{ 1086{
1071 return -1; 1087 return -1;
1072} 1088}
@@ -3187,6 +3203,12 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3187 3203
3188 device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL); 3204 device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL);
3189 3205
3206 if (pci_dev_run_wake(pdev)) {
3207 pm_runtime_set_active(&pdev->dev);
3208 pm_runtime_enable(&pdev->dev);
3209 }
3210 pm_runtime_idle(&pdev->dev);
3211
3190out: 3212out:
3191 return rc; 3213 return rc;
3192 3214
@@ -3209,10 +3231,18 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
3209 struct net_device *dev = pci_get_drvdata(pdev); 3231 struct net_device *dev = pci_get_drvdata(pdev);
3210 struct rtl8169_private *tp = netdev_priv(dev); 3232 struct rtl8169_private *tp = netdev_priv(dev);
3211 3233
3234 pm_runtime_get_sync(&pdev->dev);
3235
3212 flush_scheduled_work(); 3236 flush_scheduled_work();
3213 3237
3214 unregister_netdev(dev); 3238 unregister_netdev(dev);
3215 3239
3240 if (pci_dev_run_wake(pdev)) {
3241 pm_runtime_disable(&pdev->dev);
3242 pm_runtime_set_suspended(&pdev->dev);
3243 }
3244 pm_runtime_put_noidle(&pdev->dev);
3245
3216 /* restore original MAC address */ 3246 /* restore original MAC address */
3217 rtl_rar_set(tp, dev->perm_addr); 3247 rtl_rar_set(tp, dev->perm_addr);
3218 3248
@@ -3239,6 +3269,7 @@ static int rtl8169_open(struct net_device *dev)
3239 struct pci_dev *pdev = tp->pci_dev; 3269 struct pci_dev *pdev = tp->pci_dev;
3240 int retval = -ENOMEM; 3270 int retval = -ENOMEM;
3241 3271
3272 pm_runtime_get_sync(&pdev->dev);
3242 3273
3243 /* 3274 /*
3244 * Note that we use a magic value here, its wierd I know 3275 * Note that we use a magic value here, its wierd I know
@@ -3259,7 +3290,7 @@ static int rtl8169_open(struct net_device *dev)
3259 tp->TxDescArray = pci_alloc_consistent(pdev, R8169_TX_RING_BYTES, 3290 tp->TxDescArray = pci_alloc_consistent(pdev, R8169_TX_RING_BYTES,
3260 &tp->TxPhyAddr); 3291 &tp->TxPhyAddr);
3261 if (!tp->TxDescArray) 3292 if (!tp->TxDescArray)
3262 goto out; 3293 goto err_pm_runtime_put;
3263 3294
3264 tp->RxDescArray = pci_alloc_consistent(pdev, R8169_RX_RING_BYTES, 3295 tp->RxDescArray = pci_alloc_consistent(pdev, R8169_RX_RING_BYTES,
3265 &tp->RxPhyAddr); 3296 &tp->RxPhyAddr);
@@ -3286,6 +3317,9 @@ static int rtl8169_open(struct net_device *dev)
3286 3317
3287 rtl8169_request_timer(dev); 3318 rtl8169_request_timer(dev);
3288 3319
3320 tp->saved_wolopts = 0;
3321 pm_runtime_put_noidle(&pdev->dev);
3322
3289 rtl8169_check_link_status(dev, tp, tp->mmio_addr); 3323 rtl8169_check_link_status(dev, tp, tp->mmio_addr);
3290out: 3324out:
3291 return retval; 3325 return retval;
@@ -3295,9 +3329,13 @@ err_release_ring_2:
3295err_free_rx_1: 3329err_free_rx_1:
3296 pci_free_consistent(pdev, R8169_RX_RING_BYTES, tp->RxDescArray, 3330 pci_free_consistent(pdev, R8169_RX_RING_BYTES, tp->RxDescArray,
3297 tp->RxPhyAddr); 3331 tp->RxPhyAddr);
3332 tp->RxDescArray = NULL;
3298err_free_tx_0: 3333err_free_tx_0:
3299 pci_free_consistent(pdev, R8169_TX_RING_BYTES, tp->TxDescArray, 3334 pci_free_consistent(pdev, R8169_TX_RING_BYTES, tp->TxDescArray,
3300 tp->TxPhyAddr); 3335 tp->TxPhyAddr);
3336 tp->TxDescArray = NULL;
3337err_pm_runtime_put:
3338 pm_runtime_put_noidle(&pdev->dev);
3301 goto out; 3339 goto out;
3302} 3340}
3303 3341
@@ -4441,12 +4479,20 @@ out:
4441 return done; 4479 return done;
4442} 4480}
4443 4481
4482/*
4483 * Warning : rtl8169_rx_interrupt() might be called :
4484 * 1) from NAPI (softirq) context
4485 * (polling = 1 : we should call netif_receive_skb())
4486 * 2) from process context (rtl8169_reset_task())
4487 * (polling = 0 : we must call netif_rx() instead)
4488 */
4444static int rtl8169_rx_interrupt(struct net_device *dev, 4489static int rtl8169_rx_interrupt(struct net_device *dev,
4445 struct rtl8169_private *tp, 4490 struct rtl8169_private *tp,
4446 void __iomem *ioaddr, u32 budget) 4491 void __iomem *ioaddr, u32 budget)
4447{ 4492{
4448 unsigned int cur_rx, rx_left; 4493 unsigned int cur_rx, rx_left;
4449 unsigned int delta, count; 4494 unsigned int delta, count;
4495 int polling = (budget != ~(u32)0) ? 1 : 0;
4450 4496
4451 cur_rx = tp->cur_rx; 4497 cur_rx = tp->cur_rx;
4452 rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; 4498 rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx;
@@ -4508,8 +4554,12 @@ static int rtl8169_rx_interrupt(struct net_device *dev,
4508 skb_put(skb, pkt_size); 4554 skb_put(skb, pkt_size);
4509 skb->protocol = eth_type_trans(skb, dev); 4555 skb->protocol = eth_type_trans(skb, dev);
4510 4556
4511 if (rtl8169_rx_vlan_skb(tp, desc, skb) < 0) 4557 if (rtl8169_rx_vlan_skb(tp, desc, skb, polling) < 0) {
4512 netif_receive_skb(skb); 4558 if (likely(polling))
4559 netif_receive_skb(skb);
4560 else
4561 netif_rx(skb);
4562 }
4513 4563
4514 dev->stats.rx_bytes += pkt_size; 4564 dev->stats.rx_bytes += pkt_size;
4515 dev->stats.rx_packets++; 4565 dev->stats.rx_packets++;
@@ -4704,6 +4754,8 @@ static int rtl8169_close(struct net_device *dev)
4704 struct rtl8169_private *tp = netdev_priv(dev); 4754 struct rtl8169_private *tp = netdev_priv(dev);
4705 struct pci_dev *pdev = tp->pci_dev; 4755 struct pci_dev *pdev = tp->pci_dev;
4706 4756
4757 pm_runtime_get_sync(&pdev->dev);
4758
4707 /* update counters before going down */ 4759 /* update counters before going down */
4708 rtl8169_update_counters(dev); 4760 rtl8169_update_counters(dev);
4709 4761
@@ -4718,6 +4770,8 @@ static int rtl8169_close(struct net_device *dev)
4718 tp->TxDescArray = NULL; 4770 tp->TxDescArray = NULL;
4719 tp->RxDescArray = NULL; 4771 tp->RxDescArray = NULL;
4720 4772
4773 pm_runtime_put_sync(&pdev->dev);
4774
4721 return 0; 4775 return 0;
4722} 4776}
4723 4777
@@ -4743,12 +4797,12 @@ static void rtl_set_rx_mode(struct net_device *dev)
4743 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; 4797 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
4744 mc_filter[1] = mc_filter[0] = 0xffffffff; 4798 mc_filter[1] = mc_filter[0] = 0xffffffff;
4745 } else { 4799 } else {
4746 struct dev_mc_list *mclist; 4800 struct netdev_hw_addr *ha;
4747 4801
4748 rx_mode = AcceptBroadcast | AcceptMyPhys; 4802 rx_mode = AcceptBroadcast | AcceptMyPhys;
4749 mc_filter[1] = mc_filter[0] = 0; 4803 mc_filter[1] = mc_filter[0] = 0;
4750 netdev_for_each_mc_addr(mclist, dev) { 4804 netdev_for_each_mc_addr(ha, dev) {
4751 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; 4805 int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
4752 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); 4806 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
4753 rx_mode |= AcceptMulticast; 4807 rx_mode |= AcceptMulticast;
4754 } 4808 }
@@ -4816,21 +4870,74 @@ static int rtl8169_suspend(struct device *device)
4816 return 0; 4870 return 0;
4817} 4871}
4818 4872
4873static void __rtl8169_resume(struct net_device *dev)
4874{
4875 netif_device_attach(dev);
4876 rtl8169_schedule_work(dev, rtl8169_reset_task);
4877}
4878
4819static int rtl8169_resume(struct device *device) 4879static int rtl8169_resume(struct device *device)
4820{ 4880{
4821 struct pci_dev *pdev = to_pci_dev(device); 4881 struct pci_dev *pdev = to_pci_dev(device);
4822 struct net_device *dev = pci_get_drvdata(pdev); 4882 struct net_device *dev = pci_get_drvdata(pdev);
4823 4883
4824 if (!netif_running(dev)) 4884 if (netif_running(dev))
4825 goto out; 4885 __rtl8169_resume(dev);
4826 4886
4827 netif_device_attach(dev); 4887 return 0;
4888}
4889
4890static int rtl8169_runtime_suspend(struct device *device)
4891{
4892 struct pci_dev *pdev = to_pci_dev(device);
4893 struct net_device *dev = pci_get_drvdata(pdev);
4894 struct rtl8169_private *tp = netdev_priv(dev);
4895
4896 if (!tp->TxDescArray)
4897 return 0;
4898
4899 spin_lock_irq(&tp->lock);
4900 tp->saved_wolopts = __rtl8169_get_wol(tp);
4901 __rtl8169_set_wol(tp, WAKE_ANY);
4902 spin_unlock_irq(&tp->lock);
4903
4904 rtl8169_net_suspend(dev);
4828 4905
4829 rtl8169_schedule_work(dev, rtl8169_reset_task);
4830out:
4831 return 0; 4906 return 0;
4832} 4907}
4833 4908
4909static int rtl8169_runtime_resume(struct device *device)
4910{
4911 struct pci_dev *pdev = to_pci_dev(device);
4912 struct net_device *dev = pci_get_drvdata(pdev);
4913 struct rtl8169_private *tp = netdev_priv(dev);
4914
4915 if (!tp->TxDescArray)
4916 return 0;
4917
4918 spin_lock_irq(&tp->lock);
4919 __rtl8169_set_wol(tp, tp->saved_wolopts);
4920 tp->saved_wolopts = 0;
4921 spin_unlock_irq(&tp->lock);
4922
4923 __rtl8169_resume(dev);
4924
4925 return 0;
4926}
4927
4928static int rtl8169_runtime_idle(struct device *device)
4929{
4930 struct pci_dev *pdev = to_pci_dev(device);
4931 struct net_device *dev = pci_get_drvdata(pdev);
4932 struct rtl8169_private *tp = netdev_priv(dev);
4933
4934 if (!tp->TxDescArray)
4935 return 0;
4936
4937 rtl8169_check_link_status(dev, tp, tp->mmio_addr);
4938 return -EBUSY;
4939}
4940
4834static const struct dev_pm_ops rtl8169_pm_ops = { 4941static const struct dev_pm_ops rtl8169_pm_ops = {
4835 .suspend = rtl8169_suspend, 4942 .suspend = rtl8169_suspend,
4836 .resume = rtl8169_resume, 4943 .resume = rtl8169_resume,
@@ -4838,6 +4945,9 @@ static const struct dev_pm_ops rtl8169_pm_ops = {
4838 .thaw = rtl8169_resume, 4945 .thaw = rtl8169_resume,
4839 .poweroff = rtl8169_suspend, 4946 .poweroff = rtl8169_suspend,
4840 .restore = rtl8169_resume, 4947 .restore = rtl8169_resume,
4948 .runtime_suspend = rtl8169_runtime_suspend,
4949 .runtime_resume = rtl8169_runtime_resume,
4950 .runtime_idle = rtl8169_runtime_idle,
4841}; 4951};
4842 4952
4843#define RTL8169_PM_OPS (&rtl8169_pm_ops) 4953#define RTL8169_PM_OPS (&rtl8169_pm_ops)
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 2eb7f8a0d926..ad5a6a873b29 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -4964,7 +4964,7 @@ static struct net_device_stats *s2io_get_stats(struct net_device *dev)
4964static void s2io_set_multicast(struct net_device *dev) 4964static void s2io_set_multicast(struct net_device *dev)
4965{ 4965{
4966 int i, j, prev_cnt; 4966 int i, j, prev_cnt;
4967 struct dev_mc_list *mclist; 4967 struct netdev_hw_addr *ha;
4968 struct s2io_nic *sp = netdev_priv(dev); 4968 struct s2io_nic *sp = netdev_priv(dev);
4969 struct XENA_dev_config __iomem *bar0 = sp->bar0; 4969 struct XENA_dev_config __iomem *bar0 = sp->bar0;
4970 u64 val64 = 0, multi_mac = 0x010203040506ULL, mask = 4970 u64 val64 = 0, multi_mac = 0x010203040506ULL, mask =
@@ -5093,12 +5093,12 @@ static void s2io_set_multicast(struct net_device *dev)
5093 5093
5094 /* Create the new Rx filter list and update the same in H/W. */ 5094 /* Create the new Rx filter list and update the same in H/W. */
5095 i = 0; 5095 i = 0;
5096 netdev_for_each_mc_addr(mclist, dev) { 5096 netdev_for_each_mc_addr(ha, dev) {
5097 memcpy(sp->usr_addrs[i].addr, mclist->dmi_addr, 5097 memcpy(sp->usr_addrs[i].addr, ha->addr,
5098 ETH_ALEN); 5098 ETH_ALEN);
5099 mac_addr = 0; 5099 mac_addr = 0;
5100 for (j = 0; j < ETH_ALEN; j++) { 5100 for (j = 0; j < ETH_ALEN; j++) {
5101 mac_addr |= mclist->dmi_addr[j]; 5101 mac_addr |= ha->addr[j];
5102 mac_addr <<= 8; 5102 mac_addr <<= 8;
5103 } 5103 }
5104 mac_addr >>= 8; 5104 mac_addr >>= 8;
diff --git a/drivers/net/s6gmac.c b/drivers/net/s6gmac.c
index 45f26344b368..6b12524ad7c1 100644
--- a/drivers/net/s6gmac.c
+++ b/drivers/net/s6gmac.c
@@ -396,7 +396,6 @@ static void s6gmac_rx_interrupt(struct net_device *dev)
396 } else { 396 } else {
397 skb_put(skb, (pfx >> S6_GMAC_BURST_POSTRD_LEN) 397 skb_put(skb, (pfx >> S6_GMAC_BURST_POSTRD_LEN)
398 & S6_GMAC_BURST_POSTRD_LEN_MASK); 398 & S6_GMAC_BURST_POSTRD_LEN_MASK);
399 skb->dev = dev;
400 skb->protocol = eth_type_trans(skb, dev); 399 skb->protocol = eth_type_trans(skb, dev);
401 skb->ip_summed = CHECKSUM_UNNECESSARY; 400 skb->ip_summed = CHECKSUM_UNNECESSARY;
402 netif_rx(skb); 401 netif_rx(skb);
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index 9944e5d662c0..332031747a23 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -2112,7 +2112,7 @@ static void sbmac_setmulti(struct sbmac_softc *sc)
2112 uint64_t reg; 2112 uint64_t reg;
2113 void __iomem *port; 2113 void __iomem *port;
2114 int idx; 2114 int idx;
2115 struct dev_mc_list *mclist; 2115 struct netdev_hw_addr *ha;
2116 struct net_device *dev = sc->sbm_dev; 2116 struct net_device *dev = sc->sbm_dev;
2117 2117
2118 /* 2118 /*
@@ -2161,10 +2161,10 @@ static void sbmac_setmulti(struct sbmac_softc *sc)
2161 * XXX if the table overflows */ 2161 * XXX if the table overflows */
2162 2162
2163 idx = 1; /* skip station address */ 2163 idx = 1; /* skip station address */
2164 netdev_for_each_mc_addr(mclist, dev) { 2164 netdev_for_each_mc_addr(ha, dev) {
2165 if (idx == MAC_ADDR_COUNT) 2165 if (idx == MAC_ADDR_COUNT)
2166 break; 2166 break;
2167 reg = sbmac_addr2reg(mclist->dmi_addr); 2167 reg = sbmac_addr2reg(ha->addr);
2168 port = sc->sbm_base + R_MAC_ADDR_BASE+(idx * sizeof(uint64_t)); 2168 port = sc->sbm_base + R_MAC_ADDR_BASE+(idx * sizeof(uint64_t));
2169 __raw_writeq(reg, port); 2169 __raw_writeq(reg, port);
2170 idx++; 2170 idx++;
@@ -2664,7 +2664,6 @@ static int sbmac_close(struct net_device *dev)
2664static int sbmac_poll(struct napi_struct *napi, int budget) 2664static int sbmac_poll(struct napi_struct *napi, int budget)
2665{ 2665{
2666 struct sbmac_softc *sc = container_of(napi, struct sbmac_softc, napi); 2666 struct sbmac_softc *sc = container_of(napi, struct sbmac_softc, napi);
2667 struct net_device *dev = sc->sbm_dev;
2668 int work_done; 2667 int work_done;
2669 2668
2670 work_done = sbdma_rx_process(sc, &(sc->sbm_rxdma), budget, 1); 2669 work_done = sbdma_rx_process(sc, &(sc->sbm_rxdma), budget, 1);
diff --git a/drivers/net/sc92031.c b/drivers/net/sc92031.c
index d87c4787fffa..1b3260588933 100644
--- a/drivers/net/sc92031.c
+++ b/drivers/net/sc92031.c
@@ -433,13 +433,13 @@ static void _sc92031_set_mar(struct net_device *dev)
433 (dev->flags & IFF_ALLMULTI)) 433 (dev->flags & IFF_ALLMULTI))
434 mar0 = mar1 = 0xffffffff; 434 mar0 = mar1 = 0xffffffff;
435 else if (dev->flags & IFF_MULTICAST) { 435 else if (dev->flags & IFF_MULTICAST) {
436 struct dev_mc_list *mc_list; 436 struct netdev_hw_addr *ha;
437 437
438 netdev_for_each_mc_addr(mc_list, dev) { 438 netdev_for_each_mc_addr(ha, dev) {
439 u32 crc; 439 u32 crc;
440 unsigned bit = 0; 440 unsigned bit = 0;
441 441
442 crc = ~ether_crc(ETH_ALEN, mc_list->dmi_addr); 442 crc = ~ether_crc(ETH_ALEN, ha->addr);
443 crc >>= 24; 443 crc >>= 24;
444 444
445 if (crc & 0x01) bit |= 0x02; 445 if (crc & 0x01) bit |= 0x02;
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 88f2fb193abe..e07b82b266d9 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -1602,7 +1602,7 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data)
1602static void efx_set_multicast_list(struct net_device *net_dev) 1602static void efx_set_multicast_list(struct net_device *net_dev)
1603{ 1603{
1604 struct efx_nic *efx = netdev_priv(net_dev); 1604 struct efx_nic *efx = netdev_priv(net_dev);
1605 struct dev_mc_list *mc_list; 1605 struct netdev_hw_addr *ha;
1606 union efx_multicast_hash *mc_hash = &efx->multicast_hash; 1606 union efx_multicast_hash *mc_hash = &efx->multicast_hash;
1607 u32 crc; 1607 u32 crc;
1608 int bit; 1608 int bit;
@@ -1614,8 +1614,8 @@ static void efx_set_multicast_list(struct net_device *net_dev)
1614 memset(mc_hash, 0xff, sizeof(*mc_hash)); 1614 memset(mc_hash, 0xff, sizeof(*mc_hash));
1615 } else { 1615 } else {
1616 memset(mc_hash, 0x00, sizeof(*mc_hash)); 1616 memset(mc_hash, 0x00, sizeof(*mc_hash));
1617 netdev_for_each_mc_addr(mc_list, net_dev) { 1617 netdev_for_each_mc_addr(ha, net_dev) {
1618 crc = ether_crc_le(ETH_ALEN, mc_list->dmi_addr); 1618 crc = ether_crc_le(ETH_ALEN, ha->addr);
1619 bit = crc & (EFX_MCAST_HASH_ENTRIES - 1); 1619 bit = crc & (EFX_MCAST_HASH_ENTRIES - 1);
1620 set_bit_le(bit, mc_hash->byte); 1620 set_bit_le(bit, mc_hash->byte);
1621 } 1621 }
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index 760d9e83a465..6a05b93ae6c9 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -848,13 +848,13 @@ static void sis190_set_rx_mode(struct net_device *dev)
848 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; 848 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
849 mc_filter[1] = mc_filter[0] = 0xffffffff; 849 mc_filter[1] = mc_filter[0] = 0xffffffff;
850 } else { 850 } else {
851 struct dev_mc_list *mclist; 851 struct netdev_hw_addr *ha;
852 852
853 rx_mode = AcceptBroadcast | AcceptMyPhys; 853 rx_mode = AcceptBroadcast | AcceptMyPhys;
854 mc_filter[1] = mc_filter[0] = 0; 854 mc_filter[1] = mc_filter[0] = 0;
855 netdev_for_each_mc_addr(mclist, dev) { 855 netdev_for_each_mc_addr(ha, dev) {
856 int bit_nr = 856 int bit_nr =
857 ether_crc(ETH_ALEN, mclist->dmi_addr) & 0x3f; 857 ether_crc(ETH_ALEN, ha->addr) & 0x3f;
858 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); 858 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
859 rx_mode |= AcceptMulticast; 859 rx_mode |= AcceptMulticast;
860 } 860 }
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index cc0c731c4f09..6293592635be 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -1499,7 +1499,7 @@ static void sis900_read_mode(struct net_device *net_dev, int *speed, int *duplex
1499 } 1499 }
1500 1500
1501 if(netif_msg_link(sis_priv)) 1501 if(netif_msg_link(sis_priv))
1502 printk(KERN_INFO "%s: Media Link On %s %s-duplex \n", 1502 printk(KERN_INFO "%s: Media Link On %s %s-duplex\n",
1503 net_dev->name, 1503 net_dev->name,
1504 *speed == HW_SPEED_100_MBPS ? 1504 *speed == HW_SPEED_100_MBPS ?
1505 "100mbps" : "10mbps", 1505 "100mbps" : "10mbps",
@@ -1523,7 +1523,7 @@ static void sis900_tx_timeout(struct net_device *net_dev)
1523 int i; 1523 int i;
1524 1524
1525 if(netif_msg_tx_err(sis_priv)) 1525 if(netif_msg_tx_err(sis_priv))
1526 printk(KERN_INFO "%s: Transmit timeout, status %8.8x %8.8x \n", 1526 printk(KERN_INFO "%s: Transmit timeout, status %8.8x %8.8x\n",
1527 net_dev->name, inl(ioaddr + cr), inl(ioaddr + isr)); 1527 net_dev->name, inl(ioaddr + cr), inl(ioaddr + isr));
1528 1528
1529 /* Disable interrupts by clearing the interrupt mask. */ 1529 /* Disable interrupts by clearing the interrupt mask. */
@@ -2298,12 +2298,14 @@ static void set_rx_mode(struct net_device *net_dev)
2298 /* Accept Broadcast packet, destination address matchs our 2298 /* Accept Broadcast packet, destination address matchs our
2299 * MAC address, use Receive Filter to reject unwanted MCAST 2299 * MAC address, use Receive Filter to reject unwanted MCAST
2300 * packets */ 2300 * packets */
2301 struct dev_mc_list *mclist; 2301 struct netdev_hw_addr *ha;
2302 rx_mode = RFAAB; 2302 rx_mode = RFAAB;
2303 2303
2304 netdev_for_each_mc_addr(mclist, net_dev) { 2304 netdev_for_each_mc_addr(ha, net_dev) {
2305 unsigned int bit_nr = 2305 unsigned int bit_nr;
2306 sis900_mcast_bitnr(mclist->dmi_addr, sis_priv->chipset_rev); 2306
2307 bit_nr = sis900_mcast_bitnr(ha->addr,
2308 sis_priv->chipset_rev);
2307 mc_filter[bit_nr >> 4] |= (1 << (bit_nr & 0xf)); 2309 mc_filter[bit_nr >> 4] |= (1 << (bit_nr & 0xf));
2308 } 2310 }
2309 } 2311 }
diff --git a/drivers/net/skfp/fplustm.c b/drivers/net/skfp/fplustm.c
index 6028bbb3b28a..9d8d1ac48176 100644
--- a/drivers/net/skfp/fplustm.c
+++ b/drivers/net/skfp/fplustm.c
@@ -1352,7 +1352,7 @@ void rtm_set_timer(struct s_smc *smc)
1352 /* 1352 /*
1353 * MIB timer and hardware timer have the same resolution of 80nS 1353 * MIB timer and hardware timer have the same resolution of 80nS
1354 */ 1354 */
1355 DB_RMT("RMT: setting new fddiPATHT_Rmode, t = %d ns \n", 1355 DB_RMT("RMT: setting new fddiPATHT_Rmode, t = %d ns\n",
1356 (int) smc->mib.a[PATH0].fddiPATHT_Rmode,0) ; 1356 (int) smc->mib.a[PATH0].fddiPATHT_Rmode,0) ;
1357 outpd(ADDR(B2_RTM_INI),smc->mib.a[PATH0].fddiPATHT_Rmode) ; 1357 outpd(ADDR(B2_RTM_INI),smc->mib.a[PATH0].fddiPATHT_Rmode) ;
1358} 1358}
diff --git a/drivers/net/skfp/pcmplc.c b/drivers/net/skfp/pcmplc.c
index e6b33ee05ede..ba45bc794d77 100644
--- a/drivers/net/skfp/pcmplc.c
+++ b/drivers/net/skfp/pcmplc.c
@@ -1277,7 +1277,7 @@ static void pc_rcode_actions(struct s_smc *smc, int bit, struct s_phy *phy)
1277 1277
1278 mib = phy->mib ; 1278 mib = phy->mib ;
1279 1279
1280 DB_PCMN(1,"SIG rec %x %x: \n", bit,phy->r_val[bit] ) ; 1280 DB_PCMN(1,"SIG rec %x %x:\n", bit,phy->r_val[bit] ) ;
1281 bit++ ; 1281 bit++ ;
1282 1282
1283 switch(bit) { 1283 switch(bit) {
@@ -1580,7 +1580,7 @@ static void pc_tcode_actions(struct s_smc *smc, const int bit, struct s_phy *phy
1580 mib->fddiPORTMacIndicated.T_val = phy->t_val[9] ; 1580 mib->fddiPORTMacIndicated.T_val = phy->t_val[9] ;
1581 break ; 1581 break ;
1582 } 1582 }
1583 DB_PCMN(1,"SIG snd %x %x: \n", bit,phy->t_val[bit] ) ; 1583 DB_PCMN(1,"SIG snd %x %x:\n", bit,phy->t_val[bit] ) ;
1584} 1584}
1585 1585
1586/* 1586/*
diff --git a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c
index 1921a54ea995..7e5b9f310fb2 100644
--- a/drivers/net/skfp/skfddi.c
+++ b/drivers/net/skfp/skfddi.c
@@ -852,7 +852,7 @@ static void skfp_ctl_set_multicast_list(struct net_device *dev)
852static void skfp_ctl_set_multicast_list_wo_lock(struct net_device *dev) 852static void skfp_ctl_set_multicast_list_wo_lock(struct net_device *dev)
853{ 853{
854 struct s_smc *smc = netdev_priv(dev); 854 struct s_smc *smc = netdev_priv(dev);
855 struct dev_mc_list *dmi; 855 struct netdev_hw_addr *ha;
856 856
857 /* Enable promiscuous mode, if necessary */ 857 /* Enable promiscuous mode, if necessary */
858 if (dev->flags & IFF_PROMISC) { 858 if (dev->flags & IFF_PROMISC) {
@@ -876,13 +876,13 @@ static void skfp_ctl_set_multicast_list_wo_lock(struct net_device *dev)
876 /* use exact filtering */ 876 /* use exact filtering */
877 877
878 // point to first multicast addr 878 // point to first multicast addr
879 netdev_for_each_mc_addr(dmi, dev) { 879 netdev_for_each_mc_addr(ha, dev) {
880 mac_add_multicast(smc, 880 mac_add_multicast(smc,
881 (struct fddi_addr *)dmi->dmi_addr, 881 (struct fddi_addr *)ha->addr,
882 1); 882 1);
883 883
884 pr_debug(KERN_INFO "ENABLE MC ADDRESS: %pMF\n", 884 pr_debug(KERN_INFO "ENABLE MC ADDRESS: %pMF\n",
885 dmi->dmi_addr); 885 ha->addr);
886 } 886 }
887 887
888 } else { // more MC addresses than HW supports 888 } else { // more MC addresses than HW supports
diff --git a/drivers/net/skfp/srf.c b/drivers/net/skfp/srf.c
index 6caf713b744c..40882b3faba6 100644
--- a/drivers/net/skfp/srf.c
+++ b/drivers/net/skfp/srf.c
@@ -414,7 +414,7 @@ static void smt_send_srf(struct s_smc *smc)
414 smt->smt_len = SMT_MAX_INFO_LEN - pcon.pc_len ; 414 smt->smt_len = SMT_MAX_INFO_LEN - pcon.pc_len ;
415 mb->sm_len = smt->smt_len + sizeof(struct smt_header) ; 415 mb->sm_len = smt->smt_len + sizeof(struct smt_header) ;
416 416
417 DB_SMT("SRF: sending SRF at %x, len %d \n",smt,mb->sm_len) ; 417 DB_SMT("SRF: sending SRF at %x, len %d\n",smt,mb->sm_len) ;
418 DB_SMT("SRF: state SR%d Threshold %d\n", 418 DB_SMT("SRF: state SR%d Threshold %d\n",
419 smc->srf.sr_state,smc->srf.SRThreshold/TICKS_PER_SECOND) ; 419 smc->srf.sr_state,smc->srf.SRThreshold/TICKS_PER_SECOND) ;
420#ifdef DEBUG 420#ifdef DEBUG
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index d0058e5bb6ae..de5ef3877baf 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -2917,7 +2917,7 @@ static void genesis_set_multicast(struct net_device *dev)
2917 struct skge_port *skge = netdev_priv(dev); 2917 struct skge_port *skge = netdev_priv(dev);
2918 struct skge_hw *hw = skge->hw; 2918 struct skge_hw *hw = skge->hw;
2919 int port = skge->port; 2919 int port = skge->port;
2920 struct dev_mc_list *list; 2920 struct netdev_hw_addr *ha;
2921 u32 mode; 2921 u32 mode;
2922 u8 filter[8]; 2922 u8 filter[8];
2923 2923
@@ -2937,8 +2937,8 @@ static void genesis_set_multicast(struct net_device *dev)
2937 skge->flow_status == FLOW_STAT_SYMMETRIC) 2937 skge->flow_status == FLOW_STAT_SYMMETRIC)
2938 genesis_add_filter(filter, pause_mc_addr); 2938 genesis_add_filter(filter, pause_mc_addr);
2939 2939
2940 netdev_for_each_mc_addr(list, dev) 2940 netdev_for_each_mc_addr(ha, dev)
2941 genesis_add_filter(filter, list->dmi_addr); 2941 genesis_add_filter(filter, ha->addr);
2942 } 2942 }
2943 2943
2944 xm_write32(hw, port, XM_MODE, mode); 2944 xm_write32(hw, port, XM_MODE, mode);
@@ -2956,7 +2956,7 @@ static void yukon_set_multicast(struct net_device *dev)
2956 struct skge_port *skge = netdev_priv(dev); 2956 struct skge_port *skge = netdev_priv(dev);
2957 struct skge_hw *hw = skge->hw; 2957 struct skge_hw *hw = skge->hw;
2958 int port = skge->port; 2958 int port = skge->port;
2959 struct dev_mc_list *list; 2959 struct netdev_hw_addr *ha;
2960 int rx_pause = (skge->flow_status == FLOW_STAT_REM_SEND || 2960 int rx_pause = (skge->flow_status == FLOW_STAT_REM_SEND ||
2961 skge->flow_status == FLOW_STAT_SYMMETRIC); 2961 skge->flow_status == FLOW_STAT_SYMMETRIC);
2962 u16 reg; 2962 u16 reg;
@@ -2979,8 +2979,8 @@ static void yukon_set_multicast(struct net_device *dev)
2979 if (rx_pause) 2979 if (rx_pause)
2980 yukon_add_filter(filter, pause_mc_addr); 2980 yukon_add_filter(filter, pause_mc_addr);
2981 2981
2982 netdev_for_each_mc_addr(list, dev) 2982 netdev_for_each_mc_addr(ha, dev)
2983 yukon_add_filter(filter, list->dmi_addr); 2983 yukon_add_filter(filter, ha->addr);
2984 } 2984 }
2985 2985
2986 2986
@@ -3666,7 +3666,7 @@ static int skge_debug_show(struct seq_file *seq, void *v)
3666 t->csum_offs, t->csum_write, t->csum_start); 3666 t->csum_offs, t->csum_write, t->csum_start);
3667 } 3667 }
3668 3668
3669 seq_printf(seq, "\nRx Ring: \n"); 3669 seq_printf(seq, "\nRx Ring:\n");
3670 for (e = skge->rx_ring.to_clean; ; e = e->next) { 3670 for (e = skge->rx_ring.to_clean; ; e = e->next) {
3671 const struct skge_rx_desc *r = e->desc; 3671 const struct skge_rx_desc *r = e->desc;
3672 3672
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index d8ec4c11fd49..5b97edb7a35f 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -226,7 +226,7 @@ static void sky2_power_on(struct sky2_hw *hw)
226 /* disable Core Clock Division, */ 226 /* disable Core Clock Division, */
227 sky2_write32(hw, B2_Y2_CLK_CTRL, Y2_CLK_DIV_DIS); 227 sky2_write32(hw, B2_Y2_CLK_CTRL, Y2_CLK_DIV_DIS);
228 228
229 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) 229 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > CHIP_REV_YU_XL_A1)
230 /* enable bits are inverted */ 230 /* enable bits are inverted */
231 sky2_write8(hw, B2_Y2_CLK_GATE, 231 sky2_write8(hw, B2_Y2_CLK_GATE,
232 Y2_PCI_CLK_LNK1_DIS | Y2_COR_CLK_LNK1_DIS | 232 Y2_PCI_CLK_LNK1_DIS | Y2_COR_CLK_LNK1_DIS |
@@ -268,7 +268,7 @@ static void sky2_power_on(struct sky2_hw *hw)
268 268
269static void sky2_power_aux(struct sky2_hw *hw) 269static void sky2_power_aux(struct sky2_hw *hw)
270{ 270{
271 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) 271 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > CHIP_REV_YU_XL_A1)
272 sky2_write8(hw, B2_Y2_CLK_GATE, 0); 272 sky2_write8(hw, B2_Y2_CLK_GATE, 0);
273 else 273 else
274 /* enable bits are inverted */ 274 /* enable bits are inverted */
@@ -651,7 +651,7 @@ static void sky2_phy_power_up(struct sky2_hw *hw, unsigned port)
651 reg1 = sky2_pci_read32(hw, PCI_DEV_REG1); 651 reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
652 reg1 &= ~phy_power[port]; 652 reg1 &= ~phy_power[port];
653 653
654 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) 654 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > CHIP_REV_YU_XL_A1)
655 reg1 |= coma_mode[port]; 655 reg1 |= coma_mode[port];
656 656
657 sky2_pci_write32(hw, PCI_DEV_REG1, reg1); 657 sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
@@ -823,7 +823,9 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
823 823
824 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR); 824 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR);
825 825
826 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0 && port == 1) { 826 if (hw->chip_id == CHIP_ID_YUKON_XL &&
827 hw->chip_rev == CHIP_REV_YU_XL_A0 &&
828 port == 1) {
827 /* WA DEV_472 -- looks like crossed wires on port 2 */ 829 /* WA DEV_472 -- looks like crossed wires on port 2 */
828 /* clear GMAC 1 Control reset */ 830 /* clear GMAC 1 Control reset */
829 sky2_write8(hw, SK_REG(0, GMAC_CTRL), GMC_RST_CLR); 831 sky2_write8(hw, SK_REG(0, GMAC_CTRL), GMC_RST_CLR);
@@ -877,6 +879,10 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
877 if (hw->dev[port]->mtu > ETH_DATA_LEN) 879 if (hw->dev[port]->mtu > ETH_DATA_LEN)
878 reg |= GM_SMOD_JUMBO_ENA; 880 reg |= GM_SMOD_JUMBO_ENA;
879 881
882 if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
883 hw->chip_rev == CHIP_REV_YU_EC_U_B1)
884 reg |= GM_NEW_FLOW_CTRL;
885
880 gma_write16(hw, port, GM_SERIAL_MODE, reg); 886 gma_write16(hw, port, GM_SERIAL_MODE, reg);
881 887
882 /* virtual address for data */ 888 /* virtual address for data */
@@ -1413,8 +1419,7 @@ static void sky2_rx_start(struct sky2_port *sky2)
1413 /* These chips have no ram buffer? 1419 /* These chips have no ram buffer?
1414 * MAC Rx RAM Read is controlled by hardware */ 1420 * MAC Rx RAM Read is controlled by hardware */
1415 if (hw->chip_id == CHIP_ID_YUKON_EC_U && 1421 if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
1416 (hw->chip_rev == CHIP_REV_YU_EC_U_A1 || 1422 hw->chip_rev > CHIP_REV_YU_EC_U_A0)
1417 hw->chip_rev == CHIP_REV_YU_EC_U_B0))
1418 sky2_write32(hw, Q_ADDR(rxq, Q_TEST), F_M_RX_RAM_DIS); 1423 sky2_write32(hw, Q_ADDR(rxq, Q_TEST), F_M_RX_RAM_DIS);
1419 1424
1420 sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1); 1425 sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1);
@@ -2141,7 +2146,8 @@ static void sky2_phy_intr(struct sky2_hw *hw, unsigned port)
2141 istatus, phystat); 2146 istatus, phystat);
2142 2147
2143 if (istatus & PHY_M_IS_AN_COMPL) { 2148 if (istatus & PHY_M_IS_AN_COMPL) {
2144 if (sky2_autoneg_done(sky2, phystat) == 0) 2149 if (sky2_autoneg_done(sky2, phystat) == 0 &&
2150 !netif_carrier_ok(dev))
2145 sky2_link_up(sky2); 2151 sky2_link_up(sky2);
2146 goto out; 2152 goto out;
2147 } 2153 }
@@ -3621,7 +3627,7 @@ static void sky2_set_multicast(struct net_device *dev)
3621 struct sky2_port *sky2 = netdev_priv(dev); 3627 struct sky2_port *sky2 = netdev_priv(dev);
3622 struct sky2_hw *hw = sky2->hw; 3628 struct sky2_hw *hw = sky2->hw;
3623 unsigned port = sky2->port; 3629 unsigned port = sky2->port;
3624 struct dev_mc_list *list; 3630 struct netdev_hw_addr *ha;
3625 u16 reg; 3631 u16 reg;
3626 u8 filter[8]; 3632 u8 filter[8];
3627 int rx_pause; 3633 int rx_pause;
@@ -3645,8 +3651,8 @@ static void sky2_set_multicast(struct net_device *dev)
3645 if (rx_pause) 3651 if (rx_pause)
3646 sky2_add_filter(filter, pause_mc_addr); 3652 sky2_add_filter(filter, pause_mc_addr);
3647 3653
3648 netdev_for_each_mc_addr(list, dev) 3654 netdev_for_each_mc_addr(ha, dev)
3649 sky2_add_filter(filter, list->dmi_addr); 3655 sky2_add_filter(filter, ha->addr);
3650 } 3656 }
3651 3657
3652 gma_write16(hw, port, GM_MC_ADDR_H1, 3658 gma_write16(hw, port, GM_MC_ADDR_H1,
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index a5e182dd9819..0bebfb3638f6 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -548,6 +548,14 @@ enum {
548 CHIP_ID_YUKON_UL_2 = 0xba, /* YUKON-2 Ultra 2 */ 548 CHIP_ID_YUKON_UL_2 = 0xba, /* YUKON-2 Ultra 2 */
549 CHIP_ID_YUKON_OPT = 0xbc, /* YUKON-2 Optima */ 549 CHIP_ID_YUKON_OPT = 0xbc, /* YUKON-2 Optima */
550}; 550};
551
552enum yukon_xl_rev {
553 CHIP_REV_YU_XL_A0 = 0,
554 CHIP_REV_YU_XL_A1 = 1,
555 CHIP_REV_YU_XL_A2 = 2,
556 CHIP_REV_YU_XL_A3 = 3,
557};
558
551enum yukon_ec_rev { 559enum yukon_ec_rev {
552 CHIP_REV_YU_EC_A1 = 0, /* Chip Rev. for Yukon-EC A1/A0 */ 560 CHIP_REV_YU_EC_A1 = 0, /* Chip Rev. for Yukon-EC A1/A0 */
553 CHIP_REV_YU_EC_A2 = 1, /* Chip Rev. for Yukon-EC A2 */ 561 CHIP_REV_YU_EC_A2 = 1, /* Chip Rev. for Yukon-EC A2 */
@@ -557,6 +565,7 @@ enum yukon_ec_u_rev {
557 CHIP_REV_YU_EC_U_A0 = 1, 565 CHIP_REV_YU_EC_U_A0 = 1,
558 CHIP_REV_YU_EC_U_A1 = 2, 566 CHIP_REV_YU_EC_U_A1 = 2,
559 CHIP_REV_YU_EC_U_B0 = 3, 567 CHIP_REV_YU_EC_U_B0 = 3,
568 CHIP_REV_YU_EC_U_B1 = 5,
560}; 569};
561enum yukon_fe_rev { 570enum yukon_fe_rev {
562 CHIP_REV_YU_FE_A1 = 1, 571 CHIP_REV_YU_FE_A1 = 1,
@@ -1775,10 +1784,13 @@ enum {
1775/* GM_SERIAL_MODE 16 bit r/w Serial Mode Register */ 1784/* GM_SERIAL_MODE 16 bit r/w Serial Mode Register */
1776enum { 1785enum {
1777 GM_SMOD_DATABL_MSK = 0x1f<<11, /* Bit 15..11: Data Blinder (r/o) */ 1786 GM_SMOD_DATABL_MSK = 0x1f<<11, /* Bit 15..11: Data Blinder (r/o) */
1778 GM_SMOD_LIMIT_4 = 1<<10, /* Bit 10: 4 consecutive Tx trials */ 1787 GM_SMOD_LIMIT_4 = 1<<10, /* 4 consecutive Tx trials */
1779 GM_SMOD_VLAN_ENA = 1<<9, /* Bit 9: Enable VLAN (Max. Frame Len) */ 1788 GM_SMOD_VLAN_ENA = 1<<9, /* Enable VLAN (Max. Frame Len) */
1780 GM_SMOD_JUMBO_ENA = 1<<8, /* Bit 8: Enable Jumbo (Max. Frame Len) */ 1789 GM_SMOD_JUMBO_ENA = 1<<8, /* Enable Jumbo (Max. Frame Len) */
1781 GM_SMOD_IPG_MSK = 0x1f /* Bit 4..0: Inter-Packet Gap (IPG) */ 1790
1791 GM_NEW_FLOW_CTRL = 1<<6, /* Enable New Flow-Control */
1792
1793 GM_SMOD_IPG_MSK = 0x1f /* Bit 4..0: Inter-Packet Gap (IPG) */
1782}; 1794};
1783 1795
1784#define DATA_BLIND_VAL(x) (((x)<<11) & GM_SMOD_DATABL_MSK) 1796#define DATA_BLIND_VAL(x) (((x)<<11) & GM_SMOD_DATABL_MSK)
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 9871a2b61f86..6278734c735f 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -383,7 +383,7 @@ static inline void smc911x_rcv(struct net_device *dev)
383 DBG(SMC_DEBUG_FUNC | SMC_DEBUG_RX, "%s: --> %s\n", 383 DBG(SMC_DEBUG_FUNC | SMC_DEBUG_RX, "%s: --> %s\n",
384 dev->name, __func__); 384 dev->name, __func__);
385 status = SMC_GET_RX_STS_FIFO(lp); 385 status = SMC_GET_RX_STS_FIFO(lp);
386 DBG(SMC_DEBUG_RX, "%s: Rx pkt len %d status 0x%08x \n", 386 DBG(SMC_DEBUG_RX, "%s: Rx pkt len %d status 0x%08x\n",
387 dev->name, (status & 0x3fff0000) >> 16, status & 0xc000ffff); 387 dev->name, (status & 0x3fff0000) >> 16, status & 0xc000ffff);
388 pkt_len = (status & RX_STS_PKT_LEN_) >> 16; 388 pkt_len = (status & RX_STS_PKT_LEN_) >> 16;
389 if (status & RX_STS_ES_) { 389 if (status & RX_STS_ES_) {
@@ -1136,7 +1136,7 @@ static irqreturn_t smc911x_interrupt(int irq, void *dev_id)
1136 } 1136 }
1137#else 1137#else
1138 if (status & INT_STS_TSFL_) { 1138 if (status & INT_STS_TSFL_) {
1139 DBG(SMC_DEBUG_TX, "%s: TX status FIFO limit (%d) irq \n", dev->name, ); 1139 DBG(SMC_DEBUG_TX, "%s: TX status FIFO limit (%d) irq\n", dev->name, );
1140 smc911x_tx(dev); 1140 smc911x_tx(dev);
1141 SMC_ACK_INT(lp, INT_STS_TSFL_); 1141 SMC_ACK_INT(lp, INT_STS_TSFL_);
1142 } 1142 }
@@ -1275,7 +1275,7 @@ static void smc911x_timeout(struct net_device *dev)
1275 status = SMC_GET_INT(lp); 1275 status = SMC_GET_INT(lp);
1276 mask = SMC_GET_INT_EN(lp); 1276 mask = SMC_GET_INT_EN(lp);
1277 spin_unlock_irqrestore(&lp->lock, flags); 1277 spin_unlock_irqrestore(&lp->lock, flags);
1278 DBG(SMC_DEBUG_MISC, "%s: INT 0x%02x MASK 0x%02x \n", 1278 DBG(SMC_DEBUG_MISC, "%s: INT 0x%02x MASK 0x%02x\n",
1279 dev->name, status, mask); 1279 dev->name, status, mask);
1280 1280
1281 /* Dump the current TX FIFO contents and restart */ 1281 /* Dump the current TX FIFO contents and restart */
@@ -1341,7 +1341,7 @@ static void smc911x_set_multicast_list(struct net_device *dev)
1341 * within that register. 1341 * within that register.
1342 */ 1342 */
1343 else if (!netdev_mc_empty(dev)) { 1343 else if (!netdev_mc_empty(dev)) {
1344 struct dev_mc_list *cur_addr; 1344 struct netdev_hw_addr *ha;
1345 1345
1346 /* Set the Hash perfec mode */ 1346 /* Set the Hash perfec mode */
1347 mcr |= MAC_CR_HPFILT_; 1347 mcr |= MAC_CR_HPFILT_;
@@ -1349,19 +1349,16 @@ static void smc911x_set_multicast_list(struct net_device *dev)
1349 /* start with a table of all zeros: reject all */ 1349 /* start with a table of all zeros: reject all */
1350 memset(multicast_table, 0, sizeof(multicast_table)); 1350 memset(multicast_table, 0, sizeof(multicast_table));
1351 1351
1352 netdev_for_each_mc_addr(cur_addr, dev) { 1352 netdev_for_each_mc_addr(ha, dev) {
1353 u32 position; 1353 u32 position;
1354 1354
1355 /* do we have a pointer here? */
1356 if (!cur_addr)
1357 break;
1358 /* make sure this is a multicast address - 1355 /* make sure this is a multicast address -
1359 shouldn't this be a given if we have it here ? */ 1356 shouldn't this be a given if we have it here ? */
1360 if (!(*cur_addr->dmi_addr & 1)) 1357 if (!(*ha->addr & 1))
1361 continue; 1358 continue;
1362 1359
1363 /* upper 6 bits are used as hash index */ 1360 /* upper 6 bits are used as hash index */
1364 position = ether_crc(ETH_ALEN, cur_addr->dmi_addr)>>26; 1361 position = ether_crc(ETH_ALEN, ha->addr)>>26;
1365 1362
1366 multicast_table[position>>5] |= 1 << (position&0x1f); 1363 multicast_table[position>>5] |= 1 << (position&0x1f);
1367 } 1364 }
diff --git a/drivers/net/smc9194.c b/drivers/net/smc9194.c
index f9a960e7fc1f..9e5e9e792e86 100644
--- a/drivers/net/smc9194.c
+++ b/drivers/net/smc9194.c
@@ -417,7 +417,7 @@ static void smc_shutdown( int ioaddr )
417 417
418 418
419/* 419/*
420 . Function: smc_setmulticast( int ioaddr, int count, dev_mc_list * adds ) 420 . Function: smc_setmulticast( int ioaddr, struct net_device *dev )
421 . Purpose: 421 . Purpose:
422 . This sets the internal hardware table to filter out unwanted multicast 422 . This sets the internal hardware table to filter out unwanted multicast
423 . packets before they take up memory. 423 . packets before they take up memory.
@@ -438,26 +438,23 @@ static void smc_setmulticast(int ioaddr, struct net_device *dev)
438{ 438{
439 int i; 439 int i;
440 unsigned char multicast_table[ 8 ]; 440 unsigned char multicast_table[ 8 ];
441 struct dev_mc_list *cur_addr; 441 struct netdev_hw_addr *ha;
442 /* table for flipping the order of 3 bits */ 442 /* table for flipping the order of 3 bits */
443 unsigned char invert3[] = { 0, 4, 2, 6, 1, 5, 3, 7 }; 443 unsigned char invert3[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
444 444
445 /* start with a table of all zeros: reject all */ 445 /* start with a table of all zeros: reject all */
446 memset( multicast_table, 0, sizeof( multicast_table ) ); 446 memset( multicast_table, 0, sizeof( multicast_table ) );
447 447
448 netdev_for_each_mc_addr(cur_addr, dev) { 448 netdev_for_each_mc_addr(ha, dev) {
449 int position; 449 int position;
450 450
451 /* do we have a pointer here? */
452 if ( !cur_addr )
453 break;
454 /* make sure this is a multicast address - shouldn't this 451 /* make sure this is a multicast address - shouldn't this
455 be a given if we have it here ? */ 452 be a given if we have it here ? */
456 if ( !( *cur_addr->dmi_addr & 1 ) ) 453 if (!(*ha->addr & 1))
457 continue; 454 continue;
458 455
459 /* only use the low order bits */ 456 /* only use the low order bits */
460 position = ether_crc_le(6, cur_addr->dmi_addr) & 0x3f; 457 position = ether_crc_le(6, ha->addr) & 0x3f;
461 458
462 /* do some messy swapping to put the bit in the right spot */ 459 /* do some messy swapping to put the bit in the right spot */
463 multicast_table[invert3[position&7]] |= 460 multicast_table[invert3[position&7]] |=
@@ -529,7 +526,7 @@ static netdev_tx_t smc_wait_to_send_packet(struct sk_buff *skb,
529 numPages = ((length & 0xfffe) + 6) / 256; 526 numPages = ((length & 0xfffe) + 6) / 256;
530 527
531 if (numPages > 7 ) { 528 if (numPages > 7 ) {
532 printk(CARDNAME": Far too big packet error. \n"); 529 printk(CARDNAME": Far too big packet error.\n");
533 /* freeing the packet is a good thing here... but should 530 /* freeing the packet is a good thing here... but should
534 . any packets of this size get down here? */ 531 . any packets of this size get down here? */
535 dev_kfree_skb (skb); 532 dev_kfree_skb (skb);
@@ -571,9 +568,9 @@ static netdev_tx_t smc_wait_to_send_packet(struct sk_buff *skb,
571 if ( !time_out ) { 568 if ( !time_out ) {
572 /* oh well, wait until the chip finds memory later */ 569 /* oh well, wait until the chip finds memory later */
573 SMC_ENABLE_INT( IM_ALLOC_INT ); 570 SMC_ENABLE_INT( IM_ALLOC_INT );
574 PRINTK2((CARDNAME": memory allocation deferred. \n")); 571 PRINTK2((CARDNAME": memory allocation deferred.\n"));
575 /* it's deferred, but I'll handle it later */ 572 /* it's deferred, but I'll handle it later */
576 return NETDEV_TX_OK; 573 return NETDEV_TX_OK;
577 } 574 }
578 /* or YES! I can send the packet now.. */ 575 /* or YES! I can send the packet now.. */
579 smc_hardware_send_packet(dev); 576 smc_hardware_send_packet(dev);
@@ -611,7 +608,7 @@ static void smc_hardware_send_packet( struct net_device * dev )
611 ioaddr = dev->base_addr; 608 ioaddr = dev->base_addr;
612 609
613 if ( !skb ) { 610 if ( !skb ) {
614 PRINTK((CARDNAME": In XMIT with no packet to send \n")); 611 PRINTK((CARDNAME": In XMIT with no packet to send\n"));
615 return; 612 return;
616 } 613 }
617 length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN; 614 length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
@@ -621,7 +618,7 @@ static void smc_hardware_send_packet( struct net_device * dev )
621 packet_no = inb( ioaddr + PNR_ARR + 1 ); 618 packet_no = inb( ioaddr + PNR_ARR + 1 );
622 if ( packet_no & 0x80 ) { 619 if ( packet_no & 0x80 ) {
623 /* or isn't there? BAD CHIP! */ 620 /* or isn't there? BAD CHIP! */
624 printk(KERN_DEBUG CARDNAME": Memory allocation failed. \n"); 621 printk(KERN_DEBUG CARDNAME": Memory allocation failed.\n");
625 dev_kfree_skb_any(skb); 622 dev_kfree_skb_any(skb);
626 lp->saved_skb = NULL; 623 lp->saved_skb = NULL;
627 netif_wake_queue(dev); 624 netif_wake_queue(dev);
@@ -686,7 +683,7 @@ static void smc_hardware_send_packet( struct net_device * dev )
686 /* and let the chipset deal with it */ 683 /* and let the chipset deal with it */
687 outw( MC_ENQUEUE , ioaddr + MMU_CMD ); 684 outw( MC_ENQUEUE , ioaddr + MMU_CMD );
688 685
689 PRINTK2((CARDNAME": Sent packet of length %d \n",length)); 686 PRINTK2((CARDNAME": Sent packet of length %d\n", length));
690 687
691 lp->saved_skb = NULL; 688 lp->saved_skb = NULL;
692 dev_kfree_skb_any (skb); 689 dev_kfree_skb_any (skb);
@@ -938,7 +935,7 @@ static int __init smc_probe(struct net_device *dev, int ioaddr)
938 if ( !chip_ids[ ( revision_register >> 4 ) & 0xF ] ) { 935 if ( !chip_ids[ ( revision_register >> 4 ) & 0xF ] ) {
939 /* I don't recognize this chip, so... */ 936 /* I don't recognize this chip, so... */
940 printk(CARDNAME ": IO %x: Unrecognized revision register:" 937 printk(CARDNAME ": IO %x: Unrecognized revision register:"
941 " %x, Contact author. \n", ioaddr, revision_register ); 938 " %x, Contact author.\n", ioaddr, revision_register);
942 939
943 retval = -ENODEV; 940 retval = -ENODEV;
944 goto err_out; 941 goto err_out;
@@ -1075,7 +1072,7 @@ static void print_packet( byte * buf, int length )
1075 int remainder; 1072 int remainder;
1076 int lines; 1073 int lines;
1077 1074
1078 printk("Packet of length %d \n", length ); 1075 printk("Packet of length %d\n", length);
1079 lines = length / 16; 1076 lines = length / 16;
1080 remainder = length % 16; 1077 remainder = length % 16;
1081 1078
@@ -1202,7 +1199,7 @@ static void smc_rcv(struct net_device *dev)
1202 1199
1203 if ( packet_number & FP_RXEMPTY ) { 1200 if ( packet_number & FP_RXEMPTY ) {
1204 /* we got called , but nothing was on the FIFO */ 1201 /* we got called , but nothing was on the FIFO */
1205 PRINTK((CARDNAME ": WARNING: smc_rcv with nothing on FIFO. \n")); 1202 PRINTK((CARDNAME ": WARNING: smc_rcv with nothing on FIFO.\n"));
1206 /* don't need to restore anything */ 1203 /* don't need to restore anything */
1207 return; 1204 return;
1208 } 1205 }
@@ -1258,14 +1255,14 @@ static void smc_rcv(struct net_device *dev)
1258 to send the DWORDs or the bytes first, or some 1255 to send the DWORDs or the bytes first, or some
1259 mixture. A mixture might improve already slow PIO 1256 mixture. A mixture might improve already slow PIO
1260 performance */ 1257 performance */
1261 PRINTK3((" Reading %d dwords (and %d bytes) \n", 1258 PRINTK3((" Reading %d dwords (and %d bytes)\n",
1262 packet_length >> 2, packet_length & 3 )); 1259 packet_length >> 2, packet_length & 3 ));
1263 insl(ioaddr + DATA_1 , data, packet_length >> 2 ); 1260 insl(ioaddr + DATA_1 , data, packet_length >> 2 );
1264 /* read the left over bytes */ 1261 /* read the left over bytes */
1265 insb( ioaddr + DATA_1, data + (packet_length & 0xFFFFFC), 1262 insb( ioaddr + DATA_1, data + (packet_length & 0xFFFFFC),
1266 packet_length & 0x3 ); 1263 packet_length & 0x3 );
1267#else 1264#else
1268 PRINTK3((" Reading %d words and %d byte(s) \n", 1265 PRINTK3((" Reading %d words and %d byte(s)\n",
1269 (packet_length >> 1 ), packet_length & 1 )); 1266 (packet_length >> 1 ), packet_length & 1 ));
1270 insw(ioaddr + DATA_1 , data, packet_length >> 1); 1267 insw(ioaddr + DATA_1 , data, packet_length >> 1);
1271 if ( packet_length & 1 ) { 1268 if ( packet_length & 1 ) {
@@ -1334,7 +1331,7 @@ static void smc_tx( struct net_device * dev )
1334 outw( PTR_AUTOINC | PTR_READ, ioaddr + POINTER ); 1331 outw( PTR_AUTOINC | PTR_READ, ioaddr + POINTER );
1335 1332
1336 tx_status = inw( ioaddr + DATA_1 ); 1333 tx_status = inw( ioaddr + DATA_1 );
1337 PRINTK3((CARDNAME": TX DONE STATUS: %4x \n", tx_status )); 1334 PRINTK3((CARDNAME": TX DONE STATUS: %4x\n", tx_status));
1338 1335
1339 dev->stats.tx_errors++; 1336 dev->stats.tx_errors++;
1340 if ( tx_status & TS_LOSTCAR ) dev->stats.tx_carrier_errors++; 1337 if ( tx_status & TS_LOSTCAR ) dev->stats.tx_carrier_errors++;
@@ -1348,7 +1345,7 @@ static void smc_tx( struct net_device * dev )
1348#endif 1345#endif
1349 1346
1350 if ( tx_status & TS_SUCCESS ) { 1347 if ( tx_status & TS_SUCCESS ) {
1351 printk(CARDNAME": Successful packet caused interrupt \n"); 1348 printk(CARDNAME": Successful packet caused interrupt\n");
1352 } 1349 }
1353 /* re-enable transmit */ 1350 /* re-enable transmit */
1354 SMC_SELECT_BANK( 0 ); 1351 SMC_SELECT_BANK( 0 );
@@ -1394,7 +1391,7 @@ static irqreturn_t smc_interrupt(int irq, void * dev_id)
1394 int handled = 0; 1391 int handled = 0;
1395 1392
1396 1393
1397 PRINTK3((CARDNAME": SMC interrupt started \n")); 1394 PRINTK3((CARDNAME": SMC interrupt started\n"));
1398 1395
1399 saved_bank = inw( ioaddr + BANK_SELECT ); 1396 saved_bank = inw( ioaddr + BANK_SELECT );
1400 1397
@@ -1409,7 +1406,7 @@ static irqreturn_t smc_interrupt(int irq, void * dev_id)
1409 /* set a timeout value, so I don't stay here forever */ 1406 /* set a timeout value, so I don't stay here forever */
1410 timeout = 4; 1407 timeout = 4;
1411 1408
1412 PRINTK2((KERN_WARNING CARDNAME ": MASK IS %x \n", mask )); 1409 PRINTK2((KERN_WARNING CARDNAME ": MASK IS %x\n", mask));
1413 do { 1410 do {
1414 /* read the status flag, and mask it */ 1411 /* read the status flag, and mask it */
1415 status = inb( ioaddr + INTERRUPT ) & mask; 1412 status = inb( ioaddr + INTERRUPT ) & mask;
@@ -1419,7 +1416,7 @@ static irqreturn_t smc_interrupt(int irq, void * dev_id)
1419 handled = 1; 1416 handled = 1;
1420 1417
1421 PRINTK3((KERN_WARNING CARDNAME 1418 PRINTK3((KERN_WARNING CARDNAME
1422 ": Handling interrupt status %x \n", status )); 1419 ": Handling interrupt status %x\n", status));
1423 1420
1424 if (status & IM_RCV_INT) { 1421 if (status & IM_RCV_INT) {
1425 /* Got a packet(s). */ 1422 /* Got a packet(s). */
@@ -1453,7 +1450,7 @@ static irqreturn_t smc_interrupt(int irq, void * dev_id)
1453 1450
1454 } else if (status & IM_ALLOC_INT ) { 1451 } else if (status & IM_ALLOC_INT ) {
1455 PRINTK2((KERN_DEBUG CARDNAME 1452 PRINTK2((KERN_DEBUG CARDNAME
1456 ": Allocation interrupt \n")); 1453 ": Allocation interrupt\n"));
1457 /* clear this interrupt so it doesn't happen again */ 1454 /* clear this interrupt so it doesn't happen again */
1458 mask &= ~IM_ALLOC_INT; 1455 mask &= ~IM_ALLOC_INT;
1459 1456
@@ -1471,9 +1468,9 @@ static irqreturn_t smc_interrupt(int irq, void * dev_id)
1471 dev->stats.rx_fifo_errors++; 1468 dev->stats.rx_fifo_errors++;
1472 outb( IM_RX_OVRN_INT, ioaddr + INTERRUPT ); 1469 outb( IM_RX_OVRN_INT, ioaddr + INTERRUPT );
1473 } else if (status & IM_EPH_INT ) { 1470 } else if (status & IM_EPH_INT ) {
1474 PRINTK((CARDNAME ": UNSUPPORTED: EPH INTERRUPT \n")); 1471 PRINTK((CARDNAME ": UNSUPPORTED: EPH INTERRUPT\n"));
1475 } else if (status & IM_ERCV_INT ) { 1472 } else if (status & IM_ERCV_INT ) {
1476 PRINTK((CARDNAME ": UNSUPPORTED: ERCV INTERRUPT \n")); 1473 PRINTK((CARDNAME ": UNSUPPORTED: ERCV INTERRUPT\n"));
1477 outb( IM_ERCV_INT, ioaddr + INTERRUPT ); 1474 outb( IM_ERCV_INT, ioaddr + INTERRUPT );
1478 } 1475 }
1479 } while ( timeout -- ); 1476 } while ( timeout -- );
@@ -1483,7 +1480,7 @@ static irqreturn_t smc_interrupt(int irq, void * dev_id)
1483 SMC_SELECT_BANK( 2 ); 1480 SMC_SELECT_BANK( 2 );
1484 outb( mask, ioaddr + INT_MASK ); 1481 outb( mask, ioaddr + INT_MASK );
1485 1482
1486 PRINTK3(( KERN_WARNING CARDNAME ": MASK is now %x \n", mask )); 1483 PRINTK3((KERN_WARNING CARDNAME ": MASK is now %x\n", mask));
1487 outw( saved_pointer, ioaddr + POINTER ); 1484 outw( saved_pointer, ioaddr + POINTER );
1488 1485
1489 SMC_SELECT_BANK( saved_bank ); 1486 SMC_SELECT_BANK( saved_bank );
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index fc1b5a1a3583..20c756577631 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -1286,7 +1286,7 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id)
1286 smc_phy_interrupt(dev); 1286 smc_phy_interrupt(dev);
1287 } else if (status & IM_ERCV_INT) { 1287 } else if (status & IM_ERCV_INT) {
1288 SMC_ACK_INT(lp, IM_ERCV_INT); 1288 SMC_ACK_INT(lp, IM_ERCV_INT);
1289 PRINTK("%s: UNSUPPORTED: ERCV INTERRUPT \n", dev->name); 1289 PRINTK("%s: UNSUPPORTED: ERCV INTERRUPT\n", dev->name);
1290 } 1290 }
1291 } while (--timeout); 1291 } while (--timeout);
1292 1292
@@ -1413,7 +1413,7 @@ static void smc_set_multicast_list(struct net_device *dev)
1413 * within that register. 1413 * within that register.
1414 */ 1414 */
1415 else if (!netdev_mc_empty(dev)) { 1415 else if (!netdev_mc_empty(dev)) {
1416 struct dev_mc_list *cur_addr; 1416 struct netdev_hw_addr *ha;
1417 1417
1418 /* table for flipping the order of 3 bits */ 1418 /* table for flipping the order of 3 bits */
1419 static const unsigned char invert3[] = {0, 4, 2, 6, 1, 5, 3, 7}; 1419 static const unsigned char invert3[] = {0, 4, 2, 6, 1, 5, 3, 7};
@@ -1421,16 +1421,16 @@ static void smc_set_multicast_list(struct net_device *dev)
1421 /* start with a table of all zeros: reject all */ 1421 /* start with a table of all zeros: reject all */
1422 memset(multicast_table, 0, sizeof(multicast_table)); 1422 memset(multicast_table, 0, sizeof(multicast_table));
1423 1423
1424 netdev_for_each_mc_addr(cur_addr, dev) { 1424 netdev_for_each_mc_addr(ha, dev) {
1425 int position; 1425 int position;
1426 1426
1427 /* make sure this is a multicast address - 1427 /* make sure this is a multicast address -
1428 shouldn't this be a given if we have it here ? */ 1428 shouldn't this be a given if we have it here ? */
1429 if (!(*cur_addr->dmi_addr & 1)) 1429 if (!(*ha->addr & 1))
1430 continue; 1430 continue;
1431 1431
1432 /* only use the low order bits */ 1432 /* only use the low order bits */
1433 position = crc32_le(~0, cur_addr->dmi_addr, 6) & 0x3f; 1433 position = crc32_le(~0, ha->addr, 6) & 0x3f;
1434 1434
1435 /* do some messy swapping to put the bit in the right spot */ 1435 /* do some messy swapping to put the bit in the right spot */
1436 multicast_table[invert3[position&7]] |= 1436 multicast_table[invert3[position&7]] |=
diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
index 4fd1d8b38788..d6e3a12d65d3 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -1383,13 +1383,13 @@ static void smsc911x_set_multicast_list(struct net_device *dev)
1383 /* Enabling specific multicast addresses */ 1383 /* Enabling specific multicast addresses */
1384 unsigned int hash_high = 0; 1384 unsigned int hash_high = 0;
1385 unsigned int hash_low = 0; 1385 unsigned int hash_low = 0;
1386 struct dev_mc_list *mc_list; 1386 struct netdev_hw_addr *ha;
1387 1387
1388 pdata->set_bits_mask = MAC_CR_HPFILT_; 1388 pdata->set_bits_mask = MAC_CR_HPFILT_;
1389 pdata->clear_bits_mask = (MAC_CR_PRMS_ | MAC_CR_MCPAS_); 1389 pdata->clear_bits_mask = (MAC_CR_PRMS_ | MAC_CR_MCPAS_);
1390 1390
1391 netdev_for_each_mc_addr(mc_list, dev) { 1391 netdev_for_each_mc_addr(ha, dev) {
1392 unsigned int bitnum = smsc911x_hash(mc_list->dmi_addr); 1392 unsigned int bitnum = smsc911x_hash(ha->addr);
1393 unsigned int mask = 0x01 << (bitnum & 0x1F); 1393 unsigned int mask = 0x01 << (bitnum & 0x1F);
1394 1394
1395 if (bitnum & 0x20) 1395 if (bitnum & 0x20)
diff --git a/drivers/net/smsc9420.c b/drivers/net/smsc9420.c
index 34fa10d8ad40..5409ec1a5fd7 100644
--- a/drivers/net/smsc9420.c
+++ b/drivers/net/smsc9420.c
@@ -1063,12 +1063,12 @@ static void smsc9420_set_multicast_list(struct net_device *dev)
1063 mac_cr |= MAC_CR_MCPAS_; 1063 mac_cr |= MAC_CR_MCPAS_;
1064 mac_cr &= (~MAC_CR_HPFILT_); 1064 mac_cr &= (~MAC_CR_HPFILT_);
1065 } else if (!netdev_mc_empty(dev)) { 1065 } else if (!netdev_mc_empty(dev)) {
1066 struct dev_mc_list *mc_list; 1066 struct netdev_hw_addr *ha;
1067 u32 hash_lo = 0, hash_hi = 0; 1067 u32 hash_lo = 0, hash_hi = 0;
1068 1068
1069 smsc_dbg(HW, "Multicast filter enabled"); 1069 smsc_dbg(HW, "Multicast filter enabled");
1070 netdev_for_each_mc_addr(mc_list, dev) { 1070 netdev_for_each_mc_addr(ha, dev) {
1071 u32 bit_num = smsc9420_hash(mc_list->dmi_addr); 1071 u32 bit_num = smsc9420_hash(ha->addr);
1072 u32 mask = 1 << (bit_num & 0x1F); 1072 u32 mask = 1 << (bit_num & 0x1F);
1073 1073
1074 if (bit_num & 0x20) 1074 if (bit_num & 0x20)
diff --git a/drivers/net/sonic.c b/drivers/net/sonic.c
index 287c251075e5..e5d67327d707 100644
--- a/drivers/net/sonic.c
+++ b/drivers/net/sonic.c
@@ -531,7 +531,7 @@ static void sonic_multicast_list(struct net_device *dev)
531{ 531{
532 struct sonic_local *lp = netdev_priv(dev); 532 struct sonic_local *lp = netdev_priv(dev);
533 unsigned int rcr; 533 unsigned int rcr;
534 struct dev_mc_list *dmi; 534 struct netdev_hw_addr *ha;
535 unsigned char *addr; 535 unsigned char *addr;
536 int i; 536 int i;
537 537
@@ -550,8 +550,8 @@ static void sonic_multicast_list(struct net_device *dev)
550 netdev_mc_count(dev)); 550 netdev_mc_count(dev));
551 sonic_set_cam_enable(dev, 1); /* always enable our own address */ 551 sonic_set_cam_enable(dev, 1); /* always enable our own address */
552 i = 1; 552 i = 1;
553 netdev_for_each_mc_addr(dmi, dev) { 553 netdev_for_each_mc_addr(ha, dev) {
554 addr = dmi->dmi_addr; 554 addr = ha->addr;
555 sonic_cda_put(dev, i, SONIC_CD_CAP0, addr[1] << 8 | addr[0]); 555 sonic_cda_put(dev, i, SONIC_CD_CAP0, addr[1] << 8 | addr[0]);
556 sonic_cda_put(dev, i, SONIC_CD_CAP1, addr[3] << 8 | addr[2]); 556 sonic_cda_put(dev, i, SONIC_CD_CAP1, addr[3] << 8 | addr[2]);
557 sonic_cda_put(dev, i, SONIC_CD_CAP2, addr[5] << 8 | addr[4]); 557 sonic_cda_put(dev, i, SONIC_CD_CAP2, addr[5] << 8 | addr[4]);
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index 5ba9d989f8fc..c04c8f9a2d96 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -625,7 +625,7 @@ spider_net_get_multicast_hash(struct net_device *netdev, __u8 *addr)
625static void 625static void
626spider_net_set_multi(struct net_device *netdev) 626spider_net_set_multi(struct net_device *netdev)
627{ 627{
628 struct dev_mc_list *mc; 628 struct netdev_hw_addr *ha;
629 u8 hash; 629 u8 hash;
630 int i; 630 int i;
631 u32 reg; 631 u32 reg;
@@ -646,8 +646,8 @@ spider_net_set_multi(struct net_device *netdev)
646 hash = spider_net_get_multicast_hash(netdev, netdev->broadcast); */ 646 hash = spider_net_get_multicast_hash(netdev, netdev->broadcast); */
647 set_bit(0xfd, bitmask); 647 set_bit(0xfd, bitmask);
648 648
649 netdev_for_each_mc_addr(mc, netdev) { 649 netdev_for_each_mc_addr(ha, netdev) {
650 hash = spider_net_get_multicast_hash(netdev, mc->dmi_addr); 650 hash = spider_net_get_multicast_hash(netdev, ha->addr);
651 set_bit(hash, bitmask); 651 set_bit(hash, bitmask);
652 } 652 }
653 653
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 6dfa69899019..8a6d27cdc0bd 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -1766,7 +1766,7 @@ static void set_rx_mode(struct net_device *dev)
1766 struct netdev_private *np = netdev_priv(dev); 1766 struct netdev_private *np = netdev_priv(dev);
1767 void __iomem *ioaddr = np->base; 1767 void __iomem *ioaddr = np->base;
1768 u32 rx_mode = MinVLANPrio; 1768 u32 rx_mode = MinVLANPrio;
1769 struct dev_mc_list *mclist; 1769 struct netdev_hw_addr *ha;
1770 int i; 1770 int i;
1771#ifdef VLAN_SUPPORT 1771#ifdef VLAN_SUPPORT
1772 1772
@@ -1804,8 +1804,8 @@ static void set_rx_mode(struct net_device *dev)
1804 /* Use the 16 element perfect filter, skip first two entries. */ 1804 /* Use the 16 element perfect filter, skip first two entries. */
1805 void __iomem *filter_addr = ioaddr + PerfFilterTable + 2 * 16; 1805 void __iomem *filter_addr = ioaddr + PerfFilterTable + 2 * 16;
1806 __be16 *eaddrs; 1806 __be16 *eaddrs;
1807 netdev_for_each_mc_addr(mclist, dev) { 1807 netdev_for_each_mc_addr(ha, dev) {
1808 eaddrs = (__be16 *)mclist->dmi_addr; 1808 eaddrs = (__be16 *) ha->addr;
1809 writew(be16_to_cpu(eaddrs[2]), filter_addr); filter_addr += 4; 1809 writew(be16_to_cpu(eaddrs[2]), filter_addr); filter_addr += 4;
1810 writew(be16_to_cpu(eaddrs[1]), filter_addr); filter_addr += 4; 1810 writew(be16_to_cpu(eaddrs[1]), filter_addr); filter_addr += 4;
1811 writew(be16_to_cpu(eaddrs[0]), filter_addr); filter_addr += 8; 1811 writew(be16_to_cpu(eaddrs[0]), filter_addr); filter_addr += 8;
@@ -1825,10 +1825,10 @@ static void set_rx_mode(struct net_device *dev)
1825 __le16 mc_filter[32] __attribute__ ((aligned(sizeof(long)))); /* Multicast hash filter */ 1825 __le16 mc_filter[32] __attribute__ ((aligned(sizeof(long)))); /* Multicast hash filter */
1826 1826
1827 memset(mc_filter, 0, sizeof(mc_filter)); 1827 memset(mc_filter, 0, sizeof(mc_filter));
1828 netdev_for_each_mc_addr(mclist, dev) { 1828 netdev_for_each_mc_addr(ha, dev) {
1829 /* The chip uses the upper 9 CRC bits 1829 /* The chip uses the upper 9 CRC bits
1830 as index into the hash table */ 1830 as index into the hash table */
1831 int bit_nr = ether_crc_le(ETH_ALEN, mclist->dmi_addr) >> 23; 1831 int bit_nr = ether_crc_le(ETH_ALEN, ha->addr) >> 23;
1832 __le32 *fptr = (__le32 *) &mc_filter[(bit_nr >> 4) & ~1]; 1832 __le32 *fptr = (__le32 *) &mc_filter[(bit_nr >> 4) & ~1];
1833 1833
1834 *fptr |= cpu_to_le32(1 << (bit_nr & 31)); 1834 *fptr |= cpu_to_le32(1 << (bit_nr & 31));
diff --git a/drivers/net/stmmac/dwmac100.c b/drivers/net/stmmac/dwmac100.c
index 803b0373d843..c0a1c9df3ac7 100644
--- a/drivers/net/stmmac/dwmac100.c
+++ b/drivers/net/stmmac/dwmac100.c
@@ -138,7 +138,7 @@ static void dwmac100_dump_dma_regs(unsigned long ioaddr)
138{ 138{
139 int i; 139 int i;
140 140
141 DBG(KERN_DEBUG "DWMAC 100 DMA CSR \n"); 141 DBG(KERN_DEBUG "DWMAC 100 DMA CSR\n");
142 for (i = 0; i < 9; i++) 142 for (i = 0; i < 9; i++)
143 pr_debug("\t CSR%d (offset 0x%x): 0x%08x\n", i, 143 pr_debug("\t CSR%d (offset 0x%x): 0x%08x\n", i,
144 (DMA_BUS_MODE + i * 4), 144 (DMA_BUS_MODE + i * 4),
@@ -316,7 +316,7 @@ static void dwmac100_set_filter(struct net_device *dev)
316 MAC_CONTROL_HO | MAC_CONTROL_HP); 316 MAC_CONTROL_HO | MAC_CONTROL_HP);
317 } else { 317 } else {
318 u32 mc_filter[2]; 318 u32 mc_filter[2];
319 struct dev_mc_list *mclist; 319 struct netdev_hw_addr *ha;
320 320
321 /* Perfect filter mode for physical address and Hash 321 /* Perfect filter mode for physical address and Hash
322 filter for multicast */ 322 filter for multicast */
@@ -325,11 +325,11 @@ static void dwmac100_set_filter(struct net_device *dev)
325 MAC_CONTROL_IF | MAC_CONTROL_HO); 325 MAC_CONTROL_IF | MAC_CONTROL_HO);
326 326
327 memset(mc_filter, 0, sizeof(mc_filter)); 327 memset(mc_filter, 0, sizeof(mc_filter));
328 netdev_for_each_mc_addr(mclist, dev) { 328 netdev_for_each_mc_addr(ha, dev) {
329 /* The upper 6 bits of the calculated CRC are used to 329 /* The upper 6 bits of the calculated CRC are used to
330 * index the contens of the hash table */ 330 * index the contens of the hash table */
331 int bit_nr = 331 int bit_nr =
332 ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; 332 ether_crc(ETH_ALEN, ha->addr) >> 26;
333 /* The most significant bit determines the register to 333 /* The most significant bit determines the register to
334 * use (H/L) while the other 5 bits determine the bit 334 * use (H/L) while the other 5 bits determine the bit
335 * within the register. */ 335 * within the register. */
diff --git a/drivers/net/stmmac/dwmac1000_core.c b/drivers/net/stmmac/dwmac1000_core.c
index a6538ae4694c..bf73fda6adfb 100644
--- a/drivers/net/stmmac/dwmac1000_core.c
+++ b/drivers/net/stmmac/dwmac1000_core.c
@@ -94,17 +94,17 @@ static void dwmac1000_set_filter(struct net_device *dev)
94 writel(0xffffffff, ioaddr + GMAC_HASH_LOW); 94 writel(0xffffffff, ioaddr + GMAC_HASH_LOW);
95 } else if (!netdev_mc_empty(dev)) { 95 } else if (!netdev_mc_empty(dev)) {
96 u32 mc_filter[2]; 96 u32 mc_filter[2];
97 struct dev_mc_list *mclist; 97 struct netdev_hw_addr *ha;
98 98
99 /* Hash filter for multicast */ 99 /* Hash filter for multicast */
100 value = GMAC_FRAME_FILTER_HMC; 100 value = GMAC_FRAME_FILTER_HMC;
101 101
102 memset(mc_filter, 0, sizeof(mc_filter)); 102 memset(mc_filter, 0, sizeof(mc_filter));
103 netdev_for_each_mc_addr(mclist, dev) { 103 netdev_for_each_mc_addr(ha, dev) {
104 /* The upper 6 bits of the calculated CRC are used to 104 /* The upper 6 bits of the calculated CRC are used to
105 index the contens of the hash table */ 105 index the contens of the hash table */
106 int bit_nr = 106 int bit_nr =
107 bitrev32(~crc32_le(~0, mclist->dmi_addr, 6)) >> 26; 107 bitrev32(~crc32_le(~0, ha->addr, 6)) >> 26;
108 /* The most significant bit determines the register to 108 /* The most significant bit determines the register to
109 * use (H/L) while the other 5 bits determine the bit 109 * use (H/L) while the other 5 bits determine the bit
110 * within the register. */ 110 * within the register. */
diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index a6733612d64a..963f591f1e0e 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -836,7 +836,7 @@ static int stmmac_open(struct net_device *dev)
836#ifdef CONFIG_STMMAC_TIMER 836#ifdef CONFIG_STMMAC_TIMER
837 priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL); 837 priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL);
838 if (unlikely(priv->tm == NULL)) { 838 if (unlikely(priv->tm == NULL)) {
839 pr_err("%s: ERROR: timer memory alloc failed \n", __func__); 839 pr_err("%s: ERROR: timer memory alloc failed\n", __func__);
840 return -ENOMEM; 840 return -ENOMEM;
841 } 841 }
842 priv->tm->freq = tmrate; 842 priv->tm->freq = tmrate;
@@ -1685,8 +1685,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
1685 } 1685 }
1686 pr_info("done!\n"); 1686 pr_info("done!\n");
1687 1687
1688 if (!request_mem_region(res->start, (res->end - res->start), 1688 if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
1689 pdev->name)) {
1690 pr_err("%s: ERROR: memory allocation failed" 1689 pr_err("%s: ERROR: memory allocation failed"
1691 "cannot get the I/O addr 0x%x\n", 1690 "cannot get the I/O addr 0x%x\n",
1692 __func__, (unsigned int)res->start); 1691 __func__, (unsigned int)res->start);
@@ -1694,9 +1693,9 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
1694 goto out; 1693 goto out;
1695 } 1694 }
1696 1695
1697 addr = ioremap(res->start, (res->end - res->start)); 1696 addr = ioremap(res->start, resource_size(res));
1698 if (!addr) { 1697 if (!addr) {
1699 pr_err("%s: ERROR: memory mapping failed \n", __func__); 1698 pr_err("%s: ERROR: memory mapping failed\n", __func__);
1700 ret = -ENOMEM; 1699 ret = -ENOMEM;
1701 goto out; 1700 goto out;
1702 } 1701 }
@@ -1774,7 +1773,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
1774out: 1773out:
1775 if (ret < 0) { 1774 if (ret < 0) {
1776 platform_set_drvdata(pdev, NULL); 1775 platform_set_drvdata(pdev, NULL);
1777 release_mem_region(res->start, (res->end - res->start)); 1776 release_mem_region(res->start, resource_size(res));
1778 if (addr != NULL) 1777 if (addr != NULL)
1779 iounmap(addr); 1778 iounmap(addr);
1780 } 1779 }
@@ -1812,7 +1811,7 @@ static int stmmac_dvr_remove(struct platform_device *pdev)
1812 1811
1813 iounmap((void *)ndev->base_addr); 1812 iounmap((void *)ndev->base_addr);
1814 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1813 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1815 release_mem_region(res->start, (res->end - res->start)); 1814 release_mem_region(res->start, resource_size(res));
1816 1815
1817 free_netdev(ndev); 1816 free_netdev(ndev);
1818 1817
diff --git a/drivers/net/sun3_82586.c b/drivers/net/sun3_82586.c
index 2f6a760e5f21..2cfa065c39c0 100644
--- a/drivers/net/sun3_82586.c
+++ b/drivers/net/sun3_82586.c
@@ -413,7 +413,7 @@ static int init586(struct net_device *dev)
413 volatile struct iasetup_cmd_struct *ias_cmd; 413 volatile struct iasetup_cmd_struct *ias_cmd;
414 volatile struct tdr_cmd_struct *tdr_cmd; 414 volatile struct tdr_cmd_struct *tdr_cmd;
415 volatile struct mcsetup_cmd_struct *mc_cmd; 415 volatile struct mcsetup_cmd_struct *mc_cmd;
416 struct dev_mc_list *dmi; 416 struct netdev_hw_addr *ha;
417 int num_addrs=netdev_mc_count(dev); 417 int num_addrs=netdev_mc_count(dev);
418 418
419 ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct)); 419 ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct));
@@ -537,9 +537,9 @@ static int init586(struct net_device *dev)
537 mc_cmd->mc_cnt = swab16(num_addrs * 6); 537 mc_cmd->mc_cnt = swab16(num_addrs * 6);
538 538
539 i = 0; 539 i = 0;
540 netdev_for_each_mc_addr(dmi, dev) 540 netdev_for_each_mc_addr(ha, dev)
541 memcpy((char *) mc_cmd->mc_list[i++], 541 memcpy((char *) mc_cmd->mc_list[i++],
542 dmi->dmi_addr, ETH_ALEN); 542 ha->addr, ETH_ALEN);
543 543
544 p->scb->cbl_offset = make16(mc_cmd); 544 p->scb->cbl_offset = make16(mc_cmd);
545 p->scb->cmd_cuc = CUC_START; 545 p->scb->cmd_cuc = CUC_START;
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index a0bd361d5eca..4dd159b4116b 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -999,7 +999,7 @@ static void bigmac_set_multicast(struct net_device *dev)
999{ 999{
1000 struct bigmac *bp = netdev_priv(dev); 1000 struct bigmac *bp = netdev_priv(dev);
1001 void __iomem *bregs = bp->bregs; 1001 void __iomem *bregs = bp->bregs;
1002 struct dev_mc_list *dmi; 1002 struct netdev_hw_addr *ha;
1003 char *addrs; 1003 char *addrs;
1004 int i; 1004 int i;
1005 u32 tmp, crc; 1005 u32 tmp, crc;
@@ -1028,8 +1028,8 @@ static void bigmac_set_multicast(struct net_device *dev)
1028 for (i = 0; i < 4; i++) 1028 for (i = 0; i < 4; i++)
1029 hash_table[i] = 0; 1029 hash_table[i] = 0;
1030 1030
1031 netdev_for_each_mc_addr(dmi, dev) { 1031 netdev_for_each_mc_addr(ha, dev) {
1032 addrs = dmi->dmi_addr; 1032 addrs = ha->addr;
1033 1033
1034 if (!(*addrs & 1)) 1034 if (!(*addrs & 1))
1035 continue; 1035 continue;
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index a855934dfc3b..47e8cce10d1e 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -1523,13 +1523,13 @@ static void set_rx_mode(struct net_device *dev)
1523 memset(mc_filter, 0xff, sizeof(mc_filter)); 1523 memset(mc_filter, 0xff, sizeof(mc_filter));
1524 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; 1524 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
1525 } else if (!netdev_mc_empty(dev)) { 1525 } else if (!netdev_mc_empty(dev)) {
1526 struct dev_mc_list *mclist; 1526 struct netdev_hw_addr *ha;
1527 int bit; 1527 int bit;
1528 int index; 1528 int index;
1529 int crc; 1529 int crc;
1530 memset (mc_filter, 0, sizeof (mc_filter)); 1530 memset (mc_filter, 0, sizeof (mc_filter));
1531 netdev_for_each_mc_addr(mclist, dev) { 1531 netdev_for_each_mc_addr(ha, dev) {
1532 crc = ether_crc_le (ETH_ALEN, mclist->dmi_addr); 1532 crc = ether_crc_le(ETH_ALEN, ha->addr);
1533 for (index=0, bit=0; bit < 6; bit++, crc <<= 1) 1533 for (index=0, bit=0; bit < 6; bit++, crc <<= 1)
1534 if (crc & 0x80000000) index |= 1 << bit; 1534 if (crc & 0x80000000) index |= 1 << bit;
1535 mc_filter[index/16] |= (1 << (index % 16)); 1535 mc_filter[index/16] |= (1 << (index % 16));
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 70196bc5fe61..58a27541ae39 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -1846,12 +1846,12 @@ static u32 gem_setup_multicast(struct gem *gp)
1846 } else { 1846 } else {
1847 u16 hash_table[16]; 1847 u16 hash_table[16];
1848 u32 crc; 1848 u32 crc;
1849 struct dev_mc_list *dmi; 1849 struct netdev_hw_addr *ha;
1850 int i; 1850 int i;
1851 1851
1852 memset(hash_table, 0, sizeof(hash_table)); 1852 memset(hash_table, 0, sizeof(hash_table));
1853 netdev_for_each_mc_addr(dmi, gp->dev) { 1853 netdev_for_each_mc_addr(ha, gp->dev) {
1854 char *addrs = dmi->dmi_addr; 1854 char *addrs = ha->addr;
1855 1855
1856 if (!(*addrs & 1)) 1856 if (!(*addrs & 1))
1857 continue; 1857 continue;
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index b17dbb11bd67..20deb14e98ff 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -1523,13 +1523,13 @@ static int happy_meal_init(struct happy_meal *hp)
1523 hme_write32(hp, bregs + BMAC_HTABLE3, 0xffff); 1523 hme_write32(hp, bregs + BMAC_HTABLE3, 0xffff);
1524 } else if ((hp->dev->flags & IFF_PROMISC) == 0) { 1524 } else if ((hp->dev->flags & IFF_PROMISC) == 0) {
1525 u16 hash_table[4]; 1525 u16 hash_table[4];
1526 struct dev_mc_list *dmi; 1526 struct netdev_hw_addr *ha;
1527 char *addrs; 1527 char *addrs;
1528 u32 crc; 1528 u32 crc;
1529 1529
1530 memset(hash_table, 0, sizeof(hash_table)); 1530 memset(hash_table, 0, sizeof(hash_table));
1531 netdev_for_each_mc_addr(dmi, hp->dev) { 1531 netdev_for_each_mc_addr(ha, hp->dev) {
1532 addrs = dmi->dmi_addr; 1532 addrs = ha->addr;
1533 1533
1534 if (!(*addrs & 1)) 1534 if (!(*addrs & 1))
1535 continue; 1535 continue;
@@ -2362,7 +2362,7 @@ static void happy_meal_set_multicast(struct net_device *dev)
2362{ 2362{
2363 struct happy_meal *hp = netdev_priv(dev); 2363 struct happy_meal *hp = netdev_priv(dev);
2364 void __iomem *bregs = hp->bigmacregs; 2364 void __iomem *bregs = hp->bigmacregs;
2365 struct dev_mc_list *dmi; 2365 struct netdev_hw_addr *ha;
2366 char *addrs; 2366 char *addrs;
2367 u32 crc; 2367 u32 crc;
2368 2368
@@ -2380,8 +2380,8 @@ static void happy_meal_set_multicast(struct net_device *dev)
2380 u16 hash_table[4]; 2380 u16 hash_table[4];
2381 2381
2382 memset(hash_table, 0, sizeof(hash_table)); 2382 memset(hash_table, 0, sizeof(hash_table));
2383 netdev_for_each_mc_addr(dmi, dev) { 2383 netdev_for_each_mc_addr(ha, dev) {
2384 addrs = dmi->dmi_addr; 2384 addrs = ha->addr;
2385 2385
2386 if (!(*addrs & 1)) 2386 if (!(*addrs & 1))
2387 continue; 2387 continue;
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c
index d7c73f478ef5..674570584bd5 100644
--- a/drivers/net/sunlance.c
+++ b/drivers/net/sunlance.c
@@ -1170,7 +1170,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
1170static void lance_load_multicast(struct net_device *dev) 1170static void lance_load_multicast(struct net_device *dev)
1171{ 1171{
1172 struct lance_private *lp = netdev_priv(dev); 1172 struct lance_private *lp = netdev_priv(dev);
1173 struct dev_mc_list *dmi; 1173 struct netdev_hw_addr *ha;
1174 char *addrs; 1174 char *addrs;
1175 u32 crc; 1175 u32 crc;
1176 u32 val; 1176 u32 val;
@@ -1195,8 +1195,8 @@ static void lance_load_multicast(struct net_device *dev)
1195 return; 1195 return;
1196 1196
1197 /* Add addresses */ 1197 /* Add addresses */
1198 netdev_for_each_mc_addr(dmi, dev) { 1198 netdev_for_each_mc_addr(ha, dev) {
1199 addrs = dmi->dmi_addr; 1199 addrs = ha->addr;
1200 1200
1201 /* multicast address? */ 1201 /* multicast address? */
1202 if (!(*addrs & 1)) 1202 if (!(*addrs & 1))
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c
index be637dce944c..239f09772191 100644
--- a/drivers/net/sunqe.c
+++ b/drivers/net/sunqe.c
@@ -627,7 +627,7 @@ static int qe_start_xmit(struct sk_buff *skb, struct net_device *dev)
627static void qe_set_multicast(struct net_device *dev) 627static void qe_set_multicast(struct net_device *dev)
628{ 628{
629 struct sunqe *qep = netdev_priv(dev); 629 struct sunqe *qep = netdev_priv(dev);
630 struct dev_mc_list *dmi; 630 struct netdev_hw_addr *ha;
631 u8 new_mconfig = qep->mconfig; 631 u8 new_mconfig = qep->mconfig;
632 char *addrs; 632 char *addrs;
633 int i; 633 int i;
@@ -651,8 +651,8 @@ static void qe_set_multicast(struct net_device *dev)
651 u8 *hbytes = (unsigned char *) &hash_table[0]; 651 u8 *hbytes = (unsigned char *) &hash_table[0];
652 652
653 memset(hash_table, 0, sizeof(hash_table)); 653 memset(hash_table, 0, sizeof(hash_table));
654 netdev_for_each_mc_addr(dmi, dev) { 654 netdev_for_each_mc_addr(ha, dev) {
655 addrs = dmi->dmi_addr; 655 addrs = ha->addr;
656 656
657 if (!(*addrs & 1)) 657 if (!(*addrs & 1))
658 continue; 658 continue;
diff --git a/drivers/net/sunvnet.c b/drivers/net/sunvnet.c
index 6b1b7cea7f6b..6cf8b06be5cd 100644
--- a/drivers/net/sunvnet.c
+++ b/drivers/net/sunvnet.c
@@ -763,12 +763,12 @@ static struct vnet_mcast_entry *__vnet_mc_find(struct vnet *vp, u8 *addr)
763 763
764static void __update_mc_list(struct vnet *vp, struct net_device *dev) 764static void __update_mc_list(struct vnet *vp, struct net_device *dev)
765{ 765{
766 struct dev_addr_list *p; 766 struct netdev_hw_addr *ha;
767 767
768 netdev_for_each_mc_addr(p, dev) { 768 netdev_for_each_mc_addr(ha, dev) {
769 struct vnet_mcast_entry *m; 769 struct vnet_mcast_entry *m;
770 770
771 m = __vnet_mc_find(vp, p->dmi_addr); 771 m = __vnet_mc_find(vp, ha->addr);
772 if (m) { 772 if (m) {
773 m->hit = 1; 773 m->hit = 1;
774 continue; 774 continue;
@@ -778,7 +778,7 @@ static void __update_mc_list(struct vnet *vp, struct net_device *dev)
778 m = kzalloc(sizeof(*m), GFP_ATOMIC); 778 m = kzalloc(sizeof(*m), GFP_ATOMIC);
779 if (!m) 779 if (!m)
780 continue; 780 continue;
781 memcpy(m->addr, p->dmi_addr, ETH_ALEN); 781 memcpy(m->addr, ha->addr, ETH_ALEN);
782 m->hit = 1; 782 m->hit = 1;
783 783
784 m->next = vp->mcast_list; 784 m->next = vp->mcast_list;
diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c
index 49bd84c0d583..36149ddace46 100644
--- a/drivers/net/tc35815.c
+++ b/drivers/net/tc35815.c
@@ -1954,16 +1954,16 @@ tc35815_set_multicast_list(struct net_device *dev)
1954 /* Disable promiscuous mode, use normal mode. */ 1954 /* Disable promiscuous mode, use normal mode. */
1955 tc_writel(CAM_CompEn | CAM_BroadAcc | CAM_GroupAcc, &tr->CAM_Ctl); 1955 tc_writel(CAM_CompEn | CAM_BroadAcc | CAM_GroupAcc, &tr->CAM_Ctl);
1956 } else if (!netdev_mc_empty(dev)) { 1956 } else if (!netdev_mc_empty(dev)) {
1957 struct dev_mc_list *cur_addr; 1957 struct netdev_hw_addr *ha;
1958 int i; 1958 int i;
1959 int ena_bits = CAM_Ena_Bit(CAM_ENTRY_SOURCE); 1959 int ena_bits = CAM_Ena_Bit(CAM_ENTRY_SOURCE);
1960 1960
1961 tc_writel(0, &tr->CAM_Ctl); 1961 tc_writel(0, &tr->CAM_Ctl);
1962 /* Walk the address list, and load the filter */ 1962 /* Walk the address list, and load the filter */
1963 i = 0; 1963 i = 0;
1964 netdev_for_each_mc_addr(cur_addr, dev) { 1964 netdev_for_each_mc_addr(ha, dev) {
1965 /* entry 0,1 is reserved. */ 1965 /* entry 0,1 is reserved. */
1966 tc35815_set_cam_entry(dev, i + 2, cur_addr->dmi_addr); 1966 tc35815_set_cam_entry(dev, i + 2, ha->addr);
1967 ena_bits |= CAM_Ena_Bit(i + 2); 1967 ena_bits |= CAM_Ena_Bit(i + 2);
1968 i++; 1968 i++;
1969 } 1969 }
diff --git a/drivers/net/tehuti.c b/drivers/net/tehuti.c
index f5493092521a..a38aede5c8d6 100644
--- a/drivers/net/tehuti.c
+++ b/drivers/net/tehuti.c
@@ -808,7 +808,7 @@ static void bdx_setmulti(struct net_device *ndev)
808 WRITE_REG(priv, regRX_MCST_HASH0 + i * 4, ~0); 808 WRITE_REG(priv, regRX_MCST_HASH0 + i * 4, ~0);
809 } else if (!netdev_mc_empty(ndev)) { 809 } else if (!netdev_mc_empty(ndev)) {
810 u8 hash; 810 u8 hash;
811 struct dev_mc_list *mclist; 811 struct netdev_hw_addr *ha;
812 u32 reg, val; 812 u32 reg, val;
813 813
814 /* set IMF to deny all multicast frames */ 814 /* set IMF to deny all multicast frames */
@@ -825,10 +825,10 @@ static void bdx_setmulti(struct net_device *ndev)
825 * into RX_MAC_MCST regs. we skip this phase now and accept ALL 825 * into RX_MAC_MCST regs. we skip this phase now and accept ALL
826 * multicast frames throu IMF */ 826 * multicast frames throu IMF */
827 /* accept the rest of addresses throu IMF */ 827 /* accept the rest of addresses throu IMF */
828 netdev_for_each_mc_addr(mclist, ndev) { 828 netdev_for_each_mc_addr(ha, ndev) {
829 hash = 0; 829 hash = 0;
830 for (i = 0; i < ETH_ALEN; i++) 830 for (i = 0; i < ETH_ALEN; i++)
831 hash ^= mclist->dmi_addr[i]; 831 hash ^= ha->addr[i];
832 reg = regRX_MCST_HASH0 + ((hash >> 5) << 2); 832 reg = regRX_MCST_HASH0 + ((hash >> 5) << 2);
833 val = READ_REG(priv, reg); 833 val = READ_REG(priv, reg);
834 val |= (1 << (hash % 32)); 834 val |= (1 << (hash % 32));
@@ -1303,7 +1303,6 @@ static int bdx_rx_receive(struct bdx_priv *priv, struct rxd_fifo *f, int budget)
1303 priv->net_stats.rx_bytes += len; 1303 priv->net_stats.rx_bytes += len;
1304 1304
1305 skb_put(skb, len); 1305 skb_put(skb, len);
1306 skb->dev = priv->ndev;
1307 skb->ip_summed = CHECKSUM_UNNECESSARY; 1306 skb->ip_summed = CHECKSUM_UNNECESSARY;
1308 skb->protocol = eth_type_trans(skb, priv->ndev); 1307 skb->protocol = eth_type_trans(skb, priv->ndev);
1309 1308
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 22cf1c446de3..460a0c22b318 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -67,8 +67,8 @@
67#include "tg3.h" 67#include "tg3.h"
68 68
69#define DRV_MODULE_NAME "tg3" 69#define DRV_MODULE_NAME "tg3"
70#define DRV_MODULE_VERSION "3.108" 70#define DRV_MODULE_VERSION "3.109"
71#define DRV_MODULE_RELDATE "February 17, 2010" 71#define DRV_MODULE_RELDATE "April 2, 2010"
72 72
73#define TG3_DEF_MAC_MODE 0 73#define TG3_DEF_MAC_MODE 0
74#define TG3_DEF_RX_MODE 0 74#define TG3_DEF_RX_MODE 0
@@ -101,7 +101,7 @@
101#define TG3_DEF_RX_RING_PENDING 200 101#define TG3_DEF_RX_RING_PENDING 200
102#define TG3_RX_JUMBO_RING_SIZE 256 102#define TG3_RX_JUMBO_RING_SIZE 256
103#define TG3_DEF_RX_JUMBO_RING_PENDING 100 103#define TG3_DEF_RX_JUMBO_RING_PENDING 100
104#define TG3_RSS_INDIR_TBL_SIZE 128 104#define TG3_RSS_INDIR_TBL_SIZE 128
105 105
106/* Do not place this n-ring entries value into the tp struct itself, 106/* Do not place this n-ring entries value into the tp struct itself,
107 * we really want to expose these constants to GCC so that modulo et 107 * we really want to expose these constants to GCC so that modulo et
@@ -142,6 +142,8 @@
142#define TG3_RX_JMB_BUFF_RING_SIZE \ 142#define TG3_RX_JMB_BUFF_RING_SIZE \
143 (sizeof(struct ring_info) * TG3_RX_JUMBO_RING_SIZE) 143 (sizeof(struct ring_info) * TG3_RX_JUMBO_RING_SIZE)
144 144
145#define TG3_RSS_MIN_NUM_MSIX_VECS 2
146
145/* minimum number of free TX descriptors required to wake up TX process */ 147/* minimum number of free TX descriptors required to wake up TX process */
146#define TG3_TX_WAKEUP_THRESH(tnapi) ((tnapi)->tx_pending / 4) 148#define TG3_TX_WAKEUP_THRESH(tnapi) ((tnapi)->tx_pending / 4)
147 149
@@ -152,6 +154,8 @@
152 154
153#define TG3_NUM_TEST 6 155#define TG3_NUM_TEST 6
154 156
157#define TG3_FW_UPDATE_TIMEOUT_SEC 5
158
155#define FIRMWARE_TG3 "tigon/tg3.bin" 159#define FIRMWARE_TG3 "tigon/tg3.bin"
156#define FIRMWARE_TG3TSO "tigon/tg3_tso.bin" 160#define FIRMWARE_TG3TSO "tigon/tg3_tso.bin"
157#define FIRMWARE_TG3TSO5 "tigon/tg3_tso5.bin" 161#define FIRMWARE_TG3TSO5 "tigon/tg3_tso5.bin"
@@ -167,8 +171,6 @@ MODULE_FIRMWARE(FIRMWARE_TG3);
167MODULE_FIRMWARE(FIRMWARE_TG3TSO); 171MODULE_FIRMWARE(FIRMWARE_TG3TSO);
168MODULE_FIRMWARE(FIRMWARE_TG3TSO5); 172MODULE_FIRMWARE(FIRMWARE_TG3TSO5);
169 173
170#define TG3_RSS_MIN_NUM_MSIX_VECS 2
171
172static int tg3_debug = -1; /* -1 == use TG3_DEF_MSG_ENABLE as value */ 174static int tg3_debug = -1; /* -1 == use TG3_DEF_MSG_ENABLE as value */
173module_param(tg3_debug, int, 0); 175module_param(tg3_debug, int, 0);
174MODULE_PARM_DESC(tg3_debug, "Tigon3 bitmapped debugging message enable value"); 176MODULE_PARM_DESC(tg3_debug, "Tigon3 bitmapped debugging message enable value");
@@ -496,16 +498,16 @@ static void tg3_write32_mbox_5906(struct tg3 *tp, u32 off, u32 val)
496 writel(val, tp->regs + off + GRCMBOX_BASE); 498 writel(val, tp->regs + off + GRCMBOX_BASE);
497} 499}
498 500
499#define tw32_mailbox(reg, val) tp->write32_mbox(tp, reg, val) 501#define tw32_mailbox(reg, val) tp->write32_mbox(tp, reg, val)
500#define tw32_mailbox_f(reg, val) tw32_mailbox_flush(tp, (reg), (val)) 502#define tw32_mailbox_f(reg, val) tw32_mailbox_flush(tp, (reg), (val))
501#define tw32_rx_mbox(reg, val) tp->write32_rx_mbox(tp, reg, val) 503#define tw32_rx_mbox(reg, val) tp->write32_rx_mbox(tp, reg, val)
502#define tw32_tx_mbox(reg, val) tp->write32_tx_mbox(tp, reg, val) 504#define tw32_tx_mbox(reg, val) tp->write32_tx_mbox(tp, reg, val)
503#define tr32_mailbox(reg) tp->read32_mbox(tp, reg) 505#define tr32_mailbox(reg) tp->read32_mbox(tp, reg)
504 506
505#define tw32(reg,val) tp->write32(tp, reg, val) 507#define tw32(reg, val) tp->write32(tp, reg, val)
506#define tw32_f(reg,val) _tw32_flush(tp,(reg),(val), 0) 508#define tw32_f(reg, val) _tw32_flush(tp, (reg), (val), 0)
507#define tw32_wait_f(reg,val,us) _tw32_flush(tp,(reg),(val), (us)) 509#define tw32_wait_f(reg, val, us) _tw32_flush(tp, (reg), (val), (us))
508#define tr32(reg) tp->read32(tp, reg) 510#define tr32(reg) tp->read32(tp, reg)
509 511
510static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val) 512static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val)
511{ 513{
@@ -579,11 +581,11 @@ static int tg3_ape_lock(struct tg3 *tp, int locknum)
579 return 0; 581 return 0;
580 582
581 switch (locknum) { 583 switch (locknum) {
582 case TG3_APE_LOCK_GRC: 584 case TG3_APE_LOCK_GRC:
583 case TG3_APE_LOCK_MEM: 585 case TG3_APE_LOCK_MEM:
584 break; 586 break;
585 default: 587 default:
586 return -EINVAL; 588 return -EINVAL;
587 } 589 }
588 590
589 off = 4 * locknum; 591 off = 4 * locknum;
@@ -617,11 +619,11 @@ static void tg3_ape_unlock(struct tg3 *tp, int locknum)
617 return; 619 return;
618 620
619 switch (locknum) { 621 switch (locknum) {
620 case TG3_APE_LOCK_GRC: 622 case TG3_APE_LOCK_GRC:
621 case TG3_APE_LOCK_MEM: 623 case TG3_APE_LOCK_MEM:
622 break; 624 break;
623 default: 625 default:
624 return; 626 return;
625 } 627 }
626 628
627 off = 4 * locknum; 629 off = 4 * locknum;
@@ -651,6 +653,7 @@ static void tg3_enable_ints(struct tg3 *tp)
651 tp->coal_now = tp->coalesce_mode | HOSTCC_MODE_ENABLE; 653 tp->coal_now = tp->coalesce_mode | HOSTCC_MODE_ENABLE;
652 for (i = 0; i < tp->irq_cnt; i++) { 654 for (i = 0; i < tp->irq_cnt; i++) {
653 struct tg3_napi *tnapi = &tp->napi[i]; 655 struct tg3_napi *tnapi = &tp->napi[i];
656
654 tw32_mailbox_f(tnapi->int_mbox, tnapi->last_tag << 24); 657 tw32_mailbox_f(tnapi->int_mbox, tnapi->last_tag << 24);
655 if (tp->tg3_flags2 & TG3_FLG2_1SHOT_MSI) 658 if (tp->tg3_flags2 & TG3_FLG2_1SHOT_MSI)
656 tw32_mailbox_f(tnapi->int_mbox, tnapi->last_tag << 24); 659 tw32_mailbox_f(tnapi->int_mbox, tnapi->last_tag << 24);
@@ -1098,7 +1101,7 @@ static int tg3_mdio_init(struct tg3 *tp)
1098 1101
1099 i = mdiobus_register(tp->mdio_bus); 1102 i = mdiobus_register(tp->mdio_bus);
1100 if (i) { 1103 if (i) {
1101 netdev_warn(tp->dev, "mdiobus_reg failed (0x%x)\n", i); 1104 dev_warn(&tp->pdev->dev, "mdiobus_reg failed (0x%x)\n", i);
1102 mdiobus_free(tp->mdio_bus); 1105 mdiobus_free(tp->mdio_bus);
1103 return i; 1106 return i;
1104 } 1107 }
@@ -1106,7 +1109,7 @@ static int tg3_mdio_init(struct tg3 *tp)
1106 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 1109 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
1107 1110
1108 if (!phydev || !phydev->drv) { 1111 if (!phydev || !phydev->drv) {
1109 netdev_warn(tp->dev, "No PHY devices\n"); 1112 dev_warn(&tp->pdev->dev, "No PHY devices\n");
1110 mdiobus_unregister(tp->mdio_bus); 1113 mdiobus_unregister(tp->mdio_bus);
1111 mdiobus_free(tp->mdio_bus); 1114 mdiobus_free(tp->mdio_bus);
1112 return -ENODEV; 1115 return -ENODEV;
@@ -1437,7 +1440,7 @@ static void tg3_adjust_link(struct net_device *dev)
1437 phydev->speed != tp->link_config.active_speed || 1440 phydev->speed != tp->link_config.active_speed ||
1438 phydev->duplex != tp->link_config.active_duplex || 1441 phydev->duplex != tp->link_config.active_duplex ||
1439 oldflowctrl != tp->link_config.active_flowctrl) 1442 oldflowctrl != tp->link_config.active_flowctrl)
1440 linkmesg = 1; 1443 linkmesg = 1;
1441 1444
1442 tp->link_config.active_speed = phydev->speed; 1445 tp->link_config.active_speed = phydev->speed;
1443 tp->link_config.active_duplex = phydev->duplex; 1446 tp->link_config.active_duplex = phydev->duplex;
@@ -1464,7 +1467,7 @@ static int tg3_phy_init(struct tg3 *tp)
1464 phydev = phy_connect(tp->dev, dev_name(&phydev->dev), tg3_adjust_link, 1467 phydev = phy_connect(tp->dev, dev_name(&phydev->dev), tg3_adjust_link,
1465 phydev->dev_flags, phydev->interface); 1468 phydev->dev_flags, phydev->interface);
1466 if (IS_ERR(phydev)) { 1469 if (IS_ERR(phydev)) {
1467 netdev_err(tp->dev, "Could not attach to PHY\n"); 1470 dev_err(&tp->pdev->dev, "Could not attach to PHY\n");
1468 return PTR_ERR(phydev); 1471 return PTR_ERR(phydev);
1469 } 1472 }
1470 1473
@@ -1855,8 +1858,7 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
1855 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { 1858 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
1856 /* Set Extended packet length bit for jumbo frames */ 1859 /* Set Extended packet length bit for jumbo frames */
1857 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4400); 1860 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4400);
1858 } 1861 } else {
1859 else {
1860 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400); 1862 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400);
1861 } 1863 }
1862 1864
@@ -1974,8 +1976,7 @@ out:
1974 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x401f); 1976 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x401f);
1975 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x14e2); 1977 tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x14e2);
1976 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400); 1978 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400);
1977 } 1979 } else if (tp->tg3_flags2 & TG3_FLG2_PHY_JITTER_BUG) {
1978 else if (tp->tg3_flags2 & TG3_FLG2_PHY_JITTER_BUG) {
1979 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); 1980 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00);
1980 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000a); 1981 tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000a);
1981 if (tp->tg3_flags2 & TG3_FLG2_PHY_ADJUST_TRIM) { 1982 if (tp->tg3_flags2 & TG3_FLG2_PHY_ADJUST_TRIM) {
@@ -2007,8 +2008,8 @@ out:
2007 u32 phy_reg; 2008 u32 phy_reg;
2008 2009
2009 if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &phy_reg)) 2010 if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &phy_reg))
2010 tg3_writephy(tp, MII_TG3_EXT_CTRL, 2011 tg3_writephy(tp, MII_TG3_EXT_CTRL,
2011 phy_reg | MII_TG3_EXT_CTRL_FIFO_ELASTIC); 2012 phy_reg | MII_TG3_EXT_CTRL_FIFO_ELASTIC);
2012 } 2013 }
2013 2014
2014 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { 2015 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
@@ -3425,7 +3426,7 @@ static int tg3_fiber_aneg_smachine(struct tg3 *tp,
3425 ap->rxconfig = rx_cfg_reg; 3426 ap->rxconfig = rx_cfg_reg;
3426 ret = ANEG_OK; 3427 ret = ANEG_OK;
3427 3428
3428 switch(ap->state) { 3429 switch (ap->state) {
3429 case ANEG_STATE_UNKNOWN: 3430 case ANEG_STATE_UNKNOWN:
3430 if (ap->flags & (MR_AN_ENABLE | MR_RESTART_AN)) 3431 if (ap->flags & (MR_AN_ENABLE | MR_RESTART_AN))
3431 ap->state = ANEG_STATE_AN_ENABLE; 3432 ap->state = ANEG_STATE_AN_ENABLE;
@@ -3463,11 +3464,10 @@ static int tg3_fiber_aneg_smachine(struct tg3 *tp,
3463 /* fallthru */ 3464 /* fallthru */
3464 case ANEG_STATE_RESTART: 3465 case ANEG_STATE_RESTART:
3465 delta = ap->cur_time - ap->link_time; 3466 delta = ap->cur_time - ap->link_time;
3466 if (delta > ANEG_STATE_SETTLE_TIME) { 3467 if (delta > ANEG_STATE_SETTLE_TIME)
3467 ap->state = ANEG_STATE_ABILITY_DETECT_INIT; 3468 ap->state = ANEG_STATE_ABILITY_DETECT_INIT;
3468 } else { 3469 else
3469 ret = ANEG_TIMER_ENAB; 3470 ret = ANEG_TIMER_ENAB;
3470 }
3471 break; 3471 break;
3472 3472
3473 case ANEG_STATE_DISABLE_LINK_OK: 3473 case ANEG_STATE_DISABLE_LINK_OK:
@@ -3491,9 +3491,8 @@ static int tg3_fiber_aneg_smachine(struct tg3 *tp,
3491 break; 3491 break;
3492 3492
3493 case ANEG_STATE_ABILITY_DETECT: 3493 case ANEG_STATE_ABILITY_DETECT:
3494 if (ap->ability_match != 0 && ap->rxconfig != 0) { 3494 if (ap->ability_match != 0 && ap->rxconfig != 0)
3495 ap->state = ANEG_STATE_ACK_DETECT_INIT; 3495 ap->state = ANEG_STATE_ACK_DETECT_INIT;
3496 }
3497 break; 3496 break;
3498 3497
3499 case ANEG_STATE_ACK_DETECT_INIT: 3498 case ANEG_STATE_ACK_DETECT_INIT:
@@ -4171,9 +4170,9 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset)
4171 current_duplex = DUPLEX_FULL; 4170 current_duplex = DUPLEX_FULL;
4172 else 4171 else
4173 current_duplex = DUPLEX_HALF; 4172 current_duplex = DUPLEX_HALF;
4174 } 4173 } else {
4175 else
4176 current_link_up = 0; 4174 current_link_up = 0;
4175 }
4177 } 4176 }
4178 } 4177 }
4179 4178
@@ -4211,6 +4210,7 @@ static void tg3_serdes_parallel_detect(struct tg3 *tp)
4211 tp->serdes_counter--; 4210 tp->serdes_counter--;
4212 return; 4211 return;
4213 } 4212 }
4213
4214 if (!netif_carrier_ok(tp->dev) && 4214 if (!netif_carrier_ok(tp->dev) &&
4215 (tp->link_config.autoneg == AUTONEG_ENABLE)) { 4215 (tp->link_config.autoneg == AUTONEG_ENABLE)) {
4216 u32 bmcr; 4216 u32 bmcr;
@@ -4240,10 +4240,9 @@ static void tg3_serdes_parallel_detect(struct tg3 *tp)
4240 tp->tg3_flags2 |= TG3_FLG2_PARALLEL_DETECT; 4240 tp->tg3_flags2 |= TG3_FLG2_PARALLEL_DETECT;
4241 } 4241 }
4242 } 4242 }
4243 } 4243 } else if (netif_carrier_ok(tp->dev) &&
4244 else if (netif_carrier_ok(tp->dev) && 4244 (tp->link_config.autoneg == AUTONEG_ENABLE) &&
4245 (tp->link_config.autoneg == AUTONEG_ENABLE) && 4245 (tp->tg3_flags2 & TG3_FLG2_PARALLEL_DETECT)) {
4246 (tp->tg3_flags2 & TG3_FLG2_PARALLEL_DETECT)) {
4247 u32 phy2; 4246 u32 phy2;
4248 4247
4249 /* Select expansion interrupt status register */ 4248 /* Select expansion interrupt status register */
@@ -4266,13 +4265,12 @@ static int tg3_setup_phy(struct tg3 *tp, int force_reset)
4266{ 4265{
4267 int err; 4266 int err;
4268 4267
4269 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) { 4268 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)
4270 err = tg3_setup_fiber_phy(tp, force_reset); 4269 err = tg3_setup_fiber_phy(tp, force_reset);
4271 } else if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) { 4270 else if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES)
4272 err = tg3_setup_fiber_mii_phy(tp, force_reset); 4271 err = tg3_setup_fiber_mii_phy(tp, force_reset);
4273 } else { 4272 else
4274 err = tg3_setup_copper_phy(tp, force_reset); 4273 err = tg3_setup_copper_phy(tp, force_reset);
4275 }
4276 4274
4277 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX) { 4275 if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX) {
4278 u32 val, scale; 4276 u32 val, scale;
@@ -4335,8 +4333,11 @@ static void tg3_tx_recover(struct tg3 *tp)
4335 BUG_ON((tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER) || 4333 BUG_ON((tp->tg3_flags & TG3_FLAG_MBOX_WRITE_REORDER) ||
4336 tp->write32_tx_mbox == tg3_write_indirect_mbox); 4334 tp->write32_tx_mbox == tg3_write_indirect_mbox);
4337 4335
4338 netdev_warn(tp->dev, "The system may be re-ordering memory-mapped I/O cycles to the network device, attempting to recover\n" 4336 netdev_warn(tp->dev,
4339 "Please report the problem to the driver maintainer and include system chipset information.\n"); 4337 "The system may be re-ordering memory-mapped I/O "
4338 "cycles to the network device, attempting to recover. "
4339 "Please report the problem to the driver maintainer "
4340 "and include system chipset information.\n");
4340 4341
4341 spin_lock(&tp->lock); 4342 spin_lock(&tp->lock);
4342 tp->tg3_flags |= TG3_FLAG_TX_RECOVERY_PENDING; 4343 tp->tg3_flags |= TG3_FLAG_TX_RECOVERY_PENDING;
@@ -4516,8 +4517,8 @@ static void tg3_recycle_rx(struct tg3_napi *tnapi,
4516 struct tg3 *tp = tnapi->tp; 4517 struct tg3 *tp = tnapi->tp;
4517 struct tg3_rx_buffer_desc *src_desc, *dest_desc; 4518 struct tg3_rx_buffer_desc *src_desc, *dest_desc;
4518 struct ring_info *src_map, *dest_map; 4519 struct ring_info *src_map, *dest_map;
4519 int dest_idx;
4520 struct tg3_rx_prodring_set *spr = &tp->prodring[0]; 4520 struct tg3_rx_prodring_set *spr = &tp->prodring[0];
4521 int dest_idx;
4521 4522
4522 switch (opaque_key) { 4523 switch (opaque_key) {
4523 case RXD_OPAQUE_RING_STD: 4524 case RXD_OPAQUE_RING_STD:
@@ -4978,7 +4979,7 @@ static int tg3_poll_msix(struct napi_struct *napi, int budget)
4978 if (unlikely(work_done >= budget)) 4979 if (unlikely(work_done >= budget))
4979 break; 4980 break;
4980 4981
4981 /* tp->last_tag is used in tg3_restart_ints() below 4982 /* tp->last_tag is used in tg3_int_reenable() below
4982 * to tell the hw how much work has been processed, 4983 * to tell the hw how much work has been processed,
4983 * so we must read it before checking for more work. 4984 * so we must read it before checking for more work.
4984 */ 4985 */
@@ -4987,8 +4988,8 @@ static int tg3_poll_msix(struct napi_struct *napi, int budget)
4987 rmb(); 4988 rmb();
4988 4989
4989 /* check for RX/TX work to do */ 4990 /* check for RX/TX work to do */
4990 if (sblk->idx[0].tx_consumer == tnapi->tx_cons && 4991 if (likely(sblk->idx[0].tx_consumer == tnapi->tx_cons &&
4991 *(tnapi->rx_rcb_prod_idx) == tnapi->rx_rcb_ptr) { 4992 *(tnapi->rx_rcb_prod_idx) == tnapi->rx_rcb_ptr)) {
4992 napi_complete(napi); 4993 napi_complete(napi);
4993 /* Reenable interrupts. */ 4994 /* Reenable interrupts. */
4994 tw32_mailbox(tnapi->int_mbox, tnapi->last_tag << 24); 4995 tw32_mailbox(tnapi->int_mbox, tnapi->last_tag << 24);
@@ -5260,7 +5261,8 @@ static int tg3_restart_hw(struct tg3 *tp, int reset_phy)
5260 5261
5261 err = tg3_init_hw(tp, reset_phy); 5262 err = tg3_init_hw(tp, reset_phy);
5262 if (err) { 5263 if (err) {
5263 netdev_err(tp->dev, "Failed to re-initialize device, aborting\n"); 5264 netdev_err(tp->dev,
5265 "Failed to re-initialize device, aborting\n");
5264 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 5266 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
5265 tg3_full_unlock(tp); 5267 tg3_full_unlock(tp);
5266 del_timer_sync(&tp->timer); 5268 del_timer_sync(&tp->timer);
@@ -5492,7 +5494,6 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb,
5492 struct netdev_queue *txq; 5494 struct netdev_queue *txq;
5493 unsigned int i, last; 5495 unsigned int i, last;
5494 5496
5495
5496 txq = netdev_get_tx_queue(dev, skb_get_queue_mapping(skb)); 5497 txq = netdev_get_tx_queue(dev, skb_get_queue_mapping(skb));
5497 tnapi = &tp->napi[skb_get_queue_mapping(skb)]; 5498 tnapi = &tp->napi[skb_get_queue_mapping(skb)];
5498 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_TSS) 5499 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_TSS)
@@ -5508,7 +5509,8 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb,
5508 netif_tx_stop_queue(txq); 5509 netif_tx_stop_queue(txq);
5509 5510
5510 /* This is a hard error, log it. */ 5511 /* This is a hard error, log it. */
5511 netdev_err(dev, "BUG! Tx Ring full when queue awake!\n"); 5512 netdev_err(dev,
5513 "BUG! Tx Ring full when queue awake!\n");
5512 } 5514 }
5513 return NETDEV_TX_BUSY; 5515 return NETDEV_TX_BUSY;
5514 } 5516 }
@@ -5552,9 +5554,10 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb,
5552 5554
5553 tcp_hdr(skb)->check = 0; 5555 tcp_hdr(skb)->check = 0;
5554 5556
5555 } 5557 } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
5556 else if (skb->ip_summed == CHECKSUM_PARTIAL)
5557 base_flags |= TXD_FLAG_TCPUDP_CSUM; 5558 base_flags |= TXD_FLAG_TCPUDP_CSUM;
5559 }
5560
5558#if TG3_VLAN_TAG_USED 5561#if TG3_VLAN_TAG_USED
5559 if (tp->vlgrp != NULL && vlan_tx_tag_present(skb)) 5562 if (tp->vlgrp != NULL && vlan_tx_tag_present(skb))
5560 base_flags |= (TXD_FLAG_VLAN | 5563 base_flags |= (TXD_FLAG_VLAN |
@@ -5695,7 +5698,6 @@ static netdev_tx_t tg3_start_xmit_dma_bug(struct sk_buff *skb,
5695 struct netdev_queue *txq; 5698 struct netdev_queue *txq;
5696 unsigned int i, last; 5699 unsigned int i, last;
5697 5700
5698
5699 txq = netdev_get_tx_queue(dev, skb_get_queue_mapping(skb)); 5701 txq = netdev_get_tx_queue(dev, skb_get_queue_mapping(skb));
5700 tnapi = &tp->napi[skb_get_queue_mapping(skb)]; 5702 tnapi = &tp->napi[skb_get_queue_mapping(skb)];
5701 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_TSS) 5703 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_TSS)
@@ -5711,7 +5713,8 @@ static netdev_tx_t tg3_start_xmit_dma_bug(struct sk_buff *skb,
5711 netif_tx_stop_queue(txq); 5713 netif_tx_stop_queue(txq);
5712 5714
5713 /* This is a hard error, log it. */ 5715 /* This is a hard error, log it. */
5714 netdev_err(dev, "BUG! Tx Ring full when queue awake!\n"); 5716 netdev_err(dev,
5717 "BUG! Tx Ring full when queue awake!\n");
5715 } 5718 }
5716 return NETDEV_TX_BUSY; 5719 return NETDEV_TX_BUSY;
5717 } 5720 }
@@ -5924,9 +5927,9 @@ static inline void tg3_set_mtu(struct net_device *dev, struct tg3 *tp,
5924 if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) { 5927 if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) {
5925 tp->tg3_flags2 &= ~TG3_FLG2_TSO_CAPABLE; 5928 tp->tg3_flags2 &= ~TG3_FLG2_TSO_CAPABLE;
5926 ethtool_op_set_tso(dev, 0); 5929 ethtool_op_set_tso(dev, 0);
5927 } 5930 } else {
5928 else
5929 tp->tg3_flags |= TG3_FLAG_JUMBO_RING_ENABLE; 5931 tp->tg3_flags |= TG3_FLAG_JUMBO_RING_ENABLE;
5932 }
5930 } else { 5933 } else {
5931 if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) 5934 if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)
5932 tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE; 5935 tp->tg3_flags2 |= TG3_FLG2_TSO_CAPABLE;
@@ -6007,7 +6010,7 @@ static void tg3_rx_prodring_free(struct tg3 *tp,
6007 } 6010 }
6008} 6011}
6009 6012
6010/* Initialize tx/rx rings for packet processing. 6013/* Initialize rx rings for packet processing.
6011 * 6014 *
6012 * The chip has been shut down and the driver detached from 6015 * The chip has been shut down and the driver detached from
6013 * the networking, so no interrupts or new tx packets will 6016 * the networking, so no interrupts or new tx packets will
@@ -6058,8 +6061,10 @@ static int tg3_rx_prodring_alloc(struct tg3 *tp,
6058 /* Now allocate fresh SKBs for each rx ring. */ 6061 /* Now allocate fresh SKBs for each rx ring. */
6059 for (i = 0; i < tp->rx_pending; i++) { 6062 for (i = 0; i < tp->rx_pending; i++) {
6060 if (tg3_alloc_rx_skb(tp, tpr, RXD_OPAQUE_RING_STD, i) < 0) { 6063 if (tg3_alloc_rx_skb(tp, tpr, RXD_OPAQUE_RING_STD, i) < 0) {
6061 netdev_warn(tp->dev, "Using a smaller RX standard ring, only %d out of %d buffers were allocated successfully\n", 6064 netdev_warn(tp->dev,
6062 i, tp->rx_pending); 6065 "Using a smaller RX standard ring. Only "
6066 "%d out of %d buffers were allocated "
6067 "successfully\n", i, tp->rx_pending);
6063 if (i == 0) 6068 if (i == 0)
6064 goto initfail; 6069 goto initfail;
6065 tp->rx_pending = i; 6070 tp->rx_pending = i;
@@ -6088,8 +6093,10 @@ static int tg3_rx_prodring_alloc(struct tg3 *tp,
6088 6093
6089 for (i = 0; i < tp->rx_jumbo_pending; i++) { 6094 for (i = 0; i < tp->rx_jumbo_pending; i++) {
6090 if (tg3_alloc_rx_skb(tp, tpr, RXD_OPAQUE_RING_JUMBO, i) < 0) { 6095 if (tg3_alloc_rx_skb(tp, tpr, RXD_OPAQUE_RING_JUMBO, i) < 0) {
6091 netdev_warn(tp->dev, "Using a smaller RX jumbo ring, only %d out of %d buffers were allocated successfully\n", 6096 netdev_warn(tp->dev,
6092 i, tp->rx_jumbo_pending); 6097 "Using a smaller RX jumbo ring. Only %d "
6098 "out of %d buffers were allocated "
6099 "successfully\n", i, tp->rx_jumbo_pending);
6093 if (i == 0) 6100 if (i == 0)
6094 goto initfail; 6101 goto initfail;
6095 tp->rx_jumbo_pending = i; 6102 tp->rx_jumbo_pending = i;
@@ -6433,8 +6440,9 @@ static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit, int
6433 } 6440 }
6434 6441
6435 if (i == MAX_WAIT_CNT && !silent) { 6442 if (i == MAX_WAIT_CNT && !silent) {
6436 pr_err("tg3_stop_block timed out, ofs=%lx enable_bit=%x\n", 6443 dev_err(&tp->pdev->dev,
6437 ofs, enable_bit); 6444 "tg3_stop_block timed out, ofs=%lx enable_bit=%x\n",
6445 ofs, enable_bit);
6438 return -ENODEV; 6446 return -ENODEV;
6439 } 6447 }
6440 6448
@@ -6480,8 +6488,9 @@ static int tg3_abort_hw(struct tg3 *tp, int silent)
6480 break; 6488 break;
6481 } 6489 }
6482 if (i >= MAX_WAIT_CNT) { 6490 if (i >= MAX_WAIT_CNT) {
6483 netdev_err(tp->dev, "%s timed out, TX_MODE_ENABLE will not clear MAC_TX_MODE=%08x\n", 6491 dev_err(&tp->pdev->dev,
6484 __func__, tr32(MAC_TX_MODE)); 6492 "%s timed out, TX_MODE_ENABLE will not clear "
6493 "MAC_TX_MODE=%08x\n", __func__, tr32(MAC_TX_MODE));
6485 err |= -ENODEV; 6494 err |= -ENODEV;
6486 } 6495 }
6487 6496
@@ -6551,35 +6560,35 @@ static void tg3_ape_driver_state_change(struct tg3 *tp, int kind)
6551 return; 6560 return;
6552 6561
6553 switch (kind) { 6562 switch (kind) {
6554 case RESET_KIND_INIT: 6563 case RESET_KIND_INIT:
6555 tg3_ape_write32(tp, TG3_APE_HOST_SEG_SIG, 6564 tg3_ape_write32(tp, TG3_APE_HOST_SEG_SIG,
6556 APE_HOST_SEG_SIG_MAGIC); 6565 APE_HOST_SEG_SIG_MAGIC);
6557 tg3_ape_write32(tp, TG3_APE_HOST_SEG_LEN, 6566 tg3_ape_write32(tp, TG3_APE_HOST_SEG_LEN,
6558 APE_HOST_SEG_LEN_MAGIC); 6567 APE_HOST_SEG_LEN_MAGIC);
6559 apedata = tg3_ape_read32(tp, TG3_APE_HOST_INIT_COUNT); 6568 apedata = tg3_ape_read32(tp, TG3_APE_HOST_INIT_COUNT);
6560 tg3_ape_write32(tp, TG3_APE_HOST_INIT_COUNT, ++apedata); 6569 tg3_ape_write32(tp, TG3_APE_HOST_INIT_COUNT, ++apedata);
6561 tg3_ape_write32(tp, TG3_APE_HOST_DRIVER_ID, 6570 tg3_ape_write32(tp, TG3_APE_HOST_DRIVER_ID,
6562 APE_HOST_DRIVER_ID_MAGIC); 6571 APE_HOST_DRIVER_ID_MAGIC);
6563 tg3_ape_write32(tp, TG3_APE_HOST_BEHAVIOR, 6572 tg3_ape_write32(tp, TG3_APE_HOST_BEHAVIOR,
6564 APE_HOST_BEHAV_NO_PHYLOCK); 6573 APE_HOST_BEHAV_NO_PHYLOCK);
6565 6574
6566 event = APE_EVENT_STATUS_STATE_START; 6575 event = APE_EVENT_STATUS_STATE_START;
6567 break; 6576 break;
6568 case RESET_KIND_SHUTDOWN: 6577 case RESET_KIND_SHUTDOWN:
6569 /* With the interface we are currently using, 6578 /* With the interface we are currently using,
6570 * APE does not track driver state. Wiping 6579 * APE does not track driver state. Wiping
6571 * out the HOST SEGMENT SIGNATURE forces 6580 * out the HOST SEGMENT SIGNATURE forces
6572 * the APE to assume OS absent status. 6581 * the APE to assume OS absent status.
6573 */ 6582 */
6574 tg3_ape_write32(tp, TG3_APE_HOST_SEG_SIG, 0x0); 6583 tg3_ape_write32(tp, TG3_APE_HOST_SEG_SIG, 0x0);
6575 6584
6576 event = APE_EVENT_STATUS_STATE_UNLOAD; 6585 event = APE_EVENT_STATUS_STATE_UNLOAD;
6577 break; 6586 break;
6578 case RESET_KIND_SUSPEND: 6587 case RESET_KIND_SUSPEND:
6579 event = APE_EVENT_STATUS_STATE_SUSPEND; 6588 event = APE_EVENT_STATUS_STATE_SUSPEND;
6580 break; 6589 break;
6581 default: 6590 default:
6582 return; 6591 return;
6583 } 6592 }
6584 6593
6585 event |= APE_EVENT_STATUS_DRIVER_EVNT | APE_EVENT_STATUS_STATE_CHNGE; 6594 event |= APE_EVENT_STATUS_DRIVER_EVNT | APE_EVENT_STATUS_STATE_CHNGE;
@@ -7156,7 +7165,8 @@ static int tg3_load_firmware_cpu(struct tg3 *tp, u32 cpu_base, u32 cpu_scratch_b
7156 7165
7157 if (cpu_base == TX_CPU_BASE && 7166 if (cpu_base == TX_CPU_BASE &&
7158 (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 7167 (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
7159 netdev_err(tp->dev, "%s: Trying to load TX cpu firmware which is 5705\n", 7168 netdev_err(tp->dev,
7169 "%s: Trying to load TX cpu firmware which is 5705\n",
7160 __func__); 7170 __func__);
7161 return -EINVAL; 7171 return -EINVAL;
7162 } 7172 }
@@ -7236,7 +7246,8 @@ static int tg3_load_5701_a0_firmware_fix(struct tg3 *tp)
7236 udelay(1000); 7246 udelay(1000);
7237 } 7247 }
7238 if (i >= 5) { 7248 if (i >= 5) {
7239 netdev_err(tp->dev, "tg3_load_firmware fails to set RX CPU PC, is %08x should be %08x\n", 7249 netdev_err(tp->dev, "%s fails to set RX CPU PC, is %08x "
7250 "should be %08x\n", __func__,
7240 tr32(RX_CPU_BASE + CPU_PC), info.fw_base); 7251 tr32(RX_CPU_BASE + CPU_PC), info.fw_base);
7241 return -ENODEV; 7252 return -ENODEV;
7242 } 7253 }
@@ -7300,7 +7311,8 @@ static int tg3_load_tso_firmware(struct tg3 *tp)
7300 udelay(1000); 7311 udelay(1000);
7301 } 7312 }
7302 if (i >= 5) { 7313 if (i >= 5) {
7303 netdev_err(tp->dev, "%s fails to set CPU PC, is %08x should be %08x\n", 7314 netdev_err(tp->dev,
7315 "%s fails to set CPU PC, is %08x should be %08x\n",
7304 __func__, tr32(cpu_base + CPU_PC), info.fw_base); 7316 __func__, tr32(cpu_base + CPU_PC), info.fw_base);
7305 return -ENODEV; 7317 return -ENODEV;
7306 } 7318 }
@@ -7568,9 +7580,8 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
7568 7580
7569 tg3_write_sig_pre_reset(tp, RESET_KIND_INIT); 7581 tg3_write_sig_pre_reset(tp, RESET_KIND_INIT);
7570 7582
7571 if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) { 7583 if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE)
7572 tg3_abort_hw(tp, 1); 7584 tg3_abort_hw(tp, 1);
7573 }
7574 7585
7575 if (reset_phy) 7586 if (reset_phy)
7576 tg3_phy_reset(tp); 7587 tg3_phy_reset(tp);
@@ -7723,8 +7734,7 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
7723 tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE96); 7734 tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE96);
7724 tw32(BUFMGR_DMA_DESC_POOL_ADDR, NIC_SRAM_DMA_DESC_POOL_BASE); 7735 tw32(BUFMGR_DMA_DESC_POOL_ADDR, NIC_SRAM_DMA_DESC_POOL_BASE);
7725 tw32(BUFMGR_DMA_DESC_POOL_SIZE, NIC_SRAM_DMA_DESC_POOL_SIZE); 7736 tw32(BUFMGR_DMA_DESC_POOL_SIZE, NIC_SRAM_DMA_DESC_POOL_SIZE);
7726 } 7737 } else if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
7727 else if (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE) {
7728 int fw_len; 7738 int fw_len;
7729 7739
7730 fw_len = tp->fw_len; 7740 fw_len = tp->fw_len;
@@ -8476,8 +8486,8 @@ static void tg3_timer(unsigned long __opaque)
8476 tg3_write_mem(tp, NIC_SRAM_FW_CMD_MBOX, 8486 tg3_write_mem(tp, NIC_SRAM_FW_CMD_MBOX,
8477 FWCMD_NICDRV_ALIVE3); 8487 FWCMD_NICDRV_ALIVE3);
8478 tg3_write_mem(tp, NIC_SRAM_FW_CMD_LEN_MBOX, 4); 8488 tg3_write_mem(tp, NIC_SRAM_FW_CMD_LEN_MBOX, 4);
8479 /* 5 seconds timeout */ 8489 tg3_write_mem(tp, NIC_SRAM_FW_CMD_DATA_MBOX,
8480 tg3_write_mem(tp, NIC_SRAM_FW_CMD_DATA_MBOX, 5); 8490 TG3_FW_UPDATE_TIMEOUT_SEC);
8481 8491
8482 tg3_generate_fw_event(tp); 8492 tg3_generate_fw_event(tp);
8483 } 8493 }
@@ -8625,8 +8635,9 @@ static int tg3_test_msi(struct tg3 *tp)
8625 return err; 8635 return err;
8626 8636
8627 /* MSI test failed, go back to INTx mode */ 8637 /* MSI test failed, go back to INTx mode */
8628 netdev_warn(tp->dev, "No interrupt was generated using MSI, switching to INTx mode\n" 8638 netdev_warn(tp->dev, "No interrupt was generated using MSI. Switching "
8629 "Please report this failure to the PCI maintainer and include system chipset information\n"); 8639 "to INTx mode. Please report this failure to the PCI "
8640 "maintainer and include system chipset information\n");
8630 8641
8631 free_irq(tp->napi[0].irq_vec, &tp->napi[0]); 8642 free_irq(tp->napi[0].irq_vec, &tp->napi[0]);
8632 8643
@@ -8738,7 +8749,8 @@ static void tg3_ints_init(struct tg3 *tp)
8738 /* All MSI supporting chips should support tagged 8749 /* All MSI supporting chips should support tagged
8739 * status. Assert that this is the case. 8750 * status. Assert that this is the case.
8740 */ 8751 */
8741 netdev_warn(tp->dev, "MSI without TAGGED? Not using MSI\n"); 8752 netdev_warn(tp->dev,
8753 "MSI without TAGGED_STATUS? Not using MSI\n");
8742 goto defcfg; 8754 goto defcfg;
8743 } 8755 }
8744 8756
@@ -8913,236 +8925,6 @@ err_out1:
8913 return err; 8925 return err;
8914} 8926}
8915 8927
8916#if 0
8917/*static*/ void tg3_dump_state(struct tg3 *tp)
8918{
8919 u32 val32, val32_2, val32_3, val32_4, val32_5;
8920 u16 val16;
8921 int i;
8922 struct tg3_hw_status *sblk = tp->napi[0]->hw_status;
8923
8924 pci_read_config_word(tp->pdev, PCI_STATUS, &val16);
8925 pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE, &val32);
8926 printk("DEBUG: PCI status [%04x] TG3PCI state[%08x]\n",
8927 val16, val32);
8928
8929 /* MAC block */
8930 printk("DEBUG: MAC_MODE[%08x] MAC_STATUS[%08x]\n",
8931 tr32(MAC_MODE), tr32(MAC_STATUS));
8932 printk(" MAC_EVENT[%08x] MAC_LED_CTRL[%08x]\n",
8933 tr32(MAC_EVENT), tr32(MAC_LED_CTRL));
8934 printk("DEBUG: MAC_TX_MODE[%08x] MAC_TX_STATUS[%08x]\n",
8935 tr32(MAC_TX_MODE), tr32(MAC_TX_STATUS));
8936 printk(" MAC_RX_MODE[%08x] MAC_RX_STATUS[%08x]\n",
8937 tr32(MAC_RX_MODE), tr32(MAC_RX_STATUS));
8938
8939 /* Send data initiator control block */
8940 printk("DEBUG: SNDDATAI_MODE[%08x] SNDDATAI_STATUS[%08x]\n",
8941 tr32(SNDDATAI_MODE), tr32(SNDDATAI_STATUS));
8942 printk(" SNDDATAI_STATSCTRL[%08x]\n",
8943 tr32(SNDDATAI_STATSCTRL));
8944
8945 /* Send data completion control block */
8946 printk("DEBUG: SNDDATAC_MODE[%08x]\n", tr32(SNDDATAC_MODE));
8947
8948 /* Send BD ring selector block */
8949 printk("DEBUG: SNDBDS_MODE[%08x] SNDBDS_STATUS[%08x]\n",
8950 tr32(SNDBDS_MODE), tr32(SNDBDS_STATUS));
8951
8952 /* Send BD initiator control block */
8953 printk("DEBUG: SNDBDI_MODE[%08x] SNDBDI_STATUS[%08x]\n",
8954 tr32(SNDBDI_MODE), tr32(SNDBDI_STATUS));
8955
8956 /* Send BD completion control block */
8957 printk("DEBUG: SNDBDC_MODE[%08x]\n", tr32(SNDBDC_MODE));
8958
8959 /* Receive list placement control block */
8960 printk("DEBUG: RCVLPC_MODE[%08x] RCVLPC_STATUS[%08x]\n",
8961 tr32(RCVLPC_MODE), tr32(RCVLPC_STATUS));
8962 printk(" RCVLPC_STATSCTRL[%08x]\n",
8963 tr32(RCVLPC_STATSCTRL));
8964
8965 /* Receive data and receive BD initiator control block */
8966 printk("DEBUG: RCVDBDI_MODE[%08x] RCVDBDI_STATUS[%08x]\n",
8967 tr32(RCVDBDI_MODE), tr32(RCVDBDI_STATUS));
8968
8969 /* Receive data completion control block */
8970 printk("DEBUG: RCVDCC_MODE[%08x]\n",
8971 tr32(RCVDCC_MODE));
8972
8973 /* Receive BD initiator control block */
8974 printk("DEBUG: RCVBDI_MODE[%08x] RCVBDI_STATUS[%08x]\n",
8975 tr32(RCVBDI_MODE), tr32(RCVBDI_STATUS));
8976
8977 /* Receive BD completion control block */
8978 printk("DEBUG: RCVCC_MODE[%08x] RCVCC_STATUS[%08x]\n",
8979 tr32(RCVCC_MODE), tr32(RCVCC_STATUS));
8980
8981 /* Receive list selector control block */
8982 printk("DEBUG: RCVLSC_MODE[%08x] RCVLSC_STATUS[%08x]\n",
8983 tr32(RCVLSC_MODE), tr32(RCVLSC_STATUS));
8984
8985 /* Mbuf cluster free block */
8986 printk("DEBUG: MBFREE_MODE[%08x] MBFREE_STATUS[%08x]\n",
8987 tr32(MBFREE_MODE), tr32(MBFREE_STATUS));
8988
8989 /* Host coalescing control block */
8990 printk("DEBUG: HOSTCC_MODE[%08x] HOSTCC_STATUS[%08x]\n",
8991 tr32(HOSTCC_MODE), tr32(HOSTCC_STATUS));
8992 printk("DEBUG: HOSTCC_STATS_BLK_HOST_ADDR[%08x%08x]\n",
8993 tr32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH),
8994 tr32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW));
8995 printk("DEBUG: HOSTCC_STATUS_BLK_HOST_ADDR[%08x%08x]\n",
8996 tr32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH),
8997 tr32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW));
8998 printk("DEBUG: HOSTCC_STATS_BLK_NIC_ADDR[%08x]\n",
8999 tr32(HOSTCC_STATS_BLK_NIC_ADDR));
9000 printk("DEBUG: HOSTCC_STATUS_BLK_NIC_ADDR[%08x]\n",
9001 tr32(HOSTCC_STATUS_BLK_NIC_ADDR));
9002
9003 /* Memory arbiter control block */
9004 printk("DEBUG: MEMARB_MODE[%08x] MEMARB_STATUS[%08x]\n",
9005 tr32(MEMARB_MODE), tr32(MEMARB_STATUS));
9006
9007 /* Buffer manager control block */
9008 printk("DEBUG: BUFMGR_MODE[%08x] BUFMGR_STATUS[%08x]\n",
9009 tr32(BUFMGR_MODE), tr32(BUFMGR_STATUS));
9010 printk("DEBUG: BUFMGR_MB_POOL_ADDR[%08x] BUFMGR_MB_POOL_SIZE[%08x]\n",
9011 tr32(BUFMGR_MB_POOL_ADDR), tr32(BUFMGR_MB_POOL_SIZE));
9012 printk("DEBUG: BUFMGR_DMA_DESC_POOL_ADDR[%08x] "
9013 "BUFMGR_DMA_DESC_POOL_SIZE[%08x]\n",
9014 tr32(BUFMGR_DMA_DESC_POOL_ADDR),
9015 tr32(BUFMGR_DMA_DESC_POOL_SIZE));
9016
9017 /* Read DMA control block */
9018 printk("DEBUG: RDMAC_MODE[%08x] RDMAC_STATUS[%08x]\n",
9019 tr32(RDMAC_MODE), tr32(RDMAC_STATUS));
9020
9021 /* Write DMA control block */
9022 printk("DEBUG: WDMAC_MODE[%08x] WDMAC_STATUS[%08x]\n",
9023 tr32(WDMAC_MODE), tr32(WDMAC_STATUS));
9024
9025 /* DMA completion block */
9026 printk("DEBUG: DMAC_MODE[%08x]\n",
9027 tr32(DMAC_MODE));
9028
9029 /* GRC block */
9030 printk("DEBUG: GRC_MODE[%08x] GRC_MISC_CFG[%08x]\n",
9031 tr32(GRC_MODE), tr32(GRC_MISC_CFG));
9032 printk("DEBUG: GRC_LOCAL_CTRL[%08x]\n",
9033 tr32(GRC_LOCAL_CTRL));
9034
9035 /* TG3_BDINFOs */
9036 printk("DEBUG: RCVDBDI_JUMBO_BD[%08x%08x:%08x:%08x]\n",
9037 tr32(RCVDBDI_JUMBO_BD + 0x0),
9038 tr32(RCVDBDI_JUMBO_BD + 0x4),
9039 tr32(RCVDBDI_JUMBO_BD + 0x8),
9040 tr32(RCVDBDI_JUMBO_BD + 0xc));
9041 printk("DEBUG: RCVDBDI_STD_BD[%08x%08x:%08x:%08x]\n",
9042 tr32(RCVDBDI_STD_BD + 0x0),
9043 tr32(RCVDBDI_STD_BD + 0x4),
9044 tr32(RCVDBDI_STD_BD + 0x8),
9045 tr32(RCVDBDI_STD_BD + 0xc));
9046 printk("DEBUG: RCVDBDI_MINI_BD[%08x%08x:%08x:%08x]\n",
9047 tr32(RCVDBDI_MINI_BD + 0x0),
9048 tr32(RCVDBDI_MINI_BD + 0x4),
9049 tr32(RCVDBDI_MINI_BD + 0x8),
9050 tr32(RCVDBDI_MINI_BD + 0xc));
9051
9052 tg3_read_mem(tp, NIC_SRAM_SEND_RCB + 0x0, &val32);
9053 tg3_read_mem(tp, NIC_SRAM_SEND_RCB + 0x4, &val32_2);
9054 tg3_read_mem(tp, NIC_SRAM_SEND_RCB + 0x8, &val32_3);
9055 tg3_read_mem(tp, NIC_SRAM_SEND_RCB + 0xc, &val32_4);
9056 printk("DEBUG: SRAM_SEND_RCB_0[%08x%08x:%08x:%08x]\n",
9057 val32, val32_2, val32_3, val32_4);
9058
9059 tg3_read_mem(tp, NIC_SRAM_RCV_RET_RCB + 0x0, &val32);
9060 tg3_read_mem(tp, NIC_SRAM_RCV_RET_RCB + 0x4, &val32_2);
9061 tg3_read_mem(tp, NIC_SRAM_RCV_RET_RCB + 0x8, &val32_3);
9062 tg3_read_mem(tp, NIC_SRAM_RCV_RET_RCB + 0xc, &val32_4);
9063 printk("DEBUG: SRAM_RCV_RET_RCB_0[%08x%08x:%08x:%08x]\n",
9064 val32, val32_2, val32_3, val32_4);
9065
9066 tg3_read_mem(tp, NIC_SRAM_STATUS_BLK + 0x0, &val32);
9067 tg3_read_mem(tp, NIC_SRAM_STATUS_BLK + 0x4, &val32_2);
9068 tg3_read_mem(tp, NIC_SRAM_STATUS_BLK + 0x8, &val32_3);
9069 tg3_read_mem(tp, NIC_SRAM_STATUS_BLK + 0xc, &val32_4);
9070 tg3_read_mem(tp, NIC_SRAM_STATUS_BLK + 0x10, &val32_5);
9071 printk("DEBUG: SRAM_STATUS_BLK[%08x:%08x:%08x:%08x:%08x]\n",
9072 val32, val32_2, val32_3, val32_4, val32_5);
9073
9074 /* SW status block */
9075 printk(KERN_DEBUG
9076 "Host status block [%08x:%08x:(%04x:%04x:%04x):(%04x:%04x)]\n",
9077 sblk->status,
9078 sblk->status_tag,
9079 sblk->rx_jumbo_consumer,
9080 sblk->rx_consumer,
9081 sblk->rx_mini_consumer,
9082 sblk->idx[0].rx_producer,
9083 sblk->idx[0].tx_consumer);
9084
9085 /* SW statistics block */
9086 printk("DEBUG: Host statistics block [%08x:%08x:%08x:%08x]\n",
9087 ((u32 *)tp->hw_stats)[0],
9088 ((u32 *)tp->hw_stats)[1],
9089 ((u32 *)tp->hw_stats)[2],
9090 ((u32 *)tp->hw_stats)[3]);
9091
9092 /* Mailboxes */
9093 printk("DEBUG: SNDHOST_PROD[%08x%08x] SNDNIC_PROD[%08x%08x]\n",
9094 tr32_mailbox(MAILBOX_SNDHOST_PROD_IDX_0 + 0x0),
9095 tr32_mailbox(MAILBOX_SNDHOST_PROD_IDX_0 + 0x4),
9096 tr32_mailbox(MAILBOX_SNDNIC_PROD_IDX_0 + 0x0),
9097 tr32_mailbox(MAILBOX_SNDNIC_PROD_IDX_0 + 0x4));
9098
9099 /* NIC side send descriptors. */
9100 for (i = 0; i < 6; i++) {
9101 unsigned long txd;
9102
9103 txd = tp->regs + NIC_SRAM_WIN_BASE + NIC_SRAM_TX_BUFFER_DESC
9104 + (i * sizeof(struct tg3_tx_buffer_desc));
9105 printk("DEBUG: NIC TXD(%d)[%08x:%08x:%08x:%08x]\n",
9106 i,
9107 readl(txd + 0x0), readl(txd + 0x4),
9108 readl(txd + 0x8), readl(txd + 0xc));
9109 }
9110
9111 /* NIC side RX descriptors. */
9112 for (i = 0; i < 6; i++) {
9113 unsigned long rxd;
9114
9115 rxd = tp->regs + NIC_SRAM_WIN_BASE + NIC_SRAM_RX_BUFFER_DESC
9116 + (i * sizeof(struct tg3_rx_buffer_desc));
9117 printk("DEBUG: NIC RXD_STD(%d)[0][%08x:%08x:%08x:%08x]\n",
9118 i,
9119 readl(rxd + 0x0), readl(rxd + 0x4),
9120 readl(rxd + 0x8), readl(rxd + 0xc));
9121 rxd += (4 * sizeof(u32));
9122 printk("DEBUG: NIC RXD_STD(%d)[1][%08x:%08x:%08x:%08x]\n",
9123 i,
9124 readl(rxd + 0x0), readl(rxd + 0x4),
9125 readl(rxd + 0x8), readl(rxd + 0xc));
9126 }
9127
9128 for (i = 0; i < 6; i++) {
9129 unsigned long rxd;
9130
9131 rxd = tp->regs + NIC_SRAM_WIN_BASE + NIC_SRAM_RX_JUMBO_BUFFER_DESC
9132 + (i * sizeof(struct tg3_rx_buffer_desc));
9133 printk("DEBUG: NIC RXD_JUMBO(%d)[0][%08x:%08x:%08x:%08x]\n",
9134 i,
9135 readl(rxd + 0x0), readl(rxd + 0x4),
9136 readl(rxd + 0x8), readl(rxd + 0xc));
9137 rxd += (4 * sizeof(u32));
9138 printk("DEBUG: NIC RXD_JUMBO(%d)[1][%08x:%08x:%08x:%08x]\n",
9139 i,
9140 readl(rxd + 0x0), readl(rxd + 0x4),
9141 readl(rxd + 0x8), readl(rxd + 0xc));
9142 }
9143}
9144#endif
9145
9146static struct net_device_stats *tg3_get_stats(struct net_device *); 8928static struct net_device_stats *tg3_get_stats(struct net_device *);
9147static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *); 8929static struct tg3_ethtool_stats *tg3_get_estats(struct tg3 *);
9148 8930
@@ -9161,9 +8943,6 @@ static int tg3_close(struct net_device *dev)
9161 tg3_phy_stop(tp); 8943 tg3_phy_stop(tp);
9162 8944
9163 tg3_full_lock(tp, 1); 8945 tg3_full_lock(tp, 1);
9164#if 0
9165 tg3_dump_state(tp);
9166#endif
9167 8946
9168 tg3_disable_ints(tp); 8947 tg3_disable_ints(tp);
9169 8948
@@ -9405,9 +9184,8 @@ static inline u32 calc_crc(unsigned char *buf, int len)
9405 9184
9406 reg >>= 1; 9185 reg >>= 1;
9407 9186
9408 if (tmp) { 9187 if (tmp)
9409 reg ^= 0xedb88320; 9188 reg ^= 0xedb88320;
9410 }
9411 } 9189 }
9412 } 9190 }
9413 9191
@@ -9457,14 +9235,14 @@ static void __tg3_set_rx_mode(struct net_device *dev)
9457 tg3_set_multi (tp, 0); 9235 tg3_set_multi (tp, 0);
9458 } else { 9236 } else {
9459 /* Accept one or more multicast(s). */ 9237 /* Accept one or more multicast(s). */
9460 struct dev_mc_list *mclist; 9238 struct netdev_hw_addr *ha;
9461 u32 mc_filter[4] = { 0, }; 9239 u32 mc_filter[4] = { 0, };
9462 u32 regidx; 9240 u32 regidx;
9463 u32 bit; 9241 u32 bit;
9464 u32 crc; 9242 u32 crc;
9465 9243
9466 netdev_for_each_mc_addr(mclist, dev) { 9244 netdev_for_each_mc_addr(ha, dev) {
9467 crc = calc_crc (mclist->dmi_addr, ETH_ALEN); 9245 crc = calc_crc(ha->addr, ETH_ALEN);
9468 bit = ~crc & 0x7f; 9246 bit = ~crc & 0x7f;
9469 regidx = (bit & 0x60) >> 5; 9247 regidx = (bit & 0x60) >> 5;
9470 bit &= 0x1f; 9248 bit &= 0x1f;
@@ -9617,7 +9395,7 @@ static int tg3_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
9617 memcpy(data, ((char*)&val) + b_offset, b_count); 9395 memcpy(data, ((char*)&val) + b_offset, b_count);
9618 len -= b_count; 9396 len -= b_count;
9619 offset += b_count; 9397 offset += b_count;
9620 eeprom->len += b_count; 9398 eeprom->len += b_count;
9621 } 9399 }
9622 9400
9623 /* read bytes upto the last 4 byte boundary */ 9401 /* read bytes upto the last 4 byte boundary */
@@ -10165,8 +9943,8 @@ static int tg3_set_rx_csum(struct net_device *dev, u32 data)
10165 if (tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) { 9943 if (tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) {
10166 if (data != 0) 9944 if (data != 0)
10167 return -EINVAL; 9945 return -EINVAL;
10168 return 0; 9946 return 0;
10169 } 9947 }
10170 9948
10171 spin_lock_bh(&tp->lock); 9949 spin_lock_bh(&tp->lock);
10172 if (data) 9950 if (data)
@@ -10185,8 +9963,8 @@ static int tg3_set_tx_csum(struct net_device *dev, u32 data)
10185 if (tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) { 9963 if (tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) {
10186 if (data != 0) 9964 if (data != 0)
10187 return -EINVAL; 9965 return -EINVAL;
10188 return 0; 9966 return 0;
10189 } 9967 }
10190 9968
10191 if (tp->tg3_flags3 & TG3_FLG3_5755_PLUS) 9969 if (tp->tg3_flags3 & TG3_FLG3_5755_PLUS)
10192 ethtool_op_set_tx_ipv6_csum(dev, data); 9970 ethtool_op_set_tx_ipv6_csum(dev, data);
@@ -10361,8 +10139,7 @@ static int tg3_test_nvram(struct tg3 *tp)
10361 for (l = 0, msk = 0x80; l < 7; l++, msk >>= 1) 10139 for (l = 0, msk = 0x80; l < 7; l++, msk >>= 1)
10362 parity[k++] = buf8[i] & msk; 10140 parity[k++] = buf8[i] & msk;
10363 i++; 10141 i++;
10364 } 10142 } else if (i == 16) {
10365 else if (i == 16) {
10366 int l; 10143 int l;
10367 u8 msk; 10144 u8 msk;
10368 10145
@@ -10460,7 +10237,7 @@ static int tg3_test_registers(struct tg3 *tp)
10460 { MAC_ADDR_0_HIGH, 0x0000, 10237 { MAC_ADDR_0_HIGH, 0x0000,
10461 0x00000000, 0x0000ffff }, 10238 0x00000000, 0x0000ffff },
10462 { MAC_ADDR_0_LOW, 0x0000, 10239 { MAC_ADDR_0_LOW, 0x0000,
10463 0x00000000, 0xffffffff }, 10240 0x00000000, 0xffffffff },
10464 { MAC_RX_MTU_SIZE, 0x0000, 10241 { MAC_RX_MTU_SIZE, 0x0000,
10465 0x00000000, 0x0000ffff }, 10242 0x00000000, 0x0000ffff },
10466 { MAC_TX_MODE, 0x0000, 10243 { MAC_TX_MODE, 0x0000,
@@ -10648,7 +10425,8 @@ static int tg3_test_registers(struct tg3 *tp)
10648 10425
10649out: 10426out:
10650 if (netif_msg_hw(tp)) 10427 if (netif_msg_hw(tp))
10651 pr_err("Register test failed at offset %x\n", offset); 10428 netdev_err(tp->dev,
10429 "Register test failed at offset %x\n", offset);
10652 tw32(offset, save_val); 10430 tw32(offset, save_val);
10653 return -EIO; 10431 return -EIO;
10654} 10432}
@@ -10824,9 +10602,9 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
10824 MII_TG3_EXT_CTRL_LNK3_LED_MODE); 10602 MII_TG3_EXT_CTRL_LNK3_LED_MODE);
10825 } 10603 }
10826 tw32(MAC_MODE, mac_mode); 10604 tw32(MAC_MODE, mac_mode);
10827 } 10605 } else {
10828 else
10829 return -EINVAL; 10606 return -EINVAL;
10607 }
10830 10608
10831 err = -EIO; 10609 err = -EIO;
10832 10610
@@ -11082,7 +10860,7 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
11082 return phy_mii_ioctl(phydev, data, cmd); 10860 return phy_mii_ioctl(phydev, data, cmd);
11083 } 10861 }
11084 10862
11085 switch(cmd) { 10863 switch (cmd) {
11086 case SIOCGMIIPHY: 10864 case SIOCGMIIPHY:
11087 data->phy_id = tp->phy_addr; 10865 data->phy_id = tp->phy_addr;
11088 10866
@@ -11775,7 +11553,8 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
11775 tp->tg3_flags |= TG3_FLAG_NVRAM; 11553 tp->tg3_flags |= TG3_FLAG_NVRAM;
11776 11554
11777 if (tg3_nvram_lock(tp)) { 11555 if (tg3_nvram_lock(tp)) {
11778 netdev_warn(tp->dev, "Cannot get nvram lock, %s failed\n", 11556 netdev_warn(tp->dev,
11557 "Cannot get nvram lock, %s failed\n",
11779 __func__); 11558 __func__);
11780 return; 11559 return;
11781 } 11560 }
@@ -11894,7 +11673,7 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
11894 if (ret) 11673 if (ret)
11895 break; 11674 break;
11896 11675
11897 page_off = offset & pagemask; 11676 page_off = offset & pagemask;
11898 size = pagesize; 11677 size = pagesize;
11899 if (len < size) 11678 if (len < size)
11900 size = len; 11679 size = len;
@@ -11922,7 +11701,7 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
11922 nvram_cmd = NVRAM_CMD_GO | NVRAM_CMD_DONE | NVRAM_CMD_WR | 11701 nvram_cmd = NVRAM_CMD_GO | NVRAM_CMD_DONE | NVRAM_CMD_WR |
11923 NVRAM_CMD_FIRST | NVRAM_CMD_LAST | NVRAM_CMD_ERASE; 11702 NVRAM_CMD_FIRST | NVRAM_CMD_LAST | NVRAM_CMD_ERASE;
11924 11703
11925 if (tg3_nvram_exec_cmd(tp, nvram_cmd)) 11704 if (tg3_nvram_exec_cmd(tp, nvram_cmd))
11926 break; 11705 break;
11927 11706
11928 /* Issue another write enable to start the write. */ 11707 /* Issue another write enable to start the write. */
@@ -11976,7 +11755,7 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len,
11976 memcpy(&data, buf + i, 4); 11755 memcpy(&data, buf + i, 4);
11977 tw32(NVRAM_WRDATA, be32_to_cpu(data)); 11756 tw32(NVRAM_WRDATA, be32_to_cpu(data));
11978 11757
11979 page_off = offset % tp->nvram_pagesize; 11758 page_off = offset % tp->nvram_pagesize;
11980 11759
11981 phy_addr = tg3_nvram_phys_addr(tp, offset); 11760 phy_addr = tg3_nvram_phys_addr(tp, offset);
11982 11761
@@ -11984,7 +11763,7 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len,
11984 11763
11985 nvram_cmd = NVRAM_CMD_GO | NVRAM_CMD_DONE | NVRAM_CMD_WR; 11764 nvram_cmd = NVRAM_CMD_GO | NVRAM_CMD_DONE | NVRAM_CMD_WR;
11986 11765
11987 if ((page_off == 0) || (i == 0)) 11766 if (page_off == 0 || i == 0)
11988 nvram_cmd |= NVRAM_CMD_FIRST; 11767 nvram_cmd |= NVRAM_CMD_FIRST;
11989 if (page_off == (tp->nvram_pagesize - 4)) 11768 if (page_off == (tp->nvram_pagesize - 4))
11990 nvram_cmd |= NVRAM_CMD_LAST; 11769 nvram_cmd |= NVRAM_CMD_LAST;
@@ -12027,8 +11806,7 @@ static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf)
12027 11806
12028 if (!(tp->tg3_flags & TG3_FLAG_NVRAM)) { 11807 if (!(tp->tg3_flags & TG3_FLAG_NVRAM)) {
12029 ret = tg3_nvram_write_block_using_eeprom(tp, offset, len, buf); 11808 ret = tg3_nvram_write_block_using_eeprom(tp, offset, len, buf);
12030 } 11809 } else {
12031 else {
12032 u32 grc_mode; 11810 u32 grc_mode;
12033 11811
12034 ret = tg3_nvram_lock(tp); 11812 ret = tg3_nvram_lock(tp);
@@ -12048,8 +11826,7 @@ static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf)
12048 11826
12049 ret = tg3_nvram_write_block_buffered(tp, offset, len, 11827 ret = tg3_nvram_write_block_buffered(tp, offset, len,
12050 buf); 11828 buf);
12051 } 11829 } else {
12052 else {
12053 ret = tg3_nvram_write_block_unbuffered(tp, offset, len, 11830 ret = tg3_nvram_write_block_unbuffered(tp, offset, len,
12054 buf); 11831 buf);
12055 } 11832 }
@@ -12544,11 +12321,11 @@ skip_phy_reset:
12544 return err; 12321 return err;
12545} 12322}
12546 12323
12547static void __devinit tg3_read_partno(struct tg3 *tp) 12324static void __devinit tg3_read_vpd(struct tg3 *tp)
12548{ 12325{
12549 unsigned char vpd_data[TG3_NVM_VPD_LEN]; /* in little-endian format */ 12326 u8 vpd_data[TG3_NVM_VPD_LEN];
12550 unsigned int block_end, rosize, len; 12327 unsigned int block_end, rosize, len;
12551 int i = 0; 12328 int j, i = 0;
12552 u32 magic; 12329 u32 magic;
12553 12330
12554 if ((tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) || 12331 if ((tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) ||
@@ -12597,6 +12374,32 @@ static void __devinit tg3_read_partno(struct tg3 *tp)
12597 if (block_end > TG3_NVM_VPD_LEN) 12374 if (block_end > TG3_NVM_VPD_LEN)
12598 goto out_not_found; 12375 goto out_not_found;
12599 12376
12377 j = pci_vpd_find_info_keyword(vpd_data, i, rosize,
12378 PCI_VPD_RO_KEYWORD_MFR_ID);
12379 if (j > 0) {
12380 len = pci_vpd_info_field_size(&vpd_data[j]);
12381
12382 j += PCI_VPD_INFO_FLD_HDR_SIZE;
12383 if (j + len > block_end || len != 4 ||
12384 memcmp(&vpd_data[j], "1028", 4))
12385 goto partno;
12386
12387 j = pci_vpd_find_info_keyword(vpd_data, i, rosize,
12388 PCI_VPD_RO_KEYWORD_VENDOR0);
12389 if (j < 0)
12390 goto partno;
12391
12392 len = pci_vpd_info_field_size(&vpd_data[j]);
12393
12394 j += PCI_VPD_INFO_FLD_HDR_SIZE;
12395 if (j + len > block_end)
12396 goto partno;
12397
12398 memcpy(tp->fw_ver, &vpd_data[j], len);
12399 strncat(tp->fw_ver, " bc ", TG3_NVM_VPD_LEN - len - 1);
12400 }
12401
12402partno:
12600 i = pci_vpd_find_info_keyword(vpd_data, i, rosize, 12403 i = pci_vpd_find_info_keyword(vpd_data, i, rosize,
12601 PCI_VPD_RO_KEYWORD_PARTNO); 12404 PCI_VPD_RO_KEYWORD_PARTNO);
12602 if (i < 0) 12405 if (i < 0)
@@ -12666,7 +12469,7 @@ static int __devinit tg3_fw_img_is_valid(struct tg3 *tp, u32 offset)
12666static void __devinit tg3_read_bc_ver(struct tg3 *tp) 12469static void __devinit tg3_read_bc_ver(struct tg3 *tp)
12667{ 12470{
12668 u32 val, offset, start, ver_offset; 12471 u32 val, offset, start, ver_offset;
12669 int i; 12472 int i, dst_off;
12670 bool newver = false; 12473 bool newver = false;
12671 12474
12672 if (tg3_nvram_read(tp, 0xc, &offset) || 12475 if (tg3_nvram_read(tp, 0xc, &offset) ||
@@ -12686,8 +12489,11 @@ static void __devinit tg3_read_bc_ver(struct tg3 *tp)
12686 newver = true; 12489 newver = true;
12687 } 12490 }
12688 12491
12492 dst_off = strlen(tp->fw_ver);
12493
12689 if (newver) { 12494 if (newver) {
12690 if (tg3_nvram_read(tp, offset + 8, &ver_offset)) 12495 if (TG3_VER_SIZE - dst_off < 16 ||
12496 tg3_nvram_read(tp, offset + 8, &ver_offset))
12691 return; 12497 return;
12692 12498
12693 offset = offset + ver_offset - start; 12499 offset = offset + ver_offset - start;
@@ -12696,7 +12502,7 @@ static void __devinit tg3_read_bc_ver(struct tg3 *tp)
12696 if (tg3_nvram_read_be32(tp, offset + i, &v)) 12502 if (tg3_nvram_read_be32(tp, offset + i, &v))
12697 return; 12503 return;
12698 12504
12699 memcpy(tp->fw_ver + i, &v, sizeof(v)); 12505 memcpy(tp->fw_ver + dst_off + i, &v, sizeof(v));
12700 } 12506 }
12701 } else { 12507 } else {
12702 u32 major, minor; 12508 u32 major, minor;
@@ -12707,7 +12513,8 @@ static void __devinit tg3_read_bc_ver(struct tg3 *tp)
12707 major = (ver_offset & TG3_NVM_BCVER_MAJMSK) >> 12513 major = (ver_offset & TG3_NVM_BCVER_MAJMSK) >>
12708 TG3_NVM_BCVER_MAJSFT; 12514 TG3_NVM_BCVER_MAJSFT;
12709 minor = ver_offset & TG3_NVM_BCVER_MINMSK; 12515 minor = ver_offset & TG3_NVM_BCVER_MINMSK;
12710 snprintf(&tp->fw_ver[0], 32, "v%d.%02d", major, minor); 12516 snprintf(&tp->fw_ver[dst_off], TG3_VER_SIZE - dst_off,
12517 "v%d.%02d", major, minor);
12711 } 12518 }
12712} 12519}
12713 12520
@@ -12731,9 +12538,7 @@ static void __devinit tg3_read_sb_ver(struct tg3 *tp, u32 val)
12731{ 12538{
12732 u32 offset, major, minor, build; 12539 u32 offset, major, minor, build;
12733 12540
12734 tp->fw_ver[0] = 's'; 12541 strncat(tp->fw_ver, "sb", TG3_VER_SIZE - strlen(tp->fw_ver) - 1);
12735 tp->fw_ver[1] = 'b';
12736 tp->fw_ver[2] = '\0';
12737 12542
12738 if ((val & TG3_EEPROM_SB_FORMAT_MASK) != TG3_EEPROM_SB_FORMAT_1) 12543 if ((val & TG3_EEPROM_SB_FORMAT_MASK) != TG3_EEPROM_SB_FORMAT_1)
12739 return; 12544 return;
@@ -12770,11 +12575,14 @@ static void __devinit tg3_read_sb_ver(struct tg3 *tp, u32 val)
12770 if (minor > 99 || build > 26) 12575 if (minor > 99 || build > 26)
12771 return; 12576 return;
12772 12577
12773 snprintf(&tp->fw_ver[2], 30, " v%d.%02d", major, minor); 12578 offset = strlen(tp->fw_ver);
12579 snprintf(&tp->fw_ver[offset], TG3_VER_SIZE - offset,
12580 " v%d.%02d", major, minor);
12774 12581
12775 if (build > 0) { 12582 if (build > 0) {
12776 tp->fw_ver[8] = 'a' + build - 1; 12583 offset = strlen(tp->fw_ver);
12777 tp->fw_ver[9] = '\0'; 12584 if (offset < TG3_VER_SIZE - 1)
12585 tp->fw_ver[offset] = 'a' + build - 1;
12778 } 12586 }
12779} 12587}
12780 12588
@@ -12861,12 +12669,13 @@ static void __devinit tg3_read_dash_ver(struct tg3 *tp)
12861static void __devinit tg3_read_fw_ver(struct tg3 *tp) 12669static void __devinit tg3_read_fw_ver(struct tg3 *tp)
12862{ 12670{
12863 u32 val; 12671 u32 val;
12672 bool vpd_vers = false;
12864 12673
12865 if (tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) { 12674 if (tp->fw_ver[0] != 0)
12866 tp->fw_ver[0] = 's'; 12675 vpd_vers = true;
12867 tp->fw_ver[1] = 'b';
12868 tp->fw_ver[2] = '\0';
12869 12676
12677 if (tp->tg3_flags3 & TG3_FLG3_NO_NVRAM) {
12678 strcat(tp->fw_ver, "sb");
12870 return; 12679 return;
12871 } 12680 }
12872 12681
@@ -12883,11 +12692,12 @@ static void __devinit tg3_read_fw_ver(struct tg3 *tp)
12883 return; 12692 return;
12884 12693
12885 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF) || 12694 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF) ||
12886 (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE)) 12695 (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) || vpd_vers)
12887 return; 12696 goto done;
12888 12697
12889 tg3_read_mgmtfw_ver(tp); 12698 tg3_read_mgmtfw_ver(tp);
12890 12699
12700done:
12891 tp->fw_ver[TG3_VER_SIZE - 1] = 0; 12701 tp->fw_ver[TG3_VER_SIZE - 1] = 0;
12892} 12702}
12893 12703
@@ -12897,9 +12707,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
12897{ 12707{
12898 static struct pci_device_id write_reorder_chipsets[] = { 12708 static struct pci_device_id write_reorder_chipsets[] = {
12899 { PCI_DEVICE(PCI_VENDOR_ID_AMD, 12709 { PCI_DEVICE(PCI_VENDOR_ID_AMD,
12900 PCI_DEVICE_ID_AMD_FE_GATE_700C) }, 12710 PCI_DEVICE_ID_AMD_FE_GATE_700C) },
12901 { PCI_DEVICE(PCI_VENDOR_ID_AMD, 12711 { PCI_DEVICE(PCI_VENDOR_ID_AMD,
12902 PCI_DEVICE_ID_AMD_8131_BRIDGE) }, 12712 PCI_DEVICE_ID_AMD_8131_BRIDGE) },
12903 { PCI_DEVICE(PCI_VENDOR_ID_VIA, 12713 { PCI_DEVICE(PCI_VENDOR_ID_VIA,
12904 PCI_DEVICE_ID_VIA_8385_0) }, 12714 PCI_DEVICE_ID_VIA_8385_0) },
12905 { }, 12715 { },
@@ -13065,8 +12875,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13065 tp->tg3_flags2 |= TG3_FLG2_5780_CLASS; 12875 tp->tg3_flags2 |= TG3_FLG2_5780_CLASS;
13066 tp->tg3_flags |= TG3_FLAG_40BIT_DMA_BUG; 12876 tp->tg3_flags |= TG3_FLAG_40BIT_DMA_BUG;
13067 tp->msi_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_MSI); 12877 tp->msi_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_MSI);
13068 } 12878 } else {
13069 else {
13070 struct pci_dev *bridge = NULL; 12879 struct pci_dev *bridge = NULL;
13071 12880
13072 do { 12881 do {
@@ -13188,8 +12997,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13188 tp->tg3_flags3 |= TG3_FLG3_USE_JUMBO_BDFLAG; 12997 tp->tg3_flags3 |= TG3_FLG3_USE_JUMBO_BDFLAG;
13189 12998
13190 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS) || 12999 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS) ||
13191 (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) || 13000 (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) ||
13192 (tp->tg3_flags3 & TG3_FLG3_USE_JUMBO_BDFLAG)) 13001 (tp->tg3_flags3 & TG3_FLG3_USE_JUMBO_BDFLAG))
13193 tp->tg3_flags |= TG3_FLAG_JUMBO_CAPABLE; 13002 tp->tg3_flags |= TG3_FLAG_JUMBO_CAPABLE;
13194 13003
13195 pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE, 13004 pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE,
@@ -13223,7 +13032,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13223 (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) { 13032 (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) {
13224 tp->pcix_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_PCIX); 13033 tp->pcix_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_PCIX);
13225 if (!tp->pcix_cap) { 13034 if (!tp->pcix_cap) {
13226 pr_err("Cannot find PCI-X capability, aborting\n"); 13035 dev_err(&tp->pdev->dev,
13036 "Cannot find PCI-X capability, aborting\n");
13227 return -EIO; 13037 return -EIO;
13228 } 13038 }
13229 13039
@@ -13420,7 +13230,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13420 /* Force the chip into D0. */ 13230 /* Force the chip into D0. */
13421 err = tg3_set_power_state(tp, PCI_D0); 13231 err = tg3_set_power_state(tp, PCI_D0);
13422 if (err) { 13232 if (err) {
13423 pr_err("(%s) transition to D0 failed\n", pci_name(tp->pdev)); 13233 dev_err(&tp->pdev->dev, "Transition to D0 failed\n");
13424 return err; 13234 return err;
13425 } 13235 }
13426 13236
@@ -13594,13 +13404,12 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13594 13404
13595 err = tg3_phy_probe(tp); 13405 err = tg3_phy_probe(tp);
13596 if (err) { 13406 if (err) {
13597 pr_err("(%s) phy probe failed, err %d\n", 13407 dev_err(&tp->pdev->dev, "phy probe failed, err %d\n", err);
13598 pci_name(tp->pdev), err);
13599 /* ... but do not return immediately ... */ 13408 /* ... but do not return immediately ... */
13600 tg3_mdio_fini(tp); 13409 tg3_mdio_fini(tp);
13601 } 13410 }
13602 13411
13603 tg3_read_partno(tp); 13412 tg3_read_vpd(tp);
13604 tg3_read_fw_ver(tp); 13413 tg3_read_fw_ver(tp);
13605 13414
13606 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) { 13415 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) {
@@ -13964,11 +13773,10 @@ static int __devinit tg3_do_test_dma(struct tg3 *tp, u32 *buf, dma_addr_t buf_dm
13964 } 13773 }
13965 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0); 13774 pci_write_config_dword(tp->pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0);
13966 13775
13967 if (to_device) { 13776 if (to_device)
13968 tw32(FTQ_DMA_HIGH_READ_FIFO_ENQDEQ, sram_dma_descs); 13777 tw32(FTQ_DMA_HIGH_READ_FIFO_ENQDEQ, sram_dma_descs);
13969 } else { 13778 else
13970 tw32(FTQ_DMA_HIGH_WRITE_FIFO_ENQDEQ, sram_dma_descs); 13779 tw32(FTQ_DMA_HIGH_WRITE_FIFO_ENQDEQ, sram_dma_descs);
13971 }
13972 13780
13973 ret = -ENODEV; 13781 ret = -ENODEV;
13974 for (i = 0; i < 40; i++) { 13782 for (i = 0; i < 40; i++) {
@@ -14104,8 +13912,9 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
14104 /* Send the buffer to the chip. */ 13912 /* Send the buffer to the chip. */
14105 ret = tg3_do_test_dma(tp, buf, buf_dma, TEST_BUFFER_SIZE, 1); 13913 ret = tg3_do_test_dma(tp, buf, buf_dma, TEST_BUFFER_SIZE, 1);
14106 if (ret) { 13914 if (ret) {
14107 pr_err("tg3_test_dma() Write the buffer failed %d\n", 13915 dev_err(&tp->pdev->dev,
14108 ret); 13916 "%s: Buffer write failed. err = %d\n",
13917 __func__, ret);
14109 break; 13918 break;
14110 } 13919 }
14111 13920
@@ -14115,8 +13924,9 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
14115 u32 val; 13924 u32 val;
14116 tg3_read_mem(tp, 0x2100 + (i*4), &val); 13925 tg3_read_mem(tp, 0x2100 + (i*4), &val);
14117 if (le32_to_cpu(val) != p[i]) { 13926 if (le32_to_cpu(val) != p[i]) {
14118 pr_err(" tg3_test_dma() Card buffer corrupted on write! (%d != %d)\n", 13927 dev_err(&tp->pdev->dev,
14119 val, i); 13928 "%s: Buffer corrupted on device! "
13929 "(%d != %d)\n", __func__, val, i);
14120 /* ret = -ENODEV here? */ 13930 /* ret = -ENODEV here? */
14121 } 13931 }
14122 p[i] = 0; 13932 p[i] = 0;
@@ -14125,9 +13935,8 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
14125 /* Now read it back. */ 13935 /* Now read it back. */
14126 ret = tg3_do_test_dma(tp, buf, buf_dma, TEST_BUFFER_SIZE, 0); 13936 ret = tg3_do_test_dma(tp, buf, buf_dma, TEST_BUFFER_SIZE, 0);
14127 if (ret) { 13937 if (ret) {
14128 pr_err("tg3_test_dma() Read the buffer failed %d\n", 13938 dev_err(&tp->pdev->dev, "%s: Buffer read failed. "
14129 ret); 13939 "err = %d\n", __func__, ret);
14130
14131 break; 13940 break;
14132 } 13941 }
14133 13942
@@ -14143,8 +13952,9 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
14143 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl); 13952 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);
14144 break; 13953 break;
14145 } else { 13954 } else {
14146 pr_err("tg3_test_dma() buffer corrupted on read back! (%d != %d)\n", 13955 dev_err(&tp->pdev->dev,
14147 p[i], i); 13956 "%s: Buffer corrupted on read back! "
13957 "(%d != %d)\n", __func__, p[i], i);
14148 ret = -ENODEV; 13958 ret = -ENODEV;
14149 goto out; 13959 goto out;
14150 } 13960 }
@@ -14171,10 +13981,10 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
14171 if (pci_dev_present(dma_wait_state_chipsets)) { 13981 if (pci_dev_present(dma_wait_state_chipsets)) {
14172 tp->dma_rwctrl &= ~DMA_RWCTRL_WRITE_BNDRY_MASK; 13982 tp->dma_rwctrl &= ~DMA_RWCTRL_WRITE_BNDRY_MASK;
14173 tp->dma_rwctrl |= DMA_RWCTRL_WRITE_BNDRY_16; 13983 tp->dma_rwctrl |= DMA_RWCTRL_WRITE_BNDRY_16;
14174 } 13984 } else {
14175 else
14176 /* Safe to use the calculated DMA boundary. */ 13985 /* Safe to use the calculated DMA boundary. */
14177 tp->dma_rwctrl = saved_dma_rwctrl; 13986 tp->dma_rwctrl = saved_dma_rwctrl;
13987 }
14178 13988
14179 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl); 13989 tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);
14180 } 13990 }
@@ -14436,13 +14246,13 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
14436 14246
14437 err = pci_enable_device(pdev); 14247 err = pci_enable_device(pdev);
14438 if (err) { 14248 if (err) {
14439 pr_err("Cannot enable PCI device, aborting\n"); 14249 dev_err(&pdev->dev, "Cannot enable PCI device, aborting\n");
14440 return err; 14250 return err;
14441 } 14251 }
14442 14252
14443 err = pci_request_regions(pdev, DRV_MODULE_NAME); 14253 err = pci_request_regions(pdev, DRV_MODULE_NAME);
14444 if (err) { 14254 if (err) {
14445 pr_err("Cannot obtain PCI resources, aborting\n"); 14255 dev_err(&pdev->dev, "Cannot obtain PCI resources, aborting\n");
14446 goto err_out_disable_pdev; 14256 goto err_out_disable_pdev;
14447 } 14257 }
14448 14258
@@ -14451,14 +14261,15 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
14451 /* Find power-management capability. */ 14261 /* Find power-management capability. */
14452 pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); 14262 pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
14453 if (pm_cap == 0) { 14263 if (pm_cap == 0) {
14454 pr_err("Cannot find PowerManagement capability, aborting\n"); 14264 dev_err(&pdev->dev,
14265 "Cannot find Power Management capability, aborting\n");
14455 err = -EIO; 14266 err = -EIO;
14456 goto err_out_free_res; 14267 goto err_out_free_res;
14457 } 14268 }
14458 14269
14459 dev = alloc_etherdev_mq(sizeof(*tp), TG3_IRQ_MAX_VECS); 14270 dev = alloc_etherdev_mq(sizeof(*tp), TG3_IRQ_MAX_VECS);
14460 if (!dev) { 14271 if (!dev) {
14461 pr_err("Etherdev alloc failed, aborting\n"); 14272 dev_err(&pdev->dev, "Etherdev alloc failed, aborting\n");
14462 err = -ENOMEM; 14273 err = -ENOMEM;
14463 goto err_out_free_res; 14274 goto err_out_free_res;
14464 } 14275 }
@@ -14508,7 +14319,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
14508 14319
14509 tp->regs = pci_ioremap_bar(pdev, BAR_0); 14320 tp->regs = pci_ioremap_bar(pdev, BAR_0);
14510 if (!tp->regs) { 14321 if (!tp->regs) {
14511 netdev_err(dev, "Cannot map device registers, aborting\n"); 14322 dev_err(&pdev->dev, "Cannot map device registers, aborting\n");
14512 err = -ENOMEM; 14323 err = -ENOMEM;
14513 goto err_out_free_dev; 14324 goto err_out_free_dev;
14514 } 14325 }
@@ -14524,7 +14335,8 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
14524 14335
14525 err = tg3_get_invariants(tp); 14336 err = tg3_get_invariants(tp);
14526 if (err) { 14337 if (err) {
14527 netdev_err(dev, "Problem fetching invariants of chip, aborting\n"); 14338 dev_err(&pdev->dev,
14339 "Problem fetching invariants of chip, aborting\n");
14528 goto err_out_iounmap; 14340 goto err_out_iounmap;
14529 } 14341 }
14530 14342
@@ -14559,7 +14371,8 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
14559 err = pci_set_consistent_dma_mask(pdev, 14371 err = pci_set_consistent_dma_mask(pdev,
14560 persist_dma_mask); 14372 persist_dma_mask);
14561 if (err < 0) { 14373 if (err < 0) {
14562 netdev_err(dev, "Unable to obtain 64 bit DMA for consistent allocations\n"); 14374 dev_err(&pdev->dev, "Unable to obtain 64 bit "
14375 "DMA for consistent allocations\n");
14563 goto err_out_iounmap; 14376 goto err_out_iounmap;
14564 } 14377 }
14565 } 14378 }
@@ -14567,7 +14380,8 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
14567 if (err || dma_mask == DMA_BIT_MASK(32)) { 14380 if (err || dma_mask == DMA_BIT_MASK(32)) {
14568 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 14381 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
14569 if (err) { 14382 if (err) {
14570 netdev_err(dev, "No usable DMA configuration, aborting\n"); 14383 dev_err(&pdev->dev,
14384 "No usable DMA configuration, aborting\n");
14571 goto err_out_iounmap; 14385 goto err_out_iounmap;
14572 } 14386 }
14573 } 14387 }
@@ -14616,14 +14430,16 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
14616 14430
14617 err = tg3_get_device_address(tp); 14431 err = tg3_get_device_address(tp);
14618 if (err) { 14432 if (err) {
14619 netdev_err(dev, "Could not obtain valid ethernet address, aborting\n"); 14433 dev_err(&pdev->dev,
14434 "Could not obtain valid ethernet address, aborting\n");
14620 goto err_out_iounmap; 14435 goto err_out_iounmap;
14621 } 14436 }
14622 14437
14623 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) { 14438 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) {
14624 tp->aperegs = pci_ioremap_bar(pdev, BAR_2); 14439 tp->aperegs = pci_ioremap_bar(pdev, BAR_2);
14625 if (!tp->aperegs) { 14440 if (!tp->aperegs) {
14626 netdev_err(dev, "Cannot map APE registers, aborting\n"); 14441 dev_err(&pdev->dev,
14442 "Cannot map APE registers, aborting\n");
14627 err = -ENOMEM; 14443 err = -ENOMEM;
14628 goto err_out_iounmap; 14444 goto err_out_iounmap;
14629 } 14445 }
@@ -14647,7 +14463,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
14647 14463
14648 err = tg3_test_dma(tp); 14464 err = tg3_test_dma(tp);
14649 if (err) { 14465 if (err) {
14650 netdev_err(dev, "DMA engine test failed, aborting\n"); 14466 dev_err(&pdev->dev, "DMA engine test failed, aborting\n");
14651 goto err_out_apeunmap; 14467 goto err_out_apeunmap;
14652 } 14468 }
14653 14469
@@ -14708,7 +14524,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
14708 14524
14709 err = register_netdev(dev); 14525 err = register_netdev(dev);
14710 if (err) { 14526 if (err) {
14711 netdev_err(dev, "Cannot register net device, aborting\n"); 14527 dev_err(&pdev->dev, "Cannot register net device, aborting\n");
14712 goto err_out_apeunmap; 14528 goto err_out_apeunmap;
14713 } 14529 }
14714 14530
@@ -14721,11 +14537,12 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
14721 if (tp->tg3_flags3 & TG3_FLG3_PHY_CONNECTED) { 14537 if (tp->tg3_flags3 & TG3_FLG3_PHY_CONNECTED) {
14722 struct phy_device *phydev; 14538 struct phy_device *phydev;
14723 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR]; 14539 phydev = tp->mdio_bus->phy_map[TG3_PHY_MII_ADDR];
14724 netdev_info(dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s)\n", 14540 netdev_info(dev,
14541 "attached PHY driver [%s] (mii_bus:phy_addr=%s)\n",
14725 phydev->drv->name, dev_name(&phydev->dev)); 14542 phydev->drv->name, dev_name(&phydev->dev));
14726 } else 14543 } else
14727 netdev_info(dev, "attached PHY is %s (%s Ethernet) (WireSpeed[%d])\n", 14544 netdev_info(dev, "attached PHY is %s (%s Ethernet) "
14728 tg3_phy_string(tp), 14545 "(WireSpeed[%d])\n", tg3_phy_string(tp),
14729 ((tp->tg3_flags & TG3_FLAG_10_100_ONLY) ? "10/100Base-TX" : 14546 ((tp->tg3_flags & TG3_FLAG_10_100_ONLY) ? "10/100Base-TX" :
14730 ((tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) ? "1000Base-SX" : 14547 ((tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) ? "1000Base-SX" :
14731 "10/100/1000Base-T")), 14548 "10/100/1000Base-T")),
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 574a1cc4d353..5d7f72a2ea01 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -23,7 +23,7 @@
23#define TG3_BDINFO_NIC_ADDR 0xcUL /* 32-bit */ 23#define TG3_BDINFO_NIC_ADDR 0xcUL /* 32-bit */
24#define TG3_BDINFO_SIZE 0x10UL 24#define TG3_BDINFO_SIZE 0x10UL
25 25
26#define RX_COPY_THRESHOLD 256 26#define RX_COPY_THRESHOLD 256
27 27
28#define TG3_RX_INTERNAL_RING_SZ_5906 32 28#define TG3_RX_INTERNAL_RING_SZ_5906 32
29 29
@@ -252,7 +252,7 @@
252/* 0x94 --> 0x98 unused */ 252/* 0x94 --> 0x98 unused */
253#define TG3PCI_STD_RING_PROD_IDX 0x00000098 /* 64-bit */ 253#define TG3PCI_STD_RING_PROD_IDX 0x00000098 /* 64-bit */
254#define TG3PCI_RCV_RET_RING_CON_IDX 0x000000a0 /* 64-bit */ 254#define TG3PCI_RCV_RET_RING_CON_IDX 0x000000a0 /* 64-bit */
255/* 0xa0 --> 0xb8 unused */ 255/* 0xa8 --> 0xb8 unused */
256#define TG3PCI_DUAL_MAC_CTRL 0x000000b8 256#define TG3PCI_DUAL_MAC_CTRL 0x000000b8
257#define DUAL_MAC_CTRL_CH_MASK 0x00000003 257#define DUAL_MAC_CTRL_CH_MASK 0x00000003
258#define DUAL_MAC_CTRL_ID 0x00000004 258#define DUAL_MAC_CTRL_ID 0x00000004
@@ -2082,7 +2082,7 @@
2082#define MII_TG3_DSP_AADJ1CH0 0x001f 2082#define MII_TG3_DSP_AADJ1CH0 0x001f
2083#define MII_TG3_DSP_AADJ1CH3 0x601f 2083#define MII_TG3_DSP_AADJ1CH3 0x601f
2084#define MII_TG3_DSP_AADJ1CH3_ADCCKADJ 0x0002 2084#define MII_TG3_DSP_AADJ1CH3_ADCCKADJ 0x0002
2085#define MII_TG3_DSP_EXP8 0x0708 2085#define MII_TG3_DSP_EXP8 0x0f08
2086#define MII_TG3_DSP_EXP8_REJ2MHz 0x0001 2086#define MII_TG3_DSP_EXP8_REJ2MHz 0x0001
2087#define MII_TG3_DSP_EXP8_AEDW 0x0200 2087#define MII_TG3_DSP_EXP8_AEDW 0x0200
2088#define MII_TG3_DSP_EXP75 0x0f75 2088#define MII_TG3_DSP_EXP75 0x0f75
@@ -2561,7 +2561,7 @@ struct tg3_bufmgr_config {
2561 2561
2562struct tg3_ethtool_stats { 2562struct tg3_ethtool_stats {
2563 /* Statistics maintained by Receive MAC. */ 2563 /* Statistics maintained by Receive MAC. */
2564 u64 rx_octets; 2564 u64 rx_octets;
2565 u64 rx_fragments; 2565 u64 rx_fragments;
2566 u64 rx_ucast_packets; 2566 u64 rx_ucast_packets;
2567 u64 rx_mcast_packets; 2567 u64 rx_mcast_packets;
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index 390540c101c7..8ffec22b74bf 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -1314,7 +1314,7 @@ static struct net_device_stats *TLan_GetStats( struct net_device *dev )
1314 1314
1315static void TLan_SetMulticastList( struct net_device *dev ) 1315static void TLan_SetMulticastList( struct net_device *dev )
1316{ 1316{
1317 struct dev_mc_list *dmi; 1317 struct netdev_hw_addr *ha;
1318 u32 hash1 = 0; 1318 u32 hash1 = 0;
1319 u32 hash2 = 0; 1319 u32 hash2 = 0;
1320 int i; 1320 int i;
@@ -1336,12 +1336,12 @@ static void TLan_SetMulticastList( struct net_device *dev )
1336 TLan_DioWrite32( dev->base_addr, TLAN_HASH_2, 0xFFFFFFFF ); 1336 TLan_DioWrite32( dev->base_addr, TLAN_HASH_2, 0xFFFFFFFF );
1337 } else { 1337 } else {
1338 i = 0; 1338 i = 0;
1339 netdev_for_each_mc_addr(dmi, dev) { 1339 netdev_for_each_mc_addr(ha, dev) {
1340 if ( i < 3 ) { 1340 if ( i < 3 ) {
1341 TLan_SetMac( dev, i + 1, 1341 TLan_SetMac( dev, i + 1,
1342 (char *) &dmi->dmi_addr ); 1342 (char *) &ha->addr);
1343 } else { 1343 } else {
1344 offset = TLan_HashFunc( (u8 *) &dmi->dmi_addr ); 1344 offset = TLan_HashFunc((u8 *)&ha->addr);
1345 if ( offset < 32 ) 1345 if ( offset < 32 )
1346 hash1 |= ( 1 << offset ); 1346 hash1 |= ( 1 << offset );
1347 else 1347 else
@@ -2464,7 +2464,7 @@ static void TLan_PhyPrint( struct net_device *dev )
2464 printk( "TLAN: Device %s, Unmanaged PHY.\n", dev->name ); 2464 printk( "TLAN: Device %s, Unmanaged PHY.\n", dev->name );
2465 } else if ( phy <= TLAN_PHY_MAX_ADDR ) { 2465 } else if ( phy <= TLAN_PHY_MAX_ADDR ) {
2466 printk( "TLAN: Device %s, PHY 0x%02x.\n", dev->name, phy ); 2466 printk( "TLAN: Device %s, PHY 0x%02x.\n", dev->name, phy );
2467 printk( "TLAN: Off. +0 +1 +2 +3 \n" ); 2467 printk( "TLAN: Off. +0 +1 +2 +3\n" );
2468 for ( i = 0; i < 0x20; i+= 4 ) { 2468 for ( i = 0; i < 0x20; i+= 4 ) {
2469 printk( "TLAN: 0x%02x", i ); 2469 printk( "TLAN: 0x%02x", i );
2470 TLan_MiiReadReg( dev, phy, i, &data0 ); 2470 TLan_MiiReadReg( dev, phy, i, &data0 );
diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index 0fb930feea45..4673e38c52a9 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -76,7 +76,7 @@ static char version[] __devinitdata =
76 76
77#define FW_NAME "3com/3C359.bin" 77#define FW_NAME "3com/3C359.bin"
78MODULE_AUTHOR("Mike Phillips <mikep@linuxtr.net>") ; 78MODULE_AUTHOR("Mike Phillips <mikep@linuxtr.net>") ;
79MODULE_DESCRIPTION("3Com 3C359 Velocity XL Token Ring Adapter Driver \n") ; 79MODULE_DESCRIPTION("3Com 3C359 Velocity XL Token Ring Adapter Driver\n") ;
80MODULE_FIRMWARE(FW_NAME); 80MODULE_FIRMWARE(FW_NAME);
81 81
82/* Module parameters */ 82/* Module parameters */
@@ -162,19 +162,19 @@ static void print_tx_state(struct net_device *dev)
162 u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 162 u8 __iomem *xl_mmio = xl_priv->xl_mmio ;
163 int i ; 163 int i ;
164 164
165 printk("tx_ring_head: %d, tx_ring_tail: %d, free_ent: %d \n",xl_priv->tx_ring_head, 165 printk("tx_ring_head: %d, tx_ring_tail: %d, free_ent: %d\n",xl_priv->tx_ring_head,
166 xl_priv->tx_ring_tail, xl_priv->free_ring_entries) ; 166 xl_priv->tx_ring_tail, xl_priv->free_ring_entries) ;
167 printk("Ring , Address , FSH , DnNextPtr, Buffer, Buffer_Len \n"); 167 printk("Ring , Address , FSH , DnNextPtr, Buffer, Buffer_Len\n");
168 for (i = 0; i < 16; i++) { 168 for (i = 0; i < 16; i++) {
169 txd = &(xl_priv->xl_tx_ring[i]) ; 169 txd = &(xl_priv->xl_tx_ring[i]) ;
170 printk("%d, %08lx, %08x, %08x, %08x, %08x \n", i, virt_to_bus(txd), 170 printk("%d, %08lx, %08x, %08x, %08x, %08x\n", i, virt_to_bus(txd),
171 txd->framestartheader, txd->dnnextptr, txd->buffer, txd->buffer_length ) ; 171 txd->framestartheader, txd->dnnextptr, txd->buffer, txd->buffer_length ) ;
172 } 172 }
173 173
174 printk("DNLISTPTR = %04x \n", readl(xl_mmio + MMIO_DNLISTPTR) ); 174 printk("DNLISTPTR = %04x\n", readl(xl_mmio + MMIO_DNLISTPTR) );
175 175
176 printk("DmaCtl = %04x \n", readl(xl_mmio + MMIO_DMA_CTRL) ); 176 printk("DmaCtl = %04x\n", readl(xl_mmio + MMIO_DMA_CTRL) );
177 printk("Queue status = %0x \n",netif_running(dev) ) ; 177 printk("Queue status = %0x\n",netif_running(dev) ) ;
178} 178}
179 179
180static void print_rx_state(struct net_device *dev) 180static void print_rx_state(struct net_device *dev)
@@ -185,19 +185,19 @@ static void print_rx_state(struct net_device *dev)
185 u8 __iomem *xl_mmio = xl_priv->xl_mmio ; 185 u8 __iomem *xl_mmio = xl_priv->xl_mmio ;
186 int i ; 186 int i ;
187 187
188 printk("rx_ring_tail: %d \n", xl_priv->rx_ring_tail) ; 188 printk("rx_ring_tail: %d\n", xl_priv->rx_ring_tail);
189 printk("Ring , Address , FrameState , UPNextPtr, FragAddr, Frag_Len \n"); 189 printk("Ring , Address , FrameState , UPNextPtr, FragAddr, Frag_Len\n");
190 for (i = 0; i < 16; i++) { 190 for (i = 0; i < 16; i++) {
191 /* rxd = (struct xl_rx_desc *)xl_priv->rx_ring_dma_addr + (i * sizeof(struct xl_rx_desc)) ; */ 191 /* rxd = (struct xl_rx_desc *)xl_priv->rx_ring_dma_addr + (i * sizeof(struct xl_rx_desc)) ; */
192 rxd = &(xl_priv->xl_rx_ring[i]) ; 192 rxd = &(xl_priv->xl_rx_ring[i]) ;
193 printk("%d, %08lx, %08x, %08x, %08x, %08x \n", i, virt_to_bus(rxd), 193 printk("%d, %08lx, %08x, %08x, %08x, %08x\n", i, virt_to_bus(rxd),
194 rxd->framestatus, rxd->upnextptr, rxd->upfragaddr, rxd->upfraglen ) ; 194 rxd->framestatus, rxd->upnextptr, rxd->upfragaddr, rxd->upfraglen ) ;
195 } 195 }
196 196
197 printk("UPLISTPTR = %04x \n", readl(xl_mmio + MMIO_UPLISTPTR) ); 197 printk("UPLISTPTR = %04x\n", readl(xl_mmio + MMIO_UPLISTPTR));
198 198
199 printk("DmaCtl = %04x \n", readl(xl_mmio + MMIO_DMA_CTRL) ); 199 printk("DmaCtl = %04x\n", readl(xl_mmio + MMIO_DMA_CTRL));
200 printk("Queue status = %0x \n",netif_running(dev) ) ; 200 printk("Queue status = %0x\n",netif_running(dev));
201} 201}
202#endif 202#endif
203 203
@@ -390,7 +390,7 @@ static int __devinit xl_init(struct net_device *dev)
390 struct xl_private *xl_priv = netdev_priv(dev); 390 struct xl_private *xl_priv = netdev_priv(dev);
391 int err; 391 int err;
392 392
393 printk(KERN_INFO "%s \n", version); 393 printk(KERN_INFO "%s\n", version);
394 printk(KERN_INFO "%s: I/O at %hx, MMIO at %p, using irq %d\n", 394 printk(KERN_INFO "%s: I/O at %hx, MMIO at %p, using irq %d\n",
395 xl_priv->xl_card_name, (unsigned int)dev->base_addr ,xl_priv->xl_mmio, dev->irq); 395 xl_priv->xl_card_name, (unsigned int)dev->base_addr ,xl_priv->xl_mmio, dev->irq);
396 396
@@ -462,7 +462,7 @@ static int xl_hw_reset(struct net_device *dev)
462 writel( (IO_WORD_READ | PMBAR),xl_mmio + MMIO_MAC_ACCESS_CMD); 462 writel( (IO_WORD_READ | PMBAR),xl_mmio + MMIO_MAC_ACCESS_CMD);
463 463
464#if XL_DEBUG 464#if XL_DEBUG
465 printk(KERN_INFO "Read from PMBAR = %04x \n", readw(xl_mmio + MMIO_MACDATA)) ; 465 printk(KERN_INFO "Read from PMBAR = %04x\n", readw(xl_mmio + MMIO_MACDATA));
466#endif 466#endif
467 467
468 if ( readw( (xl_mmio + MMIO_MACDATA)) & PMB_CPHOLD ) { 468 if ( readw( (xl_mmio + MMIO_MACDATA)) & PMB_CPHOLD ) {
@@ -590,9 +590,9 @@ static int xl_hw_reset(struct net_device *dev)
590#if XL_DEBUG 590#if XL_DEBUG
591 writel(IO_WORD_READ | SWITCHSETTINGS, xl_mmio + MMIO_MAC_ACCESS_CMD) ; 591 writel(IO_WORD_READ | SWITCHSETTINGS, xl_mmio + MMIO_MAC_ACCESS_CMD) ;
592 if ( readw(xl_mmio + MMIO_MACDATA) & 2) { 592 if ( readw(xl_mmio + MMIO_MACDATA) & 2) {
593 printk(KERN_INFO "Default ring speed 4 mbps \n") ; 593 printk(KERN_INFO "Default ring speed 4 mbps\n");
594 } else { 594 } else {
595 printk(KERN_INFO "Default ring speed 16 mbps \n") ; 595 printk(KERN_INFO "Default ring speed 16 mbps\n");
596 } 596 }
597 printk(KERN_INFO "%s: xl_priv->srb = %04x\n",xl_priv->xl_card_name, xl_priv->srb); 597 printk(KERN_INFO "%s: xl_priv->srb = %04x\n",xl_priv->xl_card_name, xl_priv->srb);
598#endif 598#endif
@@ -650,7 +650,7 @@ static int xl_open(struct net_device *dev)
650 650
651 if (open_err != 0) { /* Something went wrong with the open command */ 651 if (open_err != 0) { /* Something went wrong with the open command */
652 if (open_err & 0x07) { /* Wrong speed, retry at different speed */ 652 if (open_err & 0x07) { /* Wrong speed, retry at different speed */
653 printk(KERN_WARNING "%s: Open Error, retrying at different ringspeed \n", dev->name) ; 653 printk(KERN_WARNING "%s: Open Error, retrying at different ringspeed\n", dev->name);
654 switchsettings = switchsettings ^ 2 ; 654 switchsettings = switchsettings ^ 2 ;
655 xl_ee_write(dev,0x08,switchsettings) ; 655 xl_ee_write(dev,0x08,switchsettings) ;
656 xl_hw_reset(dev) ; 656 xl_hw_reset(dev) ;
@@ -702,7 +702,7 @@ static int xl_open(struct net_device *dev)
702 } 702 }
703 703
704 if (i==0) { 704 if (i==0) {
705 printk(KERN_WARNING "%s: Not enough memory to allocate rx buffers. Adapter disabled \n",dev->name) ; 705 printk(KERN_WARNING "%s: Not enough memory to allocate rx buffers. Adapter disabled\n",dev->name);
706 free_irq(dev->irq,dev) ; 706 free_irq(dev->irq,dev) ;
707 kfree(xl_priv->xl_tx_ring); 707 kfree(xl_priv->xl_tx_ring);
708 kfree(xl_priv->xl_rx_ring); 708 kfree(xl_priv->xl_rx_ring);
@@ -852,7 +852,7 @@ static int xl_open_hw(struct net_device *dev)
852 852
853 writel( (MEM_WORD_READ | 0xD0000 | xl_priv->srb) + 12, xl_mmio + MMIO_MAC_ACCESS_CMD) ; 853 writel( (MEM_WORD_READ | 0xD0000 | xl_priv->srb) + 12, xl_mmio + MMIO_MAC_ACCESS_CMD) ;
854 xl_priv->arb = swab16(readw(xl_mmio + MMIO_MACDATA)) ; 854 xl_priv->arb = swab16(readw(xl_mmio + MMIO_MACDATA)) ;
855 printk(", ARB: %04x \n",xl_priv->arb ) ; 855 printk(", ARB: %04x\n",xl_priv->arb );
856 writel( (MEM_WORD_READ | 0xD0000 | xl_priv->srb) + 14, xl_mmio + MMIO_MAC_ACCESS_CMD) ; 856 writel( (MEM_WORD_READ | 0xD0000 | xl_priv->srb) + 14, xl_mmio + MMIO_MAC_ACCESS_CMD) ;
857 vsoff = swab16(readw(xl_mmio + MMIO_MACDATA)) ; 857 vsoff = swab16(readw(xl_mmio + MMIO_MACDATA)) ;
858 858
@@ -866,7 +866,7 @@ static int xl_open_hw(struct net_device *dev)
866 ver_str[i] = readb(xl_mmio + MMIO_MACDATA) ; 866 ver_str[i] = readb(xl_mmio + MMIO_MACDATA) ;
867 } 867 }
868 ver_str[i] = '\0' ; 868 ver_str[i] = '\0' ;
869 printk(KERN_INFO "%s: Microcode version String: %s \n",dev->name,ver_str); 869 printk(KERN_INFO "%s: Microcode version String: %s\n",dev->name,ver_str);
870 } 870 }
871 871
872 /* 872 /*
@@ -990,7 +990,7 @@ static void xl_rx(struct net_device *dev)
990 skb = dev_alloc_skb(xl_priv->pkt_buf_sz) ; 990 skb = dev_alloc_skb(xl_priv->pkt_buf_sz) ;
991 991
992 if (skb==NULL) { /* Still need to fix the rx ring */ 992 if (skb==NULL) { /* Still need to fix the rx ring */
993 printk(KERN_WARNING "%s: dev_alloc_skb failed in rx, single buffer \n",dev->name) ; 993 printk(KERN_WARNING "%s: dev_alloc_skb failed in rx, single buffer\n",dev->name);
994 adv_rx_ring(dev) ; 994 adv_rx_ring(dev) ;
995 dev->stats.rx_dropped++ ; 995 dev->stats.rx_dropped++ ;
996 writel(ACK_INTERRUPT | UPCOMPACK | LATCH_ACK , xl_mmio + MMIO_COMMAND) ; 996 writel(ACK_INTERRUPT | UPCOMPACK | LATCH_ACK , xl_mmio + MMIO_COMMAND) ;
@@ -1091,7 +1091,7 @@ static irqreturn_t xl_interrupt(int irq, void *dev_id)
1091 */ 1091 */
1092 if (intstatus == 0x0001) { 1092 if (intstatus == 0x0001) {
1093 writel(ACK_INTERRUPT | LATCH_ACK, xl_mmio + MMIO_COMMAND) ; 1093 writel(ACK_INTERRUPT | LATCH_ACK, xl_mmio + MMIO_COMMAND) ;
1094 printk(KERN_INFO "%s: 00001 int received \n",dev->name) ; 1094 printk(KERN_INFO "%s: 00001 int received\n",dev->name);
1095 } else { 1095 } else {
1096 if (intstatus & (HOSTERRINT | SRBRINT | ARBCINT | UPCOMPINT | DNCOMPINT | HARDERRINT | (1<<8) | TXUNDERRUN | ASBFINT)) { 1096 if (intstatus & (HOSTERRINT | SRBRINT | ARBCINT | UPCOMPINT | DNCOMPINT | HARDERRINT | (1<<8) | TXUNDERRUN | ASBFINT)) {
1097 1097
@@ -1102,9 +1102,9 @@ static irqreturn_t xl_interrupt(int irq, void *dev_id)
1102 */ 1102 */
1103 1103
1104 if (intstatus & HOSTERRINT) { 1104 if (intstatus & HOSTERRINT) {
1105 printk(KERN_WARNING "%s: Host Error, performing global reset, intstatus = %04x \n",dev->name,intstatus) ; 1105 printk(KERN_WARNING "%s: Host Error, performing global reset, intstatus = %04x\n",dev->name,intstatus);
1106 writew( GLOBAL_RESET, xl_mmio + MMIO_COMMAND ) ; 1106 writew( GLOBAL_RESET, xl_mmio + MMIO_COMMAND ) ;
1107 printk(KERN_WARNING "%s: Resetting hardware: \n", dev->name); 1107 printk(KERN_WARNING "%s: Resetting hardware:\n", dev->name);
1108 netif_stop_queue(dev) ; 1108 netif_stop_queue(dev) ;
1109 xl_freemem(dev) ; 1109 xl_freemem(dev) ;
1110 free_irq(dev->irq,dev); 1110 free_irq(dev->irq,dev);
@@ -1127,7 +1127,7 @@ static irqreturn_t xl_interrupt(int irq, void *dev_id)
1127 Must put a timeout check here ! */ 1127 Must put a timeout check here ! */
1128 /* Empty Loop */ 1128 /* Empty Loop */
1129 } 1129 }
1130 printk(KERN_WARNING "%s: TX Underrun received \n",dev->name) ; 1130 printk(KERN_WARNING "%s: TX Underrun received\n",dev->name);
1131 writel(ACK_INTERRUPT | LATCH_ACK, xl_mmio + MMIO_COMMAND) ; 1131 writel(ACK_INTERRUPT | LATCH_ACK, xl_mmio + MMIO_COMMAND) ;
1132 } /* TxUnderRun */ 1132 } /* TxUnderRun */
1133 1133
@@ -1156,13 +1156,13 @@ static irqreturn_t xl_interrupt(int irq, void *dev_id)
1156 macstatus = readw(xl_mmio + MMIO_MACDATA) ; 1156 macstatus = readw(xl_mmio + MMIO_MACDATA) ;
1157 printk(KERN_WARNING "%s: MacStatusError, details: ", dev->name); 1157 printk(KERN_WARNING "%s: MacStatusError, details: ", dev->name);
1158 if (macstatus & (1<<14)) 1158 if (macstatus & (1<<14))
1159 printk(KERN_WARNING "tchk error: Unrecoverable error \n") ; 1159 printk(KERN_WARNING "tchk error: Unrecoverable error\n");
1160 if (macstatus & (1<<3)) 1160 if (macstatus & (1<<3))
1161 printk(KERN_WARNING "eint error: Internal watchdog timer expired \n") ; 1161 printk(KERN_WARNING "eint error: Internal watchdog timer expired\n");
1162 if (macstatus & (1<<2)) 1162 if (macstatus & (1<<2))
1163 printk(KERN_WARNING "aint error: Host tried to perform invalid operation \n") ; 1163 printk(KERN_WARNING "aint error: Host tried to perform invalid operation\n");
1164 printk(KERN_WARNING "Instatus = %02x, macstatus = %02x\n",intstatus,macstatus) ; 1164 printk(KERN_WARNING "Instatus = %02x, macstatus = %02x\n",intstatus,macstatus) ;
1165 printk(KERN_WARNING "%s: Resetting hardware: \n", dev->name); 1165 printk(KERN_WARNING "%s: Resetting hardware:\n", dev->name);
1166 netif_stop_queue(dev) ; 1166 netif_stop_queue(dev) ;
1167 xl_freemem(dev) ; 1167 xl_freemem(dev) ;
1168 free_irq(dev->irq,dev); 1168 free_irq(dev->irq,dev);
@@ -1174,7 +1174,7 @@ static irqreturn_t xl_interrupt(int irq, void *dev_id)
1174 return IRQ_HANDLED; 1174 return IRQ_HANDLED;
1175 } 1175 }
1176 } else { 1176 } else {
1177 printk(KERN_WARNING "%s: Received Unknown interrupt : %04x \n", dev->name, intstatus) ; 1177 printk(KERN_WARNING "%s: Received Unknown interrupt : %04x\n", dev->name, intstatus);
1178 writel(ACK_INTERRUPT | LATCH_ACK, xl_mmio + MMIO_COMMAND) ; 1178 writel(ACK_INTERRUPT | LATCH_ACK, xl_mmio + MMIO_COMMAND) ;
1179 } 1179 }
1180 } 1180 }
@@ -1349,11 +1349,11 @@ static int xl_close(struct net_device *dev)
1349 1349
1350 writel(MEM_BYTE_READ | 0xd0000 | xl_priv->srb, xl_mmio + MMIO_MAC_ACCESS_CMD); 1350 writel(MEM_BYTE_READ | 0xd0000 | xl_priv->srb, xl_mmio + MMIO_MAC_ACCESS_CMD);
1351 if (readb(xl_mmio + MMIO_MACDATA) != CLOSE_NIC) { 1351 if (readb(xl_mmio + MMIO_MACDATA) != CLOSE_NIC) {
1352 printk(KERN_INFO "%s: CLOSE_NIC did not get a CLOSE_NIC response \n",dev->name) ; 1352 printk(KERN_INFO "%s: CLOSE_NIC did not get a CLOSE_NIC response\n",dev->name);
1353 } else { 1353 } else {
1354 writel((MEM_BYTE_READ | 0xd0000 | xl_priv->srb) +2, xl_mmio + MMIO_MAC_ACCESS_CMD) ; 1354 writel((MEM_BYTE_READ | 0xd0000 | xl_priv->srb) +2, xl_mmio + MMIO_MAC_ACCESS_CMD) ;
1355 if (readb(xl_mmio + MMIO_MACDATA)==0) { 1355 if (readb(xl_mmio + MMIO_MACDATA)==0) {
1356 printk(KERN_INFO "%s: Adapter has been closed \n",dev->name) ; 1356 printk(KERN_INFO "%s: Adapter has been closed\n",dev->name);
1357 writew(ACK_INTERRUPT | SRBRACK | LATCH_ACK, xl_mmio + MMIO_COMMAND) ; 1357 writew(ACK_INTERRUPT | SRBRACK | LATCH_ACK, xl_mmio + MMIO_COMMAND) ;
1358 1358
1359 xl_freemem(dev) ; 1359 xl_freemem(dev) ;
@@ -1390,7 +1390,7 @@ static int xl_close(struct net_device *dev)
1390static void xl_set_rx_mode(struct net_device *dev) 1390static void xl_set_rx_mode(struct net_device *dev)
1391{ 1391{
1392 struct xl_private *xl_priv = netdev_priv(dev); 1392 struct xl_private *xl_priv = netdev_priv(dev);
1393 struct dev_mc_list *dmi; 1393 struct netdev_hw_addr *ha;
1394 unsigned char dev_mc_address[4] ; 1394 unsigned char dev_mc_address[4] ;
1395 u16 options ; 1395 u16 options ;
1396 1396
@@ -1407,11 +1407,11 @@ static void xl_set_rx_mode(struct net_device *dev)
1407 1407
1408 dev_mc_address[0] = dev_mc_address[1] = dev_mc_address[2] = dev_mc_address[3] = 0 ; 1408 dev_mc_address[0] = dev_mc_address[1] = dev_mc_address[2] = dev_mc_address[3] = 0 ;
1409 1409
1410 netdev_for_each_mc_addr(dmi, dev) { 1410 netdev_for_each_mc_addr(ha, dev) {
1411 dev_mc_address[0] |= dmi->dmi_addr[2] ; 1411 dev_mc_address[0] |= ha->addr[2];
1412 dev_mc_address[1] |= dmi->dmi_addr[3] ; 1412 dev_mc_address[1] |= ha->addr[3];
1413 dev_mc_address[2] |= dmi->dmi_addr[4] ; 1413 dev_mc_address[2] |= ha->addr[4];
1414 dev_mc_address[3] |= dmi->dmi_addr[5] ; 1414 dev_mc_address[3] |= ha->addr[5];
1415 } 1415 }
1416 1416
1417 if (memcmp(xl_priv->xl_functional_addr,dev_mc_address,4) != 0) { /* Options have changed, run the command */ 1417 if (memcmp(xl_priv->xl_functional_addr,dev_mc_address,4) != 0) { /* Options have changed, run the command */
@@ -1446,11 +1446,11 @@ static void xl_srb_bh(struct net_device *dev)
1446 printk(KERN_INFO "%s: Command: %d - Invalid Command code\n",dev->name,srb_cmd) ; 1446 printk(KERN_INFO "%s: Command: %d - Invalid Command code\n",dev->name,srb_cmd) ;
1447 break ; 1447 break ;
1448 case 4: 1448 case 4:
1449 printk(KERN_INFO "%s: Command: %d - Adapter is closed, must be open for this command \n",dev->name,srb_cmd) ; 1449 printk(KERN_INFO "%s: Command: %d - Adapter is closed, must be open for this command\n",dev->name,srb_cmd);
1450 break ; 1450 break ;
1451 1451
1452 case 6: 1452 case 6:
1453 printk(KERN_INFO "%s: Command: %d - Options Invalid for command \n",dev->name,srb_cmd) ; 1453 printk(KERN_INFO "%s: Command: %d - Options Invalid for command\n",dev->name,srb_cmd);
1454 break ; 1454 break ;
1455 1455
1456 case 0: /* Successful command execution */ 1456 case 0: /* Successful command execution */
@@ -1471,11 +1471,11 @@ static void xl_srb_bh(struct net_device *dev)
1471 break ; 1471 break ;
1472 case SET_FUNC_ADDRESS: 1472 case SET_FUNC_ADDRESS:
1473 if(xl_priv->xl_message_level) 1473 if(xl_priv->xl_message_level)
1474 printk(KERN_INFO "%s: Functional Address Set \n",dev->name) ; 1474 printk(KERN_INFO "%s: Functional Address Set\n",dev->name);
1475 break ; 1475 break ;
1476 case CLOSE_NIC: 1476 case CLOSE_NIC:
1477 if(xl_priv->xl_message_level) 1477 if(xl_priv->xl_message_level)
1478 printk(KERN_INFO "%s: Received CLOSE_NIC interrupt in interrupt handler \n",dev->name) ; 1478 printk(KERN_INFO "%s: Received CLOSE_NIC interrupt in interrupt handler\n",dev->name);
1479 break ; 1479 break ;
1480 case SET_MULTICAST_MODE: 1480 case SET_MULTICAST_MODE:
1481 if(xl_priv->xl_message_level) 1481 if(xl_priv->xl_message_level)
@@ -1484,9 +1484,9 @@ static void xl_srb_bh(struct net_device *dev)
1484 case SET_RECEIVE_MODE: 1484 case SET_RECEIVE_MODE:
1485 if(xl_priv->xl_message_level) { 1485 if(xl_priv->xl_message_level) {
1486 if (xl_priv->xl_copy_all_options == 0x0004) 1486 if (xl_priv->xl_copy_all_options == 0x0004)
1487 printk(KERN_INFO "%s: Entering promiscuous mode \n", dev->name) ; 1487 printk(KERN_INFO "%s: Entering promiscuous mode\n", dev->name);
1488 else 1488 else
1489 printk(KERN_INFO "%s: Entering normal receive mode \n",dev->name) ; 1489 printk(KERN_INFO "%s: Entering normal receive mode\n",dev->name);
1490 } 1490 }
1491 break ; 1491 break ;
1492 1492
@@ -1556,20 +1556,20 @@ static void xl_arb_cmd(struct net_device *dev)
1556 xl_freemem(dev) ; 1556 xl_freemem(dev) ;
1557 free_irq(dev->irq,dev); 1557 free_irq(dev->irq,dev);
1558 1558
1559 printk(KERN_WARNING "%s: Adapter has been closed \n", dev->name) ; 1559 printk(KERN_WARNING "%s: Adapter has been closed\n", dev->name);
1560 } /* If serious error */ 1560 } /* If serious error */
1561 1561
1562 if (xl_priv->xl_message_level) { 1562 if (xl_priv->xl_message_level) {
1563 if (lan_status_diff & LSC_SIG_LOSS) 1563 if (lan_status_diff & LSC_SIG_LOSS)
1564 printk(KERN_WARNING "%s: No receive signal detected \n", dev->name) ; 1564 printk(KERN_WARNING "%s: No receive signal detected\n", dev->name);
1565 if (lan_status_diff & LSC_HARD_ERR) 1565 if (lan_status_diff & LSC_HARD_ERR)
1566 printk(KERN_INFO "%s: Beaconing \n",dev->name); 1566 printk(KERN_INFO "%s: Beaconing\n",dev->name);
1567 if (lan_status_diff & LSC_SOFT_ERR) 1567 if (lan_status_diff & LSC_SOFT_ERR)
1568 printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame \n",dev->name); 1568 printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame\n",dev->name);
1569 if (lan_status_diff & LSC_TRAN_BCN) 1569 if (lan_status_diff & LSC_TRAN_BCN)
1570 printk(KERN_INFO "%s: We are tranmitting the beacon, aaah\n",dev->name); 1570 printk(KERN_INFO "%s: We are tranmitting the beacon, aaah\n",dev->name);
1571 if (lan_status_diff & LSC_SS) 1571 if (lan_status_diff & LSC_SS)
1572 printk(KERN_INFO "%s: Single Station on the ring \n", dev->name); 1572 printk(KERN_INFO "%s: Single Station on the ring\n", dev->name);
1573 if (lan_status_diff & LSC_RING_REC) 1573 if (lan_status_diff & LSC_RING_REC)
1574 printk(KERN_INFO "%s: Ring recovery ongoing\n",dev->name); 1574 printk(KERN_INFO "%s: Ring recovery ongoing\n",dev->name);
1575 if (lan_status_diff & LSC_FDX_MODE) 1575 if (lan_status_diff & LSC_FDX_MODE)
@@ -1578,7 +1578,7 @@ static void xl_arb_cmd(struct net_device *dev)
1578 1578
1579 if (lan_status_diff & LSC_CO) { 1579 if (lan_status_diff & LSC_CO) {
1580 if (xl_priv->xl_message_level) 1580 if (xl_priv->xl_message_level)
1581 printk(KERN_INFO "%s: Counter Overflow \n", dev->name); 1581 printk(KERN_INFO "%s: Counter Overflow\n", dev->name);
1582 /* Issue READ.LOG command */ 1582 /* Issue READ.LOG command */
1583 xl_srb_cmd(dev, READ_LOG) ; 1583 xl_srb_cmd(dev, READ_LOG) ;
1584 } 1584 }
@@ -1594,7 +1594,7 @@ static void xl_arb_cmd(struct net_device *dev)
1594 } /* Lan.change.status */ 1594 } /* Lan.change.status */
1595 else if ( arb_cmd == RECEIVE_DATA) { /* Received.Data */ 1595 else if ( arb_cmd == RECEIVE_DATA) { /* Received.Data */
1596#if XL_DEBUG 1596#if XL_DEBUG
1597 printk(KERN_INFO "Received.Data \n") ; 1597 printk(KERN_INFO "Received.Data\n");
1598#endif 1598#endif
1599 writel( ((MEM_WORD_READ | 0xD0000 | xl_priv->arb) + 6), xl_mmio + MMIO_MAC_ACCESS_CMD) ; 1599 writel( ((MEM_WORD_READ | 0xD0000 | xl_priv->arb) + 6), xl_mmio + MMIO_MAC_ACCESS_CMD) ;
1600 xl_priv->mac_buffer = swab16(readw(xl_mmio + MMIO_MACDATA)) ; 1600 xl_priv->mac_buffer = swab16(readw(xl_mmio + MMIO_MACDATA)) ;
@@ -1629,7 +1629,7 @@ static void xl_arb_cmd(struct net_device *dev)
1629 xl_asb_cmd(dev) ; 1629 xl_asb_cmd(dev) ;
1630 1630
1631 } else { 1631 } else {
1632 printk(KERN_WARNING "%s: Received unknown arb (xl_priv) command: %02x \n",dev->name,arb_cmd) ; 1632 printk(KERN_WARNING "%s: Received unknown arb (xl_priv) command: %02x\n",dev->name,arb_cmd);
1633 } 1633 }
1634 1634
1635 /* Acknowledge the arb interrupt */ 1635 /* Acknowledge the arb interrupt */
@@ -1686,13 +1686,13 @@ static void xl_asb_bh(struct net_device *dev)
1686 ret_code = readb(xl_mmio + MMIO_MACDATA) ; 1686 ret_code = readb(xl_mmio + MMIO_MACDATA) ;
1687 switch (ret_code) { 1687 switch (ret_code) {
1688 case 0x01: 1688 case 0x01:
1689 printk(KERN_INFO "%s: ASB Command, unrecognized command code \n",dev->name) ; 1689 printk(KERN_INFO "%s: ASB Command, unrecognized command code\n",dev->name);
1690 break ; 1690 break ;
1691 case 0x26: 1691 case 0x26:
1692 printk(KERN_INFO "%s: ASB Command, unexpected receive buffer \n", dev->name) ; 1692 printk(KERN_INFO "%s: ASB Command, unexpected receive buffer\n", dev->name);
1693 break ; 1693 break ;
1694 case 0x40: 1694 case 0x40:
1695 printk(KERN_INFO "%s: ASB Command, Invalid Station ID \n", dev->name) ; 1695 printk(KERN_INFO "%s: ASB Command, Invalid Station ID\n", dev->name);
1696 break ; 1696 break ;
1697 } 1697 }
1698 xl_priv->asb_queued = 0 ; 1698 xl_priv->asb_queued = 0 ;
diff --git a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
index 1a0967246e2f..eebdaae24328 100644
--- a/drivers/net/tokenring/ibmtr.c
+++ b/drivers/net/tokenring/ibmtr.c
@@ -986,7 +986,7 @@ static void open_sap(unsigned char type, struct net_device *dev)
986static void tok_set_multicast_list(struct net_device *dev) 986static void tok_set_multicast_list(struct net_device *dev)
987{ 987{
988 struct tok_info *ti = netdev_priv(dev); 988 struct tok_info *ti = netdev_priv(dev);
989 struct dev_mc_list *mclist; 989 struct netdev_hw_addr *ha;
990 unsigned char address[4]; 990 unsigned char address[4];
991 991
992 int i; 992 int i;
@@ -995,11 +995,11 @@ static void tok_set_multicast_list(struct net_device *dev)
995 /*BMS ifconfig tr down or hot unplug a PCMCIA card ??hownowbrowncow*/ 995 /*BMS ifconfig tr down or hot unplug a PCMCIA card ??hownowbrowncow*/
996 if (/*BMSHELPdev->start == 0 ||*/ ti->open_status != OPEN) return; 996 if (/*BMSHELPdev->start == 0 ||*/ ti->open_status != OPEN) return;
997 address[0] = address[1] = address[2] = address[3] = 0; 997 address[0] = address[1] = address[2] = address[3] = 0;
998 netdev_for_each_mc_addr(mclist, dev) { 998 netdev_for_each_mc_addr(ha, dev) {
999 address[0] |= mclist->dmi_addr[2]; 999 address[0] |= ha->addr[2];
1000 address[1] |= mclist->dmi_addr[3]; 1000 address[1] |= ha->addr[3];
1001 address[2] |= mclist->dmi_addr[4]; 1001 address[2] |= ha->addr[4];
1002 address[3] |= mclist->dmi_addr[5]; 1002 address[3] |= ha->addr[5];
1003 } 1003 }
1004 SET_PAGE(ti->srb_page); 1004 SET_PAGE(ti->srb_page);
1005 for (i = 0; i < sizeof(struct srb_set_funct_addr); i++) 1005 for (i = 0; i < sizeof(struct srb_set_funct_addr); i++)
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
index dd028fee9dc2..88c893100c2b 100644
--- a/drivers/net/tokenring/lanstreamer.c
+++ b/drivers/net/tokenring/lanstreamer.c
@@ -357,7 +357,7 @@ static int __devinit streamer_init_one(struct pci_dev *pdev,
357 pcr |= PCI_COMMAND_SERR; 357 pcr |= PCI_COMMAND_SERR;
358 pci_write_config_word (pdev, PCI_COMMAND, pcr); 358 pci_write_config_word (pdev, PCI_COMMAND, pcr);
359 359
360 printk("%s \n", version); 360 printk("%s\n", version);
361 printk("%s: %s. I/O at %hx, MMIO at %p, using irq %d\n",dev->name, 361 printk("%s: %s. I/O at %hx, MMIO at %p, using irq %d\n",dev->name,
362 streamer_priv->streamer_card_name, 362 streamer_priv->streamer_card_name,
363 (unsigned int) dev->base_addr, 363 (unsigned int) dev->base_addr,
@@ -650,7 +650,7 @@ static int streamer_open(struct net_device *dev)
650#if STREAMER_DEBUG 650#if STREAMER_DEBUG
651 writew(readw(streamer_mmio + LAPWWO), 651 writew(readw(streamer_mmio + LAPWWO),
652 streamer_mmio + LAPA); 652 streamer_mmio + LAPA);
653 printk("srb open request: \n"); 653 printk("srb open request:\n");
654 for (i = 0; i < 16; i++) { 654 for (i = 0; i < 16; i++) {
655 printk("%x:", ntohs(readw(streamer_mmio + LAPDINC))); 655 printk("%x:", ntohs(readw(streamer_mmio + LAPDINC)));
656 } 656 }
@@ -700,7 +700,7 @@ static int streamer_open(struct net_device *dev)
700 if (srb_word != 0) { 700 if (srb_word != 0) {
701 if (srb_word == 0x07) { 701 if (srb_word == 0x07) {
702 if (!streamer_priv->streamer_ring_speed && open_finished) { /* Autosense , first time around */ 702 if (!streamer_priv->streamer_ring_speed && open_finished) { /* Autosense , first time around */
703 printk(KERN_WARNING "%s: Retrying at different ring speed \n", 703 printk(KERN_WARNING "%s: Retrying at different ring speed\n",
704 dev->name); 704 dev->name);
705 open_finished = 0; 705 open_finished = 0;
706 } else { 706 } else {
@@ -716,7 +716,7 @@ static int streamer_open(struct net_device *dev)
716 ((error_code & 0x0f) == 0x0d)) 716 ((error_code & 0x0f) == 0x0d))
717 { 717 {
718 printk(KERN_WARNING "%s: Tried to autosense ring speed with no monitors present\n", dev->name); 718 printk(KERN_WARNING "%s: Tried to autosense ring speed with no monitors present\n", dev->name);
719 printk(KERN_WARNING "%s: Please try again with a specified ring speed \n", dev->name); 719 printk(KERN_WARNING "%s: Please try again with a specified ring speed\n", dev->name);
720 free_irq(dev->irq, dev); 720 free_irq(dev->irq, dev);
721 return -EIO; 721 return -EIO;
722 } 722 }
@@ -922,7 +922,7 @@ static void streamer_rx(struct net_device *dev)
922 922
923 if (rx_desc->status & 0x7E830000) { /* errors */ 923 if (rx_desc->status & 0x7E830000) { /* errors */
924 if (streamer_priv->streamer_message_level) { 924 if (streamer_priv->streamer_message_level) {
925 printk(KERN_WARNING "%s: Rx Error %x \n", 925 printk(KERN_WARNING "%s: Rx Error %x\n",
926 dev->name, rx_desc->status); 926 dev->name, rx_desc->status);
927 } 927 }
928 } else { /* received without errors */ 928 } else { /* received without errors */
@@ -935,7 +935,7 @@ static void streamer_rx(struct net_device *dev)
935 935
936 if (skb == NULL) 936 if (skb == NULL)
937 { 937 {
938 printk(KERN_WARNING "%s: Not enough memory to copy packet to upper layers. \n", dev->name); 938 printk(KERN_WARNING "%s: Not enough memory to copy packet to upper layers.\n", dev->name);
939 dev->stats.rx_dropped++; 939 dev->stats.rx_dropped++;
940 } else { /* we allocated an skb OK */ 940 } else { /* we allocated an skb OK */
941 if (buffer_cnt == 1) { 941 if (buffer_cnt == 1) {
@@ -1266,7 +1266,7 @@ static void streamer_set_rx_mode(struct net_device *dev)
1266 netdev_priv(dev); 1266 netdev_priv(dev);
1267 __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio; 1267 __u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
1268 __u8 options = 0; 1268 __u8 options = 0;
1269 struct dev_mc_list *dmi; 1269 struct netdev_hw_addr *ha;
1270 unsigned char dev_mc_address[5]; 1270 unsigned char dev_mc_address[5];
1271 1271
1272 writel(streamer_priv->srb, streamer_mmio + LAPA); 1272 writel(streamer_priv->srb, streamer_mmio + LAPA);
@@ -1302,11 +1302,11 @@ static void streamer_set_rx_mode(struct net_device *dev)
1302 writel(streamer_priv->srb,streamer_mmio+LAPA); 1302 writel(streamer_priv->srb,streamer_mmio+LAPA);
1303 dev_mc_address[0] = dev_mc_address[1] = dev_mc_address[2] = dev_mc_address[3] = 0 ; 1303 dev_mc_address[0] = dev_mc_address[1] = dev_mc_address[2] = dev_mc_address[3] = 0 ;
1304 1304
1305 netdev_for_each_mc_addr(dmi, dev) { 1305 netdev_for_each_mc_addr(ha, dev) {
1306 dev_mc_address[0] |= dmi->dmi_addr[2] ; 1306 dev_mc_address[0] |= ha->addr[2];
1307 dev_mc_address[1] |= dmi->dmi_addr[3] ; 1307 dev_mc_address[1] |= ha->addr[3];
1308 dev_mc_address[2] |= dmi->dmi_addr[4] ; 1308 dev_mc_address[2] |= ha->addr[4];
1309 dev_mc_address[3] |= dmi->dmi_addr[5] ; 1309 dev_mc_address[3] |= ha->addr[5];
1310 } 1310 }
1311 1311
1312 writew(htons(SRB_SET_FUNC_ADDRESS << 8),streamer_mmio+LAPDINC); 1312 writew(htons(SRB_SET_FUNC_ADDRESS << 8),streamer_mmio+LAPDINC);
@@ -1363,7 +1363,7 @@ static void streamer_srb_bh(struct net_device *dev)
1363 case 0x00: 1363 case 0x00:
1364 break; 1364 break;
1365 case 0x01: 1365 case 0x01:
1366 printk(KERN_WARNING "%s: Unrecognized srb command \n",dev->name); 1366 printk(KERN_WARNING "%s: Unrecognized srb command\n",dev->name);
1367 break; 1367 break;
1368 case 0x04: 1368 case 0x04:
1369 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name); 1369 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
@@ -1391,13 +1391,13 @@ static void streamer_srb_bh(struct net_device *dev)
1391 case 0x00: 1391 case 0x00:
1392 break; 1392 break;
1393 case 0x01: 1393 case 0x01:
1394 printk(KERN_WARNING "%s: Unrecognized srb command \n", dev->name); 1394 printk(KERN_WARNING "%s: Unrecognized srb command\n", dev->name);
1395 break; 1395 break;
1396 case 0x04: 1396 case 0x04:
1397 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name); 1397 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
1398 break; 1398 break;
1399 case 0x39: /* Must deal with this if individual multicast addresses used */ 1399 case 0x39: /* Must deal with this if individual multicast addresses used */
1400 printk(KERN_INFO "%s: Group address not found \n", dev->name); 1400 printk(KERN_INFO "%s: Group address not found\n", dev->name);
1401 break; 1401 break;
1402 default: 1402 default:
1403 break; 1403 break;
@@ -1413,10 +1413,10 @@ static void streamer_srb_bh(struct net_device *dev)
1413 switch (srb_word) { 1413 switch (srb_word) {
1414 case 0x00: 1414 case 0x00:
1415 if (streamer_priv->streamer_message_level) 1415 if (streamer_priv->streamer_message_level)
1416 printk(KERN_INFO "%s: Functional Address Mask Set \n", dev->name); 1416 printk(KERN_INFO "%s: Functional Address Mask Set\n", dev->name);
1417 break; 1417 break;
1418 case 0x01: 1418 case 0x01:
1419 printk(KERN_WARNING "%s: Unrecognized srb command \n", dev->name); 1419 printk(KERN_WARNING "%s: Unrecognized srb command\n", dev->name);
1420 break; 1420 break;
1421 case 0x04: 1421 case 0x04:
1422 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name); 1422 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
@@ -1447,7 +1447,7 @@ static void streamer_srb_bh(struct net_device *dev)
1447 } 1447 }
1448 break; 1448 break;
1449 case 0x01: 1449 case 0x01:
1450 printk(KERN_WARNING "%s: Unrecognized srb command \n", dev->name); 1450 printk(KERN_WARNING "%s: Unrecognized srb command\n", dev->name);
1451 break; 1451 break;
1452 case 0x04: 1452 case 0x04:
1453 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name); 1453 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
@@ -1466,7 +1466,7 @@ static void streamer_srb_bh(struct net_device *dev)
1466 printk(KERN_INFO "%s: Read Source Routing Counters issued\n", dev->name); 1466 printk(KERN_INFO "%s: Read Source Routing Counters issued\n", dev->name);
1467 break; 1467 break;
1468 case 0x01: 1468 case 0x01:
1469 printk(KERN_WARNING "%s: Unrecognized srb command \n", dev->name); 1469 printk(KERN_WARNING "%s: Unrecognized srb command\n", dev->name);
1470 break; 1470 break;
1471 case 0x04: 1471 case 0x04:
1472 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name); 1472 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n", dev->name);
@@ -1555,7 +1555,7 @@ static void streamer_arb_cmd(struct net_device *dev)
1555 (streamer_mmio + LAPDINC))); 1555 (streamer_mmio + LAPDINC)));
1556 } 1556 }
1557 1557
1558 printk("next %04x, fs %02x, len %04x \n", next, 1558 printk("next %04x, fs %02x, len %04x\n", next,
1559 status, len); 1559 status, len);
1560 } 1560 }
1561#endif 1561#endif
@@ -1592,7 +1592,7 @@ static void streamer_arb_cmd(struct net_device *dev)
1592 1592
1593 mac_frame->protocol = tr_type_trans(mac_frame, dev); 1593 mac_frame->protocol = tr_type_trans(mac_frame, dev);
1594#if STREAMER_NETWORK_MONITOR 1594#if STREAMER_NETWORK_MONITOR
1595 printk(KERN_WARNING "%s: Received MAC Frame, details: \n", 1595 printk(KERN_WARNING "%s: Received MAC Frame, details:\n",
1596 dev->name); 1596 dev->name);
1597 mac_hdr = tr_hdr(mac_frame); 1597 mac_hdr = tr_hdr(mac_frame);
1598 printk(KERN_WARNING 1598 printk(KERN_WARNING
@@ -1668,15 +1668,15 @@ drop_frame:
1668 /* If serious error */ 1668 /* If serious error */
1669 if (streamer_priv->streamer_message_level) { 1669 if (streamer_priv->streamer_message_level) {
1670 if (lan_status_diff & LSC_SIG_LOSS) 1670 if (lan_status_diff & LSC_SIG_LOSS)
1671 printk(KERN_WARNING "%s: No receive signal detected \n", dev->name); 1671 printk(KERN_WARNING "%s: No receive signal detected\n", dev->name);
1672 if (lan_status_diff & LSC_HARD_ERR) 1672 if (lan_status_diff & LSC_HARD_ERR)
1673 printk(KERN_INFO "%s: Beaconing \n", dev->name); 1673 printk(KERN_INFO "%s: Beaconing\n", dev->name);
1674 if (lan_status_diff & LSC_SOFT_ERR) 1674 if (lan_status_diff & LSC_SOFT_ERR)
1675 printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame \n", dev->name); 1675 printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame\n", dev->name);
1676 if (lan_status_diff & LSC_TRAN_BCN) 1676 if (lan_status_diff & LSC_TRAN_BCN)
1677 printk(KERN_INFO "%s: We are tranmitting the beacon, aaah\n", dev->name); 1677 printk(KERN_INFO "%s: We are tranmitting the beacon, aaah\n", dev->name);
1678 if (lan_status_diff & LSC_SS) 1678 if (lan_status_diff & LSC_SS)
1679 printk(KERN_INFO "%s: Single Station on the ring \n", dev->name); 1679 printk(KERN_INFO "%s: Single Station on the ring\n", dev->name);
1680 if (lan_status_diff & LSC_RING_REC) 1680 if (lan_status_diff & LSC_RING_REC)
1681 printk(KERN_INFO "%s: Ring recovery ongoing\n", dev->name); 1681 printk(KERN_INFO "%s: Ring recovery ongoing\n", dev->name);
1682 if (lan_status_diff & LSC_FDX_MODE) 1682 if (lan_status_diff & LSC_FDX_MODE)
@@ -1685,7 +1685,7 @@ drop_frame:
1685 1685
1686 if (lan_status_diff & LSC_CO) { 1686 if (lan_status_diff & LSC_CO) {
1687 if (streamer_priv->streamer_message_level) 1687 if (streamer_priv->streamer_message_level)
1688 printk(KERN_INFO "%s: Counter Overflow \n", dev->name); 1688 printk(KERN_INFO "%s: Counter Overflow\n", dev->name);
1689 1689
1690 /* Issue READ.LOG command */ 1690 /* Issue READ.LOG command */
1691 1691
@@ -1715,7 +1715,7 @@ drop_frame:
1715 streamer_priv->streamer_lan_status = lan_status; 1715 streamer_priv->streamer_lan_status = lan_status;
1716 } /* Lan.change.status */ 1716 } /* Lan.change.status */
1717 else 1717 else
1718 printk(KERN_WARNING "%s: Unknown arb command \n", dev->name); 1718 printk(KERN_WARNING "%s: Unknown arb command\n", dev->name);
1719} 1719}
1720 1720
1721static void streamer_asb_bh(struct net_device *dev) 1721static void streamer_asb_bh(struct net_device *dev)
@@ -1746,10 +1746,10 @@ static void streamer_asb_bh(struct net_device *dev)
1746 rc=ntohs(readw(streamer_mmio+LAPD)) >> 8; 1746 rc=ntohs(readw(streamer_mmio+LAPD)) >> 8;
1747 switch (rc) { 1747 switch (rc) {
1748 case 0x01: 1748 case 0x01:
1749 printk(KERN_WARNING "%s: Unrecognized command code \n", dev->name); 1749 printk(KERN_WARNING "%s: Unrecognized command code\n", dev->name);
1750 break; 1750 break;
1751 case 0x26: 1751 case 0x26:
1752 printk(KERN_WARNING "%s: Unrecognized buffer address \n", dev->name); 1752 printk(KERN_WARNING "%s: Unrecognized buffer address\n", dev->name);
1753 break; 1753 break;
1754 case 0xFF: 1754 case 0xFF:
1755 /* Valid response, everything should be ok again */ 1755 /* Valid response, everything should be ok again */
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index 3a25e0434ae2..3d2fbe60b46e 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -302,7 +302,7 @@ static int olympic_init(struct net_device *dev)
302 olympic_priv=netdev_priv(dev); 302 olympic_priv=netdev_priv(dev);
303 olympic_mmio=olympic_priv->olympic_mmio; 303 olympic_mmio=olympic_priv->olympic_mmio;
304 304
305 printk("%s \n", version); 305 printk("%s\n", version);
306 printk("%s. I/O at %hx, MMIO at %p, LAP at %p, using irq %d\n", olympic_priv->olympic_card_name, (unsigned int) dev->base_addr,olympic_priv->olympic_mmio, olympic_priv->olympic_lap, dev->irq); 306 printk("%s. I/O at %hx, MMIO at %p, LAP at %p, using irq %d\n", olympic_priv->olympic_card_name, (unsigned int) dev->base_addr,olympic_priv->olympic_mmio, olympic_priv->olympic_lap, dev->irq);
307 307
308 writel(readl(olympic_mmio+BCTL) | BCTL_SOFTRESET,olympic_mmio+BCTL); 308 writel(readl(olympic_mmio+BCTL) | BCTL_SOFTRESET,olympic_mmio+BCTL);
@@ -468,7 +468,7 @@ static int olympic_open(struct net_device *dev)
468#if OLYMPIC_DEBUG 468#if OLYMPIC_DEBUG
469 printk("LAPWWO: %x, LAPA: %x\n",readw(olympic_mmio+LAPWWO), readl(olympic_mmio+LAPA)); 469 printk("LAPWWO: %x, LAPA: %x\n",readw(olympic_mmio+LAPWWO), readl(olympic_mmio+LAPA));
470 printk("SISR Mask = %04x\n", readl(olympic_mmio+SISR_MASK)); 470 printk("SISR Mask = %04x\n", readl(olympic_mmio+SISR_MASK));
471 printk("Before the open command \n"); 471 printk("Before the open command\n");
472#endif 472#endif
473 do { 473 do {
474 memset_io(init_srb,0,SRB_COMMAND_SIZE); 474 memset_io(init_srb,0,SRB_COMMAND_SIZE);
@@ -520,7 +520,7 @@ static int olympic_open(struct net_device *dev)
520 break; 520 break;
521 } 521 }
522 if (time_after(jiffies, t + 10*HZ)) { 522 if (time_after(jiffies, t + 10*HZ)) {
523 printk(KERN_WARNING "%s: SRB timed out. \n",dev->name) ; 523 printk(KERN_WARNING "%s: SRB timed out.\n",dev->name);
524 olympic_priv->srb_queued=0; 524 olympic_priv->srb_queued=0;
525 break ; 525 break ;
526 } 526 }
@@ -549,7 +549,7 @@ static int olympic_open(struct net_device *dev)
549 break; 549 break;
550 case 0x07: 550 case 0x07:
551 if (!olympic_priv->olympic_ring_speed && open_finished) { /* Autosense , first time around */ 551 if (!olympic_priv->olympic_ring_speed && open_finished) { /* Autosense , first time around */
552 printk(KERN_WARNING "%s: Retrying at different ring speed \n", dev->name); 552 printk(KERN_WARNING "%s: Retrying at different ring speed\n", dev->name);
553 open_finished = 0 ; 553 open_finished = 0 ;
554 continue; 554 continue;
555 } 555 }
@@ -558,7 +558,7 @@ static int olympic_open(struct net_device *dev)
558 558
559 if (!olympic_priv->olympic_ring_speed && ((err & 0x0f) == 0x0d)) { 559 if (!olympic_priv->olympic_ring_speed && ((err & 0x0f) == 0x0d)) {
560 printk(KERN_WARNING "%s: Tried to autosense ring speed with no monitors present\n",dev->name); 560 printk(KERN_WARNING "%s: Tried to autosense ring speed with no monitors present\n",dev->name);
561 printk(KERN_WARNING "%s: Please try again with a specified ring speed \n",dev->name); 561 printk(KERN_WARNING "%s: Please try again with a specified ring speed\n",dev->name);
562 } else { 562 } else {
563 printk(KERN_WARNING "%s: %s - %s\n", dev->name, 563 printk(KERN_WARNING "%s: %s - %s\n", dev->name,
564 open_maj_error[(err & 0xf0) >> 4], 564 open_maj_error[(err & 0xf0) >> 4],
@@ -759,7 +759,7 @@ static void olympic_rx(struct net_device *dev)
759 olympic_priv->rx_status_last_received++ ; 759 olympic_priv->rx_status_last_received++ ;
760 olympic_priv->rx_status_last_received &= (OLYMPIC_RX_RING_SIZE -1); 760 olympic_priv->rx_status_last_received &= (OLYMPIC_RX_RING_SIZE -1);
761#if OLYMPIC_DEBUG 761#if OLYMPIC_DEBUG
762 printk("rx status: %x rx len: %x \n", le32_to_cpu(rx_status->status_buffercnt), le32_to_cpu(rx_status->fragmentcnt_framelen)); 762 printk("rx status: %x rx len: %x\n", le32_to_cpu(rx_status->status_buffercnt), le32_to_cpu(rx_status->fragmentcnt_framelen));
763#endif 763#endif
764 length = le32_to_cpu(rx_status->fragmentcnt_framelen) & 0xffff; 764 length = le32_to_cpu(rx_status->fragmentcnt_framelen) & 0xffff;
765 buffer_cnt = le32_to_cpu(rx_status->status_buffercnt) & 0xffff; 765 buffer_cnt = le32_to_cpu(rx_status->status_buffercnt) & 0xffff;
@@ -774,15 +774,15 @@ static void olympic_rx(struct net_device *dev)
774 if (l_status_buffercnt & 0x3B000000) { 774 if (l_status_buffercnt & 0x3B000000) {
775 if (olympic_priv->olympic_message_level) { 775 if (olympic_priv->olympic_message_level) {
776 if (l_status_buffercnt & (1<<29)) /* Rx Frame Truncated */ 776 if (l_status_buffercnt & (1<<29)) /* Rx Frame Truncated */
777 printk(KERN_WARNING "%s: Rx Frame Truncated \n",dev->name); 777 printk(KERN_WARNING "%s: Rx Frame Truncated\n",dev->name);
778 if (l_status_buffercnt & (1<<28)) /*Rx receive overrun */ 778 if (l_status_buffercnt & (1<<28)) /*Rx receive overrun */
779 printk(KERN_WARNING "%s: Rx Frame Receive overrun \n",dev->name); 779 printk(KERN_WARNING "%s: Rx Frame Receive overrun\n",dev->name);
780 if (l_status_buffercnt & (1<<27)) /* No receive buffers */ 780 if (l_status_buffercnt & (1<<27)) /* No receive buffers */
781 printk(KERN_WARNING "%s: No receive buffers \n",dev->name); 781 printk(KERN_WARNING "%s: No receive buffers\n",dev->name);
782 if (l_status_buffercnt & (1<<25)) /* Receive frame error detect */ 782 if (l_status_buffercnt & (1<<25)) /* Receive frame error detect */
783 printk(KERN_WARNING "%s: Receive frame error detect \n",dev->name); 783 printk(KERN_WARNING "%s: Receive frame error detect\n",dev->name);
784 if (l_status_buffercnt & (1<<24)) /* Received Error Detect */ 784 if (l_status_buffercnt & (1<<24)) /* Received Error Detect */
785 printk(KERN_WARNING "%s: Received Error Detect \n",dev->name); 785 printk(KERN_WARNING "%s: Received Error Detect\n",dev->name);
786 } 786 }
787 olympic_priv->rx_ring_last_received += i ; 787 olympic_priv->rx_ring_last_received += i ;
788 olympic_priv->rx_ring_last_received &= (OLYMPIC_RX_RING_SIZE -1) ; 788 olympic_priv->rx_ring_last_received &= (OLYMPIC_RX_RING_SIZE -1) ;
@@ -796,7 +796,7 @@ static void olympic_rx(struct net_device *dev)
796 } 796 }
797 797
798 if (skb == NULL) { 798 if (skb == NULL) {
799 printk(KERN_WARNING "%s: Not enough memory to copy packet to upper layers. \n",dev->name) ; 799 printk(KERN_WARNING "%s: Not enough memory to copy packet to upper layers.\n",dev->name) ;
800 dev->stats.rx_dropped++; 800 dev->stats.rx_dropped++;
801 /* Update counters even though we don't transfer the frame */ 801 /* Update counters even though we don't transfer the frame */
802 olympic_priv->rx_ring_last_received += i ; 802 olympic_priv->rx_ring_last_received += i ;
@@ -1101,7 +1101,7 @@ static int olympic_close(struct net_device *dev)
1101 } 1101 }
1102 1102
1103 if (t == 0) { 1103 if (t == 0) {
1104 printk(KERN_WARNING "%s: SRB timed out. May not be fatal. \n",dev->name) ; 1104 printk(KERN_WARNING "%s: SRB timed out. May not be fatal.\n",dev->name);
1105 } 1105 }
1106 olympic_priv->srb_queued=0; 1106 olympic_priv->srb_queued=0;
1107 } 1107 }
@@ -1139,7 +1139,7 @@ static void olympic_set_rx_mode(struct net_device *dev)
1139 u8 __iomem *olympic_mmio = olympic_priv->olympic_mmio ; 1139 u8 __iomem *olympic_mmio = olympic_priv->olympic_mmio ;
1140 u8 options = 0; 1140 u8 options = 0;
1141 u8 __iomem *srb; 1141 u8 __iomem *srb;
1142 struct dev_mc_list *dmi; 1142 struct netdev_hw_addr *ha;
1143 unsigned char dev_mc_address[4] ; 1143 unsigned char dev_mc_address[4] ;
1144 1144
1145 writel(olympic_priv->srb,olympic_mmio+LAPA); 1145 writel(olympic_priv->srb,olympic_mmio+LAPA);
@@ -1177,11 +1177,11 @@ static void olympic_set_rx_mode(struct net_device *dev)
1177 1177
1178 dev_mc_address[0] = dev_mc_address[1] = dev_mc_address[2] = dev_mc_address[3] = 0 ; 1178 dev_mc_address[0] = dev_mc_address[1] = dev_mc_address[2] = dev_mc_address[3] = 0 ;
1179 1179
1180 netdev_for_each_mc_addr(dmi, dev) { 1180 netdev_for_each_mc_addr(ha, dev) {
1181 dev_mc_address[0] |= dmi->dmi_addr[2] ; 1181 dev_mc_address[0] |= ha->addr[2];
1182 dev_mc_address[1] |= dmi->dmi_addr[3] ; 1182 dev_mc_address[1] |= ha->addr[3];
1183 dev_mc_address[2] |= dmi->dmi_addr[4] ; 1183 dev_mc_address[2] |= ha->addr[4];
1184 dev_mc_address[3] |= dmi->dmi_addr[5] ; 1184 dev_mc_address[3] |= ha->addr[5];
1185 } 1185 }
1186 1186
1187 writeb(SRB_SET_FUNC_ADDRESS,srb+0); 1187 writeb(SRB_SET_FUNC_ADDRESS,srb+0);
@@ -1239,7 +1239,7 @@ static void olympic_srb_bh(struct net_device *dev)
1239 case 0x00: 1239 case 0x00:
1240 break ; 1240 break ;
1241 case 0x01: 1241 case 0x01:
1242 printk(KERN_WARNING "%s: Unrecognized srb command \n",dev->name) ; 1242 printk(KERN_WARNING "%s: Unrecognized srb command\n",dev->name);
1243 break ; 1243 break ;
1244 case 0x04: 1244 case 0x04:
1245 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n",dev->name); 1245 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n",dev->name);
@@ -1266,13 +1266,13 @@ static void olympic_srb_bh(struct net_device *dev)
1266 case 0x00: 1266 case 0x00:
1267 break ; 1267 break ;
1268 case 0x01: 1268 case 0x01:
1269 printk(KERN_WARNING "%s: Unrecognized srb command \n",dev->name) ; 1269 printk(KERN_WARNING "%s: Unrecognized srb command\n",dev->name);
1270 break ; 1270 break ;
1271 case 0x04: 1271 case 0x04:
1272 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n",dev->name) ; 1272 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n",dev->name) ;
1273 break ; 1273 break ;
1274 case 0x39: /* Must deal with this if individual multicast addresses used */ 1274 case 0x39: /* Must deal with this if individual multicast addresses used */
1275 printk(KERN_INFO "%s: Group address not found \n",dev->name); 1275 printk(KERN_INFO "%s: Group address not found\n",dev->name);
1276 break ; 1276 break ;
1277 default: 1277 default:
1278 break ; 1278 break ;
@@ -1287,10 +1287,10 @@ static void olympic_srb_bh(struct net_device *dev)
1287 switch (readb(srb+2)) { 1287 switch (readb(srb+2)) {
1288 case 0x00: 1288 case 0x00:
1289 if (olympic_priv->olympic_message_level) 1289 if (olympic_priv->olympic_message_level)
1290 printk(KERN_INFO "%s: Functional Address Mask Set \n",dev->name) ; 1290 printk(KERN_INFO "%s: Functional Address Mask Set\n",dev->name);
1291 break ; 1291 break ;
1292 case 0x01: 1292 case 0x01:
1293 printk(KERN_WARNING "%s: Unrecognized srb command \n",dev->name) ; 1293 printk(KERN_WARNING "%s: Unrecognized srb command\n",dev->name);
1294 break ; 1294 break ;
1295 case 0x04: 1295 case 0x04:
1296 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n",dev->name) ; 1296 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n",dev->name) ;
@@ -1310,7 +1310,7 @@ static void olympic_srb_bh(struct net_device *dev)
1310 printk(KERN_INFO "%s: Read Log issued\n",dev->name) ; 1310 printk(KERN_INFO "%s: Read Log issued\n",dev->name) ;
1311 break ; 1311 break ;
1312 case 0x01: 1312 case 0x01:
1313 printk(KERN_WARNING "%s: Unrecognized srb command \n",dev->name) ; 1313 printk(KERN_WARNING "%s: Unrecognized srb command\n",dev->name);
1314 break ; 1314 break ;
1315 case 0x04: 1315 case 0x04:
1316 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n",dev->name) ; 1316 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n",dev->name) ;
@@ -1328,7 +1328,7 @@ static void olympic_srb_bh(struct net_device *dev)
1328 printk(KERN_INFO "%s: Read Source Routing Counters issued\n",dev->name) ; 1328 printk(KERN_INFO "%s: Read Source Routing Counters issued\n",dev->name) ;
1329 break ; 1329 break ;
1330 case 0x01: 1330 case 0x01:
1331 printk(KERN_WARNING "%s: Unrecognized srb command \n",dev->name) ; 1331 printk(KERN_WARNING "%s: Unrecognized srb command\n",dev->name);
1332 break ; 1332 break ;
1333 case 0x04: 1333 case 0x04:
1334 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n",dev->name) ; 1334 printk(KERN_WARNING "%s: Adapter must be open for this operation, doh!!\n",dev->name) ;
@@ -1404,7 +1404,7 @@ static void olympic_arb_cmd(struct net_device *dev)
1404 printk("Loc %d = %02x\n",i,readb(frame_data + i)); 1404 printk("Loc %d = %02x\n",i,readb(frame_data + i));
1405 } 1405 }
1406 1406
1407 printk("next %04x, fs %02x, len %04x \n",readw(buf_ptr+offsetof(struct mac_receive_buffer,next)), readb(buf_ptr+offsetof(struct mac_receive_buffer,frame_status)), readw(buf_ptr+offsetof(struct mac_receive_buffer,buffer_length))); 1407 printk("next %04x, fs %02x, len %04x\n",readw(buf_ptr+offsetof(struct mac_receive_buffer,next)), readb(buf_ptr+offsetof(struct mac_receive_buffer,frame_status)), readw(buf_ptr+offsetof(struct mac_receive_buffer,buffer_length)));
1408} 1408}
1409#endif 1409#endif
1410 mac_frame = dev_alloc_skb(frame_len) ; 1410 mac_frame = dev_alloc_skb(frame_len) ;
@@ -1426,7 +1426,7 @@ static void olympic_arb_cmd(struct net_device *dev)
1426 1426
1427 if (olympic_priv->olympic_network_monitor) { 1427 if (olympic_priv->olympic_network_monitor) {
1428 struct trh_hdr *mac_hdr; 1428 struct trh_hdr *mac_hdr;
1429 printk(KERN_WARNING "%s: Received MAC Frame, details: \n",dev->name); 1429 printk(KERN_WARNING "%s: Received MAC Frame, details:\n",dev->name);
1430 mac_hdr = tr_hdr(mac_frame); 1430 mac_hdr = tr_hdr(mac_frame);
1431 printk(KERN_WARNING "%s: MAC Frame Dest. Addr: %pM\n", 1431 printk(KERN_WARNING "%s: MAC Frame Dest. Addr: %pM\n",
1432 dev->name, mac_hdr->daddr); 1432 dev->name, mac_hdr->daddr);
@@ -1489,20 +1489,20 @@ drop_frame:
1489 writel(readl(olympic_mmio+BCTL)&~(3<<13),olympic_mmio+BCTL); 1489 writel(readl(olympic_mmio+BCTL)&~(3<<13),olympic_mmio+BCTL);
1490 netif_stop_queue(dev); 1490 netif_stop_queue(dev);
1491 olympic_priv->srb = readw(olympic_priv->olympic_lap + LAPWWO) ; 1491 olympic_priv->srb = readw(olympic_priv->olympic_lap + LAPWWO) ;
1492 printk(KERN_WARNING "%s: Adapter has been closed \n", dev->name) ; 1492 printk(KERN_WARNING "%s: Adapter has been closed\n", dev->name);
1493 } /* If serious error */ 1493 } /* If serious error */
1494 1494
1495 if (olympic_priv->olympic_message_level) { 1495 if (olympic_priv->olympic_message_level) {
1496 if (lan_status_diff & LSC_SIG_LOSS) 1496 if (lan_status_diff & LSC_SIG_LOSS)
1497 printk(KERN_WARNING "%s: No receive signal detected \n", dev->name) ; 1497 printk(KERN_WARNING "%s: No receive signal detected\n", dev->name);
1498 if (lan_status_diff & LSC_HARD_ERR) 1498 if (lan_status_diff & LSC_HARD_ERR)
1499 printk(KERN_INFO "%s: Beaconing \n",dev->name); 1499 printk(KERN_INFO "%s: Beaconing\n",dev->name);
1500 if (lan_status_diff & LSC_SOFT_ERR) 1500 if (lan_status_diff & LSC_SOFT_ERR)
1501 printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame \n",dev->name); 1501 printk(KERN_WARNING "%s: Adapter transmitted Soft Error Report Mac Frame\n",dev->name);
1502 if (lan_status_diff & LSC_TRAN_BCN) 1502 if (lan_status_diff & LSC_TRAN_BCN)
1503 printk(KERN_INFO "%s: We are tranmitting the beacon, aaah\n",dev->name); 1503 printk(KERN_INFO "%s: We are tranmitting the beacon, aaah\n",dev->name);
1504 if (lan_status_diff & LSC_SS) 1504 if (lan_status_diff & LSC_SS)
1505 printk(KERN_INFO "%s: Single Station on the ring \n", dev->name); 1505 printk(KERN_INFO "%s: Single Station on the ring\n", dev->name);
1506 if (lan_status_diff & LSC_RING_REC) 1506 if (lan_status_diff & LSC_RING_REC)
1507 printk(KERN_INFO "%s: Ring recovery ongoing\n",dev->name); 1507 printk(KERN_INFO "%s: Ring recovery ongoing\n",dev->name);
1508 if (lan_status_diff & LSC_FDX_MODE) 1508 if (lan_status_diff & LSC_FDX_MODE)
@@ -1512,7 +1512,7 @@ drop_frame:
1512 if (lan_status_diff & LSC_CO) { 1512 if (lan_status_diff & LSC_CO) {
1513 1513
1514 if (olympic_priv->olympic_message_level) 1514 if (olympic_priv->olympic_message_level)
1515 printk(KERN_INFO "%s: Counter Overflow \n", dev->name); 1515 printk(KERN_INFO "%s: Counter Overflow\n", dev->name);
1516 1516
1517 /* Issue READ.LOG command */ 1517 /* Issue READ.LOG command */
1518 1518
@@ -1551,7 +1551,7 @@ drop_frame:
1551 1551
1552 } /* Lan.change.status */ 1552 } /* Lan.change.status */
1553 else 1553 else
1554 printk(KERN_WARNING "%s: Unknown arb command \n", dev->name); 1554 printk(KERN_WARNING "%s: Unknown arb command\n", dev->name);
1555} 1555}
1556 1556
1557static void olympic_asb_bh(struct net_device *dev) 1557static void olympic_asb_bh(struct net_device *dev)
@@ -1578,10 +1578,10 @@ static void olympic_asb_bh(struct net_device *dev)
1578 if (olympic_priv->asb_queued == 2) { 1578 if (olympic_priv->asb_queued == 2) {
1579 switch (readb(asb_block+2)) { 1579 switch (readb(asb_block+2)) {
1580 case 0x01: 1580 case 0x01:
1581 printk(KERN_WARNING "%s: Unrecognized command code \n", dev->name); 1581 printk(KERN_WARNING "%s: Unrecognized command code\n", dev->name);
1582 break ; 1582 break ;
1583 case 0x26: 1583 case 0x26:
1584 printk(KERN_WARNING "%s: Unrecognized buffer address \n", dev->name); 1584 printk(KERN_WARNING "%s: Unrecognized buffer address\n", dev->name);
1585 break ; 1585 break ;
1586 case 0xFF: 1586 case 0xFF:
1587 /* Valid response, everything should be ok again */ 1587 /* Valid response, everything should be ok again */
diff --git a/drivers/net/tokenring/tms380tr.c b/drivers/net/tokenring/tms380tr.c
index ee71bcfb3753..9fa2c36ff904 100644
--- a/drivers/net/tokenring/tms380tr.c
+++ b/drivers/net/tokenring/tms380tr.c
@@ -1212,17 +1212,17 @@ static void tms380tr_set_multicast_list(struct net_device *dev)
1212 } 1212 }
1213 else 1213 else
1214 { 1214 {
1215 struct dev_mc_list *mclist; 1215 struct netdev_hw_addr *ha;
1216 1216
1217 netdev_for_each_mc_addr(mclist, dev) { 1217 netdev_for_each_mc_addr(ha, dev) {
1218 ((char *)(&tp->ocpl.FunctAddr))[0] |= 1218 ((char *)(&tp->ocpl.FunctAddr))[0] |=
1219 mclist->dmi_addr[2]; 1219 ha->addr[2];
1220 ((char *)(&tp->ocpl.FunctAddr))[1] |= 1220 ((char *)(&tp->ocpl.FunctAddr))[1] |=
1221 mclist->dmi_addr[3]; 1221 ha->addr[3];
1222 ((char *)(&tp->ocpl.FunctAddr))[2] |= 1222 ((char *)(&tp->ocpl.FunctAddr))[2] |=
1223 mclist->dmi_addr[4]; 1223 ha->addr[4];
1224 ((char *)(&tp->ocpl.FunctAddr))[3] |= 1224 ((char *)(&tp->ocpl.FunctAddr))[3] |=
1225 mclist->dmi_addr[5]; 1225 ha->addr[5];
1226 } 1226 }
1227 } 1227 }
1228 tms380tr_exec_cmd(dev, OC_SET_FUNCT_ADDR); 1228 tms380tr_exec_cmd(dev, OC_SET_FUNCT_ADDR);
@@ -1391,7 +1391,7 @@ static int tms380tr_bringup_diags(struct net_device *dev)
1391 Status &= STS_MASK; 1391 Status &= STS_MASK;
1392 1392
1393 if(tms380tr_debug > 3) 1393 if(tms380tr_debug > 3)
1394 printk(KERN_DEBUG " %04X \n", Status); 1394 printk(KERN_DEBUG " %04X\n", Status);
1395 /* BUD successfully completed */ 1395 /* BUD successfully completed */
1396 if(Status == STS_INITIALIZE) 1396 if(Status == STS_INITIALIZE)
1397 return (1); 1397 return (1);
@@ -1847,7 +1847,7 @@ static void tms380tr_chk_irq(struct net_device *dev)
1847 break; 1847 break;
1848 1848
1849 case DMA_WRITE_ABORT: 1849 case DMA_WRITE_ABORT:
1850 printk(KERN_INFO "%s: DMA write operation aborted: \n", 1850 printk(KERN_INFO "%s: DMA write operation aborted:\n",
1851 dev->name); 1851 dev->name);
1852 switch (AdapterCheckBlock[1]) 1852 switch (AdapterCheckBlock[1])
1853 { 1853 {
diff --git a/drivers/net/tsi108_eth.c b/drivers/net/tsi108_eth.c
index 647cdd1d4e20..1366541c30a2 100644
--- a/drivers/net/tsi108_eth.c
+++ b/drivers/net/tsi108_eth.c
@@ -263,7 +263,7 @@ static inline void tsi108_write_tbi(struct tsi108_prv_data *data,
263 return; 263 return;
264 udelay(10); 264 udelay(10);
265 } 265 }
266 printk(KERN_ERR "%s function time out \n", __func__); 266 printk(KERN_ERR "%s function time out\n", __func__);
267} 267}
268 268
269static int mii_speed(struct mii_if_info *mii) 269static int mii_speed(struct mii_if_info *mii)
@@ -1056,7 +1056,7 @@ static void tsi108_stop_ethernet(struct net_device *dev)
1056 return; 1056 return;
1057 udelay(10); 1057 udelay(10);
1058 } 1058 }
1059 printk(KERN_ERR "%s function time out \n", __func__); 1059 printk(KERN_ERR "%s function time out\n", __func__);
1060} 1060}
1061 1061
1062static void tsi108_reset_ether(struct tsi108_prv_data * data) 1062static void tsi108_reset_ether(struct tsi108_prv_data * data)
@@ -1186,15 +1186,15 @@ static void tsi108_set_rx_mode(struct net_device *dev)
1186 1186
1187 if (dev->flags & IFF_ALLMULTI || !netdev_mc_empty(dev)) { 1187 if (dev->flags & IFF_ALLMULTI || !netdev_mc_empty(dev)) {
1188 int i; 1188 int i;
1189 struct dev_mc_list *mc; 1189 struct netdev_hw_addr *ha;
1190 rxcfg |= TSI108_EC_RXCFG_MFE | TSI108_EC_RXCFG_MC_HASH; 1190 rxcfg |= TSI108_EC_RXCFG_MFE | TSI108_EC_RXCFG_MC_HASH;
1191 1191
1192 memset(data->mc_hash, 0, sizeof(data->mc_hash)); 1192 memset(data->mc_hash, 0, sizeof(data->mc_hash));
1193 1193
1194 netdev_for_each_mc_addr(mc, dev) { 1194 netdev_for_each_mc_addr(ha, dev) {
1195 u32 hash, crc; 1195 u32 hash, crc;
1196 1196
1197 crc = ether_crc(6, mc->dmi_addr); 1197 crc = ether_crc(6, ha->addr);
1198 hash = crc >> 23; 1198 hash = crc >> 23;
1199 __set_bit(hash, &data->mc_hash[0]); 1199 __set_bit(hash, &data->mc_hash[0]);
1200 } 1200 }
@@ -1233,7 +1233,7 @@ static void tsi108_init_phy(struct net_device *dev)
1233 udelay(10); 1233 udelay(10);
1234 } 1234 }
1235 if (i == 0) 1235 if (i == 0)
1236 printk(KERN_ERR "%s function time out \n", __func__); 1236 printk(KERN_ERR "%s function time out\n", __func__);
1237 1237
1238 if (data->phy_type == TSI108_PHY_BCM54XX) { 1238 if (data->phy_type == TSI108_PHY_BCM54XX) {
1239 tsi108_write_mii(data, 0x09, 0x0300); 1239 tsi108_write_mii(data, 0x09, 0x0300);
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index cb429723b2c8..a68b91764627 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -670,15 +670,15 @@ static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev)
670{ 670{
671 struct de_private *de = netdev_priv(dev); 671 struct de_private *de = netdev_priv(dev);
672 u16 hash_table[32]; 672 u16 hash_table[32];
673 struct dev_mc_list *mclist; 673 struct netdev_hw_addr *ha;
674 int i; 674 int i;
675 u16 *eaddrs; 675 u16 *eaddrs;
676 676
677 memset(hash_table, 0, sizeof(hash_table)); 677 memset(hash_table, 0, sizeof(hash_table));
678 set_bit_le(255, hash_table); /* Broadcast entry */ 678 set_bit_le(255, hash_table); /* Broadcast entry */
679 /* This should work on big-endian machines as well. */ 679 /* This should work on big-endian machines as well. */
680 netdev_for_each_mc_addr(mclist, dev) { 680 netdev_for_each_mc_addr(ha, dev) {
681 int index = ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x1ff; 681 int index = ether_crc_le(ETH_ALEN, ha->addr) & 0x1ff;
682 682
683 set_bit_le(index, hash_table); 683 set_bit_le(index, hash_table);
684 } 684 }
@@ -699,13 +699,13 @@ static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev)
699static void build_setup_frame_perfect(u16 *setup_frm, struct net_device *dev) 699static void build_setup_frame_perfect(u16 *setup_frm, struct net_device *dev)
700{ 700{
701 struct de_private *de = netdev_priv(dev); 701 struct de_private *de = netdev_priv(dev);
702 struct dev_mc_list *mclist; 702 struct netdev_hw_addr *ha;
703 u16 *eaddrs; 703 u16 *eaddrs;
704 704
705 /* We have <= 14 addresses so we can use the wonderful 705 /* We have <= 14 addresses so we can use the wonderful
706 16 address perfect filtering of the Tulip. */ 706 16 address perfect filtering of the Tulip. */
707 netdev_for_each_mc_addr(mclist, dev) { 707 netdev_for_each_mc_addr(ha, dev) {
708 eaddrs = (u16 *)mclist->dmi_addr; 708 eaddrs = (u16 *) ha->addr;
709 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++; 709 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++;
710 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++; 710 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++;
711 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++; 711 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++;
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index c4ecb9a95409..cac4bcc83187 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -1951,7 +1951,7 @@ static void
1951SetMulticastFilter(struct net_device *dev) 1951SetMulticastFilter(struct net_device *dev)
1952{ 1952{
1953 struct de4x5_private *lp = netdev_priv(dev); 1953 struct de4x5_private *lp = netdev_priv(dev);
1954 struct dev_mc_list *dmi; 1954 struct netdev_hw_addr *ha;
1955 u_long iobase = dev->base_addr; 1955 u_long iobase = dev->base_addr;
1956 int i, bit, byte; 1956 int i, bit, byte;
1957 u16 hashcode; 1957 u16 hashcode;
@@ -1966,8 +1966,8 @@ SetMulticastFilter(struct net_device *dev)
1966 if ((dev->flags & IFF_ALLMULTI) || (netdev_mc_count(dev) > 14)) { 1966 if ((dev->flags & IFF_ALLMULTI) || (netdev_mc_count(dev) > 14)) {
1967 omr |= OMR_PM; /* Pass all multicasts */ 1967 omr |= OMR_PM; /* Pass all multicasts */
1968 } else if (lp->setup_f == HASH_PERF) { /* Hash Filtering */ 1968 } else if (lp->setup_f == HASH_PERF) { /* Hash Filtering */
1969 netdev_for_each_mc_addr(dmi, dev) { 1969 netdev_for_each_mc_addr(ha, dev) {
1970 addrs = dmi->dmi_addr; 1970 addrs = ha->addr;
1971 if ((*addrs & 0x01) == 1) { /* multicast address? */ 1971 if ((*addrs & 0x01) == 1) { /* multicast address? */
1972 crc = ether_crc_le(ETH_ALEN, addrs); 1972 crc = ether_crc_le(ETH_ALEN, addrs);
1973 hashcode = crc & HASH_BITS; /* hashcode is 9 LSb of CRC */ 1973 hashcode = crc & HASH_BITS; /* hashcode is 9 LSb of CRC */
@@ -1983,8 +1983,8 @@ SetMulticastFilter(struct net_device *dev)
1983 } 1983 }
1984 } 1984 }
1985 } else { /* Perfect filtering */ 1985 } else { /* Perfect filtering */
1986 netdev_for_each_mc_addr(dmi, dev) { 1986 netdev_for_each_mc_addr(ha, dev) {
1987 addrs = dmi->dmi_addr; 1987 addrs = ha->addr;
1988 for (i=0; i<ETH_ALEN; i++) { 1988 for (i=0; i<ETH_ALEN; i++) {
1989 *(pa + (i&1)) = *addrs++; 1989 *(pa + (i&1)) = *addrs++;
1990 if (i & 0x01) pa += 4; 1990 if (i & 0x01) pa += 4;
@@ -5077,7 +5077,7 @@ mii_get_phy(struct net_device *dev)
5077 lp->phy[k].spd.value = GENERIC_VALUE; /* TX & T4, H/F Duplex */ 5077 lp->phy[k].spd.value = GENERIC_VALUE; /* TX & T4, H/F Duplex */
5078 lp->mii_cnt++; 5078 lp->mii_cnt++;
5079 lp->active++; 5079 lp->active++;
5080 printk("%s: Using generic MII device control. If the board doesn't operate, \nplease mail the following dump to the author:\n", dev->name); 5080 printk("%s: Using generic MII device control. If the board doesn't operate,\nplease mail the following dump to the author:\n", dev->name);
5081 j = de4x5_debug; 5081 j = de4x5_debug;
5082 de4x5_debug |= DEBUG_MII; 5082 de4x5_debug |= DEBUG_MII;
5083 de4x5_dbg_mii(dev, k); 5083 de4x5_dbg_mii(dev, k);
@@ -5337,7 +5337,7 @@ de4x5_dbg_open(struct net_device *dev)
5337 } 5337 }
5338 } 5338 }
5339 printk("...0x%8.8x\n", le32_to_cpu(lp->tx_ring[i].buf)); 5339 printk("...0x%8.8x\n", le32_to_cpu(lp->tx_ring[i].buf));
5340 printk("Ring size: \nRX: %d\nTX: %d\n", 5340 printk("Ring size:\nRX: %d\nTX: %d\n",
5341 (short)lp->rxRingSize, 5341 (short)lp->rxRingSize,
5342 (short)lp->txRingSize); 5342 (short)lp->txRingSize);
5343 } 5343 }
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index 95b38d803e9b..a039c8ab98b2 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -1454,7 +1454,7 @@ static void update_cr6(u32 cr6_data, unsigned long ioaddr)
1454 1454
1455static void dm9132_id_table(struct DEVICE *dev) 1455static void dm9132_id_table(struct DEVICE *dev)
1456{ 1456{
1457 struct dev_mc_list *mcptr; 1457 struct netdev_hw_addr *ha;
1458 u16 * addrptr; 1458 u16 * addrptr;
1459 unsigned long ioaddr = dev->base_addr+0xc0; /* ID Table */ 1459 unsigned long ioaddr = dev->base_addr+0xc0; /* ID Table */
1460 u32 hash_val; 1460 u32 hash_val;
@@ -1478,8 +1478,8 @@ static void dm9132_id_table(struct DEVICE *dev)
1478 hash_table[3] = 0x8000; 1478 hash_table[3] = 0x8000;
1479 1479
1480 /* the multicast address in Hash Table : 64 bits */ 1480 /* the multicast address in Hash Table : 64 bits */
1481 netdev_for_each_mc_addr(mcptr, dev) { 1481 netdev_for_each_mc_addr(ha, dev) {
1482 hash_val = cal_CRC((char *) mcptr->dmi_addr, 6, 0) & 0x3f; 1482 hash_val = cal_CRC((char *) ha->addr, 6, 0) & 0x3f;
1483 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16); 1483 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
1484 } 1484 }
1485 1485
@@ -1497,7 +1497,7 @@ static void dm9132_id_table(struct DEVICE *dev)
1497static void send_filter_frame(struct DEVICE *dev) 1497static void send_filter_frame(struct DEVICE *dev)
1498{ 1498{
1499 struct dmfe_board_info *db = netdev_priv(dev); 1499 struct dmfe_board_info *db = netdev_priv(dev);
1500 struct dev_mc_list *mcptr; 1500 struct netdev_hw_addr *ha;
1501 struct tx_desc *txptr; 1501 struct tx_desc *txptr;
1502 u16 * addrptr; 1502 u16 * addrptr;
1503 u32 * suptr; 1503 u32 * suptr;
@@ -1520,8 +1520,8 @@ static void send_filter_frame(struct DEVICE *dev)
1520 *suptr++ = 0xffff; 1520 *suptr++ = 0xffff;
1521 1521
1522 /* fit the multicast address */ 1522 /* fit the multicast address */
1523 netdev_for_each_mc_addr(mcptr, dev) { 1523 netdev_for_each_mc_addr(ha, dev) {
1524 addrptr = (u16 *) mcptr->dmi_addr; 1524 addrptr = (u16 *) ha->addr;
1525 *suptr++ = addrptr[0]; 1525 *suptr++ = addrptr[0];
1526 *suptr++ = addrptr[1]; 1526 *suptr++ = addrptr[1];
1527 *suptr++ = addrptr[2]; 1527 *suptr++ = addrptr[2];
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index 7f544ef2f5fc..c4b7cd726b69 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -990,15 +990,15 @@ static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev)
990{ 990{
991 struct tulip_private *tp = netdev_priv(dev); 991 struct tulip_private *tp = netdev_priv(dev);
992 u16 hash_table[32]; 992 u16 hash_table[32];
993 struct dev_mc_list *mclist; 993 struct netdev_hw_addr *ha;
994 int i; 994 int i;
995 u16 *eaddrs; 995 u16 *eaddrs;
996 996
997 memset(hash_table, 0, sizeof(hash_table)); 997 memset(hash_table, 0, sizeof(hash_table));
998 set_bit_le(255, hash_table); /* Broadcast entry */ 998 set_bit_le(255, hash_table); /* Broadcast entry */
999 /* This should work on big-endian machines as well. */ 999 /* This should work on big-endian machines as well. */
1000 netdev_for_each_mc_addr(mclist, dev) { 1000 netdev_for_each_mc_addr(ha, dev) {
1001 int index = ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x1ff; 1001 int index = ether_crc_le(ETH_ALEN, ha->addr) & 0x1ff;
1002 1002
1003 set_bit_le(index, hash_table); 1003 set_bit_le(index, hash_table);
1004 } 1004 }
@@ -1018,13 +1018,13 @@ static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev)
1018static void build_setup_frame_perfect(u16 *setup_frm, struct net_device *dev) 1018static void build_setup_frame_perfect(u16 *setup_frm, struct net_device *dev)
1019{ 1019{
1020 struct tulip_private *tp = netdev_priv(dev); 1020 struct tulip_private *tp = netdev_priv(dev);
1021 struct dev_mc_list *mclist; 1021 struct netdev_hw_addr *ha;
1022 u16 *eaddrs; 1022 u16 *eaddrs;
1023 1023
1024 /* We have <= 14 addresses so we can use the wonderful 1024 /* We have <= 14 addresses so we can use the wonderful
1025 16 address perfect filtering of the Tulip. */ 1025 16 address perfect filtering of the Tulip. */
1026 netdev_for_each_mc_addr(mclist, dev) { 1026 netdev_for_each_mc_addr(ha, dev) {
1027 eaddrs = (u16 *)mclist->dmi_addr; 1027 eaddrs = (u16 *) ha->addr;
1028 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++; 1028 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++;
1029 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++; 1029 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++;
1030 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++; 1030 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++;
@@ -1061,7 +1061,7 @@ static void set_rx_mode(struct net_device *dev)
1061 } else if (tp->flags & MC_HASH_ONLY) { 1061 } else if (tp->flags & MC_HASH_ONLY) {
1062 /* Some work-alikes have only a 64-entry hash filter table. */ 1062 /* Some work-alikes have only a 64-entry hash filter table. */
1063 /* Should verify correctness on big-endian/__powerpc__ */ 1063 /* Should verify correctness on big-endian/__powerpc__ */
1064 struct dev_mc_list *mclist; 1064 struct netdev_hw_addr *ha;
1065 if (netdev_mc_count(dev) > 64) { 1065 if (netdev_mc_count(dev) > 64) {
1066 /* Arbitrary non-effective limit. */ 1066 /* Arbitrary non-effective limit. */
1067 tp->csr6 |= AcceptAllMulticast; 1067 tp->csr6 |= AcceptAllMulticast;
@@ -1069,18 +1069,21 @@ static void set_rx_mode(struct net_device *dev)
1069 } else { 1069 } else {
1070 u32 mc_filter[2] = {0, 0}; /* Multicast hash filter */ 1070 u32 mc_filter[2] = {0, 0}; /* Multicast hash filter */
1071 int filterbit; 1071 int filterbit;
1072 netdev_for_each_mc_addr(mclist, dev) { 1072 netdev_for_each_mc_addr(ha, dev) {
1073 if (tp->flags & COMET_MAC_ADDR) 1073 if (tp->flags & COMET_MAC_ADDR)
1074 filterbit = ether_crc_le(ETH_ALEN, mclist->dmi_addr); 1074 filterbit = ether_crc_le(ETH_ALEN,
1075 ha->addr);
1075 else 1076 else
1076 filterbit = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; 1077 filterbit = ether_crc(ETH_ALEN,
1078 ha->addr) >> 26;
1077 filterbit &= 0x3f; 1079 filterbit &= 0x3f;
1078 mc_filter[filterbit >> 5] |= 1 << (filterbit & 31); 1080 mc_filter[filterbit >> 5] |= 1 << (filterbit & 31);
1079 if (tulip_debug > 2) 1081 if (tulip_debug > 2)
1080 dev_info(&dev->dev, 1082 dev_info(&dev->dev,
1081 "Added filter for %pM %08x bit %d\n", 1083 "Added filter for %pM %08x bit %d\n",
1082 mclist->dmi_addr, 1084 ha->addr,
1083 ether_crc(ETH_ALEN, mclist->dmi_addr), filterbit); 1085 ether_crc(ETH_ALEN, ha->addr),
1086 filterbit);
1084 } 1087 }
1085 if (mc_filter[0] == tp->mc_filter[0] && 1088 if (mc_filter[0] == tp->mc_filter[0] &&
1086 mc_filter[1] == tp->mc_filter[1]) 1089 mc_filter[1] == tp->mc_filter[1])
diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c
index a4f09d490531..7063f56640c3 100644
--- a/drivers/net/tulip/uli526x.c
+++ b/drivers/net/tulip/uli526x.c
@@ -1394,7 +1394,7 @@ static void update_cr6(u32 cr6_data, unsigned long ioaddr)
1394static void send_filter_frame(struct net_device *dev, int mc_cnt) 1394static void send_filter_frame(struct net_device *dev, int mc_cnt)
1395{ 1395{
1396 struct uli526x_board_info *db = netdev_priv(dev); 1396 struct uli526x_board_info *db = netdev_priv(dev);
1397 struct dev_mc_list *mcptr; 1397 struct netdev_hw_addr *ha;
1398 struct tx_desc *txptr; 1398 struct tx_desc *txptr;
1399 u16 * addrptr; 1399 u16 * addrptr;
1400 u32 * suptr; 1400 u32 * suptr;
@@ -1417,8 +1417,8 @@ static void send_filter_frame(struct net_device *dev, int mc_cnt)
1417 *suptr++ = 0xffff << FLT_SHIFT; 1417 *suptr++ = 0xffff << FLT_SHIFT;
1418 1418
1419 /* fit the multicast address */ 1419 /* fit the multicast address */
1420 netdev_for_each_mc_addr(mcptr, dev) { 1420 netdev_for_each_mc_addr(ha, dev) {
1421 addrptr = (u16 *) mcptr->dmi_addr; 1421 addrptr = (u16 *) ha->addr;
1422 *suptr++ = addrptr[0] << FLT_SHIFT; 1422 *suptr++ = addrptr[0] << FLT_SHIFT;
1423 *suptr++ = addrptr[1] << FLT_SHIFT; 1423 *suptr++ = addrptr[1] << FLT_SHIFT;
1424 *suptr++ = addrptr[2] << FLT_SHIFT; 1424 *suptr++ = addrptr[2] << FLT_SHIFT;
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index 304f43866c44..3e3822c98a0d 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -1367,13 +1367,15 @@ static u32 __set_rx_mode(struct net_device *dev)
1367 memset(mc_filter, 0xff, sizeof(mc_filter)); 1367 memset(mc_filter, 0xff, sizeof(mc_filter));
1368 rx_mode = RxAcceptBroadcast | AcceptMulticast | AcceptMyPhys; 1368 rx_mode = RxAcceptBroadcast | AcceptMulticast | AcceptMyPhys;
1369 } else { 1369 } else {
1370 struct dev_mc_list *mclist; 1370 struct netdev_hw_addr *ha;
1371 1371
1372 memset(mc_filter, 0, sizeof(mc_filter)); 1372 memset(mc_filter, 0, sizeof(mc_filter));
1373 netdev_for_each_mc_addr(mclist, dev) { 1373 netdev_for_each_mc_addr(ha, dev) {
1374 int filterbit = (ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26) ^ 0x3F; 1374 int filbit;
1375 filterbit &= 0x3f; 1375
1376 mc_filter[filterbit >> 5] |= 1 << (filterbit & 31); 1376 filbit = (ether_crc(ETH_ALEN, ha->addr) >> 26) ^ 0x3F;
1377 filbit &= 0x3f;
1378 mc_filter[filbit >> 5] |= 1 << (filbit & 31);
1377 } 1379 }
1378 rx_mode = RxAcceptBroadcast | AcceptMulticast | AcceptMyPhys; 1380 rx_mode = RxAcceptBroadcast | AcceptMulticast | AcceptMyPhys;
1379 } 1381 }
diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
index acfeeb980562..a439e93be22d 100644
--- a/drivers/net/tulip/xircom_cb.c
+++ b/drivers/net/tulip/xircom_cb.c
@@ -350,9 +350,9 @@ static irqreturn_t xircom_interrupt(int irq, void *dev_instance)
350 350
351#ifdef DEBUG 351#ifdef DEBUG
352 print_binary(status); 352 print_binary(status);
353 printk("tx status 0x%08x 0x%08x \n", 353 printk("tx status 0x%08x 0x%08x\n",
354 card->tx_buffer[0], card->tx_buffer[4]); 354 card->tx_buffer[0], card->tx_buffer[4]);
355 printk("rx status 0x%08x 0x%08x \n", 355 printk("rx status 0x%08x 0x%08x\n",
356 card->rx_buffer[0], card->rx_buffer[4]); 356 card->rx_buffer[0], card->rx_buffer[4]);
357#endif 357#endif
358 /* Handle shared irq and hotplug */ 358 /* Handle shared irq and hotplug */
@@ -462,7 +462,7 @@ static int xircom_open(struct net_device *dev)
462 struct xircom_private *xp = netdev_priv(dev); 462 struct xircom_private *xp = netdev_priv(dev);
463 int retval; 463 int retval;
464 enter("xircom_open"); 464 enter("xircom_open");
465 pr_info("xircom cardbus adaptor found, registering as %s, using irq %i \n", 465 pr_info("xircom cardbus adaptor found, registering as %s, using irq %i\n",
466 dev->name, dev->irq); 466 dev->name, dev->irq);
467 retval = request_irq(dev->irq, xircom_interrupt, IRQF_SHARED, dev->name, dev); 467 retval = request_irq(dev->irq, xircom_interrupt, IRQF_SHARED, dev->name, dev);
468 if (retval) { 468 if (retval) {
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index cd24e5f2b2a2..3053f85aa066 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -921,11 +921,11 @@ typhoon_set_rx_mode(struct net_device *dev)
921 /* Too many to match, or accept all multicasts. */ 921 /* Too many to match, or accept all multicasts. */
922 filter |= TYPHOON_RX_FILTER_ALL_MCAST; 922 filter |= TYPHOON_RX_FILTER_ALL_MCAST;
923 } else if (!netdev_mc_empty(dev)) { 923 } else if (!netdev_mc_empty(dev)) {
924 struct dev_mc_list *mclist; 924 struct netdev_hw_addr *ha;
925 925
926 memset(mc_filter, 0, sizeof(mc_filter)); 926 memset(mc_filter, 0, sizeof(mc_filter));
927 netdev_for_each_mc_addr(mclist, dev) { 927 netdev_for_each_mc_addr(ha, dev) {
928 int bit = ether_crc(ETH_ALEN, mclist->dmi_addr) & 0x3f; 928 int bit = ether_crc(ETH_ALEN, ha->addr) & 0x3f;
929 mc_filter[bit >> 5] |= 1 << (bit & 0x1f); 929 mc_filter[bit >> 5] |= 1 << (bit & 0x1f);
930 } 930 }
931 931
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 1b0aef37e495..081f76bff341 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -1999,7 +1999,7 @@ static void ucc_geth_memclean(struct ucc_geth_private *ugeth)
1999static void ucc_geth_set_multi(struct net_device *dev) 1999static void ucc_geth_set_multi(struct net_device *dev)
2000{ 2000{
2001 struct ucc_geth_private *ugeth; 2001 struct ucc_geth_private *ugeth;
2002 struct dev_mc_list *dmi; 2002 struct netdev_hw_addr *ha;
2003 struct ucc_fast __iomem *uf_regs; 2003 struct ucc_fast __iomem *uf_regs;
2004 struct ucc_geth_82xx_address_filtering_pram __iomem *p_82xx_addr_filt; 2004 struct ucc_geth_82xx_address_filtering_pram __iomem *p_82xx_addr_filt;
2005 2005
@@ -2028,16 +2028,16 @@ static void ucc_geth_set_multi(struct net_device *dev)
2028 out_be32(&p_82xx_addr_filt->gaddr_h, 0x0); 2028 out_be32(&p_82xx_addr_filt->gaddr_h, 0x0);
2029 out_be32(&p_82xx_addr_filt->gaddr_l, 0x0); 2029 out_be32(&p_82xx_addr_filt->gaddr_l, 0x0);
2030 2030
2031 netdev_for_each_mc_addr(dmi, dev) { 2031 netdev_for_each_mc_addr(ha, dev) {
2032 /* Only support group multicast for now. 2032 /* Only support group multicast for now.
2033 */ 2033 */
2034 if (!(dmi->dmi_addr[0] & 1)) 2034 if (!(ha->addr[0] & 1))
2035 continue; 2035 continue;
2036 2036
2037 /* Ask CPM to run CRC and set bit in 2037 /* Ask CPM to run CRC and set bit in
2038 * filter mask. 2038 * filter mask.
2039 */ 2039 */
2040 hw_add_addr_in_hash(ugeth, dmi->dmi_addr); 2040 hw_add_addr_in_hash(ugeth, ha->addr);
2041 } 2041 }
2042 } 2042 }
2043 } 2043 }
@@ -3883,7 +3883,7 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
3883 } 3883 }
3884 3884
3885 if (netif_msg_probe(&debug)) 3885 if (netif_msg_probe(&debug))
3886 printk(KERN_INFO "ucc_geth: UCC%1d at 0x%8x (irq = %d) \n", 3886 printk(KERN_INFO "ucc_geth: UCC%1d at 0x%8x (irq = %d)\n",
3887 ug_info->uf_info.ucc_num + 1, ug_info->uf_info.regs, 3887 ug_info->uf_info.ucc_num + 1, ug_info->uf_info.regs,
3888 ug_info->uf_info.irq); 3888 ug_info->uf_info.irq);
3889 3889
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 9e05639435f2..763364f0972e 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -557,16 +557,14 @@ static void asix_set_multicast(struct net_device *net)
557 * for our 8 byte filter buffer 557 * for our 8 byte filter buffer
558 * to avoid allocating memory that 558 * to avoid allocating memory that
559 * is tricky to free later */ 559 * is tricky to free later */
560 struct dev_mc_list *mc_list; 560 struct netdev_hw_addr *ha;
561 u32 crc_bits; 561 u32 crc_bits;
562 562
563 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); 563 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
564 564
565 /* Build the multicast hash filter. */ 565 /* Build the multicast hash filter. */
566 netdev_for_each_mc_addr(mc_list, net) { 566 netdev_for_each_mc_addr(ha, net) {
567 crc_bits = 567 crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
568 ether_crc(ETH_ALEN,
569 mc_list->dmi_addr) >> 26;
570 data->multi_filter[crc_bits >> 3] |= 568 data->multi_filter[crc_bits >> 3] |=
571 1 << (crc_bits & 7); 569 1 << (crc_bits & 7);
572 } 570 }
@@ -793,16 +791,14 @@ static void ax88172_set_multicast(struct net_device *net)
793 * for our 8 byte filter buffer 791 * for our 8 byte filter buffer
794 * to avoid allocating memory that 792 * to avoid allocating memory that
795 * is tricky to free later */ 793 * is tricky to free later */
796 struct dev_mc_list *mc_list; 794 struct netdev_hw_addr *ha;
797 u32 crc_bits; 795 u32 crc_bits;
798 796
799 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); 797 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
800 798
801 /* Build the multicast hash filter. */ 799 /* Build the multicast hash filter. */
802 netdev_for_each_mc_addr(mc_list, net) { 800 netdev_for_each_mc_addr(ha, net) {
803 crc_bits = 801 crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
804 ether_crc(ETH_ALEN,
805 mc_list->dmi_addr) >> 26;
806 data->multi_filter[crc_bits >> 3] |= 802 data->multi_filter[crc_bits >> 3] |=
807 1 << (crc_bits & 7); 803 1 << (crc_bits & 7);
808 } 804 }
diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c
index 96f1ebe0d348..0c48ff97f47c 100644
--- a/drivers/net/usb/catc.c
+++ b/drivers/net/usb/catc.c
@@ -629,7 +629,7 @@ static void catc_multicast(unsigned char *addr, u8 *multicast)
629static void catc_set_multicast_list(struct net_device *netdev) 629static void catc_set_multicast_list(struct net_device *netdev)
630{ 630{
631 struct catc *catc = netdev_priv(netdev); 631 struct catc *catc = netdev_priv(netdev);
632 struct dev_mc_list *mc; 632 struct netdev_hw_addr *ha;
633 u8 broadcast[6]; 633 u8 broadcast[6];
634 u8 rx = RxEnable | RxPolarity | RxMultiCast; 634 u8 rx = RxEnable | RxPolarity | RxMultiCast;
635 635
@@ -647,8 +647,8 @@ static void catc_set_multicast_list(struct net_device *netdev)
647 if (netdev->flags & IFF_ALLMULTI) { 647 if (netdev->flags & IFF_ALLMULTI) {
648 memset(catc->multicast, 0xff, 64); 648 memset(catc->multicast, 0xff, 64);
649 } else { 649 } else {
650 netdev_for_each_mc_addr(mc, netdev) { 650 netdev_for_each_mc_addr(ha, netdev) {
651 u32 crc = ether_crc_le(6, mc->dmi_addr); 651 u32 crc = ether_crc_le(6, ha->addr);
652 if (!catc->is_f5u011) { 652 if (!catc->is_f5u011) {
653 catc->multicast[(crc >> 3) & 0x3f] |= 1 << (crc & 7); 653 catc->multicast[(crc >> 3) & 0x3f] |= 1 << (crc & 7);
654 } else { 654 } else {
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 269339769f47..4eb1fb31ff0b 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -386,10 +386,10 @@ static void dm9601_set_multicast(struct net_device *net)
386 netdev_mc_count(net) > DM_MAX_MCAST) { 386 netdev_mc_count(net) > DM_MAX_MCAST) {
387 rx_ctl |= 0x04; 387 rx_ctl |= 0x04;
388 } else if (!netdev_mc_empty(net)) { 388 } else if (!netdev_mc_empty(net)) {
389 struct dev_mc_list *mc_list; 389 struct netdev_hw_addr *ha;
390 390
391 netdev_for_each_mc_addr(mc_list, net) { 391 netdev_for_each_mc_addr(ha, net) {
392 u32 crc = ether_crc(ETH_ALEN, mc_list->dmi_addr) >> 26; 392 u32 crc = ether_crc(ETH_ALEN, ha->addr) >> 26;
393 hashes[crc >> 3] |= 1 << (crc & 0x7); 393 hashes[crc >> 3] |= 1 << (crc & 0x7);
394 } 394 }
395 } 395 }
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index 70978219e98a..0dc92c8ba4b2 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -452,12 +452,12 @@ static void mcs7830_data_set_multicast(struct net_device *net)
452 * for our 8 byte filter buffer 452 * for our 8 byte filter buffer
453 * to avoid allocating memory that 453 * to avoid allocating memory that
454 * is tricky to free later */ 454 * is tricky to free later */
455 struct dev_mc_list *mc_list; 455 struct netdev_hw_addr *ha;
456 u32 crc_bits; 456 u32 crc_bits;
457 457
458 /* Build the multicast hash filter. */ 458 /* Build the multicast hash filter. */
459 netdev_for_each_mc_addr(mc_list, net) { 459 netdev_for_each_mc_addr(ha, net) {
460 crc_bits = ether_crc(ETH_ALEN, mc_list->dmi_addr) >> 26; 460 crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
461 data->multi_filter[crc_bits >> 3] |= 1 << (crc_bits & 7); 461 data->multi_filter[crc_bits >> 3] |= 1 << (crc_bits & 7);
462 } 462 }
463 } 463 }
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 300e3e764fa2..b8b00d06ea79 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -444,14 +444,14 @@ static void smsc75xx_set_multicast(struct net_device *netdev)
444 netif_dbg(dev, drv, dev->net, "receive all multicast enabled"); 444 netif_dbg(dev, drv, dev->net, "receive all multicast enabled");
445 pdata->rfe_ctl |= RFE_CTL_AM | RFE_CTL_DPF; 445 pdata->rfe_ctl |= RFE_CTL_AM | RFE_CTL_DPF;
446 } else if (!netdev_mc_empty(dev->net)) { 446 } else if (!netdev_mc_empty(dev->net)) {
447 struct dev_mc_list *mc_list; 447 struct netdev_hw_addr *ha;
448 448
449 netif_dbg(dev, drv, dev->net, "receive multicast hash filter"); 449 netif_dbg(dev, drv, dev->net, "receive multicast hash filter");
450 450
451 pdata->rfe_ctl |= RFE_CTL_MHF | RFE_CTL_DPF; 451 pdata->rfe_ctl |= RFE_CTL_MHF | RFE_CTL_DPF;
452 452
453 netdev_for_each_mc_addr(mc_list, netdev) { 453 netdev_for_each_mc_addr(ha, netdev) {
454 u32 bitnum = smsc75xx_hash(mc_list->dmi_addr); 454 u32 bitnum = smsc75xx_hash(ha->addr);
455 pdata->multicast_hash_table[bitnum / 32] |= 455 pdata->multicast_hash_table[bitnum / 32] |=
456 (1 << (bitnum % 32)); 456 (1 << (bitnum % 32));
457 } 457 }
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 73f9a31cf94d..ccd55ca3a06a 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -384,13 +384,13 @@ static void smsc95xx_set_multicast(struct net_device *netdev)
384 pdata->mac_cr |= MAC_CR_MCPAS_; 384 pdata->mac_cr |= MAC_CR_MCPAS_;
385 pdata->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_HPFILT_); 385 pdata->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_HPFILT_);
386 } else if (!netdev_mc_empty(dev->net)) { 386 } else if (!netdev_mc_empty(dev->net)) {
387 struct dev_mc_list *mc_list; 387 struct netdev_hw_addr *ha;
388 388
389 pdata->mac_cr |= MAC_CR_HPFILT_; 389 pdata->mac_cr |= MAC_CR_HPFILT_;
390 pdata->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_MCPAS_); 390 pdata->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_MCPAS_);
391 391
392 netdev_for_each_mc_addr(mc_list, netdev) { 392 netdev_for_each_mc_addr(ha, netdev) {
393 u32 bitnum = smsc95xx_hash(mc_list->dmi_addr); 393 u32 bitnum = smsc95xx_hash(ha->addr);
394 u32 mask = 0x01 << (bitnum & 0x1F); 394 u32 mask = 0x01 << (bitnum & 0x1F);
395 if (bitnum & 0x20) 395 if (bitnum & 0x20)
396 hash_hi |= mask; 396 hash_hi |= mask;
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 17b6a62d206e..c0f64392627c 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1068,12 +1068,15 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
1068 * NOTE: strictly conforming cdc-ether devices should expect 1068 * NOTE: strictly conforming cdc-ether devices should expect
1069 * the ZLP here, but ignore the one-byte packet. 1069 * the ZLP here, but ignore the one-byte packet.
1070 */ 1070 */
1071 if (!(info->flags & FLAG_SEND_ZLP) && (length % dev->maxpacket) == 0) { 1071 if (length % dev->maxpacket == 0) {
1072 urb->transfer_buffer_length++; 1072 if (!(info->flags & FLAG_SEND_ZLP)) {
1073 if (skb_tailroom(skb)) { 1073 urb->transfer_buffer_length++;
1074 skb->data[skb->len] = 0; 1074 if (skb_tailroom(skb)) {
1075 __skb_put(skb, 1); 1075 skb->data[skb->len] = 0;
1076 } 1076 __skb_put(skb, 1);
1077 }
1078 } else
1079 urb->transfer_flags |= URB_ZERO_PACKET;
1077 } 1080 }
1078 1081
1079 spin_lock_irqsave(&dev->txq.lock, flags); 1082 spin_lock_irqsave(&dev->txq.lock, flags);
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index 50f881aa3939..d9133c62a2f5 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -1704,11 +1704,11 @@ static void rhine_set_rx_mode(struct net_device *dev)
1704 iowrite32(0xffffffff, ioaddr + MulticastFilter1); 1704 iowrite32(0xffffffff, ioaddr + MulticastFilter1);
1705 rx_mode = 0x0C; 1705 rx_mode = 0x0C;
1706 } else { 1706 } else {
1707 struct dev_mc_list *mclist; 1707 struct netdev_hw_addr *ha;
1708 1708
1709 memset(mc_filter, 0, sizeof(mc_filter)); 1709 memset(mc_filter, 0, sizeof(mc_filter));
1710 netdev_for_each_mc_addr(mclist, dev) { 1710 netdev_for_each_mc_addr(ha, dev) {
1711 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; 1711 int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
1712 1712
1713 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); 1713 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
1714 } 1714 }
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index bc278d4ee89d..616f8c92b745 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -719,30 +719,30 @@ static u32 mii_check_media_mode(struct mac_regs __iomem *regs)
719 u32 status = 0; 719 u32 status = 0;
720 u16 ANAR; 720 u16 ANAR;
721 721
722 if (!MII_REG_BITS_IS_ON(BMSR_LNK, MII_REG_BMSR, regs)) 722 if (!MII_REG_BITS_IS_ON(BMSR_LSTATUS, MII_BMSR, regs))
723 status |= VELOCITY_LINK_FAIL; 723 status |= VELOCITY_LINK_FAIL;
724 724
725 if (MII_REG_BITS_IS_ON(G1000CR_1000FD, MII_REG_G1000CR, regs)) 725 if (MII_REG_BITS_IS_ON(ADVERTISE_1000FULL, MII_CTRL1000, regs))
726 status |= VELOCITY_SPEED_1000 | VELOCITY_DUPLEX_FULL; 726 status |= VELOCITY_SPEED_1000 | VELOCITY_DUPLEX_FULL;
727 else if (MII_REG_BITS_IS_ON(G1000CR_1000, MII_REG_G1000CR, regs)) 727 else if (MII_REG_BITS_IS_ON(ADVERTISE_1000HALF, MII_CTRL1000, regs))
728 status |= (VELOCITY_SPEED_1000); 728 status |= (VELOCITY_SPEED_1000);
729 else { 729 else {
730 velocity_mii_read(regs, MII_REG_ANAR, &ANAR); 730 velocity_mii_read(regs, MII_ADVERTISE, &ANAR);
731 if (ANAR & ANAR_TXFD) 731 if (ANAR & ADVERTISE_100FULL)
732 status |= (VELOCITY_SPEED_100 | VELOCITY_DUPLEX_FULL); 732 status |= (VELOCITY_SPEED_100 | VELOCITY_DUPLEX_FULL);
733 else if (ANAR & ANAR_TX) 733 else if (ANAR & ADVERTISE_100HALF)
734 status |= VELOCITY_SPEED_100; 734 status |= VELOCITY_SPEED_100;
735 else if (ANAR & ANAR_10FD) 735 else if (ANAR & ADVERTISE_10FULL)
736 status |= (VELOCITY_SPEED_10 | VELOCITY_DUPLEX_FULL); 736 status |= (VELOCITY_SPEED_10 | VELOCITY_DUPLEX_FULL);
737 else 737 else
738 status |= (VELOCITY_SPEED_10); 738 status |= (VELOCITY_SPEED_10);
739 } 739 }
740 740
741 if (MII_REG_BITS_IS_ON(BMCR_AUTO, MII_REG_BMCR, regs)) { 741 if (MII_REG_BITS_IS_ON(BMCR_ANENABLE, MII_BMCR, regs)) {
742 velocity_mii_read(regs, MII_REG_ANAR, &ANAR); 742 velocity_mii_read(regs, MII_ADVERTISE, &ANAR);
743 if ((ANAR & (ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10)) 743 if ((ANAR & (ADVERTISE_100FULL | ADVERTISE_100HALF | ADVERTISE_10FULL | ADVERTISE_10HALF))
744 == (ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10)) { 744 == (ADVERTISE_100FULL | ADVERTISE_100HALF | ADVERTISE_10FULL | ADVERTISE_10HALF)) {
745 if (MII_REG_BITS_IS_ON(G1000CR_1000 | G1000CR_1000FD, MII_REG_G1000CR, regs)) 745 if (MII_REG_BITS_IS_ON(ADVERTISE_1000HALF | ADVERTISE_1000FULL, MII_CTRL1000, regs))
746 status |= VELOCITY_AUTONEG_ENABLE; 746 status |= VELOCITY_AUTONEG_ENABLE;
747 } 747 }
748 } 748 }
@@ -801,23 +801,23 @@ static void set_mii_flow_control(struct velocity_info *vptr)
801 /*Enable or Disable PAUSE in ANAR */ 801 /*Enable or Disable PAUSE in ANAR */
802 switch (vptr->options.flow_cntl) { 802 switch (vptr->options.flow_cntl) {
803 case FLOW_CNTL_TX: 803 case FLOW_CNTL_TX:
804 MII_REG_BITS_OFF(ANAR_PAUSE, MII_REG_ANAR, vptr->mac_regs); 804 MII_REG_BITS_OFF(ADVERTISE_PAUSE_CAP, MII_ADVERTISE, vptr->mac_regs);
805 MII_REG_BITS_ON(ANAR_ASMDIR, MII_REG_ANAR, vptr->mac_regs); 805 MII_REG_BITS_ON(ADVERTISE_PAUSE_ASYM, MII_ADVERTISE, vptr->mac_regs);
806 break; 806 break;
807 807
808 case FLOW_CNTL_RX: 808 case FLOW_CNTL_RX:
809 MII_REG_BITS_ON(ANAR_PAUSE, MII_REG_ANAR, vptr->mac_regs); 809 MII_REG_BITS_ON(ADVERTISE_PAUSE_CAP, MII_ADVERTISE, vptr->mac_regs);
810 MII_REG_BITS_ON(ANAR_ASMDIR, MII_REG_ANAR, vptr->mac_regs); 810 MII_REG_BITS_ON(ADVERTISE_PAUSE_ASYM, MII_ADVERTISE, vptr->mac_regs);
811 break; 811 break;
812 812
813 case FLOW_CNTL_TX_RX: 813 case FLOW_CNTL_TX_RX:
814 MII_REG_BITS_ON(ANAR_PAUSE, MII_REG_ANAR, vptr->mac_regs); 814 MII_REG_BITS_ON(ADVERTISE_PAUSE_CAP, MII_ADVERTISE, vptr->mac_regs);
815 MII_REG_BITS_OFF(ANAR_ASMDIR, MII_REG_ANAR, vptr->mac_regs); 815 MII_REG_BITS_OFF(ADVERTISE_PAUSE_ASYM, MII_ADVERTISE, vptr->mac_regs);
816 break; 816 break;
817 817
818 case FLOW_CNTL_DISABLE: 818 case FLOW_CNTL_DISABLE:
819 MII_REG_BITS_OFF(ANAR_PAUSE, MII_REG_ANAR, vptr->mac_regs); 819 MII_REG_BITS_OFF(ADVERTISE_PAUSE_CAP, MII_ADVERTISE, vptr->mac_regs);
820 MII_REG_BITS_OFF(ANAR_ASMDIR, MII_REG_ANAR, vptr->mac_regs); 820 MII_REG_BITS_OFF(ADVERTISE_PAUSE_ASYM, MII_ADVERTISE, vptr->mac_regs);
821 break; 821 break;
822 default: 822 default:
823 break; 823 break;
@@ -832,10 +832,10 @@ static void set_mii_flow_control(struct velocity_info *vptr)
832 */ 832 */
833static void mii_set_auto_on(struct velocity_info *vptr) 833static void mii_set_auto_on(struct velocity_info *vptr)
834{ 834{
835 if (MII_REG_BITS_IS_ON(BMCR_AUTO, MII_REG_BMCR, vptr->mac_regs)) 835 if (MII_REG_BITS_IS_ON(BMCR_ANENABLE, MII_BMCR, vptr->mac_regs))
836 MII_REG_BITS_ON(BMCR_REAUTO, MII_REG_BMCR, vptr->mac_regs); 836 MII_REG_BITS_ON(BMCR_ANRESTART, MII_BMCR, vptr->mac_regs);
837 else 837 else
838 MII_REG_BITS_ON(BMCR_AUTO, MII_REG_BMCR, vptr->mac_regs); 838 MII_REG_BITS_ON(BMCR_ANENABLE, MII_BMCR, vptr->mac_regs);
839} 839}
840 840
841static u32 check_connection_type(struct mac_regs __iomem *regs) 841static u32 check_connection_type(struct mac_regs __iomem *regs)
@@ -860,11 +860,11 @@ static u32 check_connection_type(struct mac_regs __iomem *regs)
860 else 860 else
861 status |= VELOCITY_SPEED_100; 861 status |= VELOCITY_SPEED_100;
862 862
863 if (MII_REG_BITS_IS_ON(BMCR_AUTO, MII_REG_BMCR, regs)) { 863 if (MII_REG_BITS_IS_ON(BMCR_ANENABLE, MII_BMCR, regs)) {
864 velocity_mii_read(regs, MII_REG_ANAR, &ANAR); 864 velocity_mii_read(regs, MII_ADVERTISE, &ANAR);
865 if ((ANAR & (ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10)) 865 if ((ANAR & (ADVERTISE_100FULL | ADVERTISE_100HALF | ADVERTISE_10FULL | ADVERTISE_10HALF))
866 == (ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10)) { 866 == (ADVERTISE_100FULL | ADVERTISE_100HALF | ADVERTISE_10FULL | ADVERTISE_10HALF)) {
867 if (MII_REG_BITS_IS_ON(G1000CR_1000 | G1000CR_1000FD, MII_REG_G1000CR, regs)) 867 if (MII_REG_BITS_IS_ON(ADVERTISE_1000HALF | ADVERTISE_1000FULL, MII_CTRL1000, regs))
868 status |= VELOCITY_AUTONEG_ENABLE; 868 status |= VELOCITY_AUTONEG_ENABLE;
869 } 869 }
870 } 870 }
@@ -905,7 +905,7 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
905 */ 905 */
906 906
907 if (PHYID_GET_PHY_ID(vptr->phy_id) == PHYID_CICADA_CS8201) 907 if (PHYID_GET_PHY_ID(vptr->phy_id) == PHYID_CICADA_CS8201)
908 MII_REG_BITS_ON(AUXCR_MDPPS, MII_REG_AUXCR, vptr->mac_regs); 908 MII_REG_BITS_ON(AUXCR_MDPPS, MII_NCONFIG, vptr->mac_regs);
909 909
910 /* 910 /*
911 * If connection type is AUTO 911 * If connection type is AUTO
@@ -915,9 +915,9 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
915 /* clear force MAC mode bit */ 915 /* clear force MAC mode bit */
916 BYTE_REG_BITS_OFF(CHIPGCR_FCMODE, &regs->CHIPGCR); 916 BYTE_REG_BITS_OFF(CHIPGCR_FCMODE, &regs->CHIPGCR);
917 /* set duplex mode of MAC according to duplex mode of MII */ 917 /* set duplex mode of MAC according to duplex mode of MII */
918 MII_REG_BITS_ON(ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10, MII_REG_ANAR, vptr->mac_regs); 918 MII_REG_BITS_ON(ADVERTISE_100FULL | ADVERTISE_100HALF | ADVERTISE_10FULL | ADVERTISE_10HALF, MII_ADVERTISE, vptr->mac_regs);
919 MII_REG_BITS_ON(G1000CR_1000FD | G1000CR_1000, MII_REG_G1000CR, vptr->mac_regs); 919 MII_REG_BITS_ON(ADVERTISE_1000FULL | ADVERTISE_1000HALF, MII_CTRL1000, vptr->mac_regs);
920 MII_REG_BITS_ON(BMCR_SPEED1G, MII_REG_BMCR, vptr->mac_regs); 920 MII_REG_BITS_ON(BMCR_SPEED1000, MII_BMCR, vptr->mac_regs);
921 921
922 /* enable AUTO-NEGO mode */ 922 /* enable AUTO-NEGO mode */
923 mii_set_auto_on(vptr); 923 mii_set_auto_on(vptr);
@@ -952,31 +952,31 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
952 BYTE_REG_BITS_ON(TCR_TB2BDIS, &regs->TCR); 952 BYTE_REG_BITS_ON(TCR_TB2BDIS, &regs->TCR);
953 } 953 }
954 954
955 MII_REG_BITS_OFF(G1000CR_1000FD | G1000CR_1000, MII_REG_G1000CR, vptr->mac_regs); 955 MII_REG_BITS_OFF(ADVERTISE_1000FULL | ADVERTISE_1000HALF, MII_CTRL1000, vptr->mac_regs);
956 956
957 if (!(mii_status & VELOCITY_DUPLEX_FULL) && (mii_status & VELOCITY_SPEED_10)) 957 if (!(mii_status & VELOCITY_DUPLEX_FULL) && (mii_status & VELOCITY_SPEED_10))
958 BYTE_REG_BITS_OFF(TESTCFG_HBDIS, &regs->TESTCFG); 958 BYTE_REG_BITS_OFF(TESTCFG_HBDIS, &regs->TESTCFG);
959 else 959 else
960 BYTE_REG_BITS_ON(TESTCFG_HBDIS, &regs->TESTCFG); 960 BYTE_REG_BITS_ON(TESTCFG_HBDIS, &regs->TESTCFG);
961 961
962 /* MII_REG_BITS_OFF(BMCR_SPEED1G, MII_REG_BMCR, vptr->mac_regs); */ 962 /* MII_REG_BITS_OFF(BMCR_SPEED1000, MII_BMCR, vptr->mac_regs); */
963 velocity_mii_read(vptr->mac_regs, MII_REG_ANAR, &ANAR); 963 velocity_mii_read(vptr->mac_regs, MII_ADVERTISE, &ANAR);
964 ANAR &= (~(ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10)); 964 ANAR &= (~(ADVERTISE_100FULL | ADVERTISE_100HALF | ADVERTISE_10FULL | ADVERTISE_10HALF));
965 if (mii_status & VELOCITY_SPEED_100) { 965 if (mii_status & VELOCITY_SPEED_100) {
966 if (mii_status & VELOCITY_DUPLEX_FULL) 966 if (mii_status & VELOCITY_DUPLEX_FULL)
967 ANAR |= ANAR_TXFD; 967 ANAR |= ADVERTISE_100FULL;
968 else 968 else
969 ANAR |= ANAR_TX; 969 ANAR |= ADVERTISE_100HALF;
970 } else { 970 } else {
971 if (mii_status & VELOCITY_DUPLEX_FULL) 971 if (mii_status & VELOCITY_DUPLEX_FULL)
972 ANAR |= ANAR_10FD; 972 ANAR |= ADVERTISE_10FULL;
973 else 973 else
974 ANAR |= ANAR_10; 974 ANAR |= ADVERTISE_10HALF;
975 } 975 }
976 velocity_mii_write(vptr->mac_regs, MII_REG_ANAR, ANAR); 976 velocity_mii_write(vptr->mac_regs, MII_ADVERTISE, ANAR);
977 /* enable AUTO-NEGO mode */ 977 /* enable AUTO-NEGO mode */
978 mii_set_auto_on(vptr); 978 mii_set_auto_on(vptr);
979 /* MII_REG_BITS_ON(BMCR_AUTO, MII_REG_BMCR, vptr->mac_regs); */ 979 /* MII_REG_BITS_ON(BMCR_ANENABLE, MII_BMCR, vptr->mac_regs); */
980 } 980 }
981 /* vptr->mii_status=mii_check_media_mode(vptr->mac_regs); */ 981 /* vptr->mii_status=mii_check_media_mode(vptr->mac_regs); */
982 /* vptr->mii_status=check_connection_type(vptr->mac_regs); */ 982 /* vptr->mii_status=check_connection_type(vptr->mac_regs); */
@@ -1126,7 +1126,7 @@ static void velocity_set_multi(struct net_device *dev)
1126 struct mac_regs __iomem *regs = vptr->mac_regs; 1126 struct mac_regs __iomem *regs = vptr->mac_regs;
1127 u8 rx_mode; 1127 u8 rx_mode;
1128 int i; 1128 int i;
1129 struct dev_mc_list *mclist; 1129 struct netdev_hw_addr *ha;
1130 1130
1131 if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ 1131 if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
1132 writel(0xffffffff, &regs->MARCAM[0]); 1132 writel(0xffffffff, &regs->MARCAM[0]);
@@ -1142,8 +1142,8 @@ static void velocity_set_multi(struct net_device *dev)
1142 mac_get_cam_mask(regs, vptr->mCAMmask); 1142 mac_get_cam_mask(regs, vptr->mCAMmask);
1143 1143
1144 i = 0; 1144 i = 0;
1145 netdev_for_each_mc_addr(mclist, dev) { 1145 netdev_for_each_mc_addr(ha, dev) {
1146 mac_set_cam(regs, i + offset, mclist->dmi_addr); 1146 mac_set_cam(regs, i + offset, ha->addr);
1147 vptr->mCAMmask[(offset + i) / 8] |= 1 << ((offset + i) & 7); 1147 vptr->mCAMmask[(offset + i) / 8] |= 1 << ((offset + i) & 7);
1148 i++; 1148 i++;
1149 } 1149 }
@@ -1178,36 +1178,36 @@ static void mii_init(struct velocity_info *vptr, u32 mii_status)
1178 /* 1178 /*
1179 * Reset to hardware default 1179 * Reset to hardware default
1180 */ 1180 */
1181 MII_REG_BITS_OFF((ANAR_ASMDIR | ANAR_PAUSE), MII_REG_ANAR, vptr->mac_regs); 1181 MII_REG_BITS_OFF((ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP), MII_ADVERTISE, vptr->mac_regs);
1182 /* 1182 /*
1183 * Turn on ECHODIS bit in NWay-forced full mode and turn it 1183 * Turn on ECHODIS bit in NWay-forced full mode and turn it
1184 * off it in NWay-forced half mode for NWay-forced v.s. 1184 * off it in NWay-forced half mode for NWay-forced v.s.
1185 * legacy-forced issue. 1185 * legacy-forced issue.
1186 */ 1186 */
1187 if (vptr->mii_status & VELOCITY_DUPLEX_FULL) 1187 if (vptr->mii_status & VELOCITY_DUPLEX_FULL)
1188 MII_REG_BITS_ON(TCSR_ECHODIS, MII_REG_TCSR, vptr->mac_regs); 1188 MII_REG_BITS_ON(TCSR_ECHODIS, MII_SREVISION, vptr->mac_regs);
1189 else 1189 else
1190 MII_REG_BITS_OFF(TCSR_ECHODIS, MII_REG_TCSR, vptr->mac_regs); 1190 MII_REG_BITS_OFF(TCSR_ECHODIS, MII_SREVISION, vptr->mac_regs);
1191 /* 1191 /*
1192 * Turn on Link/Activity LED enable bit for CIS8201 1192 * Turn on Link/Activity LED enable bit for CIS8201
1193 */ 1193 */
1194 MII_REG_BITS_ON(PLED_LALBE, MII_REG_PLED, vptr->mac_regs); 1194 MII_REG_BITS_ON(PLED_LALBE, MII_TPISTATUS, vptr->mac_regs);
1195 break; 1195 break;
1196 case PHYID_VT3216_32BIT: 1196 case PHYID_VT3216_32BIT:
1197 case PHYID_VT3216_64BIT: 1197 case PHYID_VT3216_64BIT:
1198 /* 1198 /*
1199 * Reset to hardware default 1199 * Reset to hardware default
1200 */ 1200 */
1201 MII_REG_BITS_ON((ANAR_ASMDIR | ANAR_PAUSE), MII_REG_ANAR, vptr->mac_regs); 1201 MII_REG_BITS_ON((ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP), MII_ADVERTISE, vptr->mac_regs);
1202 /* 1202 /*
1203 * Turn on ECHODIS bit in NWay-forced full mode and turn it 1203 * Turn on ECHODIS bit in NWay-forced full mode and turn it
1204 * off it in NWay-forced half mode for NWay-forced v.s. 1204 * off it in NWay-forced half mode for NWay-forced v.s.
1205 * legacy-forced issue 1205 * legacy-forced issue
1206 */ 1206 */
1207 if (vptr->mii_status & VELOCITY_DUPLEX_FULL) 1207 if (vptr->mii_status & VELOCITY_DUPLEX_FULL)
1208 MII_REG_BITS_ON(TCSR_ECHODIS, MII_REG_TCSR, vptr->mac_regs); 1208 MII_REG_BITS_ON(TCSR_ECHODIS, MII_SREVISION, vptr->mac_regs);
1209 else 1209 else
1210 MII_REG_BITS_OFF(TCSR_ECHODIS, MII_REG_TCSR, vptr->mac_regs); 1210 MII_REG_BITS_OFF(TCSR_ECHODIS, MII_SREVISION, vptr->mac_regs);
1211 break; 1211 break;
1212 1212
1213 case PHYID_MARVELL_1000: 1213 case PHYID_MARVELL_1000:
@@ -1219,15 +1219,15 @@ static void mii_init(struct velocity_info *vptr, u32 mii_status)
1219 /* 1219 /*
1220 * Reset to hardware default 1220 * Reset to hardware default
1221 */ 1221 */
1222 MII_REG_BITS_ON((ANAR_ASMDIR | ANAR_PAUSE), MII_REG_ANAR, vptr->mac_regs); 1222 MII_REG_BITS_ON((ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP), MII_ADVERTISE, vptr->mac_regs);
1223 break; 1223 break;
1224 default: 1224 default:
1225 ; 1225 ;
1226 } 1226 }
1227 velocity_mii_read(vptr->mac_regs, MII_REG_BMCR, &BMCR); 1227 velocity_mii_read(vptr->mac_regs, MII_BMCR, &BMCR);
1228 if (BMCR & BMCR_ISO) { 1228 if (BMCR & BMCR_ISOLATE) {
1229 BMCR &= ~BMCR_ISO; 1229 BMCR &= ~BMCR_ISOLATE;
1230 velocity_mii_write(vptr->mac_regs, MII_REG_BMCR, BMCR); 1230 velocity_mii_write(vptr->mac_regs, MII_BMCR, BMCR);
1231 } 1231 }
1232} 1232}
1233 1233
@@ -2953,13 +2953,13 @@ static int velocity_set_wol(struct velocity_info *vptr)
2953 2953
2954 if (vptr->mii_status & VELOCITY_AUTONEG_ENABLE) { 2954 if (vptr->mii_status & VELOCITY_AUTONEG_ENABLE) {
2955 if (PHYID_GET_PHY_ID(vptr->phy_id) == PHYID_CICADA_CS8201) 2955 if (PHYID_GET_PHY_ID(vptr->phy_id) == PHYID_CICADA_CS8201)
2956 MII_REG_BITS_ON(AUXCR_MDPPS, MII_REG_AUXCR, vptr->mac_regs); 2956 MII_REG_BITS_ON(AUXCR_MDPPS, MII_NCONFIG, vptr->mac_regs);
2957 2957
2958 MII_REG_BITS_OFF(G1000CR_1000FD | G1000CR_1000, MII_REG_G1000CR, vptr->mac_regs); 2958 MII_REG_BITS_OFF(ADVERTISE_1000FULL | ADVERTISE_1000HALF, MII_CTRL1000, vptr->mac_regs);
2959 } 2959 }
2960 2960
2961 if (vptr->mii_status & VELOCITY_SPEED_1000) 2961 if (vptr->mii_status & VELOCITY_SPEED_1000)
2962 MII_REG_BITS_ON(BMCR_REAUTO, MII_REG_BMCR, vptr->mac_regs); 2962 MII_REG_BITS_ON(BMCR_ANRESTART, MII_BMCR, vptr->mac_regs);
2963 2963
2964 BYTE_REG_BITS_ON(CHIPGCR_FCMODE, &regs->CHIPGCR); 2964 BYTE_REG_BITS_ON(CHIPGCR_FCMODE, &regs->CHIPGCR);
2965 2965
diff --git a/drivers/net/via-velocity.h b/drivers/net/via-velocity.h
index ef4a0f64ba16..c38191179fae 100644
--- a/drivers/net/via-velocity.h
+++ b/drivers/net/via-velocity.h
@@ -1240,86 +1240,16 @@ struct velocity_context {
1240 u32 pattern[8]; 1240 u32 pattern[8];
1241}; 1241};
1242 1242
1243
1244/*
1245 * MII registers.
1246 */
1247
1248
1249/* 1243/*
1250 * Registers in the MII (offset unit is WORD) 1244 * Registers in the MII (offset unit is WORD)
1251 */ 1245 */
1252 1246
1253#define MII_REG_BMCR 0x00 // physical address
1254#define MII_REG_BMSR 0x01 //
1255#define MII_REG_PHYID1 0x02 // OUI
1256#define MII_REG_PHYID2 0x03 // OUI + Module ID + REV ID
1257#define MII_REG_ANAR 0x04 //
1258#define MII_REG_ANLPAR 0x05 //
1259#define MII_REG_G1000CR 0x09 //
1260#define MII_REG_G1000SR 0x0A //
1261#define MII_REG_MODCFG 0x10 //
1262#define MII_REG_TCSR 0x16 //
1263#define MII_REG_PLED 0x1B //
1264// NS, MYSON only
1265#define MII_REG_PCR 0x17 //
1266// ESI only
1267#define MII_REG_PCSR 0x17 //
1268#define MII_REG_AUXCR 0x1C //
1269
1270// Marvell 88E1000/88E1000S 1247// Marvell 88E1000/88E1000S
1271#define MII_REG_PSCR 0x10 // PHY specific control register 1248#define MII_REG_PSCR 0x10 // PHY specific control register
1272 1249
1273// 1250//
1274// Bits in the BMCR register 1251// Bits in the Silicon revision register
1275//
1276#define BMCR_RESET 0x8000 //
1277#define BMCR_LBK 0x4000 //
1278#define BMCR_SPEED100 0x2000 //
1279#define BMCR_AUTO 0x1000 //
1280#define BMCR_PD 0x0800 //
1281#define BMCR_ISO 0x0400 //
1282#define BMCR_REAUTO 0x0200 //
1283#define BMCR_FDX 0x0100 //
1284#define BMCR_SPEED1G 0x0040 //
1285//
1286// Bits in the BMSR register
1287//
1288#define BMSR_AUTOCM 0x0020 //
1289#define BMSR_LNK 0x0004 //
1290
1291//
1292// Bits in the ANAR register
1293//
1294#define ANAR_ASMDIR 0x0800 // Asymmetric PAUSE support
1295#define ANAR_PAUSE 0x0400 // Symmetric PAUSE Support
1296#define ANAR_T4 0x0200 //
1297#define ANAR_TXFD 0x0100 //
1298#define ANAR_TX 0x0080 //
1299#define ANAR_10FD 0x0040 //
1300#define ANAR_10 0x0020 //
1301//
1302// Bits in the ANLPAR register
1303//
1304#define ANLPAR_ASMDIR 0x0800 // Asymmetric PAUSE support
1305#define ANLPAR_PAUSE 0x0400 // Symmetric PAUSE Support
1306#define ANLPAR_T4 0x0200 //
1307#define ANLPAR_TXFD 0x0100 //
1308#define ANLPAR_TX 0x0080 //
1309#define ANLPAR_10FD 0x0040 //
1310#define ANLPAR_10 0x0020 //
1311
1312//
1313// Bits in the G1000CR register
1314//
1315#define G1000CR_1000FD 0x0200 // PHY is 1000-T Full-duplex capable
1316#define G1000CR_1000 0x0100 // PHY is 1000-T Half-duplex capable
1317
1318//
1319// Bits in the G1000SR register
1320// 1252//
1321#define G1000SR_1000FD 0x0800 // LP PHY is 1000-T Full-duplex capable
1322#define G1000SR_1000 0x0400 // LP PHY is 1000-T Half-duplex capable
1323 1253
1324#define TCSR_ECHODIS 0x2000 // 1254#define TCSR_ECHODIS 0x2000 //
1325#define AUXCR_MDPPS 0x0004 // 1255#define AUXCR_MDPPS 0x0004 //
@@ -1338,7 +1268,6 @@ struct velocity_context {
1338 1268
1339#define PHYID_REV_ID_MASK 0x0000000FUL 1269#define PHYID_REV_ID_MASK 0x0000000FUL
1340 1270
1341#define PHYID_GET_PHY_REV_ID(i) ((i) & PHYID_REV_ID_MASK)
1342#define PHYID_GET_PHY_ID(i) ((i) & ~PHYID_REV_ID_MASK) 1271#define PHYID_GET_PHY_ID(i) ((i) & ~PHYID_REV_ID_MASK)
1343 1272
1344#define MII_REG_BITS_ON(x,i,p) do {\ 1273#define MII_REG_BITS_ON(x,i,p) do {\
@@ -1362,8 +1291,8 @@ struct velocity_context {
1362 1291
1363#define MII_GET_PHY_ID(p) ({\ 1292#define MII_GET_PHY_ID(p) ({\
1364 u32 id;\ 1293 u32 id;\
1365 velocity_mii_read((p),MII_REG_PHYID2,(u16 *) &id);\ 1294 velocity_mii_read((p),MII_PHYSID2,(u16 *) &id);\
1366 velocity_mii_read((p),MII_REG_PHYID1,((u16 *) &id)+1);\ 1295 velocity_mii_read((p),MII_PHYSID1,((u16 *) &id)+1);\
1367 (id);}) 1296 (id);})
1368 1297
1369/* 1298/*
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 25dc77ccbf58..ecec9a8527f3 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -326,6 +326,7 @@ static int add_recvbuf_small(struct virtnet_info *vi, gfp_t gfp)
326 struct scatterlist sg[2]; 326 struct scatterlist sg[2];
327 int err; 327 int err;
328 328
329 sg_init_table(sg, 2);
329 skb = netdev_alloc_skb_ip_align(vi->dev, MAX_PACKET_LEN); 330 skb = netdev_alloc_skb_ip_align(vi->dev, MAX_PACKET_LEN);
330 if (unlikely(!skb)) 331 if (unlikely(!skb))
331 return -ENOMEM; 332 return -ENOMEM;
@@ -351,6 +352,7 @@ static int add_recvbuf_big(struct virtnet_info *vi, gfp_t gfp)
351 char *p; 352 char *p;
352 int i, err, offset; 353 int i, err, offset;
353 354
355 sg_init_table(sg, MAX_SKB_FRAGS + 2);
354 /* page in sg[MAX_SKB_FRAGS + 1] is list tail */ 356 /* page in sg[MAX_SKB_FRAGS + 1] is list tail */
355 for (i = MAX_SKB_FRAGS + 1; i > 1; --i) { 357 for (i = MAX_SKB_FRAGS + 1; i > 1; --i) {
356 first = get_a_page(vi, gfp); 358 first = get_a_page(vi, gfp);
@@ -719,7 +721,6 @@ static void virtnet_set_rx_mode(struct net_device *dev)
719 struct scatterlist sg[2]; 721 struct scatterlist sg[2];
720 u8 promisc, allmulti; 722 u8 promisc, allmulti;
721 struct virtio_net_ctrl_mac *mac_data; 723 struct virtio_net_ctrl_mac *mac_data;
722 struct dev_addr_list *addr;
723 struct netdev_hw_addr *ha; 724 struct netdev_hw_addr *ha;
724 int uc_count; 725 int uc_count;
725 int mc_count; 726 int mc_count;
@@ -776,8 +777,8 @@ static void virtnet_set_rx_mode(struct net_device *dev)
776 777
777 mac_data->entries = mc_count; 778 mac_data->entries = mc_count;
778 i = 0; 779 i = 0;
779 netdev_for_each_mc_addr(addr, dev) 780 netdev_for_each_mc_addr(ha, dev)
780 memcpy(&mac_data->macs[i++][0], addr->da_addr, ETH_ALEN); 781 memcpy(&mac_data->macs[i++][0], ha->addr, ETH_ALEN);
781 782
782 sg_set_buf(&sg[1], mac_data, 783 sg_set_buf(&sg[1], mac_data,
783 sizeof(mac_data->entries) + (mc_count * ETH_ALEN)); 784 sizeof(mac_data->entries) + (mc_count * ETH_ALEN));
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index cff3485d9673..58dfa367bf86 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1675,11 +1675,11 @@ vmxnet3_copy_mc(struct net_device *netdev)
1675 /* We may be called with BH disabled */ 1675 /* We may be called with BH disabled */
1676 buf = kmalloc(sz, GFP_ATOMIC); 1676 buf = kmalloc(sz, GFP_ATOMIC);
1677 if (buf) { 1677 if (buf) {
1678 struct dev_mc_list *mc; 1678 struct netdev_hw_addr *ha;
1679 int i = 0; 1679 int i = 0;
1680 1680
1681 netdev_for_each_mc_addr(mc, netdev) 1681 netdev_for_each_mc_addr(ha, netdev)
1682 memcpy(buf + i++ * ETH_ALEN, mc->dmi_addr, 1682 memcpy(buf + i++ * ETH_ALEN, ha->addr,
1683 ETH_ALEN); 1683 ETH_ALEN);
1684 } 1684 }
1685 } 1685 }
diff --git a/drivers/net/vxge/vxge-config.c b/drivers/net/vxge/vxge-config.c
index 32a75fa935ed..ec4408ceef18 100644
--- a/drivers/net/vxge/vxge-config.c
+++ b/drivers/net/vxge/vxge-config.c
@@ -356,8 +356,10 @@ __vxge_hw_device_access_rights_get(u32 host_type, u32 func_id)
356 356
357 switch (host_type) { 357 switch (host_type) {
358 case VXGE_HW_NO_MR_NO_SR_NORMAL_FUNCTION: 358 case VXGE_HW_NO_MR_NO_SR_NORMAL_FUNCTION:
359 access_rights |= VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM | 359 if (func_id == 0) {
360 VXGE_HW_DEVICE_ACCESS_RIGHT_SRPCIM; 360 access_rights |= VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM |
361 VXGE_HW_DEVICE_ACCESS_RIGHT_SRPCIM;
362 }
361 break; 363 break;
362 case VXGE_HW_MR_NO_SR_VH0_BASE_FUNCTION: 364 case VXGE_HW_MR_NO_SR_VH0_BASE_FUNCTION:
363 access_rights |= VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM | 365 access_rights |= VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM |
@@ -1217,14 +1219,13 @@ __vxge_hw_ring_mempool_item_alloc(struct vxge_hw_mempool *mempoolh,
1217} 1219}
1218 1220
1219/* 1221/*
1220 * __vxge_hw_ring_initial_replenish - Initial replenish of RxDs 1222 * __vxge_hw_ring_replenish - Initial replenish of RxDs
1221 * This function replenishes the RxDs from reserve array to work array 1223 * This function replenishes the RxDs from reserve array to work array
1222 */ 1224 */
1223enum vxge_hw_status 1225enum vxge_hw_status
1224vxge_hw_ring_replenish(struct __vxge_hw_ring *ring, u16 min_flag) 1226vxge_hw_ring_replenish(struct __vxge_hw_ring *ring)
1225{ 1227{
1226 void *rxd; 1228 void *rxd;
1227 int i = 0;
1228 struct __vxge_hw_channel *channel; 1229 struct __vxge_hw_channel *channel;
1229 enum vxge_hw_status status = VXGE_HW_OK; 1230 enum vxge_hw_status status = VXGE_HW_OK;
1230 1231
@@ -1245,11 +1246,6 @@ vxge_hw_ring_replenish(struct __vxge_hw_ring *ring, u16 min_flag)
1245 } 1246 }
1246 1247
1247 vxge_hw_ring_rxd_post(ring, rxd); 1248 vxge_hw_ring_rxd_post(ring, rxd);
1248 if (min_flag) {
1249 i++;
1250 if (i == VXGE_HW_RING_MIN_BUFF_ALLOCATION)
1251 break;
1252 }
1253 } 1249 }
1254 status = VXGE_HW_OK; 1250 status = VXGE_HW_OK;
1255exit: 1251exit:
@@ -1354,7 +1350,7 @@ __vxge_hw_ring_create(struct __vxge_hw_vpath_handle *vp,
1354 * Currently we don't have a case when the 1) is done without the 2). 1350 * Currently we don't have a case when the 1) is done without the 2).
1355 */ 1351 */
1356 if (ring->rxd_init) { 1352 if (ring->rxd_init) {
1357 status = vxge_hw_ring_replenish(ring, 1); 1353 status = vxge_hw_ring_replenish(ring);
1358 if (status != VXGE_HW_OK) { 1354 if (status != VXGE_HW_OK) {
1359 __vxge_hw_ring_delete(vp); 1355 __vxge_hw_ring_delete(vp);
1360 goto exit; 1356 goto exit;
@@ -1416,7 +1412,7 @@ enum vxge_hw_status __vxge_hw_ring_reset(struct __vxge_hw_ring *ring)
1416 goto exit; 1412 goto exit;
1417 1413
1418 if (ring->rxd_init) { 1414 if (ring->rxd_init) {
1419 status = vxge_hw_ring_replenish(ring, 1); 1415 status = vxge_hw_ring_replenish(ring);
1420 if (status != VXGE_HW_OK) 1416 if (status != VXGE_HW_OK)
1421 goto exit; 1417 goto exit;
1422 } 1418 }
diff --git a/drivers/net/vxge/vxge-config.h b/drivers/net/vxge/vxge-config.h
index e7877df092f3..01595242a6e8 100644
--- a/drivers/net/vxge/vxge-config.h
+++ b/drivers/net/vxge/vxge-config.h
@@ -1914,20 +1914,32 @@ static inline void *vxge_os_dma_malloc(struct pci_dev *pdev,
1914 gfp_t flags; 1914 gfp_t flags;
1915 void *vaddr; 1915 void *vaddr;
1916 unsigned long misaligned = 0; 1916 unsigned long misaligned = 0;
1917 int realloc_flag = 0;
1917 *p_dma_acch = *p_dmah = NULL; 1918 *p_dma_acch = *p_dmah = NULL;
1918 1919
1919 if (in_interrupt()) 1920 if (in_interrupt())
1920 flags = GFP_ATOMIC | GFP_DMA; 1921 flags = GFP_ATOMIC | GFP_DMA;
1921 else 1922 else
1922 flags = GFP_KERNEL | GFP_DMA; 1923 flags = GFP_KERNEL | GFP_DMA;
1923 1924realloc:
1924 size += VXGE_CACHE_LINE_SIZE;
1925
1926 vaddr = kmalloc((size), flags); 1925 vaddr = kmalloc((size), flags);
1927 if (vaddr == NULL) 1926 if (vaddr == NULL)
1928 return vaddr; 1927 return vaddr;
1929 misaligned = (unsigned long)VXGE_ALIGN(*((u64 *)&vaddr), 1928 misaligned = (unsigned long)VXGE_ALIGN((unsigned long)vaddr,
1930 VXGE_CACHE_LINE_SIZE); 1929 VXGE_CACHE_LINE_SIZE);
1930 if (realloc_flag)
1931 goto out;
1932
1933 if (misaligned) {
1934 /* misaligned, free current one and try allocating
1935 * size + VXGE_CACHE_LINE_SIZE memory
1936 */
1937 kfree((void *) vaddr);
1938 size += VXGE_CACHE_LINE_SIZE;
1939 realloc_flag = 1;
1940 goto realloc;
1941 }
1942out:
1931 *(unsigned long *)p_dma_acch = misaligned; 1943 *(unsigned long *)p_dma_acch = misaligned;
1932 vaddr = (void *)((u8 *)vaddr + misaligned); 1944 vaddr = (void *)((u8 *)vaddr + misaligned);
1933 return vaddr; 1945 return vaddr;
diff --git a/drivers/net/vxge/vxge-ethtool.c b/drivers/net/vxge/vxge-ethtool.c
index c6736b972635..6faa39e9d7a6 100644
--- a/drivers/net/vxge/vxge-ethtool.c
+++ b/drivers/net/vxge/vxge-ethtool.c
@@ -108,7 +108,7 @@ static void vxge_ethtool_gregs(struct net_device *dev,
108 int index, offset; 108 int index, offset;
109 enum vxge_hw_status status; 109 enum vxge_hw_status status;
110 u64 reg; 110 u64 reg;
111 u8 *reg_space = (u8 *) space; 111 u64 *reg_space = (u64 *) space;
112 struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev); 112 struct vxgedev *vdev = (struct vxgedev *)netdev_priv(dev);
113 struct __vxge_hw_device *hldev = (struct __vxge_hw_device *) 113 struct __vxge_hw_device *hldev = (struct __vxge_hw_device *)
114 pci_get_drvdata(vdev->pdev); 114 pci_get_drvdata(vdev->pdev);
@@ -128,8 +128,7 @@ static void vxge_ethtool_gregs(struct net_device *dev,
128 __func__, __LINE__); 128 __func__, __LINE__);
129 return; 129 return;
130 } 130 }
131 131 *reg_space++ = reg;
132 memcpy((reg_space + offset), &reg, 8);
133 } 132 }
134 } 133 }
135} 134}
diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c
index 46a7c9e689ec..37836a10d093 100644
--- a/drivers/net/vxge/vxge-main.c
+++ b/drivers/net/vxge/vxge-main.c
@@ -444,7 +444,7 @@ vxge_rx_1b_compl(struct __vxge_hw_ring *ringh, void *dtr,
444 ring->ndev->name, __func__, __LINE__); 444 ring->ndev->name, __func__, __LINE__);
445 ring->pkts_processed = 0; 445 ring->pkts_processed = 0;
446 446
447 vxge_hw_ring_replenish(ringh, 0); 447 vxge_hw_ring_replenish(ringh);
448 448
449 do { 449 do {
450 prefetch((char *)dtr + L1_CACHE_BYTES); 450 prefetch((char *)dtr + L1_CACHE_BYTES);
@@ -1117,7 +1117,7 @@ vxge_tx_term(void *dtrh, enum vxge_hw_txdl_state state, void *userdata)
1117 */ 1117 */
1118static void vxge_set_multicast(struct net_device *dev) 1118static void vxge_set_multicast(struct net_device *dev)
1119{ 1119{
1120 struct dev_mc_list *mclist; 1120 struct netdev_hw_addr *ha;
1121 struct vxgedev *vdev; 1121 struct vxgedev *vdev;
1122 int i, mcast_cnt = 0; 1122 int i, mcast_cnt = 0;
1123 struct __vxge_hw_device *hldev; 1123 struct __vxge_hw_device *hldev;
@@ -1217,8 +1217,8 @@ static void vxge_set_multicast(struct net_device *dev)
1217 } 1217 }
1218 1218
1219 /* Add new ones */ 1219 /* Add new ones */
1220 netdev_for_each_mc_addr(mclist, dev) { 1220 netdev_for_each_mc_addr(ha, dev) {
1221 memcpy(mac_info.macaddr, mclist->dmi_addr, ETH_ALEN); 1221 memcpy(mac_info.macaddr, ha->addr, ETH_ALEN);
1222 for (vpath_idx = 0; vpath_idx < vdev->no_of_vpath; 1222 for (vpath_idx = 0; vpath_idx < vdev->no_of_vpath;
1223 vpath_idx++) { 1223 vpath_idx++) {
1224 mac_info.vpath_no = vpath_idx; 1224 mac_info.vpath_no = vpath_idx;
@@ -1363,28 +1363,26 @@ static int vxge_set_mac_addr(struct net_device *dev, void *p)
1363void vxge_vpath_intr_enable(struct vxgedev *vdev, int vp_id) 1363void vxge_vpath_intr_enable(struct vxgedev *vdev, int vp_id)
1364{ 1364{
1365 struct vxge_vpath *vpath = &vdev->vpaths[vp_id]; 1365 struct vxge_vpath *vpath = &vdev->vpaths[vp_id];
1366 int msix_id, alarm_msix_id; 1366 int msix_id = 0;
1367 int tim_msix_id[4] = {[0 ...3] = 0}; 1367 int tim_msix_id[4] = {0, 1, 0, 0};
1368 int alarm_msix_id = VXGE_ALARM_MSIX_ID;
1368 1369
1369 vxge_hw_vpath_intr_enable(vpath->handle); 1370 vxge_hw_vpath_intr_enable(vpath->handle);
1370 1371
1371 if (vdev->config.intr_type == INTA) 1372 if (vdev->config.intr_type == INTA)
1372 vxge_hw_vpath_inta_unmask_tx_rx(vpath->handle); 1373 vxge_hw_vpath_inta_unmask_tx_rx(vpath->handle);
1373 else { 1374 else {
1374 msix_id = vp_id * VXGE_HW_VPATH_MSIX_ACTIVE;
1375 alarm_msix_id =
1376 VXGE_HW_VPATH_MSIX_ACTIVE * vdev->no_of_vpath - 2;
1377
1378 tim_msix_id[0] = msix_id;
1379 tim_msix_id[1] = msix_id + 1;
1380 vxge_hw_vpath_msix_set(vpath->handle, tim_msix_id, 1375 vxge_hw_vpath_msix_set(vpath->handle, tim_msix_id,
1381 alarm_msix_id); 1376 alarm_msix_id);
1382 1377
1378 msix_id = vpath->device_id * VXGE_HW_VPATH_MSIX_ACTIVE;
1383 vxge_hw_vpath_msix_unmask(vpath->handle, msix_id); 1379 vxge_hw_vpath_msix_unmask(vpath->handle, msix_id);
1384 vxge_hw_vpath_msix_unmask(vpath->handle, msix_id + 1); 1380 vxge_hw_vpath_msix_unmask(vpath->handle, msix_id + 1);
1385 1381
1386 /* enable the alarm vector */ 1382 /* enable the alarm vector */
1387 vxge_hw_vpath_msix_unmask(vpath->handle, alarm_msix_id); 1383 msix_id = (vpath->handle->vpath->hldev->first_vp_id *
1384 VXGE_HW_VPATH_MSIX_ACTIVE) + alarm_msix_id;
1385 vxge_hw_vpath_msix_unmask(vpath->handle, msix_id);
1388 } 1386 }
1389} 1387}
1390 1388
@@ -1405,12 +1403,13 @@ void vxge_vpath_intr_disable(struct vxgedev *vdev, int vp_id)
1405 if (vdev->config.intr_type == INTA) 1403 if (vdev->config.intr_type == INTA)
1406 vxge_hw_vpath_inta_mask_tx_rx(vpath->handle); 1404 vxge_hw_vpath_inta_mask_tx_rx(vpath->handle);
1407 else { 1405 else {
1408 msix_id = vp_id * VXGE_HW_VPATH_MSIX_ACTIVE; 1406 msix_id = vpath->device_id * VXGE_HW_VPATH_MSIX_ACTIVE;
1409 vxge_hw_vpath_msix_mask(vpath->handle, msix_id); 1407 vxge_hw_vpath_msix_mask(vpath->handle, msix_id);
1410 vxge_hw_vpath_msix_mask(vpath->handle, msix_id + 1); 1408 vxge_hw_vpath_msix_mask(vpath->handle, msix_id + 1);
1411 1409
1412 /* disable the alarm vector */ 1410 /* disable the alarm vector */
1413 msix_id = VXGE_HW_VPATH_MSIX_ACTIVE * vdev->no_of_vpath - 2; 1411 msix_id = (vpath->handle->vpath->hldev->first_vp_id *
1412 VXGE_HW_VPATH_MSIX_ACTIVE) + VXGE_ALARM_MSIX_ID;
1414 vxge_hw_vpath_msix_mask(vpath->handle, msix_id); 1413 vxge_hw_vpath_msix_mask(vpath->handle, msix_id);
1415 } 1414 }
1416} 1415}
@@ -2223,19 +2222,18 @@ vxge_alarm_msix_handle(int irq, void *dev_id)
2223 enum vxge_hw_status status; 2222 enum vxge_hw_status status;
2224 struct vxge_vpath *vpath = (struct vxge_vpath *)dev_id; 2223 struct vxge_vpath *vpath = (struct vxge_vpath *)dev_id;
2225 struct vxgedev *vdev = vpath->vdev; 2224 struct vxgedev *vdev = vpath->vdev;
2226 int alarm_msix_id = 2225 int msix_id = (vpath->handle->vpath->vp_id *
2227 VXGE_HW_VPATH_MSIX_ACTIVE * vdev->no_of_vpath - 2; 2226 VXGE_HW_VPATH_MSIX_ACTIVE) + VXGE_ALARM_MSIX_ID;
2228 2227
2229 for (i = 0; i < vdev->no_of_vpath; i++) { 2228 for (i = 0; i < vdev->no_of_vpath; i++) {
2230 vxge_hw_vpath_msix_mask(vdev->vpaths[i].handle, 2229 vxge_hw_vpath_msix_mask(vdev->vpaths[i].handle, msix_id);
2231 alarm_msix_id);
2232 2230
2233 status = vxge_hw_vpath_alarm_process(vdev->vpaths[i].handle, 2231 status = vxge_hw_vpath_alarm_process(vdev->vpaths[i].handle,
2234 vdev->exec_mode); 2232 vdev->exec_mode);
2235 if (status == VXGE_HW_OK) { 2233 if (status == VXGE_HW_OK) {
2236 2234
2237 vxge_hw_vpath_msix_unmask(vdev->vpaths[i].handle, 2235 vxge_hw_vpath_msix_unmask(vdev->vpaths[i].handle,
2238 alarm_msix_id); 2236 msix_id);
2239 continue; 2237 continue;
2240 } 2238 }
2241 vxge_debug_intr(VXGE_ERR, 2239 vxge_debug_intr(VXGE_ERR,
@@ -2248,18 +2246,17 @@ vxge_alarm_msix_handle(int irq, void *dev_id)
2248static int vxge_alloc_msix(struct vxgedev *vdev) 2246static int vxge_alloc_msix(struct vxgedev *vdev)
2249{ 2247{
2250 int j, i, ret = 0; 2248 int j, i, ret = 0;
2251 int intr_cnt = 0; 2249 int msix_intr_vect = 0, temp;
2252 int alarm_msix_id = 0, msix_intr_vect = 0;
2253 vdev->intr_cnt = 0; 2250 vdev->intr_cnt = 0;
2254 2251
2252start:
2255 /* Tx/Rx MSIX Vectors count */ 2253 /* Tx/Rx MSIX Vectors count */
2256 vdev->intr_cnt = vdev->no_of_vpath * 2; 2254 vdev->intr_cnt = vdev->no_of_vpath * 2;
2257 2255
2258 /* Alarm MSIX Vectors count */ 2256 /* Alarm MSIX Vectors count */
2259 vdev->intr_cnt++; 2257 vdev->intr_cnt++;
2260 2258
2261 intr_cnt = (vdev->max_vpath_supported * 2) + 1; 2259 vdev->entries = kzalloc(vdev->intr_cnt * sizeof(struct msix_entry),
2262 vdev->entries = kzalloc(intr_cnt * sizeof(struct msix_entry),
2263 GFP_KERNEL); 2260 GFP_KERNEL);
2264 if (!vdev->entries) { 2261 if (!vdev->entries) {
2265 vxge_debug_init(VXGE_ERR, 2262 vxge_debug_init(VXGE_ERR,
@@ -2268,8 +2265,9 @@ static int vxge_alloc_msix(struct vxgedev *vdev)
2268 return -ENOMEM; 2265 return -ENOMEM;
2269 } 2266 }
2270 2267
2271 vdev->vxge_entries = kzalloc(intr_cnt * sizeof(struct vxge_msix_entry), 2268 vdev->vxge_entries =
2272 GFP_KERNEL); 2269 kzalloc(vdev->intr_cnt * sizeof(struct vxge_msix_entry),
2270 GFP_KERNEL);
2273 if (!vdev->vxge_entries) { 2271 if (!vdev->vxge_entries) {
2274 vxge_debug_init(VXGE_ERR, "%s: memory allocation failed", 2272 vxge_debug_init(VXGE_ERR, "%s: memory allocation failed",
2275 VXGE_DRIVER_NAME); 2273 VXGE_DRIVER_NAME);
@@ -2277,9 +2275,7 @@ static int vxge_alloc_msix(struct vxgedev *vdev)
2277 return -ENOMEM; 2275 return -ENOMEM;
2278 } 2276 }
2279 2277
2280 /* Last vector in the list is used for alarm */ 2278 for (i = 0, j = 0; i < vdev->no_of_vpath; i++) {
2281 alarm_msix_id = VXGE_HW_VPATH_MSIX_ACTIVE * vdev->no_of_vpath - 2;
2282 for (i = 0, j = 0; i < vdev->max_vpath_supported; i++) {
2283 2279
2284 msix_intr_vect = i * VXGE_HW_VPATH_MSIX_ACTIVE; 2280 msix_intr_vect = i * VXGE_HW_VPATH_MSIX_ACTIVE;
2285 2281
@@ -2297,47 +2293,31 @@ static int vxge_alloc_msix(struct vxgedev *vdev)
2297 } 2293 }
2298 2294
2299 /* Initialize the alarm vector */ 2295 /* Initialize the alarm vector */
2300 vdev->entries[j].entry = alarm_msix_id; 2296 vdev->entries[j].entry = VXGE_ALARM_MSIX_ID;
2301 vdev->vxge_entries[j].entry = alarm_msix_id; 2297 vdev->vxge_entries[j].entry = VXGE_ALARM_MSIX_ID;
2302 vdev->vxge_entries[j].in_use = 0; 2298 vdev->vxge_entries[j].in_use = 0;
2303 2299
2304 ret = pci_enable_msix(vdev->pdev, vdev->entries, intr_cnt); 2300 ret = pci_enable_msix(vdev->pdev, vdev->entries, vdev->intr_cnt);
2305 /* if driver request exceeeds available irq's, request with a small
2306 * number.
2307 */
2308 if (ret > 0) {
2309 vxge_debug_init(VXGE_ERR,
2310 "%s: MSI-X enable failed for %d vectors, available: %d",
2311 VXGE_DRIVER_NAME, intr_cnt, ret);
2312 vdev->max_vpath_supported = vdev->no_of_vpath;
2313 intr_cnt = (vdev->max_vpath_supported * 2) + 1;
2314
2315 /* Reset the alarm vector setting */
2316 vdev->entries[j].entry = 0;
2317 vdev->vxge_entries[j].entry = 0;
2318
2319 /* Initialize the alarm vector with new setting */
2320 vdev->entries[intr_cnt - 1].entry = alarm_msix_id;
2321 vdev->vxge_entries[intr_cnt - 1].entry = alarm_msix_id;
2322 vdev->vxge_entries[intr_cnt - 1].in_use = 0;
2323
2324 ret = pci_enable_msix(vdev->pdev, vdev->entries, intr_cnt);
2325 if (!ret)
2326 vxge_debug_init(VXGE_ERR,
2327 "%s: MSI-X enabled for %d vectors",
2328 VXGE_DRIVER_NAME, intr_cnt);
2329 }
2330 2301
2331 if (ret) { 2302 if (ret > 0) {
2332 vxge_debug_init(VXGE_ERR, 2303 vxge_debug_init(VXGE_ERR,
2333 "%s: MSI-X enable failed for %d vectors, ret: %d", 2304 "%s: MSI-X enable failed for %d vectors, ret: %d",
2334 VXGE_DRIVER_NAME, intr_cnt, ret); 2305 VXGE_DRIVER_NAME, vdev->intr_cnt, ret);
2335 kfree(vdev->entries); 2306 kfree(vdev->entries);
2336 kfree(vdev->vxge_entries); 2307 kfree(vdev->vxge_entries);
2337 vdev->entries = NULL; 2308 vdev->entries = NULL;
2338 vdev->vxge_entries = NULL; 2309 vdev->vxge_entries = NULL;
2310
2311 if ((max_config_vpath != VXGE_USE_DEFAULT) || (ret < 3))
2312 return -ENODEV;
2313 /* Try with less no of vector by reducing no of vpaths count */
2314 temp = (ret - 1)/2;
2315 vxge_close_vpaths(vdev, temp);
2316 vdev->no_of_vpath = temp;
2317 goto start;
2318 } else if (ret < 0)
2339 return -ENODEV; 2319 return -ENODEV;
2340 } 2320
2341 return 0; 2321 return 0;
2342} 2322}
2343 2323
@@ -2345,43 +2325,26 @@ static int vxge_enable_msix(struct vxgedev *vdev)
2345{ 2325{
2346 2326
2347 int i, ret = 0; 2327 int i, ret = 0;
2348 enum vxge_hw_status status;
2349 /* 0 - Tx, 1 - Rx */ 2328 /* 0 - Tx, 1 - Rx */
2350 int tim_msix_id[4]; 2329 int tim_msix_id[4] = {0, 1, 0, 0};
2351 int alarm_msix_id = 0, msix_intr_vect = 0; 2330
2352 vdev->intr_cnt = 0; 2331 vdev->intr_cnt = 0;
2353 2332
2354 /* allocate msix vectors */ 2333 /* allocate msix vectors */
2355 ret = vxge_alloc_msix(vdev); 2334 ret = vxge_alloc_msix(vdev);
2356 if (!ret) { 2335 if (!ret) {
2357 /* Last vector in the list is used for alarm */
2358 alarm_msix_id =
2359 VXGE_HW_VPATH_MSIX_ACTIVE * vdev->no_of_vpath - 2;
2360 for (i = 0; i < vdev->no_of_vpath; i++) { 2336 for (i = 0; i < vdev->no_of_vpath; i++) {
2361 2337
2362 /* If fifo or ring are not enabled 2338 /* If fifo or ring are not enabled
2363 the MSIX vector for that should be set to 0 2339 the MSIX vector for that should be set to 0
2364 Hence initializeing this array to all 0s. 2340 Hence initializeing this array to all 0s.
2365 */ 2341 */
2366 memset(tim_msix_id, 0, sizeof(tim_msix_id)); 2342 vdev->vpaths[i].ring.rx_vector_no =
2367 msix_intr_vect = i * VXGE_HW_VPATH_MSIX_ACTIVE; 2343 (vdev->vpaths[i].device_id *
2368 tim_msix_id[0] = msix_intr_vect; 2344 VXGE_HW_VPATH_MSIX_ACTIVE) + 1;
2369
2370 tim_msix_id[1] = msix_intr_vect + 1;
2371 vdev->vpaths[i].ring.rx_vector_no = tim_msix_id[1];
2372 2345
2373 status = vxge_hw_vpath_msix_set( 2346 vxge_hw_vpath_msix_set(vdev->vpaths[i].handle,
2374 vdev->vpaths[i].handle, 2347 tim_msix_id, VXGE_ALARM_MSIX_ID);
2375 tim_msix_id, alarm_msix_id);
2376 if (status != VXGE_HW_OK) {
2377 vxge_debug_init(VXGE_ERR,
2378 "vxge_hw_vpath_msix_set "
2379 "failed with status : %x", status);
2380 kfree(vdev->entries);
2381 kfree(vdev->vxge_entries);
2382 pci_disable_msix(vdev->pdev);
2383 return -ENODEV;
2384 }
2385 } 2348 }
2386 } 2349 }
2387 2350
@@ -2392,7 +2355,7 @@ static void vxge_rem_msix_isr(struct vxgedev *vdev)
2392{ 2355{
2393 int intr_cnt; 2356 int intr_cnt;
2394 2357
2395 for (intr_cnt = 0; intr_cnt < (vdev->max_vpath_supported * 2 + 1); 2358 for (intr_cnt = 0; intr_cnt < (vdev->no_of_vpath * 2 + 1);
2396 intr_cnt++) { 2359 intr_cnt++) {
2397 if (vdev->vxge_entries[intr_cnt].in_use) { 2360 if (vdev->vxge_entries[intr_cnt].in_use) {
2398 synchronize_irq(vdev->entries[intr_cnt].vector); 2361 synchronize_irq(vdev->entries[intr_cnt].vector);
@@ -2457,9 +2420,10 @@ static int vxge_add_isr(struct vxgedev *vdev)
2457 switch (msix_idx) { 2420 switch (msix_idx) {
2458 case 0: 2421 case 0:
2459 snprintf(vdev->desc[intr_cnt], VXGE_INTR_STRLEN, 2422 snprintf(vdev->desc[intr_cnt], VXGE_INTR_STRLEN,
2460 "%s:vxge fn: %d vpath: %d Tx MSI-X: %d", 2423 "%s:vxge:MSI-X %d - Tx - fn:%d vpath:%d",
2461 vdev->ndev->name, pci_fun, vp_idx, 2424 vdev->ndev->name,
2462 vdev->entries[intr_cnt].entry); 2425 vdev->entries[intr_cnt].entry,
2426 pci_fun, vp_idx);
2463 ret = request_irq( 2427 ret = request_irq(
2464 vdev->entries[intr_cnt].vector, 2428 vdev->entries[intr_cnt].vector,
2465 vxge_tx_msix_handle, 0, 2429 vxge_tx_msix_handle, 0,
@@ -2471,9 +2435,10 @@ static int vxge_add_isr(struct vxgedev *vdev)
2471 break; 2435 break;
2472 case 1: 2436 case 1:
2473 snprintf(vdev->desc[intr_cnt], VXGE_INTR_STRLEN, 2437 snprintf(vdev->desc[intr_cnt], VXGE_INTR_STRLEN,
2474 "%s:vxge fn: %d vpath: %d Rx MSI-X: %d", 2438 "%s:vxge:MSI-X %d - Rx - fn:%d vpath:%d",
2475 vdev->ndev->name, pci_fun, vp_idx, 2439 vdev->ndev->name,
2476 vdev->entries[intr_cnt].entry); 2440 vdev->entries[intr_cnt].entry,
2441 pci_fun, vp_idx);
2477 ret = request_irq( 2442 ret = request_irq(
2478 vdev->entries[intr_cnt].vector, 2443 vdev->entries[intr_cnt].vector,
2479 vxge_rx_msix_napi_handle, 2444 vxge_rx_msix_napi_handle,
@@ -2501,9 +2466,11 @@ static int vxge_add_isr(struct vxgedev *vdev)
2501 if (irq_req) { 2466 if (irq_req) {
2502 /* We requested for this msix interrupt */ 2467 /* We requested for this msix interrupt */
2503 vdev->vxge_entries[intr_cnt].in_use = 1; 2468 vdev->vxge_entries[intr_cnt].in_use = 1;
2469 msix_idx += vdev->vpaths[vp_idx].device_id *
2470 VXGE_HW_VPATH_MSIX_ACTIVE;
2504 vxge_hw_vpath_msix_unmask( 2471 vxge_hw_vpath_msix_unmask(
2505 vdev->vpaths[vp_idx].handle, 2472 vdev->vpaths[vp_idx].handle,
2506 intr_idx); 2473 msix_idx);
2507 intr_cnt++; 2474 intr_cnt++;
2508 } 2475 }
2509 2476
@@ -2513,16 +2480,17 @@ static int vxge_add_isr(struct vxgedev *vdev)
2513 vp_idx++; 2480 vp_idx++;
2514 } 2481 }
2515 2482
2516 intr_cnt = vdev->max_vpath_supported * 2; 2483 intr_cnt = vdev->no_of_vpath * 2;
2517 snprintf(vdev->desc[intr_cnt], VXGE_INTR_STRLEN, 2484 snprintf(vdev->desc[intr_cnt], VXGE_INTR_STRLEN,
2518 "%s:vxge Alarm fn: %d MSI-X: %d", 2485 "%s:vxge:MSI-X %d - Alarm - fn:%d",
2519 vdev->ndev->name, pci_fun, 2486 vdev->ndev->name,
2520 vdev->entries[intr_cnt].entry); 2487 vdev->entries[intr_cnt].entry,
2488 pci_fun);
2521 /* For Alarm interrupts */ 2489 /* For Alarm interrupts */
2522 ret = request_irq(vdev->entries[intr_cnt].vector, 2490 ret = request_irq(vdev->entries[intr_cnt].vector,
2523 vxge_alarm_msix_handle, 0, 2491 vxge_alarm_msix_handle, 0,
2524 vdev->desc[intr_cnt], 2492 vdev->desc[intr_cnt],
2525 &vdev->vpaths[vp_idx]); 2493 &vdev->vpaths[0]);
2526 if (ret) { 2494 if (ret) {
2527 vxge_debug_init(VXGE_ERR, 2495 vxge_debug_init(VXGE_ERR,
2528 "%s: MSIX - %d Registration failed", 2496 "%s: MSIX - %d Registration failed",
@@ -2535,16 +2503,19 @@ static int vxge_add_isr(struct vxgedev *vdev)
2535 goto INTA_MODE; 2503 goto INTA_MODE;
2536 } 2504 }
2537 2505
2506 msix_idx = (vdev->vpaths[0].handle->vpath->vp_id *
2507 VXGE_HW_VPATH_MSIX_ACTIVE) + VXGE_ALARM_MSIX_ID;
2538 vxge_hw_vpath_msix_unmask(vdev->vpaths[vp_idx].handle, 2508 vxge_hw_vpath_msix_unmask(vdev->vpaths[vp_idx].handle,
2539 intr_idx - 2); 2509 msix_idx);
2540 vdev->vxge_entries[intr_cnt].in_use = 1; 2510 vdev->vxge_entries[intr_cnt].in_use = 1;
2541 vdev->vxge_entries[intr_cnt].arg = &vdev->vpaths[vp_idx]; 2511 vdev->vxge_entries[intr_cnt].arg = &vdev->vpaths[0];
2542 } 2512 }
2543INTA_MODE: 2513INTA_MODE:
2544#endif 2514#endif
2545 snprintf(vdev->desc[0], VXGE_INTR_STRLEN, "%s:vxge", vdev->ndev->name);
2546 2515
2547 if (vdev->config.intr_type == INTA) { 2516 if (vdev->config.intr_type == INTA) {
2517 snprintf(vdev->desc[0], VXGE_INTR_STRLEN,
2518 "%s:vxge:INTA", vdev->ndev->name);
2548 vxge_hw_device_set_intr_type(vdev->devh, 2519 vxge_hw_device_set_intr_type(vdev->devh,
2549 VXGE_HW_INTR_MODE_IRQLINE); 2520 VXGE_HW_INTR_MODE_IRQLINE);
2550 vxge_hw_vpath_tti_ci_set(vdev->devh, 2521 vxge_hw_vpath_tti_ci_set(vdev->devh,
@@ -4174,7 +4145,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
4174 ret = pci_enable_sriov(pdev, max_config_dev - 1); 4145 ret = pci_enable_sriov(pdev, max_config_dev - 1);
4175 if (ret) 4146 if (ret)
4176 vxge_debug_ll_config(VXGE_ERR, 4147 vxge_debug_ll_config(VXGE_ERR,
4177 "Failed to enable SRIOV: %d \n", ret); 4148 "Failed to enable SRIOV: %d\n", ret);
4178 } 4149 }
4179 4150
4180 /* 4151 /*
diff --git a/drivers/net/vxge/vxge-main.h b/drivers/net/vxge/vxge-main.h
index 7c83ba4be9d7..0441d5aa3042 100644
--- a/drivers/net/vxge/vxge-main.h
+++ b/drivers/net/vxge/vxge-main.h
@@ -31,6 +31,7 @@
31#define PCI_DEVICE_ID_TITAN_UNI 0x5833 31#define PCI_DEVICE_ID_TITAN_UNI 0x5833
32#define VXGE_USE_DEFAULT 0xffffffff 32#define VXGE_USE_DEFAULT 0xffffffff
33#define VXGE_HW_VPATH_MSIX_ACTIVE 4 33#define VXGE_HW_VPATH_MSIX_ACTIVE 4
34#define VXGE_ALARM_MSIX_ID 2
34#define VXGE_HW_RXSYNC_FREQ_CNT 4 35#define VXGE_HW_RXSYNC_FREQ_CNT 4
35#define VXGE_LL_WATCH_DOG_TIMEOUT (15 * HZ) 36#define VXGE_LL_WATCH_DOG_TIMEOUT (15 * HZ)
36#define VXGE_LL_RX_COPY_THRESHOLD 256 37#define VXGE_LL_RX_COPY_THRESHOLD 256
diff --git a/drivers/net/vxge/vxge-traffic.c b/drivers/net/vxge/vxge-traffic.c
index 2c012f4ce465..f83e6aee3f6a 100644
--- a/drivers/net/vxge/vxge-traffic.c
+++ b/drivers/net/vxge/vxge-traffic.c
@@ -231,8 +231,7 @@ void vxge_hw_channel_msix_mask(struct __vxge_hw_channel *channel, int msix_id)
231{ 231{
232 232
233 __vxge_hw_pio_mem_write32_upper( 233 __vxge_hw_pio_mem_write32_upper(
234 (u32)vxge_bVALn(vxge_mBIT(channel->first_vp_id+(msix_id/4)), 234 (u32)vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
235 0, 32),
236 &channel->common_reg->set_msix_mask_vect[msix_id%4]); 235 &channel->common_reg->set_msix_mask_vect[msix_id%4]);
237 236
238 return; 237 return;
@@ -252,8 +251,7 @@ vxge_hw_channel_msix_unmask(struct __vxge_hw_channel *channel, int msix_id)
252{ 251{
253 252
254 __vxge_hw_pio_mem_write32_upper( 253 __vxge_hw_pio_mem_write32_upper(
255 (u32)vxge_bVALn(vxge_mBIT(channel->first_vp_id+(msix_id/4)), 254 (u32)vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
256 0, 32),
257 &channel->common_reg->clear_msix_mask_vect[msix_id%4]); 255 &channel->common_reg->clear_msix_mask_vect[msix_id%4]);
258 256
259 return; 257 return;
@@ -878,7 +876,7 @@ void vxge_hw_ring_rxd_post_post(struct __vxge_hw_ring *ring, void *rxdh)
878 876
879 channel = &ring->channel; 877 channel = &ring->channel;
880 878
881 rxdp->control_0 |= VXGE_HW_RING_RXD_LIST_OWN_ADAPTER; 879 rxdp->control_0 = VXGE_HW_RING_RXD_LIST_OWN_ADAPTER;
882 880
883 if (ring->stats->common_stats.usage_cnt > 0) 881 if (ring->stats->common_stats.usage_cnt > 0)
884 ring->stats->common_stats.usage_cnt--; 882 ring->stats->common_stats.usage_cnt--;
@@ -902,7 +900,7 @@ void vxge_hw_ring_rxd_post(struct __vxge_hw_ring *ring, void *rxdh)
902 channel = &ring->channel; 900 channel = &ring->channel;
903 901
904 wmb(); 902 wmb();
905 rxdp->control_0 |= VXGE_HW_RING_RXD_LIST_OWN_ADAPTER; 903 rxdp->control_0 = VXGE_HW_RING_RXD_LIST_OWN_ADAPTER;
906 904
907 vxge_hw_channel_dtr_post(channel, rxdh); 905 vxge_hw_channel_dtr_post(channel, rxdh);
908 906
@@ -966,6 +964,7 @@ enum vxge_hw_status vxge_hw_ring_rxd_next_completed(
966 struct __vxge_hw_channel *channel; 964 struct __vxge_hw_channel *channel;
967 struct vxge_hw_ring_rxd_1 *rxdp; 965 struct vxge_hw_ring_rxd_1 *rxdp;
968 enum vxge_hw_status status = VXGE_HW_OK; 966 enum vxge_hw_status status = VXGE_HW_OK;
967 u64 control_0, own;
969 968
970 channel = &ring->channel; 969 channel = &ring->channel;
971 970
@@ -977,8 +976,12 @@ enum vxge_hw_status vxge_hw_ring_rxd_next_completed(
977 goto exit; 976 goto exit;
978 } 977 }
979 978
979 control_0 = rxdp->control_0;
980 own = control_0 & VXGE_HW_RING_RXD_LIST_OWN_ADAPTER;
981 *t_code = (u8)VXGE_HW_RING_RXD_T_CODE_GET(control_0);
982
980 /* check whether it is not the end */ 983 /* check whether it is not the end */
981 if (!(rxdp->control_0 & VXGE_HW_RING_RXD_LIST_OWN_ADAPTER)) { 984 if (!own || ((*t_code == VXGE_HW_RING_T_CODE_FRM_DROP) && own)) {
982 985
983 vxge_assert(((struct vxge_hw_ring_rxd_1 *)rxdp)->host_control != 986 vxge_assert(((struct vxge_hw_ring_rxd_1 *)rxdp)->host_control !=
984 0); 987 0);
@@ -986,8 +989,6 @@ enum vxge_hw_status vxge_hw_ring_rxd_next_completed(
986 ++ring->cmpl_cnt; 989 ++ring->cmpl_cnt;
987 vxge_hw_channel_dtr_complete(channel); 990 vxge_hw_channel_dtr_complete(channel);
988 991
989 *t_code = (u8)VXGE_HW_RING_RXD_T_CODE_GET(rxdp->control_0);
990
991 vxge_assert(*t_code != VXGE_HW_RING_RXD_T_CODE_UNUSED); 992 vxge_assert(*t_code != VXGE_HW_RING_RXD_T_CODE_UNUSED);
992 993
993 ring->stats->common_stats.usage_cnt++; 994 ring->stats->common_stats.usage_cnt++;
@@ -1035,12 +1036,13 @@ enum vxge_hw_status vxge_hw_ring_handle_tcode(
1035 * such as unknown UPV6 header), Drop it !!! 1036 * such as unknown UPV6 header), Drop it !!!
1036 */ 1037 */
1037 1038
1038 if (t_code == 0 || t_code == 5) { 1039 if (t_code == VXGE_HW_RING_T_CODE_OK ||
1040 t_code == VXGE_HW_RING_T_CODE_L3_PKT_ERR) {
1039 status = VXGE_HW_OK; 1041 status = VXGE_HW_OK;
1040 goto exit; 1042 goto exit;
1041 } 1043 }
1042 1044
1043 if (t_code > 0xF) { 1045 if (t_code > VXGE_HW_RING_T_CODE_MULTI_ERR) {
1044 status = VXGE_HW_ERR_INVALID_TCODE; 1046 status = VXGE_HW_ERR_INVALID_TCODE;
1045 goto exit; 1047 goto exit;
1046 } 1048 }
@@ -2216,29 +2218,24 @@ exit:
2216 * This API will associate a given MSIX vector numbers with the four TIM 2218 * This API will associate a given MSIX vector numbers with the four TIM
2217 * interrupts and alarm interrupt. 2219 * interrupts and alarm interrupt.
2218 */ 2220 */
2219enum vxge_hw_status 2221void
2220vxge_hw_vpath_msix_set(struct __vxge_hw_vpath_handle *vp, int *tim_msix_id, 2222vxge_hw_vpath_msix_set(struct __vxge_hw_vpath_handle *vp, int *tim_msix_id,
2221 int alarm_msix_id) 2223 int alarm_msix_id)
2222{ 2224{
2223 u64 val64; 2225 u64 val64;
2224 struct __vxge_hw_virtualpath *vpath = vp->vpath; 2226 struct __vxge_hw_virtualpath *vpath = vp->vpath;
2225 struct vxge_hw_vpath_reg __iomem *vp_reg = vpath->vp_reg; 2227 struct vxge_hw_vpath_reg __iomem *vp_reg = vpath->vp_reg;
2226 u32 first_vp_id = vpath->hldev->first_vp_id; 2228 u32 vp_id = vp->vpath->vp_id;
2227 2229
2228 val64 = VXGE_HW_INTERRUPT_CFG0_GROUP0_MSIX_FOR_TXTI( 2230 val64 = VXGE_HW_INTERRUPT_CFG0_GROUP0_MSIX_FOR_TXTI(
2229 (first_vp_id * 4) + tim_msix_id[0]) | 2231 (vp_id * 4) + tim_msix_id[0]) |
2230 VXGE_HW_INTERRUPT_CFG0_GROUP1_MSIX_FOR_TXTI( 2232 VXGE_HW_INTERRUPT_CFG0_GROUP1_MSIX_FOR_TXTI(
2231 (first_vp_id * 4) + tim_msix_id[1]) | 2233 (vp_id * 4) + tim_msix_id[1]);
2232 VXGE_HW_INTERRUPT_CFG0_GROUP2_MSIX_FOR_TXTI(
2233 (first_vp_id * 4) + tim_msix_id[2]);
2234
2235 val64 |= VXGE_HW_INTERRUPT_CFG0_GROUP3_MSIX_FOR_TXTI(
2236 (first_vp_id * 4) + tim_msix_id[3]);
2237 2234
2238 writeq(val64, &vp_reg->interrupt_cfg0); 2235 writeq(val64, &vp_reg->interrupt_cfg0);
2239 2236
2240 writeq(VXGE_HW_INTERRUPT_CFG2_ALARM_MAP_TO_MSG( 2237 writeq(VXGE_HW_INTERRUPT_CFG2_ALARM_MAP_TO_MSG(
2241 (first_vp_id * 4) + alarm_msix_id), 2238 (vpath->hldev->first_vp_id * 4) + alarm_msix_id),
2242 &vp_reg->interrupt_cfg2); 2239 &vp_reg->interrupt_cfg2);
2243 2240
2244 if (vpath->hldev->config.intr_mode == 2241 if (vpath->hldev->config.intr_mode ==
@@ -2259,7 +2256,7 @@ vxge_hw_vpath_msix_set(struct __vxge_hw_vpath_handle *vp, int *tim_msix_id,
2259 0, 32), &vp_reg->one_shot_vect3_en); 2256 0, 32), &vp_reg->one_shot_vect3_en);
2260 } 2257 }
2261 2258
2262 return VXGE_HW_OK; 2259 return;
2263} 2260}
2264 2261
2265/** 2262/**
@@ -2279,8 +2276,7 @@ vxge_hw_vpath_msix_mask(struct __vxge_hw_vpath_handle *vp, int msix_id)
2279{ 2276{
2280 struct __vxge_hw_device *hldev = vp->vpath->hldev; 2277 struct __vxge_hw_device *hldev = vp->vpath->hldev;
2281 __vxge_hw_pio_mem_write32_upper( 2278 __vxge_hw_pio_mem_write32_upper(
2282 (u32) vxge_bVALn(vxge_mBIT(hldev->first_vp_id + 2279 (u32) vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
2283 (msix_id / 4)), 0, 32),
2284 &hldev->common_reg->set_msix_mask_vect[msix_id % 4]); 2280 &hldev->common_reg->set_msix_mask_vect[msix_id % 4]);
2285 2281
2286 return; 2282 return;
@@ -2305,14 +2301,12 @@ vxge_hw_vpath_msix_clear(struct __vxge_hw_vpath_handle *vp, int msix_id)
2305 if (hldev->config.intr_mode == 2301 if (hldev->config.intr_mode ==
2306 VXGE_HW_INTR_MODE_MSIX_ONE_SHOT) { 2302 VXGE_HW_INTR_MODE_MSIX_ONE_SHOT) {
2307 __vxge_hw_pio_mem_write32_upper( 2303 __vxge_hw_pio_mem_write32_upper(
2308 (u32)vxge_bVALn(vxge_mBIT(hldev->first_vp_id + 2304 (u32)vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
2309 (msix_id/4)), 0, 32),
2310 &hldev->common_reg-> 2305 &hldev->common_reg->
2311 clr_msix_one_shot_vec[msix_id%4]); 2306 clr_msix_one_shot_vec[msix_id%4]);
2312 } else { 2307 } else {
2313 __vxge_hw_pio_mem_write32_upper( 2308 __vxge_hw_pio_mem_write32_upper(
2314 (u32)vxge_bVALn(vxge_mBIT(hldev->first_vp_id + 2309 (u32)vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
2315 (msix_id/4)), 0, 32),
2316 &hldev->common_reg-> 2310 &hldev->common_reg->
2317 clear_msix_mask_vect[msix_id%4]); 2311 clear_msix_mask_vect[msix_id%4]);
2318 } 2312 }
@@ -2337,8 +2331,7 @@ vxge_hw_vpath_msix_unmask(struct __vxge_hw_vpath_handle *vp, int msix_id)
2337{ 2331{
2338 struct __vxge_hw_device *hldev = vp->vpath->hldev; 2332 struct __vxge_hw_device *hldev = vp->vpath->hldev;
2339 __vxge_hw_pio_mem_write32_upper( 2333 __vxge_hw_pio_mem_write32_upper(
2340 (u32)vxge_bVALn(vxge_mBIT(hldev->first_vp_id + 2334 (u32)vxge_bVALn(vxge_mBIT(msix_id >> 2), 0, 32),
2341 (msix_id/4)), 0, 32),
2342 &hldev->common_reg->clear_msix_mask_vect[msix_id%4]); 2335 &hldev->common_reg->clear_msix_mask_vect[msix_id%4]);
2343 2336
2344 return; 2337 return;
diff --git a/drivers/net/vxge/vxge-traffic.h b/drivers/net/vxge/vxge-traffic.h
index 861c853e3e84..c252f3d3f650 100644
--- a/drivers/net/vxge/vxge-traffic.h
+++ b/drivers/net/vxge/vxge-traffic.h
@@ -1866,6 +1866,51 @@ struct vxge_hw_ring_rxd_info {
1866 u32 rth_hash_type; 1866 u32 rth_hash_type;
1867 u32 rth_value; 1867 u32 rth_value;
1868}; 1868};
1869/**
1870 * enum vxge_hw_ring_tcode - Transfer codes returned by adapter
1871 * @VXGE_HW_RING_T_CODE_OK: Transfer ok.
1872 * @VXGE_HW_RING_T_CODE_L3_CKSUM_MISMATCH: Layer 3 checksum presentation
1873 * configuration mismatch.
1874 * @VXGE_HW_RING_T_CODE_L4_CKSUM_MISMATCH: Layer 4 checksum presentation
1875 * configuration mismatch.
1876 * @VXGE_HW_RING_T_CODE_L3_L4_CKSUM_MISMATCH: Layer 3 and Layer 4 checksum
1877 * presentation configuration mismatch.
1878 * @VXGE_HW_RING_T_CODE_L3_PKT_ERR: Layer 3 error unparseable packet,
1879 * such as unknown IPv6 header.
1880 * @VXGE_HW_RING_T_CODE_L2_FRM_ERR: Layer 2 error frame integrity
1881 * error, such as FCS or ECC).
1882 * @VXGE_HW_RING_T_CODE_BUF_SIZE_ERR: Buffer size error the RxD buffer(
1883 * s) were not appropriately sized and data loss occurred.
1884 * @VXGE_HW_RING_T_CODE_INT_ECC_ERR: Internal ECC error RxD corrupted.
1885 * @VXGE_HW_RING_T_CODE_BENIGN_OVFLOW: Benign overflow the contents of
1886 * Segment1 exceeded the capacity of Buffer1 and the remainder
1887 * was placed in Buffer2. Segment2 now starts in Buffer3.
1888 * No data loss or errors occurred.
1889 * @VXGE_HW_RING_T_CODE_ZERO_LEN_BUFF: Buffer size 0 one of the RxDs
1890 * assigned buffers has a size of 0 bytes.
1891 * @VXGE_HW_RING_T_CODE_FRM_DROP: Frame dropped either due to
1892 * VPath Reset or because of a VPIN mismatch.
1893 * @VXGE_HW_RING_T_CODE_UNUSED: Unused
1894 * @VXGE_HW_RING_T_CODE_MULTI_ERR: Multiple errors more than one
1895 * transfer code condition occurred.
1896 *
1897 * Transfer codes returned by adapter.
1898 */
1899enum vxge_hw_ring_tcode {
1900 VXGE_HW_RING_T_CODE_OK = 0x0,
1901 VXGE_HW_RING_T_CODE_L3_CKSUM_MISMATCH = 0x1,
1902 VXGE_HW_RING_T_CODE_L4_CKSUM_MISMATCH = 0x2,
1903 VXGE_HW_RING_T_CODE_L3_L4_CKSUM_MISMATCH = 0x3,
1904 VXGE_HW_RING_T_CODE_L3_PKT_ERR = 0x5,
1905 VXGE_HW_RING_T_CODE_L2_FRM_ERR = 0x6,
1906 VXGE_HW_RING_T_CODE_BUF_SIZE_ERR = 0x7,
1907 VXGE_HW_RING_T_CODE_INT_ECC_ERR = 0x8,
1908 VXGE_HW_RING_T_CODE_BENIGN_OVFLOW = 0x9,
1909 VXGE_HW_RING_T_CODE_ZERO_LEN_BUFF = 0xA,
1910 VXGE_HW_RING_T_CODE_FRM_DROP = 0xC,
1911 VXGE_HW_RING_T_CODE_UNUSED = 0xE,
1912 VXGE_HW_RING_T_CODE_MULTI_ERR = 0xF
1913};
1869 1914
1870/** 1915/**
1871 * enum enum vxge_hw_ring_hash_type - RTH hash types 1916 * enum enum vxge_hw_ring_hash_type - RTH hash types
@@ -1910,7 +1955,7 @@ vxge_hw_ring_rxd_post_post(
1910 void *rxdh); 1955 void *rxdh);
1911 1956
1912enum vxge_hw_status 1957enum vxge_hw_status
1913vxge_hw_ring_replenish(struct __vxge_hw_ring *ring_handle, u16 min_flag); 1958vxge_hw_ring_replenish(struct __vxge_hw_ring *ring_handle);
1914 1959
1915void 1960void
1916vxge_hw_ring_rxd_post_post_wmb( 1961vxge_hw_ring_rxd_post_post_wmb(
@@ -2042,7 +2087,6 @@ void vxge_hw_fifo_txdl_free(
2042 2087
2043#define VXGE_HW_RING_NEXT_BLOCK_POINTER_OFFSET (VXGE_HW_BLOCK_SIZE-8) 2088#define VXGE_HW_RING_NEXT_BLOCK_POINTER_OFFSET (VXGE_HW_BLOCK_SIZE-8)
2044#define VXGE_HW_RING_MEMBLOCK_IDX_OFFSET (VXGE_HW_BLOCK_SIZE-16) 2089#define VXGE_HW_RING_MEMBLOCK_IDX_OFFSET (VXGE_HW_BLOCK_SIZE-16)
2045#define VXGE_HW_RING_MIN_BUFF_ALLOCATION 64
2046 2090
2047/* 2091/*
2048 * struct __vxge_hw_ring_rxd_priv - Receive descriptor HW-private data. 2092 * struct __vxge_hw_ring_rxd_priv - Receive descriptor HW-private data.
@@ -2332,7 +2376,7 @@ enum vxge_hw_status vxge_hw_vpath_alarm_process(
2332 struct __vxge_hw_vpath_handle *vpath_handle, 2376 struct __vxge_hw_vpath_handle *vpath_handle,
2333 u32 skip_alarms); 2377 u32 skip_alarms);
2334 2378
2335enum vxge_hw_status 2379void
2336vxge_hw_vpath_msix_set(struct __vxge_hw_vpath_handle *vpath_handle, 2380vxge_hw_vpath_msix_set(struct __vxge_hw_vpath_handle *vpath_handle,
2337 int *tim_msix_id, int alarm_msix_id); 2381 int *tim_msix_id, int alarm_msix_id);
2338 2382
diff --git a/drivers/net/vxge/vxge-version.h b/drivers/net/vxge/vxge-version.h
index 77c2a754b7b8..487513900182 100644
--- a/drivers/net/vxge/vxge-version.h
+++ b/drivers/net/vxge/vxge-version.h
@@ -17,7 +17,7 @@
17 17
18#define VXGE_VERSION_MAJOR "2" 18#define VXGE_VERSION_MAJOR "2"
19#define VXGE_VERSION_MINOR "0" 19#define VXGE_VERSION_MINOR "0"
20#define VXGE_VERSION_FIX "6" 20#define VXGE_VERSION_FIX "7"
21#define VXGE_VERSION_BUILD "18937" 21#define VXGE_VERSION_BUILD "20144"
22#define VXGE_VERSION_FOR "k" 22#define VXGE_VERSION_FOR "k"
23#endif 23#endif
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index f4f1c00d0d23..cb72cc7a1e86 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -395,7 +395,7 @@ static void tx1_dma_buf_check(pc300_t * card, int ch)
395 u16 next_bd = card->chan[ch].tx_next_bd; 395 u16 next_bd = card->chan[ch].tx_next_bd;
396 u32 scabase = card->hw.scabase; 396 u32 scabase = card->hw.scabase;
397 397
398 printk ("\nnfree_tx_bd = %d \n", card->chan[ch].nfree_tx_bd); 398 printk ("\nnfree_tx_bd = %d\n", card->chan[ch].nfree_tx_bd);
399 printk("#CH%d: f_bd = %d(0x%08x), n_bd = %d(0x%08x)\n", ch, 399 printk("#CH%d: f_bd = %d(0x%08x), n_bd = %d(0x%08x)\n", ch,
400 first_bd, TX_BD_ADDR(ch, first_bd), 400 first_bd, TX_BD_ADDR(ch, first_bd),
401 next_bd, TX_BD_ADDR(ch, next_bd)); 401 next_bd, TX_BD_ADDR(ch, next_bd));
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index 4917a94943bd..4293889e287e 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -366,7 +366,7 @@ static void cpc_tty_close(struct tty_struct *tty, struct file *flip)
366 int res; 366 int res;
367 367
368 if (!tty || !tty->driver_data ) { 368 if (!tty || !tty->driver_data ) {
369 CPC_TTY_DBG("hdlx-tty: no TTY in close \n"); 369 CPC_TTY_DBG("hdlx-tty: no TTY in close\n");
370 return; 370 return;
371 } 371 }
372 372
diff --git a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c
index 31c41af2246d..43ae6f440bfb 100644
--- a/drivers/net/wan/sdla.c
+++ b/drivers/net/wan/sdla.c
@@ -1352,7 +1352,7 @@ static int sdla_set_config(struct net_device *dev, struct ifmap *map)
1352 return(-EINVAL); 1352 return(-EINVAL);
1353 1353
1354 if (!request_region(map->base_addr, SDLA_IO_EXTENTS, dev->name)){ 1354 if (!request_region(map->base_addr, SDLA_IO_EXTENTS, dev->name)){
1355 printk(KERN_WARNING "SDLA: io-port 0x%04lx in use \n", dev->base_addr); 1355 printk(KERN_WARNING "SDLA: io-port 0x%04lx in use\n", dev->base_addr);
1356 return(-EINVAL); 1356 return(-EINVAL);
1357 } 1357 }
1358 base = map->base_addr; 1358 base = map->base_addr;
diff --git a/drivers/net/wimax/i2400m/tx.c b/drivers/net/wimax/i2400m/tx.c
index 54480e8947f1..38f9c921f3e8 100644
--- a/drivers/net/wimax/i2400m/tx.c
+++ b/drivers/net/wimax/i2400m/tx.c
@@ -688,7 +688,7 @@ try_new:
688 pl_type, buf_len); 688 pl_type, buf_len);
689 tx_msg->num_pls = le16_to_cpu(num_pls+1); 689 tx_msg->num_pls = le16_to_cpu(num_pls+1);
690 tx_msg->size += padded_len; 690 tx_msg->size += padded_len;
691 d_printf(2, dev, "TX: appended %zu b (up to %u b) pl #%u \n", 691 d_printf(2, dev, "TX: appended %zu b (up to %u b) pl #%u\n",
692 padded_len, tx_msg->size, num_pls+1); 692 padded_len, tx_msg->size, num_pls+1);
693 d_printf(2, dev, 693 d_printf(2, dev,
694 "TX: appended hdr @%zu %zu b pl #%u @%zu %zu/%zu b\n", 694 "TX: appended hdr @%zu %zu b pl #%u @%zu %zu/%zu b\n",
diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c
index 547912e6843f..2277998b7264 100644
--- a/drivers/net/wireless/adm8211.c
+++ b/drivers/net/wireless/adm8211.c
@@ -1317,21 +1317,19 @@ static void adm8211_bss_info_changed(struct ieee80211_hw *dev,
1317} 1317}
1318 1318
1319static u64 adm8211_prepare_multicast(struct ieee80211_hw *hw, 1319static u64 adm8211_prepare_multicast(struct ieee80211_hw *hw,
1320 int mc_count, struct dev_addr_list *mclist) 1320 struct netdev_hw_addr_list *mc_list)
1321{ 1321{
1322 unsigned int bit_nr, i; 1322 unsigned int bit_nr;
1323 u32 mc_filter[2]; 1323 u32 mc_filter[2];
1324 struct netdev_hw_addr *ha;
1324 1325
1325 mc_filter[1] = mc_filter[0] = 0; 1326 mc_filter[1] = mc_filter[0] = 0;
1326 1327
1327 for (i = 0; i < mc_count; i++) { 1328 netdev_hw_addr_list_for_each(ha, mc_list) {
1328 if (!mclist) 1329 bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
1329 break;
1330 bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
1331 1330
1332 bit_nr &= 0x3F; 1331 bit_nr &= 0x3F;
1333 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); 1332 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
1334 mclist = mclist->next;
1335 } 1333 }
1336 1334
1337 return mc_filter[0] | ((u64)(mc_filter[1]) << 32); 1335 return mc_filter[0] | ((u64)(mc_filter[1]) << 32);
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index dc5018a6d9ed..a441aad922c2 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2876,7 +2876,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2876 ai->wep_capable = (cap_rid.softCap & cpu_to_le16(0x02)) ? 1 : 0; 2876 ai->wep_capable = (cap_rid.softCap & cpu_to_le16(0x02)) ? 1 : 0;
2877 ai->max_wep_idx = (cap_rid.softCap & cpu_to_le16(0x80)) ? 3 : 0; 2877 ai->max_wep_idx = (cap_rid.softCap & cpu_to_le16(0x80)) ? 3 : 0;
2878 2878
2879 airo_print_info(dev->name, "Firmware version %x.%x.%02x", 2879 airo_print_info(dev->name, "Firmware version %x.%x.%02d",
2880 ((le16_to_cpu(cap_rid.softVer) >> 8) & 0xF), 2880 ((le16_to_cpu(cap_rid.softVer) >> 8) & 0xF),
2881 (le16_to_cpu(cap_rid.softVer) & 0xFF), 2881 (le16_to_cpu(cap_rid.softVer) & 0xFF),
2882 le16_to_cpu(cap_rid.softSubVer)); 2882 le16_to_cpu(cap_rid.softSubVer));
@@ -3193,19 +3193,26 @@ static void airo_print_status(const char *devname, u16 status)
3193{ 3193{
3194 u8 reason = status & 0xFF; 3194 u8 reason = status & 0xFF;
3195 3195
3196 switch (status) { 3196 switch (status & 0xFF00) {
3197 case STAT_NOBEACON: 3197 case STAT_NOBEACON:
3198 airo_print_dbg(devname, "link lost (missed beacons)"); 3198 switch (status) {
3199 break; 3199 case STAT_NOBEACON:
3200 case STAT_MAXRETRIES: 3200 airo_print_dbg(devname, "link lost (missed beacons)");
3201 case STAT_MAXARL: 3201 break;
3202 airo_print_dbg(devname, "link lost (max retries)"); 3202 case STAT_MAXRETRIES:
3203 break; 3203 case STAT_MAXARL:
3204 case STAT_FORCELOSS: 3204 airo_print_dbg(devname, "link lost (max retries)");
3205 airo_print_dbg(devname, "link lost (local choice)"); 3205 break;
3206 break; 3206 case STAT_FORCELOSS:
3207 case STAT_TSFSYNC: 3207 airo_print_dbg(devname, "link lost (local choice)");
3208 airo_print_dbg(devname, "link lost (TSF sync lost)"); 3208 break;
3209 case STAT_TSFSYNC:
3210 airo_print_dbg(devname, "link lost (TSF sync lost)");
3211 break;
3212 default:
3213 airo_print_dbg(devname, "unknow status %x\n", status);
3214 break;
3215 }
3209 break; 3216 break;
3210 case STAT_DEAUTH: 3217 case STAT_DEAUTH:
3211 airo_print_dbg(devname, "deauthenticated (reason: %d)", reason); 3218 airo_print_dbg(devname, "deauthenticated (reason: %d)", reason);
@@ -3221,7 +3228,11 @@ static void airo_print_status(const char *devname, u16 status)
3221 airo_print_dbg(devname, "authentication failed (reason: %d)", 3228 airo_print_dbg(devname, "authentication failed (reason: %d)",
3222 reason); 3229 reason);
3223 break; 3230 break;
3231 case STAT_ASSOC:
3232 case STAT_REASSOC:
3233 break;
3224 default: 3234 default:
3235 airo_print_dbg(devname, "unknow status %x\n", status);
3225 break; 3236 break;
3226 } 3237 }
3227} 3238}
diff --git a/drivers/net/wireless/ath/Kconfig b/drivers/net/wireless/ath/Kconfig
index 4e7a7fd695c8..0a75be027afa 100644
--- a/drivers/net/wireless/ath/Kconfig
+++ b/drivers/net/wireless/ath/Kconfig
@@ -3,7 +3,7 @@ menuconfig ATH_COMMON
3 depends on CFG80211 3 depends on CFG80211
4 ---help--- 4 ---help---
5 This will enable the support for the Atheros wireless drivers. 5 This will enable the support for the Atheros wireless drivers.
6 ath5k, ath9k and ar9170 drivers share some common code, this option 6 ath5k, ath9k, ath9k_htc and ar9170 drivers share some common code, this option
7 enables the common ath.ko module which shares common helpers. 7 enables the common ath.ko module which shares common helpers.
8 8
9 For more information and documentation on this module you can visit: 9 For more information and documentation on this module you can visit:
diff --git a/drivers/net/wireless/ath/ar9170/main.c b/drivers/net/wireless/ath/ar9170/main.c
index 257c734733d1..b43d4b006d7e 100644
--- a/drivers/net/wireless/ath/ar9170/main.c
+++ b/drivers/net/wireless/ath/ar9170/main.c
@@ -2045,21 +2045,17 @@ out:
2045 return err; 2045 return err;
2046} 2046}
2047 2047
2048static u64 ar9170_op_prepare_multicast(struct ieee80211_hw *hw, int mc_count, 2048static u64 ar9170_op_prepare_multicast(struct ieee80211_hw *hw,
2049 struct dev_addr_list *mclist) 2049 struct netdev_hw_addr_list *mc_list)
2050{ 2050{
2051 u64 mchash; 2051 u64 mchash;
2052 int i; 2052 struct netdev_hw_addr *ha;
2053 2053
2054 /* always get broadcast frames */ 2054 /* always get broadcast frames */
2055 mchash = 1ULL << (0xff >> 2); 2055 mchash = 1ULL << (0xff >> 2);
2056 2056
2057 for (i = 0; i < mc_count; i++) { 2057 netdev_hw_addr_list_for_each(ha, mc_list)
2058 if (WARN_ON(!mclist)) 2058 mchash |= 1ULL << (ha->addr[5] >> 2);
2059 break;
2060 mchash |= 1ULL << (mclist->dmi_addr[5] >> 2);
2061 mclist = mclist->next;
2062 }
2063 2059
2064 return mchash; 2060 return mchash;
2065} 2061}
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index ac67f02e26d8..1d7491c85460 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -202,7 +202,6 @@
202#define AR5K_TUNE_MAX_TXPOWER 63 202#define AR5K_TUNE_MAX_TXPOWER 63
203#define AR5K_TUNE_DEFAULT_TXPOWER 25 203#define AR5K_TUNE_DEFAULT_TXPOWER 25
204#define AR5K_TUNE_TPC_TXPOWER false 204#define AR5K_TUNE_TPC_TXPOWER false
205#define AR5K_TUNE_HWTXTRIES 4
206 205
207#define AR5K_INIT_CARR_SENSE_EN 1 206#define AR5K_INIT_CARR_SENSE_EN 1
208 207
@@ -614,28 +613,6 @@ struct ath5k_rx_status {
614#define AR5K_BEACON_ENA 0x00800000 /*enable beacon xmit*/ 613#define AR5K_BEACON_ENA 0x00800000 /*enable beacon xmit*/
615#define AR5K_BEACON_RESET_TSF 0x01000000 /*force a TSF reset*/ 614#define AR5K_BEACON_RESET_TSF 0x01000000 /*force a TSF reset*/
616 615
617#if 0
618/**
619 * struct ath5k_beacon_state - Per-station beacon timer state.
620 * @bs_interval: in TU's, can also include the above flags
621 * @bs_cfp_max_duration: if non-zero hw is setup to coexist with a
622 * Point Coordination Function capable AP
623 */
624struct ath5k_beacon_state {
625 u32 bs_next_beacon;
626 u32 bs_next_dtim;
627 u32 bs_interval;
628 u8 bs_dtim_period;
629 u8 bs_cfp_period;
630 u16 bs_cfp_max_duration;
631 u16 bs_cfp_du_remain;
632 u16 bs_tim_offset;
633 u16 bs_sleep_duration;
634 u16 bs_bmiss_threshold;
635 u32 bs_cfp_next;
636};
637#endif
638
639 616
640/* 617/*
641 * TSF to TU conversion: 618 * TSF to TU conversion:
@@ -1028,7 +1005,6 @@ struct ath5k_nfcal_hist
1028 1005
1029/* TODO: Clean up and merge with ath5k_softc */ 1006/* TODO: Clean up and merge with ath5k_softc */
1030struct ath5k_hw { 1007struct ath5k_hw {
1031 u32 ah_magic;
1032 struct ath_common common; 1008 struct ath_common common;
1033 1009
1034 struct ath5k_softc *ah_sc; 1010 struct ath5k_softc *ah_sc;
@@ -1036,7 +1012,6 @@ struct ath5k_hw {
1036 1012
1037 enum ath5k_int ah_imr; 1013 enum ath5k_int ah_imr;
1038 1014
1039 enum nl80211_iftype ah_op_mode;
1040 struct ieee80211_channel *ah_current_channel; 1015 struct ieee80211_channel *ah_current_channel;
1041 bool ah_turbo; 1016 bool ah_turbo;
1042 bool ah_calibration; 1017 bool ah_calibration;
@@ -1049,7 +1024,6 @@ struct ath5k_hw {
1049 u32 ah_phy; 1024 u32 ah_phy;
1050 u32 ah_mac_srev; 1025 u32 ah_mac_srev;
1051 u16 ah_mac_version; 1026 u16 ah_mac_version;
1052 u16 ah_mac_revision;
1053 u16 ah_phy_revision; 1027 u16 ah_phy_revision;
1054 u16 ah_radio_5ghz_revision; 1028 u16 ah_radio_5ghz_revision;
1055 u16 ah_radio_2ghz_revision; 1029 u16 ah_radio_2ghz_revision;
@@ -1071,8 +1045,6 @@ struct ath5k_hw {
1071 u8 ah_def_ant; 1045 u8 ah_def_ant;
1072 bool ah_software_retry; 1046 bool ah_software_retry;
1073 1047
1074 int ah_gpio_npins;
1075
1076 struct ath5k_capabilities ah_capabilities; 1048 struct ath5k_capabilities ah_capabilities;
1077 1049
1078 struct ath5k_txq_info ah_txq[AR5K_NUM_TX_QUEUES]; 1050 struct ath5k_txq_info ah_txq[AR5K_NUM_TX_QUEUES];
@@ -1141,9 +1113,9 @@ struct ath5k_hw {
1141 int (*ah_setup_rx_desc)(struct ath5k_hw *ah, struct ath5k_desc *desc, 1113 int (*ah_setup_rx_desc)(struct ath5k_hw *ah, struct ath5k_desc *desc,
1142 u32 size, unsigned int flags); 1114 u32 size, unsigned int flags);
1143 int (*ah_setup_tx_desc)(struct ath5k_hw *, struct ath5k_desc *, 1115 int (*ah_setup_tx_desc)(struct ath5k_hw *, struct ath5k_desc *,
1144 unsigned int, unsigned int, enum ath5k_pkt_type, unsigned int, 1116 unsigned int, unsigned int, int, enum ath5k_pkt_type,
1145 unsigned int, unsigned int, unsigned int, unsigned int, 1117 unsigned int, unsigned int, unsigned int, unsigned int,
1146 unsigned int, unsigned int, unsigned int); 1118 unsigned int, unsigned int, unsigned int, unsigned int);
1147 int (*ah_setup_mrr_tx_desc)(struct ath5k_hw *, struct ath5k_desc *, 1119 int (*ah_setup_mrr_tx_desc)(struct ath5k_hw *, struct ath5k_desc *,
1148 unsigned int, unsigned int, unsigned int, unsigned int, 1120 unsigned int, unsigned int, unsigned int, unsigned int,
1149 unsigned int, unsigned int); 1121 unsigned int, unsigned int);
@@ -1158,158 +1130,147 @@ struct ath5k_hw {
1158 */ 1130 */
1159 1131
1160/* Attach/Detach Functions */ 1132/* Attach/Detach Functions */
1161extern int ath5k_hw_attach(struct ath5k_softc *sc); 1133int ath5k_hw_attach(struct ath5k_softc *sc);
1162extern void ath5k_hw_detach(struct ath5k_hw *ah); 1134void ath5k_hw_detach(struct ath5k_hw *ah);
1163 1135
1164/* LED functions */ 1136/* LED functions */
1165extern int ath5k_init_leds(struct ath5k_softc *sc); 1137int ath5k_init_leds(struct ath5k_softc *sc);
1166extern void ath5k_led_enable(struct ath5k_softc *sc); 1138void ath5k_led_enable(struct ath5k_softc *sc);
1167extern void ath5k_led_off(struct ath5k_softc *sc); 1139void ath5k_led_off(struct ath5k_softc *sc);
1168extern void ath5k_unregister_leds(struct ath5k_softc *sc); 1140void ath5k_unregister_leds(struct ath5k_softc *sc);
1169 1141
1170/* Reset Functions */ 1142/* Reset Functions */
1171extern int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial); 1143int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial);
1172extern int ath5k_hw_on_hold(struct ath5k_hw *ah); 1144int ath5k_hw_on_hold(struct ath5k_hw *ah);
1173extern int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, struct ieee80211_channel *channel, bool change_channel); 1145int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1146 struct ieee80211_channel *channel, bool change_channel);
1147int ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, u32 val,
1148 bool is_set);
1174/* Power management functions */ 1149/* Power management functions */
1175extern int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, bool set_chip, u16 sleep_duration);
1176 1150
1177/* DMA Related Functions */ 1151/* DMA Related Functions */
1178extern void ath5k_hw_start_rx_dma(struct ath5k_hw *ah); 1152void ath5k_hw_start_rx_dma(struct ath5k_hw *ah);
1179extern int ath5k_hw_stop_rx_dma(struct ath5k_hw *ah); 1153int ath5k_hw_stop_rx_dma(struct ath5k_hw *ah);
1180extern u32 ath5k_hw_get_rxdp(struct ath5k_hw *ah); 1154u32 ath5k_hw_get_rxdp(struct ath5k_hw *ah);
1181extern void ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr); 1155void ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr);
1182extern int ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue); 1156int ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue);
1183extern int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue); 1157int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue);
1184extern u32 ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue); 1158u32 ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue);
1185extern int ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue, 1159int ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue,
1186 u32 phys_addr); 1160 u32 phys_addr);
1187extern int ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase); 1161int ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase);
1188/* Interrupt handling */ 1162/* Interrupt handling */
1189extern bool ath5k_hw_is_intr_pending(struct ath5k_hw *ah); 1163bool ath5k_hw_is_intr_pending(struct ath5k_hw *ah);
1190extern int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask); 1164int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask);
1191extern enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum 1165enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask);
1192ath5k_int new_mask); 1166void ath5k_hw_update_mib_counters(struct ath5k_hw *ah,
1193extern void ath5k_hw_update_mib_counters(struct ath5k_hw *ah, struct ieee80211_low_level_stats *stats); 1167 struct ieee80211_low_level_stats *stats);
1194 1168
1195/* EEPROM access functions */ 1169/* EEPROM access functions */
1196extern int ath5k_eeprom_init(struct ath5k_hw *ah); 1170int ath5k_eeprom_init(struct ath5k_hw *ah);
1197extern void ath5k_eeprom_detach(struct ath5k_hw *ah); 1171void ath5k_eeprom_detach(struct ath5k_hw *ah);
1198extern int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac); 1172int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac);
1199extern bool ath5k_eeprom_is_hb63(struct ath5k_hw *ah);
1200 1173
1201/* Protocol Control Unit Functions */ 1174/* Protocol Control Unit Functions */
1202extern int ath5k_hw_set_opmode(struct ath5k_hw *ah); 1175extern int ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype opmode);
1203extern void ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class); 1176void ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class);
1204/* BSSID Functions */ 1177/* BSSID Functions */
1205extern int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac); 1178int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac);
1206extern void ath5k_hw_set_associd(struct ath5k_hw *ah); 1179void ath5k_hw_set_associd(struct ath5k_hw *ah);
1207extern void ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask); 1180void ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask);
1208/* Receive start/stop functions */ 1181/* Receive start/stop functions */
1209extern void ath5k_hw_start_rx_pcu(struct ath5k_hw *ah); 1182void ath5k_hw_start_rx_pcu(struct ath5k_hw *ah);
1210extern void ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah); 1183void ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah);
1211/* RX Filter functions */ 1184/* RX Filter functions */
1212extern void ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1); 1185void ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1);
1213extern int ath5k_hw_set_mcast_filter_idx(struct ath5k_hw *ah, u32 index); 1186u32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah);
1214extern int ath5k_hw_clear_mcast_filter_idx(struct ath5k_hw *ah, u32 index); 1187void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter);
1215extern u32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah);
1216extern void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter);
1217/* Beacon control functions */ 1188/* Beacon control functions */
1218extern u32 ath5k_hw_get_tsf32(struct ath5k_hw *ah); 1189u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah);
1219extern u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah); 1190void ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64);
1220extern void ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64); 1191void ath5k_hw_reset_tsf(struct ath5k_hw *ah);
1221extern void ath5k_hw_reset_tsf(struct ath5k_hw *ah); 1192void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval);
1222extern void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval);
1223#if 0
1224extern int ath5k_hw_set_beacon_timers(struct ath5k_hw *ah, const struct ath5k_beacon_state *state);
1225extern void ath5k_hw_reset_beacon(struct ath5k_hw *ah);
1226extern int ath5k_hw_beaconq_finish(struct ath5k_hw *ah, unsigned long phys_addr);
1227#endif
1228/* ACK bit rate */ 1193/* ACK bit rate */
1229void ath5k_hw_set_ack_bitrate_high(struct ath5k_hw *ah, bool high); 1194void ath5k_hw_set_ack_bitrate_high(struct ath5k_hw *ah, bool high);
1230/* ACK/CTS Timeouts */
1231extern int ath5k_hw_set_ack_timeout(struct ath5k_hw *ah, unsigned int timeout);
1232extern unsigned int ath5k_hw_get_ack_timeout(struct ath5k_hw *ah);
1233extern int ath5k_hw_set_cts_timeout(struct ath5k_hw *ah, unsigned int timeout);
1234extern unsigned int ath5k_hw_get_cts_timeout(struct ath5k_hw *ah);
1235/* Clock rate related functions */ 1195/* Clock rate related functions */
1236unsigned int ath5k_hw_htoclock(struct ath5k_hw *ah, unsigned int usec); 1196unsigned int ath5k_hw_htoclock(struct ath5k_hw *ah, unsigned int usec);
1237unsigned int ath5k_hw_clocktoh(struct ath5k_hw *ah, unsigned int clock); 1197unsigned int ath5k_hw_clocktoh(struct ath5k_hw *ah, unsigned int clock);
1238unsigned int ath5k_hw_get_clockrate(struct ath5k_hw *ah); 1198unsigned int ath5k_hw_get_clockrate(struct ath5k_hw *ah);
1239/* Key table (WEP) functions */ 1199/* Key table (WEP) functions */
1240extern int ath5k_hw_reset_key(struct ath5k_hw *ah, u16 entry); 1200int ath5k_hw_reset_key(struct ath5k_hw *ah, u16 entry);
1241extern int ath5k_hw_is_key_valid(struct ath5k_hw *ah, u16 entry); 1201int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry,
1242extern int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry, const struct ieee80211_key_conf *key, const u8 *mac); 1202 const struct ieee80211_key_conf *key, const u8 *mac);
1243extern int ath5k_hw_set_key_lladdr(struct ath5k_hw *ah, u16 entry, const u8 *mac); 1203int ath5k_hw_set_key_lladdr(struct ath5k_hw *ah, u16 entry, const u8 *mac);
1244 1204
1245/* Queue Control Unit, DFS Control Unit Functions */ 1205/* Queue Control Unit, DFS Control Unit Functions */
1246extern int ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue, struct ath5k_txq_info *queue_info); 1206int ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue,
1247extern int ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, int queue, 1207 struct ath5k_txq_info *queue_info);
1248 const struct ath5k_txq_info *queue_info); 1208int ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, int queue,
1249extern int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, 1209 const struct ath5k_txq_info *queue_info);
1250 enum ath5k_tx_queue queue_type, 1210int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah,
1251 struct ath5k_txq_info *queue_info); 1211 enum ath5k_tx_queue queue_type,
1252extern u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue); 1212 struct ath5k_txq_info *queue_info);
1253extern void ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue); 1213u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue);
1254extern int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue); 1214void ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue);
1255extern unsigned int ath5k_hw_get_slot_time(struct ath5k_hw *ah); 1215int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue);
1256extern int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time); 1216int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time);
1257 1217
1258/* Hardware Descriptor Functions */ 1218/* Hardware Descriptor Functions */
1259extern int ath5k_hw_init_desc_functions(struct ath5k_hw *ah); 1219int ath5k_hw_init_desc_functions(struct ath5k_hw *ah);
1260 1220
1261/* GPIO Functions */ 1221/* GPIO Functions */
1262extern void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state); 1222void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state);
1263extern int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio); 1223int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio);
1264extern int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio); 1224int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio);
1265extern u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio); 1225u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio);
1266extern int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val); 1226int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val);
1267extern void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, u32 interrupt_level); 1227void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio,
1228 u32 interrupt_level);
1268 1229
1269/* rfkill Functions */ 1230/* rfkill Functions */
1270extern void ath5k_rfkill_hw_start(struct ath5k_hw *ah); 1231void ath5k_rfkill_hw_start(struct ath5k_hw *ah);
1271extern void ath5k_rfkill_hw_stop(struct ath5k_hw *ah); 1232void ath5k_rfkill_hw_stop(struct ath5k_hw *ah);
1272 1233
1273/* Misc functions */ 1234/* Misc functions */
1274int ath5k_hw_set_capabilities(struct ath5k_hw *ah); 1235int ath5k_hw_set_capabilities(struct ath5k_hw *ah);
1275extern int ath5k_hw_get_capability(struct ath5k_hw *ah, enum ath5k_capability_type cap_type, u32 capability, u32 *result); 1236int ath5k_hw_get_capability(struct ath5k_hw *ah,
1276extern int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid, u16 assoc_id); 1237 enum ath5k_capability_type cap_type, u32 capability,
1277extern int ath5k_hw_disable_pspoll(struct ath5k_hw *ah); 1238 u32 *result);
1239int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid, u16 assoc_id);
1240int ath5k_hw_disable_pspoll(struct ath5k_hw *ah);
1278 1241
1279/* Initial register settings functions */ 1242/* Initial register settings functions */
1280extern int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel); 1243int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel);
1281 1244
1282/* Initialize RF */ 1245/* Initialize RF */
1283extern int ath5k_hw_rfregs_init(struct ath5k_hw *ah, 1246int ath5k_hw_rfregs_init(struct ath5k_hw *ah,
1284 struct ieee80211_channel *channel, 1247 struct ieee80211_channel *channel,
1285 unsigned int mode); 1248 unsigned int mode);
1286extern int ath5k_hw_rfgain_init(struct ath5k_hw *ah, unsigned int freq); 1249int ath5k_hw_rfgain_init(struct ath5k_hw *ah, unsigned int freq);
1287extern enum ath5k_rfgain ath5k_hw_gainf_calibrate(struct ath5k_hw *ah); 1250enum ath5k_rfgain ath5k_hw_gainf_calibrate(struct ath5k_hw *ah);
1288extern int ath5k_hw_rfgain_opt_init(struct ath5k_hw *ah); 1251int ath5k_hw_rfgain_opt_init(struct ath5k_hw *ah);
1289/* PHY/RF channel functions */ 1252/* PHY/RF channel functions */
1290extern bool ath5k_channel_ok(struct ath5k_hw *ah, u16 freq, unsigned int flags); 1253bool ath5k_channel_ok(struct ath5k_hw *ah, u16 freq, unsigned int flags);
1291extern int ath5k_hw_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel); 1254int ath5k_hw_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel);
1292/* PHY calibration */ 1255/* PHY calibration */
1293void ath5k_hw_init_nfcal_hist(struct ath5k_hw *ah); 1256void ath5k_hw_init_nfcal_hist(struct ath5k_hw *ah);
1294extern int ath5k_hw_phy_calibrate(struct ath5k_hw *ah, struct ieee80211_channel *channel); 1257int ath5k_hw_phy_calibrate(struct ath5k_hw *ah,
1295extern int ath5k_hw_noise_floor_calibration(struct ath5k_hw *ah, short freq); 1258 struct ieee80211_channel *channel);
1296extern s16 ath5k_hw_get_noise_floor(struct ath5k_hw *ah); 1259void ath5k_hw_calibration_poll(struct ath5k_hw *ah);
1297extern void ath5k_hw_calibration_poll(struct ath5k_hw *ah);
1298/* Spur mitigation */ 1260/* Spur mitigation */
1299bool ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah, 1261bool ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah,
1300 struct ieee80211_channel *channel); 1262 struct ieee80211_channel *channel);
1301void ath5k_hw_set_spur_mitigation_filter(struct ath5k_hw *ah, 1263void ath5k_hw_set_spur_mitigation_filter(struct ath5k_hw *ah,
1302 struct ieee80211_channel *channel); 1264 struct ieee80211_channel *channel);
1303/* Misc PHY functions */ 1265/* Misc PHY functions */
1304extern u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, unsigned int chan); 1266u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, unsigned int chan);
1305extern int ath5k_hw_phy_disable(struct ath5k_hw *ah); 1267int ath5k_hw_phy_disable(struct ath5k_hw *ah);
1306/* Antenna control */ 1268/* Antenna control */
1307extern void ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode); 1269void ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode);
1308extern void ath5k_hw_set_def_antenna(struct ath5k_hw *ah, u8 ant);
1309extern unsigned int ath5k_hw_get_def_antenna(struct ath5k_hw *ah);
1310/* TX power setup */ 1270/* TX power setup */
1311extern int ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, u8 ee_mode, u8 txpower); 1271int ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
1312extern int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower); 1272 u8 ee_mode, u8 txpower);
1273int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower);
1313 1274
1314/* 1275/*
1315 * Functions used internaly 1276 * Functions used internaly
@@ -1335,29 +1296,6 @@ static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
1335 iowrite32(val, ah->ah_iobase + reg); 1296 iowrite32(val, ah->ah_iobase + reg);
1336} 1297}
1337 1298
1338#if defined(_ATH5K_RESET) || defined(_ATH5K_PHY)
1339/*
1340 * Check if a register write has been completed
1341 */
1342static int ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag,
1343 u32 val, bool is_set)
1344{
1345 int i;
1346 u32 data;
1347
1348 for (i = AR5K_TUNE_REGISTER_TIMEOUT; i > 0; i--) {
1349 data = ath5k_hw_reg_read(ah, reg);
1350 if (is_set && (data & flag))
1351 break;
1352 else if ((data & flag) == val)
1353 break;
1354 udelay(15);
1355 }
1356
1357 return (i <= 0) ? -EAGAIN : 0;
1358}
1359#endif
1360
1361static inline u32 ath5k_hw_bitswap(u32 val, unsigned int bits) 1299static inline u32 ath5k_hw_bitswap(u32 val, unsigned int bits)
1362{ 1300{
1363 u32 retval = 0, bit, i; 1301 u32 retval = 0, bit, i;
@@ -1370,9 +1308,4 @@ static inline u32 ath5k_hw_bitswap(u32 val, unsigned int bits)
1370 return retval; 1308 return retval;
1371} 1309}
1372 1310
1373static inline int ath5k_pad_size(int hdrlen)
1374{
1375 return (hdrlen < 24) ? 0 : hdrlen & 3;
1376}
1377
1378#endif 1311#endif
diff --git a/drivers/net/wireless/ath/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c
index 42284445b75e..dd4099a2ff15 100644
--- a/drivers/net/wireless/ath/ath5k/attach.c
+++ b/drivers/net/wireless/ath/ath5k/attach.c
@@ -113,7 +113,6 @@ int ath5k_hw_attach(struct ath5k_softc *sc)
113 /* 113 /*
114 * HW information 114 * HW information
115 */ 115 */
116 ah->ah_op_mode = NL80211_IFTYPE_STATION;
117 ah->ah_radar.r_enabled = AR5K_TUNE_RADAR_ALERT; 116 ah->ah_radar.r_enabled = AR5K_TUNE_RADAR_ALERT;
118 ah->ah_turbo = false; 117 ah->ah_turbo = false;
119 ah->ah_txpower.txp_tpc = AR5K_TUNE_TPC_TXPOWER; 118 ah->ah_txpower.txp_tpc = AR5K_TUNE_TPC_TXPOWER;
@@ -123,6 +122,7 @@ int ath5k_hw_attach(struct ath5k_softc *sc)
123 ah->ah_cw_min = AR5K_TUNE_CWMIN; 122 ah->ah_cw_min = AR5K_TUNE_CWMIN;
124 ah->ah_limit_tx_retries = AR5K_INIT_TX_RETRY; 123 ah->ah_limit_tx_retries = AR5K_INIT_TX_RETRY;
125 ah->ah_software_retry = false; 124 ah->ah_software_retry = false;
125 ah->ah_ant_mode = AR5K_ANTMODE_DEFAULT;
126 126
127 /* 127 /*
128 * Find the mac version 128 * Find the mac version
@@ -148,7 +148,6 @@ int ath5k_hw_attach(struct ath5k_softc *sc)
148 /* Get MAC, PHY and RADIO revisions */ 148 /* Get MAC, PHY and RADIO revisions */
149 ah->ah_mac_srev = srev; 149 ah->ah_mac_srev = srev;
150 ah->ah_mac_version = AR5K_REG_MS(srev, AR5K_SREV_VER); 150 ah->ah_mac_version = AR5K_REG_MS(srev, AR5K_SREV_VER);
151 ah->ah_mac_revision = AR5K_REG_MS(srev, AR5K_SREV_REV);
152 ah->ah_phy_revision = ath5k_hw_reg_read(ah, AR5K_PHY_CHIP_ID) & 151 ah->ah_phy_revision = ath5k_hw_reg_read(ah, AR5K_PHY_CHIP_ID) &
153 0xffffffff; 152 0xffffffff;
154 ah->ah_radio_5ghz_revision = ath5k_hw_radio_revision(ah, 153 ah->ah_radio_5ghz_revision = ath5k_hw_radio_revision(ah,
@@ -327,7 +326,7 @@ int ath5k_hw_attach(struct ath5k_softc *sc)
327 /* Set BSSID to bcast address: ff:ff:ff:ff:ff:ff for now */ 326 /* Set BSSID to bcast address: ff:ff:ff:ff:ff:ff for now */
328 memcpy(common->curbssid, ath_bcast_mac, ETH_ALEN); 327 memcpy(common->curbssid, ath_bcast_mac, ETH_ALEN);
329 ath5k_hw_set_associd(ah); 328 ath5k_hw_set_associd(ah);
330 ath5k_hw_set_opmode(ah); 329 ath5k_hw_set_opmode(ah, sc->opmode);
331 330
332 ath5k_hw_rfgain_opt_init(ah); 331 ath5k_hw_rfgain_opt_init(ah);
333 332
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 8dce0077b023..53a2340f52bc 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -198,7 +198,7 @@ static void __devexit ath5k_pci_remove(struct pci_dev *pdev);
198static int ath5k_pci_suspend(struct device *dev); 198static int ath5k_pci_suspend(struct device *dev);
199static int ath5k_pci_resume(struct device *dev); 199static int ath5k_pci_resume(struct device *dev);
200 200
201SIMPLE_DEV_PM_OPS(ath5k_pm_ops, ath5k_pci_suspend, ath5k_pci_resume); 201static SIMPLE_DEV_PM_OPS(ath5k_pm_ops, ath5k_pci_suspend, ath5k_pci_resume);
202#define ATH5K_PM_OPS (&ath5k_pm_ops) 202#define ATH5K_PM_OPS (&ath5k_pm_ops)
203#else 203#else
204#define ATH5K_PM_OPS NULL 204#define ATH5K_PM_OPS NULL
@@ -230,7 +230,7 @@ static void ath5k_remove_interface(struct ieee80211_hw *hw,
230 struct ieee80211_vif *vif); 230 struct ieee80211_vif *vif);
231static int ath5k_config(struct ieee80211_hw *hw, u32 changed); 231static int ath5k_config(struct ieee80211_hw *hw, u32 changed);
232static u64 ath5k_prepare_multicast(struct ieee80211_hw *hw, 232static u64 ath5k_prepare_multicast(struct ieee80211_hw *hw,
233 int mc_count, struct dev_addr_list *mc_list); 233 struct netdev_hw_addr_list *mc_list);
234static void ath5k_configure_filter(struct ieee80211_hw *hw, 234static void ath5k_configure_filter(struct ieee80211_hw *hw,
235 unsigned int changed_flags, 235 unsigned int changed_flags,
236 unsigned int *new_flags, 236 unsigned int *new_flags,
@@ -307,7 +307,7 @@ static int ath5k_rxbuf_setup(struct ath5k_softc *sc,
307 struct ath5k_buf *bf); 307 struct ath5k_buf *bf);
308static int ath5k_txbuf_setup(struct ath5k_softc *sc, 308static int ath5k_txbuf_setup(struct ath5k_softc *sc,
309 struct ath5k_buf *bf, 309 struct ath5k_buf *bf,
310 struct ath5k_txq *txq); 310 struct ath5k_txq *txq, int padsize);
311static inline void ath5k_txbuf_free(struct ath5k_softc *sc, 311static inline void ath5k_txbuf_free(struct ath5k_softc *sc,
312 struct ath5k_buf *bf) 312 struct ath5k_buf *bf)
313{ 313{
@@ -1137,8 +1137,6 @@ ath5k_mode_setup(struct ath5k_softc *sc)
1137 struct ath5k_hw *ah = sc->ah; 1137 struct ath5k_hw *ah = sc->ah;
1138 u32 rfilt; 1138 u32 rfilt;
1139 1139
1140 ah->ah_op_mode = sc->opmode;
1141
1142 /* configure rx filter */ 1140 /* configure rx filter */
1143 rfilt = sc->filter_flags; 1141 rfilt = sc->filter_flags;
1144 ath5k_hw_set_rx_filter(ah, rfilt); 1142 ath5k_hw_set_rx_filter(ah, rfilt);
@@ -1147,8 +1145,9 @@ ath5k_mode_setup(struct ath5k_softc *sc)
1147 ath5k_hw_set_bssid_mask(ah, sc->bssidmask); 1145 ath5k_hw_set_bssid_mask(ah, sc->bssidmask);
1148 1146
1149 /* configure operational mode */ 1147 /* configure operational mode */
1150 ath5k_hw_set_opmode(ah); 1148 ath5k_hw_set_opmode(ah, sc->opmode);
1151 1149
1150 ATH5K_DBG(sc, ATH5K_DEBUG_MODE, "mode setup opmode %d\n", sc->opmode);
1152 ATH5K_DBG(sc, ATH5K_DEBUG_MODE, "RX filter 0x%x\n", rfilt); 1151 ATH5K_DBG(sc, ATH5K_DEBUG_MODE, "RX filter 0x%x\n", rfilt);
1153} 1152}
1154 1153
@@ -1271,7 +1270,7 @@ static enum ath5k_pkt_type get_hw_packet_type(struct sk_buff *skb)
1271 1270
1272static int 1271static int
1273ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf, 1272ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf,
1274 struct ath5k_txq *txq) 1273 struct ath5k_txq *txq, int padsize)
1275{ 1274{
1276 struct ath5k_hw *ah = sc->ah; 1275 struct ath5k_hw *ah = sc->ah;
1277 struct ath5k_desc *ds = bf->desc; 1276 struct ath5k_desc *ds = bf->desc;
@@ -1323,7 +1322,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf,
1323 sc->vif, pktlen, info)); 1322 sc->vif, pktlen, info));
1324 } 1323 }
1325 ret = ah->ah_setup_tx_desc(ah, ds, pktlen, 1324 ret = ah->ah_setup_tx_desc(ah, ds, pktlen,
1326 ieee80211_get_hdrlen_from_skb(skb), 1325 ieee80211_get_hdrlen_from_skb(skb), padsize,
1327 get_hw_packet_type(skb), 1326 get_hw_packet_type(skb),
1328 (sc->power_level * 2), 1327 (sc->power_level * 2),
1329 hw_rate, 1328 hw_rate,
@@ -1805,6 +1804,67 @@ ath5k_check_ibss_tsf(struct ath5k_softc *sc, struct sk_buff *skb,
1805 } 1804 }
1806} 1805}
1807 1806
1807/*
1808 * Compute padding position. skb must contains an IEEE 802.11 frame
1809 */
1810static int ath5k_common_padpos(struct sk_buff *skb)
1811{
1812 struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data;
1813 __le16 frame_control = hdr->frame_control;
1814 int padpos = 24;
1815
1816 if (ieee80211_has_a4(frame_control)) {
1817 padpos += ETH_ALEN;
1818 }
1819 if (ieee80211_is_data_qos(frame_control)) {
1820 padpos += IEEE80211_QOS_CTL_LEN;
1821 }
1822
1823 return padpos;
1824}
1825
1826/*
1827 * This function expects a 802.11 frame and returns the number of
1828 * bytes added, or -1 if we don't have enought header room.
1829 */
1830
1831static int ath5k_add_padding(struct sk_buff *skb)
1832{
1833 int padpos = ath5k_common_padpos(skb);
1834 int padsize = padpos & 3;
1835
1836 if (padsize && skb->len>padpos) {
1837
1838 if (skb_headroom(skb) < padsize)
1839 return -1;
1840
1841 skb_push(skb, padsize);
1842 memmove(skb->data, skb->data+padsize, padpos);
1843 return padsize;
1844 }
1845
1846 return 0;
1847}
1848
1849/*
1850 * This function expects a 802.11 frame and returns the number of
1851 * bytes removed
1852 */
1853
1854static int ath5k_remove_padding(struct sk_buff *skb)
1855{
1856 int padpos = ath5k_common_padpos(skb);
1857 int padsize = padpos & 3;
1858
1859 if (padsize && skb->len>=padpos+padsize) {
1860 memmove(skb->data + padsize, skb->data, padpos);
1861 skb_pull(skb, padsize);
1862 return padsize;
1863 }
1864
1865 return 0;
1866}
1867
1808static void 1868static void
1809ath5k_tasklet_rx(unsigned long data) 1869ath5k_tasklet_rx(unsigned long data)
1810{ 1870{
@@ -1818,8 +1878,6 @@ ath5k_tasklet_rx(unsigned long data)
1818 struct ath5k_buf *bf; 1878 struct ath5k_buf *bf;
1819 struct ath5k_desc *ds; 1879 struct ath5k_desc *ds;
1820 int ret; 1880 int ret;
1821 int hdrlen;
1822 int padsize;
1823 int rx_flag; 1881 int rx_flag;
1824 1882
1825 spin_lock(&sc->rxbuflock); 1883 spin_lock(&sc->rxbuflock);
@@ -1844,18 +1902,28 @@ ath5k_tasklet_rx(unsigned long data)
1844 break; 1902 break;
1845 else if (unlikely(ret)) { 1903 else if (unlikely(ret)) {
1846 ATH5K_ERR(sc, "error in processing rx descriptor\n"); 1904 ATH5K_ERR(sc, "error in processing rx descriptor\n");
1905 sc->stats.rxerr_proc++;
1847 spin_unlock(&sc->rxbuflock); 1906 spin_unlock(&sc->rxbuflock);
1848 return; 1907 return;
1849 } 1908 }
1850 1909
1910 sc->stats.rx_all_count++;
1911
1851 if (unlikely(rs.rs_more)) { 1912 if (unlikely(rs.rs_more)) {
1852 ATH5K_WARN(sc, "unsupported jumbo\n"); 1913 ATH5K_WARN(sc, "unsupported jumbo\n");
1914 sc->stats.rxerr_jumbo++;
1853 goto next; 1915 goto next;
1854 } 1916 }
1855 1917
1856 if (unlikely(rs.rs_status)) { 1918 if (unlikely(rs.rs_status)) {
1857 if (rs.rs_status & AR5K_RXERR_PHY) 1919 if (rs.rs_status & AR5K_RXERR_CRC)
1920 sc->stats.rxerr_crc++;
1921 if (rs.rs_status & AR5K_RXERR_FIFO)
1922 sc->stats.rxerr_fifo++;
1923 if (rs.rs_status & AR5K_RXERR_PHY) {
1924 sc->stats.rxerr_phy++;
1858 goto next; 1925 goto next;
1926 }
1859 if (rs.rs_status & AR5K_RXERR_DECRYPT) { 1927 if (rs.rs_status & AR5K_RXERR_DECRYPT) {
1860 /* 1928 /*
1861 * Decrypt error. If the error occurred 1929 * Decrypt error. If the error occurred
@@ -1867,12 +1935,14 @@ ath5k_tasklet_rx(unsigned long data)
1867 * 1935 *
1868 * XXX do key cache faulting 1936 * XXX do key cache faulting
1869 */ 1937 */
1938 sc->stats.rxerr_decrypt++;
1870 if (rs.rs_keyix == AR5K_RXKEYIX_INVALID && 1939 if (rs.rs_keyix == AR5K_RXKEYIX_INVALID &&
1871 !(rs.rs_status & AR5K_RXERR_CRC)) 1940 !(rs.rs_status & AR5K_RXERR_CRC))
1872 goto accept; 1941 goto accept;
1873 } 1942 }
1874 if (rs.rs_status & AR5K_RXERR_MIC) { 1943 if (rs.rs_status & AR5K_RXERR_MIC) {
1875 rx_flag |= RX_FLAG_MMIC_ERROR; 1944 rx_flag |= RX_FLAG_MMIC_ERROR;
1945 sc->stats.rxerr_mic++;
1876 goto accept; 1946 goto accept;
1877 } 1947 }
1878 1948
@@ -1904,12 +1974,8 @@ accept:
1904 * bytes and we can optimize this a bit. In addition, we must 1974 * bytes and we can optimize this a bit. In addition, we must
1905 * not try to remove padding from short control frames that do 1975 * not try to remove padding from short control frames that do
1906 * not have payload. */ 1976 * not have payload. */
1907 hdrlen = ieee80211_get_hdrlen_from_skb(skb); 1977 ath5k_remove_padding(skb);
1908 padsize = ath5k_pad_size(hdrlen); 1978
1909 if (padsize) {
1910 memmove(skb->data + padsize, skb->data, hdrlen);
1911 skb_pull(skb, padsize);
1912 }
1913 rxs = IEEE80211_SKB_RXCB(skb); 1979 rxs = IEEE80211_SKB_RXCB(skb);
1914 1980
1915 /* 1981 /*
@@ -1942,6 +2008,12 @@ accept:
1942 rxs->signal = rxs->noise + rs.rs_rssi; 2008 rxs->signal = rxs->noise + rs.rs_rssi;
1943 2009
1944 rxs->antenna = rs.rs_antenna; 2010 rxs->antenna = rs.rs_antenna;
2011
2012 if (rs.rs_antenna > 0 && rs.rs_antenna < 5)
2013 sc->stats.antenna_rx[rs.rs_antenna]++;
2014 else
2015 sc->stats.antenna_rx[0]++; /* invalid */
2016
1945 rxs->rate_idx = ath5k_hw_to_driver_rix(sc, rs.rs_rate); 2017 rxs->rate_idx = ath5k_hw_to_driver_rix(sc, rs.rs_rate);
1946 rxs->flag |= ath5k_rx_decrypted(sc, ds, skb, &rs); 2018 rxs->flag |= ath5k_rx_decrypted(sc, ds, skb, &rs);
1947 2019
@@ -1996,6 +2068,7 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq)
1996 break; 2068 break;
1997 } 2069 }
1998 2070
2071 sc->stats.tx_all_count++;
1999 skb = bf->skb; 2072 skb = bf->skb;
2000 info = IEEE80211_SKB_CB(skb); 2073 info = IEEE80211_SKB_CB(skb);
2001 bf->skb = NULL; 2074 bf->skb = NULL;
@@ -2022,13 +2095,30 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq)
2022 2095
2023 if (unlikely(ts.ts_status)) { 2096 if (unlikely(ts.ts_status)) {
2024 sc->ll_stats.dot11ACKFailureCount++; 2097 sc->ll_stats.dot11ACKFailureCount++;
2025 if (ts.ts_status & AR5K_TXERR_FILT) 2098 if (ts.ts_status & AR5K_TXERR_FILT) {
2026 info->flags |= IEEE80211_TX_STAT_TX_FILTERED; 2099 info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
2100 sc->stats.txerr_filt++;
2101 }
2102 if (ts.ts_status & AR5K_TXERR_XRETRY)
2103 sc->stats.txerr_retry++;
2104 if (ts.ts_status & AR5K_TXERR_FIFO)
2105 sc->stats.txerr_fifo++;
2027 } else { 2106 } else {
2028 info->flags |= IEEE80211_TX_STAT_ACK; 2107 info->flags |= IEEE80211_TX_STAT_ACK;
2029 info->status.ack_signal = ts.ts_rssi; 2108 info->status.ack_signal = ts.ts_rssi;
2030 } 2109 }
2031 2110
2111 /*
2112 * Remove MAC header padding before giving the frame
2113 * back to mac80211.
2114 */
2115 ath5k_remove_padding(skb);
2116
2117 if (ts.ts_antenna > 0 && ts.ts_antenna < 5)
2118 sc->stats.antenna_tx[ts.ts_antenna]++;
2119 else
2120 sc->stats.antenna_tx[0]++; /* invalid */
2121
2032 ieee80211_tx_status(sc->hw, skb); 2122 ieee80211_tx_status(sc->hw, skb);
2033 2123
2034 spin_lock(&sc->txbuflock); 2124 spin_lock(&sc->txbuflock);
@@ -2072,6 +2162,7 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
2072 int ret = 0; 2162 int ret = 0;
2073 u8 antenna; 2163 u8 antenna;
2074 u32 flags; 2164 u32 flags;
2165 const int padsize = 0;
2075 2166
2076 bf->skbaddr = pci_map_single(sc->pdev, skb->data, skb->len, 2167 bf->skbaddr = pci_map_single(sc->pdev, skb->data, skb->len,
2077 PCI_DMA_TODEVICE); 2168 PCI_DMA_TODEVICE);
@@ -2119,7 +2210,7 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf)
2119 * from tx power (value is in dB units already) */ 2210 * from tx power (value is in dB units already) */
2120 ds->ds_data = bf->skbaddr; 2211 ds->ds_data = bf->skbaddr;
2121 ret = ah->ah_setup_tx_desc(ah, ds, skb->len, 2212 ret = ah->ah_setup_tx_desc(ah, ds, skb->len,
2122 ieee80211_get_hdrlen_from_skb(skb), 2213 ieee80211_get_hdrlen_from_skb(skb), padsize,
2123 AR5K_PKT_TYPE_BEACON, (sc->power_level * 2), 2214 AR5K_PKT_TYPE_BEACON, (sc->power_level * 2),
2124 ieee80211_get_tx_rate(sc->hw, info)->hw_value, 2215 ieee80211_get_tx_rate(sc->hw, info)->hw_value,
2125 1, AR5K_TXKEYIX_INVALID, 2216 1, AR5K_TXKEYIX_INVALID,
@@ -2679,7 +2770,6 @@ static int ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb,
2679 struct ath5k_softc *sc = hw->priv; 2770 struct ath5k_softc *sc = hw->priv;
2680 struct ath5k_buf *bf; 2771 struct ath5k_buf *bf;
2681 unsigned long flags; 2772 unsigned long flags;
2682 int hdrlen;
2683 int padsize; 2773 int padsize;
2684 2774
2685 ath5k_debug_dump_skb(sc, skb, "TX ", 1); 2775 ath5k_debug_dump_skb(sc, skb, "TX ", 1);
@@ -2691,17 +2781,11 @@ static int ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb,
2691 * the hardware expects the header padded to 4 byte boundaries 2781 * the hardware expects the header padded to 4 byte boundaries
2692 * if this is not the case we add the padding after the header 2782 * if this is not the case we add the padding after the header
2693 */ 2783 */
2694 hdrlen = ieee80211_get_hdrlen_from_skb(skb); 2784 padsize = ath5k_add_padding(skb);
2695 padsize = ath5k_pad_size(hdrlen); 2785 if (padsize < 0) {
2696 if (padsize) { 2786 ATH5K_ERR(sc, "tx hdrlen not %%4: not enough"
2697 2787 " headroom to pad");
2698 if (skb_headroom(skb) < padsize) { 2788 goto drop_packet;
2699 ATH5K_ERR(sc, "tx hdrlen not %%4: %d not enough"
2700 " headroom to pad %d\n", hdrlen, padsize);
2701 goto drop_packet;
2702 }
2703 skb_push(skb, padsize);
2704 memmove(skb->data, skb->data+padsize, hdrlen);
2705 } 2789 }
2706 2790
2707 spin_lock_irqsave(&sc->txbuflock, flags); 2791 spin_lock_irqsave(&sc->txbuflock, flags);
@@ -2720,7 +2804,7 @@ static int ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb,
2720 2804
2721 bf->skb = skb; 2805 bf->skb = skb;
2722 2806
2723 if (ath5k_txbuf_setup(sc, bf, txq)) { 2807 if (ath5k_txbuf_setup(sc, bf, txq, padsize)) {
2724 bf->skb = NULL; 2808 bf->skb = NULL;
2725 spin_lock_irqsave(&sc->txbuflock, flags); 2809 spin_lock_irqsave(&sc->txbuflock, flags);
2726 list_add_tail(&bf->list, &sc->txbuf); 2810 list_add_tail(&bf->list, &sc->txbuf);
@@ -2835,6 +2919,8 @@ static int ath5k_add_interface(struct ieee80211_hw *hw,
2835 goto end; 2919 goto end;
2836 } 2920 }
2837 2921
2922 ATH5K_DBG(sc, ATH5K_DEBUG_MODE, "add interface mode %d\n", sc->opmode);
2923
2838 ath5k_hw_set_lladdr(sc->ah, vif->addr); 2924 ath5k_hw_set_lladdr(sc->ah, vif->addr);
2839 ath5k_mode_setup(sc); 2925 ath5k_mode_setup(sc);
2840 2926
@@ -2905,7 +2991,7 @@ ath5k_config(struct ieee80211_hw *hw, u32 changed)
2905 * then we must allow the user to set how many tx antennas we 2991 * then we must allow the user to set how many tx antennas we
2906 * have available 2992 * have available
2907 */ 2993 */
2908 ath5k_hw_set_antenna_mode(ah, AR5K_ANTMODE_DEFAULT); 2994 ath5k_hw_set_antenna_mode(ah, ah->ah_ant_mode);
2909 2995
2910unlock: 2996unlock:
2911 mutex_unlock(&sc->lock); 2997 mutex_unlock(&sc->lock);
@@ -2913,22 +2999,20 @@ unlock:
2913} 2999}
2914 3000
2915static u64 ath5k_prepare_multicast(struct ieee80211_hw *hw, 3001static u64 ath5k_prepare_multicast(struct ieee80211_hw *hw,
2916 int mc_count, struct dev_addr_list *mclist) 3002 struct netdev_hw_addr_list *mc_list)
2917{ 3003{
2918 u32 mfilt[2], val; 3004 u32 mfilt[2], val;
2919 int i;
2920 u8 pos; 3005 u8 pos;
3006 struct netdev_hw_addr *ha;
2921 3007
2922 mfilt[0] = 0; 3008 mfilt[0] = 0;
2923 mfilt[1] = 1; 3009 mfilt[1] = 1;
2924 3010
2925 for (i = 0; i < mc_count; i++) { 3011 netdev_hw_addr_list_for_each(ha, mc_list) {
2926 if (!mclist)
2927 break;
2928 /* calculate XOR of eight 6-bit values */ 3012 /* calculate XOR of eight 6-bit values */
2929 val = get_unaligned_le32(mclist->dmi_addr + 0); 3013 val = get_unaligned_le32(ha->addr + 0);
2930 pos = (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val; 3014 pos = (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val;
2931 val = get_unaligned_le32(mclist->dmi_addr + 3); 3015 val = get_unaligned_le32(ha->addr + 3);
2932 pos ^= (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val; 3016 pos ^= (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val;
2933 pos &= 0x3f; 3017 pos &= 0x3f;
2934 mfilt[pos / 32] |= (1 << (pos % 32)); 3018 mfilt[pos / 32] |= (1 << (pos % 32));
@@ -2936,8 +3020,7 @@ static u64 ath5k_prepare_multicast(struct ieee80211_hw *hw,
2936 * but not sure, needs testing, if we do use this we'd 3020 * but not sure, needs testing, if we do use this we'd
2937 * neet to inform below to not reset the mcast */ 3021 * neet to inform below to not reset the mcast */
2938 /* ath5k_hw_set_mcast_filterindex(ah, 3022 /* ath5k_hw_set_mcast_filterindex(ah,
2939 * mclist->dmi_addr[5]); */ 3023 * ha->addr[5]); */
2940 mclist = mclist->next;
2941 } 3024 }
2942 3025
2943 return ((u64)(mfilt[1]) << 32) | mfilt[0]; 3026 return ((u64)(mfilt[1]) << 32) | mfilt[0];
diff --git a/drivers/net/wireless/ath/ath5k/base.h b/drivers/net/wireless/ath/ath5k/base.h
index 7e1a88a5abdb..33f1d8b87ee1 100644
--- a/drivers/net/wireless/ath/ath5k/base.h
+++ b/drivers/net/wireless/ath/ath5k/base.h
@@ -105,6 +105,24 @@ struct ath5k_rfkill {
105 struct tasklet_struct toggleq; 105 struct tasklet_struct toggleq;
106}; 106};
107 107
108/* statistics (only used for debugging now) */
109struct ath5k_statistics {
110 unsigned int antenna_rx[5]; /* frames count per antenna RX */
111 unsigned int antenna_tx[5]; /* frames count per antenna TX */
112 unsigned int rx_all_count; /* all RX frames, including errors */
113 unsigned int tx_all_count; /* all TX frames, including errors */
114 unsigned int rxerr_crc;
115 unsigned int rxerr_phy;
116 unsigned int rxerr_fifo;
117 unsigned int rxerr_decrypt;
118 unsigned int rxerr_mic;
119 unsigned int rxerr_proc;
120 unsigned int rxerr_jumbo;
121 unsigned int txerr_retry;
122 unsigned int txerr_fifo;
123 unsigned int txerr_filt;
124};
125
108#if CHAN_DEBUG 126#if CHAN_DEBUG
109#define ATH_CHAN_MAX (26+26+26+200+200) 127#define ATH_CHAN_MAX (26+26+26+200+200)
110#else 128#else
@@ -191,6 +209,8 @@ struct ath5k_softc {
191 int power_level; /* Requested tx power in dbm */ 209 int power_level; /* Requested tx power in dbm */
192 bool assoc; /* associate state */ 210 bool assoc; /* associate state */
193 bool enable_beacon; /* true if beacons are on */ 211 bool enable_beacon; /* true if beacons are on */
212
213 struct ath5k_statistics stats;
194}; 214};
195 215
196#define ath5k_hw_hasbssidmask(_ah) \ 216#define ath5k_hw_hasbssidmask(_ah) \
diff --git a/drivers/net/wireless/ath/ath5k/caps.c b/drivers/net/wireless/ath/ath5k/caps.c
index 367a6c7d3cc7..e618e71b1ce6 100644
--- a/drivers/net/wireless/ath/ath5k/caps.c
+++ b/drivers/net/wireless/ath/ath5k/caps.c
@@ -102,9 +102,6 @@ int ath5k_hw_set_capabilities(struct ath5k_hw *ah)
102 } 102 }
103 } 103 }
104 104
105 /* GPIO */
106 ah->ah_gpio_npins = AR5K_NUM_GPIO;
107
108 /* Set number of supported TX queues */ 105 /* Set number of supported TX queues */
109 if (ah->ah_version == AR5K_AR5210) 106 if (ah->ah_version == AR5K_AR5210)
110 ah->ah_capabilities.cap_queues.q_tx_num = 107 ah->ah_capabilities.cap_queues.q_tx_num =
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index 747508c15d34..bccd4a78027e 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -364,6 +364,207 @@ static const struct file_operations fops_debug = {
364}; 364};
365 365
366 366
367/* debugfs: antenna */
368
369static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
370 size_t count, loff_t *ppos)
371{
372 struct ath5k_softc *sc = file->private_data;
373 char buf[700];
374 unsigned int len = 0;
375 unsigned int i;
376 unsigned int v;
377
378 len += snprintf(buf+len, sizeof(buf)-len, "antenna mode\t%d\n",
379 sc->ah->ah_ant_mode);
380 len += snprintf(buf+len, sizeof(buf)-len, "default antenna\t%d\n",
381 sc->ah->ah_def_ant);
382 len += snprintf(buf+len, sizeof(buf)-len, "tx antenna\t%d\n",
383 sc->ah->ah_tx_ant);
384
385 len += snprintf(buf+len, sizeof(buf)-len, "\nANTENNA\t\tRX\tTX\n");
386 for (i = 1; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) {
387 len += snprintf(buf+len, sizeof(buf)-len,
388 "[antenna %d]\t%d\t%d\n",
389 i, sc->stats.antenna_rx[i], sc->stats.antenna_tx[i]);
390 }
391 len += snprintf(buf+len, sizeof(buf)-len, "[invalid]\t%d\t%d\n",
392 sc->stats.antenna_rx[0], sc->stats.antenna_tx[0]);
393
394 v = ath5k_hw_reg_read(sc->ah, AR5K_DEFAULT_ANTENNA);
395 len += snprintf(buf+len, sizeof(buf)-len,
396 "\nAR5K_DEFAULT_ANTENNA\t0x%08x\n", v);
397
398 v = ath5k_hw_reg_read(sc->ah, AR5K_STA_ID1);
399 len += snprintf(buf+len, sizeof(buf)-len,
400 "AR5K_STA_ID1_DEFAULT_ANTENNA\t%d\n",
401 (v & AR5K_STA_ID1_DEFAULT_ANTENNA) != 0);
402 len += snprintf(buf+len, sizeof(buf)-len,
403 "AR5K_STA_ID1_DESC_ANTENNA\t%d\n",
404 (v & AR5K_STA_ID1_DESC_ANTENNA) != 0);
405 len += snprintf(buf+len, sizeof(buf)-len,
406 "AR5K_STA_ID1_RTS_DEF_ANTENNA\t%d\n",
407 (v & AR5K_STA_ID1_RTS_DEF_ANTENNA) != 0);
408 len += snprintf(buf+len, sizeof(buf)-len,
409 "AR5K_STA_ID1_SELFGEN_DEF_ANT\t%d\n",
410 (v & AR5K_STA_ID1_SELFGEN_DEF_ANT) != 0);
411
412 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_AGCCTL);
413 len += snprintf(buf+len, sizeof(buf)-len,
414 "\nAR5K_PHY_AGCCTL_OFDM_DIV_DIS\t%d\n",
415 (v & AR5K_PHY_AGCCTL_OFDM_DIV_DIS) != 0);
416
417 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_RESTART);
418 len += snprintf(buf+len, sizeof(buf)-len,
419 "AR5K_PHY_RESTART_DIV_GC\t\t%x\n",
420 (v & AR5K_PHY_RESTART_DIV_GC) >> AR5K_PHY_RESTART_DIV_GC_S);
421
422 v = ath5k_hw_reg_read(sc->ah, AR5K_PHY_FAST_ANT_DIV);
423 len += snprintf(buf+len, sizeof(buf)-len,
424 "AR5K_PHY_FAST_ANT_DIV_EN\t%d\n",
425 (v & AR5K_PHY_FAST_ANT_DIV_EN) != 0);
426
427 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
428}
429
430static ssize_t write_file_antenna(struct file *file,
431 const char __user *userbuf,
432 size_t count, loff_t *ppos)
433{
434 struct ath5k_softc *sc = file->private_data;
435 unsigned int i;
436 char buf[20];
437
438 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
439 return -EFAULT;
440
441 if (strncmp(buf, "diversity", 9) == 0) {
442 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_DEFAULT);
443 printk(KERN_INFO "ath5k debug: enable diversity\n");
444 } else if (strncmp(buf, "fixed-a", 7) == 0) {
445 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_A);
446 printk(KERN_INFO "ath5k debugfs: fixed antenna A\n");
447 } else if (strncmp(buf, "fixed-b", 7) == 0) {
448 ath5k_hw_set_antenna_mode(sc->ah, AR5K_ANTMODE_FIXED_B);
449 printk(KERN_INFO "ath5k debug: fixed antenna B\n");
450 } else if (strncmp(buf, "clear", 5) == 0) {
451 for (i = 0; i < ARRAY_SIZE(sc->stats.antenna_rx); i++) {
452 sc->stats.antenna_rx[i] = 0;
453 sc->stats.antenna_tx[i] = 0;
454 }
455 printk(KERN_INFO "ath5k debug: cleared antenna stats\n");
456 }
457 return count;
458}
459
460static const struct file_operations fops_antenna = {
461 .read = read_file_antenna,
462 .write = write_file_antenna,
463 .open = ath5k_debugfs_open,
464 .owner = THIS_MODULE,
465};
466
467
468/* debugfs: frameerrors */
469
470static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
471 size_t count, loff_t *ppos)
472{
473 struct ath5k_softc *sc = file->private_data;
474 struct ath5k_statistics *st = &sc->stats;
475 char buf[700];
476 unsigned int len = 0;
477
478 len += snprintf(buf+len, sizeof(buf)-len,
479 "RX\n---------------------\n");
480 len += snprintf(buf+len, sizeof(buf)-len, "CRC\t%d\t(%d%%)\n",
481 st->rxerr_crc,
482 st->rx_all_count > 0 ?
483 st->rxerr_crc*100/st->rx_all_count : 0);
484 len += snprintf(buf+len, sizeof(buf)-len, "PHY\t%d\t(%d%%)\n",
485 st->rxerr_phy,
486 st->rx_all_count > 0 ?
487 st->rxerr_phy*100/st->rx_all_count : 0);
488 len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%d\t(%d%%)\n",
489 st->rxerr_fifo,
490 st->rx_all_count > 0 ?
491 st->rxerr_fifo*100/st->rx_all_count : 0);
492 len += snprintf(buf+len, sizeof(buf)-len, "decrypt\t%d\t(%d%%)\n",
493 st->rxerr_decrypt,
494 st->rx_all_count > 0 ?
495 st->rxerr_decrypt*100/st->rx_all_count : 0);
496 len += snprintf(buf+len, sizeof(buf)-len, "MIC\t%d\t(%d%%)\n",
497 st->rxerr_mic,
498 st->rx_all_count > 0 ?
499 st->rxerr_mic*100/st->rx_all_count : 0);
500 len += snprintf(buf+len, sizeof(buf)-len, "process\t%d\t(%d%%)\n",
501 st->rxerr_proc,
502 st->rx_all_count > 0 ?
503 st->rxerr_proc*100/st->rx_all_count : 0);
504 len += snprintf(buf+len, sizeof(buf)-len, "jumbo\t%d\t(%d%%)\n",
505 st->rxerr_jumbo,
506 st->rx_all_count > 0 ?
507 st->rxerr_jumbo*100/st->rx_all_count : 0);
508 len += snprintf(buf+len, sizeof(buf)-len, "[RX all\t%d]\n",
509 st->rx_all_count);
510
511 len += snprintf(buf+len, sizeof(buf)-len,
512 "\nTX\n---------------------\n");
513 len += snprintf(buf+len, sizeof(buf)-len, "retry\t%d\t(%d%%)\n",
514 st->txerr_retry,
515 st->tx_all_count > 0 ?
516 st->txerr_retry*100/st->tx_all_count : 0);
517 len += snprintf(buf+len, sizeof(buf)-len, "FIFO\t%d\t(%d%%)\n",
518 st->txerr_fifo,
519 st->tx_all_count > 0 ?
520 st->txerr_fifo*100/st->tx_all_count : 0);
521 len += snprintf(buf+len, sizeof(buf)-len, "filter\t%d\t(%d%%)\n",
522 st->txerr_filt,
523 st->tx_all_count > 0 ?
524 st->txerr_filt*100/st->tx_all_count : 0);
525 len += snprintf(buf+len, sizeof(buf)-len, "[TX all\t%d]\n",
526 st->tx_all_count);
527
528 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
529}
530
531static ssize_t write_file_frameerrors(struct file *file,
532 const char __user *userbuf,
533 size_t count, loff_t *ppos)
534{
535 struct ath5k_softc *sc = file->private_data;
536 struct ath5k_statistics *st = &sc->stats;
537 char buf[20];
538
539 if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))
540 return -EFAULT;
541
542 if (strncmp(buf, "clear", 5) == 0) {
543 st->rxerr_crc = 0;
544 st->rxerr_phy = 0;
545 st->rxerr_fifo = 0;
546 st->rxerr_decrypt = 0;
547 st->rxerr_mic = 0;
548 st->rxerr_proc = 0;
549 st->rxerr_jumbo = 0;
550 st->rx_all_count = 0;
551 st->txerr_retry = 0;
552 st->txerr_fifo = 0;
553 st->txerr_filt = 0;
554 st->tx_all_count = 0;
555 printk(KERN_INFO "ath5k debug: cleared frameerrors stats\n");
556 }
557 return count;
558}
559
560static const struct file_operations fops_frameerrors = {
561 .read = read_file_frameerrors,
562 .write = write_file_frameerrors,
563 .open = ath5k_debugfs_open,
564 .owner = THIS_MODULE,
565};
566
567
367/* init */ 568/* init */
368 569
369void 570void
@@ -393,6 +594,15 @@ ath5k_debug_init_device(struct ath5k_softc *sc)
393 594
394 sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR, 595 sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR,
395 sc->debug.debugfs_phydir, sc, &fops_reset); 596 sc->debug.debugfs_phydir, sc, &fops_reset);
597
598 sc->debug.debugfs_antenna = debugfs_create_file("antenna",
599 S_IWUSR | S_IRUSR,
600 sc->debug.debugfs_phydir, sc, &fops_antenna);
601
602 sc->debug.debugfs_frameerrors = debugfs_create_file("frameerrors",
603 S_IWUSR | S_IRUSR,
604 sc->debug.debugfs_phydir, sc,
605 &fops_frameerrors);
396} 606}
397 607
398void 608void
@@ -408,6 +618,8 @@ ath5k_debug_finish_device(struct ath5k_softc *sc)
408 debugfs_remove(sc->debug.debugfs_registers); 618 debugfs_remove(sc->debug.debugfs_registers);
409 debugfs_remove(sc->debug.debugfs_beacon); 619 debugfs_remove(sc->debug.debugfs_beacon);
410 debugfs_remove(sc->debug.debugfs_reset); 620 debugfs_remove(sc->debug.debugfs_reset);
621 debugfs_remove(sc->debug.debugfs_antenna);
622 debugfs_remove(sc->debug.debugfs_frameerrors);
411 debugfs_remove(sc->debug.debugfs_phydir); 623 debugfs_remove(sc->debug.debugfs_phydir);
412} 624}
413 625
diff --git a/drivers/net/wireless/ath/ath5k/debug.h b/drivers/net/wireless/ath/ath5k/debug.h
index 66f69f04e55e..da24ff52e274 100644
--- a/drivers/net/wireless/ath/ath5k/debug.h
+++ b/drivers/net/wireless/ath/ath5k/debug.h
@@ -74,6 +74,8 @@ struct ath5k_dbg_info {
74 struct dentry *debugfs_registers; 74 struct dentry *debugfs_registers;
75 struct dentry *debugfs_beacon; 75 struct dentry *debugfs_beacon;
76 struct dentry *debugfs_reset; 76 struct dentry *debugfs_reset;
77 struct dentry *debugfs_antenna;
78 struct dentry *debugfs_frameerrors;
77}; 79};
78 80
79/** 81/**
diff --git a/drivers/net/wireless/ath/ath5k/desc.c b/drivers/net/wireless/ath/ath5k/desc.c
index dc30a2b70a6b..9d920fb14d5d 100644
--- a/drivers/net/wireless/ath/ath5k/desc.c
+++ b/drivers/net/wireless/ath/ath5k/desc.c
@@ -35,7 +35,8 @@
35 */ 35 */
36static int 36static int
37ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, 37ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
38 unsigned int pkt_len, unsigned int hdr_len, enum ath5k_pkt_type type, 38 unsigned int pkt_len, unsigned int hdr_len, int padsize,
39 enum ath5k_pkt_type type,
39 unsigned int tx_power, unsigned int tx_rate0, unsigned int tx_tries0, 40 unsigned int tx_power, unsigned int tx_rate0, unsigned int tx_tries0,
40 unsigned int key_index, unsigned int antenna_mode, unsigned int flags, 41 unsigned int key_index, unsigned int antenna_mode, unsigned int flags,
41 unsigned int rtscts_rate, unsigned int rtscts_duration) 42 unsigned int rtscts_rate, unsigned int rtscts_duration)
@@ -71,7 +72,7 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
71 /* Verify and set frame length */ 72 /* Verify and set frame length */
72 73
73 /* remove padding we might have added before */ 74 /* remove padding we might have added before */
74 frame_len = pkt_len - ath5k_pad_size(hdr_len) + FCS_LEN; 75 frame_len = pkt_len - padsize + FCS_LEN;
75 76
76 if (frame_len & ~AR5K_2W_TX_DESC_CTL0_FRAME_LEN) 77 if (frame_len & ~AR5K_2W_TX_DESC_CTL0_FRAME_LEN)
77 return -EINVAL; 78 return -EINVAL;
@@ -100,7 +101,7 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
100 AR5K_REG_SM(hdr_len, AR5K_2W_TX_DESC_CTL0_HEADER_LEN); 101 AR5K_REG_SM(hdr_len, AR5K_2W_TX_DESC_CTL0_HEADER_LEN);
101 } 102 }
102 103
103 /*Diferences between 5210-5211*/ 104 /*Differences between 5210-5211*/
104 if (ah->ah_version == AR5K_AR5210) { 105 if (ah->ah_version == AR5K_AR5210) {
105 switch (type) { 106 switch (type) {
106 case AR5K_PKT_TYPE_BEACON: 107 case AR5K_PKT_TYPE_BEACON:
@@ -165,6 +166,7 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
165 */ 166 */
166static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah, 167static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,
167 struct ath5k_desc *desc, unsigned int pkt_len, unsigned int hdr_len, 168 struct ath5k_desc *desc, unsigned int pkt_len, unsigned int hdr_len,
169 int padsize,
168 enum ath5k_pkt_type type, unsigned int tx_power, unsigned int tx_rate0, 170 enum ath5k_pkt_type type, unsigned int tx_power, unsigned int tx_rate0,
169 unsigned int tx_tries0, unsigned int key_index, 171 unsigned int tx_tries0, unsigned int key_index,
170 unsigned int antenna_mode, unsigned int flags, 172 unsigned int antenna_mode, unsigned int flags,
@@ -206,7 +208,7 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,
206 /* Verify and set frame length */ 208 /* Verify and set frame length */
207 209
208 /* remove padding we might have added before */ 210 /* remove padding we might have added before */
209 frame_len = pkt_len - ath5k_pad_size(hdr_len) + FCS_LEN; 211 frame_len = pkt_len - padsize + FCS_LEN;
210 212
211 if (frame_len & ~AR5K_4W_TX_DESC_CTL0_FRAME_LEN) 213 if (frame_len & ~AR5K_4W_TX_DESC_CTL0_FRAME_LEN)
212 return -EINVAL; 214 return -EINVAL;
@@ -229,7 +231,7 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,
229 AR5K_REG_SM(antenna_mode, AR5K_4W_TX_DESC_CTL0_ANT_MODE_XMIT); 231 AR5K_REG_SM(antenna_mode, AR5K_4W_TX_DESC_CTL0_ANT_MODE_XMIT);
230 tx_ctl->tx_control_1 |= AR5K_REG_SM(type, 232 tx_ctl->tx_control_1 |= AR5K_REG_SM(type,
231 AR5K_4W_TX_DESC_CTL1_FRAME_TYPE); 233 AR5K_4W_TX_DESC_CTL1_FRAME_TYPE);
232 tx_ctl->tx_control_2 = AR5K_REG_SM(tx_tries0 + AR5K_TUNE_HWTXTRIES, 234 tx_ctl->tx_control_2 = AR5K_REG_SM(tx_tries0,
233 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES0); 235 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES0);
234 tx_ctl->tx_control_3 = tx_rate0 & AR5K_4W_TX_DESC_CTL3_XMIT_RATE0; 236 tx_ctl->tx_control_3 = tx_rate0 & AR5K_4W_TX_DESC_CTL3_XMIT_RATE0;
235 237
@@ -668,12 +670,6 @@ int ath5k_hw_init_desc_functions(struct ath5k_hw *ah)
668 ah->ah_version != AR5K_AR5212) 670 ah->ah_version != AR5K_AR5212)
669 return -ENOTSUPP; 671 return -ENOTSUPP;
670 672
671 /* XXX: What is this magic value and where is it used ? */
672 if (ah->ah_version == AR5K_AR5212)
673 ah->ah_magic = AR5K_EEPROM_MAGIC_5212;
674 else if (ah->ah_version == AR5K_AR5211)
675 ah->ah_magic = AR5K_EEPROM_MAGIC_5211;
676
677 if (ah->ah_version == AR5K_AR5212) { 673 if (ah->ah_version == AR5K_AR5212) {
678 ah->ah_setup_rx_desc = ath5k_hw_setup_rx_desc; 674 ah->ah_setup_rx_desc = ath5k_hw_setup_rx_desc;
679 ah->ah_setup_tx_desc = ath5k_hw_setup_4word_tx_desc; 675 ah->ah_setup_tx_desc = ath5k_hw_setup_4word_tx_desc;
diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
index 10b52262b232..a3cbfe4fc389 100644
--- a/drivers/net/wireless/ath/ath5k/eeprom.c
+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
@@ -329,7 +329,8 @@ static int ath5k_eeprom_read_modes(struct ath5k_hw *ah, u32 *offset,
329 ee->ee_x_gain[mode] = (val >> 1) & 0xf; 329 ee->ee_x_gain[mode] = (val >> 1) & 0xf;
330 ee->ee_xpd[mode] = val & 0x1; 330 ee->ee_xpd[mode] = val & 0x1;
331 331
332 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_0) 332 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_0 &&
333 mode != AR5K_EEPROM_MODE_11B)
333 ee->ee_fixed_bias[mode] = (val >> 13) & 0x1; 334 ee->ee_fixed_bias[mode] = (val >> 13) & 0x1;
334 335
335 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_3_3) { 336 if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_3_3) {
@@ -339,6 +340,7 @@ static int ath5k_eeprom_read_modes(struct ath5k_hw *ah, u32 *offset,
339 if (mode == AR5K_EEPROM_MODE_11A) 340 if (mode == AR5K_EEPROM_MODE_11A)
340 ee->ee_xr_power[mode] = val & 0x3f; 341 ee->ee_xr_power[mode] = val & 0x3f;
341 else { 342 else {
343 /* b_DB_11[bg] and b_OB_11[bg] */
342 ee->ee_ob[mode][0] = val & 0x7; 344 ee->ee_ob[mode][0] = val & 0x7;
343 ee->ee_db[mode][0] = (val >> 3) & 0x7; 345 ee->ee_db[mode][0] = (val >> 3) & 0x7;
344 } 346 }
diff --git a/drivers/net/wireless/ath/ath5k/eeprom.h b/drivers/net/wireless/ath/ath5k/eeprom.h
index 473a483bb9c3..c4a6d5f26af4 100644
--- a/drivers/net/wireless/ath/ath5k/eeprom.h
+++ b/drivers/net/wireless/ath/ath5k/eeprom.h
@@ -24,9 +24,6 @@
24 * SERDES infos are present */ 24 * SERDES infos are present */
25#define AR5K_EEPROM_MAGIC 0x003d /* EEPROM Magic number */ 25#define AR5K_EEPROM_MAGIC 0x003d /* EEPROM Magic number */
26#define AR5K_EEPROM_MAGIC_VALUE 0x5aa5 /* Default - found on EEPROM */ 26#define AR5K_EEPROM_MAGIC_VALUE 0x5aa5 /* Default - found on EEPROM */
27#define AR5K_EEPROM_MAGIC_5212 0x0000145c /* 5212 */
28#define AR5K_EEPROM_MAGIC_5211 0x0000145b /* 5211 */
29#define AR5K_EEPROM_MAGIC_5210 0x0000145a /* 5210 */
30 27
31#define AR5K_EEPROM_IS_HB63 0x000b /* Talon detect */ 28#define AR5K_EEPROM_IS_HB63 0x000b /* Talon detect */
32 29
@@ -78,9 +75,9 @@
78#define AR5K_EEPROM_HDR_11A(_v) (((_v) >> AR5K_EEPROM_MODE_11A) & 0x1) 75#define AR5K_EEPROM_HDR_11A(_v) (((_v) >> AR5K_EEPROM_MODE_11A) & 0x1)
79#define AR5K_EEPROM_HDR_11B(_v) (((_v) >> AR5K_EEPROM_MODE_11B) & 0x1) 76#define AR5K_EEPROM_HDR_11B(_v) (((_v) >> AR5K_EEPROM_MODE_11B) & 0x1)
80#define AR5K_EEPROM_HDR_11G(_v) (((_v) >> AR5K_EEPROM_MODE_11G) & 0x1) 77#define AR5K_EEPROM_HDR_11G(_v) (((_v) >> AR5K_EEPROM_MODE_11G) & 0x1)
81#define AR5K_EEPROM_HDR_T_2GHZ_DIS(_v) (((_v) >> 3) & 0x1) /* Disable turbo for 2Ghz (?) */ 78#define AR5K_EEPROM_HDR_T_2GHZ_DIS(_v) (((_v) >> 3) & 0x1) /* Disable turbo for 2Ghz */
82#define AR5K_EEPROM_HDR_T_5GHZ_DBM(_v) (((_v) >> 4) & 0x7f) /* Max turbo power for a/XR mode (eeprom_init) */ 79#define AR5K_EEPROM_HDR_T_5GHZ_DBM(_v) (((_v) >> 4) & 0x7f) /* Max turbo power for < 2W power consumption */
83#define AR5K_EEPROM_HDR_DEVICE(_v) (((_v) >> 11) & 0x7) 80#define AR5K_EEPROM_HDR_DEVICE(_v) (((_v) >> 11) & 0x7) /* Device type (1 Cardbus, 2 PCI, 3 MiniPCI, 4 AP) */
84#define AR5K_EEPROM_HDR_RFKILL(_v) (((_v) >> 14) & 0x1) /* Device has RFKill support */ 81#define AR5K_EEPROM_HDR_RFKILL(_v) (((_v) >> 14) & 0x1) /* Device has RFKill support */
85#define AR5K_EEPROM_HDR_T_5GHZ_DIS(_v) (((_v) >> 15) & 0x1) /* Disable turbo for 5Ghz */ 82#define AR5K_EEPROM_HDR_T_5GHZ_DIS(_v) (((_v) >> 15) & 0x1) /* Disable turbo for 5Ghz */
86 83
@@ -101,7 +98,7 @@
101 98
102#define AR5K_EEPROM_MISC1 AR5K_EEPROM_INFO(5) 99#define AR5K_EEPROM_MISC1 AR5K_EEPROM_INFO(5)
103#define AR5K_EEPROM_TARGET_PWRSTART(_v) ((_v) & 0xfff) 100#define AR5K_EEPROM_TARGET_PWRSTART(_v) ((_v) & 0xfff)
104#define AR5K_EEPROM_HAS32KHZCRYSTAL(_v) (((_v) >> 14) & 0x1) 101#define AR5K_EEPROM_HAS32KHZCRYSTAL(_v) (((_v) >> 14) & 0x1) /* has 32KHz crystal for sleep mode */
105#define AR5K_EEPROM_HAS32KHZCRYSTAL_OLD(_v) (((_v) >> 15) & 0x1) 102#define AR5K_EEPROM_HAS32KHZCRYSTAL_OLD(_v) (((_v) >> 15) & 0x1)
106 103
107#define AR5K_EEPROM_MISC2 AR5K_EEPROM_INFO(6) 104#define AR5K_EEPROM_MISC2 AR5K_EEPROM_INFO(6)
@@ -114,26 +111,27 @@
114 111
115#define AR5K_EEPROM_MISC4 AR5K_EEPROM_INFO(8) 112#define AR5K_EEPROM_MISC4 AR5K_EEPROM_INFO(8)
116#define AR5K_EEPROM_CAL_DATA_START(_v) (((_v) >> 4) & 0xfff) 113#define AR5K_EEPROM_CAL_DATA_START(_v) (((_v) >> 4) & 0xfff)
117#define AR5K_EEPROM_MASK_R0(_v) (((_v) >> 2) & 0x3) 114#define AR5K_EEPROM_MASK_R0(_v) (((_v) >> 2) & 0x3) /* modes supported by radio 0 (bit 1: G, bit 2: A) */
118#define AR5K_EEPROM_MASK_R1(_v) ((_v) & 0x3) 115#define AR5K_EEPROM_MASK_R1(_v) ((_v) & 0x3) /* modes supported by radio 1 (bit 1: G, bit 2: A) */
119 116
120#define AR5K_EEPROM_MISC5 AR5K_EEPROM_INFO(9) 117#define AR5K_EEPROM_MISC5 AR5K_EEPROM_INFO(9)
121#define AR5K_EEPROM_COMP_DIS(_v) ((_v) & 0x1) 118#define AR5K_EEPROM_COMP_DIS(_v) ((_v) & 0x1) /* disable compression */
122#define AR5K_EEPROM_AES_DIS(_v) (((_v) >> 1) & 0x1) 119#define AR5K_EEPROM_AES_DIS(_v) (((_v) >> 1) & 0x1) /* disable AES */
123#define AR5K_EEPROM_FF_DIS(_v) (((_v) >> 2) & 0x1) 120#define AR5K_EEPROM_FF_DIS(_v) (((_v) >> 2) & 0x1) /* disable fast frames */
124#define AR5K_EEPROM_BURST_DIS(_v) (((_v) >> 3) & 0x1) 121#define AR5K_EEPROM_BURST_DIS(_v) (((_v) >> 3) & 0x1) /* disable bursting */
125#define AR5K_EEPROM_MAX_QCU(_v) (((_v) >> 4) & 0xf) 122#define AR5K_EEPROM_MAX_QCU(_v) (((_v) >> 4) & 0xf) /* max number of QCUs. defaults to 10 */
126#define AR5K_EEPROM_HEAVY_CLIP_EN(_v) (((_v) >> 8) & 0x1) 123#define AR5K_EEPROM_HEAVY_CLIP_EN(_v) (((_v) >> 8) & 0x1) /* enable heayy clipping */
127#define AR5K_EEPROM_KEY_CACHE_SIZE(_v) (((_v) >> 12) & 0xf) 124#define AR5K_EEPROM_KEY_CACHE_SIZE(_v) (((_v) >> 12) & 0xf) /* key cache size. defaults to 128 */
128 125
129#define AR5K_EEPROM_MISC6 AR5K_EEPROM_INFO(10) 126#define AR5K_EEPROM_MISC6 AR5K_EEPROM_INFO(10)
130#define AR5K_EEPROM_TX_CHAIN_DIS ((_v) & 0x8) 127#define AR5K_EEPROM_TX_CHAIN_DIS ((_v) & 0x7) /* MIMO chains disabled for TX bitmask */
131#define AR5K_EEPROM_RX_CHAIN_DIS (((_v) >> 3) & 0x8) 128#define AR5K_EEPROM_RX_CHAIN_DIS (((_v) >> 3) & 0x7) /* MIMO chains disabled for RX bitmask */
132#define AR5K_EEPROM_FCC_MID_EN (((_v) >> 6) & 0x1) 129#define AR5K_EEPROM_FCC_MID_EN (((_v) >> 6) & 0x1) /* 5.47-5.7GHz supported */
133#define AR5K_EEPROM_JAP_U1EVEN_EN (((_v) >> 7) & 0x1) 130#define AR5K_EEPROM_JAP_U1EVEN_EN (((_v) >> 7) & 0x1) /* Japan UNII1 band (5.15-5.25GHz) on even channels (5180, 5200, 5220, 5240) supported */
134#define AR5K_EEPROM_JAP_U2_EN (((_v) >> 8) & 0x1) 131#define AR5K_EEPROM_JAP_U2_EN (((_v) >> 8) & 0x1) /* Japan UNII2 band (5.25-5.35GHz) supported */
135#define AR5K_EEPROM_JAP_U1ODD_EN (((_v) >> 9) & 0x1) 132#define AR5K_EEPROM_JAP_MID_EN (((_v) >> 9) & 0x1) /* Japan band from 5.47-5.7GHz supported */
136#define AR5K_EEPROM_JAP_11A_NEW_EN (((_v) >> 10) & 0x1) 133#define AR5K_EEPROM_JAP_U1ODD_EN (((_v) >> 10) & 0x1) /* Japan UNII2 band (5.15-5.25GHz) on odd channels (5170, 5190, 5210, 5230) supported */
134#define AR5K_EEPROM_JAP_11A_NEW_EN (((_v) >> 11) & 0x1) /* Japan A mode enabled (using even channels) */
137 135
138/* calibration settings */ 136/* calibration settings */
139#define AR5K_EEPROM_MODES_11A(_v) AR5K_EEPROM_OFF(_v, 0x00c5, 0x00d4) 137#define AR5K_EEPROM_MODES_11A(_v) AR5K_EEPROM_OFF(_v, 0x00c5, 0x00d4)
@@ -389,7 +387,49 @@ struct ath5k_edge_power {
389 bool flag; 387 bool flag;
390}; 388};
391 389
392/* EEPROM calibration data */ 390/**
391 * struct ath5k_eeprom_info - EEPROM calibration data
392 *
393 * @ee_regdomain: ath/regd.c takes care of COUNTRY_ERD and WORLDWIDE_ROAMING
394 * flags
395 * @ee_ant_gain: Antenna gain in 0.5dB steps signed [5211 only?]
396 * @ee_cck_ofdm_gain_delta: difference in gainF to output the same power for
397 * OFDM and CCK packets
398 * @ee_cck_ofdm_power_delta: power difference between OFDM (6Mbps) and CCK
399 * (11Mbps) rate in G mode. 0.1dB steps
400 * @ee_scaled_cck_delta: for Japan Channel 14: 0.1dB resolution
401 *
402 * @ee_i_cal: Initial I coefficient to correct I/Q mismatch in the receive path
403 * @ee_q_cal: Initial Q coefficient to correct I/Q mismatch in the receive path
404 * @ee_fixed_bias: use ee_ob and ee_db settings or use automatic control
405 * @ee_switch_settling: RX/TX Switch settling time
406 * @ee_atn_tx_rx: Difference in attenuation between TX and RX in 1dB steps
407 * @ee_ant_control: Antenna Control Settings
408 * @ee_ob: Bias current for Output stage of PA
409 * B/G mode: Index [0] is used for AR2112/5112, otherwise [1]
410 * A mode: [0] 5.15-5.25 [1] 5.25-5.50 [2] 5.50-5.70 [3] 5.70-5.85 GHz
411 * @ee_db: Bias current for Output stage of PA. see @ee_ob
412 * @ee_tx_end2xlna_enable: Time difference from when BB finishes sending a frame
413 * to when the external LNA is activated
414 * @ee_tx_end2xpa_disable: Time difference from when BB finishes sending a frame
415 * to when the external PA switch is deactivated
416 * @ee_tx_frm2xpa_enable: Time difference from when MAC sends frame to when
417 * external PA switch is activated
418 * @ee_thr_62: Clear Channel Assessment (CCA) sensitivity
419 * (IEEE802.11a section 17.3.10.5 )
420 * @ee_xlna_gain: Total gain of the LNA (information only)
421 * @ee_xpd: Use external (1) or internal power detector
422 * @ee_x_gain: Gain for external power detector output (differences in EEMAP
423 * versions!)
424 * @ee_i_gain: Initial gain value after reset
425 * @ee_margin_tx_rx: Margin in dB when final attenuation stage should be used
426 *
427 * @ee_false_detect: Backoff in Sensitivity (dB) on channels with spur signals
428 * @ee_noise_floor_thr: Noise floor threshold in 1dB steps
429 * @ee_adc_desired_size: Desired amplitude for ADC, used by AGC; in 0.5 dB steps
430 * @ee_pga_desired_size: Desired output of PGA (for BB gain) in 0.5 dB steps
431 * @ee_pd_gain_overlap: PD ADC curves need to overlap in 0.5dB steps (ee_map>=2)
432 */
393struct ath5k_eeprom_info { 433struct ath5k_eeprom_info {
394 434
395 /* Header information */ 435 /* Header information */
diff --git a/drivers/net/wireless/ath/ath5k/pcu.c b/drivers/net/wireless/ath/ath5k/pcu.c
index aefe84f9c04b..1b9fcb842167 100644
--- a/drivers/net/wireless/ath/ath5k/pcu.c
+++ b/drivers/net/wireless/ath/ath5k/pcu.c
@@ -39,16 +39,16 @@
39 * ath5k_hw_set_opmode - Set PCU operating mode 39 * ath5k_hw_set_opmode - Set PCU operating mode
40 * 40 *
41 * @ah: The &struct ath5k_hw 41 * @ah: The &struct ath5k_hw
42 * @op_mode: &enum nl80211_iftype operating mode
42 * 43 *
43 * Initialize PCU for the various operating modes (AP/STA etc) 44 * Initialize PCU for the various operating modes (AP/STA etc)
44 *
45 * NOTE: ah->ah_op_mode must be set before calling this.
46 */ 45 */
47int ath5k_hw_set_opmode(struct ath5k_hw *ah) 46int ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype op_mode)
48{ 47{
49 struct ath_common *common = ath5k_hw_common(ah); 48 struct ath_common *common = ath5k_hw_common(ah);
50 u32 pcu_reg, beacon_reg, low_id, high_id; 49 u32 pcu_reg, beacon_reg, low_id, high_id;
51 50
51 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_MODE, "mode %d\n", op_mode);
52 52
53 /* Preserve rest settings */ 53 /* Preserve rest settings */
54 pcu_reg = ath5k_hw_reg_read(ah, AR5K_STA_ID1) & 0xffff0000; 54 pcu_reg = ath5k_hw_reg_read(ah, AR5K_STA_ID1) & 0xffff0000;
@@ -61,7 +61,7 @@ int ath5k_hw_set_opmode(struct ath5k_hw *ah)
61 61
62 ATH5K_TRACE(ah->ah_sc); 62 ATH5K_TRACE(ah->ah_sc);
63 63
64 switch (ah->ah_op_mode) { 64 switch (op_mode) {
65 case NL80211_IFTYPE_ADHOC: 65 case NL80211_IFTYPE_ADHOC:
66 pcu_reg |= AR5K_STA_ID1_ADHOC | AR5K_STA_ID1_KEYSRCH_MODE; 66 pcu_reg |= AR5K_STA_ID1_ADHOC | AR5K_STA_ID1_KEYSRCH_MODE;
67 beacon_reg |= AR5K_BCR_ADHOC; 67 beacon_reg |= AR5K_BCR_ADHOC;
@@ -179,25 +179,12 @@ void ath5k_hw_set_ack_bitrate_high(struct ath5k_hw *ah, bool high)
179\******************/ 179\******************/
180 180
181/** 181/**
182 * ath5k_hw_het_ack_timeout - Get ACK timeout from PCU in usec
183 *
184 * @ah: The &struct ath5k_hw
185 */
186unsigned int ath5k_hw_get_ack_timeout(struct ath5k_hw *ah)
187{
188 ATH5K_TRACE(ah->ah_sc);
189
190 return ath5k_hw_clocktoh(ah, AR5K_REG_MS(ath5k_hw_reg_read(ah,
191 AR5K_TIME_OUT), AR5K_TIME_OUT_ACK));
192}
193
194/**
195 * ath5k_hw_set_ack_timeout - Set ACK timeout on PCU 182 * ath5k_hw_set_ack_timeout - Set ACK timeout on PCU
196 * 183 *
197 * @ah: The &struct ath5k_hw 184 * @ah: The &struct ath5k_hw
198 * @timeout: Timeout in usec 185 * @timeout: Timeout in usec
199 */ 186 */
200int ath5k_hw_set_ack_timeout(struct ath5k_hw *ah, unsigned int timeout) 187static int ath5k_hw_set_ack_timeout(struct ath5k_hw *ah, unsigned int timeout)
201{ 188{
202 ATH5K_TRACE(ah->ah_sc); 189 ATH5K_TRACE(ah->ah_sc);
203 if (ath5k_hw_clocktoh(ah, AR5K_REG_MS(0xffffffff, AR5K_TIME_OUT_ACK)) 190 if (ath5k_hw_clocktoh(ah, AR5K_REG_MS(0xffffffff, AR5K_TIME_OUT_ACK))
@@ -211,24 +198,12 @@ int ath5k_hw_set_ack_timeout(struct ath5k_hw *ah, unsigned int timeout)
211} 198}
212 199
213/** 200/**
214 * ath5k_hw_get_cts_timeout - Get CTS timeout from PCU in usec
215 *
216 * @ah: The &struct ath5k_hw
217 */
218unsigned int ath5k_hw_get_cts_timeout(struct ath5k_hw *ah)
219{
220 ATH5K_TRACE(ah->ah_sc);
221 return ath5k_hw_clocktoh(ah, AR5K_REG_MS(ath5k_hw_reg_read(ah,
222 AR5K_TIME_OUT), AR5K_TIME_OUT_CTS));
223}
224
225/**
226 * ath5k_hw_set_cts_timeout - Set CTS timeout on PCU 201 * ath5k_hw_set_cts_timeout - Set CTS timeout on PCU
227 * 202 *
228 * @ah: The &struct ath5k_hw 203 * @ah: The &struct ath5k_hw
229 * @timeout: Timeout in usec 204 * @timeout: Timeout in usec
230 */ 205 */
231int ath5k_hw_set_cts_timeout(struct ath5k_hw *ah, unsigned int timeout) 206static int ath5k_hw_set_cts_timeout(struct ath5k_hw *ah, unsigned int timeout)
232{ 207{
233 ATH5K_TRACE(ah->ah_sc); 208 ATH5K_TRACE(ah->ah_sc);
234 if (ath5k_hw_clocktoh(ah, AR5K_REG_MS(0xffffffff, AR5K_TIME_OUT_CTS)) 209 if (ath5k_hw_clocktoh(ah, AR5K_REG_MS(0xffffffff, AR5K_TIME_OUT_CTS))
@@ -290,7 +265,7 @@ unsigned int ath5k_hw_get_clockrate(struct ath5k_hw *ah)
290 * 265 *
291 * @ah: The &struct ath5k_hw 266 * @ah: The &struct ath5k_hw
292 */ 267 */
293unsigned int ath5k_hw_get_default_slottime(struct ath5k_hw *ah) 268static unsigned int ath5k_hw_get_default_slottime(struct ath5k_hw *ah)
294{ 269{
295 struct ieee80211_channel *channel = ah->ah_current_channel; 270 struct ieee80211_channel *channel = ah->ah_current_channel;
296 271
@@ -308,7 +283,7 @@ unsigned int ath5k_hw_get_default_slottime(struct ath5k_hw *ah)
308 * 283 *
309 * @ah: The &struct ath5k_hw 284 * @ah: The &struct ath5k_hw
310 */ 285 */
311unsigned int ath5k_hw_get_default_sifs(struct ath5k_hw *ah) 286static unsigned int ath5k_hw_get_default_sifs(struct ath5k_hw *ah)
312{ 287{
313 struct ieee80211_channel *channel = ah->ah_current_channel; 288 struct ieee80211_channel *channel = ah->ah_current_channel;
314 289
@@ -451,42 +426,6 @@ void ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1)
451 ath5k_hw_reg_write(ah, filter1, AR5K_MCAST_FILTER1); 426 ath5k_hw_reg_write(ah, filter1, AR5K_MCAST_FILTER1);
452} 427}
453 428
454/*
455 * Set multicast filter by index
456 */
457int ath5k_hw_set_mcast_filter_idx(struct ath5k_hw *ah, u32 index)
458{
459
460 ATH5K_TRACE(ah->ah_sc);
461 if (index >= 64)
462 return -EINVAL;
463 else if (index >= 32)
464 AR5K_REG_ENABLE_BITS(ah, AR5K_MCAST_FILTER1,
465 (1 << (index - 32)));
466 else
467 AR5K_REG_ENABLE_BITS(ah, AR5K_MCAST_FILTER0, (1 << index));
468
469 return 0;
470}
471
472/*
473 * Clear Multicast filter by index
474 */
475int ath5k_hw_clear_mcast_filter_idx(struct ath5k_hw *ah, u32 index)
476{
477
478 ATH5K_TRACE(ah->ah_sc);
479 if (index >= 64)
480 return -EINVAL;
481 else if (index >= 32)
482 AR5K_REG_DISABLE_BITS(ah, AR5K_MCAST_FILTER1,
483 (1 << (index - 32)));
484 else
485 AR5K_REG_DISABLE_BITS(ah, AR5K_MCAST_FILTER0, (1 << index));
486
487 return 0;
488}
489
490/** 429/**
491 * ath5k_hw_get_rx_filter - Get current rx filter 430 * ath5k_hw_get_rx_filter - Get current rx filter
492 * 431 *
@@ -572,19 +511,6 @@ void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter)
572\****************/ 511\****************/
573 512
574/** 513/**
575 * ath5k_hw_get_tsf32 - Get a 32bit TSF
576 *
577 * @ah: The &struct ath5k_hw
578 *
579 * Returns lower 32 bits of current TSF
580 */
581u32 ath5k_hw_get_tsf32(struct ath5k_hw *ah)
582{
583 ATH5K_TRACE(ah->ah_sc);
584 return ath5k_hw_reg_read(ah, AR5K_TSF_L32);
585}
586
587/**
588 * ath5k_hw_get_tsf64 - Get the full 64bit TSF 514 * ath5k_hw_get_tsf64 - Get the full 64bit TSF
589 * 515 *
590 * @ah: The &struct ath5k_hw 516 * @ah: The &struct ath5k_hw
@@ -651,7 +577,7 @@ void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval)
651 /* 577 /*
652 * Set the additional timers by mode 578 * Set the additional timers by mode
653 */ 579 */
654 switch (ah->ah_op_mode) { 580 switch (ah->ah_sc->opmode) {
655 case NL80211_IFTYPE_MONITOR: 581 case NL80211_IFTYPE_MONITOR:
656 case NL80211_IFTYPE_STATION: 582 case NL80211_IFTYPE_STATION:
657 /* In STA mode timer1 is used as next wakeup 583 /* In STA mode timer1 is used as next wakeup
@@ -688,8 +614,8 @@ void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval)
688 * Set the beacon register and enable all timers. 614 * Set the beacon register and enable all timers.
689 */ 615 */
690 /* When in AP or Mesh Point mode zero timer0 to start TSF */ 616 /* When in AP or Mesh Point mode zero timer0 to start TSF */
691 if (ah->ah_op_mode == NL80211_IFTYPE_AP || 617 if (ah->ah_sc->opmode == NL80211_IFTYPE_AP ||
692 ah->ah_op_mode == NL80211_IFTYPE_MESH_POINT) 618 ah->ah_sc->opmode == NL80211_IFTYPE_MESH_POINT)
693 ath5k_hw_reg_write(ah, 0, AR5K_TIMER0); 619 ath5k_hw_reg_write(ah, 0, AR5K_TIMER0);
694 620
695 ath5k_hw_reg_write(ah, next_beacon, AR5K_TIMER0); 621 ath5k_hw_reg_write(ah, next_beacon, AR5K_TIMER0);
@@ -722,203 +648,6 @@ void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval)
722 648
723} 649}
724 650
725#if 0
726/*
727 * Set beacon timers
728 */
729int ath5k_hw_set_beacon_timers(struct ath5k_hw *ah,
730 const struct ath5k_beacon_state *state)
731{
732 u32 cfp_period, next_cfp, dtim, interval, next_beacon;
733
734 /*
735 * TODO: should be changed through *state
736 * review struct ath5k_beacon_state struct
737 *
738 * XXX: These are used for cfp period bellow, are they
739 * ok ? Is it O.K. for tsf here to be 0 or should we use
740 * get_tsf ?
741 */
742 u32 dtim_count = 0; /* XXX */
743 u32 cfp_count = 0; /* XXX */
744 u32 tsf = 0; /* XXX */
745
746 ATH5K_TRACE(ah->ah_sc);
747 /* Return on an invalid beacon state */
748 if (state->bs_interval < 1)
749 return -EINVAL;
750
751 interval = state->bs_interval;
752 dtim = state->bs_dtim_period;
753
754 /*
755 * PCF support?
756 */
757 if (state->bs_cfp_period > 0) {
758 /*
759 * Enable PCF mode and set the CFP
760 * (Contention Free Period) and timer registers
761 */
762 cfp_period = state->bs_cfp_period * state->bs_dtim_period *
763 state->bs_interval;
764 next_cfp = (cfp_count * state->bs_dtim_period + dtim_count) *
765 state->bs_interval;
766
767 AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1,
768 AR5K_STA_ID1_DEFAULT_ANTENNA |
769 AR5K_STA_ID1_PCF);
770 ath5k_hw_reg_write(ah, cfp_period, AR5K_CFP_PERIOD);
771 ath5k_hw_reg_write(ah, state->bs_cfp_max_duration,
772 AR5K_CFP_DUR);
773 ath5k_hw_reg_write(ah, (tsf + (next_cfp == 0 ? cfp_period :
774 next_cfp)) << 3, AR5K_TIMER2);
775 } else {
776 /* Disable PCF mode */
777 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1,
778 AR5K_STA_ID1_DEFAULT_ANTENNA |
779 AR5K_STA_ID1_PCF);
780 }
781
782 /*
783 * Enable the beacon timer register
784 */
785 ath5k_hw_reg_write(ah, state->bs_next_beacon, AR5K_TIMER0);
786
787 /*
788 * Start the beacon timers
789 */
790 ath5k_hw_reg_write(ah, (ath5k_hw_reg_read(ah, AR5K_BEACON) &
791 ~(AR5K_BEACON_PERIOD | AR5K_BEACON_TIM)) |
792 AR5K_REG_SM(state->bs_tim_offset ? state->bs_tim_offset + 4 : 0,
793 AR5K_BEACON_TIM) | AR5K_REG_SM(state->bs_interval,
794 AR5K_BEACON_PERIOD), AR5K_BEACON);
795
796 /*
797 * Write new beacon miss threshold, if it appears to be valid
798 * XXX: Figure out right values for min <= bs_bmiss_threshold <= max
799 * and return if its not in range. We can test this by reading value and
800 * setting value to a largest value and seeing which values register.
801 */
802
803 AR5K_REG_WRITE_BITS(ah, AR5K_RSSI_THR, AR5K_RSSI_THR_BMISS,
804 state->bs_bmiss_threshold);
805
806 /*
807 * Set sleep control register
808 * XXX: Didn't find this in 5210 code but since this register
809 * exists also in ar5k's 5210 headers i leave it as common code.
810 */
811 AR5K_REG_WRITE_BITS(ah, AR5K_SLEEP_CTL, AR5K_SLEEP_CTL_SLDUR,
812 (state->bs_sleep_duration - 3) << 3);
813
814 /*
815 * Set enhanced sleep registers on 5212
816 */
817 if (ah->ah_version == AR5K_AR5212) {
818 if (state->bs_sleep_duration > state->bs_interval &&
819 roundup(state->bs_sleep_duration, interval) ==
820 state->bs_sleep_duration)
821 interval = state->bs_sleep_duration;
822
823 if (state->bs_sleep_duration > dtim && (dtim == 0 ||
824 roundup(state->bs_sleep_duration, dtim) ==
825 state->bs_sleep_duration))
826 dtim = state->bs_sleep_duration;
827
828 if (interval > dtim)
829 return -EINVAL;
830
831 next_beacon = interval == dtim ? state->bs_next_dtim :
832 state->bs_next_beacon;
833
834 ath5k_hw_reg_write(ah,
835 AR5K_REG_SM((state->bs_next_dtim - 3) << 3,
836 AR5K_SLEEP0_NEXT_DTIM) |
837 AR5K_REG_SM(10, AR5K_SLEEP0_CABTO) |
838 AR5K_SLEEP0_ENH_SLEEP_EN |
839 AR5K_SLEEP0_ASSUME_DTIM, AR5K_SLEEP0);
840
841 ath5k_hw_reg_write(ah, AR5K_REG_SM((next_beacon - 3) << 3,
842 AR5K_SLEEP1_NEXT_TIM) |
843 AR5K_REG_SM(10, AR5K_SLEEP1_BEACON_TO), AR5K_SLEEP1);
844
845 ath5k_hw_reg_write(ah,
846 AR5K_REG_SM(interval, AR5K_SLEEP2_TIM_PER) |
847 AR5K_REG_SM(dtim, AR5K_SLEEP2_DTIM_PER), AR5K_SLEEP2);
848 }
849
850 return 0;
851}
852
853/*
854 * Reset beacon timers
855 */
856void ath5k_hw_reset_beacon(struct ath5k_hw *ah)
857{
858 ATH5K_TRACE(ah->ah_sc);
859 /*
860 * Disable beacon timer
861 */
862 ath5k_hw_reg_write(ah, 0, AR5K_TIMER0);
863
864 /*
865 * Disable some beacon register values
866 */
867 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1,
868 AR5K_STA_ID1_DEFAULT_ANTENNA | AR5K_STA_ID1_PCF);
869 ath5k_hw_reg_write(ah, AR5K_BEACON_PERIOD, AR5K_BEACON);
870}
871
872/*
873 * Wait for beacon queue to finish
874 */
875int ath5k_hw_beaconq_finish(struct ath5k_hw *ah, unsigned long phys_addr)
876{
877 unsigned int i;
878 int ret;
879
880 ATH5K_TRACE(ah->ah_sc);
881
882 /* 5210 doesn't have QCU*/
883 if (ah->ah_version == AR5K_AR5210) {
884 /*
885 * Wait for beaconn queue to finish by checking
886 * Control Register and Beacon Status Register.
887 */
888 for (i = AR5K_TUNE_BEACON_INTERVAL / 2; i > 0; i--) {
889 if (!(ath5k_hw_reg_read(ah, AR5K_BSR) & AR5K_BSR_TXQ1F)
890 ||
891 !(ath5k_hw_reg_read(ah, AR5K_CR) & AR5K_BSR_TXQ1F))
892 break;
893 udelay(10);
894 }
895
896 /* Timeout... */
897 if (i <= 0) {
898 /*
899 * Re-schedule the beacon queue
900 */
901 ath5k_hw_reg_write(ah, phys_addr, AR5K_NOQCU_TXDP1);
902 ath5k_hw_reg_write(ah, AR5K_BCR_TQ1V | AR5K_BCR_BDMAE,
903 AR5K_BCR);
904
905 return -EIO;
906 }
907 ret = 0;
908 } else {
909 /*5211/5212*/
910 ret = ath5k_hw_register_timeout(ah,
911 AR5K_QUEUE_STATUS(AR5K_TX_QUEUE_ID_BEACON),
912 AR5K_QCU_STS_FRMPENDCNT, 0, false);
913
914 if (AR5K_REG_READ_Q(ah, AR5K_QCU_TXE, AR5K_TX_QUEUE_ID_BEACON))
915 return -EIO;
916 }
917
918 return ret;
919}
920#endif
921
922 651
923/*********************\ 652/*********************\
924* Key table functions * 653* Key table functions *
@@ -971,19 +700,6 @@ int ath5k_hw_reset_key(struct ath5k_hw *ah, u16 entry)
971 return 0; 700 return 0;
972} 701}
973 702
974/*
975 * Check if a table entry is valid
976 */
977int ath5k_hw_is_key_valid(struct ath5k_hw *ah, u16 entry)
978{
979 ATH5K_TRACE(ah->ah_sc);
980 AR5K_ASSERT_ENTRY(entry, AR5K_KEYTABLE_SIZE);
981
982 /* Check the validation flag at the end of the entry */
983 return ath5k_hw_reg_read(ah, AR5K_KEYTABLE_MAC1(entry)) &
984 AR5K_KEYTABLE_VALID;
985}
986
987static 703static
988int ath5k_keycache_type(const struct ieee80211_key_conf *key) 704int ath5k_keycache_type(const struct ieee80211_key_conf *key)
989{ 705{
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index eff3323efb4b..a8adca62e527 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -20,8 +20,6 @@
20 * 20 *
21 */ 21 */
22 22
23#define _ATH5K_PHY
24
25#include <linux/delay.h> 23#include <linux/delay.h>
26 24
27#include "ath5k.h" 25#include "ath5k.h"
@@ -1190,7 +1188,7 @@ static s16 ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah)
1190 * The median of the values in the history is then loaded into the 1188 * The median of the values in the history is then loaded into the
1191 * hardware for its own use for RSSI and CCA measurements. 1189 * hardware for its own use for RSSI and CCA measurements.
1192 */ 1190 */
1193void ath5k_hw_update_noise_floor(struct ath5k_hw *ah) 1191static void ath5k_hw_update_noise_floor(struct ath5k_hw *ah)
1194{ 1192{
1195 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; 1193 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
1196 u32 val; 1194 u32 val;
@@ -1399,7 +1397,11 @@ static int ath5k_hw_rf511x_calibrate(struct ath5k_hw *ah,
1399 } 1397 }
1400 1398
1401 i_coffd = ((i_pwr >> 1) + (q_pwr >> 1)) >> 7; 1399 i_coffd = ((i_pwr >> 1) + (q_pwr >> 1)) >> 7;
1402 q_coffd = q_pwr >> 7; 1400
1401 if (ah->ah_version == AR5K_AR5211)
1402 q_coffd = q_pwr >> 6;
1403 else
1404 q_coffd = q_pwr >> 7;
1403 1405
1404 /* protect against divide by 0 and loss of sign bits */ 1406 /* protect against divide by 0 and loss of sign bits */
1405 if (i_coffd == 0 || q_coffd < 2) 1407 if (i_coffd == 0 || q_coffd < 2)
@@ -1768,7 +1770,7 @@ u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, unsigned int chan)
1768* Antenna control * 1770* Antenna control *
1769\*****************/ 1771\*****************/
1770 1772
1771void /*TODO:Boundary check*/ 1773static void /*TODO:Boundary check*/
1772ath5k_hw_set_def_antenna(struct ath5k_hw *ah, u8 ant) 1774ath5k_hw_set_def_antenna(struct ath5k_hw *ah, u8 ant)
1773{ 1775{
1774 ATH5K_TRACE(ah->ah_sc); 1776 ATH5K_TRACE(ah->ah_sc);
@@ -1777,16 +1779,6 @@ ath5k_hw_set_def_antenna(struct ath5k_hw *ah, u8 ant)
1777 ath5k_hw_reg_write(ah, ant & 0x7, AR5K_DEFAULT_ANTENNA); 1779 ath5k_hw_reg_write(ah, ant & 0x7, AR5K_DEFAULT_ANTENNA);
1778} 1780}
1779 1781
1780unsigned int ath5k_hw_get_def_antenna(struct ath5k_hw *ah)
1781{
1782 ATH5K_TRACE(ah->ah_sc);
1783
1784 if (ah->ah_version != AR5K_AR5210)
1785 return ath5k_hw_reg_read(ah, AR5K_DEFAULT_ANTENNA) & 0x7;
1786
1787 return false; /*XXX: What do we return for 5210 ?*/
1788}
1789
1790/* 1782/*
1791 * Enable/disable fast rx antenna diversity 1783 * Enable/disable fast rx antenna diversity
1792 */ 1784 */
@@ -1930,6 +1922,7 @@ ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode)
1930 1922
1931 ah->ah_tx_ant = tx_ant; 1923 ah->ah_tx_ant = tx_ant;
1932 ah->ah_ant_mode = ant_mode; 1924 ah->ah_ant_mode = ant_mode;
1925 ah->ah_def_ant = def_ant;
1933 1926
1934 sta_id1 |= use_def_for_tx ? AR5K_STA_ID1_DEFAULT_ANTENNA : 0; 1927 sta_id1 |= use_def_for_tx ? AR5K_STA_ID1_DEFAULT_ANTENNA : 0;
1935 sta_id1 |= update_def_on_tx ? AR5K_STA_ID1_DESC_ANTENNA : 0; 1928 sta_id1 |= update_def_on_tx ? AR5K_STA_ID1_DESC_ANTENNA : 0;
@@ -2440,19 +2433,6 @@ ath5k_combine_linear_pcdac_curves(struct ath5k_hw *ah, s16* table_min,
2440 pcdac_tmp = pcdac_high_pwr; 2433 pcdac_tmp = pcdac_high_pwr;
2441 2434
2442 edge_flag = 0x40; 2435 edge_flag = 0x40;
2443#if 0
2444 /* If both min and max power limits are in lower
2445 * power curve's range, only use the low power curve.
2446 * TODO: min/max levels are related to target
2447 * power values requested from driver/user
2448 * XXX: Is this really needed ? */
2449 if (min_pwr < table_max[1] &&
2450 max_pwr < table_max[1]) {
2451 edge_flag = 0;
2452 pcdac_tmp = pcdac_low_pwr;
2453 max_pwr_idx = (table_max[1] - table_min[1])/2;
2454 }
2455#endif
2456 } else { 2436 } else {
2457 pcdac_low_pwr = ah->ah_txpower.tmpL[1]; /* Zeroed */ 2437 pcdac_low_pwr = ah->ah_txpower.tmpL[1]; /* Zeroed */
2458 pcdac_high_pwr = ah->ah_txpower.tmpL[0]; 2438 pcdac_high_pwr = ah->ah_txpower.tmpL[0];
@@ -3143,5 +3123,3 @@ int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower)
3143 3123
3144 return ath5k_hw_txpower(ah, channel, ee_mode, txpower); 3124 return ath5k_hw_txpower(ah, channel, ee_mode, txpower);
3145} 3125}
3146
3147#undef _ATH5K_PHY
diff --git a/drivers/net/wireless/ath/ath5k/qcu.c b/drivers/net/wireless/ath/ath5k/qcu.c
index 9122a8556f45..f5831da33f7b 100644
--- a/drivers/net/wireless/ath/ath5k/qcu.c
+++ b/drivers/net/wireless/ath/ath5k/qcu.c
@@ -517,23 +517,6 @@ int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue)
517} 517}
518 518
519/* 519/*
520 * Get slot time from DCU
521 */
522unsigned int ath5k_hw_get_slot_time(struct ath5k_hw *ah)
523{
524 unsigned int slot_time_clock;
525
526 ATH5K_TRACE(ah->ah_sc);
527
528 if (ah->ah_version == AR5K_AR5210)
529 slot_time_clock = ath5k_hw_reg_read(ah, AR5K_SLOT_TIME);
530 else
531 slot_time_clock = ath5k_hw_reg_read(ah, AR5K_DCU_GBL_IFS_SLOT);
532
533 return ath5k_hw_clocktoh(ah, slot_time_clock & 0xffff);
534}
535
536/*
537 * Set slot time on DCU 520 * Set slot time on DCU
538 */ 521 */
539int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time) 522int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time)
diff --git a/drivers/net/wireless/ath/ath5k/reg.h b/drivers/net/wireless/ath/ath5k/reg.h
index 1464f89b249c..47f04932ab8b 100644
--- a/drivers/net/wireless/ath/ath5k/reg.h
+++ b/drivers/net/wireless/ath/ath5k/reg.h
@@ -1974,7 +1974,7 @@
1974#define AR5K_PHY_SETTLING 0x9844 /* Register Address */ 1974#define AR5K_PHY_SETTLING 0x9844 /* Register Address */
1975#define AR5K_PHY_SETTLING_AGC 0x0000007f /* AGC settling time */ 1975#define AR5K_PHY_SETTLING_AGC 0x0000007f /* AGC settling time */
1976#define AR5K_PHY_SETTLING_AGC_S 0 1976#define AR5K_PHY_SETTLING_AGC_S 0
1977#define AR5K_PHY_SETTLING_SWITCH 0x00003f80 /* Switch settlig time */ 1977#define AR5K_PHY_SETTLING_SWITCH 0x00003f80 /* Switch settling time */
1978#define AR5K_PHY_SETTLING_SWITCH_S 7 1978#define AR5K_PHY_SETTLING_SWITCH_S 7
1979 1979
1980/* 1980/*
diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c
index cbf28e379843..44bbbf2a6edd 100644
--- a/drivers/net/wireless/ath/ath5k/reset.c
+++ b/drivers/net/wireless/ath/ath5k/reset.c
@@ -19,8 +19,6 @@
19 * 19 *
20 */ 20 */
21 21
22#define _ATH5K_RESET
23
24/*****************************\ 22/*****************************\
25 Reset functions and helpers 23 Reset functions and helpers
26\*****************************/ 24\*****************************/
@@ -34,6 +32,27 @@
34#include "base.h" 32#include "base.h"
35#include "debug.h" 33#include "debug.h"
36 34
35/*
36 * Check if a register write has been completed
37 */
38int ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, u32 val,
39 bool is_set)
40{
41 int i;
42 u32 data;
43
44 for (i = AR5K_TUNE_REGISTER_TIMEOUT; i > 0; i--) {
45 data = ath5k_hw_reg_read(ah, reg);
46 if (is_set && (data & flag))
47 break;
48 else if ((data & flag) == val)
49 break;
50 udelay(15);
51 }
52
53 return (i <= 0) ? -EAGAIN : 0;
54}
55
37/** 56/**
38 * ath5k_hw_write_ofdm_timings - set OFDM timings on AR5212 57 * ath5k_hw_write_ofdm_timings - set OFDM timings on AR5212
39 * 58 *
@@ -221,8 +240,8 @@ static int ath5k_hw_nic_reset(struct ath5k_hw *ah, u32 val)
221/* 240/*
222 * Sleep control 241 * Sleep control
223 */ 242 */
224int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, 243static int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode,
225 bool set_chip, u16 sleep_duration) 244 bool set_chip, u16 sleep_duration)
226{ 245{
227 unsigned int i; 246 unsigned int i;
228 u32 staid, data; 247 u32 staid, data;
@@ -1017,11 +1036,6 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1017 if (ret) 1036 if (ret)
1018 return ret; 1037 return ret;
1019 1038
1020 /*
1021 * Initialize operating mode
1022 */
1023 ah->ah_op_mode = op_mode;
1024
1025 /* PHY access enable */ 1039 /* PHY access enable */
1026 if (ah->ah_mac_srev >= AR5K_SREV_AR5211) 1040 if (ah->ah_mac_srev >= AR5K_SREV_AR5211)
1027 ath5k_hw_reg_write(ah, AR5K_PHY_SHIFT_5GHZ, AR5K_PHY(0)); 1041 ath5k_hw_reg_write(ah, AR5K_PHY_SHIFT_5GHZ, AR5K_PHY(0));
@@ -1192,7 +1206,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1192 ath5k_hw_set_associd(ah); 1206 ath5k_hw_set_associd(ah);
1193 1207
1194 /* Set PCU config */ 1208 /* Set PCU config */
1195 ath5k_hw_set_opmode(ah); 1209 ath5k_hw_set_opmode(ah, op_mode);
1196 1210
1197 /* Clear any pending interrupts 1211 /* Clear any pending interrupts
1198 * PISR/SISR Not available on 5210 */ 1212 * PISR/SISR Not available on 5210 */
@@ -1378,7 +1392,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1378 * external 32KHz crystal when sleeping if one 1392 * external 32KHz crystal when sleeping if one
1379 * exists */ 1393 * exists */
1380 if (ah->ah_version == AR5K_AR5212 && 1394 if (ah->ah_version == AR5K_AR5212 &&
1381 ah->ah_op_mode != NL80211_IFTYPE_AP) 1395 op_mode != NL80211_IFTYPE_AP)
1382 ath5k_hw_set_sleep_clock(ah, true); 1396 ath5k_hw_set_sleep_clock(ah, true);
1383 1397
1384 /* 1398 /*
@@ -1388,5 +1402,3 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1388 ath5k_hw_reset_tsf(ah); 1402 ath5k_hw_reset_tsf(ah);
1389 return 0; 1403 return 0;
1390} 1404}
1391
1392#undef _ATH5K_RESET
diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
index 5774cea23a3b..35f23bdc442f 100644
--- a/drivers/net/wireless/ath/ath9k/Kconfig
+++ b/drivers/net/wireless/ath/ath9k/Kconfig
@@ -32,3 +32,24 @@ config ATH9K_DEBUGFS
32 32
33 Also required for changing debug message flags at run time. 33 Also required for changing debug message flags at run time.
34 34
35config ATH9K_HTC
36 tristate "Atheros HTC based wireless cards support"
37 depends on USB && MAC80211
38 select ATH9K_HW
39 select MAC80211_LEDS
40 select LEDS_CLASS
41 select NEW_LEDS
42 select ATH9K_COMMON
43 ---help---
44 Support for Atheros HTC based cards.
45 Chipsets supported: AR9271
46
47 For more information: http://wireless.kernel.org/en/users/Drivers/ath9k_htc
48
49 The built module will be ath9k_htc.
50
51config ATH9K_HTC_DEBUGFS
52 bool "Atheros ath9k_htc debugging"
53 depends on ATH9K_HTC && DEBUG_FS
54 ---help---
55 Say Y, if you need access to ath9k_htc's statistics.
diff --git a/drivers/net/wireless/ath/ath9k/Makefile b/drivers/net/wireless/ath/ath9k/Makefile
index 6b50d5eb9ec3..97133beda269 100644
--- a/drivers/net/wireless/ath/ath9k/Makefile
+++ b/drivers/net/wireless/ath/ath9k/Makefile
@@ -28,3 +28,13 @@ obj-$(CONFIG_ATH9K_HW) += ath9k_hw.o
28 28
29obj-$(CONFIG_ATH9K_COMMON) += ath9k_common.o 29obj-$(CONFIG_ATH9K_COMMON) += ath9k_common.o
30ath9k_common-y:= common.o 30ath9k_common-y:= common.o
31
32ath9k_htc-y += htc_hst.o \
33 hif_usb.o \
34 wmi.o \
35 htc_drv_txrx.o \
36 htc_drv_main.o \
37 htc_drv_beacon.o \
38 htc_drv_init.o
39
40obj-$(CONFIG_ATH9K_HTC) += ath9k_htc.o
diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
index 238a5744d8e9..d5026e4f484b 100644
--- a/drivers/net/wireless/ath/ath9k/calib.c
+++ b/drivers/net/wireless/ath/ath9k/calib.c
@@ -101,9 +101,13 @@ static void ath9k_hw_do_getnf(struct ath_hw *ah,
101 nf = 0 - ((nf ^ 0x1ff) + 1); 101 nf = 0 - ((nf ^ 0x1ff) + 1);
102 ath_print(common, ATH_DBG_CALIBRATE, 102 ath_print(common, ATH_DBG_CALIBRATE,
103 "NF calibrated [ctl] [chain 0] is %d\n", nf); 103 "NF calibrated [ctl] [chain 0] is %d\n", nf);
104
105 if (AR_SREV_9271(ah) && (nf >= -114))
106 nf = -116;
107
104 nfarray[0] = nf; 108 nfarray[0] = nf;
105 109
106 if (!AR_SREV_9285(ah)) { 110 if (!AR_SREV_9285(ah) && !AR_SREV_9271(ah)) {
107 if (AR_SREV_9280_10_OR_LATER(ah)) 111 if (AR_SREV_9280_10_OR_LATER(ah))
108 nf = MS(REG_READ(ah, AR_PHY_CH1_CCA), 112 nf = MS(REG_READ(ah, AR_PHY_CH1_CCA),
109 AR9280_PHY_CH1_MINCCA_PWR); 113 AR9280_PHY_CH1_MINCCA_PWR);
@@ -139,9 +143,13 @@ static void ath9k_hw_do_getnf(struct ath_hw *ah,
139 nf = 0 - ((nf ^ 0x1ff) + 1); 143 nf = 0 - ((nf ^ 0x1ff) + 1);
140 ath_print(common, ATH_DBG_CALIBRATE, 144 ath_print(common, ATH_DBG_CALIBRATE,
141 "NF calibrated [ext] [chain 0] is %d\n", nf); 145 "NF calibrated [ext] [chain 0] is %d\n", nf);
146
147 if (AR_SREV_9271(ah) && (nf >= -114))
148 nf = -116;
149
142 nfarray[3] = nf; 150 nfarray[3] = nf;
143 151
144 if (!AR_SREV_9285(ah)) { 152 if (!AR_SREV_9285(ah) && !AR_SREV_9271(ah)) {
145 if (AR_SREV_9280_10_OR_LATER(ah)) 153 if (AR_SREV_9280_10_OR_LATER(ah))
146 nf = MS(REG_READ(ah, AR_PHY_CH1_EXT_CCA), 154 nf = MS(REG_READ(ah, AR_PHY_CH1_EXT_CCA),
147 AR9280_PHY_CH1_EXT_MINCCA_PWR); 155 AR9280_PHY_CH1_EXT_MINCCA_PWR);
@@ -621,7 +629,7 @@ void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
621 u8 chainmask, rx_chain_status; 629 u8 chainmask, rx_chain_status;
622 630
623 rx_chain_status = REG_READ(ah, AR_PHY_RX_CHAINMASK); 631 rx_chain_status = REG_READ(ah, AR_PHY_RX_CHAINMASK);
624 if (AR_SREV_9285(ah)) 632 if (AR_SREV_9285(ah) || AR_SREV_9271(ah))
625 chainmask = 0x9; 633 chainmask = 0x9;
626 else if (AR_SREV_9280(ah) || AR_SREV_9287(ah)) { 634 else if (AR_SREV_9280(ah) || AR_SREV_9287(ah)) {
627 if ((rx_chain_status & 0x2) || (rx_chain_status & 0x4)) 635 if ((rx_chain_status & 0x2) || (rx_chain_status & 0x4))
@@ -715,7 +723,7 @@ void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah)
715 723
716 if (AR_SREV_9280(ah)) 724 if (AR_SREV_9280(ah))
717 noise_floor = AR_PHY_CCA_MAX_AR9280_GOOD_VALUE; 725 noise_floor = AR_PHY_CCA_MAX_AR9280_GOOD_VALUE;
718 else if (AR_SREV_9285(ah)) 726 else if (AR_SREV_9285(ah) || AR_SREV_9271(ah))
719 noise_floor = AR_PHY_CCA_MAX_AR9285_GOOD_VALUE; 727 noise_floor = AR_PHY_CCA_MAX_AR9285_GOOD_VALUE;
720 else if (AR_SREV_9287(ah)) 728 else if (AR_SREV_9287(ah))
721 noise_floor = AR_PHY_CCA_MAX_AR9287_GOOD_VALUE; 729 noise_floor = AR_PHY_CCA_MAX_AR9287_GOOD_VALUE;
@@ -1051,9 +1059,12 @@ bool ath9k_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
1051 /* Do NF cal only at longer intervals */ 1059 /* Do NF cal only at longer intervals */
1052 if (longcal) { 1060 if (longcal) {
1053 /* Do periodic PAOffset Cal */ 1061 /* Do periodic PAOffset Cal */
1054 if (AR_SREV_9271(ah)) 1062 if (AR_SREV_9271(ah)) {
1055 ath9k_hw_9271_pa_cal(ah, false); 1063 if (!ah->pacal_info.skipcount)
1056 else if (AR_SREV_9285_11_OR_LATER(ah)) { 1064 ath9k_hw_9271_pa_cal(ah, false);
1065 else
1066 ah->pacal_info.skipcount--;
1067 } else if (AR_SREV_9285_11_OR_LATER(ah)) {
1057 if (!ah->pacal_info.skipcount) 1068 if (!ah->pacal_info.skipcount)
1058 ath9k_hw_9285_pa_cal(ah, false); 1069 ath9k_hw_9285_pa_cal(ah, false);
1059 else 1070 else
diff --git a/drivers/net/wireless/ath/ath9k/common.c b/drivers/net/wireless/ath/ath9k/common.c
index 4d775ae141db..7902d287f671 100644
--- a/drivers/net/wireless/ath/ath9k/common.c
+++ b/drivers/net/wireless/ath/ath9k/common.c
@@ -286,6 +286,427 @@ int ath9k_cmn_padpos(__le16 frame_control)
286} 286}
287EXPORT_SYMBOL(ath9k_cmn_padpos); 287EXPORT_SYMBOL(ath9k_cmn_padpos);
288 288
289int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb)
290{
291 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
292
293 if (tx_info->control.hw_key) {
294 if (tx_info->control.hw_key->alg == ALG_WEP)
295 return ATH9K_KEY_TYPE_WEP;
296 else if (tx_info->control.hw_key->alg == ALG_TKIP)
297 return ATH9K_KEY_TYPE_TKIP;
298 else if (tx_info->control.hw_key->alg == ALG_CCMP)
299 return ATH9K_KEY_TYPE_AES;
300 }
301
302 return ATH9K_KEY_TYPE_CLEAR;
303}
304EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_keytype);
305
306/*
307 * Calculate the RX filter to be set in the HW.
308 */
309u32 ath9k_cmn_calcrxfilter(struct ieee80211_hw *hw, struct ath_hw *ah,
310 unsigned int rxfilter)
311{
312#define RX_FILTER_PRESERVE (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR)
313
314 u32 rfilt;
315
316 rfilt = (ath9k_hw_getrxfilter(ah) & RX_FILTER_PRESERVE)
317 | ATH9K_RX_FILTER_UCAST | ATH9K_RX_FILTER_BCAST
318 | ATH9K_RX_FILTER_MCAST;
319
320 /* If not a STA, enable processing of Probe Requests */
321 if (ah->opmode != NL80211_IFTYPE_STATION)
322 rfilt |= ATH9K_RX_FILTER_PROBEREQ;
323
324 /*
325 * Set promiscuous mode when FIF_PROMISC_IN_BSS is enabled for station
326 * mode interface or when in monitor mode. AP mode does not need this
327 * since it receives all in-BSS frames anyway.
328 */
329 if (((ah->opmode != NL80211_IFTYPE_AP) &&
330 (rxfilter & FIF_PROMISC_IN_BSS)) ||
331 (ah->opmode == NL80211_IFTYPE_MONITOR))
332 rfilt |= ATH9K_RX_FILTER_PROM;
333
334 if (rxfilter & FIF_CONTROL)
335 rfilt |= ATH9K_RX_FILTER_CONTROL;
336
337 if ((ah->opmode == NL80211_IFTYPE_STATION) &&
338 !(rxfilter & FIF_BCN_PRBRESP_PROMISC))
339 rfilt |= ATH9K_RX_FILTER_MYBEACON;
340 else
341 rfilt |= ATH9K_RX_FILTER_BEACON;
342
343 if ((AR_SREV_9280_10_OR_LATER(ah) ||
344 AR_SREV_9285_10_OR_LATER(ah)) &&
345 (ah->opmode == NL80211_IFTYPE_AP) &&
346 (rxfilter & FIF_PSPOLL))
347 rfilt |= ATH9K_RX_FILTER_PSPOLL;
348
349 if (conf_is_ht(&hw->conf))
350 rfilt |= ATH9K_RX_FILTER_COMP_BAR;
351
352 return rfilt;
353
354#undef RX_FILTER_PRESERVE
355}
356EXPORT_SYMBOL(ath9k_cmn_calcrxfilter);
357
358/*
359 * Recv initialization for opmode change.
360 */
361void ath9k_cmn_opmode_init(struct ieee80211_hw *hw, struct ath_hw *ah,
362 unsigned int rxfilter)
363{
364 struct ath_common *common = ath9k_hw_common(ah);
365
366 u32 rfilt, mfilt[2];
367
368 /* configure rx filter */
369 rfilt = ath9k_cmn_calcrxfilter(hw, ah, rxfilter);
370 ath9k_hw_setrxfilter(ah, rfilt);
371
372 /* configure bssid mask */
373 if (ah->caps.hw_caps & ATH9K_HW_CAP_BSSIDMASK)
374 ath_hw_setbssidmask(common);
375
376 /* configure operational mode */
377 ath9k_hw_setopmode(ah);
378
379 /* Handle any link-level address change. */
380 ath9k_hw_setmac(ah, common->macaddr);
381
382 /* calculate and install multicast filter */
383 mfilt[0] = mfilt[1] = ~0;
384 ath9k_hw_setmcastfilter(ah, mfilt[0], mfilt[1]);
385}
386EXPORT_SYMBOL(ath9k_cmn_opmode_init);
387
388static u32 ath9k_get_extchanmode(struct ieee80211_channel *chan,
389 enum nl80211_channel_type channel_type)
390{
391 u32 chanmode = 0;
392
393 switch (chan->band) {
394 case IEEE80211_BAND_2GHZ:
395 switch (channel_type) {
396 case NL80211_CHAN_NO_HT:
397 case NL80211_CHAN_HT20:
398 chanmode = CHANNEL_G_HT20;
399 break;
400 case NL80211_CHAN_HT40PLUS:
401 chanmode = CHANNEL_G_HT40PLUS;
402 break;
403 case NL80211_CHAN_HT40MINUS:
404 chanmode = CHANNEL_G_HT40MINUS;
405 break;
406 }
407 break;
408 case IEEE80211_BAND_5GHZ:
409 switch (channel_type) {
410 case NL80211_CHAN_NO_HT:
411 case NL80211_CHAN_HT20:
412 chanmode = CHANNEL_A_HT20;
413 break;
414 case NL80211_CHAN_HT40PLUS:
415 chanmode = CHANNEL_A_HT40PLUS;
416 break;
417 case NL80211_CHAN_HT40MINUS:
418 chanmode = CHANNEL_A_HT40MINUS;
419 break;
420 }
421 break;
422 default:
423 break;
424 }
425
426 return chanmode;
427}
428
429/*
430 * Update internal channel flags.
431 */
432void ath9k_cmn_update_ichannel(struct ieee80211_hw *hw,
433 struct ath9k_channel *ichan)
434{
435 struct ieee80211_channel *chan = hw->conf.channel;
436 struct ieee80211_conf *conf = &hw->conf;
437
438 ichan->channel = chan->center_freq;
439 ichan->chan = chan;
440
441 if (chan->band == IEEE80211_BAND_2GHZ) {
442 ichan->chanmode = CHANNEL_G;
443 ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM | CHANNEL_G;
444 } else {
445 ichan->chanmode = CHANNEL_A;
446 ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
447 }
448
449 if (conf_is_ht(conf))
450 ichan->chanmode = ath9k_get_extchanmode(chan,
451 conf->channel_type);
452}
453EXPORT_SYMBOL(ath9k_cmn_update_ichannel);
454
455/*
456 * Get the internal channel reference.
457 */
458struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw,
459 struct ath_hw *ah)
460{
461 struct ieee80211_channel *curchan = hw->conf.channel;
462 struct ath9k_channel *channel;
463 u8 chan_idx;
464
465 chan_idx = curchan->hw_value;
466 channel = &ah->channels[chan_idx];
467 ath9k_cmn_update_ichannel(hw, channel);
468
469 return channel;
470}
471EXPORT_SYMBOL(ath9k_cmn_get_curchannel);
472
473static int ath_setkey_tkip(struct ath_common *common, u16 keyix, const u8 *key,
474 struct ath9k_keyval *hk, const u8 *addr,
475 bool authenticator)
476{
477 struct ath_hw *ah = common->ah;
478 const u8 *key_rxmic;
479 const u8 *key_txmic;
480
481 key_txmic = key + NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY;
482 key_rxmic = key + NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY;
483
484 if (addr == NULL) {
485 /*
486 * Group key installation - only two key cache entries are used
487 * regardless of splitmic capability since group key is only
488 * used either for TX or RX.
489 */
490 if (authenticator) {
491 memcpy(hk->kv_mic, key_txmic, sizeof(hk->kv_mic));
492 memcpy(hk->kv_txmic, key_txmic, sizeof(hk->kv_mic));
493 } else {
494 memcpy(hk->kv_mic, key_rxmic, sizeof(hk->kv_mic));
495 memcpy(hk->kv_txmic, key_rxmic, sizeof(hk->kv_mic));
496 }
497 return ath9k_hw_set_keycache_entry(ah, keyix, hk, addr);
498 }
499 if (!common->splitmic) {
500 /* TX and RX keys share the same key cache entry. */
501 memcpy(hk->kv_mic, key_rxmic, sizeof(hk->kv_mic));
502 memcpy(hk->kv_txmic, key_txmic, sizeof(hk->kv_txmic));
503 return ath9k_hw_set_keycache_entry(ah, keyix, hk, addr);
504 }
505
506 /* Separate key cache entries for TX and RX */
507
508 /* TX key goes at first index, RX key at +32. */
509 memcpy(hk->kv_mic, key_txmic, sizeof(hk->kv_mic));
510 if (!ath9k_hw_set_keycache_entry(ah, keyix, hk, NULL)) {
511 /* TX MIC entry failed. No need to proceed further */
512 ath_print(common, ATH_DBG_FATAL,
513 "Setting TX MIC Key Failed\n");
514 return 0;
515 }
516
517 memcpy(hk->kv_mic, key_rxmic, sizeof(hk->kv_mic));
518 /* XXX delete tx key on failure? */
519 return ath9k_hw_set_keycache_entry(ah, keyix + 32, hk, addr);
520}
521
522static int ath_reserve_key_cache_slot_tkip(struct ath_common *common)
523{
524 int i;
525
526 for (i = IEEE80211_WEP_NKID; i < common->keymax / 2; i++) {
527 if (test_bit(i, common->keymap) ||
528 test_bit(i + 64, common->keymap))
529 continue; /* At least one part of TKIP key allocated */
530 if (common->splitmic &&
531 (test_bit(i + 32, common->keymap) ||
532 test_bit(i + 64 + 32, common->keymap)))
533 continue; /* At least one part of TKIP key allocated */
534
535 /* Found a free slot for a TKIP key */
536 return i;
537 }
538 return -1;
539}
540
541static int ath_reserve_key_cache_slot(struct ath_common *common)
542{
543 int i;
544
545 /* First, try to find slots that would not be available for TKIP. */
546 if (common->splitmic) {
547 for (i = IEEE80211_WEP_NKID; i < common->keymax / 4; i++) {
548 if (!test_bit(i, common->keymap) &&
549 (test_bit(i + 32, common->keymap) ||
550 test_bit(i + 64, common->keymap) ||
551 test_bit(i + 64 + 32, common->keymap)))
552 return i;
553 if (!test_bit(i + 32, common->keymap) &&
554 (test_bit(i, common->keymap) ||
555 test_bit(i + 64, common->keymap) ||
556 test_bit(i + 64 + 32, common->keymap)))
557 return i + 32;
558 if (!test_bit(i + 64, common->keymap) &&
559 (test_bit(i , common->keymap) ||
560 test_bit(i + 32, common->keymap) ||
561 test_bit(i + 64 + 32, common->keymap)))
562 return i + 64;
563 if (!test_bit(i + 64 + 32, common->keymap) &&
564 (test_bit(i, common->keymap) ||
565 test_bit(i + 32, common->keymap) ||
566 test_bit(i + 64, common->keymap)))
567 return i + 64 + 32;
568 }
569 } else {
570 for (i = IEEE80211_WEP_NKID; i < common->keymax / 2; i++) {
571 if (!test_bit(i, common->keymap) &&
572 test_bit(i + 64, common->keymap))
573 return i;
574 if (test_bit(i, common->keymap) &&
575 !test_bit(i + 64, common->keymap))
576 return i + 64;
577 }
578 }
579
580 /* No partially used TKIP slots, pick any available slot */
581 for (i = IEEE80211_WEP_NKID; i < common->keymax; i++) {
582 /* Do not allow slots that could be needed for TKIP group keys
583 * to be used. This limitation could be removed if we know that
584 * TKIP will not be used. */
585 if (i >= 64 && i < 64 + IEEE80211_WEP_NKID)
586 continue;
587 if (common->splitmic) {
588 if (i >= 32 && i < 32 + IEEE80211_WEP_NKID)
589 continue;
590 if (i >= 64 + 32 && i < 64 + 32 + IEEE80211_WEP_NKID)
591 continue;
592 }
593
594 if (!test_bit(i, common->keymap))
595 return i; /* Found a free slot for a key */
596 }
597
598 /* No free slot found */
599 return -1;
600}
601
602/*
603 * Configure encryption in the HW.
604 */
605int ath9k_cmn_key_config(struct ath_common *common,
606 struct ieee80211_vif *vif,
607 struct ieee80211_sta *sta,
608 struct ieee80211_key_conf *key)
609{
610 struct ath_hw *ah = common->ah;
611 struct ath9k_keyval hk;
612 const u8 *mac = NULL;
613 int ret = 0;
614 int idx;
615
616 memset(&hk, 0, sizeof(hk));
617
618 switch (key->alg) {
619 case ALG_WEP:
620 hk.kv_type = ATH9K_CIPHER_WEP;
621 break;
622 case ALG_TKIP:
623 hk.kv_type = ATH9K_CIPHER_TKIP;
624 break;
625 case ALG_CCMP:
626 hk.kv_type = ATH9K_CIPHER_AES_CCM;
627 break;
628 default:
629 return -EOPNOTSUPP;
630 }
631
632 hk.kv_len = key->keylen;
633 memcpy(hk.kv_val, key->key, key->keylen);
634
635 if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
636 /* For now, use the default keys for broadcast keys. This may
637 * need to change with virtual interfaces. */
638 idx = key->keyidx;
639 } else if (key->keyidx) {
640 if (WARN_ON(!sta))
641 return -EOPNOTSUPP;
642 mac = sta->addr;
643
644 if (vif->type != NL80211_IFTYPE_AP) {
645 /* Only keyidx 0 should be used with unicast key, but
646 * allow this for client mode for now. */
647 idx = key->keyidx;
648 } else
649 return -EIO;
650 } else {
651 if (WARN_ON(!sta))
652 return -EOPNOTSUPP;
653 mac = sta->addr;
654
655 if (key->alg == ALG_TKIP)
656 idx = ath_reserve_key_cache_slot_tkip(common);
657 else
658 idx = ath_reserve_key_cache_slot(common);
659 if (idx < 0)
660 return -ENOSPC; /* no free key cache entries */
661 }
662
663 if (key->alg == ALG_TKIP)
664 ret = ath_setkey_tkip(common, idx, key->key, &hk, mac,
665 vif->type == NL80211_IFTYPE_AP);
666 else
667 ret = ath9k_hw_set_keycache_entry(ah, idx, &hk, mac);
668
669 if (!ret)
670 return -EIO;
671
672 set_bit(idx, common->keymap);
673 if (key->alg == ALG_TKIP) {
674 set_bit(idx + 64, common->keymap);
675 if (common->splitmic) {
676 set_bit(idx + 32, common->keymap);
677 set_bit(idx + 64 + 32, common->keymap);
678 }
679 }
680
681 return idx;
682}
683EXPORT_SYMBOL(ath9k_cmn_key_config);
684
685/*
686 * Delete Key.
687 */
688void ath9k_cmn_key_delete(struct ath_common *common,
689 struct ieee80211_key_conf *key)
690{
691 struct ath_hw *ah = common->ah;
692
693 ath9k_hw_keyreset(ah, key->hw_key_idx);
694 if (key->hw_key_idx < IEEE80211_WEP_NKID)
695 return;
696
697 clear_bit(key->hw_key_idx, common->keymap);
698 if (key->alg != ALG_TKIP)
699 return;
700
701 clear_bit(key->hw_key_idx + 64, common->keymap);
702 if (common->splitmic) {
703 ath9k_hw_keyreset(ah, key->hw_key_idx + 32);
704 clear_bit(key->hw_key_idx + 32, common->keymap);
705 clear_bit(key->hw_key_idx + 64 + 32, common->keymap);
706 }
707}
708EXPORT_SYMBOL(ath9k_cmn_key_delete);
709
289static int __init ath9k_cmn_init(void) 710static int __init ath9k_cmn_init(void)
290{ 711{
291 return 0; 712 return 0;
diff --git a/drivers/net/wireless/ath/ath9k/common.h b/drivers/net/wireless/ath/ath9k/common.h
index 042999c2fe9c..bbcc57f6eba3 100644
--- a/drivers/net/wireless/ath/ath9k/common.h
+++ b/drivers/net/wireless/ath/ath9k/common.h
@@ -23,6 +23,8 @@
23 23
24/* Common header for Atheros 802.11n base driver cores */ 24/* Common header for Atheros 802.11n base driver cores */
25 25
26#define IEEE80211_WEP_NKID 4
27
26#define WME_NUM_TID 16 28#define WME_NUM_TID 16
27#define WME_BA_BMP_SIZE 64 29#define WME_BA_BMP_SIZE 64
28#define WME_MAX_BA WME_BA_BMP_SIZE 30#define WME_MAX_BA WME_BA_BMP_SIZE
@@ -125,3 +127,18 @@ void ath9k_cmn_rx_skb_postprocess(struct ath_common *common,
125 bool decrypt_error); 127 bool decrypt_error);
126 128
127int ath9k_cmn_padpos(__le16 frame_control); 129int ath9k_cmn_padpos(__le16 frame_control);
130int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
131u32 ath9k_cmn_calcrxfilter(struct ieee80211_hw *hw, struct ath_hw *ah,
132 unsigned int rxfilter);
133void ath9k_cmn_opmode_init(struct ieee80211_hw *hw, struct ath_hw *ah,
134 unsigned int rxfilter);
135void ath9k_cmn_update_ichannel(struct ieee80211_hw *hw,
136 struct ath9k_channel *ichan);
137struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw,
138 struct ath_hw *ah);
139int ath9k_cmn_key_config(struct ath_common *common,
140 struct ieee80211_vif *vif,
141 struct ieee80211_sta *sta,
142 struct ieee80211_key_conf *key);
143void ath9k_cmn_key_delete(struct ath_common *common,
144 struct ieee80211_key_conf *key);
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
new file mode 100644
index 000000000000..fc4f6e8c9ef3
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -0,0 +1,993 @@
1/*
2 * Copyright (c) 2010 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 "htc.h"
18
19#define ATH9K_FW_USB_DEV(devid, fw) \
20 { USB_DEVICE(0x0cf3, devid), .driver_info = (unsigned long) fw }
21
22static struct usb_device_id ath9k_hif_usb_ids[] = {
23 ATH9K_FW_USB_DEV(0x9271, "ar9271.fw"),
24 { },
25};
26
27MODULE_DEVICE_TABLE(usb, ath9k_hif_usb_ids);
28
29static int __hif_usb_tx(struct hif_device_usb *hif_dev);
30
31static void hif_usb_regout_cb(struct urb *urb)
32{
33 struct cmd_buf *cmd = (struct cmd_buf *)urb->context;
34 struct hif_device_usb *hif_dev = cmd->hif_dev;
35
36 if (!hif_dev) {
37 usb_free_urb(urb);
38 if (cmd) {
39 if (cmd->skb)
40 dev_kfree_skb_any(cmd->skb);
41 kfree(cmd);
42 }
43 return;
44 }
45
46 switch (urb->status) {
47 case 0:
48 break;
49 case -ENOENT:
50 case -ECONNRESET:
51 break;
52 case -ENODEV:
53 case -ESHUTDOWN:
54 return;
55 default:
56 break;
57 }
58
59 if (cmd) {
60 ath9k_htc_txcompletion_cb(cmd->hif_dev->htc_handle,
61 cmd->skb, 1);
62 kfree(cmd);
63 usb_free_urb(urb);
64 }
65}
66
67static int hif_usb_send_regout(struct hif_device_usb *hif_dev,
68 struct sk_buff *skb)
69{
70 struct urb *urb;
71 struct cmd_buf *cmd;
72 int ret = 0;
73
74 urb = usb_alloc_urb(0, GFP_KERNEL);
75 if (urb == NULL)
76 return -ENOMEM;
77
78 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
79 if (cmd == NULL) {
80 usb_free_urb(urb);
81 return -ENOMEM;
82 }
83
84 cmd->skb = skb;
85 cmd->hif_dev = hif_dev;
86
87 usb_fill_int_urb(urb, hif_dev->udev,
88 usb_sndintpipe(hif_dev->udev, USB_REG_OUT_PIPE),
89 skb->data, skb->len,
90 hif_usb_regout_cb, cmd, 1);
91
92 ret = usb_submit_urb(urb, GFP_KERNEL);
93 if (ret) {
94 usb_free_urb(urb);
95 kfree(cmd);
96 }
97
98 return ret;
99}
100
101static void hif_usb_tx_cb(struct urb *urb)
102{
103 struct tx_buf *tx_buf = (struct tx_buf *) urb->context;
104 struct hif_device_usb *hif_dev = tx_buf->hif_dev;
105 struct sk_buff *skb;
106 bool drop, flush;
107
108 if (!hif_dev)
109 return;
110
111 switch (urb->status) {
112 case 0:
113 break;
114 case -ENOENT:
115 case -ECONNRESET:
116 break;
117 case -ENODEV:
118 case -ESHUTDOWN:
119 return;
120 default:
121 break;
122 }
123
124 if (tx_buf) {
125 spin_lock(&hif_dev->tx.tx_lock);
126 drop = !!(hif_dev->tx.flags & HIF_USB_TX_STOP);
127 flush = !!(hif_dev->tx.flags & HIF_USB_TX_FLUSH);
128 spin_unlock(&hif_dev->tx.tx_lock);
129
130 while ((skb = __skb_dequeue(&tx_buf->skb_queue)) != NULL) {
131 if (!drop && !flush) {
132 ath9k_htc_txcompletion_cb(hif_dev->htc_handle,
133 skb, 1);
134 TX_STAT_INC(skb_completed);
135 } else {
136 dev_kfree_skb_any(skb);
137 }
138 }
139
140 if (flush)
141 return;
142
143 tx_buf->len = tx_buf->offset = 0;
144 __skb_queue_head_init(&tx_buf->skb_queue);
145
146 spin_lock(&hif_dev->tx.tx_lock);
147 list_del(&tx_buf->list);
148 list_add_tail(&tx_buf->list, &hif_dev->tx.tx_buf);
149 hif_dev->tx.tx_buf_cnt++;
150 if (!drop)
151 __hif_usb_tx(hif_dev); /* Check for pending SKBs */
152 TX_STAT_INC(buf_completed);
153 spin_unlock(&hif_dev->tx.tx_lock);
154 }
155}
156
157/* TX lock has to be taken */
158static int __hif_usb_tx(struct hif_device_usb *hif_dev)
159{
160 struct tx_buf *tx_buf = NULL;
161 struct sk_buff *nskb = NULL;
162 int ret = 0, i;
163 u16 *hdr, tx_skb_cnt = 0;
164 u8 *buf;
165
166 if (hif_dev->tx.tx_skb_cnt == 0)
167 return 0;
168
169 /* Check if a free TX buffer is available */
170 if (list_empty(&hif_dev->tx.tx_buf))
171 return 0;
172
173 tx_buf = list_first_entry(&hif_dev->tx.tx_buf, struct tx_buf, list);
174 list_del(&tx_buf->list);
175 list_add_tail(&tx_buf->list, &hif_dev->tx.tx_pending);
176 hif_dev->tx.tx_buf_cnt--;
177
178 tx_skb_cnt = min_t(u16, hif_dev->tx.tx_skb_cnt, MAX_TX_AGGR_NUM);
179
180 for (i = 0; i < tx_skb_cnt; i++) {
181 nskb = __skb_dequeue(&hif_dev->tx.tx_skb_queue);
182
183 /* Should never be NULL */
184 BUG_ON(!nskb);
185
186 hif_dev->tx.tx_skb_cnt--;
187
188 buf = tx_buf->buf;
189 buf += tx_buf->offset;
190 hdr = (u16 *)buf;
191 *hdr++ = nskb->len;
192 *hdr++ = ATH_USB_TX_STREAM_MODE_TAG;
193 buf += 4;
194 memcpy(buf, nskb->data, nskb->len);
195 tx_buf->len = nskb->len + 4;
196
197 if (i < (tx_skb_cnt - 1))
198 tx_buf->offset += (((tx_buf->len - 1) / 4) + 1) * 4;
199
200 if (i == (tx_skb_cnt - 1))
201 tx_buf->len += tx_buf->offset;
202
203 __skb_queue_tail(&tx_buf->skb_queue, nskb);
204 TX_STAT_INC(skb_queued);
205 }
206
207 usb_fill_bulk_urb(tx_buf->urb, hif_dev->udev,
208 usb_sndbulkpipe(hif_dev->udev, USB_WLAN_TX_PIPE),
209 tx_buf->buf, tx_buf->len,
210 hif_usb_tx_cb, tx_buf);
211
212 ret = usb_submit_urb(tx_buf->urb, GFP_ATOMIC);
213 if (ret) {
214 tx_buf->len = tx_buf->offset = 0;
215 __skb_queue_purge(&tx_buf->skb_queue);
216 __skb_queue_head_init(&tx_buf->skb_queue);
217 list_move_tail(&tx_buf->list, &hif_dev->tx.tx_buf);
218 hif_dev->tx.tx_buf_cnt++;
219 }
220
221 if (!ret)
222 TX_STAT_INC(buf_queued);
223
224 return ret;
225}
226
227static int hif_usb_send_tx(struct hif_device_usb *hif_dev, struct sk_buff *skb,
228 struct ath9k_htc_tx_ctl *tx_ctl)
229{
230 unsigned long flags;
231
232 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
233
234 if (hif_dev->tx.flags & HIF_USB_TX_STOP) {
235 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
236 return -ENODEV;
237 }
238
239 /* Check if the max queue count has been reached */
240 if (hif_dev->tx.tx_skb_cnt > MAX_TX_BUF_NUM) {
241 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
242 return -ENOMEM;
243 }
244
245 __skb_queue_tail(&hif_dev->tx.tx_skb_queue, skb);
246 hif_dev->tx.tx_skb_cnt++;
247
248 /* Send normal frames immediately */
249 if (!tx_ctl || (tx_ctl && (tx_ctl->type == ATH9K_HTC_NORMAL)))
250 __hif_usb_tx(hif_dev);
251
252 /* Check if AMPDUs have to be sent immediately */
253 if (tx_ctl && (tx_ctl->type == ATH9K_HTC_AMPDU) &&
254 (hif_dev->tx.tx_buf_cnt == MAX_TX_URB_NUM) &&
255 (hif_dev->tx.tx_skb_cnt < 2)) {
256 __hif_usb_tx(hif_dev);
257 }
258
259 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
260
261 return 0;
262}
263
264static void hif_usb_start(void *hif_handle, u8 pipe_id)
265{
266 struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle;
267 unsigned long flags;
268
269 hif_dev->flags |= HIF_USB_START;
270
271 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
272 hif_dev->tx.flags &= ~HIF_USB_TX_STOP;
273 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
274}
275
276static void hif_usb_stop(void *hif_handle, u8 pipe_id)
277{
278 struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle;
279 unsigned long flags;
280
281 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
282 __skb_queue_purge(&hif_dev->tx.tx_skb_queue);
283 hif_dev->tx.tx_skb_cnt = 0;
284 hif_dev->tx.flags |= HIF_USB_TX_STOP;
285 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
286}
287
288static int hif_usb_send(void *hif_handle, u8 pipe_id, struct sk_buff *skb,
289 struct ath9k_htc_tx_ctl *tx_ctl)
290{
291 struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle;
292 int ret = 0;
293
294 switch (pipe_id) {
295 case USB_WLAN_TX_PIPE:
296 ret = hif_usb_send_tx(hif_dev, skb, tx_ctl);
297 break;
298 case USB_REG_OUT_PIPE:
299 ret = hif_usb_send_regout(hif_dev, skb);
300 break;
301 default:
302 ret = -EINVAL;
303 break;
304 }
305
306 return ret;
307}
308
309static struct ath9k_htc_hif hif_usb = {
310 .transport = ATH9K_HIF_USB,
311 .name = "ath9k_hif_usb",
312
313 .control_ul_pipe = USB_REG_OUT_PIPE,
314 .control_dl_pipe = USB_REG_IN_PIPE,
315
316 .start = hif_usb_start,
317 .stop = hif_usb_stop,
318 .send = hif_usb_send,
319};
320
321static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
322 struct sk_buff *skb)
323{
324 struct sk_buff *nskb, *skb_pool[8];
325 int index = 0, i = 0, chk_idx, len = skb->len;
326 int rx_remain_len = 0, rx_pkt_len = 0;
327 u16 pkt_len, pkt_tag, pool_index = 0;
328 u8 *ptr;
329
330 rx_remain_len = hif_dev->rx_remain_len;
331 rx_pkt_len = hif_dev->rx_transfer_len;
332
333 if (rx_remain_len != 0) {
334 struct sk_buff *remain_skb = hif_dev->remain_skb;
335
336 if (remain_skb) {
337 ptr = (u8 *) remain_skb->data;
338
339 index = rx_remain_len;
340 rx_remain_len -= hif_dev->rx_pad_len;
341 ptr += rx_pkt_len;
342
343 memcpy(ptr, skb->data, rx_remain_len);
344
345 rx_pkt_len += rx_remain_len;
346 hif_dev->rx_remain_len = 0;
347 skb_put(remain_skb, rx_pkt_len);
348
349 skb_pool[pool_index++] = remain_skb;
350
351 } else {
352 index = rx_remain_len;
353 }
354 }
355
356 while (index < len) {
357 ptr = (u8 *) skb->data;
358
359 pkt_len = ptr[index] + (ptr[index+1] << 8);
360 pkt_tag = ptr[index+2] + (ptr[index+3] << 8);
361
362 if (pkt_tag == ATH_USB_RX_STREAM_MODE_TAG) {
363 u16 pad_len;
364
365 pad_len = 4 - (pkt_len & 0x3);
366 if (pad_len == 4)
367 pad_len = 0;
368
369 chk_idx = index;
370 index = index + 4 + pkt_len + pad_len;
371
372 if (index > MAX_RX_BUF_SIZE) {
373 hif_dev->rx_remain_len = index - MAX_RX_BUF_SIZE;
374 hif_dev->rx_transfer_len =
375 MAX_RX_BUF_SIZE - chk_idx - 4;
376 hif_dev->rx_pad_len = pad_len;
377
378 nskb = __dev_alloc_skb(pkt_len + 32,
379 GFP_ATOMIC);
380 if (!nskb) {
381 dev_err(&hif_dev->udev->dev,
382 "ath9k_htc: RX memory allocation"
383 " error\n");
384 goto err;
385 }
386 skb_reserve(nskb, 32);
387 RX_STAT_INC(skb_allocated);
388
389 memcpy(nskb->data, &(skb->data[chk_idx+4]),
390 hif_dev->rx_transfer_len);
391
392 /* Record the buffer pointer */
393 hif_dev->remain_skb = nskb;
394 } else {
395 nskb = __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC);
396 if (!nskb) {
397 dev_err(&hif_dev->udev->dev,
398 "ath9k_htc: RX memory allocation"
399 " error\n");
400 goto err;
401 }
402 skb_reserve(nskb, 32);
403 RX_STAT_INC(skb_allocated);
404
405 memcpy(nskb->data, &(skb->data[chk_idx+4]), pkt_len);
406 skb_put(nskb, pkt_len);
407 skb_pool[pool_index++] = nskb;
408 }
409 } else {
410 RX_STAT_INC(skb_dropped);
411 dev_kfree_skb_any(skb);
412 return;
413 }
414 }
415
416err:
417 dev_kfree_skb_any(skb);
418
419 for (i = 0; i < pool_index; i++) {
420 ath9k_htc_rx_msg(hif_dev->htc_handle, skb_pool[i],
421 skb_pool[i]->len, USB_WLAN_RX_PIPE);
422 RX_STAT_INC(skb_completed);
423 }
424}
425
426static void ath9k_hif_usb_rx_cb(struct urb *urb)
427{
428 struct sk_buff *skb = (struct sk_buff *) urb->context;
429 struct sk_buff *nskb;
430 struct hif_device_usb *hif_dev = (struct hif_device_usb *)
431 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
432 int ret;
433
434 if (!hif_dev)
435 goto free;
436
437 switch (urb->status) {
438 case 0:
439 break;
440 case -ENOENT:
441 case -ECONNRESET:
442 case -ENODEV:
443 case -ESHUTDOWN:
444 goto free;
445 default:
446 goto resubmit;
447 }
448
449 if (likely(urb->actual_length != 0)) {
450 skb_put(skb, urb->actual_length);
451
452 nskb = __dev_alloc_skb(MAX_RX_BUF_SIZE, GFP_ATOMIC);
453 if (!nskb)
454 goto resubmit;
455
456 usb_fill_bulk_urb(urb, hif_dev->udev,
457 usb_rcvbulkpipe(hif_dev->udev,
458 USB_WLAN_RX_PIPE),
459 nskb->data, MAX_RX_BUF_SIZE,
460 ath9k_hif_usb_rx_cb, nskb);
461
462 ret = usb_submit_urb(urb, GFP_ATOMIC);
463 if (ret) {
464 dev_kfree_skb_any(nskb);
465 goto free;
466 }
467
468 ath9k_hif_usb_rx_stream(hif_dev, skb);
469 return;
470 }
471
472resubmit:
473 skb_reset_tail_pointer(skb);
474 skb_trim(skb, 0);
475
476 ret = usb_submit_urb(urb, GFP_ATOMIC);
477 if (ret)
478 goto free;
479
480 return;
481free:
482 dev_kfree_skb_any(skb);
483}
484
485static void ath9k_hif_usb_reg_in_cb(struct urb *urb)
486{
487 struct sk_buff *skb = (struct sk_buff *) urb->context;
488 struct sk_buff *nskb;
489 struct hif_device_usb *hif_dev = (struct hif_device_usb *)
490 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
491 int ret;
492
493 if (!hif_dev)
494 goto free;
495
496 switch (urb->status) {
497 case 0:
498 break;
499 case -ENOENT:
500 case -ECONNRESET:
501 case -ENODEV:
502 case -ESHUTDOWN:
503 goto free;
504 default:
505 goto resubmit;
506 }
507
508 if (likely(urb->actual_length != 0)) {
509 skb_put(skb, urb->actual_length);
510
511 nskb = __dev_alloc_skb(MAX_REG_IN_BUF_SIZE, GFP_ATOMIC);
512 if (!nskb)
513 goto resubmit;
514
515 usb_fill_int_urb(urb, hif_dev->udev,
516 usb_rcvintpipe(hif_dev->udev, USB_REG_IN_PIPE),
517 nskb->data, MAX_REG_IN_BUF_SIZE,
518 ath9k_hif_usb_reg_in_cb, nskb, 1);
519
520 ret = usb_submit_urb(urb, GFP_ATOMIC);
521 if (ret) {
522 dev_kfree_skb_any(nskb);
523 goto free;
524 }
525
526 ath9k_htc_rx_msg(hif_dev->htc_handle, skb,
527 skb->len, USB_REG_IN_PIPE);
528
529 return;
530 }
531
532resubmit:
533 skb_reset_tail_pointer(skb);
534 skb_trim(skb, 0);
535
536 ret = usb_submit_urb(urb, GFP_ATOMIC);
537 if (ret)
538 goto free;
539
540 return;
541free:
542 dev_kfree_skb_any(skb);
543}
544
545static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)
546{
547 unsigned long flags;
548 struct tx_buf *tx_buf = NULL, *tx_buf_tmp = NULL;
549
550 list_for_each_entry_safe(tx_buf, tx_buf_tmp, &hif_dev->tx.tx_buf, list) {
551 list_del(&tx_buf->list);
552 usb_free_urb(tx_buf->urb);
553 kfree(tx_buf->buf);
554 kfree(tx_buf);
555 }
556
557 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
558 hif_dev->tx.flags |= HIF_USB_TX_FLUSH;
559 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
560
561 list_for_each_entry_safe(tx_buf, tx_buf_tmp,
562 &hif_dev->tx.tx_pending, list) {
563 usb_kill_urb(tx_buf->urb);
564 list_del(&tx_buf->list);
565 usb_free_urb(tx_buf->urb);
566 kfree(tx_buf->buf);
567 kfree(tx_buf);
568 }
569
570 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
571 hif_dev->tx.flags &= ~HIF_USB_TX_FLUSH;
572 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
573}
574
575static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev)
576{
577 struct tx_buf *tx_buf;
578 int i;
579
580 INIT_LIST_HEAD(&hif_dev->tx.tx_buf);
581 INIT_LIST_HEAD(&hif_dev->tx.tx_pending);
582 spin_lock_init(&hif_dev->tx.tx_lock);
583 __skb_queue_head_init(&hif_dev->tx.tx_skb_queue);
584
585 for (i = 0; i < MAX_TX_URB_NUM; i++) {
586 tx_buf = kzalloc(sizeof(struct tx_buf), GFP_KERNEL);
587 if (!tx_buf)
588 goto err;
589
590 tx_buf->buf = kzalloc(MAX_TX_BUF_SIZE, GFP_KERNEL);
591 if (!tx_buf->buf)
592 goto err;
593
594 tx_buf->urb = usb_alloc_urb(0, GFP_KERNEL);
595 if (!tx_buf->urb)
596 goto err;
597
598 tx_buf->hif_dev = hif_dev;
599 __skb_queue_head_init(&tx_buf->skb_queue);
600
601 list_add_tail(&tx_buf->list, &hif_dev->tx.tx_buf);
602 }
603
604 hif_dev->tx.tx_buf_cnt = MAX_TX_URB_NUM;
605
606 return 0;
607err:
608 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
609 return -ENOMEM;
610}
611
612static void ath9k_hif_usb_dealloc_rx_skbs(struct hif_device_usb *hif_dev)
613{
614 int i;
615
616 for (i = 0; i < MAX_RX_URB_NUM; i++) {
617 if (hif_dev->wlan_rx_data_urb[i]) {
618 if (hif_dev->wlan_rx_data_urb[i]->transfer_buffer)
619 dev_kfree_skb_any((void *)
620 hif_dev->wlan_rx_data_urb[i]->context);
621 }
622 }
623}
624
625static void ath9k_hif_usb_dealloc_rx_urbs(struct hif_device_usb *hif_dev)
626{
627 int i;
628
629 for (i = 0; i < MAX_RX_URB_NUM; i++) {
630 if (hif_dev->wlan_rx_data_urb[i]) {
631 usb_kill_urb(hif_dev->wlan_rx_data_urb[i]);
632 usb_free_urb(hif_dev->wlan_rx_data_urb[i]);
633 hif_dev->wlan_rx_data_urb[i] = NULL;
634 }
635 }
636}
637
638static int ath9k_hif_usb_prep_rx_urb(struct hif_device_usb *hif_dev,
639 struct urb *urb)
640{
641 struct sk_buff *skb;
642
643 skb = __dev_alloc_skb(MAX_RX_BUF_SIZE, GFP_KERNEL);
644 if (!skb)
645 return -ENOMEM;
646
647 usb_fill_bulk_urb(urb, hif_dev->udev,
648 usb_rcvbulkpipe(hif_dev->udev, USB_WLAN_RX_PIPE),
649 skb->data, MAX_RX_BUF_SIZE,
650 ath9k_hif_usb_rx_cb, skb);
651 return 0;
652}
653
654static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
655{
656 int i, ret;
657
658 for (i = 0; i < MAX_RX_URB_NUM; i++) {
659
660 /* Allocate URB */
661 hif_dev->wlan_rx_data_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
662 if (hif_dev->wlan_rx_data_urb[i] == NULL) {
663 ret = -ENOMEM;
664 goto err_rx_urb;
665 }
666
667 /* Allocate buffer */
668 ret = ath9k_hif_usb_prep_rx_urb(hif_dev,
669 hif_dev->wlan_rx_data_urb[i]);
670 if (ret)
671 goto err_rx_urb;
672
673 /* Submit URB */
674 ret = usb_submit_urb(hif_dev->wlan_rx_data_urb[i], GFP_KERNEL);
675 if (ret)
676 goto err_rx_urb;
677
678 }
679
680 return 0;
681
682err_rx_urb:
683 ath9k_hif_usb_dealloc_rx_skbs(hif_dev);
684 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
685 return ret;
686}
687
688static void ath9k_hif_usb_dealloc_reg_in_urb(struct hif_device_usb *hif_dev)
689{
690 if (hif_dev->reg_in_urb) {
691 usb_kill_urb(hif_dev->reg_in_urb);
692 usb_free_urb(hif_dev->reg_in_urb);
693 hif_dev->reg_in_urb = NULL;
694 }
695}
696
697static int ath9k_hif_usb_alloc_reg_in_urb(struct hif_device_usb *hif_dev)
698{
699 struct sk_buff *skb;
700
701 hif_dev->reg_in_urb = usb_alloc_urb(0, GFP_KERNEL);
702 if (hif_dev->reg_in_urb == NULL)
703 return -ENOMEM;
704
705 skb = __dev_alloc_skb(MAX_REG_IN_BUF_SIZE, GFP_KERNEL);
706 if (!skb)
707 goto err;
708
709 usb_fill_int_urb(hif_dev->reg_in_urb, hif_dev->udev,
710 usb_rcvintpipe(hif_dev->udev, USB_REG_IN_PIPE),
711 skb->data, MAX_REG_IN_BUF_SIZE,
712 ath9k_hif_usb_reg_in_cb, skb, 1);
713
714 if (usb_submit_urb(hif_dev->reg_in_urb, GFP_KERNEL) != 0)
715 goto err_skb;
716
717 return 0;
718
719err_skb:
720 dev_kfree_skb_any(skb);
721err:
722 ath9k_hif_usb_dealloc_reg_in_urb(hif_dev);
723 return -ENOMEM;
724}
725
726static int ath9k_hif_usb_alloc_urbs(struct hif_device_usb *hif_dev)
727{
728 /* TX */
729 if (ath9k_hif_usb_alloc_tx_urbs(hif_dev) < 0)
730 goto err;
731
732 /* RX */
733 if (ath9k_hif_usb_alloc_rx_urbs(hif_dev) < 0)
734 goto err;
735
736 /* Register Read/Write */
737 if (ath9k_hif_usb_alloc_reg_in_urb(hif_dev) < 0)
738 goto err;
739
740 return 0;
741err:
742 return -ENOMEM;
743}
744
745static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
746{
747 int transfer, err;
748 const void *data = hif_dev->firmware->data;
749 size_t len = hif_dev->firmware->size;
750 u32 addr = AR9271_FIRMWARE;
751 u8 *buf = kzalloc(4096, GFP_KERNEL);
752
753 if (!buf)
754 return -ENOMEM;
755
756 while (len) {
757 transfer = min_t(int, len, 4096);
758 memcpy(buf, data, transfer);
759
760 err = usb_control_msg(hif_dev->udev,
761 usb_sndctrlpipe(hif_dev->udev, 0),
762 FIRMWARE_DOWNLOAD, 0x40 | USB_DIR_OUT,
763 addr >> 8, 0, buf, transfer, HZ);
764 if (err < 0) {
765 kfree(buf);
766 return err;
767 }
768
769 len -= transfer;
770 data += transfer;
771 addr += transfer;
772 }
773 kfree(buf);
774
775 /*
776 * Issue FW download complete command to firmware.
777 */
778 err = usb_control_msg(hif_dev->udev, usb_sndctrlpipe(hif_dev->udev, 0),
779 FIRMWARE_DOWNLOAD_COMP,
780 0x40 | USB_DIR_OUT,
781 AR9271_FIRMWARE_TEXT >> 8, 0, NULL, 0, HZ);
782 if (err)
783 return -EIO;
784
785 dev_info(&hif_dev->udev->dev, "ath9k_htc: Transferred FW: %s, size: %ld\n",
786 "ar9271.fw", (unsigned long) hif_dev->firmware->size);
787
788 return 0;
789}
790
791static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev,
792 const char *fw_name)
793{
794 int ret;
795
796 /* Request firmware */
797 ret = request_firmware(&hif_dev->firmware, fw_name, &hif_dev->udev->dev);
798 if (ret) {
799 dev_err(&hif_dev->udev->dev,
800 "ath9k_htc: Firmware - %s not found\n", fw_name);
801 goto err_fw_req;
802 }
803
804 /* Download firmware */
805 ret = ath9k_hif_usb_download_fw(hif_dev);
806 if (ret) {
807 dev_err(&hif_dev->udev->dev,
808 "ath9k_htc: Firmware - %s download failed\n", fw_name);
809 goto err_fw_download;
810 }
811
812 /* Alloc URBs */
813 ret = ath9k_hif_usb_alloc_urbs(hif_dev);
814 if (ret) {
815 dev_err(&hif_dev->udev->dev,
816 "ath9k_htc: Unable to allocate URBs\n");
817 goto err_urb;
818 }
819
820 return 0;
821
822err_urb:
823 /* Nothing */
824err_fw_download:
825 release_firmware(hif_dev->firmware);
826err_fw_req:
827 hif_dev->firmware = NULL;
828 return ret;
829}
830
831static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev)
832{
833 ath9k_hif_usb_dealloc_reg_in_urb(hif_dev);
834 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
835 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
836}
837
838static void ath9k_hif_usb_dev_deinit(struct hif_device_usb *hif_dev)
839{
840 ath9k_hif_usb_dealloc_urbs(hif_dev);
841 if (hif_dev->firmware)
842 release_firmware(hif_dev->firmware);
843}
844
845static int ath9k_hif_usb_probe(struct usb_interface *interface,
846 const struct usb_device_id *id)
847{
848 struct usb_device *udev = interface_to_usbdev(interface);
849 struct hif_device_usb *hif_dev;
850 const char *fw_name = (const char *) id->driver_info;
851 int ret = 0;
852
853 hif_dev = kzalloc(sizeof(struct hif_device_usb), GFP_KERNEL);
854 if (!hif_dev) {
855 ret = -ENOMEM;
856 goto err_alloc;
857 }
858
859 usb_get_dev(udev);
860 hif_dev->udev = udev;
861 hif_dev->interface = interface;
862 hif_dev->device_id = id->idProduct;
863#ifdef CONFIG_PM
864 udev->reset_resume = 1;
865#endif
866 usb_set_intfdata(interface, hif_dev);
867
868 ret = ath9k_hif_usb_dev_init(hif_dev, fw_name);
869 if (ret) {
870 ret = -EINVAL;
871 goto err_hif_init_usb;
872 }
873
874 hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev);
875 if (hif_dev->htc_handle == NULL) {
876 ret = -ENOMEM;
877 goto err_htc_hw_alloc;
878 }
879
880 ret = ath9k_htc_hw_init(&hif_usb, hif_dev->htc_handle, hif_dev,
881 &hif_dev->udev->dev, hif_dev->device_id,
882 ATH9K_HIF_USB);
883 if (ret) {
884 ret = -EINVAL;
885 goto err_htc_hw_init;
886 }
887
888 dev_info(&hif_dev->udev->dev, "ath9k_htc: USB layer initialized\n");
889
890 return 0;
891
892err_htc_hw_init:
893 ath9k_htc_hw_free(hif_dev->htc_handle);
894err_htc_hw_alloc:
895 ath9k_hif_usb_dev_deinit(hif_dev);
896err_hif_init_usb:
897 usb_set_intfdata(interface, NULL);
898 kfree(hif_dev);
899 usb_put_dev(udev);
900err_alloc:
901 return ret;
902}
903
904static void ath9k_hif_usb_disconnect(struct usb_interface *interface)
905{
906 struct usb_device *udev = interface_to_usbdev(interface);
907 struct hif_device_usb *hif_dev =
908 (struct hif_device_usb *) usb_get_intfdata(interface);
909
910 if (hif_dev) {
911 ath9k_htc_hw_deinit(hif_dev->htc_handle, true);
912 ath9k_htc_hw_free(hif_dev->htc_handle);
913 ath9k_hif_usb_dev_deinit(hif_dev);
914 usb_set_intfdata(interface, NULL);
915 }
916
917 if (hif_dev->flags & HIF_USB_START)
918 usb_reset_device(udev);
919
920 kfree(hif_dev);
921 dev_info(&udev->dev, "ath9k_htc: USB layer deinitialized\n");
922 usb_put_dev(udev);
923}
924
925#ifdef CONFIG_PM
926static int ath9k_hif_usb_suspend(struct usb_interface *interface,
927 pm_message_t message)
928{
929 struct hif_device_usb *hif_dev =
930 (struct hif_device_usb *) usb_get_intfdata(interface);
931
932 ath9k_hif_usb_dealloc_urbs(hif_dev);
933
934 return 0;
935}
936
937static int ath9k_hif_usb_resume(struct usb_interface *interface)
938{
939 struct hif_device_usb *hif_dev =
940 (struct hif_device_usb *) usb_get_intfdata(interface);
941 int ret;
942
943 ret = ath9k_hif_usb_alloc_urbs(hif_dev);
944 if (ret)
945 return ret;
946
947 if (hif_dev->firmware) {
948 ret = ath9k_hif_usb_download_fw(hif_dev);
949 if (ret)
950 goto fail_resume;
951 } else {
952 ath9k_hif_usb_dealloc_urbs(hif_dev);
953 return -EIO;
954 }
955
956 mdelay(100);
957
958 ret = ath9k_htc_resume(hif_dev->htc_handle);
959
960 if (ret)
961 goto fail_resume;
962
963 return 0;
964
965fail_resume:
966 ath9k_hif_usb_dealloc_urbs(hif_dev);
967
968 return ret;
969}
970#endif
971
972static struct usb_driver ath9k_hif_usb_driver = {
973 .name = "ath9k_hif_usb",
974 .probe = ath9k_hif_usb_probe,
975 .disconnect = ath9k_hif_usb_disconnect,
976#ifdef CONFIG_PM
977 .suspend = ath9k_hif_usb_suspend,
978 .resume = ath9k_hif_usb_resume,
979 .reset_resume = ath9k_hif_usb_resume,
980#endif
981 .id_table = ath9k_hif_usb_ids,
982 .soft_unbind = 1,
983};
984
985int ath9k_hif_usb_init(void)
986{
987 return usb_register(&ath9k_hif_usb_driver);
988}
989
990void ath9k_hif_usb_exit(void)
991{
992 usb_deregister(&ath9k_hif_usb_driver);
993}
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h
new file mode 100644
index 000000000000..7cc3762a6789
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.h
@@ -0,0 +1,105 @@
1/*
2 * Copyright (c) 2010 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#ifndef HTC_USB_H
18#define HTC_USB_H
19
20#define AR9271_FIRMWARE 0x501000
21#define AR9271_FIRMWARE_TEXT 0x903000
22
23#define FIRMWARE_DOWNLOAD 0x30
24#define FIRMWARE_DOWNLOAD_COMP 0x31
25
26#define ATH_USB_RX_STREAM_MODE_TAG 0x4e00
27#define ATH_USB_TX_STREAM_MODE_TAG 0x697e
28
29/* FIXME: Verify these numbers (with Windows) */
30#define MAX_TX_URB_NUM 8
31#define MAX_TX_BUF_NUM 1024
32#define MAX_TX_BUF_SIZE 32768
33#define MAX_TX_AGGR_NUM 20
34
35#define MAX_RX_URB_NUM 8
36#define MAX_RX_BUF_SIZE 16384
37
38#define MAX_REG_OUT_URB_NUM 1
39#define MAX_REG_OUT_BUF_NUM 8
40
41#define MAX_REG_IN_BUF_SIZE 64
42
43/* USB Endpoint definition */
44#define USB_WLAN_TX_PIPE 1
45#define USB_WLAN_RX_PIPE 2
46#define USB_REG_IN_PIPE 3
47#define USB_REG_OUT_PIPE 4
48
49#define HIF_USB_MAX_RXPIPES 2
50#define HIF_USB_MAX_TXPIPES 4
51
52struct tx_buf {
53 u8 *buf;
54 u16 len;
55 u16 offset;
56 struct urb *urb;
57 struct sk_buff_head skb_queue;
58 struct hif_device_usb *hif_dev;
59 struct list_head list;
60};
61
62#define HIF_USB_TX_STOP BIT(0)
63#define HIF_USB_TX_FLUSH BIT(1)
64
65struct hif_usb_tx {
66 u8 flags;
67 u8 tx_buf_cnt;
68 u16 tx_skb_cnt;
69 struct sk_buff_head tx_skb_queue;
70 struct list_head tx_buf;
71 struct list_head tx_pending;
72 spinlock_t tx_lock;
73};
74
75struct cmd_buf {
76 struct sk_buff *skb;
77 struct hif_device_usb *hif_dev;
78};
79
80#define HIF_USB_START BIT(0)
81
82struct hif_device_usb {
83 u16 device_id;
84 struct usb_device *udev;
85 struct usb_interface *interface;
86 const struct firmware *firmware;
87 struct htc_target *htc_handle;
88 u8 flags;
89
90 struct hif_usb_tx tx;
91
92 struct urb *wlan_rx_data_urb[MAX_RX_URB_NUM];
93 struct urb *reg_in_urb;
94
95 struct sk_buff *remain_skb;
96 int rx_remain_len;
97 int rx_pkt_len;
98 int rx_transfer_len;
99 int rx_pad_len;
100};
101
102int ath9k_hif_usb_init(void);
103void ath9k_hif_usb_exit(void);
104
105#endif /* HTC_USB_H */
diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
new file mode 100644
index 000000000000..777064945fca
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -0,0 +1,441 @@
1/*
2 * Copyright (c) 2010 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#ifndef HTC_H
18#define HTC_H
19
20#include <linux/module.h>
21#include <linux/usb.h>
22#include <linux/firmware.h>
23#include <linux/skbuff.h>
24#include <linux/netdevice.h>
25#include <linux/leds.h>
26#include <net/mac80211.h>
27
28#include "common.h"
29#include "htc_hst.h"
30#include "hif_usb.h"
31#include "wmi.h"
32
33#define ATH_STA_SHORT_CALINTERVAL 1000 /* 1 second */
34#define ATH_ANI_POLLINTERVAL 100 /* 100 ms */
35#define ATH_LONG_CALINTERVAL 30000 /* 30 seconds */
36#define ATH_RESTART_CALINTERVAL 1200000 /* 20 minutes */
37
38#define ATH_DEFAULT_BMISS_LIMIT 10
39#define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024)
40#define TSF_TO_TU(_h, _l) \
41 ((((u32)(_h)) << 22) | (((u32)(_l)) >> 10))
42
43extern struct ieee80211_ops ath9k_htc_ops;
44extern int htc_modparam_nohwcrypt;
45
46enum htc_phymode {
47 HTC_MODE_AUTO = 0,
48 HTC_MODE_11A = 1,
49 HTC_MODE_11B = 2,
50 HTC_MODE_11G = 3,
51 HTC_MODE_FH = 4,
52 HTC_MODE_TURBO_A = 5,
53 HTC_MODE_TURBO_G = 6,
54 HTC_MODE_11NA = 7,
55 HTC_MODE_11NG = 8
56};
57
58enum htc_opmode {
59 HTC_M_STA = 1,
60 HTC_M_IBSS = 0,
61 HTC_M_AHDEMO = 3,
62 HTC_M_HOSTAP = 6,
63 HTC_M_MONITOR = 8,
64 HTC_M_WDS = 2
65};
66
67#define ATH9K_HTC_HDRSPACE sizeof(struct htc_frame_hdr)
68#define ATH9K_HTC_AMPDU 1
69#define ATH9K_HTC_NORMAL 2
70
71#define ATH9K_HTC_TX_CTSONLY 0x1
72#define ATH9K_HTC_TX_RTSCTS 0x2
73#define ATH9K_HTC_TX_USE_MIN_RATE 0x100
74
75struct tx_frame_hdr {
76 u8 data_type;
77 u8 node_idx;
78 u8 vif_idx;
79 u8 tidno;
80 u32 flags; /* ATH9K_HTC_TX_* */
81 u8 key_type;
82 u8 keyix;
83 u8 reserved[26];
84} __packed;
85
86struct tx_mgmt_hdr {
87 u8 node_idx;
88 u8 vif_idx;
89 u8 tidno;
90 u8 flags;
91 u8 key_type;
92 u8 keyix;
93 u16 reserved;
94} __packed;
95
96struct tx_beacon_header {
97 u8 len_changed;
98 u8 vif_index;
99 u16 rev;
100} __packed;
101
102struct ath9k_htc_target_hw {
103 u32 flags;
104 u32 flags_ext;
105 u32 ampdu_limit;
106 u8 ampdu_subframes;
107 u8 tx_chainmask;
108 u8 tx_chainmask_legacy;
109 u8 rtscts_ratecode;
110 u8 protmode;
111} __packed;
112
113struct ath9k_htc_cap_target {
114 u32 flags;
115 u32 flags_ext;
116 u32 ampdu_limit;
117 u8 ampdu_subframes;
118 u8 tx_chainmask;
119 u8 tx_chainmask_legacy;
120 u8 rtscts_ratecode;
121 u8 protmode;
122} __packed;
123
124struct ath9k_htc_target_vif {
125 u8 index;
126 u8 des_bssid[ETH_ALEN];
127 enum htc_opmode opmode;
128 u8 myaddr[ETH_ALEN];
129 u8 bssid[ETH_ALEN];
130 u32 flags;
131 u32 flags_ext;
132 u16 ps_sta;
133 u16 rtsthreshold;
134 u8 ath_cap;
135 u8 node;
136 s8 mcast_rate;
137} __packed;
138
139#define ATH_HTC_STA_AUTH 0x0001
140#define ATH_HTC_STA_QOS 0x0002
141#define ATH_HTC_STA_ERP 0x0004
142#define ATH_HTC_STA_HT 0x0008
143
144/* FIXME: UAPSD variables */
145struct ath9k_htc_target_sta {
146 u16 associd;
147 u16 txpower;
148 u32 ucastkey;
149 u8 macaddr[ETH_ALEN];
150 u8 bssid[ETH_ALEN];
151 u8 sta_index;
152 u8 vif_index;
153 u8 vif_sta;
154 u16 flags; /* ATH_HTC_STA_* */
155 u16 htcap;
156 u8 valid;
157 u16 capinfo;
158 struct ath9k_htc_target_hw *hw;
159 struct ath9k_htc_target_vif *vif;
160 u16 txseqmgmt;
161 u8 is_vif_sta;
162 u16 maxampdu;
163 u16 iv16;
164 u32 iv32;
165} __packed;
166
167struct ath9k_htc_target_aggr {
168 u8 sta_index;
169 u8 tidno;
170 u8 aggr_enable;
171 u8 padding;
172} __packed;
173
174#define ATH_HTC_RATE_MAX 30
175
176#define WLAN_RC_DS_FLAG 0x01
177#define WLAN_RC_40_FLAG 0x02
178#define WLAN_RC_SGI_FLAG 0x04
179#define WLAN_RC_HT_FLAG 0x08
180
181struct ath9k_htc_rateset {
182 u8 rs_nrates;
183 u8 rs_rates[ATH_HTC_RATE_MAX];
184};
185
186struct ath9k_htc_rate {
187 struct ath9k_htc_rateset legacy_rates;
188 struct ath9k_htc_rateset ht_rates;
189} __packed;
190
191struct ath9k_htc_target_rate {
192 u8 sta_index;
193 u8 isnew;
194 u32 capflags;
195 struct ath9k_htc_rate rates;
196};
197
198struct ath9k_htc_target_stats {
199 u32 tx_shortretry;
200 u32 tx_longretry;
201 u32 tx_xretries;
202 u32 ht_txunaggr_xretry;
203 u32 ht_tx_xretries;
204} __packed;
205
206struct ath9k_htc_vif {
207 u8 index;
208};
209
210#define ATH9K_HTC_MAX_STA 8
211#define ATH9K_HTC_MAX_TID 8
212
213enum tid_aggr_state {
214 AGGR_STOP = 0,
215 AGGR_PROGRESS,
216 AGGR_START,
217 AGGR_OPERATIONAL
218};
219
220struct ath9k_htc_sta {
221 u8 index;
222 enum tid_aggr_state tid_state[ATH9K_HTC_MAX_TID];
223};
224
225struct ath9k_htc_aggr_work {
226 u16 tid;
227 u8 sta_addr[ETH_ALEN];
228 struct ieee80211_hw *hw;
229 struct ieee80211_vif *vif;
230 enum ieee80211_ampdu_mlme_action action;
231 struct mutex mutex;
232};
233
234#define ATH9K_HTC_RXBUF 256
235#define HTC_RX_FRAME_HEADER_SIZE 40
236
237struct ath9k_htc_rxbuf {
238 bool in_process;
239 struct sk_buff *skb;
240 struct ath_htc_rx_status rxstatus;
241 struct list_head list;
242};
243
244struct ath9k_htc_rx {
245 int last_rssi; /* FIXME: per-STA */
246 struct list_head rxbuf;
247 spinlock_t rxbuflock;
248};
249
250struct ath9k_htc_tx_ctl {
251 u8 type; /* ATH9K_HTC_* */
252};
253
254#ifdef CONFIG_ATH9K_HTC_DEBUGFS
255
256#define TX_STAT_INC(c) (hif_dev->htc_handle->drv_priv->debug.tx_stats.c++)
257#define RX_STAT_INC(c) (hif_dev->htc_handle->drv_priv->debug.rx_stats.c++)
258
259struct ath_tx_stats {
260 u32 buf_queued;
261 u32 buf_completed;
262 u32 skb_queued;
263 u32 skb_completed;
264};
265
266struct ath_rx_stats {
267 u32 skb_allocated;
268 u32 skb_completed;
269 u32 skb_dropped;
270};
271
272struct ath9k_debug {
273 struct dentry *debugfs_phy;
274 struct dentry *debugfs_tgt_stats;
275 struct dentry *debugfs_xmit;
276 struct dentry *debugfs_recv;
277 struct ath_tx_stats tx_stats;
278 struct ath_rx_stats rx_stats;
279 u32 txrate;
280};
281
282#else
283
284#define TX_STAT_INC(c) do { } while (0)
285#define RX_STAT_INC(c) do { } while (0)
286
287#endif /* CONFIG_ATH9K_HTC_DEBUGFS */
288
289#define ATH_LED_PIN_DEF 1
290#define ATH_LED_PIN_9287 8
291#define ATH_LED_PIN_9271 15
292#define ATH_LED_ON_DURATION_IDLE 350 /* in msecs */
293#define ATH_LED_OFF_DURATION_IDLE 250 /* in msecs */
294
295enum ath_led_type {
296 ATH_LED_RADIO,
297 ATH_LED_ASSOC,
298 ATH_LED_TX,
299 ATH_LED_RX
300};
301
302struct ath_led {
303 struct ath9k_htc_priv *priv;
304 struct led_classdev led_cdev;
305 enum ath_led_type led_type;
306 struct delayed_work brightness_work;
307 char name[32];
308 bool registered;
309 int brightness;
310};
311
312#define OP_INVALID BIT(0)
313#define OP_SCANNING BIT(1)
314#define OP_FULL_RESET BIT(2)
315#define OP_LED_ASSOCIATED BIT(3)
316#define OP_LED_ON BIT(4)
317#define OP_PREAMBLE_SHORT BIT(5)
318#define OP_PROTECT_ENABLE BIT(6)
319#define OP_TXAGGR BIT(7)
320#define OP_ASSOCIATED BIT(8)
321#define OP_ENABLE_BEACON BIT(9)
322#define OP_LED_DEINIT BIT(10)
323
324struct ath9k_htc_priv {
325 struct device *dev;
326 struct ieee80211_hw *hw;
327 struct ath_hw *ah;
328 struct htc_target *htc;
329 struct wmi *wmi;
330
331 enum htc_endpoint_id wmi_cmd_ep;
332 enum htc_endpoint_id beacon_ep;
333 enum htc_endpoint_id cab_ep;
334 enum htc_endpoint_id uapsd_ep;
335 enum htc_endpoint_id mgmt_ep;
336 enum htc_endpoint_id data_be_ep;
337 enum htc_endpoint_id data_bk_ep;
338 enum htc_endpoint_id data_vi_ep;
339 enum htc_endpoint_id data_vo_ep;
340
341 u16 op_flags;
342 u16 curtxpow;
343 u16 txpowlimit;
344 u16 nvifs;
345 u16 nstations;
346 u16 seq_no;
347 u32 bmiss_cnt;
348
349 struct sk_buff *beacon;
350 spinlock_t beacon_lock;
351
352 struct ieee80211_vif *vif;
353 unsigned int rxfilter;
354 struct tasklet_struct wmi_tasklet;
355 struct tasklet_struct rx_tasklet;
356 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
357 struct ath9k_htc_rx rx;
358 struct tasklet_struct tx_tasklet;
359 struct sk_buff_head tx_queue;
360 struct ath9k_htc_aggr_work aggr_work;
361 struct delayed_work ath9k_aggr_work;
362 struct delayed_work ath9k_ani_work;
363
364 struct ath_led radio_led;
365 struct ath_led assoc_led;
366 struct ath_led tx_led;
367 struct ath_led rx_led;
368 struct delayed_work ath9k_led_blink_work;
369 int led_on_duration;
370 int led_off_duration;
371 int led_on_cnt;
372 int led_off_cnt;
373 int hwq_map[ATH9K_WME_AC_VO+1];
374
375#ifdef CONFIG_ATH9K_HTC_DEBUGFS
376 struct ath9k_debug debug;
377#endif
378 struct ath9k_htc_target_rate tgt_rate;
379
380 struct mutex mutex;
381};
382
383static inline void ath_read_cachesize(struct ath_common *common, int *csz)
384{
385 common->bus_ops->read_cachesize(common, csz);
386}
387
388void ath9k_htc_beacon_config(struct ath9k_htc_priv *priv,
389 struct ieee80211_vif *vif,
390 struct ieee80211_bss_conf *bss_conf);
391void ath9k_htc_swba(struct ath9k_htc_priv *priv, u8 beacon_pending);
392void ath9k_htc_beacon_update(struct ath9k_htc_priv *priv,
393 struct ieee80211_vif *vif);
394
395void ath9k_htc_rxep(void *priv, struct sk_buff *skb,
396 enum htc_endpoint_id ep_id);
397void ath9k_htc_txep(void *priv, struct sk_buff *skb, enum htc_endpoint_id ep_id,
398 bool txok);
399
400void ath9k_htc_station_work(struct work_struct *work);
401void ath9k_htc_aggr_work(struct work_struct *work);
402void ath9k_ani_work(struct work_struct *work);;
403
404int ath9k_tx_init(struct ath9k_htc_priv *priv);
405void ath9k_tx_tasklet(unsigned long data);
406int ath9k_htc_tx_start(struct ath9k_htc_priv *priv, struct sk_buff *skb);
407void ath9k_tx_cleanup(struct ath9k_htc_priv *priv);
408bool ath9k_htc_txq_setup(struct ath9k_htc_priv *priv,
409 enum ath9k_tx_queue_subtype qtype);
410int get_hw_qnum(u16 queue, int *hwq_map);
411int ath_htc_txq_update(struct ath9k_htc_priv *priv, int qnum,
412 struct ath9k_tx_queue_info *qinfo);
413
414int ath9k_rx_init(struct ath9k_htc_priv *priv);
415void ath9k_rx_cleanup(struct ath9k_htc_priv *priv);
416void ath9k_host_rx_init(struct ath9k_htc_priv *priv);
417void ath9k_rx_tasklet(unsigned long data);
418
419void ath9k_start_rfkill_poll(struct ath9k_htc_priv *priv);
420void ath9k_init_leds(struct ath9k_htc_priv *priv);
421void ath9k_deinit_leds(struct ath9k_htc_priv *priv);
422
423int ath9k_htc_probe_device(struct htc_target *htc_handle, struct device *dev,
424 u16 devid);
425void ath9k_htc_disconnect_device(struct htc_target *htc_handle, bool hotunplug);
426#ifdef CONFIG_PM
427int ath9k_htc_resume(struct htc_target *htc_handle);
428#endif
429#ifdef CONFIG_ATH9K_HTC_DEBUGFS
430int ath9k_htc_debug_create_root(void);
431void ath9k_htc_debug_remove_root(void);
432int ath9k_htc_init_debug(struct ath_hw *ah);
433void ath9k_htc_exit_debug(struct ath_hw *ah);
434#else
435static inline int ath9k_htc_debug_create_root(void) { return 0; };
436static inline void ath9k_htc_debug_remove_root(void) {};
437static inline int ath9k_htc_init_debug(struct ath_hw *ah) { return 0; };
438static inline void ath9k_htc_exit_debug(struct ath_hw *ah) {};
439#endif /* CONFIG_ATH9K_HTC_DEBUGFS */
440
441#endif /* HTC_H */
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
new file mode 100644
index 000000000000..25f5b5377bac
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c
@@ -0,0 +1,260 @@
1/*
2 * Copyright (c) 2010 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 "htc.h"
18
19#define FUDGE 2
20
21static void ath9k_htc_beacon_config_sta(struct ath9k_htc_priv *priv,
22 struct ieee80211_bss_conf *bss_conf)
23{
24 struct ath_common *common = ath9k_hw_common(priv->ah);
25 struct ath9k_beacon_state bs;
26 enum ath9k_int imask = 0;
27 int dtimperiod, dtimcount, sleepduration;
28 int cfpperiod, cfpcount, bmiss_timeout;
29 u32 nexttbtt = 0, intval, tsftu, htc_imask = 0;
30 u64 tsf;
31 int num_beacons, offset, dtim_dec_count, cfp_dec_count;
32 int ret;
33 u8 cmd_rsp;
34
35 memset(&bs, 0, sizeof(bs));
36
37 intval = bss_conf->beacon_int & ATH9K_BEACON_PERIOD;
38 bmiss_timeout = (ATH_DEFAULT_BMISS_LIMIT * bss_conf->beacon_int);
39
40 /*
41 * Setup dtim and cfp parameters according to
42 * last beacon we received (which may be none).
43 */
44 dtimperiod = bss_conf->dtim_period;
45 if (dtimperiod <= 0) /* NB: 0 if not known */
46 dtimperiod = 1;
47 dtimcount = 1;
48 if (dtimcount >= dtimperiod) /* NB: sanity check */
49 dtimcount = 0;
50 cfpperiod = 1; /* NB: no PCF support yet */
51 cfpcount = 0;
52
53 sleepduration = intval;
54 if (sleepduration <= 0)
55 sleepduration = intval;
56
57 /*
58 * Pull nexttbtt forward to reflect the current
59 * TSF and calculate dtim+cfp state for the result.
60 */
61 tsf = ath9k_hw_gettsf64(priv->ah);
62 tsftu = TSF_TO_TU(tsf>>32, tsf) + FUDGE;
63
64 num_beacons = tsftu / intval + 1;
65 offset = tsftu % intval;
66 nexttbtt = tsftu - offset;
67 if (offset)
68 nexttbtt += intval;
69
70 /* DTIM Beacon every dtimperiod Beacon */
71 dtim_dec_count = num_beacons % dtimperiod;
72 /* CFP every cfpperiod DTIM Beacon */
73 cfp_dec_count = (num_beacons / dtimperiod) % cfpperiod;
74 if (dtim_dec_count)
75 cfp_dec_count++;
76
77 dtimcount -= dtim_dec_count;
78 if (dtimcount < 0)
79 dtimcount += dtimperiod;
80
81 cfpcount -= cfp_dec_count;
82 if (cfpcount < 0)
83 cfpcount += cfpperiod;
84
85 bs.bs_intval = intval;
86 bs.bs_nexttbtt = nexttbtt;
87 bs.bs_dtimperiod = dtimperiod*intval;
88 bs.bs_nextdtim = bs.bs_nexttbtt + dtimcount*intval;
89 bs.bs_cfpperiod = cfpperiod*bs.bs_dtimperiod;
90 bs.bs_cfpnext = bs.bs_nextdtim + cfpcount*bs.bs_dtimperiod;
91 bs.bs_cfpmaxduration = 0;
92
93 /*
94 * Calculate the number of consecutive beacons to miss* before taking
95 * a BMISS interrupt. The configuration is specified in TU so we only
96 * need calculate based on the beacon interval. Note that we clamp the
97 * result to at most 15 beacons.
98 */
99 if (sleepduration > intval) {
100 bs.bs_bmissthreshold = ATH_DEFAULT_BMISS_LIMIT / 2;
101 } else {
102 bs.bs_bmissthreshold = DIV_ROUND_UP(bmiss_timeout, intval);
103 if (bs.bs_bmissthreshold > 15)
104 bs.bs_bmissthreshold = 15;
105 else if (bs.bs_bmissthreshold <= 0)
106 bs.bs_bmissthreshold = 1;
107 }
108
109 /*
110 * Calculate sleep duration. The configuration is given in ms.
111 * We ensure a multiple of the beacon period is used. Also, if the sleep
112 * duration is greater than the DTIM period then it makes senses
113 * to make it a multiple of that.
114 *
115 * XXX fixed at 100ms
116 */
117
118 bs.bs_sleepduration = roundup(IEEE80211_MS_TO_TU(100), sleepduration);
119 if (bs.bs_sleepduration > bs.bs_dtimperiod)
120 bs.bs_sleepduration = bs.bs_dtimperiod;
121
122 /* TSF out of range threshold fixed at 1 second */
123 bs.bs_tsfoor_threshold = ATH9K_TSFOOR_THRESHOLD;
124
125 ath_print(common, ATH_DBG_BEACON, "tsf: %llu tsftu: %u\n", tsf, tsftu);
126 ath_print(common, ATH_DBG_BEACON,
127 "bmiss: %u sleep: %u cfp-period: %u maxdur: %u next: %u\n",
128 bs.bs_bmissthreshold, bs.bs_sleepduration,
129 bs.bs_cfpperiod, bs.bs_cfpmaxduration, bs.bs_cfpnext);
130
131 /* Set the computed STA beacon timers */
132
133 WMI_CMD(WMI_DISABLE_INTR_CMDID);
134 ath9k_hw_set_sta_beacon_timers(priv->ah, &bs);
135 imask |= ATH9K_INT_BMISS;
136 htc_imask = cpu_to_be32(imask);
137 WMI_CMD_BUF(WMI_ENABLE_INTR_CMDID, &htc_imask);
138}
139
140static void ath9k_htc_beacon_config_adhoc(struct ath9k_htc_priv *priv,
141 struct ieee80211_bss_conf *bss_conf)
142{
143 struct ath_common *common = ath9k_hw_common(priv->ah);
144 enum ath9k_int imask = 0;
145 u32 nexttbtt, intval, htc_imask = 0;
146 int ret;
147 u8 cmd_rsp;
148
149 intval = bss_conf->beacon_int & ATH9K_BEACON_PERIOD;
150 nexttbtt = intval;
151 intval |= ATH9K_BEACON_ENA;
152 if (priv->op_flags & OP_ENABLE_BEACON)
153 imask |= ATH9K_INT_SWBA;
154
155 ath_print(common, ATH_DBG_BEACON,
156 "IBSS Beacon config, intval: %d, imask: 0x%x\n",
157 bss_conf->beacon_int, imask);
158
159 WMI_CMD(WMI_DISABLE_INTR_CMDID);
160 ath9k_hw_beaconinit(priv->ah, nexttbtt, intval);
161 priv->bmiss_cnt = 0;
162 htc_imask = cpu_to_be32(imask);
163 WMI_CMD_BUF(WMI_ENABLE_INTR_CMDID, &htc_imask);
164}
165
166void ath9k_htc_beacon_update(struct ath9k_htc_priv *priv,
167 struct ieee80211_vif *vif)
168{
169 struct ath_common *common = ath9k_hw_common(priv->ah);
170
171 spin_lock_bh(&priv->beacon_lock);
172
173 if (priv->beacon)
174 dev_kfree_skb_any(priv->beacon);
175
176 priv->beacon = ieee80211_beacon_get(priv->hw, vif);
177 if (!priv->beacon)
178 ath_print(common, ATH_DBG_BEACON,
179 "Unable to allocate beacon\n");
180
181 spin_unlock_bh(&priv->beacon_lock);
182}
183
184void ath9k_htc_swba(struct ath9k_htc_priv *priv, u8 beacon_pending)
185{
186 struct ath9k_htc_vif *avp = (void *)priv->vif->drv_priv;
187 struct tx_beacon_header beacon_hdr;
188 struct ath9k_htc_tx_ctl tx_ctl;
189 struct ieee80211_tx_info *info;
190 u8 *tx_fhdr;
191
192 memset(&beacon_hdr, 0, sizeof(struct tx_beacon_header));
193 memset(&tx_ctl, 0, sizeof(struct ath9k_htc_tx_ctl));
194
195 /* FIXME: Handle BMISS */
196 if (beacon_pending != 0) {
197 priv->bmiss_cnt++;
198 return;
199 }
200
201 spin_lock_bh(&priv->beacon_lock);
202
203 if (unlikely(priv->op_flags & OP_SCANNING)) {
204 spin_unlock_bh(&priv->beacon_lock);
205 return;
206 }
207
208 if (unlikely(priv->beacon == NULL)) {
209 spin_unlock_bh(&priv->beacon_lock);
210 return;
211 }
212
213 /* Free the old SKB first */
214 dev_kfree_skb_any(priv->beacon);
215
216 /* Get a new beacon */
217 priv->beacon = ieee80211_beacon_get(priv->hw, priv->vif);
218 if (!priv->beacon) {
219 spin_unlock_bh(&priv->beacon_lock);
220 return;
221 }
222
223 info = IEEE80211_SKB_CB(priv->beacon);
224 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
225 struct ieee80211_hdr *hdr =
226 (struct ieee80211_hdr *) priv->beacon->data;
227 priv->seq_no += 0x10;
228 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
229 hdr->seq_ctrl |= cpu_to_le16(priv->seq_no);
230 }
231
232 tx_ctl.type = ATH9K_HTC_NORMAL;
233 beacon_hdr.vif_index = avp->index;
234 tx_fhdr = skb_push(priv->beacon, sizeof(beacon_hdr));
235 memcpy(tx_fhdr, (u8 *) &beacon_hdr, sizeof(beacon_hdr));
236
237 htc_send(priv->htc, priv->beacon, priv->beacon_ep, &tx_ctl);
238
239 spin_unlock_bh(&priv->beacon_lock);
240}
241
242void ath9k_htc_beacon_config(struct ath9k_htc_priv *priv,
243 struct ieee80211_vif *vif,
244 struct ieee80211_bss_conf *bss_conf)
245{
246 struct ath_common *common = ath9k_hw_common(priv->ah);
247
248 switch (vif->type) {
249 case NL80211_IFTYPE_STATION:
250 ath9k_htc_beacon_config_sta(priv, bss_conf);
251 break;
252 case NL80211_IFTYPE_ADHOC:
253 ath9k_htc_beacon_config_adhoc(priv, bss_conf);
254 break;
255 default:
256 ath_print(common, ATH_DBG_CONFIG,
257 "Unsupported beaconing mode\n");
258 return;
259 }
260}
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
new file mode 100644
index 000000000000..10c87605d2c4
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -0,0 +1,713 @@
1/*
2 * Copyright (c) 2010 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 "htc.h"
18
19MODULE_AUTHOR("Atheros Communications");
20MODULE_LICENSE("Dual BSD/GPL");
21MODULE_DESCRIPTION("Atheros driver 802.11n HTC based wireless devices");
22
23static unsigned int ath9k_debug = ATH_DBG_DEFAULT;
24module_param_named(debug, ath9k_debug, uint, 0);
25MODULE_PARM_DESC(debug, "Debugging mask");
26
27int htc_modparam_nohwcrypt;
28module_param_named(nohwcrypt, htc_modparam_nohwcrypt, int, 0444);
29MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption");
30
31#define CHAN2G(_freq, _idx) { \
32 .center_freq = (_freq), \
33 .hw_value = (_idx), \
34 .max_power = 20, \
35}
36
37static struct ieee80211_channel ath9k_2ghz_channels[] = {
38 CHAN2G(2412, 0), /* Channel 1 */
39 CHAN2G(2417, 1), /* Channel 2 */
40 CHAN2G(2422, 2), /* Channel 3 */
41 CHAN2G(2427, 3), /* Channel 4 */
42 CHAN2G(2432, 4), /* Channel 5 */
43 CHAN2G(2437, 5), /* Channel 6 */
44 CHAN2G(2442, 6), /* Channel 7 */
45 CHAN2G(2447, 7), /* Channel 8 */
46 CHAN2G(2452, 8), /* Channel 9 */
47 CHAN2G(2457, 9), /* Channel 10 */
48 CHAN2G(2462, 10), /* Channel 11 */
49 CHAN2G(2467, 11), /* Channel 12 */
50 CHAN2G(2472, 12), /* Channel 13 */
51 CHAN2G(2484, 13), /* Channel 14 */
52};
53
54/* Atheros hardware rate code addition for short premble */
55#define SHPCHECK(__hw_rate, __flags) \
56 ((__flags & IEEE80211_RATE_SHORT_PREAMBLE) ? (__hw_rate | 0x04) : 0)
57
58#define RATE(_bitrate, _hw_rate, _flags) { \
59 .bitrate = (_bitrate), \
60 .flags = (_flags), \
61 .hw_value = (_hw_rate), \
62 .hw_value_short = (SHPCHECK(_hw_rate, _flags)) \
63}
64
65static struct ieee80211_rate ath9k_legacy_rates[] = {
66 RATE(10, 0x1b, 0),
67 RATE(20, 0x1a, IEEE80211_RATE_SHORT_PREAMBLE), /* shortp : 0x1e */
68 RATE(55, 0x19, IEEE80211_RATE_SHORT_PREAMBLE), /* shortp: 0x1d */
69 RATE(110, 0x18, IEEE80211_RATE_SHORT_PREAMBLE), /* short: 0x1c */
70 RATE(60, 0x0b, 0),
71 RATE(90, 0x0f, 0),
72 RATE(120, 0x0a, 0),
73 RATE(180, 0x0e, 0),
74 RATE(240, 0x09, 0),
75 RATE(360, 0x0d, 0),
76 RATE(480, 0x08, 0),
77 RATE(540, 0x0c, 0),
78};
79
80static int ath9k_htc_wait_for_target(struct ath9k_htc_priv *priv)
81{
82 int time_left;
83
84 /* Firmware can take up to 50ms to get ready, to be safe use 1 second */
85 time_left = wait_for_completion_timeout(&priv->htc->target_wait, HZ);
86 if (!time_left) {
87 dev_err(priv->dev, "ath9k_htc: Target is unresponsive\n");
88 return -ETIMEDOUT;
89 }
90
91 return 0;
92}
93
94static void ath9k_deinit_priv(struct ath9k_htc_priv *priv)
95{
96 ath9k_htc_exit_debug(priv->ah);
97 ath9k_hw_deinit(priv->ah);
98 tasklet_kill(&priv->wmi_tasklet);
99 tasklet_kill(&priv->rx_tasklet);
100 tasklet_kill(&priv->tx_tasklet);
101 kfree(priv->ah);
102 priv->ah = NULL;
103}
104
105static void ath9k_deinit_device(struct ath9k_htc_priv *priv)
106{
107 struct ieee80211_hw *hw = priv->hw;
108
109 wiphy_rfkill_stop_polling(hw->wiphy);
110 ath9k_deinit_leds(priv);
111 ieee80211_unregister_hw(hw);
112 ath9k_rx_cleanup(priv);
113 ath9k_tx_cleanup(priv);
114 ath9k_deinit_priv(priv);
115}
116
117static inline int ath9k_htc_connect_svc(struct ath9k_htc_priv *priv,
118 u16 service_id,
119 void (*tx) (void *,
120 struct sk_buff *,
121 enum htc_endpoint_id,
122 bool txok),
123 enum htc_endpoint_id *ep_id)
124{
125 struct htc_service_connreq req;
126
127 memset(&req, 0, sizeof(struct htc_service_connreq));
128
129 req.service_id = service_id;
130 req.ep_callbacks.priv = priv;
131 req.ep_callbacks.rx = ath9k_htc_rxep;
132 req.ep_callbacks.tx = tx;
133
134 return htc_connect_service(priv->htc, &req, ep_id);
135}
136
137static int ath9k_init_htc_services(struct ath9k_htc_priv *priv)
138{
139 int ret;
140
141 /* WMI CMD*/
142 ret = ath9k_wmi_connect(priv->htc, priv->wmi, &priv->wmi_cmd_ep);
143 if (ret)
144 goto err;
145
146 /* Beacon */
147 ret = ath9k_htc_connect_svc(priv, WMI_BEACON_SVC, NULL,
148 &priv->beacon_ep);
149 if (ret)
150 goto err;
151
152 /* CAB */
153 ret = ath9k_htc_connect_svc(priv, WMI_CAB_SVC, ath9k_htc_txep,
154 &priv->cab_ep);
155 if (ret)
156 goto err;
157
158
159 /* UAPSD */
160 ret = ath9k_htc_connect_svc(priv, WMI_UAPSD_SVC, ath9k_htc_txep,
161 &priv->uapsd_ep);
162 if (ret)
163 goto err;
164
165 /* MGMT */
166 ret = ath9k_htc_connect_svc(priv, WMI_MGMT_SVC, ath9k_htc_txep,
167 &priv->mgmt_ep);
168 if (ret)
169 goto err;
170
171 /* DATA BE */
172 ret = ath9k_htc_connect_svc(priv, WMI_DATA_BE_SVC, ath9k_htc_txep,
173 &priv->data_be_ep);
174 if (ret)
175 goto err;
176
177 /* DATA BK */
178 ret = ath9k_htc_connect_svc(priv, WMI_DATA_BK_SVC, ath9k_htc_txep,
179 &priv->data_bk_ep);
180 if (ret)
181 goto err;
182
183 /* DATA VI */
184 ret = ath9k_htc_connect_svc(priv, WMI_DATA_VI_SVC, ath9k_htc_txep,
185 &priv->data_vi_ep);
186 if (ret)
187 goto err;
188
189 /* DATA VO */
190 ret = ath9k_htc_connect_svc(priv, WMI_DATA_VO_SVC, ath9k_htc_txep,
191 &priv->data_vo_ep);
192 if (ret)
193 goto err;
194
195 ret = htc_init(priv->htc);
196 if (ret)
197 goto err;
198
199 return 0;
200
201err:
202 dev_err(priv->dev, "ath9k_htc: Unable to initialize HTC services\n");
203 return ret;
204}
205
206static int ath9k_reg_notifier(struct wiphy *wiphy,
207 struct regulatory_request *request)
208{
209 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
210 struct ath9k_htc_priv *priv = hw->priv;
211
212 return ath_reg_notifier_apply(wiphy, request,
213 ath9k_hw_regulatory(priv->ah));
214}
215
216static unsigned int ath9k_ioread32(void *hw_priv, u32 reg_offset)
217{
218 struct ath_hw *ah = (struct ath_hw *) hw_priv;
219 struct ath_common *common = ath9k_hw_common(ah);
220 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
221 __be32 val, reg = cpu_to_be32(reg_offset);
222 int r;
223
224 r = ath9k_wmi_cmd(priv->wmi, WMI_REG_READ_CMDID,
225 (u8 *) &reg, sizeof(reg),
226 (u8 *) &val, sizeof(val),
227 100);
228 if (unlikely(r)) {
229 ath_print(common, ATH_DBG_WMI,
230 "REGISTER READ FAILED: (0x%04x, %d)\n",
231 reg_offset, r);
232 return -EIO;
233 }
234
235 return be32_to_cpu(val);
236}
237
238static void ath9k_iowrite32(void *hw_priv, u32 val, u32 reg_offset)
239{
240 struct ath_hw *ah = (struct ath_hw *) hw_priv;
241 struct ath_common *common = ath9k_hw_common(ah);
242 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
243 __be32 buf[2] = {
244 cpu_to_be32(reg_offset),
245 cpu_to_be32(val),
246 };
247 int r;
248
249 r = ath9k_wmi_cmd(priv->wmi, WMI_REG_WRITE_CMDID,
250 (u8 *) &buf, sizeof(buf),
251 (u8 *) &val, sizeof(val),
252 100);
253 if (unlikely(r)) {
254 ath_print(common, ATH_DBG_WMI,
255 "REGISTER WRITE FAILED:(0x%04x, %d)\n",
256 reg_offset, r);
257 }
258}
259
260static const struct ath_ops ath9k_common_ops = {
261 .read = ath9k_ioread32,
262 .write = ath9k_iowrite32,
263};
264
265static void ath_usb_read_cachesize(struct ath_common *common, int *csz)
266{
267 *csz = L1_CACHE_BYTES >> 2;
268}
269
270static bool ath_usb_eeprom_read(struct ath_common *common, u32 off, u16 *data)
271{
272 struct ath_hw *ah = (struct ath_hw *) common->ah;
273
274 (void)REG_READ(ah, AR5416_EEPROM_OFFSET + (off << AR5416_EEPROM_S));
275
276 if (!ath9k_hw_wait(ah,
277 AR_EEPROM_STATUS_DATA,
278 AR_EEPROM_STATUS_DATA_BUSY |
279 AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0,
280 AH_WAIT_TIMEOUT))
281 return false;
282
283 *data = MS(REG_READ(ah, AR_EEPROM_STATUS_DATA),
284 AR_EEPROM_STATUS_DATA_VAL);
285
286 return true;
287}
288
289static const struct ath_bus_ops ath9k_usb_bus_ops = {
290 .read_cachesize = ath_usb_read_cachesize,
291 .eeprom_read = ath_usb_eeprom_read,
292};
293
294static void setup_ht_cap(struct ath9k_htc_priv *priv,
295 struct ieee80211_sta_ht_cap *ht_info)
296{
297 ht_info->ht_supported = true;
298 ht_info->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
299 IEEE80211_HT_CAP_SM_PS |
300 IEEE80211_HT_CAP_SGI_40 |
301 IEEE80211_HT_CAP_DSSSCCK40;
302
303 ht_info->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;
304 ht_info->ampdu_density = IEEE80211_HT_MPDU_DENSITY_8;
305
306 memset(&ht_info->mcs, 0, sizeof(ht_info->mcs));
307 ht_info->mcs.rx_mask[0] = 0xff;
308 ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_DEFINED;
309}
310
311static int ath9k_init_queues(struct ath9k_htc_priv *priv)
312{
313 struct ath_common *common = ath9k_hw_common(priv->ah);
314 int i;
315
316 for (i = 0; i < ARRAY_SIZE(priv->hwq_map); i++)
317 priv->hwq_map[i] = -1;
318
319 if (!ath9k_htc_txq_setup(priv, ATH9K_WME_AC_BE)) {
320 ath_print(common, ATH_DBG_FATAL,
321 "Unable to setup xmit queue for BE traffic\n");
322 goto err;
323 }
324
325 if (!ath9k_htc_txq_setup(priv, ATH9K_WME_AC_BK)) {
326 ath_print(common, ATH_DBG_FATAL,
327 "Unable to setup xmit queue for BK traffic\n");
328 goto err;
329 }
330 if (!ath9k_htc_txq_setup(priv, ATH9K_WME_AC_VI)) {
331 ath_print(common, ATH_DBG_FATAL,
332 "Unable to setup xmit queue for VI traffic\n");
333 goto err;
334 }
335 if (!ath9k_htc_txq_setup(priv, ATH9K_WME_AC_VO)) {
336 ath_print(common, ATH_DBG_FATAL,
337 "Unable to setup xmit queue for VO traffic\n");
338 goto err;
339 }
340
341 return 0;
342
343err:
344 return -EINVAL;
345}
346
347static void ath9k_init_crypto(struct ath9k_htc_priv *priv)
348{
349 struct ath_common *common = ath9k_hw_common(priv->ah);
350 int i = 0;
351
352 /* Get the hardware key cache size. */
353 common->keymax = priv->ah->caps.keycache_size;
354 if (common->keymax > ATH_KEYMAX) {
355 ath_print(common, ATH_DBG_ANY,
356 "Warning, using only %u entries in %u key cache\n",
357 ATH_KEYMAX, common->keymax);
358 common->keymax = ATH_KEYMAX;
359 }
360
361 /*
362 * Reset the key cache since some parts do not
363 * reset the contents on initial power up.
364 */
365 for (i = 0; i < common->keymax; i++)
366 ath9k_hw_keyreset(priv->ah, (u16) i);
367
368 if (ath9k_hw_getcapability(priv->ah, ATH9K_CAP_CIPHER,
369 ATH9K_CIPHER_TKIP, NULL)) {
370 /*
371 * Whether we should enable h/w TKIP MIC.
372 * XXX: if we don't support WME TKIP MIC, then we wouldn't
373 * report WMM capable, so it's always safe to turn on
374 * TKIP MIC in this case.
375 */
376 ath9k_hw_setcapability(priv->ah, ATH9K_CAP_TKIP_MIC, 0, 1, NULL);
377 }
378
379 /*
380 * Check whether the separate key cache entries
381 * are required to handle both tx+rx MIC keys.
382 * With split mic keys the number of stations is limited
383 * to 27 otherwise 59.
384 */
385 if (ath9k_hw_getcapability(priv->ah, ATH9K_CAP_CIPHER,
386 ATH9K_CIPHER_TKIP, NULL)
387 && ath9k_hw_getcapability(priv->ah, ATH9K_CAP_CIPHER,
388 ATH9K_CIPHER_MIC, NULL)
389 && ath9k_hw_getcapability(priv->ah, ATH9K_CAP_TKIP_SPLIT,
390 0, NULL))
391 common->splitmic = 1;
392
393 /* turn on mcast key search if possible */
394 if (!ath9k_hw_getcapability(priv->ah, ATH9K_CAP_MCAST_KEYSRCH, 0, NULL))
395 (void)ath9k_hw_setcapability(priv->ah, ATH9K_CAP_MCAST_KEYSRCH,
396 1, 1, NULL);
397}
398
399static void ath9k_init_channels_rates(struct ath9k_htc_priv *priv)
400{
401 if (test_bit(ATH9K_MODE_11G, priv->ah->caps.wireless_modes)) {
402 priv->sbands[IEEE80211_BAND_2GHZ].channels =
403 ath9k_2ghz_channels;
404 priv->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
405 priv->sbands[IEEE80211_BAND_2GHZ].n_channels =
406 ARRAY_SIZE(ath9k_2ghz_channels);
407 priv->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates;
408 priv->sbands[IEEE80211_BAND_2GHZ].n_bitrates =
409 ARRAY_SIZE(ath9k_legacy_rates);
410 }
411}
412
413static void ath9k_init_misc(struct ath9k_htc_priv *priv)
414{
415 struct ath_common *common = ath9k_hw_common(priv->ah);
416
417 common->tx_chainmask = priv->ah->caps.tx_chainmask;
418 common->rx_chainmask = priv->ah->caps.rx_chainmask;
419
420 if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_BSSIDMASK)
421 memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN);
422
423 priv->op_flags |= OP_TXAGGR;
424}
425
426static int ath9k_init_priv(struct ath9k_htc_priv *priv, u16 devid)
427{
428 struct ath_hw *ah = NULL;
429 struct ath_common *common;
430 int ret = 0, csz = 0;
431
432 priv->op_flags |= OP_INVALID;
433
434 ah = kzalloc(sizeof(struct ath_hw), GFP_KERNEL);
435 if (!ah)
436 return -ENOMEM;
437
438 ah->hw_version.devid = devid;
439 ah->hw_version.subsysid = 0; /* FIXME */
440 priv->ah = ah;
441
442 common = ath9k_hw_common(ah);
443 common->ops = &ath9k_common_ops;
444 common->bus_ops = &ath9k_usb_bus_ops;
445 common->ah = ah;
446 common->hw = priv->hw;
447 common->priv = priv;
448 common->debug_mask = ath9k_debug;
449
450 spin_lock_init(&priv->wmi->wmi_lock);
451 spin_lock_init(&priv->beacon_lock);
452 mutex_init(&priv->mutex);
453 mutex_init(&priv->aggr_work.mutex);
454 tasklet_init(&priv->wmi_tasklet, ath9k_wmi_tasklet,
455 (unsigned long)priv);
456 tasklet_init(&priv->rx_tasklet, ath9k_rx_tasklet,
457 (unsigned long)priv);
458 tasklet_init(&priv->tx_tasklet, ath9k_tx_tasklet, (unsigned long)priv);
459 INIT_DELAYED_WORK(&priv->ath9k_aggr_work, ath9k_htc_aggr_work);
460 INIT_DELAYED_WORK(&priv->ath9k_ani_work, ath9k_ani_work);
461
462 /*
463 * Cache line size is used to size and align various
464 * structures used to communicate with the hardware.
465 */
466 ath_read_cachesize(common, &csz);
467 common->cachelsz = csz << 2; /* convert to bytes */
468
469 ret = ath9k_hw_init(ah);
470 if (ret) {
471 ath_print(common, ATH_DBG_FATAL,
472 "Unable to initialize hardware; "
473 "initialization status: %d\n", ret);
474 goto err_hw;
475 }
476
477 ret = ath9k_htc_init_debug(ah);
478 if (ret) {
479 ath_print(common, ATH_DBG_FATAL,
480 "Unable to create debugfs files\n");
481 goto err_debug;
482 }
483
484 ret = ath9k_init_queues(priv);
485 if (ret)
486 goto err_queues;
487
488 ath9k_init_crypto(priv);
489 ath9k_init_channels_rates(priv);
490 ath9k_init_misc(priv);
491
492 return 0;
493
494err_queues:
495 ath9k_htc_exit_debug(ah);
496err_debug:
497 ath9k_hw_deinit(ah);
498err_hw:
499
500 kfree(ah);
501 priv->ah = NULL;
502
503 return ret;
504}
505
506static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv,
507 struct ieee80211_hw *hw)
508{
509 struct ath_common *common = ath9k_hw_common(priv->ah);
510
511 hw->flags = IEEE80211_HW_SIGNAL_DBM |
512 IEEE80211_HW_AMPDU_AGGREGATION |
513 IEEE80211_HW_SPECTRUM_MGMT |
514 IEEE80211_HW_HAS_RATE_CONTROL;
515
516 hw->wiphy->interface_modes =
517 BIT(NL80211_IFTYPE_STATION) |
518 BIT(NL80211_IFTYPE_ADHOC);
519
520 hw->queues = 4;
521 hw->channel_change_time = 5000;
522 hw->max_listen_interval = 10;
523 hw->vif_data_size = sizeof(struct ath9k_htc_vif);
524 hw->sta_data_size = sizeof(struct ath9k_htc_sta);
525
526 /* tx_frame_hdr is larger than tx_mgmt_hdr anyway */
527 hw->extra_tx_headroom = sizeof(struct tx_frame_hdr) +
528 sizeof(struct htc_frame_hdr) + 4;
529
530 if (test_bit(ATH9K_MODE_11G, priv->ah->caps.wireless_modes))
531 hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
532 &priv->sbands[IEEE80211_BAND_2GHZ];
533
534 if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
535 if (test_bit(ATH9K_MODE_11G, priv->ah->caps.wireless_modes))
536 setup_ht_cap(priv,
537 &priv->sbands[IEEE80211_BAND_2GHZ].ht_cap);
538 }
539
540 SET_IEEE80211_PERM_ADDR(hw, common->macaddr);
541}
542
543static int ath9k_init_device(struct ath9k_htc_priv *priv, u16 devid)
544{
545 struct ieee80211_hw *hw = priv->hw;
546 struct ath_common *common;
547 struct ath_hw *ah;
548 int error = 0;
549 struct ath_regulatory *reg;
550
551 /* Bring up device */
552 error = ath9k_init_priv(priv, devid);
553 if (error != 0)
554 goto err_init;
555
556 ah = priv->ah;
557 common = ath9k_hw_common(ah);
558 ath9k_set_hw_capab(priv, hw);
559
560 /* Initialize regulatory */
561 error = ath_regd_init(&common->regulatory, priv->hw->wiphy,
562 ath9k_reg_notifier);
563 if (error)
564 goto err_regd;
565
566 reg = &common->regulatory;
567
568 /* Setup TX */
569 error = ath9k_tx_init(priv);
570 if (error != 0)
571 goto err_tx;
572
573 /* Setup RX */
574 error = ath9k_rx_init(priv);
575 if (error != 0)
576 goto err_rx;
577
578 /* Register with mac80211 */
579 error = ieee80211_register_hw(hw);
580 if (error)
581 goto err_register;
582
583 /* Handle world regulatory */
584 if (!ath_is_world_regd(reg)) {
585 error = regulatory_hint(hw->wiphy, reg->alpha2);
586 if (error)
587 goto err_world;
588 }
589
590 ath9k_init_leds(priv);
591 ath9k_start_rfkill_poll(priv);
592
593 return 0;
594
595err_world:
596 ieee80211_unregister_hw(hw);
597err_register:
598 ath9k_rx_cleanup(priv);
599err_rx:
600 ath9k_tx_cleanup(priv);
601err_tx:
602 /* Nothing */
603err_regd:
604 ath9k_deinit_priv(priv);
605err_init:
606 return error;
607}
608
609int ath9k_htc_probe_device(struct htc_target *htc_handle, struct device *dev,
610 u16 devid)
611{
612 struct ieee80211_hw *hw;
613 struct ath9k_htc_priv *priv;
614 int ret;
615
616 hw = ieee80211_alloc_hw(sizeof(struct ath9k_htc_priv), &ath9k_htc_ops);
617 if (!hw)
618 return -ENOMEM;
619
620 priv = hw->priv;
621 priv->hw = hw;
622 priv->htc = htc_handle;
623 priv->dev = dev;
624 htc_handle->drv_priv = priv;
625 SET_IEEE80211_DEV(hw, priv->dev);
626
627 ret = ath9k_htc_wait_for_target(priv);
628 if (ret)
629 goto err_free;
630
631 priv->wmi = ath9k_init_wmi(priv);
632 if (!priv->wmi) {
633 ret = -EINVAL;
634 goto err_free;
635 }
636
637 ret = ath9k_init_htc_services(priv);
638 if (ret)
639 goto err_init;
640
641 ret = ath9k_init_device(priv, devid);
642 if (ret)
643 goto err_init;
644
645 return 0;
646
647err_init:
648 ath9k_deinit_wmi(priv);
649err_free:
650 ieee80211_free_hw(hw);
651 return ret;
652}
653
654void ath9k_htc_disconnect_device(struct htc_target *htc_handle, bool hotunplug)
655{
656 if (htc_handle->drv_priv) {
657 ath9k_deinit_device(htc_handle->drv_priv);
658 ath9k_deinit_wmi(htc_handle->drv_priv);
659 ieee80211_free_hw(htc_handle->drv_priv->hw);
660 }
661}
662
663#ifdef CONFIG_PM
664int ath9k_htc_resume(struct htc_target *htc_handle)
665{
666 int ret;
667
668 ret = ath9k_htc_wait_for_target(htc_handle->drv_priv);
669 if (ret)
670 return ret;
671
672 ret = ath9k_init_htc_services(htc_handle->drv_priv);
673 return ret;
674}
675#endif
676
677static int __init ath9k_htc_init(void)
678{
679 int error;
680
681 error = ath9k_htc_debug_create_root();
682 if (error < 0) {
683 printk(KERN_ERR
684 "ath9k_htc: Unable to create debugfs root: %d\n",
685 error);
686 goto err_dbg;
687 }
688
689 error = ath9k_hif_usb_init();
690 if (error < 0) {
691 printk(KERN_ERR
692 "ath9k_htc: No USB devices found,"
693 " driver not installed.\n");
694 error = -ENODEV;
695 goto err_usb;
696 }
697
698 return 0;
699
700err_usb:
701 ath9k_htc_debug_remove_root();
702err_dbg:
703 return error;
704}
705module_init(ath9k_htc_init);
706
707static void __exit ath9k_htc_exit(void)
708{
709 ath9k_hif_usb_exit();
710 ath9k_htc_debug_remove_root();
711 printk(KERN_INFO "ath9k_htc: Driver unloaded\n");
712}
713module_exit(ath9k_htc_exit);
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
new file mode 100644
index 000000000000..20a2c1341e20
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -0,0 +1,1626 @@
1/*
2 * Copyright (c) 2010 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 "htc.h"
18
19#ifdef CONFIG_ATH9K_HTC_DEBUGFS
20static struct dentry *ath9k_debugfs_root;
21#endif
22
23/*************/
24/* Utilities */
25/*************/
26
27static void ath_update_txpow(struct ath9k_htc_priv *priv)
28{
29 struct ath_hw *ah = priv->ah;
30 u32 txpow;
31
32 if (priv->curtxpow != priv->txpowlimit) {
33 ath9k_hw_set_txpowerlimit(ah, priv->txpowlimit);
34 /* read back in case value is clamped */
35 ath9k_hw_getcapability(ah, ATH9K_CAP_TXPOW, 1, &txpow);
36 priv->curtxpow = txpow;
37 }
38}
39
40/* HACK Alert: Use 11NG for 2.4, use 11NA for 5 */
41static enum htc_phymode ath9k_htc_get_curmode(struct ath9k_htc_priv *priv,
42 struct ath9k_channel *ichan)
43{
44 enum htc_phymode mode;
45
46 mode = HTC_MODE_AUTO;
47
48 switch (ichan->chanmode) {
49 case CHANNEL_G:
50 case CHANNEL_G_HT20:
51 case CHANNEL_G_HT40PLUS:
52 case CHANNEL_G_HT40MINUS:
53 mode = HTC_MODE_11NG;
54 break;
55 case CHANNEL_A:
56 case CHANNEL_A_HT20:
57 case CHANNEL_A_HT40PLUS:
58 case CHANNEL_A_HT40MINUS:
59 mode = HTC_MODE_11NA;
60 break;
61 default:
62 break;
63 }
64
65 return mode;
66}
67
68static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv,
69 struct ieee80211_hw *hw,
70 struct ath9k_channel *hchan)
71{
72 struct ath_hw *ah = priv->ah;
73 struct ath_common *common = ath9k_hw_common(ah);
74 struct ieee80211_conf *conf = &common->hw->conf;
75 bool fastcc = true;
76 struct ieee80211_channel *channel = hw->conf.channel;
77 enum htc_phymode mode;
78 u16 htc_mode;
79 u8 cmd_rsp;
80 int ret;
81
82 if (priv->op_flags & OP_INVALID)
83 return -EIO;
84
85 if (priv->op_flags & OP_FULL_RESET)
86 fastcc = false;
87
88 /* Fiddle around with fastcc later on, for now just use full reset */
89 fastcc = false;
90
91 htc_stop(priv->htc);
92 WMI_CMD(WMI_DISABLE_INTR_CMDID);
93 WMI_CMD(WMI_DRAIN_TXQ_ALL_CMDID);
94 WMI_CMD(WMI_STOP_RECV_CMDID);
95
96 ath_print(common, ATH_DBG_CONFIG,
97 "(%u MHz) -> (%u MHz), HT: %d, HT40: %d\n",
98 priv->ah->curchan->channel,
99 channel->center_freq, conf_is_ht(conf), conf_is_ht40(conf));
100
101 ret = ath9k_hw_reset(ah, hchan, fastcc);
102 if (ret) {
103 ath_print(common, ATH_DBG_FATAL,
104 "Unable to reset channel (%u Mhz) "
105 "reset status %d\n", channel->center_freq, ret);
106 goto err;
107 }
108
109 ath_update_txpow(priv);
110
111 WMI_CMD(WMI_START_RECV_CMDID);
112 if (ret)
113 goto err;
114
115 ath9k_host_rx_init(priv);
116
117 mode = ath9k_htc_get_curmode(priv, hchan);
118 htc_mode = cpu_to_be16(mode);
119 WMI_CMD_BUF(WMI_SET_MODE_CMDID, &htc_mode);
120 if (ret)
121 goto err;
122
123 WMI_CMD(WMI_ENABLE_INTR_CMDID);
124 if (ret)
125 goto err;
126
127 htc_start(priv->htc);
128
129 priv->op_flags &= ~OP_FULL_RESET;
130err:
131 return ret;
132}
133
134static int ath9k_htc_add_monitor_interface(struct ath9k_htc_priv *priv)
135{
136 struct ath_common *common = ath9k_hw_common(priv->ah);
137 struct ath9k_htc_target_vif hvif;
138 int ret = 0;
139 u8 cmd_rsp;
140
141 if (priv->nvifs > 0)
142 return -ENOBUFS;
143
144 memset(&hvif, 0, sizeof(struct ath9k_htc_target_vif));
145 memcpy(&hvif.myaddr, common->macaddr, ETH_ALEN);
146
147 hvif.opmode = cpu_to_be32(HTC_M_MONITOR);
148 priv->ah->opmode = NL80211_IFTYPE_MONITOR;
149 hvif.index = priv->nvifs;
150
151 WMI_CMD_BUF(WMI_VAP_CREATE_CMDID, &hvif);
152 if (ret)
153 return ret;
154
155 priv->nvifs++;
156 return 0;
157}
158
159static int ath9k_htc_remove_monitor_interface(struct ath9k_htc_priv *priv)
160{
161 struct ath_common *common = ath9k_hw_common(priv->ah);
162 struct ath9k_htc_target_vif hvif;
163 int ret = 0;
164 u8 cmd_rsp;
165
166 memset(&hvif, 0, sizeof(struct ath9k_htc_target_vif));
167 memcpy(&hvif.myaddr, common->macaddr, ETH_ALEN);
168 hvif.index = 0; /* Should do for now */
169 WMI_CMD_BUF(WMI_VAP_REMOVE_CMDID, &hvif);
170 priv->nvifs--;
171
172 return ret;
173}
174
175static int ath9k_htc_add_station(struct ath9k_htc_priv *priv,
176 struct ieee80211_vif *vif,
177 struct ieee80211_sta *sta)
178{
179 struct ath_common *common = ath9k_hw_common(priv->ah);
180 struct ath9k_htc_target_sta tsta;
181 struct ath9k_htc_vif *avp = (struct ath9k_htc_vif *) vif->drv_priv;
182 struct ath9k_htc_sta *ista;
183 int ret;
184 u8 cmd_rsp;
185
186 if (priv->nstations >= ATH9K_HTC_MAX_STA)
187 return -ENOBUFS;
188
189 memset(&tsta, 0, sizeof(struct ath9k_htc_target_sta));
190
191 if (sta) {
192 ista = (struct ath9k_htc_sta *) sta->drv_priv;
193 memcpy(&tsta.macaddr, sta->addr, ETH_ALEN);
194 memcpy(&tsta.bssid, common->curbssid, ETH_ALEN);
195 tsta.associd = common->curaid;
196 tsta.is_vif_sta = 0;
197 tsta.valid = true;
198 ista->index = priv->nstations;
199 } else {
200 memcpy(&tsta.macaddr, vif->addr, ETH_ALEN);
201 tsta.is_vif_sta = 1;
202 }
203
204 tsta.sta_index = priv->nstations;
205 tsta.vif_index = avp->index;
206 tsta.maxampdu = 0xffff;
207 if (sta && sta->ht_cap.ht_supported)
208 tsta.flags = cpu_to_be16(ATH_HTC_STA_HT);
209
210 WMI_CMD_BUF(WMI_NODE_CREATE_CMDID, &tsta);
211 if (ret) {
212 if (sta)
213 ath_print(common, ATH_DBG_FATAL,
214 "Unable to add station entry for: %pM\n", sta->addr);
215 return ret;
216 }
217
218 if (sta)
219 ath_print(common, ATH_DBG_CONFIG,
220 "Added a station entry for: %pM (idx: %d)\n",
221 sta->addr, tsta.sta_index);
222
223 priv->nstations++;
224 return 0;
225}
226
227static int ath9k_htc_remove_station(struct ath9k_htc_priv *priv,
228 struct ieee80211_vif *vif,
229 struct ieee80211_sta *sta)
230{
231 struct ath_common *common = ath9k_hw_common(priv->ah);
232 struct ath9k_htc_sta *ista;
233 int ret;
234 u8 cmd_rsp, sta_idx;
235
236 if (sta) {
237 ista = (struct ath9k_htc_sta *) sta->drv_priv;
238 sta_idx = ista->index;
239 } else {
240 sta_idx = 0;
241 }
242
243 WMI_CMD_BUF(WMI_NODE_REMOVE_CMDID, &sta_idx);
244 if (ret) {
245 if (sta)
246 ath_print(common, ATH_DBG_FATAL,
247 "Unable to remove station entry for: %pM\n",
248 sta->addr);
249 return ret;
250 }
251
252 if (sta)
253 ath_print(common, ATH_DBG_CONFIG,
254 "Removed a station entry for: %pM (idx: %d)\n",
255 sta->addr, sta_idx);
256
257 priv->nstations--;
258 return 0;
259}
260
261static int ath9k_htc_update_cap_target(struct ath9k_htc_priv *priv)
262{
263 struct ath9k_htc_cap_target tcap;
264 int ret;
265 u8 cmd_rsp;
266
267 memset(&tcap, 0, sizeof(struct ath9k_htc_cap_target));
268
269 /* FIXME: Values are hardcoded */
270 tcap.flags = 0x240c40;
271 tcap.flags_ext = 0x80601000;
272 tcap.ampdu_limit = 0xffff0000;
273 tcap.ampdu_subframes = 20;
274 tcap.tx_chainmask_legacy = 1;
275 tcap.protmode = 1;
276 tcap.tx_chainmask = 1;
277
278 WMI_CMD_BUF(WMI_TARGET_IC_UPDATE_CMDID, &tcap);
279
280 return ret;
281}
282
283static int ath9k_htc_init_rate(struct ath9k_htc_priv *priv,
284 struct ieee80211_vif *vif,
285 struct ieee80211_sta *sta)
286{
287 struct ath_common *common = ath9k_hw_common(priv->ah);
288 struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv;
289 struct ieee80211_supported_band *sband;
290 struct ath9k_htc_target_rate trate;
291 u32 caps = 0;
292 u8 cmd_rsp;
293 int i, j, ret;
294
295 memset(&trate, 0, sizeof(trate));
296
297 /* Only 2GHz is supported */
298 sband = priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ];
299
300 for (i = 0, j = 0; i < sband->n_bitrates; i++) {
301 if (sta->supp_rates[sband->band] & BIT(i)) {
302 priv->tgt_rate.rates.legacy_rates.rs_rates[j]
303 = (sband->bitrates[i].bitrate * 2) / 10;
304 j++;
305 }
306 }
307 priv->tgt_rate.rates.legacy_rates.rs_nrates = j;
308
309 if (sta->ht_cap.ht_supported) {
310 for (i = 0, j = 0; i < 77; i++) {
311 if (sta->ht_cap.mcs.rx_mask[i/8] & (1<<(i%8)))
312 priv->tgt_rate.rates.ht_rates.rs_rates[j++] = i;
313 if (j == ATH_HTC_RATE_MAX)
314 break;
315 }
316 priv->tgt_rate.rates.ht_rates.rs_nrates = j;
317
318 caps = WLAN_RC_HT_FLAG;
319 if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
320 caps |= WLAN_RC_40_FLAG;
321 if (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40)
322 caps |= WLAN_RC_SGI_FLAG;
323
324 }
325
326 priv->tgt_rate.sta_index = ista->index;
327 priv->tgt_rate.isnew = 1;
328 trate = priv->tgt_rate;
329 priv->tgt_rate.capflags = caps;
330 trate.capflags = cpu_to_be32(caps);
331
332 WMI_CMD_BUF(WMI_RC_RATE_UPDATE_CMDID, &trate);
333 if (ret) {
334 ath_print(common, ATH_DBG_FATAL,
335 "Unable to initialize Rate information on target\n");
336 return ret;
337 }
338
339 ath_print(common, ATH_DBG_CONFIG,
340 "Updated target STA: %pM (caps: 0x%x)\n", sta->addr, caps);
341 return 0;
342}
343
344static bool check_rc_update(struct ieee80211_hw *hw, bool *cw40)
345{
346 struct ath9k_htc_priv *priv = hw->priv;
347 struct ieee80211_conf *conf = &hw->conf;
348
349 if (!conf_is_ht(conf))
350 return false;
351
352 if (!(priv->op_flags & OP_ASSOCIATED) ||
353 (priv->op_flags & OP_SCANNING))
354 return false;
355
356 if (conf_is_ht40(conf)) {
357 if (priv->ah->curchan->chanmode &
358 (CHANNEL_HT40PLUS | CHANNEL_HT40MINUS)) {
359 return false;
360 } else {
361 *cw40 = true;
362 return true;
363 }
364 } else { /* ht20 */
365 if (priv->ah->curchan->chanmode & CHANNEL_HT20)
366 return false;
367 else
368 return true;
369 }
370}
371
372static void ath9k_htc_rc_update(struct ath9k_htc_priv *priv, bool is_cw40)
373{
374 struct ath9k_htc_target_rate trate;
375 struct ath_common *common = ath9k_hw_common(priv->ah);
376 int ret;
377 u8 cmd_rsp;
378
379 memset(&trate, 0, sizeof(trate));
380
381 trate = priv->tgt_rate;
382
383 if (is_cw40)
384 priv->tgt_rate.capflags |= WLAN_RC_40_FLAG;
385 else
386 priv->tgt_rate.capflags &= ~WLAN_RC_40_FLAG;
387
388 trate.capflags = cpu_to_be32(priv->tgt_rate.capflags);
389
390 WMI_CMD_BUF(WMI_RC_RATE_UPDATE_CMDID, &trate);
391 if (ret) {
392 ath_print(common, ATH_DBG_FATAL,
393 "Unable to update Rate information on target\n");
394 return;
395 }
396
397 ath_print(common, ATH_DBG_CONFIG, "Rate control updated with "
398 "caps:0x%x on target\n", priv->tgt_rate.capflags);
399}
400
401static int ath9k_htc_aggr_oper(struct ath9k_htc_priv *priv,
402 struct ieee80211_vif *vif,
403 u8 *sta_addr, u8 tid, bool oper)
404{
405 struct ath_common *common = ath9k_hw_common(priv->ah);
406 struct ath9k_htc_target_aggr aggr;
407 struct ieee80211_sta *sta = NULL;
408 struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv;
409 int ret = 0;
410 u8 cmd_rsp;
411
412 if (tid > ATH9K_HTC_MAX_TID)
413 return -EINVAL;
414
415 rcu_read_lock();
416 sta = ieee80211_find_sta(vif, sta_addr);
417 if (sta) {
418 ista = (struct ath9k_htc_sta *) sta->drv_priv;
419 } else {
420 rcu_read_unlock();
421 return -EINVAL;
422 }
423
424 if (!ista) {
425 rcu_read_unlock();
426 return -EINVAL;
427 }
428
429 memset(&aggr, 0, sizeof(struct ath9k_htc_target_aggr));
430
431 aggr.sta_index = ista->index;
432 rcu_read_unlock();
433 aggr.tidno = tid;
434 aggr.aggr_enable = oper;
435
436 if (oper)
437 ista->tid_state[tid] = AGGR_START;
438 else
439 ista->tid_state[tid] = AGGR_STOP;
440
441 WMI_CMD_BUF(WMI_TX_AGGR_ENABLE_CMDID, &aggr);
442 if (ret)
443 ath_print(common, ATH_DBG_CONFIG,
444 "Unable to %s TX aggregation for (%pM, %d)\n",
445 (oper) ? "start" : "stop", sta->addr, tid);
446 else
447 ath_print(common, ATH_DBG_CONFIG,
448 "%s aggregation for (%pM, %d)\n",
449 (oper) ? "Starting" : "Stopping", sta->addr, tid);
450
451 return ret;
452}
453
454void ath9k_htc_aggr_work(struct work_struct *work)
455{
456 int ret = 0;
457 struct ath9k_htc_priv *priv =
458 container_of(work, struct ath9k_htc_priv,
459 ath9k_aggr_work.work);
460 struct ath9k_htc_aggr_work *wk = &priv->aggr_work;
461
462 mutex_lock(&wk->mutex);
463
464 switch (wk->action) {
465 case IEEE80211_AMPDU_TX_START:
466 ret = ath9k_htc_aggr_oper(priv, wk->vif, wk->sta_addr,
467 wk->tid, true);
468 if (!ret)
469 ieee80211_start_tx_ba_cb(wk->vif, wk->sta_addr,
470 wk->tid);
471 break;
472 case IEEE80211_AMPDU_TX_STOP:
473 ath9k_htc_aggr_oper(priv, wk->vif, wk->sta_addr,
474 wk->tid, false);
475 ieee80211_stop_tx_ba_cb(wk->vif, wk->sta_addr, wk->tid);
476 break;
477 default:
478 ath_print(ath9k_hw_common(priv->ah), ATH_DBG_FATAL,
479 "Unknown AMPDU action\n");
480 }
481
482 mutex_unlock(&wk->mutex);
483}
484
485/*********/
486/* DEBUG */
487/*********/
488
489#ifdef CONFIG_ATH9K_HTC_DEBUGFS
490
491static int ath9k_debugfs_open(struct inode *inode, struct file *file)
492{
493 file->private_data = inode->i_private;
494 return 0;
495}
496
497static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
498 size_t count, loff_t *ppos)
499{
500 struct ath9k_htc_priv *priv =
501 (struct ath9k_htc_priv *) file->private_data;
502 struct ath9k_htc_target_stats cmd_rsp;
503 char buf[512];
504 unsigned int len = 0;
505 int ret = 0;
506
507 memset(&cmd_rsp, 0, sizeof(cmd_rsp));
508
509 WMI_CMD(WMI_TGT_STATS_CMDID);
510 if (ret)
511 return -EINVAL;
512
513
514 len += snprintf(buf + len, sizeof(buf) - len,
515 "%19s : %10u\n", "TX Short Retries",
516 be32_to_cpu(cmd_rsp.tx_shortretry));
517 len += snprintf(buf + len, sizeof(buf) - len,
518 "%19s : %10u\n", "TX Long Retries",
519 be32_to_cpu(cmd_rsp.tx_longretry));
520 len += snprintf(buf + len, sizeof(buf) - len,
521 "%19s : %10u\n", "TX Xretries",
522 be32_to_cpu(cmd_rsp.tx_xretries));
523 len += snprintf(buf + len, sizeof(buf) - len,
524 "%19s : %10u\n", "TX Unaggr. Xretries",
525 be32_to_cpu(cmd_rsp.ht_txunaggr_xretry));
526 len += snprintf(buf + len, sizeof(buf) - len,
527 "%19s : %10u\n", "TX Xretries (HT)",
528 be32_to_cpu(cmd_rsp.ht_tx_xretries));
529 len += snprintf(buf + len, sizeof(buf) - len,
530 "%19s : %10u\n", "TX Rate", priv->debug.txrate);
531
532 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
533}
534
535static const struct file_operations fops_tgt_stats = {
536 .read = read_file_tgt_stats,
537 .open = ath9k_debugfs_open,
538 .owner = THIS_MODULE
539};
540
541static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
542 size_t count, loff_t *ppos)
543{
544 struct ath9k_htc_priv *priv =
545 (struct ath9k_htc_priv *) file->private_data;
546 char buf[512];
547 unsigned int len = 0;
548
549 len += snprintf(buf + len, sizeof(buf) - len,
550 "%20s : %10u\n", "Buffers queued",
551 priv->debug.tx_stats.buf_queued);
552 len += snprintf(buf + len, sizeof(buf) - len,
553 "%20s : %10u\n", "Buffers completed",
554 priv->debug.tx_stats.buf_completed);
555 len += snprintf(buf + len, sizeof(buf) - len,
556 "%20s : %10u\n", "SKBs queued",
557 priv->debug.tx_stats.skb_queued);
558 len += snprintf(buf + len, sizeof(buf) - len,
559 "%20s : %10u\n", "SKBs completed",
560 priv->debug.tx_stats.skb_completed);
561
562 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
563}
564
565static const struct file_operations fops_xmit = {
566 .read = read_file_xmit,
567 .open = ath9k_debugfs_open,
568 .owner = THIS_MODULE
569};
570
571static ssize_t read_file_recv(struct file *file, char __user *user_buf,
572 size_t count, loff_t *ppos)
573{
574 struct ath9k_htc_priv *priv =
575 (struct ath9k_htc_priv *) file->private_data;
576 char buf[512];
577 unsigned int len = 0;
578
579 len += snprintf(buf + len, sizeof(buf) - len,
580 "%20s : %10u\n", "SKBs allocated",
581 priv->debug.rx_stats.skb_allocated);
582 len += snprintf(buf + len, sizeof(buf) - len,
583 "%20s : %10u\n", "SKBs completed",
584 priv->debug.rx_stats.skb_completed);
585 len += snprintf(buf + len, sizeof(buf) - len,
586 "%20s : %10u\n", "SKBs Dropped",
587 priv->debug.rx_stats.skb_dropped);
588
589 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
590}
591
592static const struct file_operations fops_recv = {
593 .read = read_file_recv,
594 .open = ath9k_debugfs_open,
595 .owner = THIS_MODULE
596};
597
598int ath9k_htc_init_debug(struct ath_hw *ah)
599{
600 struct ath_common *common = ath9k_hw_common(ah);
601 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
602
603 if (!ath9k_debugfs_root)
604 return -ENOENT;
605
606 priv->debug.debugfs_phy = debugfs_create_dir(wiphy_name(priv->hw->wiphy),
607 ath9k_debugfs_root);
608 if (!priv->debug.debugfs_phy)
609 goto err;
610
611 priv->debug.debugfs_tgt_stats = debugfs_create_file("tgt_stats", S_IRUSR,
612 priv->debug.debugfs_phy,
613 priv, &fops_tgt_stats);
614 if (!priv->debug.debugfs_tgt_stats)
615 goto err;
616
617
618 priv->debug.debugfs_xmit = debugfs_create_file("xmit", S_IRUSR,
619 priv->debug.debugfs_phy,
620 priv, &fops_xmit);
621 if (!priv->debug.debugfs_xmit)
622 goto err;
623
624 priv->debug.debugfs_recv = debugfs_create_file("recv", S_IRUSR,
625 priv->debug.debugfs_phy,
626 priv, &fops_recv);
627 if (!priv->debug.debugfs_recv)
628 goto err;
629
630 return 0;
631
632err:
633 ath9k_htc_exit_debug(ah);
634 return -ENOMEM;
635}
636
637void ath9k_htc_exit_debug(struct ath_hw *ah)
638{
639 struct ath_common *common = ath9k_hw_common(ah);
640 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
641
642 debugfs_remove(priv->debug.debugfs_recv);
643 debugfs_remove(priv->debug.debugfs_xmit);
644 debugfs_remove(priv->debug.debugfs_tgt_stats);
645 debugfs_remove(priv->debug.debugfs_phy);
646}
647
648int ath9k_htc_debug_create_root(void)
649{
650 ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
651 if (!ath9k_debugfs_root)
652 return -ENOENT;
653
654 return 0;
655}
656
657void ath9k_htc_debug_remove_root(void)
658{
659 debugfs_remove(ath9k_debugfs_root);
660 ath9k_debugfs_root = NULL;
661}
662
663#endif /* CONFIG_ATH9K_HTC_DEBUGFS */
664
665/*******/
666/* ANI */
667/*******/
668
669static void ath_start_ani(struct ath9k_htc_priv *priv)
670{
671 struct ath_common *common = ath9k_hw_common(priv->ah);
672 unsigned long timestamp = jiffies_to_msecs(jiffies);
673
674 common->ani.longcal_timer = timestamp;
675 common->ani.shortcal_timer = timestamp;
676 common->ani.checkani_timer = timestamp;
677
678 ieee80211_queue_delayed_work(common->hw, &priv->ath9k_ani_work,
679 msecs_to_jiffies(ATH_ANI_POLLINTERVAL));
680}
681
682void ath9k_ani_work(struct work_struct *work)
683{
684 struct ath9k_htc_priv *priv =
685 container_of(work, struct ath9k_htc_priv,
686 ath9k_ani_work.work);
687 struct ath_hw *ah = priv->ah;
688 struct ath_common *common = ath9k_hw_common(ah);
689 bool longcal = false;
690 bool shortcal = false;
691 bool aniflag = false;
692 unsigned int timestamp = jiffies_to_msecs(jiffies);
693 u32 cal_interval, short_cal_interval;
694
695 short_cal_interval = ATH_STA_SHORT_CALINTERVAL;
696
697 /* Long calibration runs independently of short calibration. */
698 if ((timestamp - common->ani.longcal_timer) >= ATH_LONG_CALINTERVAL) {
699 longcal = true;
700 ath_print(common, ATH_DBG_ANI, "longcal @%lu\n", jiffies);
701 common->ani.longcal_timer = timestamp;
702 }
703
704 /* Short calibration applies only while caldone is false */
705 if (!common->ani.caldone) {
706 if ((timestamp - common->ani.shortcal_timer) >=
707 short_cal_interval) {
708 shortcal = true;
709 ath_print(common, ATH_DBG_ANI,
710 "shortcal @%lu\n", jiffies);
711 common->ani.shortcal_timer = timestamp;
712 common->ani.resetcal_timer = timestamp;
713 }
714 } else {
715 if ((timestamp - common->ani.resetcal_timer) >=
716 ATH_RESTART_CALINTERVAL) {
717 common->ani.caldone = ath9k_hw_reset_calvalid(ah);
718 if (common->ani.caldone)
719 common->ani.resetcal_timer = timestamp;
720 }
721 }
722
723 /* Verify whether we must check ANI */
724 if ((timestamp - common->ani.checkani_timer) >= ATH_ANI_POLLINTERVAL) {
725 aniflag = true;
726 common->ani.checkani_timer = timestamp;
727 }
728
729 /* Skip all processing if there's nothing to do. */
730 if (longcal || shortcal || aniflag) {
731 /* Call ANI routine if necessary */
732 if (aniflag)
733 ath9k_hw_ani_monitor(ah, ah->curchan);
734
735 /* Perform calibration if necessary */
736 if (longcal || shortcal) {
737 common->ani.caldone =
738 ath9k_hw_calibrate(ah, ah->curchan,
739 common->rx_chainmask,
740 longcal);
741
742 if (longcal)
743 common->ani.noise_floor =
744 ath9k_hw_getchan_noise(ah, ah->curchan);
745
746 ath_print(common, ATH_DBG_ANI,
747 " calibrate chan %u/%x nf: %d\n",
748 ah->curchan->channel,
749 ah->curchan->channelFlags,
750 common->ani.noise_floor);
751 }
752 }
753
754 /*
755 * Set timer interval based on previous results.
756 * The interval must be the shortest necessary to satisfy ANI,
757 * short calibration and long calibration.
758 */
759 cal_interval = ATH_LONG_CALINTERVAL;
760 if (priv->ah->config.enable_ani)
761 cal_interval = min(cal_interval, (u32)ATH_ANI_POLLINTERVAL);
762 if (!common->ani.caldone)
763 cal_interval = min(cal_interval, (u32)short_cal_interval);
764
765 ieee80211_queue_delayed_work(common->hw, &priv->ath9k_ani_work,
766 msecs_to_jiffies(cal_interval));
767}
768
769/*******/
770/* LED */
771/*******/
772
773static void ath9k_led_blink_work(struct work_struct *work)
774{
775 struct ath9k_htc_priv *priv = container_of(work, struct ath9k_htc_priv,
776 ath9k_led_blink_work.work);
777
778 if (!(priv->op_flags & OP_LED_ASSOCIATED))
779 return;
780
781 if ((priv->led_on_duration == ATH_LED_ON_DURATION_IDLE) ||
782 (priv->led_off_duration == ATH_LED_OFF_DURATION_IDLE))
783 ath9k_hw_set_gpio(priv->ah, priv->ah->led_pin, 0);
784 else
785 ath9k_hw_set_gpio(priv->ah, priv->ah->led_pin,
786 (priv->op_flags & OP_LED_ON) ? 1 : 0);
787
788 ieee80211_queue_delayed_work(priv->hw,
789 &priv->ath9k_led_blink_work,
790 (priv->op_flags & OP_LED_ON) ?
791 msecs_to_jiffies(priv->led_off_duration) :
792 msecs_to_jiffies(priv->led_on_duration));
793
794 priv->led_on_duration = priv->led_on_cnt ?
795 max((ATH_LED_ON_DURATION_IDLE - priv->led_on_cnt), 25) :
796 ATH_LED_ON_DURATION_IDLE;
797 priv->led_off_duration = priv->led_off_cnt ?
798 max((ATH_LED_OFF_DURATION_IDLE - priv->led_off_cnt), 10) :
799 ATH_LED_OFF_DURATION_IDLE;
800 priv->led_on_cnt = priv->led_off_cnt = 0;
801
802 if (priv->op_flags & OP_LED_ON)
803 priv->op_flags &= ~OP_LED_ON;
804 else
805 priv->op_flags |= OP_LED_ON;
806}
807
808static void ath9k_led_brightness_work(struct work_struct *work)
809{
810 struct ath_led *led = container_of(work, struct ath_led,
811 brightness_work.work);
812 struct ath9k_htc_priv *priv = led->priv;
813
814 switch (led->brightness) {
815 case LED_OFF:
816 if (led->led_type == ATH_LED_ASSOC ||
817 led->led_type == ATH_LED_RADIO) {
818 ath9k_hw_set_gpio(priv->ah, priv->ah->led_pin,
819 (led->led_type == ATH_LED_RADIO));
820 priv->op_flags &= ~OP_LED_ASSOCIATED;
821 if (led->led_type == ATH_LED_RADIO)
822 priv->op_flags &= ~OP_LED_ON;
823 } else {
824 priv->led_off_cnt++;
825 }
826 break;
827 case LED_FULL:
828 if (led->led_type == ATH_LED_ASSOC) {
829 priv->op_flags |= OP_LED_ASSOCIATED;
830 ieee80211_queue_delayed_work(priv->hw,
831 &priv->ath9k_led_blink_work, 0);
832 } else if (led->led_type == ATH_LED_RADIO) {
833 ath9k_hw_set_gpio(priv->ah, priv->ah->led_pin, 0);
834 priv->op_flags |= OP_LED_ON;
835 } else {
836 priv->led_on_cnt++;
837 }
838 break;
839 default:
840 break;
841 }
842}
843
844static void ath9k_led_brightness(struct led_classdev *led_cdev,
845 enum led_brightness brightness)
846{
847 struct ath_led *led = container_of(led_cdev, struct ath_led, led_cdev);
848 struct ath9k_htc_priv *priv = led->priv;
849
850 led->brightness = brightness;
851 if (!(priv->op_flags & OP_LED_DEINIT))
852 ieee80211_queue_delayed_work(priv->hw,
853 &led->brightness_work, 0);
854}
855
856static void ath9k_led_stop_brightness(struct ath9k_htc_priv *priv)
857{
858 cancel_delayed_work_sync(&priv->radio_led.brightness_work);
859 cancel_delayed_work_sync(&priv->assoc_led.brightness_work);
860 cancel_delayed_work_sync(&priv->tx_led.brightness_work);
861 cancel_delayed_work_sync(&priv->rx_led.brightness_work);
862}
863
864static int ath9k_register_led(struct ath9k_htc_priv *priv, struct ath_led *led,
865 char *trigger)
866{
867 int ret;
868
869 led->priv = priv;
870 led->led_cdev.name = led->name;
871 led->led_cdev.default_trigger = trigger;
872 led->led_cdev.brightness_set = ath9k_led_brightness;
873
874 ret = led_classdev_register(wiphy_dev(priv->hw->wiphy), &led->led_cdev);
875 if (ret)
876 ath_print(ath9k_hw_common(priv->ah), ATH_DBG_FATAL,
877 "Failed to register led:%s", led->name);
878 else
879 led->registered = 1;
880
881 INIT_DELAYED_WORK(&led->brightness_work, ath9k_led_brightness_work);
882
883 return ret;
884}
885
886static void ath9k_unregister_led(struct ath_led *led)
887{
888 if (led->registered) {
889 led_classdev_unregister(&led->led_cdev);
890 led->registered = 0;
891 }
892}
893
894void ath9k_deinit_leds(struct ath9k_htc_priv *priv)
895{
896 priv->op_flags |= OP_LED_DEINIT;
897 ath9k_unregister_led(&priv->assoc_led);
898 priv->op_flags &= ~OP_LED_ASSOCIATED;
899 ath9k_unregister_led(&priv->tx_led);
900 ath9k_unregister_led(&priv->rx_led);
901 ath9k_unregister_led(&priv->radio_led);
902 ath9k_hw_set_gpio(priv->ah, priv->ah->led_pin, 1);
903}
904
905void ath9k_init_leds(struct ath9k_htc_priv *priv)
906{
907 char *trigger;
908 int ret;
909
910 if (AR_SREV_9287(priv->ah))
911 priv->ah->led_pin = ATH_LED_PIN_9287;
912 else if (AR_SREV_9271(priv->ah))
913 priv->ah->led_pin = ATH_LED_PIN_9271;
914 else
915 priv->ah->led_pin = ATH_LED_PIN_DEF;
916
917 /* Configure gpio 1 for output */
918 ath9k_hw_cfg_output(priv->ah, priv->ah->led_pin,
919 AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
920 /* LED off, active low */
921 ath9k_hw_set_gpio(priv->ah, priv->ah->led_pin, 1);
922
923 INIT_DELAYED_WORK(&priv->ath9k_led_blink_work, ath9k_led_blink_work);
924
925 trigger = ieee80211_get_radio_led_name(priv->hw);
926 snprintf(priv->radio_led.name, sizeof(priv->radio_led.name),
927 "ath9k-%s::radio", wiphy_name(priv->hw->wiphy));
928 ret = ath9k_register_led(priv, &priv->radio_led, trigger);
929 priv->radio_led.led_type = ATH_LED_RADIO;
930 if (ret)
931 goto fail;
932
933 trigger = ieee80211_get_assoc_led_name(priv->hw);
934 snprintf(priv->assoc_led.name, sizeof(priv->assoc_led.name),
935 "ath9k-%s::assoc", wiphy_name(priv->hw->wiphy));
936 ret = ath9k_register_led(priv, &priv->assoc_led, trigger);
937 priv->assoc_led.led_type = ATH_LED_ASSOC;
938 if (ret)
939 goto fail;
940
941 trigger = ieee80211_get_tx_led_name(priv->hw);
942 snprintf(priv->tx_led.name, sizeof(priv->tx_led.name),
943 "ath9k-%s::tx", wiphy_name(priv->hw->wiphy));
944 ret = ath9k_register_led(priv, &priv->tx_led, trigger);
945 priv->tx_led.led_type = ATH_LED_TX;
946 if (ret)
947 goto fail;
948
949 trigger = ieee80211_get_rx_led_name(priv->hw);
950 snprintf(priv->rx_led.name, sizeof(priv->rx_led.name),
951 "ath9k-%s::rx", wiphy_name(priv->hw->wiphy));
952 ret = ath9k_register_led(priv, &priv->rx_led, trigger);
953 priv->rx_led.led_type = ATH_LED_RX;
954 if (ret)
955 goto fail;
956
957 priv->op_flags &= ~OP_LED_DEINIT;
958
959 return;
960
961fail:
962 cancel_delayed_work_sync(&priv->ath9k_led_blink_work);
963 ath9k_deinit_leds(priv);
964}
965
966/*******************/
967/* Rfkill */
968/*******************/
969
970static bool ath_is_rfkill_set(struct ath9k_htc_priv *priv)
971{
972 return ath9k_hw_gpio_get(priv->ah, priv->ah->rfkill_gpio) ==
973 priv->ah->rfkill_polarity;
974}
975
976static void ath9k_htc_rfkill_poll_state(struct ieee80211_hw *hw)
977{
978 struct ath9k_htc_priv *priv = hw->priv;
979 bool blocked = !!ath_is_rfkill_set(priv);
980
981 wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
982}
983
984void ath9k_start_rfkill_poll(struct ath9k_htc_priv *priv)
985{
986 if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
987 wiphy_rfkill_start_polling(priv->hw->wiphy);
988}
989
990/**********************/
991/* mac80211 Callbacks */
992/**********************/
993
994static int ath9k_htc_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
995{
996 struct ieee80211_hdr *hdr;
997 struct ath9k_htc_priv *priv = hw->priv;
998 int padpos, padsize;
999
1000 hdr = (struct ieee80211_hdr *) skb->data;
1001
1002 /* Add the padding after the header if this is not already done */
1003 padpos = ath9k_cmn_padpos(hdr->frame_control);
1004 padsize = padpos & 3;
1005 if (padsize && skb->len > padpos) {
1006 if (skb_headroom(skb) < padsize)
1007 return -1;
1008 skb_push(skb, padsize);
1009 memmove(skb->data, skb->data + padsize, padpos);
1010 }
1011
1012 if (ath9k_htc_tx_start(priv, skb) != 0) {
1013 ath_print(ath9k_hw_common(priv->ah), ATH_DBG_XMIT, "Tx failed");
1014 goto fail_tx;
1015 }
1016
1017 return 0;
1018
1019fail_tx:
1020 dev_kfree_skb_any(skb);
1021 return 0;
1022}
1023
1024static int ath9k_htc_start(struct ieee80211_hw *hw)
1025{
1026 struct ath9k_htc_priv *priv = hw->priv;
1027 struct ath_hw *ah = priv->ah;
1028 struct ath_common *common = ath9k_hw_common(ah);
1029 struct ieee80211_channel *curchan = hw->conf.channel;
1030 struct ath9k_channel *init_channel;
1031 int ret = 0;
1032 enum htc_phymode mode;
1033 u16 htc_mode;
1034 u8 cmd_rsp;
1035
1036 ath_print(common, ATH_DBG_CONFIG,
1037 "Starting driver with initial channel: %d MHz\n",
1038 curchan->center_freq);
1039
1040 mutex_lock(&priv->mutex);
1041
1042 /* setup initial channel */
1043 init_channel = ath9k_cmn_get_curchannel(hw, ah);
1044
1045 /* Reset SERDES registers */
1046 ath9k_hw_configpcipowersave(ah, 0, 0);
1047
1048 ath9k_hw_htc_resetinit(ah);
1049 ret = ath9k_hw_reset(ah, init_channel, false);
1050 if (ret) {
1051 ath_print(common, ATH_DBG_FATAL,
1052 "Unable to reset hardware; reset status %d "
1053 "(freq %u MHz)\n", ret, curchan->center_freq);
1054 goto mutex_unlock;
1055 }
1056
1057 ath_update_txpow(priv);
1058
1059 mode = ath9k_htc_get_curmode(priv, init_channel);
1060 htc_mode = cpu_to_be16(mode);
1061 WMI_CMD_BUF(WMI_SET_MODE_CMDID, &htc_mode);
1062 if (ret)
1063 goto mutex_unlock;
1064
1065 WMI_CMD(WMI_ATH_INIT_CMDID);
1066 if (ret)
1067 goto mutex_unlock;
1068
1069 WMI_CMD(WMI_START_RECV_CMDID);
1070 if (ret)
1071 goto mutex_unlock;
1072
1073 ath9k_host_rx_init(priv);
1074
1075 priv->op_flags &= ~OP_INVALID;
1076 htc_start(priv->htc);
1077
1078mutex_unlock:
1079 mutex_unlock(&priv->mutex);
1080 return ret;
1081}
1082
1083static void ath9k_htc_stop(struct ieee80211_hw *hw)
1084{
1085 struct ath9k_htc_priv *priv = hw->priv;
1086 struct ath_hw *ah = priv->ah;
1087 struct ath_common *common = ath9k_hw_common(ah);
1088 int ret = 0;
1089 u8 cmd_rsp;
1090
1091 mutex_lock(&priv->mutex);
1092
1093 if (priv->op_flags & OP_INVALID) {
1094 ath_print(common, ATH_DBG_ANY, "Device not present\n");
1095 mutex_unlock(&priv->mutex);
1096 return;
1097 }
1098
1099 htc_stop(priv->htc);
1100 WMI_CMD(WMI_DISABLE_INTR_CMDID);
1101 WMI_CMD(WMI_DRAIN_TXQ_ALL_CMDID);
1102 WMI_CMD(WMI_STOP_RECV_CMDID);
1103 ath9k_hw_phy_disable(ah);
1104 ath9k_hw_disable(ah);
1105 ath9k_hw_configpcipowersave(ah, 1, 1);
1106 ath9k_hw_setpower(ah, ATH9K_PM_FULL_SLEEP);
1107
1108 cancel_delayed_work_sync(&priv->ath9k_ani_work);
1109 cancel_delayed_work_sync(&priv->ath9k_aggr_work);
1110 cancel_delayed_work_sync(&priv->ath9k_led_blink_work);
1111 ath9k_led_stop_brightness(priv);
1112 skb_queue_purge(&priv->tx_queue);
1113
1114 /* Remove monitor interface here */
1115 if (ah->opmode == NL80211_IFTYPE_MONITOR) {
1116 if (ath9k_htc_remove_monitor_interface(priv))
1117 ath_print(common, ATH_DBG_FATAL,
1118 "Unable to remove monitor interface\n");
1119 else
1120 ath_print(common, ATH_DBG_CONFIG,
1121 "Monitor interface removed\n");
1122 }
1123
1124 priv->op_flags |= OP_INVALID;
1125 mutex_unlock(&priv->mutex);
1126
1127 ath_print(common, ATH_DBG_CONFIG, "Driver halt\n");
1128}
1129
1130static int ath9k_htc_add_interface(struct ieee80211_hw *hw,
1131 struct ieee80211_vif *vif)
1132{
1133 struct ath9k_htc_priv *priv = hw->priv;
1134 struct ath9k_htc_vif *avp = (void *)vif->drv_priv;
1135 struct ath_common *common = ath9k_hw_common(priv->ah);
1136 struct ath9k_htc_target_vif hvif;
1137 int ret = 0;
1138 u8 cmd_rsp;
1139
1140 mutex_lock(&priv->mutex);
1141
1142 /* Only one interface for now */
1143 if (priv->nvifs > 0) {
1144 ret = -ENOBUFS;
1145 goto out;
1146 }
1147
1148 memset(&hvif, 0, sizeof(struct ath9k_htc_target_vif));
1149 memcpy(&hvif.myaddr, vif->addr, ETH_ALEN);
1150
1151 switch (vif->type) {
1152 case NL80211_IFTYPE_STATION:
1153 hvif.opmode = cpu_to_be32(HTC_M_STA);
1154 break;
1155 case NL80211_IFTYPE_ADHOC:
1156 hvif.opmode = cpu_to_be32(HTC_M_IBSS);
1157 break;
1158 default:
1159 ath_print(common, ATH_DBG_FATAL,
1160 "Interface type %d not yet supported\n", vif->type);
1161 ret = -EOPNOTSUPP;
1162 goto out;
1163 }
1164
1165 ath_print(common, ATH_DBG_CONFIG,
1166 "Attach a VIF of type: %d\n", vif->type);
1167
1168 priv->ah->opmode = vif->type;
1169
1170 /* Index starts from zero on the target */
1171 avp->index = hvif.index = priv->nvifs;
1172 hvif.rtsthreshold = cpu_to_be16(2304);
1173 WMI_CMD_BUF(WMI_VAP_CREATE_CMDID, &hvif);
1174 if (ret)
1175 goto out;
1176
1177 priv->nvifs++;
1178
1179 /*
1180 * We need a node in target to tx mgmt frames
1181 * before association.
1182 */
1183 ret = ath9k_htc_add_station(priv, vif, NULL);
1184 if (ret)
1185 goto out;
1186
1187 ret = ath9k_htc_update_cap_target(priv);
1188 if (ret)
1189 ath_print(common, ATH_DBG_CONFIG, "Failed to update"
1190 " capability in target \n");
1191
1192 priv->vif = vif;
1193out:
1194 mutex_unlock(&priv->mutex);
1195 return ret;
1196}
1197
1198static void ath9k_htc_remove_interface(struct ieee80211_hw *hw,
1199 struct ieee80211_vif *vif)
1200{
1201 struct ath9k_htc_priv *priv = hw->priv;
1202 struct ath_common *common = ath9k_hw_common(priv->ah);
1203 struct ath9k_htc_vif *avp = (void *)vif->drv_priv;
1204 struct ath9k_htc_target_vif hvif;
1205 int ret = 0;
1206 u8 cmd_rsp;
1207
1208 ath_print(common, ATH_DBG_CONFIG, "Detach Interface\n");
1209
1210 mutex_lock(&priv->mutex);
1211
1212 memset(&hvif, 0, sizeof(struct ath9k_htc_target_vif));
1213 memcpy(&hvif.myaddr, vif->addr, ETH_ALEN);
1214 hvif.index = avp->index;
1215 WMI_CMD_BUF(WMI_VAP_REMOVE_CMDID, &hvif);
1216 priv->nvifs--;
1217
1218 ath9k_htc_remove_station(priv, vif, NULL);
1219
1220 if (vif->type == NL80211_IFTYPE_ADHOC) {
1221 spin_lock_bh(&priv->beacon_lock);
1222 if (priv->beacon)
1223 dev_kfree_skb_any(priv->beacon);
1224 priv->beacon = NULL;
1225 spin_unlock_bh(&priv->beacon_lock);
1226 }
1227
1228 priv->vif = NULL;
1229
1230 mutex_unlock(&priv->mutex);
1231}
1232
1233static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed)
1234{
1235 struct ath9k_htc_priv *priv = hw->priv;
1236 struct ath_common *common = ath9k_hw_common(priv->ah);
1237 struct ieee80211_conf *conf = &hw->conf;
1238
1239 mutex_lock(&priv->mutex);
1240
1241 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
1242 struct ieee80211_channel *curchan = hw->conf.channel;
1243 int pos = curchan->hw_value;
1244 bool is_cw40 = false;
1245
1246 ath_print(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n",
1247 curchan->center_freq);
1248
1249 if (check_rc_update(hw, &is_cw40))
1250 ath9k_htc_rc_update(priv, is_cw40);
1251
1252 ath9k_cmn_update_ichannel(hw, &priv->ah->channels[pos]);
1253
1254 if (ath9k_htc_set_channel(priv, hw, &priv->ah->channels[pos]) < 0) {
1255 ath_print(common, ATH_DBG_FATAL,
1256 "Unable to set channel\n");
1257 mutex_unlock(&priv->mutex);
1258 return -EINVAL;
1259 }
1260
1261 }
1262
1263 if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
1264 if (conf->flags & IEEE80211_CONF_MONITOR) {
1265 if (ath9k_htc_add_monitor_interface(priv))
1266 ath_print(common, ATH_DBG_FATAL,
1267 "Failed to set monitor mode\n");
1268 else
1269 ath_print(common, ATH_DBG_CONFIG,
1270 "HW opmode set to Monitor mode\n");
1271 }
1272 }
1273
1274 mutex_unlock(&priv->mutex);
1275
1276 return 0;
1277}
1278
1279#define SUPPORTED_FILTERS \
1280 (FIF_PROMISC_IN_BSS | \
1281 FIF_ALLMULTI | \
1282 FIF_CONTROL | \
1283 FIF_PSPOLL | \
1284 FIF_OTHER_BSS | \
1285 FIF_BCN_PRBRESP_PROMISC | \
1286 FIF_FCSFAIL)
1287
1288static void ath9k_htc_configure_filter(struct ieee80211_hw *hw,
1289 unsigned int changed_flags,
1290 unsigned int *total_flags,
1291 u64 multicast)
1292{
1293 struct ath9k_htc_priv *priv = hw->priv;
1294 u32 rfilt;
1295
1296 mutex_lock(&priv->mutex);
1297
1298 changed_flags &= SUPPORTED_FILTERS;
1299 *total_flags &= SUPPORTED_FILTERS;
1300
1301 priv->rxfilter = *total_flags;
1302 rfilt = ath9k_cmn_calcrxfilter(hw, priv->ah, priv->rxfilter);
1303 ath9k_hw_setrxfilter(priv->ah, rfilt);
1304
1305 ath_print(ath9k_hw_common(priv->ah), ATH_DBG_CONFIG,
1306 "Set HW RX filter: 0x%x\n", rfilt);
1307
1308 mutex_unlock(&priv->mutex);
1309}
1310
1311static void ath9k_htc_sta_notify(struct ieee80211_hw *hw,
1312 struct ieee80211_vif *vif,
1313 enum sta_notify_cmd cmd,
1314 struct ieee80211_sta *sta)
1315{
1316 struct ath9k_htc_priv *priv = hw->priv;
1317 int ret;
1318
1319 switch (cmd) {
1320 case STA_NOTIFY_ADD:
1321 ret = ath9k_htc_add_station(priv, vif, sta);
1322 if (!ret)
1323 ath9k_htc_init_rate(priv, vif, sta);
1324 break;
1325 case STA_NOTIFY_REMOVE:
1326 ath9k_htc_remove_station(priv, vif, sta);
1327 break;
1328 default:
1329 break;
1330 }
1331}
1332
1333static int ath9k_htc_conf_tx(struct ieee80211_hw *hw, u16 queue,
1334 const struct ieee80211_tx_queue_params *params)
1335{
1336 struct ath9k_htc_priv *priv = hw->priv;
1337 struct ath_common *common = ath9k_hw_common(priv->ah);
1338 struct ath9k_tx_queue_info qi;
1339 int ret = 0, qnum;
1340
1341 if (queue >= WME_NUM_AC)
1342 return 0;
1343
1344 mutex_lock(&priv->mutex);
1345
1346 memset(&qi, 0, sizeof(struct ath9k_tx_queue_info));
1347
1348 qi.tqi_aifs = params->aifs;
1349 qi.tqi_cwmin = params->cw_min;
1350 qi.tqi_cwmax = params->cw_max;
1351 qi.tqi_burstTime = params->txop;
1352
1353 qnum = get_hw_qnum(queue, priv->hwq_map);
1354
1355 ath_print(common, ATH_DBG_CONFIG,
1356 "Configure tx [queue/hwq] [%d/%d], "
1357 "aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n",
1358 queue, qnum, params->aifs, params->cw_min,
1359 params->cw_max, params->txop);
1360
1361 ret = ath_htc_txq_update(priv, qnum, &qi);
1362 if (ret)
1363 ath_print(common, ATH_DBG_FATAL, "TXQ Update failed\n");
1364
1365 mutex_unlock(&priv->mutex);
1366
1367 return ret;
1368}
1369
1370static int ath9k_htc_set_key(struct ieee80211_hw *hw,
1371 enum set_key_cmd cmd,
1372 struct ieee80211_vif *vif,
1373 struct ieee80211_sta *sta,
1374 struct ieee80211_key_conf *key)
1375{
1376 struct ath9k_htc_priv *priv = hw->priv;
1377 struct ath_common *common = ath9k_hw_common(priv->ah);
1378 int ret = 0;
1379
1380 if (htc_modparam_nohwcrypt)
1381 return -ENOSPC;
1382
1383 mutex_lock(&priv->mutex);
1384 ath_print(common, ATH_DBG_CONFIG, "Set HW Key\n");
1385
1386 switch (cmd) {
1387 case SET_KEY:
1388 ret = ath9k_cmn_key_config(common, vif, sta, key);
1389 if (ret >= 0) {
1390 key->hw_key_idx = ret;
1391 /* push IV and Michael MIC generation to stack */
1392 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1393 if (key->alg == ALG_TKIP)
1394 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1395 if (priv->ah->sw_mgmt_crypto && key->alg == ALG_CCMP)
1396 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT;
1397 ret = 0;
1398 }
1399 break;
1400 case DISABLE_KEY:
1401 ath9k_cmn_key_delete(common, key);
1402 break;
1403 default:
1404 ret = -EINVAL;
1405 }
1406
1407 mutex_unlock(&priv->mutex);
1408
1409 return ret;
1410}
1411
1412static void ath9k_htc_bss_info_changed(struct ieee80211_hw *hw,
1413 struct ieee80211_vif *vif,
1414 struct ieee80211_bss_conf *bss_conf,
1415 u32 changed)
1416{
1417 struct ath9k_htc_priv *priv = hw->priv;
1418 struct ath_hw *ah = priv->ah;
1419 struct ath_common *common = ath9k_hw_common(ah);
1420
1421 mutex_lock(&priv->mutex);
1422
1423 if (changed & BSS_CHANGED_ASSOC) {
1424 common->curaid = bss_conf->assoc ?
1425 bss_conf->aid : 0;
1426 ath_print(common, ATH_DBG_CONFIG, "BSS Changed ASSOC %d\n",
1427 bss_conf->assoc);
1428
1429 if (bss_conf->assoc) {
1430 priv->op_flags |= OP_ASSOCIATED;
1431 ath_start_ani(priv);
1432 } else {
1433 priv->op_flags &= ~OP_ASSOCIATED;
1434 cancel_delayed_work_sync(&priv->ath9k_ani_work);
1435 }
1436 }
1437
1438 if (changed & BSS_CHANGED_BSSID) {
1439 /* Set BSSID */
1440 memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
1441 ath9k_hw_write_associd(ah);
1442
1443 ath_print(common, ATH_DBG_CONFIG,
1444 "BSSID: %pM aid: 0x%x\n",
1445 common->curbssid, common->curaid);
1446 }
1447
1448 if ((changed & BSS_CHANGED_BEACON_INT) ||
1449 (changed & BSS_CHANGED_BEACON) ||
1450 ((changed & BSS_CHANGED_BEACON_ENABLED) &&
1451 bss_conf->enable_beacon)) {
1452 priv->op_flags |= OP_ENABLE_BEACON;
1453 ath9k_htc_beacon_config(priv, vif, bss_conf);
1454 }
1455
1456 if (changed & BSS_CHANGED_BEACON)
1457 ath9k_htc_beacon_update(priv, vif);
1458
1459 if ((changed & BSS_CHANGED_BEACON_ENABLED) &&
1460 !bss_conf->enable_beacon) {
1461 priv->op_flags &= ~OP_ENABLE_BEACON;
1462 ath9k_htc_beacon_config(priv, vif, bss_conf);
1463 }
1464
1465 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
1466 ath_print(common, ATH_DBG_CONFIG, "BSS Changed PREAMBLE %d\n",
1467 bss_conf->use_short_preamble);
1468 if (bss_conf->use_short_preamble)
1469 priv->op_flags |= OP_PREAMBLE_SHORT;
1470 else
1471 priv->op_flags &= ~OP_PREAMBLE_SHORT;
1472 }
1473
1474 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
1475 ath_print(common, ATH_DBG_CONFIG, "BSS Changed CTS PROT %d\n",
1476 bss_conf->use_cts_prot);
1477 if (bss_conf->use_cts_prot &&
1478 hw->conf.channel->band != IEEE80211_BAND_5GHZ)
1479 priv->op_flags |= OP_PROTECT_ENABLE;
1480 else
1481 priv->op_flags &= ~OP_PROTECT_ENABLE;
1482 }
1483
1484 if (changed & BSS_CHANGED_ERP_SLOT) {
1485 if (bss_conf->use_short_slot)
1486 ah->slottime = 9;
1487 else
1488 ah->slottime = 20;
1489
1490 ath9k_hw_init_global_settings(ah);
1491 }
1492
1493 mutex_unlock(&priv->mutex);
1494}
1495
1496static u64 ath9k_htc_get_tsf(struct ieee80211_hw *hw)
1497{
1498 struct ath9k_htc_priv *priv = hw->priv;
1499 u64 tsf;
1500
1501 mutex_lock(&priv->mutex);
1502 tsf = ath9k_hw_gettsf64(priv->ah);
1503 mutex_unlock(&priv->mutex);
1504
1505 return tsf;
1506}
1507
1508static void ath9k_htc_set_tsf(struct ieee80211_hw *hw, u64 tsf)
1509{
1510 struct ath9k_htc_priv *priv = hw->priv;
1511
1512 mutex_lock(&priv->mutex);
1513 ath9k_hw_settsf64(priv->ah, tsf);
1514 mutex_unlock(&priv->mutex);
1515}
1516
1517static void ath9k_htc_reset_tsf(struct ieee80211_hw *hw)
1518{
1519 struct ath9k_htc_priv *priv = hw->priv;
1520
1521 mutex_lock(&priv->mutex);
1522 ath9k_hw_reset_tsf(priv->ah);
1523 mutex_unlock(&priv->mutex);
1524}
1525
1526static int ath9k_htc_ampdu_action(struct ieee80211_hw *hw,
1527 struct ieee80211_vif *vif,
1528 enum ieee80211_ampdu_mlme_action action,
1529 struct ieee80211_sta *sta,
1530 u16 tid, u16 *ssn)
1531{
1532 struct ath9k_htc_priv *priv = hw->priv;
1533 struct ath9k_htc_aggr_work *work = &priv->aggr_work;
1534 struct ath9k_htc_sta *ista;
1535
1536 switch (action) {
1537 case IEEE80211_AMPDU_RX_START:
1538 break;
1539 case IEEE80211_AMPDU_RX_STOP:
1540 break;
1541 case IEEE80211_AMPDU_TX_START:
1542 case IEEE80211_AMPDU_TX_STOP:
1543 if (!(priv->op_flags & OP_TXAGGR))
1544 return -ENOTSUPP;
1545 memcpy(work->sta_addr, sta->addr, ETH_ALEN);
1546 work->hw = hw;
1547 work->vif = vif;
1548 work->action = action;
1549 work->tid = tid;
1550 ieee80211_queue_delayed_work(hw, &priv->ath9k_aggr_work, 0);
1551 break;
1552 case IEEE80211_AMPDU_TX_OPERATIONAL:
1553 ista = (struct ath9k_htc_sta *) sta->drv_priv;
1554 ista->tid_state[tid] = AGGR_OPERATIONAL;
1555 break;
1556 default:
1557 ath_print(ath9k_hw_common(priv->ah), ATH_DBG_FATAL,
1558 "Unknown AMPDU action\n");
1559 }
1560
1561 return 0;
1562}
1563
1564static void ath9k_htc_sw_scan_start(struct ieee80211_hw *hw)
1565{
1566 struct ath9k_htc_priv *priv = hw->priv;
1567
1568 mutex_lock(&priv->mutex);
1569 spin_lock_bh(&priv->beacon_lock);
1570 priv->op_flags |= OP_SCANNING;
1571 spin_unlock_bh(&priv->beacon_lock);
1572 cancel_delayed_work_sync(&priv->ath9k_ani_work);
1573 mutex_unlock(&priv->mutex);
1574}
1575
1576static void ath9k_htc_sw_scan_complete(struct ieee80211_hw *hw)
1577{
1578 struct ath9k_htc_priv *priv = hw->priv;
1579
1580 mutex_lock(&priv->mutex);
1581 spin_lock_bh(&priv->beacon_lock);
1582 priv->op_flags &= ~OP_SCANNING;
1583 spin_unlock_bh(&priv->beacon_lock);
1584 priv->op_flags |= OP_FULL_RESET;
1585 ath_start_ani(priv);
1586 mutex_unlock(&priv->mutex);
1587}
1588
1589static int ath9k_htc_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
1590{
1591 return 0;
1592}
1593
1594static void ath9k_htc_set_coverage_class(struct ieee80211_hw *hw,
1595 u8 coverage_class)
1596{
1597 struct ath9k_htc_priv *priv = hw->priv;
1598
1599 mutex_lock(&priv->mutex);
1600 priv->ah->coverage_class = coverage_class;
1601 ath9k_hw_init_global_settings(priv->ah);
1602 mutex_unlock(&priv->mutex);
1603}
1604
1605struct ieee80211_ops ath9k_htc_ops = {
1606 .tx = ath9k_htc_tx,
1607 .start = ath9k_htc_start,
1608 .stop = ath9k_htc_stop,
1609 .add_interface = ath9k_htc_add_interface,
1610 .remove_interface = ath9k_htc_remove_interface,
1611 .config = ath9k_htc_config,
1612 .configure_filter = ath9k_htc_configure_filter,
1613 .sta_notify = ath9k_htc_sta_notify,
1614 .conf_tx = ath9k_htc_conf_tx,
1615 .bss_info_changed = ath9k_htc_bss_info_changed,
1616 .set_key = ath9k_htc_set_key,
1617 .get_tsf = ath9k_htc_get_tsf,
1618 .set_tsf = ath9k_htc_set_tsf,
1619 .reset_tsf = ath9k_htc_reset_tsf,
1620 .ampdu_action = ath9k_htc_ampdu_action,
1621 .sw_scan_start = ath9k_htc_sw_scan_start,
1622 .sw_scan_complete = ath9k_htc_sw_scan_complete,
1623 .set_rts_threshold = ath9k_htc_set_rts_threshold,
1624 .rfkill_poll = ath9k_htc_rfkill_poll_state,
1625 .set_coverage_class = ath9k_htc_set_coverage_class,
1626};
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
new file mode 100644
index 000000000000..ac66cf0b2d53
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
@@ -0,0 +1,604 @@
1/*
2 * Copyright (c) 2010 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 "htc.h"
18
19/******/
20/* TX */
21/******/
22
23int get_hw_qnum(u16 queue, int *hwq_map)
24{
25 switch (queue) {
26 case 0:
27 return hwq_map[ATH9K_WME_AC_VO];
28 case 1:
29 return hwq_map[ATH9K_WME_AC_VI];
30 case 2:
31 return hwq_map[ATH9K_WME_AC_BE];
32 case 3:
33 return hwq_map[ATH9K_WME_AC_BK];
34 default:
35 return hwq_map[ATH9K_WME_AC_BE];
36 }
37}
38
39int ath_htc_txq_update(struct ath9k_htc_priv *priv, int qnum,
40 struct ath9k_tx_queue_info *qinfo)
41{
42 struct ath_hw *ah = priv->ah;
43 int error = 0;
44 struct ath9k_tx_queue_info qi;
45
46 ath9k_hw_get_txq_props(ah, qnum, &qi);
47
48 qi.tqi_aifs = qinfo->tqi_aifs;
49 qi.tqi_cwmin = qinfo->tqi_cwmin / 2; /* XXX */
50 qi.tqi_cwmax = qinfo->tqi_cwmax;
51 qi.tqi_burstTime = qinfo->tqi_burstTime;
52 qi.tqi_readyTime = qinfo->tqi_readyTime;
53
54 if (!ath9k_hw_set_txq_props(ah, qnum, &qi)) {
55 ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
56 "Unable to update hardware queue %u!\n", qnum);
57 error = -EIO;
58 } else {
59 ath9k_hw_resettxqueue(ah, qnum);
60 }
61
62 return error;
63}
64
65int ath9k_htc_tx_start(struct ath9k_htc_priv *priv, struct sk_buff *skb)
66{
67 struct ieee80211_hdr *hdr;
68 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
69 struct ieee80211_sta *sta = tx_info->control.sta;
70 struct ath9k_htc_sta *ista;
71 struct ath9k_htc_vif *avp;
72 struct ath9k_htc_tx_ctl tx_ctl;
73 enum htc_endpoint_id epid;
74 u16 qnum, hw_qnum;
75 __le16 fc;
76 u8 *tx_fhdr;
77 u8 sta_idx;
78
79 hdr = (struct ieee80211_hdr *) skb->data;
80 fc = hdr->frame_control;
81
82 avp = (struct ath9k_htc_vif *) tx_info->control.vif->drv_priv;
83 if (sta) {
84 ista = (struct ath9k_htc_sta *) sta->drv_priv;
85 sta_idx = ista->index;
86 } else {
87 sta_idx = 0;
88 }
89
90 memset(&tx_ctl, 0, sizeof(struct ath9k_htc_tx_ctl));
91
92 if (ieee80211_is_data(fc)) {
93 struct tx_frame_hdr tx_hdr;
94 u8 *qc;
95
96 memset(&tx_hdr, 0, sizeof(struct tx_frame_hdr));
97
98 tx_hdr.node_idx = sta_idx;
99 tx_hdr.vif_idx = avp->index;
100
101 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
102 tx_ctl.type = ATH9K_HTC_AMPDU;
103 tx_hdr.data_type = ATH9K_HTC_AMPDU;
104 } else {
105 tx_ctl.type = ATH9K_HTC_NORMAL;
106 tx_hdr.data_type = ATH9K_HTC_NORMAL;
107 }
108
109 if (ieee80211_is_data(fc)) {
110 qc = ieee80211_get_qos_ctl(hdr);
111 tx_hdr.tidno = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
112 }
113
114 /* Check for RTS protection */
115 if (priv->hw->wiphy->rts_threshold != (u32) -1)
116 if (skb->len > priv->hw->wiphy->rts_threshold)
117 tx_hdr.flags |= ATH9K_HTC_TX_RTSCTS;
118
119 /* CTS-to-self */
120 if (!(tx_hdr.flags & ATH9K_HTC_TX_RTSCTS) &&
121 (priv->op_flags & OP_PROTECT_ENABLE))
122 tx_hdr.flags |= ATH9K_HTC_TX_CTSONLY;
123
124 tx_hdr.key_type = ath9k_cmn_get_hw_crypto_keytype(skb);
125 if (tx_hdr.key_type == ATH9K_KEY_TYPE_CLEAR)
126 tx_hdr.keyix = (u8) ATH9K_TXKEYIX_INVALID;
127 else
128 tx_hdr.keyix = tx_info->control.hw_key->hw_key_idx;
129
130 tx_fhdr = skb_push(skb, sizeof(tx_hdr));
131 memcpy(tx_fhdr, (u8 *) &tx_hdr, sizeof(tx_hdr));
132
133 qnum = skb_get_queue_mapping(skb);
134 hw_qnum = get_hw_qnum(qnum, priv->hwq_map);
135
136 switch (hw_qnum) {
137 case 0:
138 epid = priv->data_be_ep;
139 break;
140 case 2:
141 epid = priv->data_vi_ep;
142 break;
143 case 3:
144 epid = priv->data_vo_ep;
145 break;
146 case 1:
147 default:
148 epid = priv->data_bk_ep;
149 break;
150 }
151 } else {
152 struct tx_mgmt_hdr mgmt_hdr;
153
154 memset(&mgmt_hdr, 0, sizeof(struct tx_mgmt_hdr));
155
156 tx_ctl.type = ATH9K_HTC_NORMAL;
157
158 mgmt_hdr.node_idx = sta_idx;
159 mgmt_hdr.vif_idx = avp->index;
160 mgmt_hdr.tidno = 0;
161 mgmt_hdr.flags = 0;
162
163 mgmt_hdr.key_type = ath9k_cmn_get_hw_crypto_keytype(skb);
164 if (mgmt_hdr.key_type == ATH9K_KEY_TYPE_CLEAR)
165 mgmt_hdr.keyix = (u8) ATH9K_TXKEYIX_INVALID;
166 else
167 mgmt_hdr.keyix = tx_info->control.hw_key->hw_key_idx;
168
169 tx_fhdr = skb_push(skb, sizeof(mgmt_hdr));
170 memcpy(tx_fhdr, (u8 *) &mgmt_hdr, sizeof(mgmt_hdr));
171 epid = priv->mgmt_ep;
172 }
173
174 return htc_send(priv->htc, skb, epid, &tx_ctl);
175}
176
177void ath9k_tx_tasklet(unsigned long data)
178{
179 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *)data;
180 struct ieee80211_sta *sta;
181 struct ieee80211_hdr *hdr;
182 struct ieee80211_tx_info *tx_info;
183 struct sk_buff *skb = NULL;
184 __le16 fc;
185
186 while ((skb = skb_dequeue(&priv->tx_queue)) != NULL) {
187
188 hdr = (struct ieee80211_hdr *) skb->data;
189 fc = hdr->frame_control;
190 tx_info = IEEE80211_SKB_CB(skb);
191 sta = tx_info->control.sta;
192
193 rcu_read_lock();
194
195 if (sta && conf_is_ht(&priv->hw->conf) &&
196 (priv->op_flags & OP_TXAGGR)
197 && !(skb->protocol == cpu_to_be16(ETH_P_PAE))) {
198 if (ieee80211_is_data_qos(fc)) {
199 u8 *qc, tid;
200 struct ath9k_htc_sta *ista;
201
202 qc = ieee80211_get_qos_ctl(hdr);
203 tid = qc[0] & 0xf;
204 ista = (struct ath9k_htc_sta *)sta->drv_priv;
205
206 if ((tid < ATH9K_HTC_MAX_TID) &&
207 ista->tid_state[tid] == AGGR_STOP) {
208 ieee80211_start_tx_ba_session(sta, tid);
209 ista->tid_state[tid] = AGGR_PROGRESS;
210 }
211 }
212 }
213
214 rcu_read_unlock();
215
216 memset(&tx_info->status, 0, sizeof(tx_info->status));
217 ieee80211_tx_status(priv->hw, skb);
218 }
219}
220
221void ath9k_htc_txep(void *drv_priv, struct sk_buff *skb,
222 enum htc_endpoint_id ep_id, bool txok)
223{
224 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) drv_priv;
225 struct ieee80211_tx_info *tx_info;
226
227 if (!skb)
228 return;
229
230 if (ep_id == priv->mgmt_ep)
231 skb_pull(skb, sizeof(struct tx_mgmt_hdr));
232 else
233 /* TODO: Check for cab/uapsd/data */
234 skb_pull(skb, sizeof(struct tx_frame_hdr));
235
236 tx_info = IEEE80211_SKB_CB(skb);
237
238 if (txok)
239 tx_info->flags |= IEEE80211_TX_STAT_ACK;
240
241 skb_queue_tail(&priv->tx_queue, skb);
242 tasklet_schedule(&priv->tx_tasklet);
243}
244
245int ath9k_tx_init(struct ath9k_htc_priv *priv)
246{
247 skb_queue_head_init(&priv->tx_queue);
248 return 0;
249}
250
251void ath9k_tx_cleanup(struct ath9k_htc_priv *priv)
252{
253
254}
255
256bool ath9k_htc_txq_setup(struct ath9k_htc_priv *priv,
257 enum ath9k_tx_queue_subtype subtype)
258{
259 struct ath_hw *ah = priv->ah;
260 struct ath_common *common = ath9k_hw_common(ah);
261 struct ath9k_tx_queue_info qi;
262 int qnum;
263
264 memset(&qi, 0, sizeof(qi));
265
266 qi.tqi_subtype = subtype;
267 qi.tqi_aifs = ATH9K_TXQ_USEDEFAULT;
268 qi.tqi_cwmin = ATH9K_TXQ_USEDEFAULT;
269 qi.tqi_cwmax = ATH9K_TXQ_USEDEFAULT;
270 qi.tqi_physCompBuf = 0;
271 qi.tqi_qflags = TXQ_FLAG_TXEOLINT_ENABLE | TXQ_FLAG_TXDESCINT_ENABLE;
272
273 qnum = ath9k_hw_setuptxqueue(priv->ah, ATH9K_TX_QUEUE_DATA, &qi);
274 if (qnum == -1)
275 return false;
276
277 if (qnum >= ARRAY_SIZE(priv->hwq_map)) {
278 ath_print(common, ATH_DBG_FATAL,
279 "qnum %u out of range, max %u!\n",
280 qnum, (unsigned int)ARRAY_SIZE(priv->hwq_map));
281 ath9k_hw_releasetxqueue(ah, qnum);
282 return false;
283 }
284
285 priv->hwq_map[subtype] = qnum;
286 return true;
287}
288
289/******/
290/* RX */
291/******/
292
293void ath9k_host_rx_init(struct ath9k_htc_priv *priv)
294{
295 ath9k_hw_rxena(priv->ah);
296 ath9k_cmn_opmode_init(priv->hw, priv->ah, priv->rxfilter);
297 ath9k_hw_startpcureceive(priv->ah);
298 priv->rx.last_rssi = ATH_RSSI_DUMMY_MARKER;
299}
300
301static void ath9k_process_rate(struct ieee80211_hw *hw,
302 struct ieee80211_rx_status *rxs,
303 u8 rx_rate, u8 rs_flags)
304{
305 struct ieee80211_supported_band *sband;
306 enum ieee80211_band band;
307 unsigned int i = 0;
308
309 if (rx_rate & 0x80) {
310 /* HT rate */
311 rxs->flag |= RX_FLAG_HT;
312 if (rs_flags & ATH9K_RX_2040)
313 rxs->flag |= RX_FLAG_40MHZ;
314 if (rs_flags & ATH9K_RX_GI)
315 rxs->flag |= RX_FLAG_SHORT_GI;
316 rxs->rate_idx = rx_rate & 0x7f;
317 return;
318 }
319
320 band = hw->conf.channel->band;
321 sband = hw->wiphy->bands[band];
322
323 for (i = 0; i < sband->n_bitrates; i++) {
324 if (sband->bitrates[i].hw_value == rx_rate) {
325 rxs->rate_idx = i;
326 return;
327 }
328 if (sband->bitrates[i].hw_value_short == rx_rate) {
329 rxs->rate_idx = i;
330 rxs->flag |= RX_FLAG_SHORTPRE;
331 return;
332 }
333 }
334
335}
336
337static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
338 struct ath9k_htc_rxbuf *rxbuf,
339 struct ieee80211_rx_status *rx_status)
340
341{
342 struct ieee80211_hdr *hdr;
343 struct ieee80211_hw *hw = priv->hw;
344 struct sk_buff *skb = rxbuf->skb;
345 struct ath_common *common = ath9k_hw_common(priv->ah);
346 int hdrlen, padpos, padsize;
347 int last_rssi = ATH_RSSI_DUMMY_MARKER;
348 __le16 fc;
349
350 hdr = (struct ieee80211_hdr *)skb->data;
351 fc = hdr->frame_control;
352 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
353
354 padpos = ath9k_cmn_padpos(fc);
355
356 padsize = padpos & 3;
357 if (padsize && skb->len >= padpos+padsize) {
358 memmove(skb->data + padsize, skb->data, padpos);
359 skb_pull(skb, padsize);
360 }
361
362 memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
363
364 if (rxbuf->rxstatus.rs_status != 0) {
365 if (rxbuf->rxstatus.rs_status & ATH9K_RXERR_CRC)
366 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
367 if (rxbuf->rxstatus.rs_status & ATH9K_RXERR_PHY)
368 goto rx_next;
369
370 if (rxbuf->rxstatus.rs_status & ATH9K_RXERR_DECRYPT) {
371 /* FIXME */
372 } else if (rxbuf->rxstatus.rs_status & ATH9K_RXERR_MIC) {
373 if (ieee80211_is_ctl(fc))
374 /*
375 * Sometimes, we get invalid
376 * MIC failures on valid control frames.
377 * Remove these mic errors.
378 */
379 rxbuf->rxstatus.rs_status &= ~ATH9K_RXERR_MIC;
380 else
381 rx_status->flag |= RX_FLAG_MMIC_ERROR;
382 }
383
384 /*
385 * Reject error frames with the exception of
386 * decryption and MIC failures. For monitor mode,
387 * we also ignore the CRC error.
388 */
389 if (priv->ah->opmode == NL80211_IFTYPE_MONITOR) {
390 if (rxbuf->rxstatus.rs_status &
391 ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC |
392 ATH9K_RXERR_CRC))
393 goto rx_next;
394 } else {
395 if (rxbuf->rxstatus.rs_status &
396 ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC)) {
397 goto rx_next;
398 }
399 }
400 }
401
402 if (!(rxbuf->rxstatus.rs_status & ATH9K_RXERR_DECRYPT)) {
403 u8 keyix;
404 keyix = rxbuf->rxstatus.rs_keyix;
405 if (keyix != ATH9K_RXKEYIX_INVALID) {
406 rx_status->flag |= RX_FLAG_DECRYPTED;
407 } else if (ieee80211_has_protected(fc) &&
408 skb->len >= hdrlen + 4) {
409 keyix = skb->data[hdrlen + 3] >> 6;
410 if (test_bit(keyix, common->keymap))
411 rx_status->flag |= RX_FLAG_DECRYPTED;
412 }
413 }
414
415 ath9k_process_rate(hw, rx_status, rxbuf->rxstatus.rs_rate,
416 rxbuf->rxstatus.rs_flags);
417
418 if (priv->op_flags & OP_ASSOCIATED) {
419 if (rxbuf->rxstatus.rs_rssi != ATH9K_RSSI_BAD &&
420 !rxbuf->rxstatus.rs_moreaggr)
421 ATH_RSSI_LPF(priv->rx.last_rssi,
422 rxbuf->rxstatus.rs_rssi);
423
424 last_rssi = priv->rx.last_rssi;
425
426 if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
427 rxbuf->rxstatus.rs_rssi = ATH_EP_RND(last_rssi,
428 ATH_RSSI_EP_MULTIPLIER);
429
430 if (rxbuf->rxstatus.rs_rssi < 0)
431 rxbuf->rxstatus.rs_rssi = 0;
432
433 if (ieee80211_is_beacon(fc))
434 priv->ah->stats.avgbrssi = rxbuf->rxstatus.rs_rssi;
435 }
436
437 rx_status->mactime = rxbuf->rxstatus.rs_tstamp;
438 rx_status->band = hw->conf.channel->band;
439 rx_status->freq = hw->conf.channel->center_freq;
440 rx_status->signal = rxbuf->rxstatus.rs_rssi + ATH_DEFAULT_NOISE_FLOOR;
441 rx_status->antenna = rxbuf->rxstatus.rs_antenna;
442 rx_status->flag |= RX_FLAG_TSFT;
443
444 return true;
445
446rx_next:
447 return false;
448}
449
450/*
451 * FIXME: Handle FLUSH later on.
452 */
453void ath9k_rx_tasklet(unsigned long data)
454{
455 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *)data;
456 struct ath9k_htc_rxbuf *rxbuf = NULL, *tmp_buf = NULL;
457 struct ieee80211_rx_status rx_status;
458 struct sk_buff *skb;
459 unsigned long flags;
460
461
462 do {
463 spin_lock_irqsave(&priv->rx.rxbuflock, flags);
464 list_for_each_entry(tmp_buf, &priv->rx.rxbuf, list) {
465 if (tmp_buf->in_process) {
466 rxbuf = tmp_buf;
467 break;
468 }
469 }
470
471 if (rxbuf == NULL) {
472 spin_unlock_irqrestore(&priv->rx.rxbuflock, flags);
473 break;
474 }
475
476 if (!rxbuf->skb)
477 goto requeue;
478
479 if (!ath9k_rx_prepare(priv, rxbuf, &rx_status)) {
480 dev_kfree_skb_any(rxbuf->skb);
481 goto requeue;
482 }
483
484 memcpy(IEEE80211_SKB_RXCB(rxbuf->skb), &rx_status,
485 sizeof(struct ieee80211_rx_status));
486 skb = rxbuf->skb;
487 spin_unlock_irqrestore(&priv->rx.rxbuflock, flags);
488
489 ieee80211_rx(priv->hw, skb);
490
491 spin_lock_irqsave(&priv->rx.rxbuflock, flags);
492requeue:
493 rxbuf->in_process = false;
494 rxbuf->skb = NULL;
495 list_move_tail(&rxbuf->list, &priv->rx.rxbuf);
496 rxbuf = NULL;
497 spin_unlock_irqrestore(&priv->rx.rxbuflock, flags);
498 } while (1);
499
500}
501
502void ath9k_htc_rxep(void *drv_priv, struct sk_buff *skb,
503 enum htc_endpoint_id ep_id)
504{
505 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *)drv_priv;
506 struct ath_hw *ah = priv->ah;
507 struct ath_common *common = ath9k_hw_common(ah);
508 struct ath9k_htc_rxbuf *rxbuf = NULL, *tmp_buf = NULL;
509 struct ath_htc_rx_status *rxstatus;
510 u32 len = 0;
511
512 spin_lock(&priv->rx.rxbuflock);
513 list_for_each_entry(tmp_buf, &priv->rx.rxbuf, list) {
514 if (!tmp_buf->in_process) {
515 rxbuf = tmp_buf;
516 break;
517 }
518 }
519 spin_unlock(&priv->rx.rxbuflock);
520
521 if (rxbuf == NULL) {
522 ath_print(common, ATH_DBG_ANY,
523 "No free RX buffer\n");
524 goto err;
525 }
526
527 len = skb->len;
528 if (len <= HTC_RX_FRAME_HEADER_SIZE) {
529 ath_print(common, ATH_DBG_FATAL,
530 "Corrupted RX frame, dropping\n");
531 goto err;
532 }
533
534 rxstatus = (struct ath_htc_rx_status *)skb->data;
535
536 rxstatus->rs_tstamp = be64_to_cpu(rxstatus->rs_tstamp);
537 rxstatus->rs_datalen = be16_to_cpu(rxstatus->rs_datalen);
538 rxstatus->evm0 = be32_to_cpu(rxstatus->evm0);
539 rxstatus->evm1 = be32_to_cpu(rxstatus->evm1);
540 rxstatus->evm2 = be32_to_cpu(rxstatus->evm2);
541
542 if (rxstatus->rs_datalen - (len - HTC_RX_FRAME_HEADER_SIZE) != 0) {
543 ath_print(common, ATH_DBG_FATAL,
544 "Corrupted RX data len, dropping "
545 "(epid: %d, dlen: %d, skblen: %d)\n",
546 ep_id, rxstatus->rs_datalen, len);
547 goto err;
548 }
549
550 spin_lock(&priv->rx.rxbuflock);
551 memcpy(&rxbuf->rxstatus, rxstatus, HTC_RX_FRAME_HEADER_SIZE);
552 skb_pull(skb, HTC_RX_FRAME_HEADER_SIZE);
553 skb->len = rxstatus->rs_datalen;
554 rxbuf->skb = skb;
555 rxbuf->in_process = true;
556 spin_unlock(&priv->rx.rxbuflock);
557
558 tasklet_schedule(&priv->rx_tasklet);
559 return;
560err:
561 dev_kfree_skb_any(skb);
562 return;
563}
564
565/* FIXME: Locking for cleanup/init */
566
567void ath9k_rx_cleanup(struct ath9k_htc_priv *priv)
568{
569 struct ath9k_htc_rxbuf *rxbuf, *tbuf;
570
571 list_for_each_entry_safe(rxbuf, tbuf, &priv->rx.rxbuf, list) {
572 list_del(&rxbuf->list);
573 if (rxbuf->skb)
574 dev_kfree_skb_any(rxbuf->skb);
575 kfree(rxbuf);
576 }
577}
578
579int ath9k_rx_init(struct ath9k_htc_priv *priv)
580{
581 struct ath_hw *ah = priv->ah;
582 struct ath_common *common = ath9k_hw_common(ah);
583 struct ath9k_htc_rxbuf *rxbuf;
584 int i = 0;
585
586 INIT_LIST_HEAD(&priv->rx.rxbuf);
587 spin_lock_init(&priv->rx.rxbuflock);
588
589 for (i = 0; i < ATH9K_HTC_RXBUF; i++) {
590 rxbuf = kzalloc(sizeof(struct ath9k_htc_rxbuf), GFP_KERNEL);
591 if (rxbuf == NULL) {
592 ath_print(common, ATH_DBG_FATAL,
593 "Unable to allocate RX buffers\n");
594 goto err;
595 }
596 list_add_tail(&rxbuf->list, &priv->rx.rxbuf);
597 }
598
599 return 0;
600
601err:
602 ath9k_rx_cleanup(priv);
603 return -ENOMEM;
604}
diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c
new file mode 100644
index 000000000000..9a48999d0979
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/htc_hst.c
@@ -0,0 +1,463 @@
1/*
2 * Copyright (c) 2010 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 "htc.h"
18
19static int htc_issue_send(struct htc_target *target, struct sk_buff* skb,
20 u16 len, u8 flags, u8 epid,
21 struct ath9k_htc_tx_ctl *tx_ctl)
22{
23 struct htc_frame_hdr *hdr;
24 struct htc_endpoint *endpoint = &target->endpoint[epid];
25 int status;
26
27 hdr = (struct htc_frame_hdr *)
28 skb_push(skb, sizeof(struct htc_frame_hdr));
29 hdr->endpoint_id = epid;
30 hdr->flags = flags;
31 hdr->payload_len = cpu_to_be16(len);
32
33 status = target->hif->send(target->hif_dev, endpoint->ul_pipeid, skb,
34 tx_ctl);
35 return status;
36}
37
38static struct htc_endpoint *get_next_avail_ep(struct htc_endpoint *endpoint)
39{
40 enum htc_endpoint_id avail_epid;
41
42 for (avail_epid = ENDPOINT_MAX; avail_epid > ENDPOINT0; avail_epid--)
43 if (endpoint[avail_epid].service_id == 0)
44 return &endpoint[avail_epid];
45 return NULL;
46}
47
48static u8 service_to_ulpipe(u16 service_id)
49{
50 switch (service_id) {
51 case WMI_CONTROL_SVC:
52 return 4;
53 case WMI_BEACON_SVC:
54 case WMI_CAB_SVC:
55 case WMI_UAPSD_SVC:
56 case WMI_MGMT_SVC:
57 case WMI_DATA_VO_SVC:
58 case WMI_DATA_VI_SVC:
59 case WMI_DATA_BE_SVC:
60 case WMI_DATA_BK_SVC:
61 return 1;
62 default:
63 return 0;
64 }
65}
66
67static u8 service_to_dlpipe(u16 service_id)
68{
69 switch (service_id) {
70 case WMI_CONTROL_SVC:
71 return 3;
72 case WMI_BEACON_SVC:
73 case WMI_CAB_SVC:
74 case WMI_UAPSD_SVC:
75 case WMI_MGMT_SVC:
76 case WMI_DATA_VO_SVC:
77 case WMI_DATA_VI_SVC:
78 case WMI_DATA_BE_SVC:
79 case WMI_DATA_BK_SVC:
80 return 2;
81 default:
82 return 0;
83 }
84}
85
86static void htc_process_target_rdy(struct htc_target *target,
87 void *buf)
88{
89 struct htc_endpoint *endpoint;
90 struct htc_ready_msg *htc_ready_msg = (struct htc_ready_msg *) buf;
91
92 target->credits = be16_to_cpu(htc_ready_msg->credits);
93 target->credit_size = be16_to_cpu(htc_ready_msg->credit_size);
94
95 endpoint = &target->endpoint[ENDPOINT0];
96 endpoint->service_id = HTC_CTRL_RSVD_SVC;
97 endpoint->max_msglen = HTC_MAX_CONTROL_MESSAGE_LENGTH;
98 complete(&target->target_wait);
99}
100
101static void htc_process_conn_rsp(struct htc_target *target,
102 struct htc_frame_hdr *htc_hdr)
103{
104 struct htc_conn_svc_rspmsg *svc_rspmsg;
105 struct htc_endpoint *endpoint, *tmp_endpoint = NULL;
106 u16 service_id;
107 u16 max_msglen;
108 enum htc_endpoint_id epid, tepid;
109
110 svc_rspmsg = (struct htc_conn_svc_rspmsg *)
111 ((void *) htc_hdr + sizeof(struct htc_frame_hdr));
112
113 if (svc_rspmsg->status == HTC_SERVICE_SUCCESS) {
114 epid = svc_rspmsg->endpoint_id;
115 service_id = be16_to_cpu(svc_rspmsg->service_id);
116 max_msglen = be16_to_cpu(svc_rspmsg->max_msg_len);
117 endpoint = &target->endpoint[epid];
118
119 for (tepid = ENDPOINT_MAX; tepid > ENDPOINT0; tepid--) {
120 tmp_endpoint = &target->endpoint[tepid];
121 if (tmp_endpoint->service_id == service_id) {
122 tmp_endpoint->service_id = 0;
123 break;
124 }
125 }
126
127 if (!tmp_endpoint)
128 return;
129
130 endpoint->service_id = service_id;
131 endpoint->max_txqdepth = tmp_endpoint->max_txqdepth;
132 endpoint->ep_callbacks = tmp_endpoint->ep_callbacks;
133 endpoint->ul_pipeid = tmp_endpoint->ul_pipeid;
134 endpoint->dl_pipeid = tmp_endpoint->dl_pipeid;
135 endpoint->max_msglen = max_msglen;
136 target->conn_rsp_epid = epid;
137 complete(&target->cmd_wait);
138 } else {
139 target->conn_rsp_epid = ENDPOINT_UNUSED;
140 }
141}
142
143static int htc_config_pipe_credits(struct htc_target *target)
144{
145 struct sk_buff *skb;
146 struct htc_config_pipe_msg *cp_msg;
147 int ret, time_left;
148
149 skb = dev_alloc_skb(50 + sizeof(struct htc_frame_hdr));
150 if (!skb) {
151 dev_err(target->dev, "failed to allocate send buffer\n");
152 return -ENOMEM;
153 }
154 skb_reserve(skb, sizeof(struct htc_frame_hdr));
155
156 cp_msg = (struct htc_config_pipe_msg *)
157 skb_put(skb, sizeof(struct htc_config_pipe_msg));
158
159 cp_msg->message_id = cpu_to_be16(HTC_MSG_CONFIG_PIPE_ID);
160 cp_msg->pipe_id = USB_WLAN_TX_PIPE;
161 cp_msg->credits = 28;
162
163 target->htc_flags |= HTC_OP_CONFIG_PIPE_CREDITS;
164
165 ret = htc_issue_send(target, skb, skb->len, 0, ENDPOINT0, NULL);
166 if (ret)
167 goto err;
168
169 time_left = wait_for_completion_timeout(&target->cmd_wait, HZ);
170 if (!time_left) {
171 dev_err(target->dev, "HTC credit config timeout\n");
172 return -ETIMEDOUT;
173 }
174
175 return 0;
176err:
177 dev_kfree_skb(skb);
178 return -EINVAL;
179}
180
181static int htc_setup_complete(struct htc_target *target)
182{
183 struct sk_buff *skb;
184 struct htc_comp_msg *comp_msg;
185 int ret = 0, time_left;
186
187 skb = dev_alloc_skb(50 + sizeof(struct htc_frame_hdr));
188 if (!skb) {
189 dev_err(target->dev, "failed to allocate send buffer\n");
190 return -ENOMEM;
191 }
192 skb_reserve(skb, sizeof(struct htc_frame_hdr));
193
194 comp_msg = (struct htc_comp_msg *)
195 skb_put(skb, sizeof(struct htc_comp_msg));
196 comp_msg->msg_id = cpu_to_be16(HTC_MSG_SETUP_COMPLETE_ID);
197
198 target->htc_flags |= HTC_OP_START_WAIT;
199
200 ret = htc_issue_send(target, skb, skb->len, 0, ENDPOINT0, NULL);
201 if (ret)
202 goto err;
203
204 time_left = wait_for_completion_timeout(&target->cmd_wait, HZ);
205 if (!time_left) {
206 dev_err(target->dev, "HTC start timeout\n");
207 return -ETIMEDOUT;
208 }
209
210 return 0;
211
212err:
213 dev_kfree_skb(skb);
214 return -EINVAL;
215}
216
217/* HTC APIs */
218
219int htc_init(struct htc_target *target)
220{
221 int ret;
222
223 ret = htc_config_pipe_credits(target);
224 if (ret)
225 return ret;
226
227 return htc_setup_complete(target);
228}
229
230int htc_connect_service(struct htc_target *target,
231 struct htc_service_connreq *service_connreq,
232 enum htc_endpoint_id *conn_rsp_epid)
233{
234 struct sk_buff *skb;
235 struct htc_endpoint *endpoint;
236 struct htc_conn_svc_msg *conn_msg;
237 int ret, time_left;
238
239 /* Find an available endpoint */
240 endpoint = get_next_avail_ep(target->endpoint);
241 if (!endpoint) {
242 dev_err(target->dev, "Endpoint is not available for"
243 "service %d\n", service_connreq->service_id);
244 return -EINVAL;
245 }
246
247 endpoint->service_id = service_connreq->service_id;
248 endpoint->max_txqdepth = service_connreq->max_send_qdepth;
249 endpoint->ul_pipeid = service_to_ulpipe(service_connreq->service_id);
250 endpoint->dl_pipeid = service_to_dlpipe(service_connreq->service_id);
251 endpoint->ep_callbacks = service_connreq->ep_callbacks;
252
253 skb = dev_alloc_skb(sizeof(struct htc_conn_svc_msg) +
254 sizeof(struct htc_frame_hdr));
255 if (!skb) {
256 dev_err(target->dev, "Failed to allocate buf to send"
257 "service connect req\n");
258 return -ENOMEM;
259 }
260
261 skb_reserve(skb, sizeof(struct htc_frame_hdr));
262
263 conn_msg = (struct htc_conn_svc_msg *)
264 skb_put(skb, sizeof(struct htc_conn_svc_msg));
265 conn_msg->service_id = cpu_to_be16(service_connreq->service_id);
266 conn_msg->msg_id = cpu_to_be16(HTC_MSG_CONNECT_SERVICE_ID);
267 conn_msg->con_flags = cpu_to_be16(service_connreq->con_flags);
268 conn_msg->dl_pipeid = endpoint->dl_pipeid;
269 conn_msg->ul_pipeid = endpoint->ul_pipeid;
270
271 ret = htc_issue_send(target, skb, skb->len, 0, ENDPOINT0, NULL);
272 if (ret)
273 goto err;
274
275 time_left = wait_for_completion_timeout(&target->cmd_wait, HZ);
276 if (!time_left) {
277 dev_err(target->dev, "Service connection timeout for: %d\n",
278 service_connreq->service_id);
279 return -ETIMEDOUT;
280 }
281
282 *conn_rsp_epid = target->conn_rsp_epid;
283 return 0;
284err:
285 dev_kfree_skb(skb);
286 return ret;
287}
288
289int htc_send(struct htc_target *target, struct sk_buff *skb,
290 enum htc_endpoint_id epid, struct ath9k_htc_tx_ctl *tx_ctl)
291{
292 return htc_issue_send(target, skb, skb->len, 0, epid, tx_ctl);
293}
294
295void htc_stop(struct htc_target *target)
296{
297 enum htc_endpoint_id epid;
298 struct htc_endpoint *endpoint;
299
300 for (epid = ENDPOINT0; epid <= ENDPOINT_MAX; epid++) {
301 endpoint = &target->endpoint[epid];
302 if (endpoint->service_id != 0)
303 target->hif->stop(target->hif_dev, endpoint->ul_pipeid);
304 }
305}
306
307void htc_start(struct htc_target *target)
308{
309 enum htc_endpoint_id epid;
310 struct htc_endpoint *endpoint;
311
312 for (epid = ENDPOINT0; epid <= ENDPOINT_MAX; epid++) {
313 endpoint = &target->endpoint[epid];
314 if (endpoint->service_id != 0)
315 target->hif->start(target->hif_dev,
316 endpoint->ul_pipeid);
317 }
318}
319
320void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
321 struct sk_buff *skb, bool txok)
322{
323 struct htc_endpoint *endpoint;
324 struct htc_frame_hdr *htc_hdr;
325
326 if (htc_handle->htc_flags & HTC_OP_CONFIG_PIPE_CREDITS) {
327 complete(&htc_handle->cmd_wait);
328 htc_handle->htc_flags &= ~HTC_OP_CONFIG_PIPE_CREDITS;
329 }
330
331 if (htc_handle->htc_flags & HTC_OP_START_WAIT) {
332 complete(&htc_handle->cmd_wait);
333 htc_handle->htc_flags &= ~HTC_OP_START_WAIT;
334 }
335
336 if (skb) {
337 htc_hdr = (struct htc_frame_hdr *) skb->data;
338 endpoint = &htc_handle->endpoint[htc_hdr->endpoint_id];
339 skb_pull(skb, sizeof(struct htc_frame_hdr));
340
341 if (endpoint->ep_callbacks.tx) {
342 endpoint->ep_callbacks.tx(htc_handle->drv_priv, skb,
343 htc_hdr->endpoint_id, txok);
344 }
345 }
346}
347
348/*
349 * HTC Messages are handled directly here and the obtained SKB
350 * is freed.
351 *
352 * Sevice messages (Data, WMI) passed to the corresponding
353 * endpoint RX handlers, which have to free the SKB.
354 */
355void ath9k_htc_rx_msg(struct htc_target *htc_handle,
356 struct sk_buff *skb, u32 len, u8 pipe_id)
357{
358 struct htc_frame_hdr *htc_hdr;
359 enum htc_endpoint_id epid;
360 struct htc_endpoint *endpoint;
361 u16 *msg_id;
362
363 if (!htc_handle || !skb)
364 return;
365
366 htc_hdr = (struct htc_frame_hdr *) skb->data;
367 epid = htc_hdr->endpoint_id;
368
369 if (epid >= ENDPOINT_MAX) {
370 dev_kfree_skb_any(skb);
371 return;
372 }
373
374 if (epid == ENDPOINT0) {
375
376 /* Handle trailer */
377 if (htc_hdr->flags & HTC_FLAGS_RECV_TRAILER) {
378 if (be32_to_cpu(*(u32 *) skb->data) == 0x00C60000)
379 /* Move past the Watchdog pattern */
380 htc_hdr = (struct htc_frame_hdr *) skb->data + 4;
381 }
382
383 /* Get the message ID */
384 msg_id = (u16 *) ((void *) htc_hdr +
385 sizeof(struct htc_frame_hdr));
386
387 /* Now process HTC messages */
388 switch (be16_to_cpu(*msg_id)) {
389 case HTC_MSG_READY_ID:
390 htc_process_target_rdy(htc_handle, htc_hdr);
391 break;
392 case HTC_MSG_CONNECT_SERVICE_RESPONSE_ID:
393 htc_process_conn_rsp(htc_handle, htc_hdr);
394 break;
395 default:
396 break;
397 }
398
399 dev_kfree_skb_any(skb);
400
401 } else {
402 if (htc_hdr->flags & HTC_FLAGS_RECV_TRAILER)
403 skb_trim(skb, len - htc_hdr->control[0]);
404
405 skb_pull(skb, sizeof(struct htc_frame_hdr));
406
407 endpoint = &htc_handle->endpoint[epid];
408 if (endpoint->ep_callbacks.rx)
409 endpoint->ep_callbacks.rx(endpoint->ep_callbacks.priv,
410 skb, epid);
411 }
412}
413
414struct htc_target *ath9k_htc_hw_alloc(void *hif_handle)
415{
416 struct htc_target *target;
417
418 target = kzalloc(sizeof(struct htc_target), GFP_KERNEL);
419 if (!target)
420 printk(KERN_ERR "Unable to allocate memory for"
421 "target device\n");
422
423 return target;
424}
425
426void ath9k_htc_hw_free(struct htc_target *htc)
427{
428 kfree(htc);
429}
430
431int ath9k_htc_hw_init(struct ath9k_htc_hif *hif, struct htc_target *target,
432 void *hif_handle, struct device *dev, u16 devid,
433 enum ath9k_hif_transports transport)
434{
435 struct htc_endpoint *endpoint;
436 int err = 0;
437
438 init_completion(&target->target_wait);
439 init_completion(&target->cmd_wait);
440
441 target->hif = hif;
442 target->hif_dev = hif_handle;
443 target->dev = dev;
444
445 /* Assign control endpoint pipe IDs */
446 endpoint = &target->endpoint[ENDPOINT0];
447 endpoint->ul_pipeid = hif->control_ul_pipe;
448 endpoint->dl_pipeid = hif->control_dl_pipe;
449
450 err = ath9k_htc_probe_device(target, dev, devid);
451 if (err) {
452 printk(KERN_ERR "Failed to initialize the device\n");
453 return -ENODEV;
454 }
455
456 return 0;
457}
458
459void ath9k_htc_hw_deinit(struct htc_target *target, bool hot_unplug)
460{
461 if (target)
462 ath9k_htc_disconnect_device(target, hot_unplug);
463}
diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.h b/drivers/net/wireless/ath/ath9k/htc_hst.h
new file mode 100644
index 000000000000..cd7048ffd239
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/htc_hst.h
@@ -0,0 +1,246 @@
1/*
2 * Copyright (c) 2010 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#ifndef HTC_HST_H
18#define HTC_HST_H
19
20struct ath9k_htc_priv;
21struct htc_target;
22struct ath9k_htc_tx_ctl;
23
24enum ath9k_hif_transports {
25 ATH9K_HIF_USB,
26};
27
28struct ath9k_htc_hif {
29 struct list_head list;
30 const enum ath9k_hif_transports transport;
31 const char *name;
32
33 u8 control_dl_pipe;
34 u8 control_ul_pipe;
35
36 void (*start) (void *hif_handle, u8 pipe);
37 void (*stop) (void *hif_handle, u8 pipe);
38 int (*send) (void *hif_handle, u8 pipe, struct sk_buff *buf,
39 struct ath9k_htc_tx_ctl *tx_ctl);
40};
41
42enum htc_endpoint_id {
43 ENDPOINT_UNUSED = -1,
44 ENDPOINT0 = 0,
45 ENDPOINT1 = 1,
46 ENDPOINT2 = 2,
47 ENDPOINT3 = 3,
48 ENDPOINT4 = 4,
49 ENDPOINT5 = 5,
50 ENDPOINT6 = 6,
51 ENDPOINT7 = 7,
52 ENDPOINT8 = 8,
53 ENDPOINT_MAX = 22
54};
55
56/* Htc frame hdr flags */
57#define HTC_FLAGS_RECV_TRAILER (1 << 1)
58
59struct htc_frame_hdr {
60 u8 endpoint_id;
61 u8 flags;
62 u16 payload_len;
63 u8 control[4];
64} __packed;
65
66struct htc_ready_msg {
67 u16 message_id;
68 u16 credits;
69 u16 credit_size;
70 u8 max_endpoints;
71 u8 pad;
72} __packed;
73
74struct htc_config_pipe_msg {
75 u16 message_id;
76 u8 pipe_id;
77 u8 credits;
78} __packed;
79
80struct htc_packet {
81 void *pktcontext;
82 u8 *buf;
83 u8 *buf_payload;
84 u32 buflen;
85 u32 payload_len;
86
87 int endpoint;
88 int status;
89
90 void *context;
91 u32 reserved;
92};
93
94struct htc_ep_callbacks {
95 void *priv;
96 void (*tx) (void *, struct sk_buff *, enum htc_endpoint_id, bool txok);
97 void (*rx) (void *, struct sk_buff *, enum htc_endpoint_id);
98};
99
100#define HTC_TX_QUEUE_SIZE 256
101
102struct htc_txq {
103 struct sk_buff *buf[HTC_TX_QUEUE_SIZE];
104 u32 txqdepth;
105 u16 txbuf_cnt;
106 u16 txq_head;
107 u16 txq_tail;
108};
109
110struct htc_endpoint {
111 u16 service_id;
112
113 struct htc_ep_callbacks ep_callbacks;
114 struct htc_txq htc_txq;
115 u32 max_txqdepth;
116 int max_msglen;
117
118 u8 ul_pipeid;
119 u8 dl_pipeid;
120};
121
122#define HTC_MAX_CONTROL_MESSAGE_LENGTH 255
123#define HTC_CONTROL_BUFFER_SIZE \
124 (HTC_MAX_CONTROL_MESSAGE_LENGTH + sizeof(struct htc_frame_hdr))
125
126#define NUM_CONTROL_BUFFERS 8
127#define HST_ENDPOINT_MAX 8
128
129struct htc_control_buf {
130 struct htc_packet htc_pkt;
131 u8 buf[HTC_CONTROL_BUFFER_SIZE];
132};
133
134#define HTC_OP_START_WAIT BIT(0)
135#define HTC_OP_CONFIG_PIPE_CREDITS BIT(1)
136
137struct htc_target {
138 void *hif_dev;
139 struct ath9k_htc_priv *drv_priv;
140 struct device *dev;
141 struct ath9k_htc_hif *hif;
142 struct htc_endpoint endpoint[HST_ENDPOINT_MAX];
143 struct completion target_wait;
144 struct completion cmd_wait;
145 struct list_head list;
146 enum htc_endpoint_id conn_rsp_epid;
147 u16 credits;
148 u16 credit_size;
149 u8 htc_flags;
150};
151
152enum htc_msg_id {
153 HTC_MSG_READY_ID = 1,
154 HTC_MSG_CONNECT_SERVICE_ID,
155 HTC_MSG_CONNECT_SERVICE_RESPONSE_ID,
156 HTC_MSG_SETUP_COMPLETE_ID,
157 HTC_MSG_CONFIG_PIPE_ID,
158 HTC_MSG_CONFIG_PIPE_RESPONSE_ID,
159};
160
161struct htc_service_connreq {
162 u16 service_id;
163 u16 con_flags;
164 u32 max_send_qdepth;
165 struct htc_ep_callbacks ep_callbacks;
166};
167
168/* Current service IDs */
169
170enum htc_service_group_ids{
171 RSVD_SERVICE_GROUP = 0,
172 WMI_SERVICE_GROUP = 1,
173
174 HTC_SERVICE_GROUP_LAST = 255
175};
176
177#define MAKE_SERVICE_ID(group, index) \
178 (int)(((int)group << 8) | (int)(index))
179
180/* NOTE: service ID of 0x0000 is reserved and should never be used */
181#define HTC_CTRL_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 1)
182#define HTC_LOOPBACK_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 2)
183
184#define WMI_CONTROL_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 0)
185#define WMI_BEACON_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 1)
186#define WMI_CAB_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 2)
187#define WMI_UAPSD_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 3)
188#define WMI_MGMT_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 4)
189#define WMI_DATA_VO_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 5)
190#define WMI_DATA_VI_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 6)
191#define WMI_DATA_BE_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 7)
192#define WMI_DATA_BK_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 8)
193
194struct htc_conn_svc_msg {
195 u16 msg_id;
196 u16 service_id;
197 u16 con_flags;
198 u8 dl_pipeid;
199 u8 ul_pipeid;
200 u8 svc_meta_len;
201 u8 pad;
202} __packed;
203
204/* connect response status codes */
205#define HTC_SERVICE_SUCCESS 0
206#define HTC_SERVICE_NOT_FOUND 1
207#define HTC_SERVICE_FAILED 2
208#define HTC_SERVICE_NO_RESOURCES 3
209#define HTC_SERVICE_NO_MORE_EP 4
210
211struct htc_conn_svc_rspmsg {
212 u16 msg_id;
213 u16 service_id;
214 u8 status;
215 u8 endpoint_id;
216 u16 max_msg_len;
217 u8 svc_meta_len;
218 u8 pad;
219} __packed;
220
221struct htc_comp_msg {
222 u16 msg_id;
223} __packed;
224
225int htc_init(struct htc_target *target);
226int htc_connect_service(struct htc_target *target,
227 struct htc_service_connreq *service_connreq,
228 enum htc_endpoint_id *conn_rsp_eid);
229int htc_send(struct htc_target *target, struct sk_buff *skb,
230 enum htc_endpoint_id eid, struct ath9k_htc_tx_ctl *tx_ctl);
231void htc_stop(struct htc_target *target);
232void htc_start(struct htc_target *target);
233
234void ath9k_htc_rx_msg(struct htc_target *htc_handle,
235 struct sk_buff *skb, u32 len, u8 pipe_id);
236void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
237 struct sk_buff *skb, bool txok);
238
239struct htc_target *ath9k_htc_hw_alloc(void *hif_handle);
240void ath9k_htc_hw_free(struct htc_target *htc);
241int ath9k_htc_hw_init(struct ath9k_htc_hif *hif, struct htc_target *target,
242 void *hif_handle, struct device *dev, u16 devid,
243 enum ath9k_hif_transports transport);
244void ath9k_htc_hw_deinit(struct htc_target *target, bool hot_unplug);
245
246#endif /* HTC_HST_H */
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 2e767cf22f1e..77db932c3137 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -499,8 +499,10 @@ static int ath9k_hw_post_init(struct ath_hw *ah)
499{ 499{
500 int ecode; 500 int ecode;
501 501
502 if (!ath9k_hw_chip_test(ah)) 502 if (!AR_SREV_9271(ah)) {
503 return -ENODEV; 503 if (!ath9k_hw_chip_test(ah))
504 return -ENODEV;
505 }
504 506
505 ecode = ath9k_hw_rf_claim(ah); 507 ecode = ath9k_hw_rf_claim(ah);
506 if (ecode != 0) 508 if (ecode != 0)
@@ -603,9 +605,23 @@ static void ath9k_hw_init_mode_regs(struct ath_hw *ah)
603 ARRAY_SIZE(ar9271Modes_9271), 6); 605 ARRAY_SIZE(ar9271Modes_9271), 6);
604 INIT_INI_ARRAY(&ah->iniCommon, ar9271Common_9271, 606 INIT_INI_ARRAY(&ah->iniCommon, ar9271Common_9271,
605 ARRAY_SIZE(ar9271Common_9271), 2); 607 ARRAY_SIZE(ar9271Common_9271), 2);
608 INIT_INI_ARRAY(&ah->iniCommon_normal_cck_fir_coeff_9271,
609 ar9271Common_normal_cck_fir_coeff_9271,
610 ARRAY_SIZE(ar9271Common_normal_cck_fir_coeff_9271), 2);
611 INIT_INI_ARRAY(&ah->iniCommon_japan_2484_cck_fir_coeff_9271,
612 ar9271Common_japan_2484_cck_fir_coeff_9271,
613 ARRAY_SIZE(ar9271Common_japan_2484_cck_fir_coeff_9271), 2);
606 INIT_INI_ARRAY(&ah->iniModes_9271_1_0_only, 614 INIT_INI_ARRAY(&ah->iniModes_9271_1_0_only,
607 ar9271Modes_9271_1_0_only, 615 ar9271Modes_9271_1_0_only,
608 ARRAY_SIZE(ar9271Modes_9271_1_0_only), 6); 616 ARRAY_SIZE(ar9271Modes_9271_1_0_only), 6);
617 INIT_INI_ARRAY(&ah->iniModes_9271_ANI_reg, ar9271Modes_9271_ANI_reg,
618 ARRAY_SIZE(ar9271Modes_9271_ANI_reg), 6);
619 INIT_INI_ARRAY(&ah->iniModes_high_power_tx_gain_9271,
620 ar9271Modes_high_power_tx_gain_9271,
621 ARRAY_SIZE(ar9271Modes_high_power_tx_gain_9271), 6);
622 INIT_INI_ARRAY(&ah->iniModes_normal_power_tx_gain_9271,
623 ar9271Modes_normal_power_tx_gain_9271,
624 ARRAY_SIZE(ar9271Modes_normal_power_tx_gain_9271), 6);
609 return; 625 return;
610 } 626 }
611 627
@@ -990,22 +1006,6 @@ static void ath9k_hw_init_qos(struct ath_hw *ah)
990 REG_WRITE(ah, AR_TXOP_12_15, 0xFFFFFFFF); 1006 REG_WRITE(ah, AR_TXOP_12_15, 0xFFFFFFFF);
991} 1007}
992 1008
993static void ath9k_hw_change_target_baud(struct ath_hw *ah, u32 freq, u32 baud)
994{
995 u32 lcr;
996 u32 baud_divider = freq * 1000 * 1000 / 16 / baud;
997
998 lcr = REG_READ(ah , 0x5100c);
999 lcr |= 0x80;
1000
1001 REG_WRITE(ah, 0x5100c, lcr);
1002 REG_WRITE(ah, 0x51004, (baud_divider >> 8));
1003 REG_WRITE(ah, 0x51000, (baud_divider & 0xff));
1004
1005 lcr &= ~0x80;
1006 REG_WRITE(ah, 0x5100c, lcr);
1007}
1008
1009static void ath9k_hw_init_pll(struct ath_hw *ah, 1009static void ath9k_hw_init_pll(struct ath_hw *ah,
1010 struct ath9k_channel *chan) 1010 struct ath9k_channel *chan)
1011{ 1011{
@@ -1071,22 +1071,8 @@ static void ath9k_hw_init_pll(struct ath_hw *ah,
1071 1071
1072 /* Switch the core clock for ar9271 to 117Mhz */ 1072 /* Switch the core clock for ar9271 to 117Mhz */
1073 if (AR_SREV_9271(ah)) { 1073 if (AR_SREV_9271(ah)) {
1074 if ((pll == 0x142c) || (pll == 0x2850) ) { 1074 udelay(500);
1075 udelay(500); 1075 REG_WRITE(ah, 0x50040, 0x304);
1076 /* set CLKOBS to output AHB clock */
1077 REG_WRITE(ah, 0x7020, 0xe);
1078 /*
1079 * 0x304: 117Mhz, ahb_ratio: 1x1
1080 * 0x306: 40Mhz, ahb_ratio: 1x1
1081 */
1082 REG_WRITE(ah, 0x50040, 0x304);
1083 /*
1084 * makes adjustments for the baud dividor to keep the
1085 * targetted baud rate based on the used core clock.
1086 */
1087 ath9k_hw_change_target_baud(ah, AR9271_CORE_CLOCK,
1088 AR9271_TARGET_BAUD_RATE);
1089 }
1090 } 1076 }
1091 1077
1092 udelay(RTC_PLL_SETTLE_DELAY); 1078 udelay(RTC_PLL_SETTLE_DELAY);
@@ -1151,7 +1137,8 @@ static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah,
1151 ah->mask_reg |= AR_IMR_MIB; 1137 ah->mask_reg |= AR_IMR_MIB;
1152 1138
1153 REG_WRITE(ah, AR_IMR, ah->mask_reg); 1139 REG_WRITE(ah, AR_IMR, ah->mask_reg);
1154 REG_WRITE(ah, AR_IMR_S2, REG_READ(ah, AR_IMR_S2) | AR_IMR_S2_GTT); 1140 ah->imrs2_reg |= AR_IMR_S2_GTT;
1141 REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg);
1155 1142
1156 if (!AR_SREV_9100(ah)) { 1143 if (!AR_SREV_9100(ah)) {
1157 REG_WRITE(ah, AR_INTR_SYNC_CAUSE, 0xFFFFFFFF); 1144 REG_WRITE(ah, AR_INTR_SYNC_CAUSE, 0xFFFFFFFF);
@@ -1240,7 +1227,7 @@ void ath9k_hw_deinit(struct ath_hw *ah)
1240{ 1227{
1241 struct ath_common *common = ath9k_hw_common(ah); 1228 struct ath_common *common = ath9k_hw_common(ah);
1242 1229
1243 if (common->state <= ATH_HW_INITIALIZED) 1230 if (common->state < ATH_HW_INITIALIZED)
1244 goto free_hw; 1231 goto free_hw;
1245 1232
1246 if (!AR_SREV_9100(ah)) 1233 if (!AR_SREV_9100(ah))
@@ -1251,8 +1238,6 @@ void ath9k_hw_deinit(struct ath_hw *ah)
1251free_hw: 1238free_hw:
1252 if (!AR_SREV_9280_10_OR_LATER(ah)) 1239 if (!AR_SREV_9280_10_OR_LATER(ah))
1253 ath9k_hw_rf_free_ext_banks(ah); 1240 ath9k_hw_rf_free_ext_banks(ah);
1254 kfree(ah);
1255 ah = NULL;
1256} 1241}
1257EXPORT_SYMBOL(ath9k_hw_deinit); 1242EXPORT_SYMBOL(ath9k_hw_deinit);
1258 1243
@@ -1265,26 +1250,6 @@ static void ath9k_hw_override_ini(struct ath_hw *ah,
1265{ 1250{
1266 u32 val; 1251 u32 val;
1267 1252
1268 if (AR_SREV_9271(ah)) {
1269 /*
1270 * Enable spectral scan to solution for issues with stuck
1271 * beacons on AR9271 1.0. The beacon stuck issue is not seeon on
1272 * AR9271 1.1
1273 */
1274 if (AR_SREV_9271_10(ah)) {
1275 val = REG_READ(ah, AR_PHY_SPECTRAL_SCAN) |
1276 AR_PHY_SPECTRAL_SCAN_ENABLE;
1277 REG_WRITE(ah, AR_PHY_SPECTRAL_SCAN, val);
1278 }
1279 else if (AR_SREV_9271_11(ah))
1280 /*
1281 * change AR_PHY_RF_CTL3 setting to fix MAC issue
1282 * present on AR9271 1.1
1283 */
1284 REG_WRITE(ah, AR_PHY_RF_CTL3, 0x3a020001);
1285 return;
1286 }
1287
1288 /* 1253 /*
1289 * Set the RX_ABORT and RX_DIS and clear if off only after 1254 * Set the RX_ABORT and RX_DIS and clear if off only after
1290 * RXE is set for MAC. This prevents frames with corrupted 1255 * RXE is set for MAC. This prevents frames with corrupted
@@ -1293,8 +1258,10 @@ static void ath9k_hw_override_ini(struct ath_hw *ah,
1293 REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); 1258 REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
1294 1259
1295 if (AR_SREV_9280_10_OR_LATER(ah)) { 1260 if (AR_SREV_9280_10_OR_LATER(ah)) {
1296 val = REG_READ(ah, AR_PCU_MISC_MODE2) & 1261 val = REG_READ(ah, AR_PCU_MISC_MODE2);
1297 (~AR_PCU_MISC_MODE2_HWWAR1); 1262
1263 if (!AR_SREV_9271(ah))
1264 val &= ~AR_PCU_MISC_MODE2_HWWAR1;
1298 1265
1299 if (AR_SREV_9287_10_OR_LATER(ah)) 1266 if (AR_SREV_9287_10_OR_LATER(ah))
1300 val = val & (~AR_PCU_MISC_MODE2_HWWAR2); 1267 val = val & (~AR_PCU_MISC_MODE2_HWWAR2);
@@ -1438,7 +1405,10 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1438 return -EINVAL; 1405 return -EINVAL;
1439 } 1406 }
1440 1407
1408 /* Set correct baseband to analog shift setting to access analog chips */
1441 REG_WRITE(ah, AR_PHY(0), 0x00000007); 1409 REG_WRITE(ah, AR_PHY(0), 0x00000007);
1410
1411 /* Write ADDAC shifts */
1442 REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_EXTERNAL_RADIO); 1412 REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_EXTERNAL_RADIO);
1443 ah->eep_ops->set_addac(ah, chan); 1413 ah->eep_ops->set_addac(ah, chan);
1444 1414
@@ -1450,9 +1420,11 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1450 sizeof(u32) * ah->iniAddac.ia_rows * 1420 sizeof(u32) * ah->iniAddac.ia_rows *
1451 ah->iniAddac.ia_columns; 1421 ah->iniAddac.ia_columns;
1452 1422
1423 /* For AR5416 2.0/2.1 */
1453 memcpy(ah->addac5416_21, 1424 memcpy(ah->addac5416_21,
1454 ah->iniAddac.ia_array, addacSize); 1425 ah->iniAddac.ia_array, addacSize);
1455 1426
1427 /* override CLKDRV value at [row, column] = [31, 1] */
1456 (ah->addac5416_21)[31 * ah->iniAddac.ia_columns + 1] = 0; 1428 (ah->addac5416_21)[31 * ah->iniAddac.ia_columns + 1] = 0;
1457 1429
1458 temp.ia_array = ah->addac5416_21; 1430 temp.ia_array = ah->addac5416_21;
@@ -1484,6 +1456,11 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1484 AR_SREV_9287_10_OR_LATER(ah)) 1456 AR_SREV_9287_10_OR_LATER(ah))
1485 REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites); 1457 REG_WRITE_ARRAY(&ah->iniModesTxGain, modesIndex, regWrites);
1486 1458
1459 if (AR_SREV_9271_10(ah))
1460 REG_WRITE_ARRAY(&ah->iniModes_9271_1_0_only,
1461 modesIndex, regWrites);
1462
1463 /* Write common array parameters */
1487 for (i = 0; i < ah->iniCommon.ia_rows; i++) { 1464 for (i = 0; i < ah->iniCommon.ia_rows; i++) {
1488 u32 reg = INI_RA(&ah->iniCommon, i, 0); 1465 u32 reg = INI_RA(&ah->iniCommon, i, 0);
1489 u32 val = INI_RA(&ah->iniCommon, i, 1); 1466 u32 val = INI_RA(&ah->iniCommon, i, 1);
@@ -1498,11 +1475,16 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1498 DO_DELAY(regWrites); 1475 DO_DELAY(regWrites);
1499 } 1476 }
1500 1477
1501 ath9k_hw_write_regs(ah, freqIndex, regWrites); 1478 if (AR_SREV_9271(ah)) {
1479 if (ah->eep_ops->get_eeprom(ah, EEP_TXGAIN_TYPE) == 1)
1480 REG_WRITE_ARRAY(&ah->iniModes_high_power_tx_gain_9271,
1481 modesIndex, regWrites);
1482 else
1483 REG_WRITE_ARRAY(&ah->iniModes_normal_power_tx_gain_9271,
1484 modesIndex, regWrites);
1485 }
1502 1486
1503 if (AR_SREV_9271_10(ah)) 1487 ath9k_hw_write_regs(ah, freqIndex, regWrites);
1504 REG_WRITE_ARRAY(&ah->iniModes_9271_1_0_only,
1505 modesIndex, regWrites);
1506 1488
1507 if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan)) { 1489 if (AR_SREV_9280_20(ah) && IS_CHAN_A_5MHZ_SPACED(chan)) {
1508 REG_WRITE_ARRAY(&ah->iniModesAdditional, modesIndex, 1490 REG_WRITE_ARRAY(&ah->iniModesAdditional, modesIndex,
@@ -1516,6 +1498,7 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1516 if (OLC_FOR_AR9280_20_LATER) 1498 if (OLC_FOR_AR9280_20_LATER)
1517 ath9k_olc_init(ah); 1499 ath9k_olc_init(ah);
1518 1500
1501 /* Set TX power */
1519 ah->eep_ops->set_txpower(ah, chan, 1502 ah->eep_ops->set_txpower(ah, chan,
1520 ath9k_regd_get_ctl(regulatory, chan), 1503 ath9k_regd_get_ctl(regulatory, chan),
1521 channel->max_antenna_gain * 2, 1504 channel->max_antenna_gain * 2,
@@ -1523,6 +1506,7 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1523 min((u32) MAX_RATE_POWER, 1506 min((u32) MAX_RATE_POWER,
1524 (u32) regulatory->power_limit)); 1507 (u32) regulatory->power_limit));
1525 1508
1509 /* Write analog registers */
1526 if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) { 1510 if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
1527 ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, 1511 ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
1528 "ar5416SetRfRegs failed\n"); 1512 "ar5416SetRfRegs failed\n");
@@ -1965,6 +1949,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1965 1949
1966 ath9k_hw_mark_phy_inactive(ah); 1950 ath9k_hw_mark_phy_inactive(ah);
1967 1951
1952 /* Only required on the first reset */
1968 if (AR_SREV_9271(ah) && ah->htc_reset_init) { 1953 if (AR_SREV_9271(ah) && ah->htc_reset_init) {
1969 REG_WRITE(ah, 1954 REG_WRITE(ah,
1970 AR9271_RESET_POWER_DOWN_CONTROL, 1955 AR9271_RESET_POWER_DOWN_CONTROL,
@@ -1977,6 +1962,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1977 return -EINVAL; 1962 return -EINVAL;
1978 } 1963 }
1979 1964
1965 /* Only required on the first reset */
1980 if (AR_SREV_9271(ah) && ah->htc_reset_init) { 1966 if (AR_SREV_9271(ah) && ah->htc_reset_init) {
1981 ah->htc_reset_init = false; 1967 ah->htc_reset_init = false;
1982 REG_WRITE(ah, 1968 REG_WRITE(ah,
@@ -2437,7 +2423,7 @@ static void ath9k_set_power_sleep(struct ath_hw *ah, int setChip)
2437 if (!AR_SREV_9100(ah)) 2423 if (!AR_SREV_9100(ah))
2438 REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF); 2424 REG_WRITE(ah, AR_RC, AR_RC_AHB | AR_RC_HOSTIF);
2439 2425
2440 if(!AR_SREV_5416(ah)) 2426 if (!AR_SREV_5416(ah) && !AR_SREV_9271(ah))
2441 REG_CLR_BIT(ah, (AR_RTC_RESET), 2427 REG_CLR_BIT(ah, (AR_RTC_RESET),
2442 AR_RTC_RESET_EN); 2428 AR_RTC_RESET_EN);
2443 } 2429 }
@@ -2920,14 +2906,11 @@ enum ath9k_int ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints)
2920 2906
2921 ath_print(common, ATH_DBG_INTERRUPT, "new IMR 0x%x\n", mask); 2907 ath_print(common, ATH_DBG_INTERRUPT, "new IMR 0x%x\n", mask);
2922 REG_WRITE(ah, AR_IMR, mask); 2908 REG_WRITE(ah, AR_IMR, mask);
2923 mask = REG_READ(ah, AR_IMR_S2) & ~(AR_IMR_S2_TIM | 2909 ah->imrs2_reg &= ~(AR_IMR_S2_TIM | AR_IMR_S2_DTIM | AR_IMR_S2_DTIMSYNC |
2924 AR_IMR_S2_DTIM | 2910 AR_IMR_S2_CABEND | AR_IMR_S2_CABTO |
2925 AR_IMR_S2_DTIMSYNC | 2911 AR_IMR_S2_TSFOOR | AR_IMR_S2_GTT | AR_IMR_S2_CST);
2926 AR_IMR_S2_CABEND | 2912 ah->imrs2_reg |= mask2;
2927 AR_IMR_S2_CABTO | 2913 REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg);
2928 AR_IMR_S2_TSFOOR |
2929 AR_IMR_S2_GTT | AR_IMR_S2_CST);
2930 REG_WRITE(ah, AR_IMR_S2, mask | mask2);
2931 ah->mask_reg = ints; 2914 ah->mask_reg = ints;
2932 2915
2933 if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) { 2916 if (!(pCap->hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
@@ -3218,7 +3201,9 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
3218 else 3201 else
3219 pCap->tx_triglevel_max = MAX_TX_FIFO_THRESHOLD; 3202 pCap->tx_triglevel_max = MAX_TX_FIFO_THRESHOLD;
3220 3203
3221 if (AR_SREV_9285_10_OR_LATER(ah)) 3204 if (AR_SREV_9271(ah))
3205 pCap->num_gpio_pins = AR9271_NUM_GPIO;
3206 else if (AR_SREV_9285_10_OR_LATER(ah))
3222 pCap->num_gpio_pins = AR9285_NUM_GPIO; 3207 pCap->num_gpio_pins = AR9285_NUM_GPIO;
3223 else if (AR_SREV_9280_10_OR_LATER(ah)) 3208 else if (AR_SREV_9280_10_OR_LATER(ah))
3224 pCap->num_gpio_pins = AR928X_NUM_GPIO; 3209 pCap->num_gpio_pins = AR928X_NUM_GPIO;
@@ -3454,7 +3439,9 @@ u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio)
3454 if (gpio >= ah->caps.num_gpio_pins) 3439 if (gpio >= ah->caps.num_gpio_pins)
3455 return 0xffffffff; 3440 return 0xffffffff;
3456 3441
3457 if (AR_SREV_9287_10_OR_LATER(ah)) 3442 if (AR_SREV_9271(ah))
3443 return MS_REG_READ(AR9271, gpio) != 0;
3444 else if (AR_SREV_9287_10_OR_LATER(ah))
3458 return MS_REG_READ(AR9287, gpio) != 0; 3445 return MS_REG_READ(AR9287, gpio) != 0;
3459 else if (AR_SREV_9285_10_OR_LATER(ah)) 3446 else if (AR_SREV_9285_10_OR_LATER(ah))
3460 return MS_REG_READ(AR9285, gpio) != 0; 3447 return MS_REG_READ(AR9285, gpio) != 0;
@@ -3483,6 +3470,9 @@ EXPORT_SYMBOL(ath9k_hw_cfg_output);
3483 3470
3484void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val) 3471void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val)
3485{ 3472{
3473 if (AR_SREV_9271(ah))
3474 val = ~val;
3475
3486 REG_RMW(ah, AR_GPIO_IN_OUT, ((val & 1) << gpio), 3476 REG_RMW(ah, AR_GPIO_IN_OUT, ((val & 1) << gpio),
3487 AR_GPIO_BIT(gpio)); 3477 AR_GPIO_BIT(gpio));
3488} 3478}
@@ -3867,6 +3857,16 @@ void ath_gen_timer_isr(struct ath_hw *ah)
3867} 3857}
3868EXPORT_SYMBOL(ath_gen_timer_isr); 3858EXPORT_SYMBOL(ath_gen_timer_isr);
3869 3859
3860/********/
3861/* HTC */
3862/********/
3863
3864void ath9k_hw_htc_resetinit(struct ath_hw *ah)
3865{
3866 ah->htc_reset_init = true;
3867}
3868EXPORT_SYMBOL(ath9k_hw_htc_resetinit);
3869
3870static struct { 3870static struct {
3871 u32 version; 3871 u32 version;
3872 const char * name; 3872 const char * name;
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index dbbf7ca5f97d..6b03e1688b22 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -479,6 +479,7 @@ struct ath_hw {
479 479
480 int16_t curchan_rad_index; 480 int16_t curchan_rad_index;
481 u32 mask_reg; 481 u32 mask_reg;
482 u32 imrs2_reg;
482 u32 txok_interrupt_mask; 483 u32 txok_interrupt_mask;
483 u32 txerr_interrupt_mask; 484 u32 txerr_interrupt_mask;
484 u32 txdesc_interrupt_mask; 485 u32 txdesc_interrupt_mask;
@@ -598,6 +599,11 @@ struct ath_hw {
598 struct ar5416IniArray iniModes_9271_1_0_only; 599 struct ar5416IniArray iniModes_9271_1_0_only;
599 struct ar5416IniArray iniCckfirNormal; 600 struct ar5416IniArray iniCckfirNormal;
600 struct ar5416IniArray iniCckfirJapan2484; 601 struct ar5416IniArray iniCckfirJapan2484;
602 struct ar5416IniArray iniCommon_normal_cck_fir_coeff_9271;
603 struct ar5416IniArray iniCommon_japan_2484_cck_fir_coeff_9271;
604 struct ar5416IniArray iniModes_9271_ANI_reg;
605 struct ar5416IniArray iniModes_high_power_tx_gain_9271;
606 struct ar5416IniArray iniModes_normal_power_tx_gain_9271;
601 607
602 u32 intr_gen_timer_trigger; 608 u32 intr_gen_timer_trigger;
603 u32 intr_gen_timer_thresh; 609 u32 intr_gen_timer_thresh;
@@ -701,6 +707,9 @@ u32 ath9k_hw_gettsf32(struct ath_hw *ah);
701 707
702void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len); 708void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len);
703 709
710/* HTC */
711void ath9k_hw_htc_resetinit(struct ath_hw *ah);
712
704#define ATH_PCIE_CAP_LINK_CTRL 0x70 713#define ATH_PCIE_CAP_LINK_CTRL 0x70
705#define ATH_PCIE_CAP_LINK_L0S 1 714#define ATH_PCIE_CAP_LINK_L0S 1
706#define ATH_PCIE_CAP_LINK_L1 2 715#define ATH_PCIE_CAP_LINK_L1 2
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 623c2f884987..6063f5463708 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -758,6 +758,9 @@ static void ath9k_deinit_softc(struct ath_softc *sc)
758 758
759 tasklet_kill(&sc->intr_tq); 759 tasklet_kill(&sc->intr_tq);
760 tasklet_kill(&sc->bcon_tasklet); 760 tasklet_kill(&sc->bcon_tasklet);
761
762 kfree(sc->sc_ah);
763 sc->sc_ah = NULL;
761} 764}
762 765
763void ath9k_deinit_device(struct ath_softc *sc) 766void ath9k_deinit_device(struct ath_softc *sc)
diff --git a/drivers/net/wireless/ath/ath9k/initvals.h b/drivers/net/wireless/ath/ath9k/initvals.h
index 8a3bf3ab998d..177bdeb84ad7 100644
--- a/drivers/net/wireless/ath/ath9k/initvals.h
+++ b/drivers/net/wireless/ath/ath9k/initvals.h
@@ -6441,7 +6441,7 @@ static const u_int32_t ar9271Modes_9271[][6] = {
6441 { 0x00009a44, 0x00000000, 0x00000000, 0x000581a8, 0x000581a8, 0x00000000 }, 6441 { 0x00009a44, 0x00000000, 0x00000000, 0x000581a8, 0x000581a8, 0x00000000 },
6442 { 0x00009a48, 0x00000000, 0x00000000, 0x00058284, 0x00058284, 0x00000000 }, 6442 { 0x00009a48, 0x00000000, 0x00000000, 0x00058284, 0x00058284, 0x00000000 },
6443 { 0x00009a4c, 0x00000000, 0x00000000, 0x00058288, 0x00058288, 0x00000000 }, 6443 { 0x00009a4c, 0x00000000, 0x00000000, 0x00058288, 0x00058288, 0x00000000 },
6444 { 0x00009a50, 0x00000000, 0x00000000, 0x00058220, 0x00058220, 0x00000000 }, 6444 { 0x00009a50, 0x00000000, 0x00000000, 0x00058224, 0x00058224, 0x00000000 },
6445 { 0x00009a54, 0x00000000, 0x00000000, 0x00058290, 0x00058290, 0x00000000 }, 6445 { 0x00009a54, 0x00000000, 0x00000000, 0x00058290, 0x00058290, 0x00000000 },
6446 { 0x00009a58, 0x00000000, 0x00000000, 0x00058300, 0x00058300, 0x00000000 }, 6446 { 0x00009a58, 0x00000000, 0x00000000, 0x00058300, 0x00058300, 0x00000000 },
6447 { 0x00009a5c, 0x00000000, 0x00000000, 0x00058304, 0x00058304, 0x00000000 }, 6447 { 0x00009a5c, 0x00000000, 0x00000000, 0x00058304, 0x00058304, 0x00000000 },
@@ -6455,8 +6455,8 @@ static const u_int32_t ar9271Modes_9271[][6] = {
6455 { 0x00009a7c, 0x00000000, 0x00000000, 0x0006870c, 0x0006870c, 0x00000000 }, 6455 { 0x00009a7c, 0x00000000, 0x00000000, 0x0006870c, 0x0006870c, 0x00000000 },
6456 { 0x00009a80, 0x00000000, 0x00000000, 0x00068780, 0x00068780, 0x00000000 }, 6456 { 0x00009a80, 0x00000000, 0x00000000, 0x00068780, 0x00068780, 0x00000000 },
6457 { 0x00009a84, 0x00000000, 0x00000000, 0x00068784, 0x00068784, 0x00000000 }, 6457 { 0x00009a84, 0x00000000, 0x00000000, 0x00068784, 0x00068784, 0x00000000 },
6458 { 0x00009a88, 0x00000000, 0x00000000, 0x00078b04, 0x00078b04, 0x00000000 }, 6458 { 0x00009a88, 0x00000000, 0x00000000, 0x00078b00, 0x00078b00, 0x00000000 },
6459 { 0x00009a8c, 0x00000000, 0x00000000, 0x00078b08, 0x00078b08, 0x00000000 }, 6459 { 0x00009a8c, 0x00000000, 0x00000000, 0x00078b04, 0x00078b04, 0x00000000 },
6460 { 0x00009a90, 0x00000000, 0x00000000, 0x00078b08, 0x00078b08, 0x00000000 }, 6460 { 0x00009a90, 0x00000000, 0x00000000, 0x00078b08, 0x00078b08, 0x00000000 },
6461 { 0x00009a94, 0x00000000, 0x00000000, 0x00078b0c, 0x00078b0c, 0x00000000 }, 6461 { 0x00009a94, 0x00000000, 0x00000000, 0x00078b0c, 0x00078b0c, 0x00000000 },
6462 { 0x00009a98, 0x00000000, 0x00000000, 0x00078b80, 0x00078b80, 0x00000000 }, 6462 { 0x00009a98, 0x00000000, 0x00000000, 0x00078b80, 0x00078b80, 0x00000000 },
@@ -6569,7 +6569,7 @@ static const u_int32_t ar9271Modes_9271[][6] = {
6569 { 0x0000aa44, 0x00000000, 0x00000000, 0x000581a8, 0x000581a8, 0x00000000 }, 6569 { 0x0000aa44, 0x00000000, 0x00000000, 0x000581a8, 0x000581a8, 0x00000000 },
6570 { 0x0000aa48, 0x00000000, 0x00000000, 0x00058284, 0x00058284, 0x00000000 }, 6570 { 0x0000aa48, 0x00000000, 0x00000000, 0x00058284, 0x00058284, 0x00000000 },
6571 { 0x0000aa4c, 0x00000000, 0x00000000, 0x00058288, 0x00058288, 0x00000000 }, 6571 { 0x0000aa4c, 0x00000000, 0x00000000, 0x00058288, 0x00058288, 0x00000000 },
6572 { 0x0000aa50, 0x00000000, 0x00000000, 0x00058220, 0x00058220, 0x00000000 }, 6572 { 0x0000aa50, 0x00000000, 0x00000000, 0x00058224, 0x00058224, 0x00000000 },
6573 { 0x0000aa54, 0x00000000, 0x00000000, 0x00058290, 0x00058290, 0x00000000 }, 6573 { 0x0000aa54, 0x00000000, 0x00000000, 0x00058290, 0x00058290, 0x00000000 },
6574 { 0x0000aa58, 0x00000000, 0x00000000, 0x00058300, 0x00058300, 0x00000000 }, 6574 { 0x0000aa58, 0x00000000, 0x00000000, 0x00058300, 0x00058300, 0x00000000 },
6575 { 0x0000aa5c, 0x00000000, 0x00000000, 0x00058304, 0x00058304, 0x00000000 }, 6575 { 0x0000aa5c, 0x00000000, 0x00000000, 0x00058304, 0x00058304, 0x00000000 },
@@ -6583,8 +6583,8 @@ static const u_int32_t ar9271Modes_9271[][6] = {
6583 { 0x0000aa7c, 0x00000000, 0x00000000, 0x0006870c, 0x0006870c, 0x00000000 }, 6583 { 0x0000aa7c, 0x00000000, 0x00000000, 0x0006870c, 0x0006870c, 0x00000000 },
6584 { 0x0000aa80, 0x00000000, 0x00000000, 0x00068780, 0x00068780, 0x00000000 }, 6584 { 0x0000aa80, 0x00000000, 0x00000000, 0x00068780, 0x00068780, 0x00000000 },
6585 { 0x0000aa84, 0x00000000, 0x00000000, 0x00068784, 0x00068784, 0x00000000 }, 6585 { 0x0000aa84, 0x00000000, 0x00000000, 0x00068784, 0x00068784, 0x00000000 },
6586 { 0x0000aa88, 0x00000000, 0x00000000, 0x00078b04, 0x00078b04, 0x00000000 }, 6586 { 0x0000aa88, 0x00000000, 0x00000000, 0x00078b00, 0x00078b00, 0x00000000 },
6587 { 0x0000aa8c, 0x00000000, 0x00000000, 0x00078b08, 0x00078b08, 0x00000000 }, 6587 { 0x0000aa8c, 0x00000000, 0x00000000, 0x00078b04, 0x00078b04, 0x00000000 },
6588 { 0x0000aa90, 0x00000000, 0x00000000, 0x00078b08, 0x00078b08, 0x00000000 }, 6588 { 0x0000aa90, 0x00000000, 0x00000000, 0x00078b08, 0x00078b08, 0x00000000 },
6589 { 0x0000aa94, 0x00000000, 0x00000000, 0x00078b0c, 0x00078b0c, 0x00000000 }, 6589 { 0x0000aa94, 0x00000000, 0x00000000, 0x00078b0c, 0x00078b0c, 0x00000000 },
6590 { 0x0000aa98, 0x00000000, 0x00000000, 0x00078b80, 0x00078b80, 0x00000000 }, 6590 { 0x0000aa98, 0x00000000, 0x00000000, 0x00078b80, 0x00078b80, 0x00000000 },
@@ -6683,25 +6683,6 @@ static const u_int32_t ar9271Modes_9271[][6] = {
6683 { 0x0000a21c, 0x1883800a, 0x1883800a, 0x1883800a, 0x1883800a, 0x1883800a }, 6683 { 0x0000a21c, 0x1883800a, 0x1883800a, 0x1883800a, 0x1883800a, 0x1883800a },
6684 { 0x0000a230, 0x00000000, 0x00000000, 0x00000210, 0x00000108, 0x00000000 }, 6684 { 0x0000a230, 0x00000000, 0x00000000, 0x00000210, 0x00000108, 0x00000000 },
6685 { 0x0000a250, 0x0004f000, 0x0004f000, 0x0004a000, 0x0004a000, 0x0004a000 }, 6685 { 0x0000a250, 0x0004f000, 0x0004f000, 0x0004a000, 0x0004a000, 0x0004a000 },
6686 { 0x0000a274, 0x0a21c652, 0x0a21c652, 0x0a218652, 0x0a218652, 0x0a22a652 },
6687 { 0x0000a300, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
6688 { 0x0000a304, 0x00000000, 0x00000000, 0x00009200, 0x00009200, 0x00000000 },
6689 { 0x0000a308, 0x00000000, 0x00000000, 0x00010208, 0x00010208, 0x00000000 },
6690 { 0x0000a30c, 0x00000000, 0x00000000, 0x00019608, 0x00019608, 0x00000000 },
6691 { 0x0000a310, 0x00000000, 0x00000000, 0x0001e610, 0x0001e610, 0x00000000 },
6692 { 0x0000a314, 0x00000000, 0x00000000, 0x0002d6d0, 0x0002d6d0, 0x00000000 },
6693 { 0x0000a318, 0x00000000, 0x00000000, 0x00039758, 0x00039758, 0x00000000 },
6694 { 0x0000a31c, 0x00000000, 0x00000000, 0x0003b759, 0x0003b759, 0x00000000 },
6695 { 0x0000a320, 0x00000000, 0x00000000, 0x0003d75a, 0x0003d75a, 0x00000000 },
6696 { 0x0000a324, 0x00000000, 0x00000000, 0x0004175c, 0x0004175c, 0x00000000 },
6697 { 0x0000a328, 0x00000000, 0x00000000, 0x0004575e, 0x0004575e, 0x00000000 },
6698 { 0x0000a32c, 0x00000000, 0x00000000, 0x0004979f, 0x0004979f, 0x00000000 },
6699 { 0x0000a330, 0x00000000, 0x00000000, 0x0004d7df, 0x0004d7df, 0x00000000 },
6700 { 0x0000a334, 0x000368de, 0x000368de, 0x000368de, 0x000368de, 0x00000000 },
6701 { 0x0000a338, 0x0003891e, 0x0003891e, 0x0003891e, 0x0003891e, 0x00000000 },
6702 { 0x0000a33c, 0x0003a95e, 0x0003a95e, 0x0003a95e, 0x0003a95e, 0x00000000 },
6703 { 0x0000a340, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
6704 { 0x0000a344, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
6705 { 0x0000a358, 0x7999aa02, 0x7999aa02, 0x7999aa0e, 0x7999aa0e, 0x7999aa0e }, 6686 { 0x0000a358, 0x7999aa02, 0x7999aa02, 0x7999aa0e, 0x7999aa0e, 0x7999aa0e },
6706}; 6687};
6707 6688
@@ -6879,7 +6860,7 @@ static const u_int32_t ar9271Common_9271[][2] = {
6879 { 0x00008258, 0x00000000 }, 6860 { 0x00008258, 0x00000000 },
6880 { 0x0000825c, 0x400000ff }, 6861 { 0x0000825c, 0x400000ff },
6881 { 0x00008260, 0x00080922 }, 6862 { 0x00008260, 0x00080922 },
6882 { 0x00008264, 0x88a00010 }, 6863 { 0x00008264, 0xa8a00010 },
6883 { 0x00008270, 0x00000000 }, 6864 { 0x00008270, 0x00000000 },
6884 { 0x00008274, 0x40000000 }, 6865 { 0x00008274, 0x40000000 },
6885 { 0x00008278, 0x003e4180 }, 6866 { 0x00008278, 0x003e4180 },
@@ -6910,13 +6891,10 @@ static const u_int32_t ar9271Common_9271[][2] = {
6910 { 0x00007810, 0x71c0d388 }, 6891 { 0x00007810, 0x71c0d388 },
6911 { 0x00007814, 0x924934a8 }, 6892 { 0x00007814, 0x924934a8 },
6912 { 0x0000781c, 0x00000000 }, 6893 { 0x0000781c, 0x00000000 },
6913 { 0x00007820, 0x00000c04 },
6914 { 0x00007824, 0x00d8abff },
6915 { 0x00007828, 0x66964300 }, 6894 { 0x00007828, 0x66964300 },
6916 { 0x0000782c, 0x8db6d961 }, 6895 { 0x0000782c, 0x8db6d961 },
6917 { 0x00007830, 0x8db6d96c }, 6896 { 0x00007830, 0x8db6d96c },
6918 { 0x00007834, 0x6140008b }, 6897 { 0x00007834, 0x6140008b },
6919 { 0x00007838, 0x00000029 },
6920 { 0x0000783c, 0x72ee0a72 }, 6898 { 0x0000783c, 0x72ee0a72 },
6921 { 0x00007840, 0xbbfffffc }, 6899 { 0x00007840, 0xbbfffffc },
6922 { 0x00007844, 0x000c0db6 }, 6900 { 0x00007844, 0x000c0db6 },
@@ -6929,7 +6907,6 @@ static const u_int32_t ar9271Common_9271[][2] = {
6929 { 0x00007860, 0x21084210 }, 6907 { 0x00007860, 0x21084210 },
6930 { 0x00007864, 0xf7d7ffde }, 6908 { 0x00007864, 0xf7d7ffde },
6931 { 0x00007868, 0xc2034080 }, 6909 { 0x00007868, 0xc2034080 },
6932 { 0x0000786c, 0x48609eb4 },
6933 { 0x00007870, 0x10142c00 }, 6910 { 0x00007870, 0x10142c00 },
6934 { 0x00009808, 0x00000000 }, 6911 { 0x00009808, 0x00000000 },
6935 { 0x0000980c, 0xafe68e30 }, 6912 { 0x0000980c, 0xafe68e30 },
@@ -6982,9 +6959,6 @@ static const u_int32_t ar9271Common_9271[][2] = {
6982 { 0x000099e8, 0x3c466478 }, 6959 { 0x000099e8, 0x3c466478 },
6983 { 0x000099ec, 0x0cc80caa }, 6960 { 0x000099ec, 0x0cc80caa },
6984 { 0x000099f0, 0x00000000 }, 6961 { 0x000099f0, 0x00000000 },
6985 { 0x0000a1f4, 0x00000000 },
6986 { 0x0000a1f8, 0x71733d01 },
6987 { 0x0000a1fc, 0xd0ad5c12 },
6988 { 0x0000a208, 0x803e68c8 }, 6962 { 0x0000a208, 0x803e68c8 },
6989 { 0x0000a210, 0x4080a333 }, 6963 { 0x0000a210, 0x4080a333 },
6990 { 0x0000a214, 0x00206c10 }, 6964 { 0x0000a214, 0x00206c10 },
@@ -7004,13 +6978,9 @@ static const u_int32_t ar9271Common_9271[][2] = {
7004 { 0x0000a260, 0xdfa90f01 }, 6978 { 0x0000a260, 0xdfa90f01 },
7005 { 0x0000a268, 0x00000000 }, 6979 { 0x0000a268, 0x00000000 },
7006 { 0x0000a26c, 0x0ebae9e6 }, 6980 { 0x0000a26c, 0x0ebae9e6 },
7007 { 0x0000a278, 0x3bdef7bd },
7008 { 0x0000a27c, 0x050e83bd },
7009 { 0x0000a388, 0x0c000000 }, 6981 { 0x0000a388, 0x0c000000 },
7010 { 0x0000a38c, 0x20202020 }, 6982 { 0x0000a38c, 0x20202020 },
7011 { 0x0000a390, 0x20202020 }, 6983 { 0x0000a390, 0x20202020 },
7012 { 0x0000a394, 0x3bdef7bd },
7013 { 0x0000a398, 0x000003bd },
7014 { 0x0000a39c, 0x00000001 }, 6984 { 0x0000a39c, 0x00000001 },
7015 { 0x0000a3a0, 0x00000000 }, 6985 { 0x0000a3a0, 0x00000000 },
7016 { 0x0000a3a4, 0x00000000 }, 6986 { 0x0000a3a4, 0x00000000 },
@@ -7025,8 +6995,6 @@ static const u_int32_t ar9271Common_9271[][2] = {
7025 { 0x0000a3cc, 0x20202020 }, 6995 { 0x0000a3cc, 0x20202020 },
7026 { 0x0000a3d0, 0x20202020 }, 6996 { 0x0000a3d0, 0x20202020 },
7027 { 0x0000a3d4, 0x20202020 }, 6997 { 0x0000a3d4, 0x20202020 },
7028 { 0x0000a3dc, 0x3bdef7bd },
7029 { 0x0000a3e0, 0x000003bd },
7030 { 0x0000a3e4, 0x00000000 }, 6998 { 0x0000a3e4, 0x00000000 },
7031 { 0x0000a3e8, 0x18c43433 }, 6999 { 0x0000a3e8, 0x18c43433 },
7032 { 0x0000a3ec, 0x00f70081 }, 7000 { 0x0000a3ec, 0x00f70081 },
@@ -7046,7 +7014,102 @@ static const u_int32_t ar9271Common_9271[][2] = {
7046 { 0x0000d384, 0xf3307ff0 }, 7014 { 0x0000d384, 0xf3307ff0 },
7047}; 7015};
7048 7016
7017static const u_int32_t ar9271Common_normal_cck_fir_coeff_9271[][2] = {
7018 { 0x0000a1f4, 0x00fffeff },
7019 { 0x0000a1f8, 0x00f5f9ff },
7020 { 0x0000a1fc, 0xb79f6427 },
7021};
7022
7023static const u_int32_t ar9271Common_japan_2484_cck_fir_coeff_9271[][2] = {
7024 { 0x0000a1f4, 0x00000000 },
7025 { 0x0000a1f8, 0xefff0301 },
7026 { 0x0000a1fc, 0xca9228ee },
7027};
7028
7049static const u_int32_t ar9271Modes_9271_1_0_only[][6] = { 7029static const u_int32_t ar9271Modes_9271_1_0_only[][6] = {
7050 { 0x00009910, 0x30002311, 0x30002311, 0x30002311, 0x30002311, 0x30002311 }, 7030 { 0x00009910, 0x30002311, 0x30002311, 0x30002311, 0x30002311, 0x30002311 },
7051 { 0x00009828, 0x0a020001, 0x0a020001, 0x0a020001, 0x0a020001, 0x0a020001 }, 7031 { 0x00009828, 0x0a020001, 0x0a020001, 0x0a020001, 0x0a020001, 0x0a020001 },
7052}; 7032};
7033
7034static const u_int32_t ar9271Modes_9271_ANI_reg[][6] = {
7035 { 0x00009850, 0x6d4000e2, 0x6d4000e2, 0x6d4000e2, 0x6d4000e2, 0x6d4000e2 },
7036 { 0x0000985c, 0x3139605e, 0x3139605e, 0x3137605e, 0x3137605e, 0x3139605e },
7037 { 0x00009858, 0x7ec84d2e, 0x7ec84d2e, 0x7ec84d2e, 0x7ec84d2e, 0x7ec84d2e },
7038 { 0x0000986c, 0x06903881, 0x06903881, 0x06903881, 0x06903881, 0x06903881 },
7039 { 0x00009868, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0 },
7040 { 0x0000a208, 0x803e68c8, 0x803e68c8, 0x803e68c8, 0x803e68c8, 0x803e68c8 },
7041 { 0x00009924, 0xd00a8007, 0xd00a8007, 0xd00a800d, 0xd00a800d, 0xd00a800d },
7042 { 0x000099c0, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4 },
7043};
7044
7045static const u_int32_t ar9271Modes_normal_power_tx_gain_9271[][6] = {
7046 { 0x0000a300, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
7047 { 0x0000a304, 0x00000000, 0x00000000, 0x00009200, 0x00009200, 0x00000000 },
7048 { 0x0000a308, 0x00000000, 0x00000000, 0x00010208, 0x00010208, 0x00000000 },
7049 { 0x0000a30c, 0x00000000, 0x00000000, 0x00019608, 0x00019608, 0x00000000 },
7050 { 0x0000a310, 0x00000000, 0x00000000, 0x0001e610, 0x0001e610, 0x00000000 },
7051 { 0x0000a314, 0x00000000, 0x00000000, 0x0002d6d0, 0x0002d6d0, 0x00000000 },
7052 { 0x0000a318, 0x00000000, 0x00000000, 0x00039758, 0x00039758, 0x00000000 },
7053 { 0x0000a31c, 0x00000000, 0x00000000, 0x0003b759, 0x0003b759, 0x00000000 },
7054 { 0x0000a320, 0x00000000, 0x00000000, 0x0003d75a, 0x0003d75a, 0x00000000 },
7055 { 0x0000a324, 0x00000000, 0x00000000, 0x0004175c, 0x0004175c, 0x00000000 },
7056 { 0x0000a328, 0x00000000, 0x00000000, 0x0004575e, 0x0004575e, 0x00000000 },
7057 { 0x0000a32c, 0x00000000, 0x00000000, 0x0004979f, 0x0004979f, 0x00000000 },
7058 { 0x0000a330, 0x00000000, 0x00000000, 0x0004d7df, 0x0004d7df, 0x00000000 },
7059 { 0x0000a334, 0x000368de, 0x000368de, 0x000368de, 0x000368de, 0x00000000 },
7060 { 0x0000a338, 0x0003891e, 0x0003891e, 0x0003891e, 0x0003891e, 0x00000000 },
7061 { 0x0000a33c, 0x0003a95e, 0x0003a95e, 0x0003a95e, 0x0003a95e, 0x00000000 },
7062 { 0x0000a340, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
7063 { 0x0000a344, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
7064 { 0x0000a348, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
7065 { 0x0000a34c, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
7066 { 0x0000a350, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
7067 { 0x0000a354, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
7068 { 0x00007838, 0x00000029, 0x00000029, 0x00000029, 0x00000029, 0x00000029 },
7069 { 0x00007824, 0x00d8abff, 0x00d8abff, 0x00d8abff, 0x00d8abff, 0x00d8abff },
7070 { 0x0000786c, 0x48609eb4, 0x48609eb4, 0x48609eb4, 0x48609eb4, 0x48609eb4 },
7071 { 0x00007820, 0x00000c04, 0x00000c04, 0x00000c04, 0x00000c04, 0x00000c04 },
7072 { 0x0000a274, 0x0a21c652, 0x0a21c652, 0x0a218652, 0x0a218652, 0x0a22a652 },
7073 { 0x0000a278, 0x3bdef7bd, 0x3bdef7bd, 0x3bdef7bd, 0x3bdef7bd, 0x3bdef7bd },
7074 { 0x0000a27c, 0x050e83bd, 0x050e83bd, 0x050e83bd, 0x050e83bd, 0x050e83bd },
7075 { 0x0000a394, 0x3bdef7bd, 0x3bdef7bd, 0x3bdef7bd, 0x3bdef7bd, 0x3bdef7bd },
7076 { 0x0000a398, 0x000003bd, 0x000003bd, 0x000003bd, 0x000003bd, 0x000003bd },
7077 { 0x0000a3dc, 0x3bdef7bd, 0x3bdef7bd, 0x3bdef7bd, 0x3bdef7bd, 0x3bdef7bd },
7078 { 0x0000a3e0, 0x000003bd, 0x000003bd, 0x000003bd, 0x000003bd, 0x000003bd },
7079};
7080
7081static const u_int32_t ar9271Modes_high_power_tx_gain_9271[][6] = {
7082 { 0x0000a300, 0x00000000, 0x00000000, 0x00010000, 0x00010000, 0x00000000 },
7083 { 0x0000a304, 0x00000000, 0x00000000, 0x00016200, 0x00016200, 0x00000000 },
7084 { 0x0000a308, 0x00000000, 0x00000000, 0x00018201, 0x00018201, 0x00000000 },
7085 { 0x0000a30c, 0x00000000, 0x00000000, 0x0001b240, 0x0001b240, 0x00000000 },
7086 { 0x0000a310, 0x00000000, 0x00000000, 0x0001d241, 0x0001d241, 0x00000000 },
7087 { 0x0000a314, 0x00000000, 0x00000000, 0x0001f600, 0x0001f600, 0x00000000 },
7088 { 0x0000a318, 0x00000000, 0x00000000, 0x00022800, 0x00022800, 0x00000000 },
7089 { 0x0000a31c, 0x00000000, 0x00000000, 0x00026802, 0x00026802, 0x00000000 },
7090 { 0x0000a320, 0x00000000, 0x00000000, 0x0002b805, 0x0002b805, 0x00000000 },
7091 { 0x0000a324, 0x00000000, 0x00000000, 0x0002ea41, 0x0002ea41, 0x00000000 },
7092 { 0x0000a328, 0x00000000, 0x00000000, 0x00038b00, 0x00038b00, 0x00000000 },
7093 { 0x0000a32c, 0x00000000, 0x00000000, 0x0003ab40, 0x0003ab40, 0x00000000 },
7094 { 0x0000a330, 0x00000000, 0x00000000, 0x0003cd80, 0x0003cd80, 0x00000000 },
7095 { 0x0000a334, 0x000368de, 0x000368de, 0x000368de, 0x000368de, 0x00000000 },
7096 { 0x0000a338, 0x0003891e, 0x0003891e, 0x0003891e, 0x0003891e, 0x00000000 },
7097 { 0x0000a33c, 0x0003a95e, 0x0003a95e, 0x0003a95e, 0x0003a95e, 0x00000000 },
7098 { 0x0000a340, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
7099 { 0x0000a344, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
7100 { 0x0000a348, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
7101 { 0x0000a34c, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
7102 { 0x0000a350, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
7103 { 0x0000a354, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x0003e9df, 0x00000000 },
7104 { 0x00007838, 0x0000002b, 0x0000002b, 0x0000002b, 0x0000002b, 0x0000002b },
7105 { 0x00007824, 0x00d8a7ff, 0x00d8a7ff, 0x00d8a7ff, 0x00d8a7ff, 0x00d8a7ff },
7106 { 0x0000786c, 0x08609eb6, 0x08609eb6, 0x08609eba, 0x08609eba, 0x08609eb6 },
7107 { 0x00007820, 0x00000c00, 0x00000c00, 0x00000c00, 0x00000c00, 0x00000c00 },
7108 { 0x0000a274, 0x0a22a652, 0x0a22a652, 0x0a212652, 0x0a212652, 0x0a22a652 },
7109 { 0x0000a278, 0x0e739ce7, 0x0e739ce7, 0x0e739ce7, 0x0e739ce7, 0x0e739ce7 },
7110 { 0x0000a27c, 0x05018063, 0x05038063, 0x05018063, 0x05018063, 0x05018063 },
7111 { 0x0000a394, 0x06318c63, 0x06318c63, 0x06318c63, 0x06318c63, 0x06318c63 },
7112 { 0x0000a398, 0x00000063, 0x00000063, 0x00000063, 0x00000063, 0x00000063 },
7113 { 0x0000a3dc, 0x06318c63, 0x06318c63, 0x06318c63, 0x06318c63, 0x06318c63 },
7114 { 0x0000a3e0, 0x00000063, 0x00000063, 0x00000063, 0x00000063, 0x00000063 },
7115};
diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c
index efc420cd42bf..7af823a1527d 100644
--- a/drivers/net/wireless/ath/ath9k/mac.c
+++ b/drivers/net/wireless/ath/ath9k/mac.c
@@ -31,8 +31,10 @@ static void ath9k_hw_set_txq_interrupts(struct ath_hw *ah,
31 REG_WRITE(ah, AR_IMR_S1, 31 REG_WRITE(ah, AR_IMR_S1,
32 SM(ah->txerr_interrupt_mask, AR_IMR_S1_QCU_TXERR) 32 SM(ah->txerr_interrupt_mask, AR_IMR_S1_QCU_TXERR)
33 | SM(ah->txeol_interrupt_mask, AR_IMR_S1_QCU_TXEOL)); 33 | SM(ah->txeol_interrupt_mask, AR_IMR_S1_QCU_TXEOL));
34 REG_RMW_FIELD(ah, AR_IMR_S2, 34
35 AR_IMR_S2_QCU_TXURN, ah->txurn_interrupt_mask); 35 ah->imrs2_reg &= ~AR_IMR_S2_QCU_TXURN;
36 ah->imrs2_reg |= (ah->txurn_interrupt_mask & AR_IMR_S2_QCU_TXURN);
37 REG_WRITE(ah, AR_IMR_S2, ah->imrs2_reg);
36} 38}
37 39
38u32 ath9k_hw_gettxbuf(struct ath_hw *ah, u32 q) 40u32 ath9k_hw_gettxbuf(struct ath_hw *ah, u32 q)
@@ -349,7 +351,7 @@ void ath9k_hw_set11n_txdesc(struct ath_hw *ah, struct ath_desc *ds,
349 351
350 ads->ds_ctl6 = SM(keyType, AR_EncrType); 352 ads->ds_ctl6 = SM(keyType, AR_EncrType);
351 353
352 if (AR_SREV_9285(ah)) { 354 if (AR_SREV_9285(ah) || AR_SREV_9271(ah)) {
353 ads->ds_ctl8 = 0; 355 ads->ds_ctl8 = 0;
354 ads->ds_ctl9 = 0; 356 ads->ds_ctl9 = 0;
355 ads->ds_ctl10 = 0; 357 ads->ds_ctl10 = 0;
diff --git a/drivers/net/wireless/ath/ath9k/mac.h b/drivers/net/wireless/ath/ath9k/mac.h
index 29851e6376a9..a5e543bd2271 100644
--- a/drivers/net/wireless/ath/ath9k/mac.h
+++ b/drivers/net/wireless/ath/ath9k/mac.h
@@ -150,6 +150,32 @@ struct ath_rx_status {
150 u32 evm2; 150 u32 evm2;
151}; 151};
152 152
153struct ath_htc_rx_status {
154 u64 rs_tstamp;
155 u16 rs_datalen;
156 u8 rs_status;
157 u8 rs_phyerr;
158 int8_t rs_rssi;
159 int8_t rs_rssi_ctl0;
160 int8_t rs_rssi_ctl1;
161 int8_t rs_rssi_ctl2;
162 int8_t rs_rssi_ext0;
163 int8_t rs_rssi_ext1;
164 int8_t rs_rssi_ext2;
165 u8 rs_keyix;
166 u8 rs_rate;
167 u8 rs_antenna;
168 u8 rs_more;
169 u8 rs_isaggr;
170 u8 rs_moreaggr;
171 u8 rs_num_delims;
172 u8 rs_flags;
173 u8 rs_dummy;
174 u32 evm0;
175 u32 evm1;
176 u32 evm2;
177};
178
153#define ATH9K_RXERR_CRC 0x01 179#define ATH9K_RXERR_CRC 0x01
154#define ATH9K_RXERR_PHY 0x02 180#define ATH9K_RXERR_PHY 0x02
155#define ATH9K_RXERR_FIFO 0x04 181#define ATH9K_RXERR_FIFO 0x04
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index 0e79e58cf4c9..3c4b5d2d9e16 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -1226,8 +1226,12 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
1226 long_retry = rate->count - 1; 1226 long_retry = rate->count - 1;
1227 } 1227 }
1228 1228
1229 if (!priv_sta || !ieee80211_is_data(fc) || 1229 if (!priv_sta || !ieee80211_is_data(fc))
1230 !(tx_info->pad[0] & ATH_TX_INFO_UPDATE_RC)) 1230 return;
1231
1232 /* This packet was aggregated but doesn't carry status info */
1233 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) &&
1234 !(tx_info->flags & IEEE80211_TX_STAT_AMPDU))
1231 return; 1235 return;
1232 1236
1233 if (tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED) 1237 if (tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED)
diff --git a/drivers/net/wireless/ath/ath9k/rc.h b/drivers/net/wireless/ath/ath9k/rc.h
index 4f6d6fd442f4..36083dde863d 100644
--- a/drivers/net/wireless/ath/ath9k/rc.h
+++ b/drivers/net/wireless/ath/ath9k/rc.h
@@ -110,8 +110,8 @@ struct ath_rate_table {
110 int rate_cnt; 110 int rate_cnt;
111 int mcs_start; 111 int mcs_start;
112 struct { 112 struct {
113 int valid; 113 u8 valid;
114 int valid_single_stream; 114 u8 valid_single_stream;
115 u8 phy; 115 u8 phy;
116 u32 ratekbps; 116 u32 ratekbps;
117 u32 user_ratekbps; 117 u32 user_ratekbps;
@@ -172,7 +172,6 @@ struct ath_rate_priv {
172 172
173#define ATH_TX_INFO_FRAME_TYPE_INTERNAL (1 << 0) 173#define ATH_TX_INFO_FRAME_TYPE_INTERNAL (1 << 0)
174#define ATH_TX_INFO_FRAME_TYPE_PAUSE (1 << 1) 174#define ATH_TX_INFO_FRAME_TYPE_PAUSE (1 << 1)
175#define ATH_TX_INFO_UPDATE_RC (1 << 2)
176#define ATH_TX_INFO_XRETRY (1 << 3) 175#define ATH_TX_INFO_XRETRY (1 << 3)
177#define ATH_TX_INFO_UNDERRUN (1 << 4) 176#define ATH_TX_INFO_UNDERRUN (1 << 4)
178 177
diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h
index 72cfa8ebd9ae..198e41dd38a6 100644
--- a/drivers/net/wireless/ath/ath9k/reg.h
+++ b/drivers/net/wireless/ath/ath9k/reg.h
@@ -940,6 +940,7 @@ enum {
940#define AR928X_NUM_GPIO 10 940#define AR928X_NUM_GPIO 10
941#define AR9285_NUM_GPIO 12 941#define AR9285_NUM_GPIO 12
942#define AR9287_NUM_GPIO 11 942#define AR9287_NUM_GPIO 11
943#define AR9271_NUM_GPIO 16
943 944
944#define AR_GPIO_IN_OUT 0x4048 945#define AR_GPIO_IN_OUT 0x4048
945#define AR_GPIO_IN_VAL 0x0FFFC000 946#define AR_GPIO_IN_VAL 0x0FFFC000
@@ -950,6 +951,8 @@ enum {
950#define AR9285_GPIO_IN_VAL_S 12 951#define AR9285_GPIO_IN_VAL_S 12
951#define AR9287_GPIO_IN_VAL 0x003FF800 952#define AR9287_GPIO_IN_VAL 0x003FF800
952#define AR9287_GPIO_IN_VAL_S 11 953#define AR9287_GPIO_IN_VAL_S 11
954#define AR9271_GPIO_IN_VAL 0xFFFF0000
955#define AR9271_GPIO_IN_VAL_S 16
953 956
954#define AR_GPIO_OE_OUT 0x404c 957#define AR_GPIO_OE_OUT 0x404c
955#define AR_GPIO_OE_OUT_DRV 0x3 958#define AR_GPIO_OE_OUT_DRV 0x3
diff --git a/drivers/net/wireless/ath/ath9k/wmi.c b/drivers/net/wireless/ath/ath9k/wmi.c
new file mode 100644
index 000000000000..818dea0164ec
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/wmi.c
@@ -0,0 +1,319 @@
1/*
2 * Copyright (c) 2010 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 "htc.h"
18
19static const char *wmi_cmd_to_name(enum wmi_cmd_id wmi_cmd)
20{
21 switch (wmi_cmd) {
22 case WMI_ECHO_CMDID:
23 return "WMI_ECHO_CMDID";
24 case WMI_ACCESS_MEMORY_CMDID:
25 return "WMI_ACCESS_MEMORY_CMDID";
26 case WMI_DISABLE_INTR_CMDID:
27 return "WMI_DISABLE_INTR_CMDID";
28 case WMI_ENABLE_INTR_CMDID:
29 return "WMI_ENABLE_INTR_CMDID";
30 case WMI_RX_LINK_CMDID:
31 return "WMI_RX_LINK_CMDID";
32 case WMI_ATH_INIT_CMDID:
33 return "WMI_ATH_INIT_CMDID";
34 case WMI_ABORT_TXQ_CMDID:
35 return "WMI_ABORT_TXQ_CMDID";
36 case WMI_STOP_TX_DMA_CMDID:
37 return "WMI_STOP_TX_DMA_CMDID";
38 case WMI_STOP_DMA_RECV_CMDID:
39 return "WMI_STOP_DMA_RECV_CMDID";
40 case WMI_ABORT_TX_DMA_CMDID:
41 return "WMI_ABORT_TX_DMA_CMDID";
42 case WMI_DRAIN_TXQ_CMDID:
43 return "WMI_DRAIN_TXQ_CMDID";
44 case WMI_DRAIN_TXQ_ALL_CMDID:
45 return "WMI_DRAIN_TXQ_ALL_CMDID";
46 case WMI_START_RECV_CMDID:
47 return "WMI_START_RECV_CMDID";
48 case WMI_STOP_RECV_CMDID:
49 return "WMI_STOP_RECV_CMDID";
50 case WMI_FLUSH_RECV_CMDID:
51 return "WMI_FLUSH_RECV_CMDID";
52 case WMI_SET_MODE_CMDID:
53 return "WMI_SET_MODE_CMDID";
54 case WMI_RESET_CMDID:
55 return "WMI_RESET_CMDID";
56 case WMI_NODE_CREATE_CMDID:
57 return "WMI_NODE_CREATE_CMDID";
58 case WMI_NODE_REMOVE_CMDID:
59 return "WMI_NODE_REMOVE_CMDID";
60 case WMI_VAP_REMOVE_CMDID:
61 return "WMI_VAP_REMOVE_CMDID";
62 case WMI_VAP_CREATE_CMDID:
63 return "WMI_VAP_CREATE_CMDID";
64 case WMI_BEACON_UPDATE_CMDID:
65 return "WMI_BEACON_UPDATE_CMDID";
66 case WMI_REG_READ_CMDID:
67 return "WMI_REG_READ_CMDID";
68 case WMI_REG_WRITE_CMDID:
69 return "WMI_REG_WRITE_CMDID";
70 case WMI_RC_STATE_CHANGE_CMDID:
71 return "WMI_RC_STATE_CHANGE_CMDID";
72 case WMI_RC_RATE_UPDATE_CMDID:
73 return "WMI_RC_RATE_UPDATE_CMDID";
74 case WMI_DEBUG_INFO_CMDID:
75 return "WMI_DEBUG_INFO_CMDID";
76 case WMI_HOST_ATTACH:
77 return "WMI_HOST_ATTACH";
78 case WMI_TARGET_IC_UPDATE_CMDID:
79 return "WMI_TARGET_IC_UPDATE_CMDID";
80 case WMI_TGT_STATS_CMDID:
81 return "WMI_TGT_STATS_CMDID";
82 case WMI_TX_AGGR_ENABLE_CMDID:
83 return "WMI_TX_AGGR_ENABLE_CMDID";
84 case WMI_TGT_DETACH_CMDID:
85 return "WMI_TGT_DETACH_CMDID";
86 case WMI_TGT_TXQ_ENABLE_CMDID:
87 return "WMI_TGT_TXQ_ENABLE_CMDID";
88 }
89
90 return "Bogus";
91}
92
93struct wmi *ath9k_init_wmi(struct ath9k_htc_priv *priv)
94{
95 struct wmi *wmi;
96
97 wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL);
98 if (!wmi)
99 return NULL;
100
101 wmi->drv_priv = priv;
102 wmi->stopped = false;
103 mutex_init(&wmi->op_mutex);
104 init_completion(&wmi->cmd_wait);
105
106 return wmi;
107}
108
109void ath9k_deinit_wmi(struct ath9k_htc_priv *priv)
110{
111 struct wmi *wmi = priv->wmi;
112
113 mutex_lock(&wmi->op_mutex);
114 wmi->stopped = true;
115 mutex_unlock(&wmi->op_mutex);
116
117 kfree(priv->wmi);
118}
119
120void ath9k_wmi_tasklet(unsigned long data)
121{
122 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *)data;
123 struct ath_common *common = ath9k_hw_common(priv->ah);
124 struct wmi_cmd_hdr *hdr;
125 struct wmi_swba *swba_hdr;
126 enum wmi_event_id event;
127 struct sk_buff *skb;
128 void *wmi_event;
129 unsigned long flags;
130#ifdef CONFIG_ATH9K_HTC_DEBUGFS
131 u32 txrate;
132#endif
133
134 spin_lock_irqsave(&priv->wmi->wmi_lock, flags);
135 skb = priv->wmi->wmi_skb;
136 spin_unlock_irqrestore(&priv->wmi->wmi_lock, flags);
137
138 hdr = (struct wmi_cmd_hdr *) skb->data;
139 event = be16_to_cpu(hdr->command_id);
140 wmi_event = skb_pull(skb, sizeof(struct wmi_cmd_hdr));
141
142 ath_print(common, ATH_DBG_WMI,
143 "WMI Event: 0x%x\n", event);
144
145 switch (event) {
146 case WMI_TGT_RDY_EVENTID:
147 break;
148 case WMI_SWBA_EVENTID:
149 swba_hdr = (struct wmi_swba *) wmi_event;
150 ath9k_htc_swba(priv, swba_hdr->beacon_pending);
151 break;
152 case WMI_FATAL_EVENTID:
153 break;
154 case WMI_TXTO_EVENTID:
155 break;
156 case WMI_BMISS_EVENTID:
157 break;
158 case WMI_WLAN_TXCOMP_EVENTID:
159 break;
160 case WMI_DELBA_EVENTID:
161 break;
162 case WMI_TXRATE_EVENTID:
163#ifdef CONFIG_ATH9K_HTC_DEBUGFS
164 txrate = ((struct wmi_event_txrate *)wmi_event)->txrate;
165 priv->debug.txrate = be32_to_cpu(txrate);
166#endif
167 break;
168 default:
169 break;
170 }
171
172 dev_kfree_skb_any(skb);
173}
174
175static void ath9k_wmi_rsp_callback(struct wmi *wmi, struct sk_buff *skb)
176{
177 skb_pull(skb, sizeof(struct wmi_cmd_hdr));
178
179 if (wmi->cmd_rsp_buf != NULL && wmi->cmd_rsp_len != 0)
180 memcpy(wmi->cmd_rsp_buf, skb->data, wmi->cmd_rsp_len);
181
182 complete(&wmi->cmd_wait);
183}
184
185static void ath9k_wmi_ctrl_rx(void *priv, struct sk_buff *skb,
186 enum htc_endpoint_id epid)
187{
188 struct wmi *wmi = (struct wmi *) priv;
189 struct wmi_cmd_hdr *hdr;
190 u16 cmd_id;
191
192 if (unlikely(wmi->stopped))
193 goto free_skb;
194
195 hdr = (struct wmi_cmd_hdr *) skb->data;
196 cmd_id = be16_to_cpu(hdr->command_id);
197
198 if (cmd_id & 0x1000) {
199 spin_lock(&wmi->wmi_lock);
200 wmi->wmi_skb = skb;
201 spin_unlock(&wmi->wmi_lock);
202 tasklet_schedule(&wmi->drv_priv->wmi_tasklet);
203 return;
204 }
205
206 /* WMI command response */
207 ath9k_wmi_rsp_callback(wmi, skb);
208
209free_skb:
210 dev_kfree_skb_any(skb);
211}
212
213static void ath9k_wmi_ctrl_tx(void *priv, struct sk_buff *skb,
214 enum htc_endpoint_id epid, bool txok)
215{
216 dev_kfree_skb_any(skb);
217}
218
219int ath9k_wmi_connect(struct htc_target *htc, struct wmi *wmi,
220 enum htc_endpoint_id *wmi_ctrl_epid)
221{
222 struct htc_service_connreq connect;
223 int ret;
224
225 wmi->htc = htc;
226
227 memset(&connect, 0, sizeof(connect));
228
229 connect.ep_callbacks.priv = wmi;
230 connect.ep_callbacks.tx = ath9k_wmi_ctrl_tx;
231 connect.ep_callbacks.rx = ath9k_wmi_ctrl_rx;
232 connect.service_id = WMI_CONTROL_SVC;
233
234 ret = htc_connect_service(htc, &connect, &wmi->ctrl_epid);
235 if (ret)
236 return ret;
237
238 *wmi_ctrl_epid = wmi->ctrl_epid;
239
240 return 0;
241}
242
243static int ath9k_wmi_cmd_issue(struct wmi *wmi,
244 struct sk_buff *skb,
245 enum wmi_cmd_id cmd, u16 len)
246{
247 struct wmi_cmd_hdr *hdr;
248
249 hdr = (struct wmi_cmd_hdr *) skb_push(skb, sizeof(struct wmi_cmd_hdr));
250 hdr->command_id = cpu_to_be16(cmd);
251 hdr->seq_no = cpu_to_be16(++wmi->tx_seq_id);
252
253 return htc_send(wmi->htc, skb, wmi->ctrl_epid, NULL);
254}
255
256int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id,
257 u8 *cmd_buf, u32 cmd_len,
258 u8 *rsp_buf, u32 rsp_len,
259 u32 timeout)
260{
261 struct ath_hw *ah = wmi->drv_priv->ah;
262 struct ath_common *common = ath9k_hw_common(ah);
263 u16 headroom = sizeof(struct htc_frame_hdr) +
264 sizeof(struct wmi_cmd_hdr);
265 struct sk_buff *skb;
266 u8 *data;
267 int time_left, ret = 0;
268
269 if (!wmi)
270 return -EINVAL;
271
272 skb = dev_alloc_skb(headroom + cmd_len);
273 if (!skb)
274 return -ENOMEM;
275
276 skb_reserve(skb, headroom);
277
278 if (cmd_len != 0 && cmd_buf != NULL) {
279 data = (u8 *) skb_put(skb, cmd_len);
280 memcpy(data, cmd_buf, cmd_len);
281 }
282
283 mutex_lock(&wmi->op_mutex);
284
285 /* check if wmi stopped flag is set */
286 if (unlikely(wmi->stopped)) {
287 ret = -EPROTO;
288 goto out;
289 }
290
291 /* record the rsp buffer and length */
292 wmi->cmd_rsp_buf = rsp_buf;
293 wmi->cmd_rsp_len = rsp_len;
294
295 ret = ath9k_wmi_cmd_issue(wmi, skb, cmd_id, cmd_len);
296 if (ret)
297 goto out;
298
299 time_left = wait_for_completion_timeout(&wmi->cmd_wait, timeout);
300 if (!time_left) {
301 ath_print(common, ATH_DBG_WMI,
302 "Timeout waiting for WMI command: %s\n",
303 wmi_cmd_to_name(cmd_id));
304 mutex_unlock(&wmi->op_mutex);
305 return -ETIMEDOUT;
306 }
307
308 mutex_unlock(&wmi->op_mutex);
309
310 return 0;
311
312out:
313 ath_print(common, ATH_DBG_WMI,
314 "WMI failure for: %s\n", wmi_cmd_to_name(cmd_id));
315 mutex_unlock(&wmi->op_mutex);
316 dev_kfree_skb_any(skb);
317
318 return ret;
319}
diff --git a/drivers/net/wireless/ath/ath9k/wmi.h b/drivers/net/wireless/ath/ath9k/wmi.h
new file mode 100644
index 000000000000..39ef926f27c2
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/wmi.h
@@ -0,0 +1,126 @@
1/*
2 * Copyright (c) 2010 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#ifndef WMI_H
18#define WMI_H
19
20
21struct wmi_event_txrate {
22 u32 txrate;
23 struct {
24 u8 rssi_thresh;
25 u8 per;
26 } rc_stats;
27} __packed;
28
29struct wmi_cmd_hdr {
30 u16 command_id;
31 u16 seq_no;
32} __packed;
33
34struct wmi_swba {
35 u8 beacon_pending;
36} __packed;
37
38enum wmi_cmd_id {
39 WMI_ECHO_CMDID = 0x0001,
40 WMI_ACCESS_MEMORY_CMDID,
41
42 /* Commands to Target */
43 WMI_DISABLE_INTR_CMDID,
44 WMI_ENABLE_INTR_CMDID,
45 WMI_RX_LINK_CMDID,
46 WMI_ATH_INIT_CMDID,
47 WMI_ABORT_TXQ_CMDID,
48 WMI_STOP_TX_DMA_CMDID,
49 WMI_STOP_DMA_RECV_CMDID,
50 WMI_ABORT_TX_DMA_CMDID,
51 WMI_DRAIN_TXQ_CMDID,
52 WMI_DRAIN_TXQ_ALL_CMDID,
53 WMI_START_RECV_CMDID,
54 WMI_STOP_RECV_CMDID,
55 WMI_FLUSH_RECV_CMDID,
56 WMI_SET_MODE_CMDID,
57 WMI_RESET_CMDID,
58 WMI_NODE_CREATE_CMDID,
59 WMI_NODE_REMOVE_CMDID,
60 WMI_VAP_REMOVE_CMDID,
61 WMI_VAP_CREATE_CMDID,
62 WMI_BEACON_UPDATE_CMDID,
63 WMI_REG_READ_CMDID,
64 WMI_REG_WRITE_CMDID,
65 WMI_RC_STATE_CHANGE_CMDID,
66 WMI_RC_RATE_UPDATE_CMDID,
67 WMI_DEBUG_INFO_CMDID,
68 WMI_HOST_ATTACH,
69 WMI_TARGET_IC_UPDATE_CMDID,
70 WMI_TGT_STATS_CMDID,
71 WMI_TX_AGGR_ENABLE_CMDID,
72 WMI_TGT_DETACH_CMDID,
73 WMI_TGT_TXQ_ENABLE_CMDID,
74};
75
76enum wmi_event_id {
77 WMI_TGT_RDY_EVENTID = 0x1001,
78 WMI_SWBA_EVENTID,
79 WMI_FATAL_EVENTID,
80 WMI_TXTO_EVENTID,
81 WMI_BMISS_EVENTID,
82 WMI_WLAN_TXCOMP_EVENTID,
83 WMI_DELBA_EVENTID,
84 WMI_TXRATE_EVENTID,
85};
86
87struct wmi {
88 struct ath9k_htc_priv *drv_priv;
89 struct htc_target *htc;
90 enum htc_endpoint_id ctrl_epid;
91 struct mutex op_mutex;
92 struct completion cmd_wait;
93 u16 tx_seq_id;
94 u8 *cmd_rsp_buf;
95 u32 cmd_rsp_len;
96 bool stopped;
97
98 struct sk_buff *wmi_skb;
99 spinlock_t wmi_lock;
100};
101
102struct wmi *ath9k_init_wmi(struct ath9k_htc_priv *priv);
103void ath9k_deinit_wmi(struct ath9k_htc_priv *priv);
104int ath9k_wmi_connect(struct htc_target *htc, struct wmi *wmi,
105 enum htc_endpoint_id *wmi_ctrl_epid);
106int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id,
107 u8 *cmd_buf, u32 cmd_len,
108 u8 *rsp_buf, u32 rsp_len,
109 u32 timeout);
110void ath9k_wmi_tasklet(unsigned long data);
111
112#define WMI_CMD(_wmi_cmd) \
113 do { \
114 ret = ath9k_wmi_cmd(priv->wmi, _wmi_cmd, NULL, 0, \
115 (u8 *) &cmd_rsp, \
116 sizeof(cmd_rsp), HZ); \
117 } while (0)
118
119#define WMI_CMD_BUF(_wmi_cmd, _buf) \
120 do { \
121 ret = ath9k_wmi_cmd(priv->wmi, _wmi_cmd, \
122 (u8 *) _buf, sizeof(*_buf), \
123 &cmd_rsp, sizeof(cmd_rsp), HZ); \
124 } while (0)
125
126#endif /* WMI_H */
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 294b486bc3ed..a3b6cf20f8a1 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1928,10 +1928,10 @@ static void ath_tx_rc_status(struct ath_buf *bf, struct ath_desc *ds,
1928 tx_rateindex = ds->ds_txstat.ts_rateindex; 1928 tx_rateindex = ds->ds_txstat.ts_rateindex;
1929 WARN_ON(tx_rateindex >= hw->max_rates); 1929 WARN_ON(tx_rateindex >= hw->max_rates);
1930 1930
1931 if (update_rc)
1932 tx_info->pad[0] |= ATH_TX_INFO_UPDATE_RC;
1933 if (ds->ds_txstat.ts_status & ATH9K_TXERR_FILT) 1931 if (ds->ds_txstat.ts_status & ATH9K_TXERR_FILT)
1934 tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED; 1932 tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
1933 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && update_rc)
1934 tx_info->flags |= IEEE80211_TX_STAT_AMPDU;
1935 1935
1936 if ((ds->ds_txstat.ts_status & ATH9K_TXERR_FILT) == 0 && 1936 if ((ds->ds_txstat.ts_status & ATH9K_TXERR_FILT) == 0 &&
1937 (bf->bf_flags & ATH9K_TXDESC_NOACK) == 0 && update_rc) { 1937 (bf->bf_flags & ATH9K_TXDESC_NOACK) == 0 && update_rc) {
diff --git a/drivers/net/wireless/ath/debug.h b/drivers/net/wireless/ath/debug.h
index 8263633c003c..873bf526e11f 100644
--- a/drivers/net/wireless/ath/debug.h
+++ b/drivers/net/wireless/ath/debug.h
@@ -59,6 +59,7 @@ enum ATH_DEBUG {
59 ATH_DBG_PS = 0x00000800, 59 ATH_DBG_PS = 0x00000800,
60 ATH_DBG_HWTIMER = 0x00001000, 60 ATH_DBG_HWTIMER = 0x00001000,
61 ATH_DBG_BTCOEX = 0x00002000, 61 ATH_DBG_BTCOEX = 0x00002000,
62 ATH_DBG_WMI = 0x00004000,
62 ATH_DBG_ANY = 0xffffffff 63 ATH_DBG_ANY = 0xffffffff
63}; 64};
64 65
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index b8807fb12c92..3a003e6803a5 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -104,6 +104,7 @@
104#define B43_MMIO_MACFILTER_CONTROL 0x420 104#define B43_MMIO_MACFILTER_CONTROL 0x420
105#define B43_MMIO_MACFILTER_DATA 0x422 105#define B43_MMIO_MACFILTER_DATA 0x422
106#define B43_MMIO_RCMTA_COUNT 0x43C 106#define B43_MMIO_RCMTA_COUNT 0x43C
107#define B43_MMIO_PSM_PHY_HDR 0x492
107#define B43_MMIO_RADIO_HWENABLED_LO 0x49A 108#define B43_MMIO_RADIO_HWENABLED_LO 0x49A
108#define B43_MMIO_GPIO_CONTROL 0x49C 109#define B43_MMIO_GPIO_CONTROL 0x49C
109#define B43_MMIO_GPIO_MASK 0x49E 110#define B43_MMIO_GPIO_MASK 0x49E
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 1521b1e78d21..14cf3bd7ea51 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -4348,11 +4348,10 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
4348 b43_set_phytxctl_defaults(dev); 4348 b43_set_phytxctl_defaults(dev);
4349 4349
4350 /* Minimum Contention Window */ 4350 /* Minimum Contention Window */
4351 if (phy->type == B43_PHYTYPE_B) { 4351 if (phy->type == B43_PHYTYPE_B)
4352 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_MINCONT, 0x1F); 4352 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_MINCONT, 0x1F);
4353 } else { 4353 else
4354 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_MINCONT, 0xF); 4354 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_MINCONT, 0xF);
4355 }
4356 /* Maximum Contention Window */ 4355 /* Maximum Contention Window */
4357 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_MAXCONT, 0x3FF); 4356 b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_MAXCONT, 0x3FF);
4358 4357
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 795bb1e3345d..6fd140ac7f9e 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -72,6 +72,22 @@ static void b43_nphy_rf_control_override(struct b43_wldev *dev, u16 field,
72 u16 value, u8 core, bool off); 72 u16 value, u8 core, bool off);
73static void b43_nphy_rf_control_intc_override(struct b43_wldev *dev, u8 field, 73static void b43_nphy_rf_control_intc_override(struct b43_wldev *dev, u8 field,
74 u16 value, u8 core); 74 u16 value, u8 core);
75static int nphy_channel_switch(struct b43_wldev *dev, unsigned int channel);
76
77static inline bool b43_empty_chanspec(struct b43_chanspec *chanspec)
78{
79 return !chanspec->channel && !chanspec->sideband &&
80 !chanspec->b_width && !chanspec->b_freq;
81}
82
83static inline bool b43_eq_chanspecs(struct b43_chanspec *chanspec1,
84 struct b43_chanspec *chanspec2)
85{
86 return (chanspec1->channel == chanspec2->channel &&
87 chanspec1->sideband == chanspec2->sideband &&
88 chanspec1->b_width == chanspec2->b_width &&
89 chanspec1->b_freq == chanspec2->b_freq);
90}
75 91
76void b43_nphy_set_rxantenna(struct b43_wldev *dev, int antenna) 92void b43_nphy_set_rxantenna(struct b43_wldev *dev, int antenna)
77{//TODO 93{//TODO
@@ -90,28 +106,38 @@ static enum b43_txpwr_result b43_nphy_op_recalc_txpower(struct b43_wldev *dev,
90static void b43_chantab_radio_upload(struct b43_wldev *dev, 106static void b43_chantab_radio_upload(struct b43_wldev *dev,
91 const struct b43_nphy_channeltab_entry *e) 107 const struct b43_nphy_channeltab_entry *e)
92{ 108{
93 b43_radio_write16(dev, B2055_PLL_REF, e->radio_pll_ref); 109 b43_radio_write(dev, B2055_PLL_REF, e->radio_pll_ref);
94 b43_radio_write16(dev, B2055_RF_PLLMOD0, e->radio_rf_pllmod0); 110 b43_radio_write(dev, B2055_RF_PLLMOD0, e->radio_rf_pllmod0);
95 b43_radio_write16(dev, B2055_RF_PLLMOD1, e->radio_rf_pllmod1); 111 b43_radio_write(dev, B2055_RF_PLLMOD1, e->radio_rf_pllmod1);
96 b43_radio_write16(dev, B2055_VCO_CAPTAIL, e->radio_vco_captail); 112 b43_radio_write(dev, B2055_VCO_CAPTAIL, e->radio_vco_captail);
97 b43_radio_write16(dev, B2055_VCO_CAL1, e->radio_vco_cal1); 113 b43_read32(dev, B43_MMIO_MACCTL); /* flush writes */
98 b43_radio_write16(dev, B2055_VCO_CAL2, e->radio_vco_cal2); 114
99 b43_radio_write16(dev, B2055_PLL_LFC1, e->radio_pll_lfc1); 115 b43_radio_write(dev, B2055_VCO_CAL1, e->radio_vco_cal1);
100 b43_radio_write16(dev, B2055_PLL_LFR1, e->radio_pll_lfr1); 116 b43_radio_write(dev, B2055_VCO_CAL2, e->radio_vco_cal2);
101 b43_radio_write16(dev, B2055_PLL_LFC2, e->radio_pll_lfc2); 117 b43_radio_write(dev, B2055_PLL_LFC1, e->radio_pll_lfc1);
102 b43_radio_write16(dev, B2055_LGBUF_CENBUF, e->radio_lgbuf_cenbuf); 118 b43_radio_write(dev, B2055_PLL_LFR1, e->radio_pll_lfr1);
103 b43_radio_write16(dev, B2055_LGEN_TUNE1, e->radio_lgen_tune1); 119 b43_read32(dev, B43_MMIO_MACCTL); /* flush writes */
104 b43_radio_write16(dev, B2055_LGEN_TUNE2, e->radio_lgen_tune2); 120
105 b43_radio_write16(dev, B2055_C1_LGBUF_ATUNE, e->radio_c1_lgbuf_atune); 121 b43_radio_write(dev, B2055_PLL_LFC2, e->radio_pll_lfc2);
106 b43_radio_write16(dev, B2055_C1_LGBUF_GTUNE, e->radio_c1_lgbuf_gtune); 122 b43_radio_write(dev, B2055_LGBUF_CENBUF, e->radio_lgbuf_cenbuf);
107 b43_radio_write16(dev, B2055_C1_RX_RFR1, e->radio_c1_rx_rfr1); 123 b43_radio_write(dev, B2055_LGEN_TUNE1, e->radio_lgen_tune1);
108 b43_radio_write16(dev, B2055_C1_TX_PGAPADTN, e->radio_c1_tx_pgapadtn); 124 b43_radio_write(dev, B2055_LGEN_TUNE2, e->radio_lgen_tune2);
109 b43_radio_write16(dev, B2055_C1_TX_MXBGTRIM, e->radio_c1_tx_mxbgtrim); 125 b43_read32(dev, B43_MMIO_MACCTL); /* flush writes */
110 b43_radio_write16(dev, B2055_C2_LGBUF_ATUNE, e->radio_c2_lgbuf_atune); 126
111 b43_radio_write16(dev, B2055_C2_LGBUF_GTUNE, e->radio_c2_lgbuf_gtune); 127 b43_radio_write(dev, B2055_C1_LGBUF_ATUNE, e->radio_c1_lgbuf_atune);
112 b43_radio_write16(dev, B2055_C2_RX_RFR1, e->radio_c2_rx_rfr1); 128 b43_radio_write(dev, B2055_C1_LGBUF_GTUNE, e->radio_c1_lgbuf_gtune);
113 b43_radio_write16(dev, B2055_C2_TX_PGAPADTN, e->radio_c2_tx_pgapadtn); 129 b43_radio_write(dev, B2055_C1_RX_RFR1, e->radio_c1_rx_rfr1);
114 b43_radio_write16(dev, B2055_C2_TX_MXBGTRIM, e->radio_c2_tx_mxbgtrim); 130 b43_radio_write(dev, B2055_C1_TX_PGAPADTN, e->radio_c1_tx_pgapadtn);
131 b43_read32(dev, B43_MMIO_MACCTL); /* flush writes */
132
133 b43_radio_write(dev, B2055_C1_TX_MXBGTRIM, e->radio_c1_tx_mxbgtrim);
134 b43_radio_write(dev, B2055_C2_LGBUF_ATUNE, e->radio_c2_lgbuf_atune);
135 b43_radio_write(dev, B2055_C2_LGBUF_GTUNE, e->radio_c2_lgbuf_gtune);
136 b43_radio_write(dev, B2055_C2_RX_RFR1, e->radio_c2_rx_rfr1);
137 b43_read32(dev, B43_MMIO_MACCTL); /* flush writes */
138
139 b43_radio_write(dev, B2055_C2_TX_PGAPADTN, e->radio_c2_tx_pgapadtn);
140 b43_radio_write(dev, B2055_C2_TX_MXBGTRIM, e->radio_c2_tx_mxbgtrim);
115} 141}
116 142
117static void b43_chantab_phy_upload(struct b43_wldev *dev, 143static void b43_chantab_phy_upload(struct b43_wldev *dev,
@@ -130,34 +156,20 @@ static void b43_nphy_tx_power_fix(struct b43_wldev *dev)
130 //TODO 156 //TODO
131} 157}
132 158
133/* Tune the hardware to a new channel. */
134static int nphy_channel_switch(struct b43_wldev *dev, unsigned int channel)
135{
136 const struct b43_nphy_channeltab_entry *tabent;
137 159
138 tabent = b43_nphy_get_chantabent(dev, channel); 160/* http://bcm-v4.sipsolutions.net/802.11/PHY/Radio/2055Setup */
139 if (!tabent) 161static void b43_radio_2055_setup(struct b43_wldev *dev,
140 return -ESRCH; 162 const struct b43_nphy_channeltab_entry *e)
163{
164 B43_WARN_ON(dev->phy.rev >= 3);
141 165
142 //FIXME enable/disable band select upper20 in RXCTL 166 b43_chantab_radio_upload(dev, e);
143 if (0 /*FIXME 5Ghz*/)
144 b43_radio_maskset(dev, B2055_MASTER1, 0xFF8F, 0x20);
145 else
146 b43_radio_maskset(dev, B2055_MASTER1, 0xFF8F, 0x50);
147 b43_chantab_radio_upload(dev, tabent);
148 udelay(50); 167 udelay(50);
149 b43_radio_write16(dev, B2055_VCO_CAL10, 5); 168 b43_radio_write(dev, B2055_VCO_CAL10, 5);
150 b43_radio_write16(dev, B2055_VCO_CAL10, 45); 169 b43_radio_write(dev, B2055_VCO_CAL10, 45);
151 b43_radio_write16(dev, B2055_VCO_CAL10, 65); 170 b43_read32(dev, B43_MMIO_MACCTL); /* flush writes */
171 b43_radio_write(dev, B2055_VCO_CAL10, 65);
152 udelay(300); 172 udelay(300);
153 if (0 /*FIXME 5Ghz*/)
154 b43_phy_set(dev, B43_NPHY_BANDCTL, B43_NPHY_BANDCTL_5GHZ);
155 else
156 b43_phy_mask(dev, B43_NPHY_BANDCTL, ~B43_NPHY_BANDCTL_5GHZ);
157 b43_chantab_phy_upload(dev, tabent);
158 b43_nphy_tx_power_fix(dev);
159
160 return 0;
161} 173}
162 174
163static void b43_radio_init2055_pre(struct b43_wldev *dev) 175static void b43_radio_init2055_pre(struct b43_wldev *dev)
@@ -173,52 +185,64 @@ static void b43_radio_init2055_pre(struct b43_wldev *dev)
173 185
174static void b43_radio_init2055_post(struct b43_wldev *dev) 186static void b43_radio_init2055_post(struct b43_wldev *dev)
175{ 187{
188 struct b43_phy_n *nphy = dev->phy.n;
176 struct ssb_sprom *sprom = &(dev->dev->bus->sprom); 189 struct ssb_sprom *sprom = &(dev->dev->bus->sprom);
177 struct ssb_boardinfo *binfo = &(dev->dev->bus->boardinfo); 190 struct ssb_boardinfo *binfo = &(dev->dev->bus->boardinfo);
178 int i; 191 int i;
179 u16 val; 192 u16 val;
193 bool workaround = false;
194
195 if (sprom->revision < 4)
196 workaround = (binfo->vendor != PCI_VENDOR_ID_BROADCOM ||
197 binfo->type != 0x46D ||
198 binfo->rev < 0x41);
199 else
200 workaround = ((sprom->boardflags_hi & B43_BFH_NOPA) == 0);
180 201
181 b43_radio_mask(dev, B2055_MASTER1, 0xFFF3); 202 b43_radio_mask(dev, B2055_MASTER1, 0xFFF3);
182 msleep(1); 203 if (workaround) {
183 if ((sprom->revision != 4) || 204 b43_radio_mask(dev, B2055_C1_RX_BB_REG, 0x7F);
184 !(sprom->boardflags_hi & B43_BFH_RSSIINV)) { 205 b43_radio_mask(dev, B2055_C2_RX_BB_REG, 0x7F);
185 if ((binfo->vendor != PCI_VENDOR_ID_BROADCOM) ||
186 (binfo->type != 0x46D) ||
187 (binfo->rev < 0x41)) {
188 b43_radio_mask(dev, B2055_C1_RX_BB_REG, 0x7F);
189 b43_radio_mask(dev, B2055_C1_RX_BB_REG, 0x7F);
190 msleep(1);
191 }
192 } 206 }
193 b43_radio_maskset(dev, B2055_RRCCAL_NOPTSEL, 0x3F, 0x2C); 207 b43_radio_maskset(dev, B2055_RRCCAL_NOPTSEL, 0xFFC0, 0x2C);
194 msleep(1); 208 b43_radio_write(dev, B2055_CAL_MISC, 0x3C);
195 b43_radio_write16(dev, B2055_CAL_MISC, 0x3C);
196 msleep(1);
197 b43_radio_mask(dev, B2055_CAL_MISC, 0xFFBE); 209 b43_radio_mask(dev, B2055_CAL_MISC, 0xFFBE);
198 msleep(1);
199 b43_radio_set(dev, B2055_CAL_LPOCTL, 0x80); 210 b43_radio_set(dev, B2055_CAL_LPOCTL, 0x80);
200 msleep(1);
201 b43_radio_set(dev, B2055_CAL_MISC, 0x1); 211 b43_radio_set(dev, B2055_CAL_MISC, 0x1);
202 msleep(1); 212 msleep(1);
203 b43_radio_set(dev, B2055_CAL_MISC, 0x40); 213 b43_radio_set(dev, B2055_CAL_MISC, 0x40);
204 msleep(1); 214 for (i = 0; i < 200; i++) {
205 for (i = 0; i < 100; i++) { 215 val = b43_radio_read(dev, B2055_CAL_COUT2);
206 val = b43_radio_read16(dev, B2055_CAL_COUT2); 216 if (val & 0x80) {
207 if (val & 0x80) 217 i = 0;
208 break; 218 break;
219 }
209 udelay(10); 220 udelay(10);
210 } 221 }
211 msleep(1); 222 if (i)
223 b43err(dev->wl, "radio post init timeout\n");
212 b43_radio_mask(dev, B2055_CAL_LPOCTL, 0xFF7F); 224 b43_radio_mask(dev, B2055_CAL_LPOCTL, 0xFF7F);
213 msleep(1);
214 nphy_channel_switch(dev, dev->phy.channel); 225 nphy_channel_switch(dev, dev->phy.channel);
215 b43_radio_write16(dev, B2055_C1_RX_BB_LPF, 0x9); 226 b43_radio_write(dev, B2055_C1_RX_BB_LPF, 0x9);
216 b43_radio_write16(dev, B2055_C2_RX_BB_LPF, 0x9); 227 b43_radio_write(dev, B2055_C2_RX_BB_LPF, 0x9);
217 b43_radio_write16(dev, B2055_C1_RX_BB_MIDACHP, 0x83); 228 b43_radio_write(dev, B2055_C1_RX_BB_MIDACHP, 0x83);
218 b43_radio_write16(dev, B2055_C2_RX_BB_MIDACHP, 0x83); 229 b43_radio_write(dev, B2055_C2_RX_BB_MIDACHP, 0x83);
230 b43_radio_maskset(dev, B2055_C1_LNA_GAINBST, 0xFFF8, 0x6);
231 b43_radio_maskset(dev, B2055_C2_LNA_GAINBST, 0xFFF8, 0x6);
232 if (!nphy->gain_boost) {
233 b43_radio_set(dev, B2055_C1_RX_RFSPC1, 0x2);
234 b43_radio_set(dev, B2055_C2_RX_RFSPC1, 0x2);
235 } else {
236 b43_radio_mask(dev, B2055_C1_RX_RFSPC1, 0xFFFD);
237 b43_radio_mask(dev, B2055_C2_RX_RFSPC1, 0xFFFD);
238 }
239 udelay(2);
219} 240}
220 241
221/* Initialize a Broadcom 2055 N-radio */ 242/*
243 * Initialize a Broadcom 2055 N-radio
244 * http://bcm-v4.sipsolutions.net/802.11/Radio/2055/Init
245 */
222static void b43_radio_init2055(struct b43_wldev *dev) 246static void b43_radio_init2055(struct b43_wldev *dev)
223{ 247{
224 b43_radio_init2055_pre(dev); 248 b43_radio_init2055_pre(dev);
@@ -229,17 +253,6 @@ static void b43_radio_init2055(struct b43_wldev *dev)
229 b43_radio_init2055_post(dev); 253 b43_radio_init2055_post(dev);
230} 254}
231 255
232void b43_nphy_radio_turn_on(struct b43_wldev *dev)
233{
234 b43_radio_init2055(dev);
235}
236
237void b43_nphy_radio_turn_off(struct b43_wldev *dev)
238{
239 b43_phy_mask(dev, B43_NPHY_RFCTL_CMD,
240 ~B43_NPHY_RFCTL_CMD_EN);
241}
242
243/* 256/*
244 * Upload the N-PHY tables. 257 * Upload the N-PHY tables.
245 * http://bcm-v4.sipsolutions.net/802.11/PHY/N/InitTables 258 * http://bcm-v4.sipsolutions.net/802.11/PHY/N/InitTables
@@ -646,6 +659,41 @@ static void b43_nphy_read_clip_detection(struct b43_wldev *dev, u16 *clip_st)
646 clip_st[1] = b43_phy_read(dev, B43_NPHY_C2_CLIP1THRES); 659 clip_st[1] = b43_phy_read(dev, B43_NPHY_C2_CLIP1THRES);
647} 660}
648 661
662/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SuperSwitchInit */
663static void b43_nphy_superswitch_init(struct b43_wldev *dev, bool init)
664{
665 if (dev->phy.rev >= 3) {
666 if (!init)
667 return;
668 if (0 /* FIXME */) {
669 b43_ntab_write(dev, B43_NTAB16(9, 2), 0x211);
670 b43_ntab_write(dev, B43_NTAB16(9, 3), 0x222);
671 b43_ntab_write(dev, B43_NTAB16(9, 8), 0x144);
672 b43_ntab_write(dev, B43_NTAB16(9, 12), 0x188);
673 }
674 } else {
675 b43_phy_write(dev, B43_NPHY_GPIO_LOOEN, 0);
676 b43_phy_write(dev, B43_NPHY_GPIO_HIOEN, 0);
677
678 ssb_chipco_gpio_control(&dev->dev->bus->chipco, 0xFC00,
679 0xFC00);
680 b43_write32(dev, B43_MMIO_MACCTL,
681 b43_read32(dev, B43_MMIO_MACCTL) &
682 ~B43_MACCTL_GPOUTSMSK);
683 b43_write16(dev, B43_MMIO_GPIO_MASK,
684 b43_read16(dev, B43_MMIO_GPIO_MASK) | 0xFC00);
685 b43_write16(dev, B43_MMIO_GPIO_CONTROL,
686 b43_read16(dev, B43_MMIO_GPIO_CONTROL) & ~0xFC00);
687
688 if (init) {
689 b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_LO1, 0x2D8);
690 b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_UP1, 0x301);
691 b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_LO2, 0x2D8);
692 b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_UP2, 0x301);
693 }
694 }
695}
696
649/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/classifier */ 697/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/classifier */
650static u16 b43_nphy_classifier(struct b43_wldev *dev, u16 mask, u16 val) 698static u16 b43_nphy_classifier(struct b43_wldev *dev, u16 mask, u16 val)
651{ 699{
@@ -722,7 +770,7 @@ static void b43_nphy_spur_workaround(struct b43_wldev *dev)
722{ 770{
723 struct b43_phy_n *nphy = dev->phy.n; 771 struct b43_phy_n *nphy = dev->phy.n;
724 772
725 unsigned int channel; 773 u8 channel = nphy->radio_chanspec.channel;
726 int tone[2] = { 57, 58 }; 774 int tone[2] = { 57, 58 };
727 u32 noise[2] = { 0x3FF, 0x3FF }; 775 u32 noise[2] = { 0x3FF, 0x3FF };
728 776
@@ -731,8 +779,6 @@ static void b43_nphy_spur_workaround(struct b43_wldev *dev)
731 if (nphy->hang_avoid) 779 if (nphy->hang_avoid)
732 b43_nphy_stay_in_carrier_search(dev, 1); 780 b43_nphy_stay_in_carrier_search(dev, 1);
733 781
734 /* FIXME: channel = radio_chanspec */
735
736 if (nphy->gband_spurwar_en) { 782 if (nphy->gband_spurwar_en) {
737 /* TODO: N PHY Adjust Analog Pfbw (7) */ 783 /* TODO: N PHY Adjust Analog Pfbw (7) */
738 if (channel == 11 && dev->phy.is_40mhz) 784 if (channel == 11 && dev->phy.is_40mhz)
@@ -778,6 +824,62 @@ static void b43_nphy_spur_workaround(struct b43_wldev *dev)
778 b43_nphy_stay_in_carrier_search(dev, 0); 824 b43_nphy_stay_in_carrier_search(dev, 0);
779} 825}
780 826
827/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/AdjustLnaGainTbl */
828static void b43_nphy_adjust_lna_gain_table(struct b43_wldev *dev)
829{
830 struct b43_phy_n *nphy = dev->phy.n;
831
832 u8 i;
833 s16 tmp;
834 u16 data[4];
835 s16 gain[2];
836 u16 minmax[2];
837 u16 lna_gain[4] = { -2, 10, 19, 25 };
838
839 if (nphy->hang_avoid)
840 b43_nphy_stay_in_carrier_search(dev, 1);
841
842 if (nphy->gain_boost) {
843 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
844 gain[0] = 6;
845 gain[1] = 6;
846 } else {
847 tmp = 40370 - 315 * nphy->radio_chanspec.channel;
848 gain[0] = ((tmp >> 13) + ((tmp >> 12) & 1));
849 tmp = 23242 - 224 * nphy->radio_chanspec.channel;
850 gain[1] = ((tmp >> 13) + ((tmp >> 12) & 1));
851 }
852 } else {
853 gain[0] = 0;
854 gain[1] = 0;
855 }
856
857 for (i = 0; i < 2; i++) {
858 if (nphy->elna_gain_config) {
859 data[0] = 19 + gain[i];
860 data[1] = 25 + gain[i];
861 data[2] = 25 + gain[i];
862 data[3] = 25 + gain[i];
863 } else {
864 data[0] = lna_gain[0] + gain[i];
865 data[1] = lna_gain[1] + gain[i];
866 data[2] = lna_gain[2] + gain[i];
867 data[3] = lna_gain[3] + gain[i];
868 }
869 b43_ntab_write_bulk(dev, B43_NTAB16(10, 8), 4, data);
870
871 minmax[i] = 23 + gain[i];
872 }
873
874 b43_phy_maskset(dev, B43_NPHY_C1_MINMAX_GAIN, ~B43_NPHY_C1_MINGAIN,
875 minmax[0] << B43_NPHY_C1_MINGAIN_SHIFT);
876 b43_phy_maskset(dev, B43_NPHY_C2_MINMAX_GAIN, ~B43_NPHY_C2_MINGAIN,
877 minmax[1] << B43_NPHY_C2_MINGAIN_SHIFT);
878
879 if (nphy->hang_avoid)
880 b43_nphy_stay_in_carrier_search(dev, 0);
881}
882
781/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/WorkaroundsGainCtrl */ 883/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/WorkaroundsGainCtrl */
782static void b43_nphy_gain_crtl_workarounds(struct b43_wldev *dev) 884static void b43_nphy_gain_crtl_workarounds(struct b43_wldev *dev)
783{ 885{
@@ -862,7 +964,7 @@ static void b43_nphy_gain_crtl_workarounds(struct b43_wldev *dev)
862 b43_phy_write(dev, B43_NPHY_TABLE_DATALO, 964 b43_phy_write(dev, B43_NPHY_TABLE_DATALO,
863 (code << 8 | 0x7C)); 965 (code << 8 | 0x7C));
864 966
865 /* TODO: b43_nphy_adjust_lna_gain_table(dev); */ 967 b43_nphy_adjust_lna_gain_table(dev);
866 968
867 if (nphy->elna_gain_config) { 969 if (nphy->elna_gain_config) {
868 b43_phy_write(dev, B43_NPHY_TABLE_ADDR, 0x0808); 970 b43_phy_write(dev, B43_NPHY_TABLE_ADDR, 0x0808);
@@ -1969,12 +2071,12 @@ static void b43_nphy_restore_rssi_cal(struct b43_wldev *dev)
1969 u16 *rssical_phy_regs = NULL; 2071 u16 *rssical_phy_regs = NULL;
1970 2072
1971 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) { 2073 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
1972 if (!nphy->rssical_chanspec_2G) 2074 if (b43_empty_chanspec(&nphy->rssical_chanspec_2G))
1973 return; 2075 return;
1974 rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_2G; 2076 rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_2G;
1975 rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_2G; 2077 rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_2G;
1976 } else { 2078 } else {
1977 if (!nphy->rssical_chanspec_5G) 2079 if (b43_empty_chanspec(&nphy->rssical_chanspec_5G))
1978 return; 2080 return;
1979 rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_5G; 2081 rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_5G;
1980 rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_5G; 2082 rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_5G;
@@ -2394,7 +2496,7 @@ static void b43_nphy_save_cal(struct b43_wldev *dev)
2394 2496
2395 struct b43_phy_n_iq_comp *rxcal_coeffs = NULL; 2497 struct b43_phy_n_iq_comp *rxcal_coeffs = NULL;
2396 u16 *txcal_radio_regs = NULL; 2498 u16 *txcal_radio_regs = NULL;
2397 u8 *iqcal_chanspec; 2499 struct b43_chanspec *iqcal_chanspec;
2398 u16 *table = NULL; 2500 u16 *table = NULL;
2399 2501
2400 if (nphy->hang_avoid) 2502 if (nphy->hang_avoid)
@@ -2450,12 +2552,12 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev)
2450 struct b43_phy_n_iq_comp *rxcal_coeffs = NULL; 2552 struct b43_phy_n_iq_comp *rxcal_coeffs = NULL;
2451 2553
2452 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) { 2554 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
2453 if (nphy->iqcal_chanspec_2G == 0) 2555 if (b43_empty_chanspec(&nphy->iqcal_chanspec_2G))
2454 return; 2556 return;
2455 table = nphy->cal_cache.txcal_coeffs_2G; 2557 table = nphy->cal_cache.txcal_coeffs_2G;
2456 loft = &nphy->cal_cache.txcal_coeffs_2G[5]; 2558 loft = &nphy->cal_cache.txcal_coeffs_2G[5];
2457 } else { 2559 } else {
2458 if (nphy->iqcal_chanspec_5G == 0) 2560 if (b43_empty_chanspec(&nphy->iqcal_chanspec_5G))
2459 return; 2561 return;
2460 table = nphy->cal_cache.txcal_coeffs_5G; 2562 table = nphy->cal_cache.txcal_coeffs_5G;
2461 loft = &nphy->cal_cache.txcal_coeffs_5G[5]; 2563 loft = &nphy->cal_cache.txcal_coeffs_5G[5];
@@ -2700,8 +2802,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
2700 b43_ntab_read_bulk(dev, B43_NTAB16(15, 96), length, 2802 b43_ntab_read_bulk(dev, B43_NTAB16(15, 96), length,
2701 nphy->txiqlocal_bestc); 2803 nphy->txiqlocal_bestc);
2702 nphy->txiqlocal_coeffsvalid = true; 2804 nphy->txiqlocal_coeffsvalid = true;
2703 /* TODO: Set nphy->txiqlocal_chanspec to 2805 nphy->txiqlocal_chanspec = nphy->radio_chanspec;
2704 the current channel */
2705 } else { 2806 } else {
2706 length = 11; 2807 length = 11;
2707 if (dev->phy.rev < 3) 2808 if (dev->phy.rev < 3)
@@ -2736,7 +2837,8 @@ static void b43_nphy_reapply_tx_cal_coeffs(struct b43_wldev *dev)
2736 u16 buffer[7]; 2837 u16 buffer[7];
2737 bool equal = true; 2838 bool equal = true;
2738 2839
2739 if (!nphy->txiqlocal_coeffsvalid || 1 /* FIXME */) 2840 if (!nphy->txiqlocal_coeffsvalid ||
2841 b43_eq_chanspecs(&nphy->txiqlocal_chanspec, &nphy->radio_chanspec))
2740 return; 2842 return;
2741 2843
2742 b43_ntab_read_bulk(dev, B43_NTAB16(15, 80), 7, buffer); 2844 b43_ntab_read_bulk(dev, B43_NTAB16(15, 80), 7, buffer);
@@ -3091,9 +3193,11 @@ int b43_phy_initn(struct b43_wldev *dev)
3091 do_rssi_cal = false; 3193 do_rssi_cal = false;
3092 if (phy->rev >= 3) { 3194 if (phy->rev >= 3) {
3093 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) 3195 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
3094 do_rssi_cal = (nphy->rssical_chanspec_2G == 0); 3196 do_rssi_cal =
3197 b43_empty_chanspec(&nphy->rssical_chanspec_2G);
3095 else 3198 else
3096 do_rssi_cal = (nphy->rssical_chanspec_5G == 0); 3199 do_rssi_cal =
3200 b43_empty_chanspec(&nphy->rssical_chanspec_5G);
3097 3201
3098 if (do_rssi_cal) 3202 if (do_rssi_cal)
3099 b43_nphy_rssi_cal(dev); 3203 b43_nphy_rssi_cal(dev);
@@ -3105,9 +3209,9 @@ int b43_phy_initn(struct b43_wldev *dev)
3105 3209
3106 if (!((nphy->measure_hold & 0x6) != 0)) { 3210 if (!((nphy->measure_hold & 0x6) != 0)) {
3107 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) 3211 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
3108 do_cal = (nphy->iqcal_chanspec_2G == 0); 3212 do_cal = b43_empty_chanspec(&nphy->iqcal_chanspec_2G);
3109 else 3213 else
3110 do_cal = (nphy->iqcal_chanspec_5G == 0); 3214 do_cal = b43_empty_chanspec(&nphy->iqcal_chanspec_5G);
3111 3215
3112 if (nphy->mute) 3216 if (nphy->mute)
3113 do_cal = false; 3217 do_cal = false;
@@ -3116,7 +3220,7 @@ int b43_phy_initn(struct b43_wldev *dev)
3116 target = b43_nphy_get_tx_gains(dev); 3220 target = b43_nphy_get_tx_gains(dev);
3117 3221
3118 if (nphy->antsel_type == 2) 3222 if (nphy->antsel_type == 2)
3119 ;/*TODO NPHY Superswitch Init with argument 1*/ 3223 b43_nphy_superswitch_init(dev, true);
3120 if (nphy->perical != 2) { 3224 if (nphy->perical != 2) {
3121 b43_nphy_rssi_cal(dev); 3225 b43_nphy_rssi_cal(dev);
3122 if (phy->rev >= 3) { 3226 if (phy->rev >= 3) {
@@ -3154,6 +3258,129 @@ int b43_phy_initn(struct b43_wldev *dev)
3154 return 0; 3258 return 0;
3155} 3259}
3156 3260
3261/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ChanspecSetup */
3262static void b43_nphy_chanspec_setup(struct b43_wldev *dev,
3263 const struct b43_nphy_channeltab_entry *e,
3264 struct b43_chanspec chanspec)
3265{
3266 struct b43_phy *phy = &dev->phy;
3267 struct b43_phy_n *nphy = dev->phy.n;
3268
3269 u16 tmp;
3270 u32 tmp32;
3271
3272 tmp = b43_phy_read(dev, B43_NPHY_BANDCTL) & B43_NPHY_BANDCTL_5GHZ;
3273 if (chanspec.b_freq == 1 && tmp == 0) {
3274 tmp32 = b43_read32(dev, B43_MMIO_PSM_PHY_HDR);
3275 b43_write32(dev, B43_MMIO_PSM_PHY_HDR, tmp32 | 4);
3276 b43_phy_set(dev, B43_PHY_B_BBCFG, 0xC000);
3277 b43_write32(dev, B43_MMIO_PSM_PHY_HDR, tmp32);
3278 b43_phy_set(dev, B43_NPHY_BANDCTL, B43_NPHY_BANDCTL_5GHZ);
3279 } else if (chanspec.b_freq == 1) {
3280 b43_phy_mask(dev, B43_NPHY_BANDCTL, ~B43_NPHY_BANDCTL_5GHZ);
3281 tmp32 = b43_read32(dev, B43_MMIO_PSM_PHY_HDR);
3282 b43_write32(dev, B43_MMIO_PSM_PHY_HDR, tmp32 | 4);
3283 b43_phy_mask(dev, B43_PHY_B_BBCFG, (u16)~0xC000);
3284 b43_write32(dev, B43_MMIO_PSM_PHY_HDR, tmp32);
3285 }
3286
3287 b43_chantab_phy_upload(dev, e);
3288
3289 tmp = chanspec.channel;
3290 if (chanspec.b_freq == 1)
3291 tmp |= 0x0100;
3292 if (chanspec.b_width == 3)
3293 tmp |= 0x0200;
3294 b43_shm_write16(dev, B43_SHM_SHARED, 0xA0, tmp);
3295
3296 if (nphy->radio_chanspec.channel == 14) {
3297 b43_nphy_classifier(dev, 2, 0);
3298 b43_phy_set(dev, B43_PHY_B_TEST, 0x0800);
3299 } else {
3300 b43_nphy_classifier(dev, 2, 2);
3301 if (chanspec.b_freq == 2)
3302 b43_phy_mask(dev, B43_PHY_B_TEST, ~0x840);
3303 }
3304
3305 if (nphy->txpwrctrl)
3306 b43_nphy_tx_power_fix(dev);
3307
3308 if (dev->phy.rev < 3)
3309 b43_nphy_adjust_lna_gain_table(dev);
3310
3311 b43_nphy_tx_lp_fbw(dev);
3312
3313 if (dev->phy.rev >= 3 && 0) {
3314 /* TODO */
3315 }
3316
3317 b43_phy_write(dev, B43_NPHY_NDATAT_DUP40, 0x3830);
3318
3319 if (phy->rev >= 3)
3320 b43_nphy_spur_workaround(dev);
3321}
3322
3323/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SetChanspec */
3324static int b43_nphy_set_chanspec(struct b43_wldev *dev,
3325 struct b43_chanspec chanspec)
3326{
3327 struct b43_phy_n *nphy = dev->phy.n;
3328
3329 const struct b43_nphy_channeltab_entry *tabent;
3330
3331 u8 tmp;
3332 u8 channel = chanspec.channel;
3333
3334 if (dev->phy.rev >= 3) {
3335 /* TODO */
3336 }
3337
3338 nphy->radio_chanspec = chanspec;
3339
3340 if (chanspec.b_width != nphy->b_width)
3341 ; /* TODO: BMAC BW Set (chanspec.b_width) */
3342
3343 /* TODO: use defines */
3344 if (chanspec.b_width == 3) {
3345 if (chanspec.sideband == 2)
3346 b43_phy_set(dev, B43_NPHY_RXCTL,
3347 B43_NPHY_RXCTL_BSELU20);
3348 else
3349 b43_phy_mask(dev, B43_NPHY_RXCTL,
3350 ~B43_NPHY_RXCTL_BSELU20);
3351 }
3352
3353 if (dev->phy.rev >= 3) {
3354 tmp = (chanspec.b_freq == 1) ? 4 : 0;
3355 b43_radio_maskset(dev, 0x08, 0xFFFB, tmp);
3356 /* TODO: PHY Radio2056 Setup (chan_info_ptr[i]) */
3357 /* TODO: N PHY Chanspec Setup (chan_info_ptr[i]) */
3358 } else {
3359 tabent = b43_nphy_get_chantabent(dev, channel);
3360 if (!tabent)
3361 return -ESRCH;
3362
3363 tmp = (chanspec.b_freq == 1) ? 0x0020 : 0x0050;
3364 b43_radio_maskset(dev, B2055_MASTER1, 0xFF8F, tmp);
3365 b43_radio_2055_setup(dev, tabent);
3366 b43_nphy_chanspec_setup(dev, tabent, chanspec);
3367 }
3368
3369 return 0;
3370}
3371
3372/* Tune the hardware to a new channel */
3373static int nphy_channel_switch(struct b43_wldev *dev, unsigned int channel)
3374{
3375 struct b43_phy_n *nphy = dev->phy.n;
3376
3377 struct b43_chanspec chanspec;
3378 chanspec = nphy->radio_chanspec;
3379 chanspec.channel = channel;
3380
3381 return b43_nphy_set_chanspec(dev, chanspec);
3382}
3383
3157static int b43_nphy_op_allocate(struct b43_wldev *dev) 3384static int b43_nphy_op_allocate(struct b43_wldev *dev)
3158{ 3385{
3159 struct b43_phy_n *nphy; 3386 struct b43_phy_n *nphy;
@@ -3242,9 +3469,41 @@ static void b43_nphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
3242 b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value); 3469 b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
3243} 3470}
3244 3471
3472/* http://bcm-v4.sipsolutions.net/802.11/Radio/Switch%20Radio */
3245static void b43_nphy_op_software_rfkill(struct b43_wldev *dev, 3473static void b43_nphy_op_software_rfkill(struct b43_wldev *dev,
3246 bool blocked) 3474 bool blocked)
3247{//TODO 3475{
3476 if (b43_read32(dev, B43_MMIO_MACCTL) & B43_MACCTL_ENABLED)
3477 b43err(dev->wl, "MAC not suspended\n");
3478
3479 if (blocked) {
3480 b43_phy_mask(dev, B43_NPHY_RFCTL_CMD,
3481 ~B43_NPHY_RFCTL_CMD_CHIP0PU);
3482 if (dev->phy.rev >= 3) {
3483 b43_radio_mask(dev, 0x09, ~0x2);
3484
3485 b43_radio_write(dev, 0x204D, 0);
3486 b43_radio_write(dev, 0x2053, 0);
3487 b43_radio_write(dev, 0x2058, 0);
3488 b43_radio_write(dev, 0x205E, 0);
3489 b43_radio_mask(dev, 0x2062, ~0xF0);
3490 b43_radio_write(dev, 0x2064, 0);
3491
3492 b43_radio_write(dev, 0x304D, 0);
3493 b43_radio_write(dev, 0x3053, 0);
3494 b43_radio_write(dev, 0x3058, 0);
3495 b43_radio_write(dev, 0x305E, 0);
3496 b43_radio_mask(dev, 0x3062, ~0xF0);
3497 b43_radio_write(dev, 0x3064, 0);
3498 }
3499 } else {
3500 if (dev->phy.rev >= 3) {
3501 /* TODO: b43_radio_init2056(dev); */
3502 /* TODO: PHY Set Channel Spec (dev, radio_chanspec) */
3503 } else {
3504 b43_radio_init2055(dev);
3505 }
3506 }
3248} 3507}
3249 3508
3250static void b43_nphy_op_switch_analog(struct b43_wldev *dev, bool on) 3509static void b43_nphy_op_switch_analog(struct b43_wldev *dev, bool on)
diff --git a/drivers/net/wireless/b43/phy_n.h b/drivers/net/wireless/b43/phy_n.h
index 403aad3f894f..8b6d570dd0aa 100644
--- a/drivers/net/wireless/b43/phy_n.h
+++ b/drivers/net/wireless/b43/phy_n.h
@@ -711,6 +711,8 @@
711#define B43_NPHY_PAPD_EN1 B43_PHY_N(0x29B) /* PAPD Enable1 TBD */ 711#define B43_NPHY_PAPD_EN1 B43_PHY_N(0x29B) /* PAPD Enable1 TBD */
712#define B43_NPHY_EPS_TABLE_ADJ1 B43_PHY_N(0x29C) /* EPS Table Adj1 TBD */ 712#define B43_NPHY_EPS_TABLE_ADJ1 B43_PHY_N(0x29C) /* EPS Table Adj1 TBD */
713 713
714#define B43_PHY_B_BBCFG B43_PHY_N_BMODE(0x001) /* BB config */
715#define B43_PHY_B_TEST B43_PHY_N_BMODE(0x00A)
714 716
715 717
716/* Broadcom 2055 radio registers */ 718/* Broadcom 2055 radio registers */
@@ -924,6 +926,13 @@
924 926
925struct b43_wldev; 927struct b43_wldev;
926 928
929struct b43_chanspec {
930 u8 channel;
931 u8 sideband;
932 u8 b_width;
933 u8 b_freq;
934};
935
927struct b43_phy_n_iq_comp { 936struct b43_phy_n_iq_comp {
928 s16 a0; 937 s16 a0;
929 s16 b0; 938 s16 b0;
@@ -975,7 +984,8 @@ struct b43_phy_n {
975 u16 papd_epsilon_offset[2]; 984 u16 papd_epsilon_offset[2];
976 s32 preamble_override; 985 s32 preamble_override;
977 u32 bb_mult_save; 986 u32 bb_mult_save;
978 u16 radio_chanspec; 987 u8 b_width;
988 struct b43_chanspec radio_chanspec;
979 989
980 bool gain_boost; 990 bool gain_boost;
981 bool elna_gain_config; 991 bool elna_gain_config;
@@ -991,6 +1001,7 @@ struct b43_phy_n {
991 u16 txiqlocal_bestc[11]; 1001 u16 txiqlocal_bestc[11];
992 bool txiqlocal_coeffsvalid; 1002 bool txiqlocal_coeffsvalid;
993 struct b43_phy_n_txpwrindex txpwrindex[2]; 1003 struct b43_phy_n_txpwrindex txpwrindex[2];
1004 struct b43_chanspec txiqlocal_chanspec;
994 1005
995 u8 txrx_chain; 1006 u8 txrx_chain;
996 u16 tx_rx_cal_phy_saveregs[11]; 1007 u16 tx_rx_cal_phy_saveregs[11];
@@ -1006,12 +1017,12 @@ struct b43_phy_n {
1006 bool gband_spurwar_en; 1017 bool gband_spurwar_en;
1007 1018
1008 bool ipa2g_on; 1019 bool ipa2g_on;
1009 u8 iqcal_chanspec_2G; 1020 struct b43_chanspec iqcal_chanspec_2G;
1010 u8 rssical_chanspec_2G; 1021 struct b43_chanspec rssical_chanspec_2G;
1011 1022
1012 bool ipa5g_on; 1023 bool ipa5g_on;
1013 u8 iqcal_chanspec_5G; 1024 struct b43_chanspec iqcal_chanspec_5G;
1014 u8 rssical_chanspec_5G; 1025 struct b43_chanspec rssical_chanspec_5G;
1015 1026
1016 struct b43_phy_n_rssical_cache rssical_cache; 1027 struct b43_phy_n_rssical_cache rssical_cache;
1017 struct b43_phy_n_cal_cache cal_cache; 1028 struct b43_phy_n_cal_cache cal_cache;
diff --git a/drivers/net/wireless/b43/tables_nphy.h b/drivers/net/wireless/b43/tables_nphy.h
index 9c1c6ecd3672..b23036f7dc19 100644
--- a/drivers/net/wireless/b43/tables_nphy.h
+++ b/drivers/net/wireless/b43/tables_nphy.h
@@ -4,6 +4,15 @@
4#include <linux/types.h> 4#include <linux/types.h>
5 5
6 6
7struct b43_phy_n_sfo_cfg {
8 u16 phy_bw1a;
9 u16 phy_bw2;
10 u16 phy_bw3;
11 u16 phy_bw4;
12 u16 phy_bw5;
13 u16 phy_bw6;
14};
15
7struct b43_nphy_channeltab_entry { 16struct b43_nphy_channeltab_entry {
8 /* The channel number */ 17 /* The channel number */
9 u8 channel; 18 u8 channel;
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c
index 9b72c45a7748..fe63bf21c67e 100644
--- a/drivers/net/wireless/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/ipw2x00/ipw2100.c
@@ -6102,7 +6102,7 @@ static const struct net_device_ops ipw2100_netdev_ops = {
6102 .ndo_validate_addr = eth_validate_addr, 6102 .ndo_validate_addr = eth_validate_addr,
6103}; 6103};
6104 6104
6105/* Look into using netdev destructor to shutdown ieee80211? */ 6105/* Look into using netdev destructor to shutdown libipw? */
6106 6106
6107static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev, 6107static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6108 void __iomem * base_addr, 6108 void __iomem * base_addr,
@@ -6112,7 +6112,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6112 struct ipw2100_priv *priv; 6112 struct ipw2100_priv *priv;
6113 struct net_device *dev; 6113 struct net_device *dev;
6114 6114
6115 dev = alloc_ieee80211(sizeof(struct ipw2100_priv), 0); 6115 dev = alloc_libipw(sizeof(struct ipw2100_priv), 0);
6116 if (!dev) 6116 if (!dev)
6117 return NULL; 6117 return NULL;
6118 priv = libipw_priv(dev); 6118 priv = libipw_priv(dev);
@@ -6425,7 +6425,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6425 sysfs_remove_group(&pci_dev->dev.kobj, 6425 sysfs_remove_group(&pci_dev->dev.kobj,
6426 &ipw2100_attribute_group); 6426 &ipw2100_attribute_group);
6427 6427
6428 free_ieee80211(dev, 0); 6428 free_libipw(dev, 0);
6429 pci_set_drvdata(pci_dev, NULL); 6429 pci_set_drvdata(pci_dev, NULL);
6430 } 6430 }
6431 6431
@@ -6483,10 +6483,10 @@ static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev)
6483 if (dev->base_addr) 6483 if (dev->base_addr)
6484 iounmap((void __iomem *)dev->base_addr); 6484 iounmap((void __iomem *)dev->base_addr);
6485 6485
6486 /* wiphy_unregister needs to be here, before free_ieee80211 */ 6486 /* wiphy_unregister needs to be here, before free_libipw */
6487 wiphy_unregister(priv->ieee->wdev.wiphy); 6487 wiphy_unregister(priv->ieee->wdev.wiphy);
6488 kfree(priv->ieee->bg_band.channels); 6488 kfree(priv->ieee->bg_band.channels);
6489 free_ieee80211(dev, 0); 6489 free_libipw(dev, 0);
6490 } 6490 }
6491 6491
6492 pci_release_regions(pci_dev); 6492 pci_release_regions(pci_dev);
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 5c7aa1b1eb56..cb3ba134865e 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -9995,49 +9995,48 @@ static int ipw_wx_sw_reset(struct net_device *dev,
9995} 9995}
9996 9996
9997/* Rebase the WE IOCTLs to zero for the handler array */ 9997/* Rebase the WE IOCTLs to zero for the handler array */
9998#define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT]
9999static iw_handler ipw_wx_handlers[] = { 9998static iw_handler ipw_wx_handlers[] = {
10000 IW_IOCTL(SIOCGIWNAME) = (iw_handler) cfg80211_wext_giwname, 9999 IW_HANDLER(SIOCGIWNAME, (iw_handler)cfg80211_wext_giwname),
10001 IW_IOCTL(SIOCSIWFREQ) = ipw_wx_set_freq, 10000 IW_HANDLER(SIOCSIWFREQ, ipw_wx_set_freq),
10002 IW_IOCTL(SIOCGIWFREQ) = ipw_wx_get_freq, 10001 IW_HANDLER(SIOCGIWFREQ, ipw_wx_get_freq),
10003 IW_IOCTL(SIOCSIWMODE) = ipw_wx_set_mode, 10002 IW_HANDLER(SIOCSIWMODE, ipw_wx_set_mode),
10004 IW_IOCTL(SIOCGIWMODE) = ipw_wx_get_mode, 10003 IW_HANDLER(SIOCGIWMODE, ipw_wx_get_mode),
10005 IW_IOCTL(SIOCSIWSENS) = ipw_wx_set_sens, 10004 IW_HANDLER(SIOCSIWSENS, ipw_wx_set_sens),
10006 IW_IOCTL(SIOCGIWSENS) = ipw_wx_get_sens, 10005 IW_HANDLER(SIOCGIWSENS, ipw_wx_get_sens),
10007 IW_IOCTL(SIOCGIWRANGE) = ipw_wx_get_range, 10006 IW_HANDLER(SIOCGIWRANGE, ipw_wx_get_range),
10008 IW_IOCTL(SIOCSIWAP) = ipw_wx_set_wap, 10007 IW_HANDLER(SIOCSIWAP, ipw_wx_set_wap),
10009 IW_IOCTL(SIOCGIWAP) = ipw_wx_get_wap, 10008 IW_HANDLER(SIOCGIWAP, ipw_wx_get_wap),
10010 IW_IOCTL(SIOCSIWSCAN) = ipw_wx_set_scan, 10009 IW_HANDLER(SIOCSIWSCAN, ipw_wx_set_scan),
10011 IW_IOCTL(SIOCGIWSCAN) = ipw_wx_get_scan, 10010 IW_HANDLER(SIOCGIWSCAN, ipw_wx_get_scan),
10012 IW_IOCTL(SIOCSIWESSID) = ipw_wx_set_essid, 10011 IW_HANDLER(SIOCSIWESSID, ipw_wx_set_essid),
10013 IW_IOCTL(SIOCGIWESSID) = ipw_wx_get_essid, 10012 IW_HANDLER(SIOCGIWESSID, ipw_wx_get_essid),
10014 IW_IOCTL(SIOCSIWNICKN) = ipw_wx_set_nick, 10013 IW_HANDLER(SIOCSIWNICKN, ipw_wx_set_nick),
10015 IW_IOCTL(SIOCGIWNICKN) = ipw_wx_get_nick, 10014 IW_HANDLER(SIOCGIWNICKN, ipw_wx_get_nick),
10016 IW_IOCTL(SIOCSIWRATE) = ipw_wx_set_rate, 10015 IW_HANDLER(SIOCSIWRATE, ipw_wx_set_rate),
10017 IW_IOCTL(SIOCGIWRATE) = ipw_wx_get_rate, 10016 IW_HANDLER(SIOCGIWRATE, ipw_wx_get_rate),
10018 IW_IOCTL(SIOCSIWRTS) = ipw_wx_set_rts, 10017 IW_HANDLER(SIOCSIWRTS, ipw_wx_set_rts),
10019 IW_IOCTL(SIOCGIWRTS) = ipw_wx_get_rts, 10018 IW_HANDLER(SIOCGIWRTS, ipw_wx_get_rts),
10020 IW_IOCTL(SIOCSIWFRAG) = ipw_wx_set_frag, 10019 IW_HANDLER(SIOCSIWFRAG, ipw_wx_set_frag),
10021 IW_IOCTL(SIOCGIWFRAG) = ipw_wx_get_frag, 10020 IW_HANDLER(SIOCGIWFRAG, ipw_wx_get_frag),
10022 IW_IOCTL(SIOCSIWTXPOW) = ipw_wx_set_txpow, 10021 IW_HANDLER(SIOCSIWTXPOW, ipw_wx_set_txpow),
10023 IW_IOCTL(SIOCGIWTXPOW) = ipw_wx_get_txpow, 10022 IW_HANDLER(SIOCGIWTXPOW, ipw_wx_get_txpow),
10024 IW_IOCTL(SIOCSIWRETRY) = ipw_wx_set_retry, 10023 IW_HANDLER(SIOCSIWRETRY, ipw_wx_set_retry),
10025 IW_IOCTL(SIOCGIWRETRY) = ipw_wx_get_retry, 10024 IW_HANDLER(SIOCGIWRETRY, ipw_wx_get_retry),
10026 IW_IOCTL(SIOCSIWENCODE) = ipw_wx_set_encode, 10025 IW_HANDLER(SIOCSIWENCODE, ipw_wx_set_encode),
10027 IW_IOCTL(SIOCGIWENCODE) = ipw_wx_get_encode, 10026 IW_HANDLER(SIOCGIWENCODE, ipw_wx_get_encode),
10028 IW_IOCTL(SIOCSIWPOWER) = ipw_wx_set_power, 10027 IW_HANDLER(SIOCSIWPOWER, ipw_wx_set_power),
10029 IW_IOCTL(SIOCGIWPOWER) = ipw_wx_get_power, 10028 IW_HANDLER(SIOCGIWPOWER, ipw_wx_get_power),
10030 IW_IOCTL(SIOCSIWSPY) = iw_handler_set_spy, 10029 IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy),
10031 IW_IOCTL(SIOCGIWSPY) = iw_handler_get_spy, 10030 IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy),
10032 IW_IOCTL(SIOCSIWTHRSPY) = iw_handler_set_thrspy, 10031 IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy),
10033 IW_IOCTL(SIOCGIWTHRSPY) = iw_handler_get_thrspy, 10032 IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy),
10034 IW_IOCTL(SIOCSIWGENIE) = ipw_wx_set_genie, 10033 IW_HANDLER(SIOCSIWGENIE, ipw_wx_set_genie),
10035 IW_IOCTL(SIOCGIWGENIE) = ipw_wx_get_genie, 10034 IW_HANDLER(SIOCGIWGENIE, ipw_wx_get_genie),
10036 IW_IOCTL(SIOCSIWMLME) = ipw_wx_set_mlme, 10035 IW_HANDLER(SIOCSIWMLME, ipw_wx_set_mlme),
10037 IW_IOCTL(SIOCSIWAUTH) = ipw_wx_set_auth, 10036 IW_HANDLER(SIOCSIWAUTH, ipw_wx_set_auth),
10038 IW_IOCTL(SIOCGIWAUTH) = ipw_wx_get_auth, 10037 IW_HANDLER(SIOCGIWAUTH, ipw_wx_get_auth),
10039 IW_IOCTL(SIOCSIWENCODEEXT) = ipw_wx_set_encodeext, 10038 IW_HANDLER(SIOCSIWENCODEEXT, ipw_wx_set_encodeext),
10040 IW_IOCTL(SIOCGIWENCODEEXT) = ipw_wx_get_encodeext, 10039 IW_HANDLER(SIOCGIWENCODEEXT, ipw_wx_get_encodeext),
10041}; 10040};
10042 10041
10043enum { 10042enum {
@@ -11666,7 +11665,7 @@ static int ipw_prom_alloc(struct ipw_priv *priv)
11666 if (priv->prom_net_dev) 11665 if (priv->prom_net_dev)
11667 return -EPERM; 11666 return -EPERM;
11668 11667
11669 priv->prom_net_dev = alloc_ieee80211(sizeof(struct ipw_prom_priv), 1); 11668 priv->prom_net_dev = alloc_libipw(sizeof(struct ipw_prom_priv), 1);
11670 if (priv->prom_net_dev == NULL) 11669 if (priv->prom_net_dev == NULL)
11671 return -ENOMEM; 11670 return -ENOMEM;
11672 11671
@@ -11685,7 +11684,7 @@ static int ipw_prom_alloc(struct ipw_priv *priv)
11685 11684
11686 rc = register_netdev(priv->prom_net_dev); 11685 rc = register_netdev(priv->prom_net_dev);
11687 if (rc) { 11686 if (rc) {
11688 free_ieee80211(priv->prom_net_dev, 1); 11687 free_libipw(priv->prom_net_dev, 1);
11689 priv->prom_net_dev = NULL; 11688 priv->prom_net_dev = NULL;
11690 return rc; 11689 return rc;
11691 } 11690 }
@@ -11699,7 +11698,7 @@ static void ipw_prom_free(struct ipw_priv *priv)
11699 return; 11698 return;
11700 11699
11701 unregister_netdev(priv->prom_net_dev); 11700 unregister_netdev(priv->prom_net_dev);
11702 free_ieee80211(priv->prom_net_dev, 1); 11701 free_libipw(priv->prom_net_dev, 1);
11703 11702
11704 priv->prom_net_dev = NULL; 11703 priv->prom_net_dev = NULL;
11705} 11704}
@@ -11727,7 +11726,7 @@ static int __devinit ipw_pci_probe(struct pci_dev *pdev,
11727 struct ipw_priv *priv; 11726 struct ipw_priv *priv;
11728 int i; 11727 int i;
11729 11728
11730 net_dev = alloc_ieee80211(sizeof(struct ipw_priv), 0); 11729 net_dev = alloc_libipw(sizeof(struct ipw_priv), 0);
11731 if (net_dev == NULL) { 11730 if (net_dev == NULL) {
11732 err = -ENOMEM; 11731 err = -ENOMEM;
11733 goto out; 11732 goto out;
@@ -11747,7 +11746,7 @@ static int __devinit ipw_pci_probe(struct pci_dev *pdev,
11747 mutex_init(&priv->mutex); 11746 mutex_init(&priv->mutex);
11748 if (pci_enable_device(pdev)) { 11747 if (pci_enable_device(pdev)) {
11749 err = -ENODEV; 11748 err = -ENODEV;
11750 goto out_free_ieee80211; 11749 goto out_free_libipw;
11751 } 11750 }
11752 11751
11753 pci_set_master(pdev); 11752 pci_set_master(pdev);
@@ -11874,8 +11873,8 @@ static int __devinit ipw_pci_probe(struct pci_dev *pdev,
11874 out_pci_disable_device: 11873 out_pci_disable_device:
11875 pci_disable_device(pdev); 11874 pci_disable_device(pdev);
11876 pci_set_drvdata(pdev, NULL); 11875 pci_set_drvdata(pdev, NULL);
11877 out_free_ieee80211: 11876 out_free_libipw:
11878 free_ieee80211(priv->net_dev, 0); 11877 free_libipw(priv->net_dev, 0);
11879 out: 11878 out:
11880 return err; 11879 return err;
11881} 11880}
@@ -11942,11 +11941,11 @@ static void __devexit ipw_pci_remove(struct pci_dev *pdev)
11942 pci_release_regions(pdev); 11941 pci_release_regions(pdev);
11943 pci_disable_device(pdev); 11942 pci_disable_device(pdev);
11944 pci_set_drvdata(pdev, NULL); 11943 pci_set_drvdata(pdev, NULL);
11945 /* wiphy_unregister needs to be here, before free_ieee80211 */ 11944 /* wiphy_unregister needs to be here, before free_libipw */
11946 wiphy_unregister(priv->ieee->wdev.wiphy); 11945 wiphy_unregister(priv->ieee->wdev.wiphy);
11947 kfree(priv->ieee->a_band.channels); 11946 kfree(priv->ieee->a_band.channels);
11948 kfree(priv->ieee->bg_band.channels); 11947 kfree(priv->ieee->bg_band.channels);
11949 free_ieee80211(priv->net_dev, 0); 11948 free_libipw(priv->net_dev, 0);
11950 free_firmware(); 11949 free_firmware();
11951} 11950}
11952 11951
diff --git a/drivers/net/wireless/ipw2x00/libipw.h b/drivers/net/wireless/ipw2x00/libipw.h
index a6d5e42647e4..284b0e4cb815 100644
--- a/drivers/net/wireless/ipw2x00/libipw.h
+++ b/drivers/net/wireless/ipw2x00/libipw.h
@@ -64,7 +64,7 @@
64extern u32 libipw_debug_level; 64extern u32 libipw_debug_level;
65#define LIBIPW_DEBUG(level, fmt, args...) \ 65#define LIBIPW_DEBUG(level, fmt, args...) \
66do { if (libipw_debug_level & (level)) \ 66do { if (libipw_debug_level & (level)) \
67 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \ 67 printk(KERN_DEBUG "libipw: %c %s " fmt, \
68 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0) 68 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
69static inline bool libipw_ratelimit_debug(u32 level) 69static inline bool libipw_ratelimit_debug(u32 level)
70{ 70{
@@ -116,8 +116,8 @@ static inline bool libipw_ratelimit_debug(u32 level)
116#define LIBIPW_DL_RX (1<<9) 116#define LIBIPW_DL_RX (1<<9)
117#define LIBIPW_DL_QOS (1<<31) 117#define LIBIPW_DL_QOS (1<<31)
118 118
119#define LIBIPW_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a) 119#define LIBIPW_ERROR(f, a...) printk(KERN_ERR "libipw: " f, ## a)
120#define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a) 120#define LIBIPW_WARNING(f, a...) printk(KERN_WARNING "libipw: " f, ## a)
121#define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a) 121#define LIBIPW_DEBUG_INFO(f, a...) LIBIPW_DEBUG(LIBIPW_DL_INFO, f, ## a)
122 122
123#define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a) 123#define LIBIPW_DEBUG_WX(f, a...) LIBIPW_DEBUG(LIBIPW_DL_WX, f, ## a)
@@ -905,7 +905,7 @@ struct libipw_device {
905 struct libipw_reassoc_request * req); 905 struct libipw_reassoc_request * req);
906 906
907 /* This must be the last item so that it points to the data 907 /* This must be the last item so that it points to the data
908 * allocated beyond this structure by alloc_ieee80211 */ 908 * allocated beyond this structure by alloc_libipw */
909 u8 priv[0]; 909 u8 priv[0];
910}; 910};
911 911
@@ -1017,9 +1017,9 @@ static inline int libipw_is_cck_rate(u8 rate)
1017 return 0; 1017 return 0;
1018} 1018}
1019 1019
1020/* ieee80211.c */ 1020/* libipw.c */
1021extern void free_ieee80211(struct net_device *dev, int monitor); 1021extern void free_libipw(struct net_device *dev, int monitor);
1022extern struct net_device *alloc_ieee80211(int sizeof_priv, int monitor); 1022extern struct net_device *alloc_libipw(int sizeof_priv, int monitor);
1023extern int libipw_change_mtu(struct net_device *dev, int new_mtu); 1023extern int libipw_change_mtu(struct net_device *dev, int new_mtu);
1024 1024
1025extern void libipw_networks_age(struct libipw_device *ieee, 1025extern void libipw_networks_age(struct libipw_device *ieee,
diff --git a/drivers/net/wireless/ipw2x00/libipw_module.c b/drivers/net/wireless/ipw2x00/libipw_module.c
index 2fa55867bd8b..55965408ff3f 100644
--- a/drivers/net/wireless/ipw2x00/libipw_module.c
+++ b/drivers/net/wireless/ipw2x00/libipw_module.c
@@ -53,7 +53,7 @@
53#include "libipw.h" 53#include "libipw.h"
54 54
55#define DRV_DESCRIPTION "802.11 data/management/control stack" 55#define DRV_DESCRIPTION "802.11 data/management/control stack"
56#define DRV_NAME "ieee80211" 56#define DRV_NAME "libipw"
57#define DRV_VERSION LIBIPW_VERSION 57#define DRV_VERSION LIBIPW_VERSION
58#define DRV_COPYRIGHT "Copyright (C) 2004-2005 Intel Corporation <jketreno@linux.intel.com>" 58#define DRV_COPYRIGHT "Copyright (C) 2004-2005 Intel Corporation <jketreno@linux.intel.com>"
59 59
@@ -140,7 +140,7 @@ int libipw_change_mtu(struct net_device *dev, int new_mtu)
140} 140}
141EXPORT_SYMBOL(libipw_change_mtu); 141EXPORT_SYMBOL(libipw_change_mtu);
142 142
143struct net_device *alloc_ieee80211(int sizeof_priv, int monitor) 143struct net_device *alloc_libipw(int sizeof_priv, int monitor)
144{ 144{
145 struct libipw_device *ieee; 145 struct libipw_device *ieee;
146 struct net_device *dev; 146 struct net_device *dev;
@@ -222,8 +222,9 @@ failed_free_netdev:
222failed: 222failed:
223 return NULL; 223 return NULL;
224} 224}
225EXPORT_SYMBOL(alloc_libipw);
225 226
226void free_ieee80211(struct net_device *dev, int monitor) 227void free_libipw(struct net_device *dev, int monitor)
227{ 228{
228 struct libipw_device *ieee = netdev_priv(dev); 229 struct libipw_device *ieee = netdev_priv(dev);
229 230
@@ -237,6 +238,7 @@ void free_ieee80211(struct net_device *dev, int monitor)
237 238
238 free_netdev(dev); 239 free_netdev(dev);
239} 240}
241EXPORT_SYMBOL(free_libipw);
240 242
241#ifdef CONFIG_LIBIPW_DEBUG 243#ifdef CONFIG_LIBIPW_DEBUG
242 244
@@ -291,7 +293,7 @@ static int __init libipw_init(void)
291 struct proc_dir_entry *e; 293 struct proc_dir_entry *e;
292 294
293 libipw_debug_level = debug; 295 libipw_debug_level = debug;
294 libipw_proc = proc_mkdir(DRV_NAME, init_net.proc_net); 296 libipw_proc = proc_mkdir("ieee80211", init_net.proc_net);
295 if (libipw_proc == NULL) { 297 if (libipw_proc == NULL) {
296 LIBIPW_ERROR("Unable to create " DRV_NAME 298 LIBIPW_ERROR("Unable to create " DRV_NAME
297 " proc directory\n"); 299 " proc directory\n");
@@ -331,6 +333,3 @@ MODULE_PARM_DESC(debug, "debug output mask");
331 333
332module_exit(libipw_exit); 334module_exit(libipw_exit);
333module_init(libipw_init); 335module_init(libipw_init);
334
335EXPORT_SYMBOL(alloc_ieee80211);
336EXPORT_SYMBOL(free_ieee80211);
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index 4e378faee650..e31a5ccebea2 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -9,7 +9,7 @@ CFLAGS_iwl-devtrace.o := -I$(src)
9 9
10# AGN 10# AGN
11obj-$(CONFIG_IWLAGN) += iwlagn.o 11obj-$(CONFIG_IWLAGN) += iwlagn.o
12iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-led.o 12iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-led.o iwl-agn-ict.o
13 13
14iwlagn-$(CONFIG_IWL4965) += iwl-4965.o 14iwlagn-$(CONFIG_IWL4965) += iwl-4965.o
15iwlagn-$(CONFIG_IWL5000) += iwl-5000.o 15iwlagn-$(CONFIG_IWL5000) += iwl-5000.o
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index 3bf2e6e9b2d9..9e392896005d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -42,6 +42,7 @@
42#include "iwl-core.h" 42#include "iwl-core.h"
43#include "iwl-io.h" 43#include "iwl-io.h"
44#include "iwl-sta.h" 44#include "iwl-sta.h"
45#include "iwl-agn.h"
45#include "iwl-helpers.h" 46#include "iwl-helpers.h"
46#include "iwl-5000-hw.h" 47#include "iwl-5000-hw.h"
47#include "iwl-agn-led.h" 48#include "iwl-agn-led.h"
@@ -211,6 +212,9 @@ static struct iwl_lib_ops iwl1000_lib = {
211 .set_ct_kill = iwl1000_set_ct_threshold, 212 .set_ct_kill = iwl1000_set_ct_threshold,
212 }, 213 },
213 .add_bcast_station = iwl_add_bcast_station, 214 .add_bcast_station = iwl_add_bcast_station,
215 .recover_from_tx_stall = iwl_bg_monitor_recover,
216 .check_plcp_health = iwl_good_plcp_health,
217 .check_ack_health = iwl_good_ack_health,
214}; 218};
215 219
216static const struct iwl_ops iwl1000_ops = { 220static const struct iwl_ops iwl1000_ops = {
@@ -222,7 +226,7 @@ static const struct iwl_ops iwl1000_ops = {
222}; 226};
223 227
224struct iwl_cfg iwl1000_bgn_cfg = { 228struct iwl_cfg iwl1000_bgn_cfg = {
225 .name = "1000 Series BGN", 229 .name = "Intel(R) Centrino(R) Wireless-N 1000 BGN",
226 .fw_name_pre = IWL1000_FW_PRE, 230 .fw_name_pre = IWL1000_FW_PRE,
227 .ucode_api_max = IWL1000_UCODE_API_MAX, 231 .ucode_api_max = IWL1000_UCODE_API_MAX,
228 .ucode_api_min = IWL1000_UCODE_API_MIN, 232 .ucode_api_min = IWL1000_UCODE_API_MIN,
@@ -248,10 +252,11 @@ struct iwl_cfg iwl1000_bgn_cfg = {
248 .support_ct_kill_exit = true, 252 .support_ct_kill_exit = true,
249 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF, 253 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
250 .chain_noise_scale = 1000, 254 .chain_noise_scale = 1000,
255 .monitor_recover_period = IWL_MONITORING_PERIOD,
251}; 256};
252 257
253struct iwl_cfg iwl1000_bg_cfg = { 258struct iwl_cfg iwl1000_bg_cfg = {
254 .name = "1000 Series BG", 259 .name = "Intel(R) Centrino(R) Wireless-N 1000 BG",
255 .fw_name_pre = IWL1000_FW_PRE, 260 .fw_name_pre = IWL1000_FW_PRE,
256 .ucode_api_max = IWL1000_UCODE_API_MAX, 261 .ucode_api_max = IWL1000_UCODE_API_MAX,
257 .ucode_api_min = IWL1000_UCODE_API_MIN, 262 .ucode_api_min = IWL1000_UCODE_API_MIN,
@@ -276,6 +281,7 @@ struct iwl_cfg iwl1000_bg_cfg = {
276 .support_ct_kill_exit = true, 281 .support_ct_kill_exit = true,
277 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF, 282 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
278 .chain_noise_scale = 1000, 283 .chain_noise_scale = 1000,
284 .monitor_recover_period = IWL_MONITORING_PERIOD,
279}; 285};
280 286
281MODULE_FIRMWARE(IWL1000_MODULE_FIRMWARE(IWL1000_UCODE_API_MAX)); 287MODULE_FIRMWARE(IWL1000_MODULE_FIRMWARE(IWL1000_UCODE_API_MAX));
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
index 3a876a8ece38..074f42a7dcad 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
@@ -78,6 +78,8 @@
78/* RSSI to dBm */ 78/* RSSI to dBm */
79#define IWL39_RSSI_OFFSET 95 79#define IWL39_RSSI_OFFSET 95
80 80
81#define IWL_DEFAULT_TX_POWER 0x0F
82
81/* 83/*
82 * EEPROM related constants, enums, and structures. 84 * EEPROM related constants, enums, and structures.
83 */ 85 */
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index 47909f94271e..605aca4c78c8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -329,16 +329,25 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta,
329 329
330} 330}
331 331
332static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, 332/*
333 struct ieee80211_sta *sta, void *priv_sta) 333 * Called after adding a new station to initialize rate scaling
334 */
335void iwl3945_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_id)
334{ 336{
335 struct iwl3945_rs_sta *rs_sta = priv_sta; 337 struct ieee80211_hw *hw = priv->hw;
336 struct iwl_priv *priv = (struct iwl_priv *)priv_r; 338 struct ieee80211_conf *conf = &priv->hw->conf;
339 struct iwl3945_sta_priv *psta;
340 struct iwl3945_rs_sta *rs_sta;
341 struct ieee80211_supported_band *sband;
337 int i; 342 int i;
338 343
339 IWL_DEBUG_RATE(priv, "enter\n"); 344 IWL_DEBUG_INFO(priv, "enter \n");
345 if (sta_id == priv->hw_params.bcast_sta_id)
346 goto out;
340 347
341 spin_lock_init(&rs_sta->lock); 348 psta = (struct iwl3945_sta_priv *) sta->drv_priv;
349 rs_sta = &psta->rs_sta;
350 sband = hw->wiphy->bands[conf->channel->band];
342 351
343 rs_sta->priv = priv; 352 rs_sta->priv = priv;
344 353
@@ -351,9 +360,7 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
351 rs_sta->last_flush = jiffies; 360 rs_sta->last_flush = jiffies;
352 rs_sta->flush_time = IWL_RATE_FLUSH; 361 rs_sta->flush_time = IWL_RATE_FLUSH;
353 rs_sta->last_tx_packets = 0; 362 rs_sta->last_tx_packets = 0;
354 rs_sta->ibss_sta_added = 0;
355 363
356 init_timer(&rs_sta->rate_scale_flush);
357 rs_sta->rate_scale_flush.data = (unsigned long)rs_sta; 364 rs_sta->rate_scale_flush.data = (unsigned long)rs_sta;
358 rs_sta->rate_scale_flush.function = iwl3945_bg_rate_scale_flush; 365 rs_sta->rate_scale_flush.function = iwl3945_bg_rate_scale_flush;
359 366
@@ -372,16 +379,18 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
372 } 379 }
373 } 380 }
374 381
375 priv->sta_supp_rates = sta->supp_rates[sband->band]; 382 priv->_3945.sta_supp_rates = sta->supp_rates[sband->band];
376 /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */ 383 /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */
377 if (sband->band == IEEE80211_BAND_5GHZ) { 384 if (sband->band == IEEE80211_BAND_5GHZ) {
378 rs_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; 385 rs_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE;
379 priv->sta_supp_rates = priv->sta_supp_rates << 386 priv->_3945.sta_supp_rates = priv->_3945.sta_supp_rates <<
380 IWL_FIRST_OFDM_RATE; 387 IWL_FIRST_OFDM_RATE;
381 } 388 }
382 389
390out:
391 priv->stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
383 392
384 IWL_DEBUG_RATE(priv, "leave\n"); 393 IWL_DEBUG_INFO(priv, "leave\n");
385} 394}
386 395
387static void *rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) 396static void *rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
@@ -405,6 +414,9 @@ static void *rs_alloc_sta(void *iwl_priv, struct ieee80211_sta *sta, gfp_t gfp)
405 414
406 rs_sta = &psta->rs_sta; 415 rs_sta = &psta->rs_sta;
407 416
417 spin_lock_init(&rs_sta->lock);
418 init_timer(&rs_sta->rate_scale_flush);
419
408 IWL_DEBUG_RATE(priv, "leave\n"); 420 IWL_DEBUG_RATE(priv, "leave\n");
409 421
410 return rs_sta; 422 return rs_sta;
@@ -413,13 +425,14 @@ static void *rs_alloc_sta(void *iwl_priv, struct ieee80211_sta *sta, gfp_t gfp)
413static void rs_free_sta(void *iwl_priv, struct ieee80211_sta *sta, 425static void rs_free_sta(void *iwl_priv, struct ieee80211_sta *sta,
414 void *priv_sta) 426 void *priv_sta)
415{ 427{
416 struct iwl3945_sta_priv *psta = (void *) sta->drv_priv; 428 struct iwl3945_rs_sta *rs_sta = priv_sta;
417 struct iwl3945_rs_sta *rs_sta = &psta->rs_sta;
418 struct iwl_priv *priv __maybe_unused = rs_sta->priv;
419 429
420 IWL_DEBUG_RATE(priv, "enter\n"); 430 /*
431 * Be careful not to use any members of iwl3945_rs_sta (like trying
432 * to use iwl_priv to print out debugging) since it may not be fully
433 * initialized at this point.
434 */
421 del_timer_sync(&rs_sta->rate_scale_flush); 435 del_timer_sync(&rs_sta->rate_scale_flush);
422 IWL_DEBUG_RATE(priv, "leave\n");
423} 436}
424 437
425 438
@@ -458,6 +471,13 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
458 return; 471 return;
459 } 472 }
460 473
474 /* Treat uninitialized rate scaling data same as non-existing. */
475 if (!rs_sta->priv) {
476 IWL_DEBUG_RATE(priv, "leave: STA priv data uninitialized!\n");
477 return;
478 }
479
480
461 rs_sta->tx_packets++; 481 rs_sta->tx_packets++;
462 482
463 scale_rate_index = first_index; 483 scale_rate_index = first_index;
@@ -625,7 +645,6 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
625 u32 fail_count; 645 u32 fail_count;
626 s8 scale_action = 0; 646 s8 scale_action = 0;
627 unsigned long flags; 647 unsigned long flags;
628 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
629 u16 rate_mask = sta ? sta->supp_rates[sband->band] : 0; 648 u16 rate_mask = sta ? sta->supp_rates[sband->band] : 0;
630 s8 max_rate_idx = -1; 649 s8 max_rate_idx = -1;
631 struct iwl_priv *priv = (struct iwl_priv *)priv_r; 650 struct iwl_priv *priv = (struct iwl_priv *)priv_r;
@@ -633,6 +652,12 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
633 652
634 IWL_DEBUG_RATE(priv, "enter\n"); 653 IWL_DEBUG_RATE(priv, "enter\n");
635 654
655 /* Treat uninitialized rate scaling data same as non-existing. */
656 if (rs_sta && !rs_sta->priv) {
657 IWL_DEBUG_RATE(priv, "Rate scaling information not initialized yet.\n");
658 priv_sta = NULL;
659 }
660
636 if (rate_control_send_low(sta, priv_sta, txrc)) 661 if (rate_control_send_low(sta, priv_sta, txrc))
637 return; 662 return;
638 663
@@ -650,20 +675,6 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
650 if (sband->band == IEEE80211_BAND_5GHZ) 675 if (sband->band == IEEE80211_BAND_5GHZ)
651 rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; 676 rate_mask = rate_mask << IWL_FIRST_OFDM_RATE;
652 677
653 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
654 !rs_sta->ibss_sta_added) {
655 u8 sta_id = iwl_find_station(priv, hdr->addr1);
656
657 if (sta_id == IWL_INVALID_STATION) {
658 IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n",
659 hdr->addr1);
660 sta_id = iwl_add_station(priv, hdr->addr1, false,
661 CMD_ASYNC, NULL);
662 }
663 if (sta_id != IWL_INVALID_STATION)
664 rs_sta->ibss_sta_added = 1;
665 }
666
667 spin_lock_irqsave(&rs_sta->lock, flags); 678 spin_lock_irqsave(&rs_sta->lock, flags);
668 679
669 /* for recent assoc, choose best rate regarding 680 /* for recent assoc, choose best rate regarding
@@ -883,12 +894,22 @@ static void iwl3945_remove_debugfs(void *priv, void *priv_sta)
883} 894}
884#endif 895#endif
885 896
897/*
898 * Initialization of rate scaling information is done by driver after
899 * the station is added. Since mac80211 calls this function before a
900 * station is added we ignore it.
901 */
902static void rs_rate_init_stub(void *priv_r, struct ieee80211_supported_band *sband,
903 struct ieee80211_sta *sta, void *priv_sta)
904{
905}
906
886static struct rate_control_ops rs_ops = { 907static struct rate_control_ops rs_ops = {
887 .module = NULL, 908 .module = NULL,
888 .name = RS_NAME, 909 .name = RS_NAME,
889 .tx_status = rs_tx_status, 910 .tx_status = rs_tx_status,
890 .get_rate = rs_get_rate, 911 .get_rate = rs_get_rate,
891 .rate_init = rs_rate_init, 912 .rate_init = rs_rate_init_stub,
892 .alloc = rs_alloc, 913 .alloc = rs_alloc,
893 .free = rs_free, 914 .free = rs_free,
894 .alloc_sta = rs_alloc_sta, 915 .alloc_sta = rs_alloc_sta,
@@ -899,7 +920,6 @@ static struct rate_control_ops rs_ops = {
899#endif 920#endif
900 921
901}; 922};
902
903void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) 923void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
904{ 924{
905 struct iwl_priv *priv = hw->priv; 925 struct iwl_priv *priv = hw->priv;
@@ -916,6 +936,7 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
916 sta = ieee80211_find_sta(priv->vif, 936 sta = ieee80211_find_sta(priv->vif,
917 priv->stations[sta_id].sta.sta.addr); 937 priv->stations[sta_id].sta.sta.addr);
918 if (!sta) { 938 if (!sta) {
939 IWL_DEBUG_RATE(priv, "Unable to find station to initialize rate scaling.\n");
919 rcu_read_unlock(); 940 rcu_read_unlock();
920 return; 941 return;
921 } 942 }
@@ -946,7 +967,7 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
946 967
947 spin_unlock_irqrestore(&rs_sta->lock, flags); 968 spin_unlock_irqrestore(&rs_sta->lock, flags);
948 969
949 rssi = priv->last_rx_rssi; 970 rssi = priv->_3945.last_rx_rssi;
950 if (rssi == 0) 971 if (rssi == 0)
951 rssi = IWL_MIN_RSSI_VAL; 972 rssi = IWL_MIN_RSSI_VAL;
952 973
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index e0678d921055..3b5889d8d662 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -242,7 +242,7 @@ int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate)
242 next_rate = IWL_RATE_6M_INDEX; 242 next_rate = IWL_RATE_6M_INDEX;
243 break; 243 break;
244 case IEEE80211_BAND_2GHZ: 244 case IEEE80211_BAND_2GHZ:
245 if (!(priv->sta_supp_rates & IWL_OFDM_RATES_MASK) && 245 if (!(priv->_3945.sta_supp_rates & IWL_OFDM_RATES_MASK) &&
246 iwl_is_associated(priv)) { 246 iwl_is_associated(priv)) {
247 if (rate == IWL_RATE_11M_INDEX) 247 if (rate == IWL_RATE_11M_INDEX)
248 next_rate = IWL_RATE_5M_INDEX; 248 next_rate = IWL_RATE_5M_INDEX;
@@ -359,7 +359,7 @@ void iwl3945_hw_rx_statistics(struct iwl_priv *priv,
359 (int)sizeof(struct iwl3945_notif_statistics), 359 (int)sizeof(struct iwl3945_notif_statistics),
360 le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); 360 le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK);
361 361
362 memcpy(&priv->statistics_39, pkt->u.raw, sizeof(priv->statistics_39)); 362 memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics));
363} 363}
364 364
365/****************************************************************************** 365/******************************************************************************
@@ -705,9 +705,10 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv,
705 iwl_dbg_log_rx_data_frame(priv, le16_to_cpu(rx_hdr->len), header); 705 iwl_dbg_log_rx_data_frame(priv, le16_to_cpu(rx_hdr->len), header);
706 706
707 if (network_packet) { 707 if (network_packet) {
708 priv->last_beacon_time = le32_to_cpu(rx_end->beacon_timestamp); 708 priv->_3945.last_beacon_time =
709 priv->last_tsf = le64_to_cpu(rx_end->timestamp); 709 le32_to_cpu(rx_end->beacon_timestamp);
710 priv->last_rx_rssi = rx_status.signal; 710 priv->_3945.last_tsf = le64_to_cpu(rx_end->timestamp);
711 priv->_3945.last_rx_rssi = rx_status.signal;
711 priv->last_rx_noise = rx_status.noise; 712 priv->last_rx_noise = rx_status.noise;
712 } 713 }
713 714
@@ -956,7 +957,7 @@ static int iwl3945_tx_reset(struct iwl_priv *priv)
956 iwl_write_prph(priv, ALM_SCD_TXF5MF_REG, 0x000005); 957 iwl_write_prph(priv, ALM_SCD_TXF5MF_REG, 0x000005);
957 958
958 iwl_write_direct32(priv, FH39_TSSR_CBB_BASE, 959 iwl_write_direct32(priv, FH39_TSSR_CBB_BASE,
959 priv->shared_phys); 960 priv->_3945.shared_phys);
960 961
961 iwl_write_direct32(priv, FH39_TSSR_MSG_CONFIG, 962 iwl_write_direct32(priv, FH39_TSSR_MSG_CONFIG,
962 FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | 963 FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON |
@@ -1606,7 +1607,7 @@ static int iwl3945_hw_reg_set_new_power(struct iwl_priv *priv,
1606 int power; 1607 int power;
1607 1608
1608 /* Get this chnlgrp's rate-to-max/clip-powers table */ 1609 /* Get this chnlgrp's rate-to-max/clip-powers table */
1609 clip_pwrs = priv->clip39_groups[ch_info->group_index].clip_powers; 1610 clip_pwrs = priv->_3945.clip_groups[ch_info->group_index].clip_powers;
1610 1611
1611 /* Get this channel's rate-to-current-power settings table */ 1612 /* Get this channel's rate-to-current-power settings table */
1612 power_info = ch_info->power_info; 1613 power_info = ch_info->power_info;
@@ -1732,7 +1733,7 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv)
1732 } 1733 }
1733 1734
1734 /* Get this chnlgrp's rate-to-max/clip-powers table */ 1735 /* Get this chnlgrp's rate-to-max/clip-powers table */
1735 clip_pwrs = priv->clip39_groups[ch_info->group_index].clip_powers; 1736 clip_pwrs = priv->_3945.clip_groups[ch_info->group_index].clip_powers;
1736 1737
1737 /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ 1738 /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */
1738 for (scan_tbl_index = 0; 1739 for (scan_tbl_index = 0;
@@ -1910,6 +1911,8 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
1910 "configuration (%d).\n", rc); 1911 "configuration (%d).\n", rc);
1911 return rc; 1912 return rc;
1912 } 1913 }
1914 iwl_clear_ucode_stations(priv, false);
1915 iwl_restore_stations(priv);
1913 } 1916 }
1914 1917
1915 IWL_DEBUG_INFO(priv, "Sending RXON\n" 1918 IWL_DEBUG_INFO(priv, "Sending RXON\n"
@@ -1940,7 +1943,10 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
1940 1943
1941 memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); 1944 memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
1942 1945
1943 iwl_clear_stations_table(priv); 1946 if (!new_assoc) {
1947 iwl_clear_ucode_stations(priv, false);
1948 iwl_restore_stations(priv);
1949 }
1944 1950
1945 /* If we issue a new RXON command which required a tune then we must 1951 /* If we issue a new RXON command which required a tune then we must
1946 * send a new TXPOWER command or we won't be able to Tx any frames */ 1952 * send a new TXPOWER command or we won't be able to Tx any frames */
@@ -1950,19 +1956,6 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
1950 return rc; 1956 return rc;
1951 } 1957 }
1952 1958
1953 /* Add the broadcast address so we can send broadcast frames */
1954 priv->cfg->ops->lib->add_bcast_station(priv);
1955
1956 /* If we have set the ASSOC_MSK and we are in BSS mode then
1957 * add the IWL_AP_ID to the station rate table */
1958 if (iwl_is_associated(priv) &&
1959 (priv->iw_mode == NL80211_IFTYPE_STATION))
1960 if (iwl_add_station(priv, priv->active_rxon.bssid_addr,
1961 true, CMD_SYNC, NULL) == IWL_INVALID_STATION) {
1962 IWL_ERR(priv, "Error adding AP address for transmit\n");
1963 return -EIO;
1964 }
1965
1966 /* Init the hardware's rate fallback order based on the band */ 1959 /* Init the hardware's rate fallback order based on the band */
1967 rc = iwl3945_init_hw_rate_table(priv); 1960 rc = iwl3945_init_hw_rate_table(priv);
1968 if (rc) { 1961 if (rc) {
@@ -1997,13 +1990,13 @@ void iwl3945_reg_txpower_periodic(struct iwl_priv *priv)
1997 1990
1998 reschedule: 1991 reschedule:
1999 queue_delayed_work(priv->workqueue, 1992 queue_delayed_work(priv->workqueue,
2000 &priv->thermal_periodic, REG_RECALIB_PERIOD * HZ); 1993 &priv->_3945.thermal_periodic, REG_RECALIB_PERIOD * HZ);
2001} 1994}
2002 1995
2003static void iwl3945_bg_reg_txpower_periodic(struct work_struct *work) 1996static void iwl3945_bg_reg_txpower_periodic(struct work_struct *work)
2004{ 1997{
2005 struct iwl_priv *priv = container_of(work, struct iwl_priv, 1998 struct iwl_priv *priv = container_of(work, struct iwl_priv,
2006 thermal_periodic.work); 1999 _3945.thermal_periodic.work);
2007 2000
2008 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2001 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2009 return; 2002 return;
@@ -2139,7 +2132,7 @@ static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv)
2139 * power peaks, without too much distortion (clipping). 2132 * power peaks, without too much distortion (clipping).
2140 */ 2133 */
2141 /* we'll fill in this array with h/w max power levels */ 2134 /* we'll fill in this array with h/w max power levels */
2142 clip_pwrs = (s8 *) priv->clip39_groups[i].clip_powers; 2135 clip_pwrs = (s8 *) priv->_3945.clip_groups[i].clip_powers;
2143 2136
2144 /* divide factory saturation power by 2 to find -3dB level */ 2137 /* divide factory saturation power by 2 to find -3dB level */
2145 satur_pwr = (s8) (group->saturation_power >> 1); 2138 satur_pwr = (s8) (group->saturation_power >> 1);
@@ -2223,7 +2216,7 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv)
2223 iwl3945_hw_reg_get_ch_grp_index(priv, ch_info); 2216 iwl3945_hw_reg_get_ch_grp_index(priv, ch_info);
2224 2217
2225 /* Get this chnlgrp's rate->max/clip-powers table */ 2218 /* Get this chnlgrp's rate->max/clip-powers table */
2226 clip_pwrs = priv->clip39_groups[ch_info->group_index].clip_powers; 2219 clip_pwrs = priv->_3945.clip_groups[ch_info->group_index].clip_powers;
2227 2220
2228 /* calculate power index *adjustment* value according to 2221 /* calculate power index *adjustment* value according to
2229 * diff between current temperature and factory temperature */ 2222 * diff between current temperature and factory temperature */
@@ -2331,7 +2324,7 @@ int iwl3945_hw_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq)
2331{ 2324{
2332 int txq_id = txq->q.id; 2325 int txq_id = txq->q.id;
2333 2326
2334 struct iwl3945_shared *shared_data = priv->shared_virt; 2327 struct iwl3945_shared *shared_data = priv->_3945.shared_virt;
2335 2328
2336 shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); 2329 shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr);
2337 2330
@@ -2431,7 +2424,7 @@ int iwl3945_init_hw_rate_table(struct iwl_priv *priv)
2431 /* If an OFDM rate is used, have it fall back to the 2424 /* If an OFDM rate is used, have it fall back to the
2432 * 1M CCK rates */ 2425 * 1M CCK rates */
2433 2426
2434 if (!(priv->sta_supp_rates & IWL_OFDM_RATES_MASK) && 2427 if (!(priv->_3945.sta_supp_rates & IWL_OFDM_RATES_MASK) &&
2435 iwl_is_associated(priv)) { 2428 iwl_is_associated(priv)) {
2436 2429
2437 index = IWL_FIRST_CCK_RATE; 2430 index = IWL_FIRST_CCK_RATE;
@@ -2470,10 +2463,11 @@ int iwl3945_hw_set_hw_params(struct iwl_priv *priv)
2470 memset((void *)&priv->hw_params, 0, 2463 memset((void *)&priv->hw_params, 0,
2471 sizeof(struct iwl_hw_params)); 2464 sizeof(struct iwl_hw_params));
2472 2465
2473 priv->shared_virt = dma_alloc_coherent(&priv->pci_dev->dev, 2466 priv->_3945.shared_virt =
2474 sizeof(struct iwl3945_shared), 2467 dma_alloc_coherent(&priv->pci_dev->dev,
2475 &priv->shared_phys, GFP_KERNEL); 2468 sizeof(struct iwl3945_shared),
2476 if (!priv->shared_virt) { 2469 &priv->_3945.shared_phys, GFP_KERNEL);
2470 if (!priv->_3945.shared_virt) {
2477 IWL_ERR(priv, "failed to allocate pci memory\n"); 2471 IWL_ERR(priv, "failed to allocate pci memory\n");
2478 mutex_unlock(&priv->mutex); 2472 mutex_unlock(&priv->mutex);
2479 return -ENOMEM; 2473 return -ENOMEM;
@@ -2536,13 +2530,13 @@ void iwl3945_hw_rx_handler_setup(struct iwl_priv *priv)
2536 2530
2537void iwl3945_hw_setup_deferred_work(struct iwl_priv *priv) 2531void iwl3945_hw_setup_deferred_work(struct iwl_priv *priv)
2538{ 2532{
2539 INIT_DELAYED_WORK(&priv->thermal_periodic, 2533 INIT_DELAYED_WORK(&priv->_3945.thermal_periodic,
2540 iwl3945_bg_reg_txpower_periodic); 2534 iwl3945_bg_reg_txpower_periodic);
2541} 2535}
2542 2536
2543void iwl3945_hw_cancel_deferred_work(struct iwl_priv *priv) 2537void iwl3945_hw_cancel_deferred_work(struct iwl_priv *priv)
2544{ 2538{
2545 cancel_delayed_work(&priv->thermal_periodic); 2539 cancel_delayed_work(&priv->_3945.thermal_periodic);
2546} 2540}
2547 2541
2548/* check contents of special bootstrap uCode SRAM */ 2542/* check contents of special bootstrap uCode SRAM */
@@ -2826,6 +2820,7 @@ static struct iwl_cfg iwl3945_bg_cfg = {
2826 .led_compensation = 64, 2820 .led_compensation = 64,
2827 .broken_powersave = true, 2821 .broken_powersave = true,
2828 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 2822 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
2823 .monitor_recover_period = IWL_MONITORING_PERIOD,
2829}; 2824};
2830 2825
2831static struct iwl_cfg iwl3945_abg_cfg = { 2826static struct iwl_cfg iwl3945_abg_cfg = {
@@ -2844,6 +2839,7 @@ static struct iwl_cfg iwl3945_abg_cfg = {
2844 .led_compensation = 64, 2839 .led_compensation = 64,
2845 .broken_powersave = true, 2840 .broken_powersave = true,
2846 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 2841 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
2842 .monitor_recover_period = IWL_MONITORING_PERIOD,
2847}; 2843};
2848 2844
2849DEFINE_PCI_DEVICE_TABLE(iwl3945_hw_card_ids) = { 2845DEFINE_PCI_DEVICE_TABLE(iwl3945_hw_card_ids) = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 452dfd5456c6..b89219573b91 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -95,7 +95,6 @@ struct iwl3945_rs_sta {
95 u8 tgg; 95 u8 tgg;
96 u8 flush_pending; 96 u8 flush_pending;
97 u8 start_rate; 97 u8 start_rate;
98 u8 ibss_sta_added;
99 struct timer_list rate_scale_flush; 98 struct timer_list rate_scale_flush;
100 struct iwl3945_rate_scale_data win[IWL_RATE_COUNT_3945]; 99 struct iwl3945_rate_scale_data win[IWL_RATE_COUNT_3945];
101#ifdef CONFIG_MAC80211_DEBUGFS 100#ifdef CONFIG_MAC80211_DEBUGFS
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 83c52a682622..3297fc7b80bf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -502,14 +502,14 @@ static void iwl4965_tx_queue_set_status(struct iwl_priv *priv,
502 scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); 502 scd_retry ? "BA" : "AC", txq_id, tx_fifo_id);
503} 503}
504 504
505static const u16 default_queue_to_tx_fifo[] = { 505static const s8 default_queue_to_tx_fifo[] = {
506 IWL_TX_FIFO_AC3, 506 IWL_TX_FIFO_VO,
507 IWL_TX_FIFO_AC2, 507 IWL_TX_FIFO_VI,
508 IWL_TX_FIFO_AC1, 508 IWL_TX_FIFO_BE,
509 IWL_TX_FIFO_AC0, 509 IWL_TX_FIFO_BK,
510 IWL49_CMD_FIFO_NUM, 510 IWL49_CMD_FIFO_NUM,
511 IWL_TX_FIFO_HCCA_1, 511 IWL_TX_FIFO_UNUSED,
512 IWL_TX_FIFO_HCCA_2 512 IWL_TX_FIFO_UNUSED,
513}; 513};
514 514
515static int iwl4965_alive_notify(struct iwl_priv *priv) 515static int iwl4965_alive_notify(struct iwl_priv *priv)
@@ -589,9 +589,15 @@ static int iwl4965_alive_notify(struct iwl_priv *priv)
589 /* reset to 0 to enable all the queue first */ 589 /* reset to 0 to enable all the queue first */
590 priv->txq_ctx_active_msk = 0; 590 priv->txq_ctx_active_msk = 0;
591 /* Map each Tx/cmd queue to its corresponding fifo */ 591 /* Map each Tx/cmd queue to its corresponding fifo */
592 BUILD_BUG_ON(ARRAY_SIZE(default_queue_to_tx_fifo) != 7);
592 for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { 593 for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) {
593 int ac = default_queue_to_tx_fifo[i]; 594 int ac = default_queue_to_tx_fifo[i];
595
594 iwl_txq_ctx_activate(priv, i); 596 iwl_txq_ctx_activate(priv, i);
597
598 if (ac == IWL_TX_FIFO_UNUSED)
599 continue;
600
595 iwl4965_tx_queue_set_status(priv, &priv->txq[i], ac, 0); 601 iwl4965_tx_queue_set_status(priv, &priv->txq[i], ac, 0);
596 } 602 }
597 603
@@ -2179,6 +2185,7 @@ static struct iwl_lib_ops iwl4965_lib = {
2179 .load_ucode = iwl4965_load_bsm, 2185 .load_ucode = iwl4965_load_bsm,
2180 .dump_nic_event_log = iwl_dump_nic_event_log, 2186 .dump_nic_event_log = iwl_dump_nic_event_log,
2181 .dump_nic_error_log = iwl_dump_nic_error_log, 2187 .dump_nic_error_log = iwl_dump_nic_error_log,
2188 .dump_fh = iwl_dump_fh,
2182 .set_channel_switch = iwl4965_hw_channel_switch, 2189 .set_channel_switch = iwl4965_hw_channel_switch,
2183 .apm_ops = { 2190 .apm_ops = {
2184 .init = iwl_apm_init, 2191 .init = iwl_apm_init,
@@ -2212,6 +2219,7 @@ static struct iwl_lib_ops iwl4965_lib = {
2212 .set_ct_kill = iwl4965_set_ct_threshold, 2219 .set_ct_kill = iwl4965_set_ct_threshold,
2213 }, 2220 },
2214 .add_bcast_station = iwl_add_bcast_station, 2221 .add_bcast_station = iwl_add_bcast_station,
2222 .check_plcp_health = iwl_good_plcp_health,
2215}; 2223};
2216 2224
2217static const struct iwl_ops iwl4965_ops = { 2225static const struct iwl_ops iwl4965_ops = {
@@ -2223,7 +2231,7 @@ static const struct iwl_ops iwl4965_ops = {
2223}; 2231};
2224 2232
2225struct iwl_cfg iwl4965_agn_cfg = { 2233struct iwl_cfg iwl4965_agn_cfg = {
2226 .name = "4965AGN", 2234 .name = "Intel(R) Wireless WiFi Link 4965AGN",
2227 .fw_name_pre = IWL4965_FW_PRE, 2235 .fw_name_pre = IWL4965_FW_PRE,
2228 .ucode_api_max = IWL4965_UCODE_API_MAX, 2236 .ucode_api_max = IWL4965_UCODE_API_MAX,
2229 .ucode_api_min = IWL4965_UCODE_API_MIN, 2237 .ucode_api_min = IWL4965_UCODE_API_MIN,
@@ -2246,6 +2254,7 @@ struct iwl_cfg iwl4965_agn_cfg = {
2246 .led_compensation = 61, 2254 .led_compensation = 61,
2247 .chain_noise_num_beacons = IWL4965_CAL_NUM_BEACONS, 2255 .chain_noise_num_beacons = IWL4965_CAL_NUM_BEACONS,
2248 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 2256 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
2257 .monitor_recover_period = IWL_MONITORING_PERIOD,
2249}; 2258};
2250 2259
2251/* Module firmware */ 2260/* Module firmware */
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index e476acb53aa7..2267cad49cbf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -43,6 +43,7 @@
43#include "iwl-io.h" 43#include "iwl-io.h"
44#include "iwl-sta.h" 44#include "iwl-sta.h"
45#include "iwl-helpers.h" 45#include "iwl-helpers.h"
46#include "iwl-agn.h"
46#include "iwl-agn-led.h" 47#include "iwl-agn-led.h"
47#include "iwl-5000-hw.h" 48#include "iwl-5000-hw.h"
48#include "iwl-6000-hw.h" 49#include "iwl-6000-hw.h"
@@ -63,14 +64,17 @@
63#define _IWL5150_MODULE_FIRMWARE(api) IWL5150_FW_PRE #api ".ucode" 64#define _IWL5150_MODULE_FIRMWARE(api) IWL5150_FW_PRE #api ".ucode"
64#define IWL5150_MODULE_FIRMWARE(api) _IWL5150_MODULE_FIRMWARE(api) 65#define IWL5150_MODULE_FIRMWARE(api) _IWL5150_MODULE_FIRMWARE(api)
65 66
66static const u16 iwl5000_default_queue_to_tx_fifo[] = { 67static const s8 iwl5000_default_queue_to_tx_fifo[] = {
67 IWL_TX_FIFO_AC3, 68 IWL_TX_FIFO_VO,
68 IWL_TX_FIFO_AC2, 69 IWL_TX_FIFO_VI,
69 IWL_TX_FIFO_AC1, 70 IWL_TX_FIFO_BE,
70 IWL_TX_FIFO_AC0, 71 IWL_TX_FIFO_BK,
71 IWL50_CMD_FIFO_NUM, 72 IWL50_CMD_FIFO_NUM,
72 IWL_TX_FIFO_HCCA_1, 73 IWL_TX_FIFO_UNUSED,
73 IWL_TX_FIFO_HCCA_2 74 IWL_TX_FIFO_UNUSED,
75 IWL_TX_FIFO_UNUSED,
76 IWL_TX_FIFO_UNUSED,
77 IWL_TX_FIFO_UNUSED,
74}; 78};
75 79
76/* NIC configuration for 5000 series */ 80/* NIC configuration for 5000 series */
@@ -540,7 +544,6 @@ void iwl5000_init_alive_start(struct iwl_priv *priv)
540 goto restart; 544 goto restart;
541 } 545 }
542 546
543 iwl_clear_stations_table(priv);
544 ret = priv->cfg->ops->lib->alive_notify(priv); 547 ret = priv->cfg->ops->lib->alive_notify(priv);
545 if (ret) { 548 if (ret) {
546 IWL_WARN(priv, 549 IWL_WARN(priv,
@@ -579,9 +582,9 @@ static void iwl5000_tx_queue_set_status(struct iwl_priv *priv,
579 582
580 txq->sched_retry = scd_retry; 583 txq->sched_retry = scd_retry;
581 584
582 IWL_DEBUG_INFO(priv, "%s %s Queue %d on AC %d\n", 585 IWL_DEBUG_INFO(priv, "%s %s Queue %d on FIFO %d\n",
583 active ? "Activate" : "Deactivate", 586 active ? "Activate" : "Deactivate",
584 scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); 587 scd_retry ? "BA" : "AC/CMD", txq_id, tx_fifo_id);
585} 588}
586 589
587int iwl5000_alive_notify(struct iwl_priv *priv) 590int iwl5000_alive_notify(struct iwl_priv *priv)
@@ -656,25 +659,21 @@ int iwl5000_alive_notify(struct iwl_priv *priv)
656 /* reset to 0 to enable all the queue first */ 659 /* reset to 0 to enable all the queue first */
657 priv->txq_ctx_active_msk = 0; 660 priv->txq_ctx_active_msk = 0;
658 /* map qos queues to fifos one-to-one */ 661 /* map qos queues to fifos one-to-one */
662 BUILD_BUG_ON(ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo) != 10);
663
659 for (i = 0; i < ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo); i++) { 664 for (i = 0; i < ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo); i++) {
660 int ac = iwl5000_default_queue_to_tx_fifo[i]; 665 int ac = iwl5000_default_queue_to_tx_fifo[i];
666
661 iwl_txq_ctx_activate(priv, i); 667 iwl_txq_ctx_activate(priv, i);
668
669 if (ac == IWL_TX_FIFO_UNUSED)
670 continue;
671
662 iwl5000_tx_queue_set_status(priv, &priv->txq[i], ac, 0); 672 iwl5000_tx_queue_set_status(priv, &priv->txq[i], ac, 0);
663 } 673 }
664 674
665 /*
666 * TODO - need to initialize these queues and map them to FIFOs
667 * in the loop above, not only mark them as active. We do this
668 * because we want the first aggregation queue to be queue #10,
669 * but do not use 8 or 9 otherwise yet.
670 */
671 iwl_txq_ctx_activate(priv, 7);
672 iwl_txq_ctx_activate(priv, 8);
673 iwl_txq_ctx_activate(priv, 9);
674
675 spin_unlock_irqrestore(&priv->lock, flags); 675 spin_unlock_irqrestore(&priv->lock, flags);
676 676
677
678 iwl_send_wimax_coex(priv); 677 iwl_send_wimax_coex(priv);
679 678
680 iwl5000_set_Xtal_calib(priv); 679 iwl5000_set_Xtal_calib(priv);
@@ -1500,6 +1499,9 @@ struct iwl_lib_ops iwl5000_lib = {
1500 .set_ct_kill = iwl5000_set_ct_threshold, 1499 .set_ct_kill = iwl5000_set_ct_threshold,
1501 }, 1500 },
1502 .add_bcast_station = iwl_add_bcast_station, 1501 .add_bcast_station = iwl_add_bcast_station,
1502 .recover_from_tx_stall = iwl_bg_monitor_recover,
1503 .check_plcp_health = iwl_good_plcp_health,
1504 .check_ack_health = iwl_good_ack_health,
1503}; 1505};
1504 1506
1505static struct iwl_lib_ops iwl5150_lib = { 1507static struct iwl_lib_ops iwl5150_lib = {
@@ -1554,6 +1556,9 @@ static struct iwl_lib_ops iwl5150_lib = {
1554 .set_ct_kill = iwl5150_set_ct_threshold, 1556 .set_ct_kill = iwl5150_set_ct_threshold,
1555 }, 1557 },
1556 .add_bcast_station = iwl_add_bcast_station, 1558 .add_bcast_station = iwl_add_bcast_station,
1559 .recover_from_tx_stall = iwl_bg_monitor_recover,
1560 .check_plcp_health = iwl_good_plcp_health,
1561 .check_ack_health = iwl_good_ack_health,
1557}; 1562};
1558 1563
1559static const struct iwl_ops iwl5000_ops = { 1564static const struct iwl_ops iwl5000_ops = {
@@ -1580,7 +1585,7 @@ struct iwl_mod_params iwl50_mod_params = {
1580 1585
1581 1586
1582struct iwl_cfg iwl5300_agn_cfg = { 1587struct iwl_cfg iwl5300_agn_cfg = {
1583 .name = "5300AGN", 1588 .name = "Intel(R) Ultimate N WiFi Link 5300 AGN",
1584 .fw_name_pre = IWL5000_FW_PRE, 1589 .fw_name_pre = IWL5000_FW_PRE,
1585 .ucode_api_max = IWL5000_UCODE_API_MAX, 1590 .ucode_api_max = IWL5000_UCODE_API_MAX,
1586 .ucode_api_min = IWL5000_UCODE_API_MIN, 1591 .ucode_api_min = IWL5000_UCODE_API_MIN,
@@ -1603,10 +1608,11 @@ struct iwl_cfg iwl5300_agn_cfg = {
1603 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS, 1608 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
1604 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF, 1609 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
1605 .chain_noise_scale = 1000, 1610 .chain_noise_scale = 1000,
1611 .monitor_recover_period = IWL_MONITORING_PERIOD,
1606}; 1612};
1607 1613
1608struct iwl_cfg iwl5100_bgn_cfg = { 1614struct iwl_cfg iwl5100_bgn_cfg = {
1609 .name = "5100BGN", 1615 .name = "Intel(R) WiFi Link 5100 BGN",
1610 .fw_name_pre = IWL5000_FW_PRE, 1616 .fw_name_pre = IWL5000_FW_PRE,
1611 .ucode_api_max = IWL5000_UCODE_API_MAX, 1617 .ucode_api_max = IWL5000_UCODE_API_MAX,
1612 .ucode_api_min = IWL5000_UCODE_API_MIN, 1618 .ucode_api_min = IWL5000_UCODE_API_MIN,
@@ -1629,10 +1635,11 @@ struct iwl_cfg iwl5100_bgn_cfg = {
1629 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS, 1635 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
1630 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF, 1636 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
1631 .chain_noise_scale = 1000, 1637 .chain_noise_scale = 1000,
1638 .monitor_recover_period = IWL_MONITORING_PERIOD,
1632}; 1639};
1633 1640
1634struct iwl_cfg iwl5100_abg_cfg = { 1641struct iwl_cfg iwl5100_abg_cfg = {
1635 .name = "5100ABG", 1642 .name = "Intel(R) WiFi Link 5100 ABG",
1636 .fw_name_pre = IWL5000_FW_PRE, 1643 .fw_name_pre = IWL5000_FW_PRE,
1637 .ucode_api_max = IWL5000_UCODE_API_MAX, 1644 .ucode_api_max = IWL5000_UCODE_API_MAX,
1638 .ucode_api_min = IWL5000_UCODE_API_MIN, 1645 .ucode_api_min = IWL5000_UCODE_API_MIN,
@@ -1653,10 +1660,11 @@ struct iwl_cfg iwl5100_abg_cfg = {
1653 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS, 1660 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
1654 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF, 1661 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
1655 .chain_noise_scale = 1000, 1662 .chain_noise_scale = 1000,
1663 .monitor_recover_period = IWL_MONITORING_PERIOD,
1656}; 1664};
1657 1665
1658struct iwl_cfg iwl5100_agn_cfg = { 1666struct iwl_cfg iwl5100_agn_cfg = {
1659 .name = "5100AGN", 1667 .name = "Intel(R) WiFi Link 5100 AGN",
1660 .fw_name_pre = IWL5000_FW_PRE, 1668 .fw_name_pre = IWL5000_FW_PRE,
1661 .ucode_api_max = IWL5000_UCODE_API_MAX, 1669 .ucode_api_max = IWL5000_UCODE_API_MAX,
1662 .ucode_api_min = IWL5000_UCODE_API_MIN, 1670 .ucode_api_min = IWL5000_UCODE_API_MIN,
@@ -1679,10 +1687,11 @@ struct iwl_cfg iwl5100_agn_cfg = {
1679 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS, 1687 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
1680 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF, 1688 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
1681 .chain_noise_scale = 1000, 1689 .chain_noise_scale = 1000,
1690 .monitor_recover_period = IWL_MONITORING_PERIOD,
1682}; 1691};
1683 1692
1684struct iwl_cfg iwl5350_agn_cfg = { 1693struct iwl_cfg iwl5350_agn_cfg = {
1685 .name = "5350AGN", 1694 .name = "Intel(R) WiMAX/WiFi Link 5350 AGN",
1686 .fw_name_pre = IWL5000_FW_PRE, 1695 .fw_name_pre = IWL5000_FW_PRE,
1687 .ucode_api_max = IWL5000_UCODE_API_MAX, 1696 .ucode_api_max = IWL5000_UCODE_API_MAX,
1688 .ucode_api_min = IWL5000_UCODE_API_MIN, 1697 .ucode_api_min = IWL5000_UCODE_API_MIN,
@@ -1705,10 +1714,11 @@ struct iwl_cfg iwl5350_agn_cfg = {
1705 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS, 1714 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
1706 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF, 1715 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
1707 .chain_noise_scale = 1000, 1716 .chain_noise_scale = 1000,
1717 .monitor_recover_period = IWL_MONITORING_PERIOD,
1708}; 1718};
1709 1719
1710struct iwl_cfg iwl5150_agn_cfg = { 1720struct iwl_cfg iwl5150_agn_cfg = {
1711 .name = "5150AGN", 1721 .name = "Intel(R) WiMAX/WiFi Link 5150 AGN",
1712 .fw_name_pre = IWL5150_FW_PRE, 1722 .fw_name_pre = IWL5150_FW_PRE,
1713 .ucode_api_max = IWL5150_UCODE_API_MAX, 1723 .ucode_api_max = IWL5150_UCODE_API_MAX,
1714 .ucode_api_min = IWL5150_UCODE_API_MIN, 1724 .ucode_api_min = IWL5150_UCODE_API_MIN,
@@ -1731,10 +1741,11 @@ struct iwl_cfg iwl5150_agn_cfg = {
1731 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS, 1741 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
1732 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF, 1742 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
1733 .chain_noise_scale = 1000, 1743 .chain_noise_scale = 1000,
1744 .monitor_recover_period = IWL_MONITORING_PERIOD,
1734}; 1745};
1735 1746
1736struct iwl_cfg iwl5150_abg_cfg = { 1747struct iwl_cfg iwl5150_abg_cfg = {
1737 .name = "5150ABG", 1748 .name = "Intel(R) WiMAX/WiFi Link 5150 ABG",
1738 .fw_name_pre = IWL5150_FW_PRE, 1749 .fw_name_pre = IWL5150_FW_PRE,
1739 .ucode_api_max = IWL5150_UCODE_API_MAX, 1750 .ucode_api_max = IWL5150_UCODE_API_MAX,
1740 .ucode_api_min = IWL5150_UCODE_API_MIN, 1751 .ucode_api_min = IWL5150_UCODE_API_MIN,
@@ -1755,6 +1766,7 @@ struct iwl_cfg iwl5150_abg_cfg = {
1755 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS, 1766 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
1756 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF, 1767 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
1757 .chain_noise_scale = 1000, 1768 .chain_noise_scale = 1000,
1769 .monitor_recover_period = IWL_MONITORING_PERIOD,
1758}; 1770};
1759 1771
1760MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX)); 1772MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX));
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index c4844adff92a..d75799946a7e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -42,6 +42,7 @@
42#include "iwl-core.h" 42#include "iwl-core.h"
43#include "iwl-io.h" 43#include "iwl-io.h"
44#include "iwl-sta.h" 44#include "iwl-sta.h"
45#include "iwl-agn.h"
45#include "iwl-helpers.h" 46#include "iwl-helpers.h"
46#include "iwl-5000-hw.h" 47#include "iwl-5000-hw.h"
47#include "iwl-6000-hw.h" 48#include "iwl-6000-hw.h"
@@ -277,6 +278,9 @@ static struct iwl_lib_ops iwl6000_lib = {
277 .set_ct_kill = iwl6000_set_ct_threshold, 278 .set_ct_kill = iwl6000_set_ct_threshold,
278 }, 279 },
279 .add_bcast_station = iwl_add_bcast_station, 280 .add_bcast_station = iwl_add_bcast_station,
281 .recover_from_tx_stall = iwl_bg_monitor_recover,
282 .check_plcp_health = iwl_good_plcp_health,
283 .check_ack_health = iwl_good_ack_health,
280}; 284};
281 285
282static const struct iwl_ops iwl6000_ops = { 286static const struct iwl_ops iwl6000_ops = {
@@ -342,6 +346,9 @@ static struct iwl_lib_ops iwl6050_lib = {
342 .set_calib_version = iwl6050_set_calib_version, 346 .set_calib_version = iwl6050_set_calib_version,
343 }, 347 },
344 .add_bcast_station = iwl_add_bcast_station, 348 .add_bcast_station = iwl_add_bcast_station,
349 .recover_from_tx_stall = iwl_bg_monitor_recover,
350 .check_plcp_health = iwl_good_plcp_health,
351 .check_ack_health = iwl_good_ack_health,
345}; 352};
346 353
347static const struct iwl_ops iwl6050_ops = { 354static const struct iwl_ops iwl6050_ops = {
@@ -356,7 +363,7 @@ static const struct iwl_ops iwl6050_ops = {
356 * "i": Internal configuration, use internal Power Amplifier 363 * "i": Internal configuration, use internal Power Amplifier
357 */ 364 */
358struct iwl_cfg iwl6000i_2agn_cfg = { 365struct iwl_cfg iwl6000i_2agn_cfg = {
359 .name = "6000 Series 2x2 AGN", 366 .name = "Intel(R) Centrino(R) Advanced-N 6200 AGN",
360 .fw_name_pre = IWL6000_FW_PRE, 367 .fw_name_pre = IWL6000_FW_PRE,
361 .ucode_api_max = IWL6000_UCODE_API_MAX, 368 .ucode_api_max = IWL6000_UCODE_API_MAX,
362 .ucode_api_min = IWL6000_UCODE_API_MIN, 369 .ucode_api_min = IWL6000_UCODE_API_MIN,
@@ -385,10 +392,11 @@ struct iwl_cfg iwl6000i_2agn_cfg = {
385 .support_ct_kill_exit = true, 392 .support_ct_kill_exit = true,
386 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 393 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
387 .chain_noise_scale = 1000, 394 .chain_noise_scale = 1000,
395 .monitor_recover_period = IWL_MONITORING_PERIOD,
388}; 396};
389 397
390struct iwl_cfg iwl6000i_2abg_cfg = { 398struct iwl_cfg iwl6000i_2abg_cfg = {
391 .name = "6000 Series 2x2 ABG", 399 .name = "Intel(R) Centrino(R) Advanced-N 6200 ABG",
392 .fw_name_pre = IWL6000_FW_PRE, 400 .fw_name_pre = IWL6000_FW_PRE,
393 .ucode_api_max = IWL6000_UCODE_API_MAX, 401 .ucode_api_max = IWL6000_UCODE_API_MAX,
394 .ucode_api_min = IWL6000_UCODE_API_MIN, 402 .ucode_api_min = IWL6000_UCODE_API_MIN,
@@ -416,10 +424,11 @@ struct iwl_cfg iwl6000i_2abg_cfg = {
416 .support_ct_kill_exit = true, 424 .support_ct_kill_exit = true,
417 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 425 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
418 .chain_noise_scale = 1000, 426 .chain_noise_scale = 1000,
427 .monitor_recover_period = IWL_MONITORING_PERIOD,
419}; 428};
420 429
421struct iwl_cfg iwl6000i_2bg_cfg = { 430struct iwl_cfg iwl6000i_2bg_cfg = {
422 .name = "6000 Series 2x2 BG", 431 .name = "Intel(R) Centrino(R) Advanced-N 6200 BG",
423 .fw_name_pre = IWL6000_FW_PRE, 432 .fw_name_pre = IWL6000_FW_PRE,
424 .ucode_api_max = IWL6000_UCODE_API_MAX, 433 .ucode_api_max = IWL6000_UCODE_API_MAX,
425 .ucode_api_min = IWL6000_UCODE_API_MIN, 434 .ucode_api_min = IWL6000_UCODE_API_MIN,
@@ -447,10 +456,11 @@ struct iwl_cfg iwl6000i_2bg_cfg = {
447 .support_ct_kill_exit = true, 456 .support_ct_kill_exit = true,
448 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 457 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
449 .chain_noise_scale = 1000, 458 .chain_noise_scale = 1000,
459 .monitor_recover_period = IWL_MONITORING_PERIOD,
450}; 460};
451 461
452struct iwl_cfg iwl6050_2agn_cfg = { 462struct iwl_cfg iwl6050_2agn_cfg = {
453 .name = "6050 Series 2x2 AGN", 463 .name = "Intel(R) Centrino(R) Advanced-N + WiMAX 6250 AGN",
454 .fw_name_pre = IWL6050_FW_PRE, 464 .fw_name_pre = IWL6050_FW_PRE,
455 .ucode_api_max = IWL6050_UCODE_API_MAX, 465 .ucode_api_max = IWL6050_UCODE_API_MAX,
456 .ucode_api_min = IWL6050_UCODE_API_MIN, 466 .ucode_api_min = IWL6050_UCODE_API_MIN,
@@ -479,10 +489,11 @@ struct iwl_cfg iwl6050_2agn_cfg = {
479 .support_ct_kill_exit = true, 489 .support_ct_kill_exit = true,
480 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 490 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
481 .chain_noise_scale = 1500, 491 .chain_noise_scale = 1500,
492 .monitor_recover_period = IWL_MONITORING_PERIOD,
482}; 493};
483 494
484struct iwl_cfg iwl6050_2abg_cfg = { 495struct iwl_cfg iwl6050_2abg_cfg = {
485 .name = "6050 Series 2x2 ABG", 496 .name = "Intel(R) Centrino(R) Advanced-N + WiMAX 6250 ABG",
486 .fw_name_pre = IWL6050_FW_PRE, 497 .fw_name_pre = IWL6050_FW_PRE,
487 .ucode_api_max = IWL6050_UCODE_API_MAX, 498 .ucode_api_max = IWL6050_UCODE_API_MAX,
488 .ucode_api_min = IWL6050_UCODE_API_MIN, 499 .ucode_api_min = IWL6050_UCODE_API_MIN,
@@ -510,10 +521,11 @@ struct iwl_cfg iwl6050_2abg_cfg = {
510 .support_ct_kill_exit = true, 521 .support_ct_kill_exit = true,
511 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 522 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
512 .chain_noise_scale = 1500, 523 .chain_noise_scale = 1500,
524 .monitor_recover_period = IWL_MONITORING_PERIOD,
513}; 525};
514 526
515struct iwl_cfg iwl6000_3agn_cfg = { 527struct iwl_cfg iwl6000_3agn_cfg = {
516 .name = "6000 Series 3x3 AGN", 528 .name = "Intel(R) Centrino(R) Ultimate-N 6300 AGN",
517 .fw_name_pre = IWL6000_FW_PRE, 529 .fw_name_pre = IWL6000_FW_PRE,
518 .ucode_api_max = IWL6000_UCODE_API_MAX, 530 .ucode_api_max = IWL6000_UCODE_API_MAX,
519 .ucode_api_min = IWL6000_UCODE_API_MIN, 531 .ucode_api_min = IWL6000_UCODE_API_MIN,
@@ -542,6 +554,7 @@ struct iwl_cfg iwl6000_3agn_cfg = {
542 .support_ct_kill_exit = true, 554 .support_ct_kill_exit = true,
543 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 555 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
544 .chain_noise_scale = 1000, 556 .chain_noise_scale = 1000,
557 .monitor_recover_period = IWL_MONITORING_PERIOD,
545}; 558};
546 559
547MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX)); 560MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX));
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ict.c b/drivers/net/wireless/iwlwifi/iwl-agn-ict.c
new file mode 100644
index 000000000000..4c5395eae956
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ict.c
@@ -0,0 +1,305 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/etherdevice.h>
32#include <linux/sched.h>
33#include <net/mac80211.h>
34
35#include "iwl-dev.h"
36#include "iwl-core.h"
37#include "iwl-agn.h"
38#include "iwl-helpers.h"
39
40#define ICT_COUNT (PAGE_SIZE/sizeof(u32))
41
42/* Free dram table */
43void iwl_free_isr_ict(struct iwl_priv *priv)
44{
45 if (priv->_agn.ict_tbl_vir) {
46 dma_free_coherent(&priv->pci_dev->dev,
47 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
48 priv->_agn.ict_tbl_vir,
49 priv->_agn.ict_tbl_dma);
50 priv->_agn.ict_tbl_vir = NULL;
51 }
52}
53
54
55/* allocate dram shared table it is a PAGE_SIZE aligned
56 * also reset all data related to ICT table interrupt.
57 */
58int iwl_alloc_isr_ict(struct iwl_priv *priv)
59{
60
61 if (priv->cfg->use_isr_legacy)
62 return 0;
63 /* allocate shrared data table */
64 priv->_agn.ict_tbl_vir =
65 dma_alloc_coherent(&priv->pci_dev->dev,
66 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
67 &priv->_agn.ict_tbl_dma, GFP_KERNEL);
68 if (!priv->_agn.ict_tbl_vir)
69 return -ENOMEM;
70
71 /* align table to PAGE_SIZE boundry */
72 priv->_agn.aligned_ict_tbl_dma = ALIGN(priv->_agn.ict_tbl_dma, PAGE_SIZE);
73
74 IWL_DEBUG_ISR(priv, "ict dma addr %Lx dma aligned %Lx diff %d\n",
75 (unsigned long long)priv->_agn.ict_tbl_dma,
76 (unsigned long long)priv->_agn.aligned_ict_tbl_dma,
77 (int)(priv->_agn.aligned_ict_tbl_dma - priv->_agn.ict_tbl_dma));
78
79 priv->_agn.ict_tbl = priv->_agn.ict_tbl_vir +
80 (priv->_agn.aligned_ict_tbl_dma - priv->_agn.ict_tbl_dma);
81
82 IWL_DEBUG_ISR(priv, "ict vir addr %p vir aligned %p diff %d\n",
83 priv->_agn.ict_tbl, priv->_agn.ict_tbl_vir,
84 (int)(priv->_agn.aligned_ict_tbl_dma - priv->_agn.ict_tbl_dma));
85
86 /* reset table and index to all 0 */
87 memset(priv->_agn.ict_tbl_vir,0, (sizeof(u32) * ICT_COUNT) + PAGE_SIZE);
88 priv->_agn.ict_index = 0;
89
90 /* add periodic RX interrupt */
91 priv->inta_mask |= CSR_INT_BIT_RX_PERIODIC;
92 return 0;
93}
94
95/* Device is going up inform it about using ICT interrupt table,
96 * also we need to tell the driver to start using ICT interrupt.
97 */
98int iwl_reset_ict(struct iwl_priv *priv)
99{
100 u32 val;
101 unsigned long flags;
102
103 if (!priv->_agn.ict_tbl_vir)
104 return 0;
105
106 spin_lock_irqsave(&priv->lock, flags);
107 iwl_disable_interrupts(priv);
108
109 memset(&priv->_agn.ict_tbl[0], 0, sizeof(u32) * ICT_COUNT);
110
111 val = priv->_agn.aligned_ict_tbl_dma >> PAGE_SHIFT;
112
113 val |= CSR_DRAM_INT_TBL_ENABLE;
114 val |= CSR_DRAM_INIT_TBL_WRAP_CHECK;
115
116 IWL_DEBUG_ISR(priv, "CSR_DRAM_INT_TBL_REG =0x%X "
117 "aligned dma address %Lx\n",
118 val, (unsigned long long)priv->_agn.aligned_ict_tbl_dma);
119
120 iwl_write32(priv, CSR_DRAM_INT_TBL_REG, val);
121 priv->_agn.use_ict = true;
122 priv->_agn.ict_index = 0;
123 iwl_write32(priv, CSR_INT, priv->inta_mask);
124 iwl_enable_interrupts(priv);
125 spin_unlock_irqrestore(&priv->lock, flags);
126
127 return 0;
128}
129
130/* Device is going down disable ict interrupt usage */
131void iwl_disable_ict(struct iwl_priv *priv)
132{
133 unsigned long flags;
134
135 spin_lock_irqsave(&priv->lock, flags);
136 priv->_agn.use_ict = false;
137 spin_unlock_irqrestore(&priv->lock, flags);
138}
139
140static irqreturn_t iwl_isr(int irq, void *data)
141{
142 struct iwl_priv *priv = data;
143 u32 inta, inta_mask;
144#ifdef CONFIG_IWLWIFI_DEBUG
145 u32 inta_fh;
146#endif
147 if (!priv)
148 return IRQ_NONE;
149
150 spin_lock(&priv->lock);
151
152 /* Disable (but don't clear!) interrupts here to avoid
153 * back-to-back ISRs and sporadic interrupts from our NIC.
154 * If we have something to service, the tasklet will re-enable ints.
155 * If we *don't* have something, we'll re-enable before leaving here. */
156 inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */
157 iwl_write32(priv, CSR_INT_MASK, 0x00000000);
158
159 /* Discover which interrupts are active/pending */
160 inta = iwl_read32(priv, CSR_INT);
161
162 /* Ignore interrupt if there's nothing in NIC to service.
163 * This may be due to IRQ shared with another device,
164 * or due to sporadic interrupts thrown from our NIC. */
165 if (!inta) {
166 IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0\n");
167 goto none;
168 }
169
170 if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
171 /* Hardware disappeared. It might have already raised
172 * an interrupt */
173 IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta);
174 goto unplugged;
175 }
176
177#ifdef CONFIG_IWLWIFI_DEBUG
178 if (iwl_get_debug_level(priv) & (IWL_DL_ISR)) {
179 inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS);
180 IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, "
181 "fh 0x%08x\n", inta, inta_mask, inta_fh);
182 }
183#endif
184
185 priv->_agn.inta |= inta;
186 /* iwl_irq_tasklet() will service interrupts and re-enable them */
187 if (likely(inta))
188 tasklet_schedule(&priv->irq_tasklet);
189 else if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->_agn.inta)
190 iwl_enable_interrupts(priv);
191
192 unplugged:
193 spin_unlock(&priv->lock);
194 return IRQ_HANDLED;
195
196 none:
197 /* re-enable interrupts here since we don't have anything to service. */
198 /* only Re-enable if diabled by irq and no schedules tasklet. */
199 if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->_agn.inta)
200 iwl_enable_interrupts(priv);
201
202 spin_unlock(&priv->lock);
203 return IRQ_NONE;
204}
205
206/* interrupt handler using ict table, with this interrupt driver will
207 * stop using INTA register to get device's interrupt, reading this register
208 * is expensive, device will write interrupts in ICT dram table, increment
209 * index then will fire interrupt to driver, driver will OR all ICT table
210 * entries from current index up to table entry with 0 value. the result is
211 * the interrupt we need to service, driver will set the entries back to 0 and
212 * set index.
213 */
214irqreturn_t iwl_isr_ict(int irq, void *data)
215{
216 struct iwl_priv *priv = data;
217 u32 inta, inta_mask;
218 u32 val = 0;
219
220 if (!priv)
221 return IRQ_NONE;
222
223 /* dram interrupt table not set yet,
224 * use legacy interrupt.
225 */
226 if (!priv->_agn.use_ict)
227 return iwl_isr(irq, data);
228
229 spin_lock(&priv->lock);
230
231 /* Disable (but don't clear!) interrupts here to avoid
232 * back-to-back ISRs and sporadic interrupts from our NIC.
233 * If we have something to service, the tasklet will re-enable ints.
234 * If we *don't* have something, we'll re-enable before leaving here.
235 */
236 inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */
237 iwl_write32(priv, CSR_INT_MASK, 0x00000000);
238
239
240 /* Ignore interrupt if there's nothing in NIC to service.
241 * This may be due to IRQ shared with another device,
242 * or due to sporadic interrupts thrown from our NIC. */
243 if (!priv->_agn.ict_tbl[priv->_agn.ict_index]) {
244 IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0\n");
245 goto none;
246 }
247
248 /* read all entries that not 0 start with ict_index */
249 while (priv->_agn.ict_tbl[priv->_agn.ict_index]) {
250
251 val |= le32_to_cpu(priv->_agn.ict_tbl[priv->_agn.ict_index]);
252 IWL_DEBUG_ISR(priv, "ICT index %d value 0x%08X\n",
253 priv->_agn.ict_index,
254 le32_to_cpu(priv->_agn.ict_tbl[priv->_agn.ict_index]));
255 priv->_agn.ict_tbl[priv->_agn.ict_index] = 0;
256 priv->_agn.ict_index = iwl_queue_inc_wrap(priv->_agn.ict_index,
257 ICT_COUNT);
258
259 }
260
261 /* We should not get this value, just ignore it. */
262 if (val == 0xffffffff)
263 val = 0;
264
265 /*
266 * this is a w/a for a h/w bug. the h/w bug may cause the Rx bit
267 * (bit 15 before shifting it to 31) to clear when using interrupt
268 * coalescing. fortunately, bits 18 and 19 stay set when this happens
269 * so we use them to decide on the real state of the Rx bit.
270 * In order words, bit 15 is set if bit 18 or bit 19 are set.
271 */
272 if (val & 0xC0000)
273 val |= 0x8000;
274
275 inta = (0xff & val) | ((0xff00 & val) << 16);
276 IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x ict 0x%08x\n",
277 inta, inta_mask, val);
278
279 inta &= priv->inta_mask;
280 priv->_agn.inta |= inta;
281
282 /* iwl_irq_tasklet() will service interrupts and re-enable them */
283 if (likely(inta))
284 tasklet_schedule(&priv->irq_tasklet);
285 else if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->_agn.inta) {
286 /* Allow interrupt if was disabled by this handler and
287 * no tasklet was schedules, We should not enable interrupt,
288 * tasklet will enable it.
289 */
290 iwl_enable_interrupts(priv);
291 }
292
293 spin_unlock(&priv->lock);
294 return IRQ_HANDLED;
295
296 none:
297 /* re-enable interrupts here since we don't have anything to service.
298 * only Re-enable if disabled by irq.
299 */
300 if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->_agn.inta)
301 iwl_enable_interrupts(priv);
302
303 spin_unlock(&priv->lock);
304 return IRQ_NONE;
305}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 8bf7c20b9d39..5155b1a027eb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -597,10 +597,6 @@ static u16 rs_get_supported_rates(struct iwl_lq_sta *lq_sta,
597 struct ieee80211_hdr *hdr, 597 struct ieee80211_hdr *hdr,
598 enum iwl_table_type rate_type) 598 enum iwl_table_type rate_type)
599{ 599{
600 if (hdr && is_multicast_ether_addr(hdr->addr1) &&
601 lq_sta->active_rate_basic)
602 return lq_sta->active_rate_basic;
603
604 if (is_legacy(rate_type)) { 600 if (is_legacy(rate_type)) {
605 return lq_sta->active_legacy_rate; 601 return lq_sta->active_legacy_rate;
606 } else { 602 } else {
@@ -773,6 +769,15 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
773 769
774 IWL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n"); 770 IWL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n");
775 771
772 /* Treat uninitialized rate scaling data same as non-existing. */
773 if (!lq_sta) {
774 IWL_DEBUG_RATE(priv, "Station rate scaling not created yet.\n");
775 return;
776 } else if (!lq_sta->drv) {
777 IWL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n");
778 return;
779 }
780
776 if (!ieee80211_is_data(hdr->frame_control) || 781 if (!ieee80211_is_data(hdr->frame_control) ||
777 info->flags & IEEE80211_TX_CTL_NO_ACK) 782 info->flags & IEEE80211_TX_CTL_NO_ACK)
778 return; 783 return;
@@ -782,10 +787,6 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
782 !(info->flags & IEEE80211_TX_STAT_AMPDU)) 787 !(info->flags & IEEE80211_TX_STAT_AMPDU))
783 return; 788 return;
784 789
785 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
786 !lq_sta->ibss_sta_added)
787 return;
788
789 /* 790 /*
790 * Ignore this Tx frame response if its initial rate doesn't match 791 * Ignore this Tx frame response if its initial rate doesn't match
791 * that of latest Link Quality command. There may be stragglers 792 * that of latest Link Quality command. There may be stragglers
@@ -831,7 +832,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
831 lq_sta->missed_rate_counter++; 832 lq_sta->missed_rate_counter++;
832 if (lq_sta->missed_rate_counter > IWL_MISSED_RATE_MAX) { 833 if (lq_sta->missed_rate_counter > IWL_MISSED_RATE_MAX) {
833 lq_sta->missed_rate_counter = 0; 834 lq_sta->missed_rate_counter = 0;
834 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); 835 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC, false);
835 } 836 }
836 /* Regardless, ignore this status info for outdated rate */ 837 /* Regardless, ignore this status info for outdated rate */
837 return; 838 return;
@@ -1919,7 +1920,7 @@ static u32 rs_update_rate_tbl(struct iwl_priv *priv,
1919 /* Update uCode's rate table. */ 1920 /* Update uCode's rate table. */
1920 rate = rate_n_flags_from_tbl(priv, tbl, index, is_green); 1921 rate = rate_n_flags_from_tbl(priv, tbl, index, is_green);
1921 rs_fill_link_cmd(priv, lq_sta, rate); 1922 rs_fill_link_cmd(priv, lq_sta, rate);
1922 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); 1923 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC, false);
1923 1924
1924 return rate; 1925 return rate;
1925} 1926}
@@ -2295,7 +2296,7 @@ lq_update:
2295 IWL_DEBUG_RATE(priv, "Switch current mcs: %X index: %d\n", 2296 IWL_DEBUG_RATE(priv, "Switch current mcs: %X index: %d\n",
2296 tbl->current_rate, index); 2297 tbl->current_rate, index);
2297 rs_fill_link_cmd(priv, lq_sta, tbl->current_rate); 2298 rs_fill_link_cmd(priv, lq_sta, tbl->current_rate);
2298 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); 2299 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC, false);
2299 } else 2300 } else
2300 done_search = 1; 2301 done_search = 1;
2301 } 2302 }
@@ -2344,7 +2345,20 @@ out:
2344 return; 2345 return;
2345} 2346}
2346 2347
2347 2348/**
2349 * rs_initialize_lq - Initialize a station's hardware rate table
2350 *
2351 * The uCode's station table contains a table of fallback rates
2352 * for automatic fallback during transmission.
2353 *
2354 * NOTE: This sets up a default set of values. These will be replaced later
2355 * if the driver's iwl-agn-rs rate scaling algorithm is used, instead of
2356 * rc80211_simple.
2357 *
2358 * NOTE: Run REPLY_ADD_STA command to set up station table entry, before
2359 * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD,
2360 * which requires station table entry to exist).
2361 */
2348static void rs_initialize_lq(struct iwl_priv *priv, 2362static void rs_initialize_lq(struct iwl_priv *priv,
2349 struct ieee80211_conf *conf, 2363 struct ieee80211_conf *conf,
2350 struct ieee80211_sta *sta, 2364 struct ieee80211_sta *sta,
@@ -2363,10 +2377,6 @@ static void rs_initialize_lq(struct iwl_priv *priv,
2363 2377
2364 i = lq_sta->last_txrate_idx; 2378 i = lq_sta->last_txrate_idx;
2365 2379
2366 if ((lq_sta->lq.sta_id == 0xff) &&
2367 (priv->iw_mode == NL80211_IFTYPE_ADHOC))
2368 goto out;
2369
2370 valid_tx_ant = priv->hw_params.valid_tx_ant; 2380 valid_tx_ant = priv->hw_params.valid_tx_ant;
2371 2381
2372 if (!lq_sta->search_better_tbl) 2382 if (!lq_sta->search_better_tbl)
@@ -2394,7 +2404,8 @@ static void rs_initialize_lq(struct iwl_priv *priv,
2394 tbl->current_rate = rate; 2404 tbl->current_rate = rate;
2395 rs_set_expected_tpt_table(lq_sta, tbl); 2405 rs_set_expected_tpt_table(lq_sta, tbl);
2396 rs_fill_link_cmd(NULL, lq_sta, rate); 2406 rs_fill_link_cmd(NULL, lq_sta, rate);
2397 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); 2407 priv->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq;
2408 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_SYNC, true);
2398 out: 2409 out:
2399 return; 2410 return;
2400} 2411}
@@ -2406,9 +2417,6 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
2406 struct sk_buff *skb = txrc->skb; 2417 struct sk_buff *skb = txrc->skb;
2407 struct ieee80211_supported_band *sband = txrc->sband; 2418 struct ieee80211_supported_band *sband = txrc->sband;
2408 struct iwl_priv *priv = (struct iwl_priv *)priv_r; 2419 struct iwl_priv *priv = (struct iwl_priv *)priv_r;
2409 struct ieee80211_conf *conf = &priv->hw->conf;
2410 struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
2411 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2412 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 2420 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2413 struct iwl_lq_sta *lq_sta = priv_sta; 2421 struct iwl_lq_sta *lq_sta = priv_sta;
2414 int rate_idx; 2422 int rate_idx;
@@ -2426,30 +2434,18 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
2426 lq_sta->max_rate_idx = -1; 2434 lq_sta->max_rate_idx = -1;
2427 } 2435 }
2428 2436
2437 /* Treat uninitialized rate scaling data same as non-existing. */
2438 if (lq_sta && !lq_sta->drv) {
2439 IWL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n");
2440 priv_sta = NULL;
2441 }
2442
2429 /* Send management frames and NO_ACK data using lowest rate. */ 2443 /* Send management frames and NO_ACK data using lowest rate. */
2430 if (rate_control_send_low(sta, priv_sta, txrc)) 2444 if (rate_control_send_low(sta, priv_sta, txrc))
2431 return; 2445 return;
2432 2446
2433 rate_idx = lq_sta->last_txrate_idx; 2447 rate_idx = lq_sta->last_txrate_idx;
2434 2448
2435 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
2436 !lq_sta->ibss_sta_added) {
2437 u8 sta_id = iwl_find_station(priv, hdr->addr1);
2438
2439 if (sta_id == IWL_INVALID_STATION) {
2440 IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n",
2441 hdr->addr1);
2442 sta_id = iwl_add_station(priv, hdr->addr1,
2443 false, CMD_ASYNC, ht_cap);
2444 }
2445 if ((sta_id != IWL_INVALID_STATION)) {
2446 lq_sta->lq.sta_id = sta_id;
2447 lq_sta->lq.rs_table[0].rate_n_flags = 0;
2448 lq_sta->ibss_sta_added = 1;
2449 rs_initialize_lq(priv, conf, sta, lq_sta);
2450 }
2451 }
2452
2453 if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { 2449 if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) {
2454 rate_idx -= IWL_FIRST_OFDM_RATE; 2450 rate_idx -= IWL_FIRST_OFDM_RATE;
2455 /* 6M and 9M shared same MCS index */ 2451 /* 6M and 9M shared same MCS index */
@@ -2499,16 +2495,25 @@ static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta,
2499 return lq_sta; 2495 return lq_sta;
2500} 2496}
2501 2497
2502static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband, 2498/*
2503 struct ieee80211_sta *sta, void *priv_sta) 2499 * Called after adding a new station to initialize rate scaling
2500 */
2501void iwl_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_id)
2504{ 2502{
2505 int i, j; 2503 int i, j;
2506 struct iwl_priv *priv = (struct iwl_priv *)priv_r; 2504 struct ieee80211_hw *hw = priv->hw;
2507 struct ieee80211_conf *conf = &priv->hw->conf; 2505 struct ieee80211_conf *conf = &priv->hw->conf;
2508 struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; 2506 struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
2509 struct iwl_lq_sta *lq_sta = priv_sta; 2507 struct iwl_station_priv *sta_priv;
2508 struct iwl_lq_sta *lq_sta;
2509 struct ieee80211_supported_band *sband;
2510
2511 sta_priv = (struct iwl_station_priv *) sta->drv_priv;
2512 lq_sta = &sta_priv->lq_sta;
2513 sband = hw->wiphy->bands[conf->channel->band];
2514
2510 2515
2511 lq_sta->lq.sta_id = 0xff; 2516 lq_sta->lq.sta_id = sta_id;
2512 2517
2513 for (j = 0; j < LQ_SIZE; j++) 2518 for (j = 0; j < LQ_SIZE; j++)
2514 for (i = 0; i < IWL_RATE_COUNT; i++) 2519 for (i = 0; i < IWL_RATE_COUNT; i++)
@@ -2520,39 +2525,18 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
2520 for (i = 0; i < IWL_RATE_COUNT; i++) 2525 for (i = 0; i < IWL_RATE_COUNT; i++)
2521 rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); 2526 rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]);
2522 2527
2523 IWL_DEBUG_RATE(priv, "LQ: *** rate scale station global init ***\n"); 2528 IWL_DEBUG_RATE(priv, "LQ: *** rate scale station global init for station %d ***\n",
2529 sta_id);
2524 /* TODO: what is a good starting rate for STA? About middle? Maybe not 2530 /* TODO: what is a good starting rate for STA? About middle? Maybe not
2525 * the lowest or the highest rate.. Could consider using RSSI from 2531 * the lowest or the highest rate.. Could consider using RSSI from
2526 * previous packets? Need to have IEEE 802.1X auth succeed immediately 2532 * previous packets? Need to have IEEE 802.1X auth succeed immediately
2527 * after assoc.. */ 2533 * after assoc.. */
2528 2534
2529 lq_sta->ibss_sta_added = 0;
2530 if (priv->iw_mode == NL80211_IFTYPE_AP) {
2531 u8 sta_id = iwl_find_station(priv,
2532 sta->addr);
2533
2534 /* for IBSS the call are from tasklet */
2535 IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", sta->addr);
2536
2537 if (sta_id == IWL_INVALID_STATION) {
2538 IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", sta->addr);
2539 sta_id = iwl_add_station(priv, sta->addr, false,
2540 CMD_ASYNC, ht_cap);
2541 }
2542 if ((sta_id != IWL_INVALID_STATION)) {
2543 lq_sta->lq.sta_id = sta_id;
2544 lq_sta->lq.rs_table[0].rate_n_flags = 0;
2545 }
2546 /* FIXME: this is w/a remove it later */
2547 priv->assoc_station_added = 1;
2548 }
2549
2550 lq_sta->is_dup = 0; 2535 lq_sta->is_dup = 0;
2551 lq_sta->max_rate_idx = -1; 2536 lq_sta->max_rate_idx = -1;
2552 lq_sta->missed_rate_counter = IWL_MISSED_RATE_MAX; 2537 lq_sta->missed_rate_counter = IWL_MISSED_RATE_MAX;
2553 lq_sta->is_green = rs_use_green(sta, &priv->current_ht_config); 2538 lq_sta->is_green = rs_use_green(sta, &priv->current_ht_config);
2554 lq_sta->active_legacy_rate = priv->active_rate & ~(0x1000); 2539 lq_sta->active_legacy_rate = priv->active_rate & ~(0x1000);
2555 lq_sta->active_rate_basic = priv->active_rate_basic;
2556 lq_sta->band = priv->band; 2540 lq_sta->band = priv->band;
2557 /* 2541 /*
2558 * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), 2542 * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3),
@@ -2800,7 +2784,7 @@ static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file,
2800 2784
2801 if (lq_sta->dbg_fixed_rate) { 2785 if (lq_sta->dbg_fixed_rate) {
2802 rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); 2786 rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate);
2803 iwl_send_lq_cmd(lq_sta->drv, &lq_sta->lq, CMD_ASYNC); 2787 iwl_send_lq_cmd(lq_sta->drv, &lq_sta->lq, CMD_ASYNC, false);
2804 } 2788 }
2805 2789
2806 return count; 2790 return count;
@@ -2956,12 +2940,8 @@ static ssize_t rs_sta_dbgfs_rate_scale_data_read(struct file *file,
2956 desc += sprintf(buff+desc, 2940 desc += sprintf(buff+desc,
2957 "Bit Rate= %d Mb/s\n", 2941 "Bit Rate= %d Mb/s\n",
2958 iwl_rates[lq_sta->last_txrate_idx].ieee >> 1); 2942 iwl_rates[lq_sta->last_txrate_idx].ieee >> 1);
2959 desc += sprintf(buff+desc, 2943 desc += sprintf(buff+desc, "Noise Level= %d dBm\n",
2960 "Signal Level= %d dBm\tNoise Level= %d dBm\n", 2944 priv->last_rx_noise);
2961 priv->last_rx_rssi, priv->last_rx_noise);
2962 desc += sprintf(buff+desc,
2963 "Tsf= 0x%llx\tBeacon time= 0x%08X\n",
2964 priv->last_tsf, priv->last_beacon_time);
2965 2945
2966 ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); 2946 ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
2967 return ret; 2947 return ret;
@@ -3001,12 +2981,21 @@ static void rs_remove_debugfs(void *priv, void *priv_sta)
3001} 2981}
3002#endif 2982#endif
3003 2983
2984/*
2985 * Initialization of rate scaling information is done by driver after
2986 * the station is added. Since mac80211 calls this function before a
2987 * station is added we ignore it.
2988 */
2989static void rs_rate_init_stub(void *priv_r, struct ieee80211_supported_band *sband,
2990 struct ieee80211_sta *sta, void *priv_sta)
2991{
2992}
3004static struct rate_control_ops rs_ops = { 2993static struct rate_control_ops rs_ops = {
3005 .module = NULL, 2994 .module = NULL,
3006 .name = RS_NAME, 2995 .name = RS_NAME,
3007 .tx_status = rs_tx_status, 2996 .tx_status = rs_tx_status,
3008 .get_rate = rs_get_rate, 2997 .get_rate = rs_get_rate,
3009 .rate_init = rs_rate_init, 2998 .rate_init = rs_rate_init_stub,
3010 .alloc = rs_alloc, 2999 .alloc = rs_alloc,
3011 .free = rs_free, 3000 .free = rs_free,
3012 .alloc_sta = rs_alloc_sta, 3001 .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 e71923961e69..8292f6d48ec6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
@@ -403,7 +403,6 @@ struct iwl_lq_sta {
403 u8 is_green; 403 u8 is_green;
404 u8 is_dup; 404 u8 is_dup;
405 enum ieee80211_band band; 405 enum ieee80211_band band;
406 u8 ibss_sta_added;
407 406
408 /* The following are bitmaps of rates; IWL_RATE_6M_MASK, etc. */ 407 /* The following are bitmaps of rates; IWL_RATE_6M_MASK, etc. */
409 u32 supp_rates; 408 u32 supp_rates;
@@ -411,7 +410,6 @@ struct iwl_lq_sta {
411 u16 active_siso_rate; 410 u16 active_siso_rate;
412 u16 active_mimo2_rate; 411 u16 active_mimo2_rate;
413 u16 active_mimo3_rate; 412 u16 active_mimo3_rate;
414 u16 active_rate_basic;
415 s8 max_rate_idx; /* Max rate set by user */ 413 s8 max_rate_idx; /* Max rate set by user */
416 u8 missed_rate_counter; 414 u8 missed_rate_counter;
417 415
@@ -479,6 +477,12 @@ static inline u8 iwl3945_get_prev_ieee_rate(u8 rate_index)
479 */ 477 */
480extern void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); 478extern void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id);
481 479
480/* Initialize station's rate scaling information after adding station */
481extern void iwl_rs_rate_init(struct iwl_priv *priv,
482 struct ieee80211_sta *sta, u8 sta_id);
483extern void iwl3945_rs_rate_init(struct iwl_priv *priv,
484 struct ieee80211_sta *sta, u8 sta_id);
485
482/** 486/**
483 * iwl_rate_control_register - Register the rate control algorithm callbacks 487 * iwl_rate_control_register - Register the rate control algorithm callbacks
484 * 488 *
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index e4c2e1e448ad..f43a45d0f1dd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -54,6 +54,7 @@
54#include "iwl-helpers.h" 54#include "iwl-helpers.h"
55#include "iwl-sta.h" 55#include "iwl-sta.h"
56#include "iwl-calib.h" 56#include "iwl-calib.h"
57#include "iwl-agn.h"
57 58
58 59
59/****************************************************************************** 60/******************************************************************************
@@ -143,9 +144,6 @@ int iwl_commit_rxon(struct iwl_priv *priv)
143 return 0; 144 return 0;
144 } 145 }
145 146
146 /* station table will be cleared */
147 priv->assoc_station_added = 0;
148
149 /* If we are currently associated and the new config requires 147 /* If we are currently associated and the new config requires
150 * an RXON_ASSOC and the new config wants the associated mask enabled, 148 * an RXON_ASSOC and the new config wants the associated mask enabled,
151 * we must clear the associated from the active configuration 149 * we must clear the associated from the active configuration
@@ -165,6 +163,8 @@ int iwl_commit_rxon(struct iwl_priv *priv)
165 IWL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret); 163 IWL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret);
166 return ret; 164 return ret;
167 } 165 }
166 iwl_clear_ucode_stations(priv, false);
167 iwl_restore_stations(priv);
168 } 168 }
169 169
170 IWL_DEBUG_INFO(priv, "Sending RXON\n" 170 IWL_DEBUG_INFO(priv, "Sending RXON\n"
@@ -178,9 +178,8 @@ int iwl_commit_rxon(struct iwl_priv *priv)
178 iwl_set_rxon_hwcrypto(priv, !priv->cfg->mod_params->sw_crypto); 178 iwl_set_rxon_hwcrypto(priv, !priv->cfg->mod_params->sw_crypto);
179 179
180 /* Apply the new configuration 180 /* Apply the new configuration
181 * RXON unassoc clears the station table in uCode, send it before 181 * RXON unassoc clears the station table in uCode so restoration of
182 * we add the bcast station. If assoc bit is set, we will send RXON 182 * stations is needed after it (the RXON command) completes
183 * after having added the bcast and bssid station.
184 */ 183 */
185 if (!new_assoc) { 184 if (!new_assoc) {
186 ret = iwl_send_cmd_pdu(priv, REPLY_RXON, 185 ret = iwl_send_cmd_pdu(priv, REPLY_RXON,
@@ -189,35 +188,14 @@ int iwl_commit_rxon(struct iwl_priv *priv)
189 IWL_ERR(priv, "Error setting new RXON (%d)\n", ret); 188 IWL_ERR(priv, "Error setting new RXON (%d)\n", ret);
190 return ret; 189 return ret;
191 } 190 }
191 IWL_DEBUG_INFO(priv, "Return from !new_assoc RXON. \n");
192 memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon)); 192 memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon));
193 iwl_clear_ucode_stations(priv, false);
194 iwl_restore_stations(priv);
193 } 195 }
194 196
195 iwl_clear_stations_table(priv);
196
197 priv->start_calib = 0; 197 priv->start_calib = 0;
198
199 /* Add the broadcast address so we can send broadcast frames */
200 priv->cfg->ops->lib->add_bcast_station(priv);
201
202
203 /* If we have set the ASSOC_MSK and we are in BSS mode then
204 * add the IWL_AP_ID to the station rate table */
205 if (new_assoc) { 198 if (new_assoc) {
206 if (priv->iw_mode == NL80211_IFTYPE_STATION) {
207 ret = iwl_rxon_add_station(priv,
208 priv->active_rxon.bssid_addr, 1);
209 if (ret == IWL_INVALID_STATION) {
210 IWL_ERR(priv,
211 "Error adding AP address for TX.\n");
212 return -EIO;
213 }
214 priv->assoc_station_added = 1;
215 if (priv->default_wep_key &&
216 iwl_send_static_wepkey_cmd(priv, 0))
217 IWL_ERR(priv,
218 "Could not send WEP static key.\n");
219 }
220
221 /* 199 /*
222 * allow CTS-to-self if possible for new association. 200 * allow CTS-to-self if possible for new association.
223 * this is relevant only for 5000 series and up, 201 * this is relevant only for 5000 series and up,
@@ -1266,9 +1244,9 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1266 * hardware bugs here by ACKing all the possible interrupts so that 1244 * hardware bugs here by ACKing all the possible interrupts so that
1267 * interrupt coalescing can still be achieved. 1245 * interrupt coalescing can still be achieved.
1268 */ 1246 */
1269 iwl_write32(priv, CSR_INT, priv->inta | ~priv->inta_mask); 1247 iwl_write32(priv, CSR_INT, priv->_agn.inta | ~priv->inta_mask);
1270 1248
1271 inta = priv->inta; 1249 inta = priv->_agn.inta;
1272 1250
1273#ifdef CONFIG_IWLWIFI_DEBUG 1251#ifdef CONFIG_IWLWIFI_DEBUG
1274 if (iwl_get_debug_level(priv) & IWL_DL_ISR) { 1252 if (iwl_get_debug_level(priv) & IWL_DL_ISR) {
@@ -1281,8 +1259,8 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1281 1259
1282 spin_unlock_irqrestore(&priv->lock, flags); 1260 spin_unlock_irqrestore(&priv->lock, flags);
1283 1261
1284 /* saved interrupt in inta variable now we can reset priv->inta */ 1262 /* saved interrupt in inta variable now we can reset priv->_agn.inta */
1285 priv->inta = 0; 1263 priv->_agn.inta = 0;
1286 1264
1287 /* Now service all interrupt bits discovered above. */ 1265 /* Now service all interrupt bits discovered above. */
1288 if (inta & CSR_INT_BIT_HW_ERR) { 1266 if (inta & CSR_INT_BIT_HW_ERR) {
@@ -2094,7 +2072,6 @@ static void iwl_alive_start(struct iwl_priv *priv)
2094 goto restart; 2072 goto restart;
2095 } 2073 }
2096 2074
2097 iwl_clear_stations_table(priv);
2098 ret = priv->cfg->ops->lib->alive_notify(priv); 2075 ret = priv->cfg->ops->lib->alive_notify(priv);
2099 if (ret) { 2076 if (ret) {
2100 IWL_WARN(priv, 2077 IWL_WARN(priv,
@@ -2105,13 +2082,19 @@ static void iwl_alive_start(struct iwl_priv *priv)
2105 /* After the ALIVE response, we can send host commands to the uCode */ 2082 /* After the ALIVE response, we can send host commands to the uCode */
2106 set_bit(STATUS_ALIVE, &priv->status); 2083 set_bit(STATUS_ALIVE, &priv->status);
2107 2084
2085 if (priv->cfg->ops->lib->recover_from_tx_stall) {
2086 /* Enable timer to monitor the driver queues */
2087 mod_timer(&priv->monitor_recover,
2088 jiffies +
2089 msecs_to_jiffies(priv->cfg->monitor_recover_period));
2090 }
2091
2108 if (iwl_is_rfkill(priv)) 2092 if (iwl_is_rfkill(priv))
2109 return; 2093 return;
2110 2094
2111 ieee80211_wake_queues(priv->hw); 2095 ieee80211_wake_queues(priv->hw);
2112 2096
2113 priv->active_rate = priv->rates_mask; 2097 priv->active_rate = IWL_RATES_MASK;
2114 priv->active_rate_basic = priv->rates_mask & IWL_BASIC_RATES_MASK;
2115 2098
2116 /* Configure Tx antenna selection based on H/W config */ 2099 /* Configure Tx antenna selection based on H/W config */
2117 if (priv->cfg->ops->hcmd->set_tx_ant) 2100 if (priv->cfg->ops->hcmd->set_tx_ant)
@@ -2151,18 +2134,8 @@ static void iwl_alive_start(struct iwl_priv *priv)
2151 wake_up_interruptible(&priv->wait_command_queue); 2134 wake_up_interruptible(&priv->wait_command_queue);
2152 2135
2153 iwl_power_update_mode(priv, true); 2136 iwl_power_update_mode(priv, true);
2137 IWL_DEBUG_INFO(priv, "Updated power mode\n");
2154 2138
2155 /* reassociate for ADHOC mode */
2156 if (priv->vif && (priv->iw_mode == NL80211_IFTYPE_ADHOC)) {
2157 struct sk_buff *beacon = ieee80211_beacon_get(priv->hw,
2158 priv->vif);
2159 if (beacon)
2160 iwl_mac_beacon_update(priv->hw, beacon);
2161 }
2162
2163
2164 if (test_and_clear_bit(STATUS_MODE_PENDING, &priv->status))
2165 iwl_set_mode(priv, priv->iw_mode);
2166 2139
2167 return; 2140 return;
2168 2141
@@ -2182,7 +2155,7 @@ static void __iwl_down(struct iwl_priv *priv)
2182 if (!exit_pending) 2155 if (!exit_pending)
2183 set_bit(STATUS_EXIT_PENDING, &priv->status); 2156 set_bit(STATUS_EXIT_PENDING, &priv->status);
2184 2157
2185 iwl_clear_stations_table(priv); 2158 iwl_clear_ucode_stations(priv, true);
2186 2159
2187 /* Unblock any waiting calls */ 2160 /* Unblock any waiting calls */
2188 wake_up_interruptible_all(&priv->wait_command_queue); 2161 wake_up_interruptible_all(&priv->wait_command_queue);
@@ -2379,8 +2352,6 @@ static int __iwl_up(struct iwl_priv *priv)
2379 2352
2380 for (i = 0; i < MAX_HW_RESTARTS; i++) { 2353 for (i = 0; i < MAX_HW_RESTARTS; i++) {
2381 2354
2382 iwl_clear_stations_table(priv);
2383
2384 /* load bootstrap state machine, 2355 /* load bootstrap state machine,
2385 * load bootstrap program into processor's memory, 2356 * load bootstrap program into processor's memory,
2386 * prepare to load the "initialize" uCode */ 2357 * prepare to load the "initialize" uCode */
@@ -2521,10 +2492,6 @@ void iwl_post_associate(struct iwl_priv *priv)
2521 return; 2492 return;
2522 } 2493 }
2523 2494
2524 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n",
2525 priv->assoc_id, priv->active_rxon.bssid_addr);
2526
2527
2528 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2495 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2529 return; 2496 return;
2530 2497
@@ -2576,6 +2543,9 @@ void iwl_post_associate(struct iwl_priv *priv)
2576 2543
2577 iwlcore_commit_rxon(priv); 2544 iwlcore_commit_rxon(priv);
2578 2545
2546 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n",
2547 priv->assoc_id, priv->active_rxon.bssid_addr);
2548
2579 switch (priv->iw_mode) { 2549 switch (priv->iw_mode) {
2580 case NL80211_IFTYPE_STATION: 2550 case NL80211_IFTYPE_STATION:
2581 break; 2551 break;
@@ -2585,7 +2555,7 @@ void iwl_post_associate(struct iwl_priv *priv)
2585 /* assume default assoc id */ 2555 /* assume default assoc id */
2586 priv->assoc_id = 1; 2556 priv->assoc_id = 1;
2587 2557
2588 iwl_rxon_add_station(priv, priv->bssid, 0); 2558 iwl_add_local_station(priv, priv->bssid, true);
2589 iwl_send_beacon_cmd(priv); 2559 iwl_send_beacon_cmd(priv);
2590 2560
2591 break; 2561 break;
@@ -2596,9 +2566,6 @@ void iwl_post_associate(struct iwl_priv *priv)
2596 break; 2566 break;
2597 } 2567 }
2598 2568
2599 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
2600 priv->assoc_station_added = 1;
2601
2602 spin_lock_irqsave(&priv->lock, flags); 2569 spin_lock_irqsave(&priv->lock, flags);
2603 iwl_activate_qos(priv, 0); 2570 iwl_activate_qos(priv, 0);
2604 spin_unlock_irqrestore(&priv->lock, flags); 2571 spin_unlock_irqrestore(&priv->lock, flags);
@@ -2889,7 +2856,6 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2889 2856
2890 mutex_lock(&priv->mutex); 2857 mutex_lock(&priv->mutex);
2891 iwl_scan_cancel_timeout(priv, 100); 2858 iwl_scan_cancel_timeout(priv, 100);
2892 mutex_unlock(&priv->mutex);
2893 2859
2894 /* If we are getting WEP group key and we didn't receive any key mapping 2860 /* If we are getting WEP group key and we didn't receive any key mapping
2895 * so far, we are in legacy wep mode (group key only), otherwise we are 2861 * so far, we are in legacy wep mode (group key only), otherwise we are
@@ -2925,6 +2891,7 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2925 ret = -EINVAL; 2891 ret = -EINVAL;
2926 } 2892 }
2927 2893
2894 mutex_unlock(&priv->mutex);
2928 IWL_DEBUG_MAC80211(priv, "leave\n"); 2895 IWL_DEBUG_MAC80211(priv, "leave\n");
2929 2896
2930 return ret; 2897 return ret;
@@ -2957,10 +2924,21 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
2957 return ret; 2924 return ret;
2958 case IEEE80211_AMPDU_TX_START: 2925 case IEEE80211_AMPDU_TX_START:
2959 IWL_DEBUG_HT(priv, "start Tx\n"); 2926 IWL_DEBUG_HT(priv, "start Tx\n");
2960 return iwl_tx_agg_start(priv, sta->addr, tid, ssn); 2927 ret = iwl_tx_agg_start(priv, sta->addr, tid, ssn);
2928 if (ret == 0) {
2929 priv->_agn.agg_tids_count++;
2930 IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n",
2931 priv->_agn.agg_tids_count);
2932 }
2933 return ret;
2961 case IEEE80211_AMPDU_TX_STOP: 2934 case IEEE80211_AMPDU_TX_STOP:
2962 IWL_DEBUG_HT(priv, "stop Tx\n"); 2935 IWL_DEBUG_HT(priv, "stop Tx\n");
2963 ret = iwl_tx_agg_stop(priv, sta->addr, tid); 2936 ret = iwl_tx_agg_stop(priv, sta->addr, tid);
2937 if ((ret == 0) && (priv->_agn.agg_tids_count > 0)) {
2938 priv->_agn.agg_tids_count--;
2939 IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n",
2940 priv->_agn.agg_tids_count);
2941 }
2964 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2942 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2965 return 0; 2943 return 0;
2966 else 2944 else
@@ -2997,18 +2975,7 @@ static void iwl_mac_sta_notify(struct ieee80211_hw *hw,
2997 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; 2975 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
2998 int sta_id; 2976 int sta_id;
2999 2977
3000 /*
3001 * TODO: We really should use this callback to
3002 * actually maintain the station table in
3003 * the device.
3004 */
3005
3006 switch (cmd) { 2978 switch (cmd) {
3007 case STA_NOTIFY_ADD:
3008 atomic_set(&sta_priv->pending_frames, 0);
3009 if (vif->type == NL80211_IFTYPE_AP)
3010 sta_priv->client = true;
3011 break;
3012 case STA_NOTIFY_SLEEP: 2979 case STA_NOTIFY_SLEEP:
3013 WARN_ON(!sta_priv->client); 2980 WARN_ON(!sta_priv->client);
3014 sta_priv->asleep = true; 2981 sta_priv->asleep = true;
@@ -3029,6 +2996,55 @@ static void iwl_mac_sta_notify(struct ieee80211_hw *hw,
3029 } 2996 }
3030} 2997}
3031 2998
2999/**
3000 * iwl_restore_wepkeys - Restore WEP keys to device
3001 */
3002static void iwl_restore_wepkeys(struct iwl_priv *priv)
3003{
3004 mutex_lock(&priv->mutex);
3005 if (priv->iw_mode == NL80211_IFTYPE_STATION &&
3006 priv->default_wep_key &&
3007 iwl_send_static_wepkey_cmd(priv, 0))
3008 IWL_ERR(priv, "Could not send WEP static key\n");
3009 mutex_unlock(&priv->mutex);
3010}
3011
3012static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
3013 struct ieee80211_vif *vif,
3014 struct ieee80211_sta *sta)
3015{
3016 struct iwl_priv *priv = hw->priv;
3017 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
3018 bool is_ap = priv->iw_mode == NL80211_IFTYPE_STATION;
3019 int ret;
3020 u8 sta_id;
3021
3022 IWL_DEBUG_INFO(priv, "received request to add station %pM\n",
3023 sta->addr);
3024
3025 atomic_set(&sta_priv->pending_frames, 0);
3026 if (vif->type == NL80211_IFTYPE_AP)
3027 sta_priv->client = true;
3028
3029 ret = iwl_add_station_common(priv, sta->addr, is_ap, &sta->ht_cap,
3030 &sta_id);
3031 if (ret) {
3032 IWL_ERR(priv, "Unable to add station %pM (%d)\n",
3033 sta->addr, ret);
3034 /* Should we return success if return code is EEXIST ? */
3035 return ret;
3036 }
3037
3038 iwl_restore_wepkeys(priv);
3039
3040 /* Initialize rate scaling */
3041 IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM \n",
3042 sta->addr);
3043 iwl_rs_rate_init(priv, sta, sta_id);
3044
3045 return ret;
3046}
3047
3032/***************************************************************************** 3048/*****************************************************************************
3033 * 3049 *
3034 * sysfs attributes 3050 * sysfs attributes
@@ -3129,87 +3145,6 @@ static ssize_t store_tx_power(struct device *d,
3129 3145
3130static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power); 3146static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power);
3131 3147
3132static ssize_t show_flags(struct device *d,
3133 struct device_attribute *attr, char *buf)
3134{
3135 struct iwl_priv *priv = dev_get_drvdata(d);
3136
3137 return sprintf(buf, "0x%04X\n", priv->active_rxon.flags);
3138}
3139
3140static ssize_t store_flags(struct device *d,
3141 struct device_attribute *attr,
3142 const char *buf, size_t count)
3143{
3144 struct iwl_priv *priv = dev_get_drvdata(d);
3145 unsigned long val;
3146 u32 flags;
3147 int ret = strict_strtoul(buf, 0, &val);
3148 if (ret)
3149 return ret;
3150 flags = (u32)val;
3151
3152 mutex_lock(&priv->mutex);
3153 if (le32_to_cpu(priv->staging_rxon.flags) != flags) {
3154 /* Cancel any currently running scans... */
3155 if (iwl_scan_cancel_timeout(priv, 100))
3156 IWL_WARN(priv, "Could not cancel scan.\n");
3157 else {
3158 IWL_DEBUG_INFO(priv, "Commit rxon.flags = 0x%04X\n", flags);
3159 priv->staging_rxon.flags = cpu_to_le32(flags);
3160 iwlcore_commit_rxon(priv);
3161 }
3162 }
3163 mutex_unlock(&priv->mutex);
3164
3165 return count;
3166}
3167
3168static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, show_flags, store_flags);
3169
3170static ssize_t show_filter_flags(struct device *d,
3171 struct device_attribute *attr, char *buf)
3172{
3173 struct iwl_priv *priv = dev_get_drvdata(d);
3174
3175 return sprintf(buf, "0x%04X\n",
3176 le32_to_cpu(priv->active_rxon.filter_flags));
3177}
3178
3179static ssize_t store_filter_flags(struct device *d,
3180 struct device_attribute *attr,
3181 const char *buf, size_t count)
3182{
3183 struct iwl_priv *priv = dev_get_drvdata(d);
3184 unsigned long val;
3185 u32 filter_flags;
3186 int ret = strict_strtoul(buf, 0, &val);
3187 if (ret)
3188 return ret;
3189 filter_flags = (u32)val;
3190
3191 mutex_lock(&priv->mutex);
3192 if (le32_to_cpu(priv->staging_rxon.filter_flags) != filter_flags) {
3193 /* Cancel any currently running scans... */
3194 if (iwl_scan_cancel_timeout(priv, 100))
3195 IWL_WARN(priv, "Could not cancel scan.\n");
3196 else {
3197 IWL_DEBUG_INFO(priv, "Committing rxon.filter_flags = "
3198 "0x%04X\n", filter_flags);
3199 priv->staging_rxon.filter_flags =
3200 cpu_to_le32(filter_flags);
3201 iwlcore_commit_rxon(priv);
3202 }
3203 }
3204 mutex_unlock(&priv->mutex);
3205
3206 return count;
3207}
3208
3209static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, show_filter_flags,
3210 store_filter_flags);
3211
3212
3213static ssize_t show_statistics(struct device *d, 3148static ssize_t show_statistics(struct device *d,
3214 struct device_attribute *attr, char *buf) 3149 struct device_attribute *attr, char *buf)
3215{ 3150{
@@ -3315,6 +3250,13 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)
3315 priv->ucode_trace.data = (unsigned long)priv; 3250 priv->ucode_trace.data = (unsigned long)priv;
3316 priv->ucode_trace.function = iwl_bg_ucode_trace; 3251 priv->ucode_trace.function = iwl_bg_ucode_trace;
3317 3252
3253 if (priv->cfg->ops->lib->recover_from_tx_stall) {
3254 init_timer(&priv->monitor_recover);
3255 priv->monitor_recover.data = (unsigned long)priv;
3256 priv->monitor_recover.function =
3257 priv->cfg->ops->lib->recover_from_tx_stall;
3258 }
3259
3318 if (!priv->cfg->use_isr_legacy) 3260 if (!priv->cfg->use_isr_legacy)
3319 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 3261 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
3320 iwl_irq_tasklet, (unsigned long)priv); 3262 iwl_irq_tasklet, (unsigned long)priv);
@@ -3334,6 +3276,8 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
3334 cancel_work_sync(&priv->beacon_update); 3276 cancel_work_sync(&priv->beacon_update);
3335 del_timer_sync(&priv->statistics_periodic); 3277 del_timer_sync(&priv->statistics_periodic);
3336 del_timer_sync(&priv->ucode_trace); 3278 del_timer_sync(&priv->ucode_trace);
3279 if (priv->cfg->ops->lib->recover_from_tx_stall)
3280 del_timer_sync(&priv->monitor_recover);
3337} 3281}
3338 3282
3339static void iwl_init_hw_rates(struct iwl_priv *priv, 3283static void iwl_init_hw_rates(struct iwl_priv *priv,
@@ -3371,9 +3315,6 @@ static int iwl_init_drv(struct iwl_priv *priv)
3371 mutex_init(&priv->mutex); 3315 mutex_init(&priv->mutex);
3372 mutex_init(&priv->sync_cmd_mutex); 3316 mutex_init(&priv->sync_cmd_mutex);
3373 3317
3374 /* Clear the driver's (not device's) station table */
3375 iwl_clear_stations_table(priv);
3376
3377 priv->ieee_channels = NULL; 3318 priv->ieee_channels = NULL;
3378 priv->ieee_rates = NULL; 3319 priv->ieee_rates = NULL;
3379 priv->band = IEEE80211_BAND_2GHZ; 3320 priv->band = IEEE80211_BAND_2GHZ;
@@ -3381,6 +3322,7 @@ static int iwl_init_drv(struct iwl_priv *priv)
3381 priv->iw_mode = NL80211_IFTYPE_STATION; 3322 priv->iw_mode = NL80211_IFTYPE_STATION;
3382 priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; 3323 priv->current_ht_config.smps = IEEE80211_SMPS_STATIC;
3383 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; 3324 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF;
3325 priv->_agn.agg_tids_count = 0;
3384 3326
3385 /* initialize force reset */ 3327 /* initialize force reset */
3386 priv->force_reset[IWL_RF_RESET].reset_duration = 3328 priv->force_reset[IWL_RF_RESET].reset_duration =
@@ -3399,7 +3341,6 @@ static int iwl_init_drv(struct iwl_priv *priv)
3399 priv->qos_data.qos_active = 0; 3341 priv->qos_data.qos_active = 0;
3400 priv->qos_data.qos_cap.val = 0; 3342 priv->qos_data.qos_cap.val = 0;
3401 3343
3402 priv->rates_mask = IWL_RATES_MASK;
3403 /* Set the tx_power_user_lmt to the lowest power level 3344 /* Set the tx_power_user_lmt to the lowest power level
3404 * this value will get overwritten by channel max power avg 3345 * this value will get overwritten by channel max power avg
3405 * from eeprom */ 3346 * from eeprom */
@@ -3435,8 +3376,6 @@ static void iwl_uninit_drv(struct iwl_priv *priv)
3435} 3376}
3436 3377
3437static struct attribute *iwl_sysfs_entries[] = { 3378static struct attribute *iwl_sysfs_entries[] = {
3438 &dev_attr_flags.attr,
3439 &dev_attr_filter_flags.attr,
3440 &dev_attr_statistics.attr, 3379 &dev_attr_statistics.attr,
3441 &dev_attr_temperature.attr, 3380 &dev_attr_temperature.attr,
3442 &dev_attr_tx_power.attr, 3381 &dev_attr_tx_power.attr,
@@ -3469,6 +3408,8 @@ static struct ieee80211_ops iwl_hw_ops = {
3469 .ampdu_action = iwl_mac_ampdu_action, 3408 .ampdu_action = iwl_mac_ampdu_action,
3470 .hw_scan = iwl_mac_hw_scan, 3409 .hw_scan = iwl_mac_hw_scan,
3471 .sta_notify = iwl_mac_sta_notify, 3410 .sta_notify = iwl_mac_sta_notify,
3411 .sta_add = iwlagn_mac_sta_add,
3412 .sta_remove = iwl_mac_sta_remove,
3472}; 3413};
3473 3414
3474static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 3415static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
@@ -3572,7 +3513,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3572 iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); 3513 iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
3573 3514
3574 iwl_hw_detect(priv); 3515 iwl_hw_detect(priv);
3575 IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s REV=0x%X\n", 3516 IWL_INFO(priv, "Detected %s, REV=0x%X\n",
3576 priv->cfg->name, priv->hw_rev); 3517 priv->cfg->name, priv->hw_rev);
3577 3518
3578 /* We disable the RETRY_TIMEOUT register (0x41) to keep 3519 /* We disable the RETRY_TIMEOUT register (0x41) to keep
@@ -3753,7 +3694,6 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
3753 iwl_rx_queue_free(priv, &priv->rxq); 3694 iwl_rx_queue_free(priv, &priv->rxq);
3754 iwl_hw_txq_ctx_free(priv); 3695 iwl_hw_txq_ctx_free(priv);
3755 3696
3756 iwl_clear_stations_table(priv);
3757 iwl_eeprom_free(priv); 3697 iwl_eeprom_free(priv);
3758 3698
3759 3699
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
new file mode 100644
index 000000000000..26eeb586ee00
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -0,0 +1,74 @@
1/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called LICENSE.GPL.
26 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
33 * Copyright(c) 2005 - 2010 Intel Corporation. All rights reserved.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *****************************************************************************/
62
63#ifndef __iwl_agn_h__
64#define __iwl_agn_h__
65
66#include "iwl-dev.h"
67
68int iwl_reset_ict(struct iwl_priv *priv);
69void iwl_disable_ict(struct iwl_priv *priv);
70int iwl_alloc_isr_ict(struct iwl_priv *priv);
71void iwl_free_isr_ict(struct iwl_priv *priv);
72irqreturn_t iwl_isr_ict(int irq, void *data);
73
74#endif /* __iwl_agn_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 112149e9b31e..5180fb24cd38 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -114,8 +114,6 @@ static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = {
114u32 iwl_debug_level; 114u32 iwl_debug_level;
115EXPORT_SYMBOL(iwl_debug_level); 115EXPORT_SYMBOL(iwl_debug_level);
116 116
117static irqreturn_t iwl_isr(int irq, void *data);
118
119/* 117/*
120 * Parameter order: 118 * Parameter order:
121 * rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate 119 * rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate
@@ -899,23 +897,10 @@ EXPORT_SYMBOL(iwl_full_rxon_required);
899 897
900u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv) 898u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv)
901{ 899{
902 int i; 900 /*
903 int rate_mask; 901 * Assign the lowest rate -- should really get this from
904 902 * the beacon skb from mac80211.
905 /* Set rate mask*/ 903 */
906 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK)
907 rate_mask = priv->active_rate_basic & IWL_CCK_RATES_MASK;
908 else
909 rate_mask = priv->active_rate_basic & IWL_OFDM_RATES_MASK;
910
911 /* Find lowest valid rate */
912 for (i = IWL_RATE_1M_INDEX; i != IWL_RATE_INVALID;
913 i = iwl_rates[i].next_ieee) {
914 if (rate_mask & (1 << i))
915 return iwl_rates[i].plcp;
916 }
917
918 /* No valid rate was found. Assign the lowest one */
919 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) 904 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK)
920 return IWL_RATE_1M_PLCP; 905 return IWL_RATE_1M_PLCP;
921 else 906 else
@@ -1240,14 +1225,6 @@ void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode)
1240 if (!ch_info) 1225 if (!ch_info)
1241 ch_info = &priv->channel_info[0]; 1226 ch_info = &priv->channel_info[0];
1242 1227
1243 /*
1244 * in some case A channels are all non IBSS
1245 * in this case force B/G channel
1246 */
1247 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
1248 !(is_channel_ibss(ch_info)))
1249 ch_info = &priv->channel_info[0];
1250
1251 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); 1228 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel);
1252 priv->band = ch_info->band; 1229 priv->band = ch_info->band;
1253 1230
@@ -1282,7 +1259,6 @@ static void iwl_set_rate(struct iwl_priv *priv)
1282 } 1259 }
1283 1260
1284 priv->active_rate = 0; 1261 priv->active_rate = 0;
1285 priv->active_rate_basic = 0;
1286 1262
1287 for (i = 0; i < hw->n_bitrates; i++) { 1263 for (i = 0; i < hw->n_bitrates; i++) {
1288 rate = &(hw->bitrates[i]); 1264 rate = &(hw->bitrates[i]);
@@ -1290,30 +1266,13 @@ static void iwl_set_rate(struct iwl_priv *priv)
1290 priv->active_rate |= (1 << rate->hw_value); 1266 priv->active_rate |= (1 << rate->hw_value);
1291 } 1267 }
1292 1268
1293 IWL_DEBUG_RATE(priv, "Set active_rate = %0x, active_rate_basic = %0x\n", 1269 IWL_DEBUG_RATE(priv, "Set active_rate = %0x\n", priv->active_rate);
1294 priv->active_rate, priv->active_rate_basic);
1295 1270
1296 /* 1271 priv->staging_rxon.cck_basic_rates =
1297 * If a basic rate is configured, then use it (adding IWL_RATE_1M_MASK) 1272 (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
1298 * otherwise set it to the default of all CCK rates and 6, 12, 24 for 1273
1299 * OFDM 1274 priv->staging_rxon.ofdm_basic_rates =
1300 */ 1275 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
1301 if (priv->active_rate_basic & IWL_CCK_BASIC_RATES_MASK)
1302 priv->staging_rxon.cck_basic_rates =
1303 ((priv->active_rate_basic &
1304 IWL_CCK_RATES_MASK) >> IWL_FIRST_CCK_RATE) & 0xF;
1305 else
1306 priv->staging_rxon.cck_basic_rates =
1307 (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
1308
1309 if (priv->active_rate_basic & IWL_OFDM_BASIC_RATES_MASK)
1310 priv->staging_rxon.ofdm_basic_rates =
1311 ((priv->active_rate_basic &
1312 (IWL_OFDM_BASIC_RATES_MASK | IWL_RATE_6M_MASK)) >>
1313 IWL_FIRST_OFDM_RATE) & 0xFF;
1314 else
1315 priv->staging_rxon.ofdm_basic_rates =
1316 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
1317} 1276}
1318 1277
1319void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) 1278void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
@@ -1397,7 +1356,7 @@ void iwl_irq_handle_error(struct iwl_priv *priv)
1397} 1356}
1398EXPORT_SYMBOL(iwl_irq_handle_error); 1357EXPORT_SYMBOL(iwl_irq_handle_error);
1399 1358
1400int iwl_apm_stop_master(struct iwl_priv *priv) 1359static int iwl_apm_stop_master(struct iwl_priv *priv)
1401{ 1360{
1402 int ret = 0; 1361 int ret = 0;
1403 1362
@@ -1413,7 +1372,6 @@ int iwl_apm_stop_master(struct iwl_priv *priv)
1413 1372
1414 return ret; 1373 return ret;
1415} 1374}
1416EXPORT_SYMBOL(iwl_apm_stop_master);
1417 1375
1418void iwl_apm_stop(struct iwl_priv *priv) 1376void iwl_apm_stop(struct iwl_priv *priv)
1419{ 1377{
@@ -1664,277 +1622,6 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
1664} 1622}
1665EXPORT_SYMBOL(iwl_set_tx_power); 1623EXPORT_SYMBOL(iwl_set_tx_power);
1666 1624
1667#define ICT_COUNT (PAGE_SIZE/sizeof(u32))
1668
1669/* Free dram table */
1670void iwl_free_isr_ict(struct iwl_priv *priv)
1671{
1672 if (priv->ict_tbl_vir) {
1673 dma_free_coherent(&priv->pci_dev->dev,
1674 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
1675 priv->ict_tbl_vir, priv->ict_tbl_dma);
1676 priv->ict_tbl_vir = NULL;
1677 }
1678}
1679EXPORT_SYMBOL(iwl_free_isr_ict);
1680
1681
1682/* allocate dram shared table it is a PAGE_SIZE aligned
1683 * also reset all data related to ICT table interrupt.
1684 */
1685int iwl_alloc_isr_ict(struct iwl_priv *priv)
1686{
1687
1688 if (priv->cfg->use_isr_legacy)
1689 return 0;
1690 /* allocate shrared data table */
1691 priv->ict_tbl_vir = dma_alloc_coherent(&priv->pci_dev->dev,
1692 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
1693 &priv->ict_tbl_dma, GFP_KERNEL);
1694 if (!priv->ict_tbl_vir)
1695 return -ENOMEM;
1696
1697 /* align table to PAGE_SIZE boundry */
1698 priv->aligned_ict_tbl_dma = ALIGN(priv->ict_tbl_dma, PAGE_SIZE);
1699
1700 IWL_DEBUG_ISR(priv, "ict dma addr %Lx dma aligned %Lx diff %d\n",
1701 (unsigned long long)priv->ict_tbl_dma,
1702 (unsigned long long)priv->aligned_ict_tbl_dma,
1703 (int)(priv->aligned_ict_tbl_dma - priv->ict_tbl_dma));
1704
1705 priv->ict_tbl = priv->ict_tbl_vir +
1706 (priv->aligned_ict_tbl_dma - priv->ict_tbl_dma);
1707
1708 IWL_DEBUG_ISR(priv, "ict vir addr %p vir aligned %p diff %d\n",
1709 priv->ict_tbl, priv->ict_tbl_vir,
1710 (int)(priv->aligned_ict_tbl_dma - priv->ict_tbl_dma));
1711
1712 /* reset table and index to all 0 */
1713 memset(priv->ict_tbl_vir,0, (sizeof(u32) * ICT_COUNT) + PAGE_SIZE);
1714 priv->ict_index = 0;
1715
1716 /* add periodic RX interrupt */
1717 priv->inta_mask |= CSR_INT_BIT_RX_PERIODIC;
1718 return 0;
1719}
1720EXPORT_SYMBOL(iwl_alloc_isr_ict);
1721
1722/* Device is going up inform it about using ICT interrupt table,
1723 * also we need to tell the driver to start using ICT interrupt.
1724 */
1725int iwl_reset_ict(struct iwl_priv *priv)
1726{
1727 u32 val;
1728 unsigned long flags;
1729
1730 if (!priv->ict_tbl_vir)
1731 return 0;
1732
1733 spin_lock_irqsave(&priv->lock, flags);
1734 iwl_disable_interrupts(priv);
1735
1736 memset(&priv->ict_tbl[0], 0, sizeof(u32) * ICT_COUNT);
1737
1738 val = priv->aligned_ict_tbl_dma >> PAGE_SHIFT;
1739
1740 val |= CSR_DRAM_INT_TBL_ENABLE;
1741 val |= CSR_DRAM_INIT_TBL_WRAP_CHECK;
1742
1743 IWL_DEBUG_ISR(priv, "CSR_DRAM_INT_TBL_REG =0x%X "
1744 "aligned dma address %Lx\n",
1745 val, (unsigned long long)priv->aligned_ict_tbl_dma);
1746
1747 iwl_write32(priv, CSR_DRAM_INT_TBL_REG, val);
1748 priv->use_ict = true;
1749 priv->ict_index = 0;
1750 iwl_write32(priv, CSR_INT, priv->inta_mask);
1751 iwl_enable_interrupts(priv);
1752 spin_unlock_irqrestore(&priv->lock, flags);
1753
1754 return 0;
1755}
1756EXPORT_SYMBOL(iwl_reset_ict);
1757
1758/* Device is going down disable ict interrupt usage */
1759void iwl_disable_ict(struct iwl_priv *priv)
1760{
1761 unsigned long flags;
1762
1763 spin_lock_irqsave(&priv->lock, flags);
1764 priv->use_ict = false;
1765 spin_unlock_irqrestore(&priv->lock, flags);
1766}
1767EXPORT_SYMBOL(iwl_disable_ict);
1768
1769/* interrupt handler using ict table, with this interrupt driver will
1770 * stop using INTA register to get device's interrupt, reading this register
1771 * is expensive, device will write interrupts in ICT dram table, increment
1772 * index then will fire interrupt to driver, driver will OR all ICT table
1773 * entries from current index up to table entry with 0 value. the result is
1774 * the interrupt we need to service, driver will set the entries back to 0 and
1775 * set index.
1776 */
1777irqreturn_t iwl_isr_ict(int irq, void *data)
1778{
1779 struct iwl_priv *priv = data;
1780 u32 inta, inta_mask;
1781 u32 val = 0;
1782
1783 if (!priv)
1784 return IRQ_NONE;
1785
1786 /* dram interrupt table not set yet,
1787 * use legacy interrupt.
1788 */
1789 if (!priv->use_ict)
1790 return iwl_isr(irq, data);
1791
1792 spin_lock(&priv->lock);
1793
1794 /* Disable (but don't clear!) interrupts here to avoid
1795 * back-to-back ISRs and sporadic interrupts from our NIC.
1796 * If we have something to service, the tasklet will re-enable ints.
1797 * If we *don't* have something, we'll re-enable before leaving here.
1798 */
1799 inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */
1800 iwl_write32(priv, CSR_INT_MASK, 0x00000000);
1801
1802
1803 /* Ignore interrupt if there's nothing in NIC to service.
1804 * This may be due to IRQ shared with another device,
1805 * or due to sporadic interrupts thrown from our NIC. */
1806 if (!priv->ict_tbl[priv->ict_index]) {
1807 IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0\n");
1808 goto none;
1809 }
1810
1811 /* read all entries that not 0 start with ict_index */
1812 while (priv->ict_tbl[priv->ict_index]) {
1813
1814 val |= le32_to_cpu(priv->ict_tbl[priv->ict_index]);
1815 IWL_DEBUG_ISR(priv, "ICT index %d value 0x%08X\n",
1816 priv->ict_index,
1817 le32_to_cpu(priv->ict_tbl[priv->ict_index]));
1818 priv->ict_tbl[priv->ict_index] = 0;
1819 priv->ict_index = iwl_queue_inc_wrap(priv->ict_index,
1820 ICT_COUNT);
1821
1822 }
1823
1824 /* We should not get this value, just ignore it. */
1825 if (val == 0xffffffff)
1826 val = 0;
1827
1828 /*
1829 * this is a w/a for a h/w bug. the h/w bug may cause the Rx bit
1830 * (bit 15 before shifting it to 31) to clear when using interrupt
1831 * coalescing. fortunately, bits 18 and 19 stay set when this happens
1832 * so we use them to decide on the real state of the Rx bit.
1833 * In order words, bit 15 is set if bit 18 or bit 19 are set.
1834 */
1835 if (val & 0xC0000)
1836 val |= 0x8000;
1837
1838 inta = (0xff & val) | ((0xff00 & val) << 16);
1839 IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x ict 0x%08x\n",
1840 inta, inta_mask, val);
1841
1842 inta &= priv->inta_mask;
1843 priv->inta |= inta;
1844
1845 /* iwl_irq_tasklet() will service interrupts and re-enable them */
1846 if (likely(inta))
1847 tasklet_schedule(&priv->irq_tasklet);
1848 else if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->inta) {
1849 /* Allow interrupt if was disabled by this handler and
1850 * no tasklet was schedules, We should not enable interrupt,
1851 * tasklet will enable it.
1852 */
1853 iwl_enable_interrupts(priv);
1854 }
1855
1856 spin_unlock(&priv->lock);
1857 return IRQ_HANDLED;
1858
1859 none:
1860 /* re-enable interrupts here since we don't have anything to service.
1861 * only Re-enable if disabled by irq.
1862 */
1863 if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->inta)
1864 iwl_enable_interrupts(priv);
1865
1866 spin_unlock(&priv->lock);
1867 return IRQ_NONE;
1868}
1869EXPORT_SYMBOL(iwl_isr_ict);
1870
1871
1872static irqreturn_t iwl_isr(int irq, void *data)
1873{
1874 struct iwl_priv *priv = data;
1875 u32 inta, inta_mask;
1876#ifdef CONFIG_IWLWIFI_DEBUG
1877 u32 inta_fh;
1878#endif
1879 if (!priv)
1880 return IRQ_NONE;
1881
1882 spin_lock(&priv->lock);
1883
1884 /* Disable (but don't clear!) interrupts here to avoid
1885 * back-to-back ISRs and sporadic interrupts from our NIC.
1886 * If we have something to service, the tasklet will re-enable ints.
1887 * If we *don't* have something, we'll re-enable before leaving here. */
1888 inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */
1889 iwl_write32(priv, CSR_INT_MASK, 0x00000000);
1890
1891 /* Discover which interrupts are active/pending */
1892 inta = iwl_read32(priv, CSR_INT);
1893
1894 /* Ignore interrupt if there's nothing in NIC to service.
1895 * This may be due to IRQ shared with another device,
1896 * or due to sporadic interrupts thrown from our NIC. */
1897 if (!inta) {
1898 IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0\n");
1899 goto none;
1900 }
1901
1902 if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
1903 /* Hardware disappeared. It might have already raised
1904 * an interrupt */
1905 IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta);
1906 goto unplugged;
1907 }
1908
1909#ifdef CONFIG_IWLWIFI_DEBUG
1910 if (iwl_get_debug_level(priv) & (IWL_DL_ISR)) {
1911 inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS);
1912 IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, "
1913 "fh 0x%08x\n", inta, inta_mask, inta_fh);
1914 }
1915#endif
1916
1917 priv->inta |= inta;
1918 /* iwl_irq_tasklet() will service interrupts and re-enable them */
1919 if (likely(inta))
1920 tasklet_schedule(&priv->irq_tasklet);
1921 else if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->inta)
1922 iwl_enable_interrupts(priv);
1923
1924 unplugged:
1925 spin_unlock(&priv->lock);
1926 return IRQ_HANDLED;
1927
1928 none:
1929 /* re-enable interrupts here since we don't have anything to service. */
1930 /* only Re-enable if diabled by irq and no schedules tasklet. */
1931 if (test_bit(STATUS_INT_ENABLED, &priv->status) && !priv->inta)
1932 iwl_enable_interrupts(priv);
1933
1934 spin_unlock(&priv->lock);
1935 return IRQ_NONE;
1936}
1937
1938irqreturn_t iwl_isr_legacy(int irq, void *data) 1625irqreturn_t iwl_isr_legacy(int irq, void *data)
1939{ 1626{
1940 struct iwl_priv *priv = data; 1627 struct iwl_priv *priv = data;
@@ -2564,11 +2251,6 @@ int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
2564 return -EIO; 2251 return -EIO;
2565 } 2252 }
2566 2253
2567 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
2568 IWL_DEBUG_MAC80211(priv, "leave - not IBSS\n");
2569 return -EIO;
2570 }
2571
2572 spin_lock_irqsave(&priv->lock, flags); 2254 spin_lock_irqsave(&priv->lock, flags);
2573 2255
2574 if (priv->ibss_beacon) 2256 if (priv->ibss_beacon)
@@ -2592,43 +2274,19 @@ int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
2592} 2274}
2593EXPORT_SYMBOL(iwl_mac_beacon_update); 2275EXPORT_SYMBOL(iwl_mac_beacon_update);
2594 2276
2595int iwl_set_mode(struct iwl_priv *priv, int mode) 2277static int iwl_set_mode(struct iwl_priv *priv, struct ieee80211_vif *vif)
2596{ 2278{
2597 if (mode == NL80211_IFTYPE_ADHOC) { 2279 iwl_connection_init_rx_config(priv, vif->type);
2598 const struct iwl_channel_info *ch_info;
2599
2600 ch_info = iwl_get_channel_info(priv,
2601 priv->band,
2602 le16_to_cpu(priv->staging_rxon.channel));
2603
2604 if (!ch_info || !is_channel_ibss(ch_info)) {
2605 IWL_ERR(priv, "channel %d not IBSS channel\n",
2606 le16_to_cpu(priv->staging_rxon.channel));
2607 return -EINVAL;
2608 }
2609 }
2610
2611 iwl_connection_init_rx_config(priv, mode);
2612 2280
2613 if (priv->cfg->ops->hcmd->set_rxon_chain) 2281 if (priv->cfg->ops->hcmd->set_rxon_chain)
2614 priv->cfg->ops->hcmd->set_rxon_chain(priv); 2282 priv->cfg->ops->hcmd->set_rxon_chain(priv);
2615 2283
2616 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN); 2284 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
2617 2285
2618 iwl_clear_stations_table(priv); 2286 return iwlcore_commit_rxon(priv);
2619
2620 /* dont commit rxon if rf-kill is on*/
2621 if (!iwl_is_ready_rf(priv))
2622 return -EAGAIN;
2623
2624 iwlcore_commit_rxon(priv);
2625
2626 return 0;
2627} 2287}
2628EXPORT_SYMBOL(iwl_set_mode);
2629 2288
2630int iwl_mac_add_interface(struct ieee80211_hw *hw, 2289int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
2631 struct ieee80211_vif *vif)
2632{ 2290{
2633 struct iwl_priv *priv = hw->priv; 2291 struct iwl_priv *priv = hw->priv;
2634 int err = 0; 2292 int err = 0;
@@ -2637,6 +2295,11 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw,
2637 2295
2638 mutex_lock(&priv->mutex); 2296 mutex_lock(&priv->mutex);
2639 2297
2298 if (WARN_ON(!iwl_is_ready_rf(priv))) {
2299 err = -EINVAL;
2300 goto out;
2301 }
2302
2640 if (priv->vif) { 2303 if (priv->vif) {
2641 IWL_DEBUG_MAC80211(priv, "leave - vif != NULL\n"); 2304 IWL_DEBUG_MAC80211(priv, "leave - vif != NULL\n");
2642 err = -EOPNOTSUPP; 2305 err = -EOPNOTSUPP;
@@ -2646,15 +2309,21 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw,
2646 priv->vif = vif; 2309 priv->vif = vif;
2647 priv->iw_mode = vif->type; 2310 priv->iw_mode = vif->type;
2648 2311
2649 if (vif->addr) { 2312 IWL_DEBUG_MAC80211(priv, "Set %pM\n", vif->addr);
2650 IWL_DEBUG_MAC80211(priv, "Set %pM\n", vif->addr); 2313 memcpy(priv->mac_addr, vif->addr, ETH_ALEN);
2651 memcpy(priv->mac_addr, vif->addr, ETH_ALEN);
2652 }
2653 2314
2654 if (iwl_set_mode(priv, vif->type) == -EAGAIN) 2315 err = iwl_set_mode(priv, vif);
2655 /* we are not ready, will run again when ready */ 2316 if (err)
2656 set_bit(STATUS_MODE_PENDING, &priv->status); 2317 goto out_err;
2657 2318
2319 /* Add the broadcast address so we can send broadcast frames */
2320 priv->cfg->ops->lib->add_bcast_station(priv);
2321
2322 goto out;
2323
2324 out_err:
2325 priv->vif = NULL;
2326 priv->iw_mode = NL80211_IFTYPE_STATION;
2658 out: 2327 out:
2659 mutex_unlock(&priv->mutex); 2328 mutex_unlock(&priv->mutex);
2660 2329
@@ -2664,7 +2333,7 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw,
2664EXPORT_SYMBOL(iwl_mac_add_interface); 2333EXPORT_SYMBOL(iwl_mac_add_interface);
2665 2334
2666void iwl_mac_remove_interface(struct ieee80211_hw *hw, 2335void iwl_mac_remove_interface(struct ieee80211_hw *hw,
2667 struct ieee80211_vif *vif) 2336 struct ieee80211_vif *vif)
2668{ 2337{
2669 struct iwl_priv *priv = hw->priv; 2338 struct iwl_priv *priv = hw->priv;
2670 2339
@@ -2672,6 +2341,8 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw,
2672 2341
2673 mutex_lock(&priv->mutex); 2342 mutex_lock(&priv->mutex);
2674 2343
2344 iwl_clear_ucode_stations(priv, true);
2345
2675 if (iwl_is_ready_rf(priv)) { 2346 if (iwl_is_ready_rf(priv)) {
2676 iwl_scan_cancel_timeout(priv, 100); 2347 iwl_scan_cancel_timeout(priv, 100);
2677 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2348 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
@@ -2748,15 +2419,6 @@ int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
2748 goto set_ch_out; 2419 goto set_ch_out;
2749 } 2420 }
2750 2421
2751 if (priv->iw_mode == NL80211_IFTYPE_ADHOC &&
2752 !is_channel_ibss(ch_info)) {
2753 IWL_ERR(priv, "channel %d in band %d not "
2754 "IBSS channel\n",
2755 conf->channel->hw_value, conf->channel->band);
2756 ret = -EINVAL;
2757 goto set_ch_out;
2758 }
2759
2760 spin_lock_irqsave(&priv->lock, flags); 2422 spin_lock_irqsave(&priv->lock, flags);
2761 2423
2762 /* Configure HT40 channels */ 2424 /* Configure HT40 channels */
@@ -2868,7 +2530,6 @@ void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
2868 spin_lock_irqsave(&priv->lock, flags); 2530 spin_lock_irqsave(&priv->lock, flags);
2869 priv->assoc_id = 0; 2531 priv->assoc_id = 0;
2870 priv->assoc_capability = 0; 2532 priv->assoc_capability = 0;
2871 priv->assoc_station_added = 0;
2872 2533
2873 /* new association get rid of ibss beacon skb */ 2534 /* new association get rid of ibss beacon skb */
2874 if (priv->ibss_beacon) 2535 if (priv->ibss_beacon)
@@ -2878,8 +2539,6 @@ void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
2878 2539
2879 priv->beacon_int = priv->vif->bss_conf.beacon_int; 2540 priv->beacon_int = priv->vif->bss_conf.beacon_int;
2880 priv->timestamp = 0; 2541 priv->timestamp = 0;
2881 if ((priv->iw_mode == NL80211_IFTYPE_STATION))
2882 priv->beacon_int = 0;
2883 2542
2884 spin_unlock_irqrestore(&priv->lock, flags); 2543 spin_unlock_irqrestore(&priv->lock, flags);
2885 2544
@@ -2892,17 +2551,9 @@ void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
2892 /* we are restarting association process 2551 /* we are restarting association process
2893 * clear RXON_FILTER_ASSOC_MSK bit 2552 * clear RXON_FILTER_ASSOC_MSK bit
2894 */ 2553 */
2895 if (priv->iw_mode != NL80211_IFTYPE_AP) { 2554 iwl_scan_cancel_timeout(priv, 100);
2896 iwl_scan_cancel_timeout(priv, 100); 2555 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2897 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2556 iwlcore_commit_rxon(priv);
2898 iwlcore_commit_rxon(priv);
2899 }
2900
2901 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
2902 IWL_DEBUG_MAC80211(priv, "leave - not in IBSS\n");
2903 mutex_unlock(&priv->mutex);
2904 return;
2905 }
2906 2557
2907 iwl_set_rate(priv); 2558 iwl_set_rate(priv);
2908 2559
@@ -3400,6 +3051,99 @@ int iwl_force_reset(struct iwl_priv *priv, int mode)
3400 } 3051 }
3401 return 0; 3052 return 0;
3402} 3053}
3054EXPORT_SYMBOL(iwl_force_reset);
3055
3056/**
3057 * iwl_bg_monitor_recover - Timer callback to check for stuck queue and recover
3058 *
3059 * During normal condition (no queue is stuck), the timer is continually set to
3060 * execute every monitor_recover_period milliseconds after the last timer
3061 * expired. When the queue read_ptr is at the same place, the timer is
3062 * shorten to 100mSecs. This is
3063 * 1) to reduce the chance that the read_ptr may wrap around (not stuck)
3064 * 2) to detect the stuck queues quicker before the station and AP can
3065 * disassociate each other.
3066 *
3067 * This function monitors all the tx queues and recover from it if any
3068 * of the queues are stuck.
3069 * 1. It first check the cmd queue for stuck conditions. If it is stuck,
3070 * it will recover by resetting the firmware and return.
3071 * 2. Then, it checks for station association. If it associates it will check
3072 * other queues. If any queue is stuck, it will recover by resetting
3073 * the firmware.
3074 * Note: It the number of times the queue read_ptr to be at the same place to
3075 * be MAX_REPEAT+1 in order to consider to be stuck.
3076 */
3077/*
3078 * The maximum number of times the read pointer of the tx queue at the
3079 * same place without considering to be stuck.
3080 */
3081#define MAX_REPEAT (2)
3082static int iwl_check_stuck_queue(struct iwl_priv *priv, int cnt)
3083{
3084 struct iwl_tx_queue *txq;
3085 struct iwl_queue *q;
3086
3087 txq = &priv->txq[cnt];
3088 q = &txq->q;
3089 /* queue is empty, skip */
3090 if (q->read_ptr != q->write_ptr) {
3091 if (q->read_ptr == q->last_read_ptr) {
3092 /* a queue has not been read from last time */
3093 if (q->repeat_same_read_ptr > MAX_REPEAT) {
3094 IWL_ERR(priv,
3095 "queue %d stuck %d time. Fw reload.\n",
3096 q->id, q->repeat_same_read_ptr);
3097 q->repeat_same_read_ptr = 0;
3098 iwl_force_reset(priv, IWL_FW_RESET);
3099 } else {
3100 q->repeat_same_read_ptr++;
3101 IWL_DEBUG_RADIO(priv,
3102 "queue %d, not read %d time\n",
3103 q->id,
3104 q->repeat_same_read_ptr);
3105 mod_timer(&priv->monitor_recover, jiffies +
3106 msecs_to_jiffies(IWL_ONE_HUNDRED_MSECS));
3107 }
3108 return 1;
3109 } else {
3110 q->last_read_ptr = q->read_ptr;
3111 q->repeat_same_read_ptr = 0;
3112 }
3113 }
3114 return 0;
3115}
3116
3117void iwl_bg_monitor_recover(unsigned long data)
3118{
3119 struct iwl_priv *priv = (struct iwl_priv *)data;
3120 int cnt;
3121
3122 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
3123 return;
3124
3125 /* monitor and check for stuck cmd queue */
3126 if (iwl_check_stuck_queue(priv, IWL_CMD_QUEUE_NUM))
3127 return;
3128
3129 /* monitor and check for other stuck queues */
3130 if (iwl_is_associated(priv)) {
3131 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
3132 /* skip as we already checked the command queue */
3133 if (cnt == IWL_CMD_QUEUE_NUM)
3134 continue;
3135 if (iwl_check_stuck_queue(priv, cnt))
3136 return;
3137 }
3138 }
3139 /*
3140 * Reschedule the timer to occur in
3141 * priv->cfg->monitor_recover_period
3142 */
3143 mod_timer(&priv->monitor_recover,
3144 jiffies + msecs_to_jiffies(priv->cfg->monitor_recover_period));
3145}
3146EXPORT_SYMBOL(iwl_bg_monitor_recover);
3403 3147
3404#ifdef CONFIG_PM 3148#ifdef CONFIG_PM
3405 3149
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 4ef7739f9e8e..b3e698b576e1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -191,6 +191,14 @@ struct iwl_lib_ops {
191 struct iwl_temp_ops temp_ops; 191 struct iwl_temp_ops temp_ops;
192 /* station management */ 192 /* station management */
193 void (*add_bcast_station)(struct iwl_priv *priv); 193 void (*add_bcast_station)(struct iwl_priv *priv);
194 /* recover from tx queue stall */
195 void (*recover_from_tx_stall)(unsigned long data);
196 /* check for plcp health */
197 bool (*check_plcp_health)(struct iwl_priv *priv,
198 struct iwl_rx_packet *pkt);
199 /* check for ack health */
200 bool (*check_ack_health)(struct iwl_priv *priv,
201 struct iwl_rx_packet *pkt);
194}; 202};
195 203
196struct iwl_led_ops { 204struct iwl_led_ops {
@@ -295,6 +303,8 @@ struct iwl_cfg {
295 const bool support_wimax_coexist; 303 const bool support_wimax_coexist;
296 u8 plcp_delta_threshold; 304 u8 plcp_delta_threshold;
297 s32 chain_noise_scale; 305 s32 chain_noise_scale;
306 /* timer period for monitor the driver queues */
307 u32 monitor_recover_period;
298}; 308};
299 309
300/*************************** 310/***************************
@@ -336,7 +346,6 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
336 u32 changes); 346 u32 changes);
337int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb); 347int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb);
338int iwl_commit_rxon(struct iwl_priv *priv); 348int iwl_commit_rxon(struct iwl_priv *priv);
339int iwl_set_mode(struct iwl_priv *priv, int mode);
340int iwl_mac_add_interface(struct ieee80211_hw *hw, 349int iwl_mac_add_interface(struct ieee80211_hw *hw,
341 struct ieee80211_vif *vif); 350 struct ieee80211_vif *vif);
342void iwl_mac_remove_interface(struct ieee80211_hw *hw, 351void iwl_mac_remove_interface(struct ieee80211_hw *hw,
@@ -431,6 +440,10 @@ void iwl_rx_missed_beacon_notif(struct iwl_priv *priv,
431 struct iwl_rx_mem_buffer *rxb); 440 struct iwl_rx_mem_buffer *rxb);
432void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv, 441void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv,
433 struct iwl_rx_mem_buffer *rxb); 442 struct iwl_rx_mem_buffer *rxb);
443bool iwl_good_plcp_health(struct iwl_priv *priv,
444 struct iwl_rx_packet *pkt);
445bool iwl_good_ack_health(struct iwl_priv *priv,
446 struct iwl_rx_packet *pkt);
434void iwl_rx_statistics(struct iwl_priv *priv, 447void iwl_rx_statistics(struct iwl_priv *priv,
435 struct iwl_rx_mem_buffer *rxb); 448 struct iwl_rx_mem_buffer *rxb);
436void iwl_reply_statistics(struct iwl_priv *priv, 449void iwl_reply_statistics(struct iwl_priv *priv,
@@ -560,11 +573,6 @@ int iwl_send_card_state(struct iwl_priv *priv, u32 flags,
560 * PCI * 573 * PCI *
561 *****************************************************/ 574 *****************************************************/
562irqreturn_t iwl_isr_legacy(int irq, void *data); 575irqreturn_t iwl_isr_legacy(int irq, void *data);
563int iwl_reset_ict(struct iwl_priv *priv);
564void iwl_disable_ict(struct iwl_priv *priv);
565int iwl_alloc_isr_ict(struct iwl_priv *priv);
566void iwl_free_isr_ict(struct iwl_priv *priv);
567irqreturn_t iwl_isr_ict(int irq, void *data);
568 576
569static inline u16 iwl_pcie_link_ctl(struct iwl_priv *priv) 577static inline u16 iwl_pcie_link_ctl(struct iwl_priv *priv)
570{ 578{
@@ -574,6 +582,9 @@ static inline u16 iwl_pcie_link_ctl(struct iwl_priv *priv)
574 pci_read_config_word(priv->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); 582 pci_read_config_word(priv->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl);
575 return pci_lnk_ctl; 583 return pci_lnk_ctl;
576} 584}
585
586void iwl_bg_monitor_recover(unsigned long data);
587
577#ifdef CONFIG_PM 588#ifdef CONFIG_PM
578int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state); 589int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state);
579int iwl_pci_resume(struct pci_dev *pdev); 590int iwl_pci_resume(struct pci_dev *pdev);
@@ -622,7 +633,6 @@ void iwlcore_free_geos(struct iwl_priv *priv);
622#define STATUS_SCAN_HW 15 633#define STATUS_SCAN_HW 15
623#define STATUS_POWER_PMI 16 634#define STATUS_POWER_PMI 16
624#define STATUS_FW_ERROR 17 635#define STATUS_FW_ERROR 17
625#define STATUS_MODE_PENDING 18
626 636
627 637
628static inline int iwl_is_ready(struct iwl_priv *priv) 638static inline int iwl_is_ready(struct iwl_priv *priv)
@@ -674,7 +684,7 @@ extern int iwl_send_statistics_request(struct iwl_priv *priv,
674 u8 flags, bool clear); 684 u8 flags, bool clear);
675extern int iwl_verify_ucode(struct iwl_priv *priv); 685extern int iwl_verify_ucode(struct iwl_priv *priv);
676extern int iwl_send_lq_cmd(struct iwl_priv *priv, 686extern int iwl_send_lq_cmd(struct iwl_priv *priv,
677 struct iwl_link_quality_cmd *lq, u8 flags); 687 struct iwl_link_quality_cmd *lq, u8 flags, bool init);
678extern void iwl_rx_reply_rx(struct iwl_priv *priv, 688extern void iwl_rx_reply_rx(struct iwl_priv *priv,
679 struct iwl_rx_mem_buffer *rxb); 689 struct iwl_rx_mem_buffer *rxb);
680extern void iwl_rx_reply_rx_phy(struct iwl_priv *priv, 690extern void iwl_rx_reply_rx_phy(struct iwl_priv *priv,
@@ -682,7 +692,6 @@ extern void iwl_rx_reply_rx_phy(struct iwl_priv *priv,
682void iwl_rx_reply_compressed_ba(struct iwl_priv *priv, 692void iwl_rx_reply_compressed_ba(struct iwl_priv *priv,
683 struct iwl_rx_mem_buffer *rxb); 693 struct iwl_rx_mem_buffer *rxb);
684void iwl_apm_stop(struct iwl_priv *priv); 694void iwl_apm_stop(struct iwl_priv *priv);
685int iwl_apm_stop_master(struct iwl_priv *priv);
686int iwl_apm_init(struct iwl_priv *priv); 695int iwl_apm_init(struct iwl_priv *priv);
687 696
688void iwl_setup_rxon_timing(struct iwl_priv *priv); 697void iwl_setup_rxon_timing(struct iwl_priv *priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 7bf44f146799..5f5820249a29 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -560,8 +560,6 @@ static ssize_t iwl_dbgfs_status_read(struct file *file,
560 test_bit(STATUS_POWER_PMI, &priv->status)); 560 test_bit(STATUS_POWER_PMI, &priv->status));
561 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", 561 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n",
562 test_bit(STATUS_FW_ERROR, &priv->status)); 562 test_bit(STATUS_FW_ERROR, &priv->status));
563 pos += scnprintf(buf + pos, bufsz - pos, "STATUS_MODE_PENDING:\t %d\n",
564 test_bit(STATUS_MODE_PENDING, &priv->status));
565 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 563 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
566} 564}
567 565
@@ -660,7 +658,6 @@ static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
660 int pos = 0, i; 658 int pos = 0, i;
661 char buf[256]; 659 char buf[256];
662 const size_t bufsz = sizeof(buf); 660 const size_t bufsz = sizeof(buf);
663 ssize_t ret;
664 661
665 for (i = 0; i < AC_NUM; i++) { 662 for (i = 0; i < AC_NUM; i++) {
666 pos += scnprintf(buf + pos, bufsz - pos, 663 pos += scnprintf(buf + pos, bufsz - pos,
@@ -672,8 +669,7 @@ static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
672 priv->qos_data.def_qos_parm.ac[i].aifsn, 669 priv->qos_data.def_qos_parm.ac[i].aifsn,
673 priv->qos_data.def_qos_parm.ac[i].edca_txop); 670 priv->qos_data.def_qos_parm.ac[i].edca_txop);
674 } 671 }
675 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 672 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
676 return ret;
677} 673}
678 674
679static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf, 675static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
@@ -683,7 +679,6 @@ static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
683 int pos = 0; 679 int pos = 0;
684 char buf[256]; 680 char buf[256];
685 const size_t bufsz = sizeof(buf); 681 const size_t bufsz = sizeof(buf);
686 ssize_t ret;
687 682
688 pos += scnprintf(buf + pos, bufsz - pos, 683 pos += scnprintf(buf + pos, bufsz - pos,
689 "allow blinking: %s\n", 684 "allow blinking: %s\n",
@@ -697,8 +692,7 @@ static ssize_t iwl_dbgfs_led_read(struct file *file, char __user *user_buf,
697 priv->last_blink_time); 692 priv->last_blink_time);
698 } 693 }
699 694
700 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 695 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
701 return ret;
702} 696}
703 697
704static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file, 698static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
@@ -711,7 +705,6 @@ static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
711 char buf[100]; 705 char buf[100];
712 int pos = 0; 706 int pos = 0;
713 const size_t bufsz = sizeof(buf); 707 const size_t bufsz = sizeof(buf);
714 ssize_t ret;
715 708
716 pos += scnprintf(buf + pos, bufsz - pos, 709 pos += scnprintf(buf + pos, bufsz - pos,
717 "Thermal Throttling Mode: %s\n", 710 "Thermal Throttling Mode: %s\n",
@@ -731,8 +724,7 @@ static ssize_t iwl_dbgfs_thermal_throttling_read(struct file *file,
731 "HT mode: %d\n", 724 "HT mode: %d\n",
732 restriction->is_ht); 725 restriction->is_ht);
733 } 726 }
734 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 727 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
735 return ret;
736} 728}
737 729
738static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file, 730static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
@@ -769,13 +761,11 @@ static ssize_t iwl_dbgfs_disable_ht40_read(struct file *file,
769 char buf[100]; 761 char buf[100];
770 int pos = 0; 762 int pos = 0;
771 const size_t bufsz = sizeof(buf); 763 const size_t bufsz = sizeof(buf);
772 ssize_t ret;
773 764
774 pos += scnprintf(buf + pos, bufsz - pos, 765 pos += scnprintf(buf + pos, bufsz - pos,
775 "11n 40MHz Mode: %s\n", 766 "11n 40MHz Mode: %s\n",
776 priv->disable_ht40 ? "Disabled" : "Enabled"); 767 priv->disable_ht40 ? "Disabled" : "Enabled");
777 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 768 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
778 return ret;
779} 769}
780 770
781static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file, 771static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
@@ -2051,7 +2041,6 @@ static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
2051 int pos = 0; 2041 int pos = 0;
2052 char buf[128]; 2042 char buf[128];
2053 const size_t bufsz = sizeof(buf); 2043 const size_t bufsz = sizeof(buf);
2054 ssize_t ret;
2055 2044
2056 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n", 2045 pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n",
2057 priv->event_log.ucode_trace ? "On" : "Off"); 2046 priv->event_log.ucode_trace ? "On" : "Off");
@@ -2062,8 +2051,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_read(struct file *file,
2062 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n", 2051 pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n",
2063 priv->event_log.wraps_more_count); 2052 priv->event_log.wraps_more_count);
2064 2053
2065 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2054 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2066 return ret;
2067} 2055}
2068 2056
2069static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file, 2057static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
@@ -2095,6 +2083,31 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
2095 return count; 2083 return count;
2096} 2084}
2097 2085
2086static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
2087 char __user *user_buf,
2088 size_t count, loff_t *ppos) {
2089
2090 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2091 int len = 0;
2092 char buf[20];
2093
2094 len = sprintf(buf, "0x%04X\n", le32_to_cpu(priv->active_rxon.flags));
2095 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
2096}
2097
2098static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
2099 char __user *user_buf,
2100 size_t count, loff_t *ppos) {
2101
2102 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
2103 int len = 0;
2104 char buf[20];
2105
2106 len = sprintf(buf, "0x%04X\n",
2107 le32_to_cpu(priv->active_rxon.filter_flags));
2108 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
2109}
2110
2098static ssize_t iwl_dbgfs_fh_reg_read(struct file *file, 2111static ssize_t iwl_dbgfs_fh_reg_read(struct file *file,
2099 char __user *user_buf, 2112 char __user *user_buf,
2100 size_t count, loff_t *ppos) 2113 size_t count, loff_t *ppos)
@@ -2124,13 +2137,11 @@ static ssize_t iwl_dbgfs_missed_beacon_read(struct file *file,
2124 int pos = 0; 2137 int pos = 0;
2125 char buf[12]; 2138 char buf[12];
2126 const size_t bufsz = sizeof(buf); 2139 const size_t bufsz = sizeof(buf);
2127 ssize_t ret;
2128 2140
2129 pos += scnprintf(buf + pos, bufsz - pos, "%d\n", 2141 pos += scnprintf(buf + pos, bufsz - pos, "%d\n",
2130 priv->missed_beacon_threshold); 2142 priv->missed_beacon_threshold);
2131 2143
2132 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2144 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2133 return ret;
2134} 2145}
2135 2146
2136static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file, 2147static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
@@ -2159,27 +2170,6 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
2159 return count; 2170 return count;
2160} 2171}
2161 2172
2162static ssize_t iwl_dbgfs_internal_scan_write(struct file *file,
2163 const char __user *user_buf,
2164 size_t count, loff_t *ppos)
2165{
2166 struct iwl_priv *priv = file->private_data;
2167 char buf[8];
2168 int buf_size;
2169 int scan;
2170
2171 memset(buf, 0, sizeof(buf));
2172 buf_size = min(count, sizeof(buf) - 1);
2173 if (copy_from_user(buf, user_buf, buf_size))
2174 return -EFAULT;
2175 if (sscanf(buf, "%d", &scan) != 1)
2176 return -EINVAL;
2177
2178 iwl_internal_short_hw_scan(priv);
2179
2180 return count;
2181}
2182
2183static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file, 2173static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
2184 char __user *user_buf, 2174 char __user *user_buf,
2185 size_t count, loff_t *ppos) { 2175 size_t count, loff_t *ppos) {
@@ -2188,13 +2178,11 @@ static ssize_t iwl_dbgfs_plcp_delta_read(struct file *file,
2188 int pos = 0; 2178 int pos = 0;
2189 char buf[12]; 2179 char buf[12];
2190 const size_t bufsz = sizeof(buf); 2180 const size_t bufsz = sizeof(buf);
2191 ssize_t ret;
2192 2181
2193 pos += scnprintf(buf + pos, bufsz - pos, "%u\n", 2182 pos += scnprintf(buf + pos, bufsz - pos, "%u\n",
2194 priv->cfg->plcp_delta_threshold); 2183 priv->cfg->plcp_delta_threshold);
2195 2184
2196 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); 2185 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2197 return ret;
2198} 2186}
2199 2187
2200static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file, 2188static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
@@ -2295,9 +2283,10 @@ DEBUGFS_WRITE_FILE_OPS(csr);
2295DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing); 2283DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing);
2296DEBUGFS_READ_FILE_OPS(fh_reg); 2284DEBUGFS_READ_FILE_OPS(fh_reg);
2297DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); 2285DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
2298DEBUGFS_WRITE_FILE_OPS(internal_scan);
2299DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta); 2286DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
2300DEBUGFS_READ_WRITE_FILE_OPS(force_reset); 2287DEBUGFS_READ_WRITE_FILE_OPS(force_reset);
2288DEBUGFS_READ_FILE_OPS(rxon_flags);
2289DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
2301 2290
2302/* 2291/*
2303 * Create the debugfs files and directories 2292 * Create the debugfs files and directories
@@ -2349,7 +2338,6 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2349 DEBUGFS_ADD_FILE(csr, dir_debug, S_IWUSR); 2338 DEBUGFS_ADD_FILE(csr, dir_debug, S_IWUSR);
2350 DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR); 2339 DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR);
2351 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); 2340 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
2352 DEBUGFS_ADD_FILE(internal_scan, dir_debug, S_IWUSR);
2353 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR); 2341 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
2354 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); 2342 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR);
2355 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) { 2343 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
@@ -2360,6 +2348,8 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2360 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); 2348 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
2361 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR); 2349 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
2362 } 2350 }
2351 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
2352 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
2363 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, &priv->disable_sens_cal); 2353 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, &priv->disable_sens_cal);
2364 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, 2354 DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf,
2365 &priv->disable_chain_noise_cal); 2355 &priv->disable_chain_noise_cal);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 6054c5fba0c1..e847e6197a3d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -183,6 +183,10 @@ struct iwl_queue {
183 int n_bd; /* number of BDs in this queue */ 183 int n_bd; /* number of BDs in this queue */
184 int write_ptr; /* 1-st empty entry (index) host_w*/ 184 int write_ptr; /* 1-st empty entry (index) host_w*/
185 int read_ptr; /* last used entry (index) host_r*/ 185 int read_ptr; /* last used entry (index) host_r*/
186 /* use for monitoring and recovering the stuck queue */
187 int last_read_ptr; /* storing the last read_ptr */
188 /* number of time read_ptr and last_read_ptr are the same */
189 u8 repeat_same_read_ptr;
186 dma_addr_t dma_addr; /* physical addr for BD's */ 190 dma_addr_t dma_addr; /* physical addr for BD's */
187 int n_window; /* safe queue window */ 191 int n_window; /* safe queue window */
188 u32 id; 192 u32 id;
@@ -304,13 +308,11 @@ struct iwl_channel_info {
304 struct iwl3945_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES]; 308 struct iwl3945_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
305}; 309};
306 310
307#define IWL_TX_FIFO_AC0 0 311#define IWL_TX_FIFO_BK 0
308#define IWL_TX_FIFO_AC1 1 312#define IWL_TX_FIFO_BE 1
309#define IWL_TX_FIFO_AC2 2 313#define IWL_TX_FIFO_VI 2
310#define IWL_TX_FIFO_AC3 3 314#define IWL_TX_FIFO_VO 3
311#define IWL_TX_FIFO_HCCA_1 5 315#define IWL_TX_FIFO_UNUSED -1
312#define IWL_TX_FIFO_HCCA_2 6
313#define IWL_TX_FIFO_NONE 7
314 316
315/* Minimum number of queues. MAX_NUM is defined in hw specific files. 317/* Minimum number of queues. MAX_NUM is defined in hw specific files.
316 * Set the minimum to accommodate the 4 standard TX queues, 1 command 318 * Set the minimum to accommodate the 4 standard TX queues, 1 command
@@ -546,11 +548,18 @@ struct iwl_qos_info {
546 struct iwl_qosparam_cmd def_qos_parm; 548 struct iwl_qosparam_cmd def_qos_parm;
547}; 549};
548 550
551/*
552 * Structure should be accessed with sta_lock held. When station addition
553 * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
554 * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
555 * held.
556 */
549struct iwl_station_entry { 557struct iwl_station_entry {
550 struct iwl_addsta_cmd sta; 558 struct iwl_addsta_cmd sta;
551 struct iwl_tid_data tid[MAX_TID_COUNT]; 559 struct iwl_tid_data tid[MAX_TID_COUNT];
552 u8 used; 560 u8 used;
553 struct iwl_hw_key keyinfo; 561 struct iwl_hw_key keyinfo;
562 struct iwl_link_quality_cmd *lq;
554}; 563};
555 564
556/* 565/*
@@ -1039,6 +1048,11 @@ struct iwl_event_log {
1039#define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3) 1048#define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
1040#define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) 1049#define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
1041 1050
1051/* timer constants use to monitor and recover stuck tx queues in mSecs */
1052#define IWL_MONITORING_PERIOD (1000)
1053#define IWL_ONE_HUNDRED_MSECS (100)
1054#define IWL_SIXTY_SECS (60000)
1055
1042enum iwl_reset { 1056enum iwl_reset {
1043 IWL_RF_RESET = 0, 1057 IWL_RF_RESET = 0,
1044 IWL_FW_RESET, 1058 IWL_FW_RESET,
@@ -1092,10 +1106,6 @@ struct iwl_priv {
1092 struct iwl_channel_info *channel_info; /* channel info array */ 1106 struct iwl_channel_info *channel_info; /* channel info array */
1093 u8 channel_count; /* # of channels */ 1107 u8 channel_count; /* # of channels */
1094 1108
1095 /* each calibration channel group in the EEPROM has a derived
1096 * clip setting for each rate. 3945 only.*/
1097 const struct iwl3945_clip_group clip39_groups[5];
1098
1099 /* thermal calibration */ 1109 /* thermal calibration */
1100 s32 temperature; /* degrees Kelvin */ 1110 s32 temperature; /* degrees Kelvin */
1101 s32 last_temperature; 1111 s32 last_temperature;
@@ -1168,9 +1178,7 @@ struct iwl_priv {
1168 u64 led_tpt; 1178 u64 led_tpt;
1169 1179
1170 u16 active_rate; 1180 u16 active_rate;
1171 u16 active_rate_basic;
1172 1181
1173 u8 assoc_station_added;
1174 u8 start_calib; 1182 u8 start_calib;
1175 struct iwl_sensitivity_data sensitivity_data; 1183 struct iwl_sensitivity_data sensitivity_data;
1176 struct iwl_chain_noise_data chain_noise_data; 1184 struct iwl_chain_noise_data chain_noise_data;
@@ -1197,7 +1205,6 @@ struct iwl_priv {
1197 1205
1198 unsigned long status; 1206 unsigned long status;
1199 1207
1200 int last_rx_rssi; /* From Rx packet statistics */
1201 int last_rx_noise; /* From beacon statistics */ 1208 int last_rx_noise; /* From beacon statistics */
1202 1209
1203 /* counts mgmt, ctl, and data packets */ 1210 /* counts mgmt, ctl, and data packets */
@@ -1218,8 +1225,6 @@ struct iwl_priv {
1218#endif 1225#endif
1219 1226
1220 /* context information */ 1227 /* context information */
1221 u16 rates_mask;
1222
1223 u8 bssid[ETH_ALEN]; 1228 u8 bssid[ETH_ALEN];
1224 u16 rts_threshold; 1229 u16 rts_threshold;
1225 u8 mac_addr[ETH_ALEN]; 1230 u8 mac_addr[ETH_ALEN];
@@ -1228,7 +1233,7 @@ struct iwl_priv {
1228 spinlock_t sta_lock; 1233 spinlock_t sta_lock;
1229 int num_stations; 1234 int num_stations;
1230 struct iwl_station_entry stations[IWL_STATION_COUNT]; 1235 struct iwl_station_entry stations[IWL_STATION_COUNT];
1231 struct iwl_wep_key wep_keys[WEP_KEYS_MAX]; 1236 struct iwl_wep_key wep_keys[WEP_KEYS_MAX]; /* protected by mutex */
1232 u8 default_wep_key; 1237 u8 default_wep_key;
1233 u8 key_mapping_key; 1238 u8 key_mapping_key;
1234 unsigned long ucode_key_table; 1239 unsigned long ucode_key_table;
@@ -1244,10 +1249,6 @@ struct iwl_priv {
1244 1249
1245 u8 mac80211_registered; 1250 u8 mac80211_registered;
1246 1251
1247 /* Rx'd packet timing information */
1248 u32 last_beacon_time;
1249 u64 last_tsf;
1250
1251 /* eeprom -- this is in the card's little endian byte order */ 1252 /* eeprom -- this is in the card's little endian byte order */
1252 u8 *eeprom; 1253 u8 *eeprom;
1253 int nvm_device_type; 1254 int nvm_device_type;
@@ -1262,20 +1263,53 @@ struct iwl_priv {
1262 u16 beacon_int; 1263 u16 beacon_int;
1263 struct ieee80211_vif *vif; 1264 struct ieee80211_vif *vif;
1264 1265
1265 /*Added for 3945 */ 1266 union {
1266 void *shared_virt; 1267#if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE)
1267 dma_addr_t shared_phys; 1268 struct {
1268 /*End*/ 1269 void *shared_virt;
1269 struct iwl_hw_params hw_params; 1270 dma_addr_t shared_phys;
1271
1272 struct delayed_work thermal_periodic;
1273 struct delayed_work rfkill_poll;
1274
1275 struct iwl3945_notif_statistics statistics;
1276
1277 u32 sta_supp_rates;
1278 int last_rx_rssi; /* From Rx packet statistics */
1270 1279
1271 /* INT ICT Table */ 1280 /* Rx'd packet timing information */
1272 __le32 *ict_tbl; 1281 u32 last_beacon_time;
1273 dma_addr_t ict_tbl_dma; 1282 u64 last_tsf;
1274 dma_addr_t aligned_ict_tbl_dma; 1283
1275 int ict_index; 1284 /*
1276 void *ict_tbl_vir; 1285 * each calibration channel group in the
1277 u32 inta; 1286 * EEPROM has a derived clip setting for
1278 bool use_ict; 1287 * each rate.
1288 */
1289 const struct iwl3945_clip_group clip_groups[5];
1290
1291 } _3945;
1292#endif
1293#if defined(CONFIG_IWLAGN) || defined(CONFIG_IWLAGN_MODULE)
1294 struct {
1295 /* INT ICT Table */
1296 __le32 *ict_tbl;
1297 void *ict_tbl_vir;
1298 dma_addr_t ict_tbl_dma;
1299 dma_addr_t aligned_ict_tbl_dma;
1300 int ict_index;
1301 u32 inta;
1302 bool use_ict;
1303 /*
1304 * reporting the number of tids has AGG on. 0 means
1305 * no AGGREGATION
1306 */
1307 u8 agg_tids_count;
1308 } _agn;
1309#endif
1310 };
1311
1312 struct iwl_hw_params hw_params;
1279 1313
1280 u32 inta_mask; 1314 u32 inta_mask;
1281 /* Current association information needed to configure the 1315 /* Current association information needed to configure the
@@ -1303,10 +1337,6 @@ struct iwl_priv {
1303 struct delayed_work alive_start; 1337 struct delayed_work alive_start;
1304 struct delayed_work scan_check; 1338 struct delayed_work scan_check;
1305 1339
1306 /*For 3945 only*/
1307 struct delayed_work thermal_periodic;
1308 struct delayed_work rfkill_poll;
1309
1310 /* TX Power */ 1340 /* TX Power */
1311 s8 tx_power_user_lmt; 1341 s8 tx_power_user_lmt;
1312 s8 tx_power_device_lmt; 1342 s8 tx_power_device_lmt;
@@ -1338,13 +1368,8 @@ struct iwl_priv {
1338 struct work_struct run_time_calib_work; 1368 struct work_struct run_time_calib_work;
1339 struct timer_list statistics_periodic; 1369 struct timer_list statistics_periodic;
1340 struct timer_list ucode_trace; 1370 struct timer_list ucode_trace;
1371 struct timer_list monitor_recover;
1341 bool hw_ready; 1372 bool hw_ready;
1342 /*For 3945*/
1343#define IWL_DEFAULT_TX_POWER 0x0F
1344
1345 struct iwl3945_notif_statistics statistics_39;
1346
1347 u32 sta_supp_rates;
1348 1373
1349 struct iwl_event_log event_log; 1374 struct iwl_event_log event_log;
1350}; /*iwl_priv */ 1375}; /*iwl_priv */
diff --git a/drivers/net/wireless/iwlwifi/iwl-helpers.h b/drivers/net/wireless/iwlwifi/iwl-helpers.h
index 51a67fb2e185..3ff6b9d25a10 100644
--- a/drivers/net/wireless/iwlwifi/iwl-helpers.h
+++ b/drivers/net/wireless/iwlwifi/iwl-helpers.h
@@ -31,6 +31,9 @@
31#define __iwl_helpers_h__ 31#define __iwl_helpers_h__
32 32
33#include <linux/ctype.h> 33#include <linux/ctype.h>
34#include <net/mac80211.h>
35
36#include "iwl-io.h"
34 37
35#define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) 38#define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo))))
36 39
diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h
index d2d2a9174900..5944de7a98a2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-prph.h
+++ b/drivers/net/wireless/iwlwifi/iwl-prph.h
@@ -254,7 +254,7 @@
254 * device. A queue maps to only one (selectable by driver) Tx DMA channel, 254 * device. A queue maps to only one (selectable by driver) Tx DMA channel,
255 * but one DMA channel may take input from several queues. 255 * but one DMA channel may take input from several queues.
256 * 256 *
257 * Tx DMA channels have dedicated purposes. For 4965, they are used as follows 257 * Tx DMA FIFOs have dedicated purposes. For 4965, they are used as follows
258 * (cf. default_queue_to_tx_fifo in iwl-4965.c): 258 * (cf. default_queue_to_tx_fifo in iwl-4965.c):
259 * 259 *
260 * 0 -- EDCA BK (background) frames, lowest priority 260 * 0 -- EDCA BK (background) frames, lowest priority
@@ -262,20 +262,20 @@
262 * 2 -- EDCA VI (video) frames, higher priority 262 * 2 -- EDCA VI (video) frames, higher priority
263 * 3 -- EDCA VO (voice) and management frames, highest priority 263 * 3 -- EDCA VO (voice) and management frames, highest priority
264 * 4 -- Commands (e.g. RXON, etc.) 264 * 4 -- Commands (e.g. RXON, etc.)
265 * 5 -- HCCA short frames 265 * 5 -- unused (HCCA)
266 * 6 -- HCCA long frames 266 * 6 -- unused (HCCA)
267 * 7 -- not used by driver (device-internal only) 267 * 7 -- not used by driver (device-internal only)
268 * 268 *
269 * For 5000 series and up, they are used slightly differently 269 * For 5000 series and up, they are used differently
270 * (cf. iwl5000_default_queue_to_tx_fifo in iwl-5000.c): 270 * (cf. iwl5000_default_queue_to_tx_fifo in iwl-5000.c):
271 * 271 *
272 * 0 -- EDCA BK (background) frames, lowest priority 272 * 0 -- EDCA BK (background) frames, lowest priority
273 * 1 -- EDCA BE (best effort) frames, normal priority 273 * 1 -- EDCA BE (best effort) frames, normal priority
274 * 2 -- EDCA VI (video) frames, higher priority 274 * 2 -- EDCA VI (video) frames, higher priority
275 * 3 -- EDCA VO (voice) and management frames, highest priority 275 * 3 -- EDCA VO (voice) and management frames, highest priority
276 * 4 -- (TBD) 276 * 4 -- unused
277 * 5 -- HCCA short frames 277 * 5 -- unused
278 * 6 -- HCCA long frames 278 * 6 -- unused
279 * 7 -- Commands 279 * 7 -- Commands
280 * 280 *
281 * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6. 281 * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6.
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index df257bc15f49..2fa30dfb7c59 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -616,29 +616,77 @@ static void iwl_accumulative_statistics(struct iwl_priv *priv,
616 616
617#define REG_RECALIB_PERIOD (60) 617#define REG_RECALIB_PERIOD (60)
618 618
619#define PLCP_MSG "plcp_err exceeded %u, %u, %u, %u, %u, %d, %u mSecs\n" 619/* the threshold ratio of actual_ack_cnt to expected_ack_cnt in percent */
620void iwl_rx_statistics(struct iwl_priv *priv, 620#define ACK_CNT_RATIO (50)
621 struct iwl_rx_mem_buffer *rxb) 621#define BA_TIMEOUT_CNT (5)
622#define BA_TIMEOUT_MAX (16)
623
624#if defined(CONFIG_IWLAGN) || defined(CONFIG_IWLAGN_MODULE)
625/**
626 * iwl_good_ack_health - checks for ACK count ratios, BA timeout retries.
627 *
628 * When the ACK count ratio is 0 and aggregated BA timeout retries exceeding
629 * the BA_TIMEOUT_MAX, reload firmware and bring system back to normal
630 * operation state.
631 */
632bool iwl_good_ack_health(struct iwl_priv *priv,
633 struct iwl_rx_packet *pkt)
622{ 634{
623 int change; 635 bool rc = true;
624 struct iwl_rx_packet *pkt = rxb_addr(rxb); 636 int actual_ack_cnt_delta, expected_ack_cnt_delta;
637 int ba_timeout_delta;
638
639 actual_ack_cnt_delta =
640 le32_to_cpu(pkt->u.stats.tx.actual_ack_cnt) -
641 le32_to_cpu(priv->statistics.tx.actual_ack_cnt);
642 expected_ack_cnt_delta =
643 le32_to_cpu(pkt->u.stats.tx.expected_ack_cnt) -
644 le32_to_cpu(priv->statistics.tx.expected_ack_cnt);
645 ba_timeout_delta =
646 le32_to_cpu(pkt->u.stats.tx.agg.ba_timeout) -
647 le32_to_cpu(priv->statistics.tx.agg.ba_timeout);
648 if ((priv->_agn.agg_tids_count > 0) &&
649 (expected_ack_cnt_delta > 0) &&
650 (((actual_ack_cnt_delta * 100) / expected_ack_cnt_delta)
651 < ACK_CNT_RATIO) &&
652 (ba_timeout_delta > BA_TIMEOUT_CNT)) {
653 IWL_DEBUG_RADIO(priv, "actual_ack_cnt delta = %d,"
654 " expected_ack_cnt = %d\n",
655 actual_ack_cnt_delta, expected_ack_cnt_delta);
656
657#ifdef CONFIG_IWLWIFI_DEBUG
658 IWL_DEBUG_RADIO(priv, "rx_detected_cnt delta = %d\n",
659 priv->delta_statistics.tx.rx_detected_cnt);
660 IWL_DEBUG_RADIO(priv,
661 "ack_or_ba_timeout_collision delta = %d\n",
662 priv->delta_statistics.tx.
663 ack_or_ba_timeout_collision);
664#endif
665 IWL_DEBUG_RADIO(priv, "agg ba_timeout delta = %d\n",
666 ba_timeout_delta);
667 if (!actual_ack_cnt_delta &&
668 (ba_timeout_delta >= BA_TIMEOUT_MAX))
669 rc = false;
670 }
671 return rc;
672}
673EXPORT_SYMBOL(iwl_good_ack_health);
674#endif
675
676/**
677 * iwl_good_plcp_health - checks for plcp error.
678 *
679 * When the plcp error is exceeding the thresholds, reset the radio
680 * to improve the throughput.
681 */
682bool iwl_good_plcp_health(struct iwl_priv *priv,
683 struct iwl_rx_packet *pkt)
684{
685 bool rc = true;
625 int combined_plcp_delta; 686 int combined_plcp_delta;
626 unsigned int plcp_msec; 687 unsigned int plcp_msec;
627 unsigned long plcp_received_jiffies; 688 unsigned long plcp_received_jiffies;
628 689
629 IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n",
630 (int)sizeof(priv->statistics),
631 le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK);
632
633 change = ((priv->statistics.general.temperature !=
634 pkt->u.stats.general.temperature) ||
635 ((priv->statistics.flag &
636 STATISTICS_REPLY_FLG_HT40_MODE_MSK) !=
637 (pkt->u.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)));
638
639#ifdef CONFIG_IWLWIFI_DEBUG
640 iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats);
641#endif
642 /* 690 /*
643 * check for plcp_err and trigger radio reset if it exceeds 691 * check for plcp_err and trigger radio reset if it exceeds
644 * the plcp error threshold plcp_delta. 692 * the plcp error threshold plcp_delta.
@@ -659,11 +707,11 @@ void iwl_rx_statistics(struct iwl_priv *priv,
659 le32_to_cpu(priv->statistics.rx.ofdm_ht.plcp_err)); 707 le32_to_cpu(priv->statistics.rx.ofdm_ht.plcp_err));
660 708
661 if ((combined_plcp_delta > 0) && 709 if ((combined_plcp_delta > 0) &&
662 ((combined_plcp_delta * 100) / plcp_msec) > 710 ((combined_plcp_delta * 100) / plcp_msec) >
663 priv->cfg->plcp_delta_threshold) { 711 priv->cfg->plcp_delta_threshold) {
664 /* 712 /*
665 * if plcp_err exceed the threshold, the following 713 * if plcp_err exceed the threshold,
666 * data is printed in csv format: 714 * the following data is printed in csv format:
667 * Text: plcp_err exceeded %d, 715 * Text: plcp_err exceeded %d,
668 * Received ofdm.plcp_err, 716 * Received ofdm.plcp_err,
669 * Current ofdm.plcp_err, 717 * Current ofdm.plcp_err,
@@ -672,22 +720,73 @@ void iwl_rx_statistics(struct iwl_priv *priv,
672 * combined_plcp_delta, 720 * combined_plcp_delta,
673 * plcp_msec 721 * plcp_msec
674 */ 722 */
675 IWL_DEBUG_RADIO(priv, PLCP_MSG, 723 IWL_DEBUG_RADIO(priv, "plcp_err exceeded %u, "
724 "%u, %u, %u, %u, %d, %u mSecs\n",
676 priv->cfg->plcp_delta_threshold, 725 priv->cfg->plcp_delta_threshold,
677 le32_to_cpu(pkt->u.stats.rx.ofdm.plcp_err), 726 le32_to_cpu(pkt->u.stats.rx.ofdm.plcp_err),
678 le32_to_cpu(priv->statistics.rx.ofdm.plcp_err), 727 le32_to_cpu(priv->statistics.rx.ofdm.plcp_err),
679 le32_to_cpu(pkt->u.stats.rx.ofdm_ht.plcp_err), 728 le32_to_cpu(pkt->u.stats.rx.ofdm_ht.plcp_err),
680 le32_to_cpu( 729 le32_to_cpu(
681 priv->statistics.rx.ofdm_ht.plcp_err), 730 priv->statistics.rx.ofdm_ht.plcp_err),
682 combined_plcp_delta, plcp_msec); 731 combined_plcp_delta, plcp_msec);
732 rc = false;
733 }
734 }
735 return rc;
736}
737EXPORT_SYMBOL(iwl_good_plcp_health);
683 738
684 /* 739static void iwl_recover_from_statistics(struct iwl_priv *priv,
685 * Reset the RF radio due to the high plcp 740 struct iwl_rx_packet *pkt)
686 * error rate 741{
687 */ 742 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
688 iwl_force_reset(priv, IWL_RF_RESET); 743 return;
744 if (iwl_is_associated(priv)) {
745 if (priv->cfg->ops->lib->check_ack_health) {
746 if (!priv->cfg->ops->lib->check_ack_health(
747 priv, pkt)) {
748 /*
749 * low ack count detected
750 * restart Firmware
751 */
752 IWL_ERR(priv, "low ack count detected, "
753 "restart firmware\n");
754 iwl_force_reset(priv, IWL_FW_RESET);
755 }
756 } else if (priv->cfg->ops->lib->check_plcp_health) {
757 if (!priv->cfg->ops->lib->check_plcp_health(
758 priv, pkt)) {
759 /*
760 * high plcp error detected
761 * reset Radio
762 */
763 iwl_force_reset(priv, IWL_RF_RESET);
764 }
689 } 765 }
690 } 766 }
767}
768
769void iwl_rx_statistics(struct iwl_priv *priv,
770 struct iwl_rx_mem_buffer *rxb)
771{
772 int change;
773 struct iwl_rx_packet *pkt = rxb_addr(rxb);
774
775
776 IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n",
777 (int)sizeof(priv->statistics),
778 le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK);
779
780 change = ((priv->statistics.general.temperature !=
781 pkt->u.stats.general.temperature) ||
782 ((priv->statistics.flag &
783 STATISTICS_REPLY_FLG_HT40_MODE_MSK) !=
784 (pkt->u.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)));
785
786#ifdef CONFIG_IWLWIFI_DEBUG
787 iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats);
788#endif
789 iwl_recover_from_statistics(priv, pkt);
691 790
692 memcpy(&priv->statistics, &pkt->u.stats, sizeof(priv->statistics)); 791 memcpy(&priv->statistics, &pkt->u.stats, sizeof(priv->statistics));
693 792
@@ -1036,24 +1135,6 @@ static void iwl_pass_packet_to_mac80211(struct iwl_priv *priv,
1036 rxb->page = NULL; 1135 rxb->page = NULL;
1037} 1136}
1038 1137
1039/* This is necessary only for a number of statistics, see the caller. */
1040static int iwl_is_network_packet(struct iwl_priv *priv,
1041 struct ieee80211_hdr *header)
1042{
1043 /* Filter incoming packets to determine if they are targeted toward
1044 * this network, discarding packets coming from ourselves */
1045 switch (priv->iw_mode) {
1046 case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */
1047 /* packets to our IBSS update information */
1048 return !compare_ether_addr(header->addr3, priv->bssid);
1049 case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */
1050 /* packets to our IBSS update information */
1051 return !compare_ether_addr(header->addr2, priv->bssid);
1052 default:
1053 return 1;
1054 }
1055}
1056
1057/* Called for REPLY_RX (legacy ABG frames), or 1138/* Called for REPLY_RX (legacy ABG frames), or
1058 * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ 1139 * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */
1059void iwl_rx_reply_rx(struct iwl_priv *priv, 1140void iwl_rx_reply_rx(struct iwl_priv *priv,
@@ -1190,12 +1271,6 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
1190 if (rate_n_flags & RATE_MCS_SGI_MSK) 1271 if (rate_n_flags & RATE_MCS_SGI_MSK)
1191 rx_status.flag |= RX_FLAG_SHORT_GI; 1272 rx_status.flag |= RX_FLAG_SHORT_GI;
1192 1273
1193 if (iwl_is_network_packet(priv, header)) {
1194 priv->last_rx_rssi = rx_status.signal;
1195 priv->last_beacon_time = priv->ucode_beacon_time;
1196 priv->last_tsf = le64_to_cpu(phy_res->timestamp);
1197 }
1198
1199 iwl_pass_packet_to_mac80211(priv, header, len, ampdu_status, 1274 iwl_pass_packet_to_mac80211(priv, header, len, ampdu_status,
1200 rxb, &rx_status); 1275 rxb, &rx_status);
1201} 1276}
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index bd2f7c420563..84b19b12ff03 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -580,7 +580,6 @@ int iwl_internal_short_hw_scan(struct iwl_priv *priv)
580out: 580out:
581 return ret; 581 return ret;
582} 582}
583EXPORT_SYMBOL(iwl_internal_short_hw_scan);
584 583
585#define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) 584#define IWL_SCAN_CHECK_WATCHDOG (7 * HZ)
586 585
@@ -665,7 +664,6 @@ static void iwl_bg_request_scan(struct work_struct *data)
665 }; 664 };
666 struct iwl_scan_cmd *scan; 665 struct iwl_scan_cmd *scan;
667 struct ieee80211_conf *conf = NULL; 666 struct ieee80211_conf *conf = NULL;
668 int ret = 0;
669 u32 rate_flags = 0; 667 u32 rate_flags = 0;
670 u16 cmd_len; 668 u16 cmd_len;
671 u16 rx_chain = 0; 669 u16 rx_chain = 0;
@@ -698,7 +696,6 @@ static void iwl_bg_request_scan(struct work_struct *data)
698 if (test_bit(STATUS_SCAN_HW, &priv->status)) { 696 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
699 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests in parallel. " 697 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests in parallel. "
700 "Ignoring second request.\n"); 698 "Ignoring second request.\n");
701 ret = -EIO;
702 goto done; 699 goto done;
703 } 700 }
704 701
@@ -731,7 +728,8 @@ static void iwl_bg_request_scan(struct work_struct *data)
731 priv->scan = kmalloc(sizeof(struct iwl_scan_cmd) + 728 priv->scan = kmalloc(sizeof(struct iwl_scan_cmd) +
732 IWL_MAX_SCAN_SIZE, GFP_KERNEL); 729 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
733 if (!priv->scan) { 730 if (!priv->scan) {
734 ret = -ENOMEM; 731 IWL_DEBUG_SCAN(priv,
732 "fail to allocate memory for scan\n");
735 goto done; 733 goto done;
736 } 734 }
737 } 735 }
@@ -892,8 +890,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
892 scan->len = cpu_to_le16(cmd.len); 890 scan->len = cpu_to_le16(cmd.len);
893 891
894 set_bit(STATUS_SCAN_HW, &priv->status); 892 set_bit(STATUS_SCAN_HW, &priv->status);
895 ret = iwl_send_cmd_sync(priv, &cmd); 893 if (iwl_send_cmd_sync(priv, &cmd))
896 if (ret)
897 goto done; 894 goto done;
898 895
899 queue_delayed_work(priv->workqueue, &priv->scan_check, 896 queue_delayed_work(priv->workqueue, &priv->scan_check,
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 4a6686fa6b36..d401b6f226f9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -29,14 +29,12 @@
29 29
30#include <net/mac80211.h> 30#include <net/mac80211.h>
31#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
32#include <linux/sched.h>
32 33
33#include "iwl-dev.h" 34#include "iwl-dev.h"
34#include "iwl-core.h" 35#include "iwl-core.h"
35#include "iwl-sta.h" 36#include "iwl-sta.h"
36 37
37#define IWL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */
38#define IWL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */
39
40u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr) 38u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr)
41{ 39{
42 int i; 40 int i;
@@ -64,6 +62,19 @@ u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr)
64 addr, priv->num_stations); 62 addr, priv->num_stations);
65 63
66 out: 64 out:
65 /*
66 * It may be possible that more commands interacting with stations
67 * arrive before we completed processing the adding of
68 * station
69 */
70 if (ret != IWL_INVALID_STATION &&
71 (!(priv->stations[ret].used & IWL_STA_UCODE_ACTIVE) ||
72 ((priv->stations[ret].used & IWL_STA_UCODE_ACTIVE) &&
73 (priv->stations[ret].used & IWL_STA_UCODE_INPROGRESS)))) {
74 IWL_ERR(priv, "Requested station info for sta %d before ready. \n",
75 ret);
76 ret = IWL_INVALID_STATION;
77 }
67 spin_unlock_irqrestore(&priv->sta_lock, flags); 78 spin_unlock_irqrestore(&priv->sta_lock, flags);
68 return ret; 79 return ret;
69} 80}
@@ -158,13 +169,6 @@ static void iwl_process_add_sta_resp(struct iwl_priv *priv,
158 priv->stations[sta_id].sta.mode == 169 priv->stations[sta_id].sta.mode ==
159 STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", 170 STA_CONTROL_MODIFY_MSK ? "Modified" : "Added",
160 addsta->sta.addr); 171 addsta->sta.addr);
161
162 /*
163 * Determine if we wanted to modify or add a station,
164 * if adding a station succeeded we have some more initialization
165 * to do when using station notification. TODO
166 */
167
168 spin_unlock_irqrestore(&priv->sta_lock, flags); 172 spin_unlock_irqrestore(&priv->sta_lock, flags);
169} 173}
170 174
@@ -190,6 +194,10 @@ int iwl_send_add_sta(struct iwl_priv *priv,
190 .flags = flags, 194 .flags = flags,
191 .data = data, 195 .data = data,
192 }; 196 };
197 u8 sta_id = sta->sta.sta_id;
198
199 IWL_DEBUG_INFO(priv, "Adding sta %u (%pM) %ssynchronously\n",
200 sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : "");
193 201
194 if (flags & CMD_ASYNC) 202 if (flags & CMD_ASYNC)
195 cmd.callback = iwl_add_sta_callback; 203 cmd.callback = iwl_add_sta_callback;
@@ -263,18 +271,19 @@ static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
263} 271}
264 272
265/** 273/**
266 * iwl_add_station - Add station to tables in driver and device 274 * iwl_prep_station - Prepare station information for addition
275 *
276 * should be called with sta_lock held
267 */ 277 */
268u8 iwl_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap, u8 flags, 278static u8 iwl_prep_station(struct iwl_priv *priv, const u8 *addr,
269 struct ieee80211_sta_ht_cap *ht_info) 279 bool is_ap,
280 struct ieee80211_sta_ht_cap *ht_info)
270{ 281{
271 struct iwl_station_entry *station; 282 struct iwl_station_entry *station;
272 unsigned long flags_spin;
273 int i; 283 int i;
274 int sta_id = IWL_INVALID_STATION; 284 u8 sta_id = IWL_INVALID_STATION;
275 u16 rate; 285 u16 rate;
276 286
277 spin_lock_irqsave(&priv->sta_lock, flags_spin);
278 if (is_ap) 287 if (is_ap)
279 sta_id = IWL_AP_ID; 288 sta_id = IWL_AP_ID;
280 else if (is_broadcast_ether_addr(addr)) 289 else if (is_broadcast_ether_addr(addr))
@@ -292,20 +301,32 @@ u8 iwl_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap, u8 flags,
292 sta_id = i; 301 sta_id = i;
293 } 302 }
294 303
295 /* These two conditions have the same outcome, but keep them separate 304 /*
296 since they have different meanings */ 305 * These two conditions have the same outcome, but keep them
297 if (unlikely(sta_id == IWL_INVALID_STATION)) { 306 * separate
298 spin_unlock_irqrestore(&priv->sta_lock, flags_spin); 307 */
308 if (unlikely(sta_id == IWL_INVALID_STATION))
309 return sta_id;
310
311 /*
312 * uCode is not able to deal with multiple requests to add a
313 * station. Keep track if one is in progress so that we do not send
314 * another.
315 */
316 if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) {
317 IWL_DEBUG_INFO(priv, "STA %d already in process of being added.\n",
318 sta_id);
299 return sta_id; 319 return sta_id;
300 } 320 }
301 321
302 if (priv->stations[sta_id].used && 322 if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) &&
323 (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE) &&
303 !compare_ether_addr(priv->stations[sta_id].sta.sta.addr, addr)) { 324 !compare_ether_addr(priv->stations[sta_id].sta.sta.addr, addr)) {
304 spin_unlock_irqrestore(&priv->sta_lock, flags_spin); 325 IWL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not adding again.\n",
326 sta_id, addr);
305 return sta_id; 327 return sta_id;
306 } 328 }
307 329
308
309 station = &priv->stations[sta_id]; 330 station = &priv->stations[sta_id];
310 station->used = IWL_STA_DRIVER_ACTIVE; 331 station->used = IWL_STA_DRIVER_ACTIVE;
311 IWL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n", 332 IWL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n",
@@ -330,86 +351,185 @@ u8 iwl_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap, u8 flags,
330 /* Turn on both antennas for the station... */ 351 /* Turn on both antennas for the station... */
331 station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); 352 station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK);
332 353
354 return sta_id;
355
356}
357
358#define STA_WAIT_TIMEOUT (HZ/2)
359
360/**
361 * iwl_add_station_common -
362 */
363int iwl_add_station_common(struct iwl_priv *priv, const u8 *addr,
364 bool is_ap,
365 struct ieee80211_sta_ht_cap *ht_info,
366 u8 *sta_id_r)
367{
368 struct iwl_station_entry *station;
369 unsigned long flags_spin;
370 int ret = 0;
371 u8 sta_id;
372
373 *sta_id_r = 0;
374 spin_lock_irqsave(&priv->sta_lock, flags_spin);
375 sta_id = iwl_prep_station(priv, addr, is_ap, ht_info);
376 if (sta_id == IWL_INVALID_STATION) {
377 IWL_ERR(priv, "Unable to prepare station %pM for addition\n",
378 addr);
379 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
380 return -EINVAL;
381 }
382
383 /*
384 * uCode is not able to deal with multiple requests to add a
385 * station. Keep track if one is in progress so that we do not send
386 * another.
387 */
388 if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) {
389 IWL_DEBUG_INFO(priv, "STA %d already in process of being added.\n",
390 sta_id);
391 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
392 return -EEXIST;
393 }
394
395 if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) &&
396 (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) {
397 IWL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not adding again.\n",
398 sta_id, addr);
399 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
400 return -EEXIST;
401 }
402
403 priv->stations[sta_id].used |= IWL_STA_UCODE_INPROGRESS;
404 station = &priv->stations[sta_id];
333 spin_unlock_irqrestore(&priv->sta_lock, flags_spin); 405 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
334 406
335 /* Add station to device's station table */ 407 /* Add station to device's station table */
336 iwl_send_add_sta(priv, &station->sta, flags); 408 ret = iwl_send_add_sta(priv, &station->sta, CMD_SYNC);
337 return sta_id; 409 if (ret) {
338 410 IWL_ERR(priv, "Adding station %pM failed.\n", station->sta.sta.addr);
411 spin_lock_irqsave(&priv->sta_lock, flags_spin);
412 priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE;
413 priv->stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
414 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
415 }
416 *sta_id_r = sta_id;
417 return ret;
339} 418}
340EXPORT_SYMBOL(iwl_add_station); 419EXPORT_SYMBOL(iwl_add_station_common);
341 420
342static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, const u8 *addr) 421static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, bool is_ap)
343{ 422{
344 unsigned long flags; 423 int i, r;
345 u8 sta_id = iwl_find_station(priv, addr); 424 struct iwl_link_quality_cmd link_cmd = {
425 .reserved1 = 0,
426 };
427 u32 rate_flags;
346 428
347 BUG_ON(sta_id == IWL_INVALID_STATION); 429 /* Set up the rate scaling to start at selected rate, fall back
430 * all the way down to 1M in IEEE order, and then spin on 1M */
431 if (is_ap)
432 r = IWL_RATE_54M_INDEX;
433 else if (priv->band == IEEE80211_BAND_5GHZ)
434 r = IWL_RATE_6M_INDEX;
435 else
436 r = IWL_RATE_1M_INDEX;
348 437
349 IWL_DEBUG_ASSOC(priv, "Removed STA from Ucode: %pM\n", addr); 438 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
439 rate_flags = 0;
440 if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE)
441 rate_flags |= RATE_MCS_CCK_MSK;
350 442
351 spin_lock_irqsave(&priv->sta_lock, flags); 443 rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) <<
444 RATE_MCS_ANT_POS;
352 445
353 /* Ucode must be active and driver must be non active */ 446 link_cmd.rs_table[i].rate_n_flags =
354 if (priv->stations[sta_id].used != IWL_STA_UCODE_ACTIVE) 447 iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags);
355 IWL_ERR(priv, "removed non active STA %d\n", sta_id); 448 r = iwl_get_prev_ieee_rate(r);
449 }
356 450
357 priv->stations[sta_id].used &= ~IWL_STA_UCODE_ACTIVE; 451 link_cmd.general_params.single_stream_ant_msk =
452 first_antenna(priv->hw_params.valid_tx_ant);
453 link_cmd.general_params.dual_stream_ant_msk = 3;
454 link_cmd.agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF;
455 link_cmd.agg_params.agg_time_limit =
456 cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF);
358 457
359 memset(&priv->stations[sta_id], 0, sizeof(struct iwl_station_entry)); 458 /* Update the rate scaling for control frame Tx to AP */
360 spin_unlock_irqrestore(&priv->sta_lock, flags); 459 link_cmd.sta_id = is_ap ? IWL_AP_ID : priv->hw_params.bcast_sta_id;
460
461 iwl_send_cmd_pdu(priv, REPLY_TX_LINK_QUALITY_CMD,
462 sizeof(link_cmd), &link_cmd);
361} 463}
362 464
363static void iwl_remove_sta_callback(struct iwl_priv *priv, 465/*
364 struct iwl_device_cmd *cmd, 466 * iwl_add_local_stations - Add stations not requested by mac80211
365 struct iwl_rx_packet *pkt) 467 *
468 * This will be either the broadcast station or the bssid station needed by
469 * ad-hoc.
470 *
471 * Function sleeps.
472 */
473int iwl_add_local_station(struct iwl_priv *priv, const u8 *addr, bool init_rs)
366{ 474{
367 struct iwl_rem_sta_cmd *rm_sta = 475 int ret;
368 (struct iwl_rem_sta_cmd *)cmd->cmd.payload; 476 u8 sta_id;
369 const u8 *addr = rm_sta->addr;
370 477
371 if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { 478 ret = iwl_add_station_common(priv, addr, 0, NULL, &sta_id);
372 IWL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", 479 if (ret) {
373 pkt->hdr.flags); 480 IWL_ERR(priv, "Unable to add station %pM\n", addr);
374 return; 481 return ret;
375 } 482 }
376 483
377 switch (pkt->u.rem_sta.status) { 484 if (init_rs)
378 case REM_STA_SUCCESS_MSK: 485 /* Set up default rate scaling table in device's station table */
379 iwl_sta_ucode_deactivate(priv, addr); 486 iwl_sta_init_lq(priv, addr, false);
380 break; 487 return 0;
381 default: 488}
382 IWL_ERR(priv, "REPLY_REMOVE_STA failed\n"); 489EXPORT_SYMBOL(iwl_add_local_station);
383 break; 490
384 } 491/**
492 * iwl_sta_ucode_deactivate - deactivate ucode status for a station
493 *
494 * priv->sta_lock must be held
495 */
496static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, u8 sta_id)
497{
498 /* Ucode must be active and driver must be non active */
499 if (priv->stations[sta_id].used != IWL_STA_UCODE_ACTIVE)
500 IWL_ERR(priv, "removed non active STA %u\n", sta_id);
501
502 priv->stations[sta_id].used &= ~IWL_STA_UCODE_ACTIVE;
503
504 memset(&priv->stations[sta_id], 0, sizeof(struct iwl_station_entry));
505 IWL_DEBUG_ASSOC(priv, "Removed STA %u\n", sta_id);
385} 506}
386 507
387static int iwl_send_remove_station(struct iwl_priv *priv, const u8 *addr, 508static int iwl_send_remove_station(struct iwl_priv *priv,
388 u8 flags) 509 struct iwl_station_entry *station)
389{ 510{
390 struct iwl_rx_packet *pkt; 511 struct iwl_rx_packet *pkt;
391 int ret; 512 int ret;
392 513
514 unsigned long flags_spin;
393 struct iwl_rem_sta_cmd rm_sta_cmd; 515 struct iwl_rem_sta_cmd rm_sta_cmd;
394 516
395 struct iwl_host_cmd cmd = { 517 struct iwl_host_cmd cmd = {
396 .id = REPLY_REMOVE_STA, 518 .id = REPLY_REMOVE_STA,
397 .len = sizeof(struct iwl_rem_sta_cmd), 519 .len = sizeof(struct iwl_rem_sta_cmd),
398 .flags = flags, 520 .flags = CMD_SYNC,
399 .data = &rm_sta_cmd, 521 .data = &rm_sta_cmd,
400 }; 522 };
401 523
402 memset(&rm_sta_cmd, 0, sizeof(rm_sta_cmd)); 524 memset(&rm_sta_cmd, 0, sizeof(rm_sta_cmd));
403 rm_sta_cmd.num_sta = 1; 525 rm_sta_cmd.num_sta = 1;
404 memcpy(&rm_sta_cmd.addr, addr , ETH_ALEN); 526 memcpy(&rm_sta_cmd.addr, &station->sta.sta.addr , ETH_ALEN);
527
528 cmd.flags |= CMD_WANT_SKB;
405 529
406 if (flags & CMD_ASYNC)
407 cmd.callback = iwl_remove_sta_callback;
408 else
409 cmd.flags |= CMD_WANT_SKB;
410 ret = iwl_send_cmd(priv, &cmd); 530 ret = iwl_send_cmd(priv, &cmd);
411 531
412 if (ret || (flags & CMD_ASYNC)) 532 if (ret)
413 return ret; 533 return ret;
414 534
415 pkt = (struct iwl_rx_packet *)cmd.reply_page; 535 pkt = (struct iwl_rx_packet *)cmd.reply_page;
@@ -422,7 +542,9 @@ static int iwl_send_remove_station(struct iwl_priv *priv, const u8 *addr,
422 if (!ret) { 542 if (!ret) {
423 switch (pkt->u.rem_sta.status) { 543 switch (pkt->u.rem_sta.status) {
424 case REM_STA_SUCCESS_MSK: 544 case REM_STA_SUCCESS_MSK:
425 iwl_sta_ucode_deactivate(priv, addr); 545 spin_lock_irqsave(&priv->sta_lock, flags_spin);
546 iwl_sta_ucode_deactivate(priv, station->sta.sta.sta_id);
547 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
426 IWL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n"); 548 IWL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n");
427 break; 549 break;
428 default: 550 default:
@@ -439,23 +561,35 @@ static int iwl_send_remove_station(struct iwl_priv *priv, const u8 *addr,
439/** 561/**
440 * iwl_remove_station - Remove driver's knowledge of station. 562 * iwl_remove_station - Remove driver's knowledge of station.
441 */ 563 */
442int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, bool is_ap) 564static int iwl_remove_station(struct iwl_priv *priv, struct ieee80211_sta *sta)
443{ 565{
444 int sta_id = IWL_INVALID_STATION; 566 int sta_id = IWL_INVALID_STATION;
445 int i, ret = -EINVAL; 567 int i, ret = -EINVAL;
446 unsigned long flags; 568 unsigned long flags;
569 bool is_ap = priv->iw_mode == NL80211_IFTYPE_STATION;
570 struct iwl_station_entry *station;
571
572 if (!iwl_is_ready(priv)) {
573 IWL_DEBUG_INFO(priv,
574 "Unable to remove station %pM, device not ready. \n",
575 sta->addr);
576 /*
577 * It is typical for stations to be removed when we are
578 * going down. Return success since device will be down
579 * soon anyway
580 */
581 return 0;
582 }
447 583
448 spin_lock_irqsave(&priv->sta_lock, flags); 584 spin_lock_irqsave(&priv->sta_lock, flags);
449 585
450 if (is_ap) 586 if (is_ap)
451 sta_id = IWL_AP_ID; 587 sta_id = IWL_AP_ID;
452 else if (is_broadcast_ether_addr(addr))
453 sta_id = priv->hw_params.bcast_sta_id;
454 else 588 else
455 for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) 589 for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++)
456 if (priv->stations[i].used && 590 if (priv->stations[i].used &&
457 !compare_ether_addr(priv->stations[i].sta.sta.addr, 591 !compare_ether_addr(priv->stations[i].sta.sta.addr,
458 addr)) { 592 sta->addr)) {
459 sta_id = i; 593 sta_id = i;
460 break; 594 break;
461 } 595 }
@@ -464,17 +598,17 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, bool is_ap)
464 goto out; 598 goto out;
465 599
466 IWL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n", 600 IWL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n",
467 sta_id, addr); 601 sta_id, sta->addr);
468 602
469 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { 603 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) {
470 IWL_ERR(priv, "Removing %pM but non DRIVER active\n", 604 IWL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n",
471 addr); 605 sta->addr);
472 goto out; 606 goto out;
473 } 607 }
474 608
475 if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) { 609 if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) {
476 IWL_ERR(priv, "Removing %pM but non UCODE active\n", 610 IWL_DEBUG_INFO(priv, "Removing %pM but non UCODE active\n",
477 addr); 611 sta->addr);
478 goto out; 612 goto out;
479 } 613 }
480 614
@@ -485,9 +619,10 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, bool is_ap)
485 619
486 BUG_ON(priv->num_stations < 0); 620 BUG_ON(priv->num_stations < 0);
487 621
622 station = &priv->stations[sta_id];
488 spin_unlock_irqrestore(&priv->sta_lock, flags); 623 spin_unlock_irqrestore(&priv->sta_lock, flags);
489 624
490 ret = iwl_send_remove_station(priv, addr, CMD_ASYNC); 625 ret = iwl_send_remove_station(priv, station);
491 return ret; 626 return ret;
492out: 627out:
493 spin_unlock_irqrestore(&priv->sta_lock, flags); 628 spin_unlock_irqrestore(&priv->sta_lock, flags);
@@ -495,37 +630,122 @@ out:
495} 630}
496 631
497/** 632/**
498 * iwl_clear_stations_table - Clear the driver's station table 633 * iwl_clear_ucode_stations() - clear entire station table driver and/or ucode
499 * 634 * @priv:
500 * NOTE: This does not clear or otherwise alter the device's station table. 635 * @force: If set then the uCode station table needs to be cleared here. If
636 * not set then the uCode station table has already been cleared,
637 * for example after sending it a RXON command without ASSOC bit
638 * set, and we just need to change driver state here.
501 */ 639 */
502void iwl_clear_stations_table(struct iwl_priv *priv) 640void iwl_clear_ucode_stations(struct iwl_priv *priv, bool force)
503{ 641{
504 unsigned long flags;
505 int i; 642 int i;
643 unsigned long flags_spin;
644 bool cleared = false;
645
646 IWL_DEBUG_INFO(priv, "Clearing ucode stations in driver%s\n",
647 force ? " and ucode" : "");
648
649 if (force) {
650 if (!iwl_is_ready(priv)) {
651 /*
652 * If device is not ready at this point the station
653 * table is likely already empty (uCode not ready
654 * to receive station requests) or will soon be
655 * due to interface going down.
656 */
657 IWL_DEBUG_INFO(priv, "Unable to remove stations from device - device not ready\n");
658 } else {
659 iwl_send_cmd_pdu_async(priv, REPLY_REMOVE_ALL_STA, 0, NULL, NULL);
660 }
661 }
506 662
507 spin_lock_irqsave(&priv->sta_lock, flags); 663 spin_lock_irqsave(&priv->sta_lock, flags_spin);
664 if (force) {
665 IWL_DEBUG_INFO(priv, "Clearing all station information in driver\n");
666 priv->num_stations = 0;
667 memset(priv->stations, 0, sizeof(priv->stations));
668 } else {
669 for (i = 0; i < priv->hw_params.max_stations; i++) {
670 if (priv->stations[i].used & IWL_STA_UCODE_ACTIVE) {
671 IWL_DEBUG_INFO(priv, "Clearing ucode active for station %d \n", i);
672 priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE;
673 cleared = true;
674 }
675 }
676 }
677 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
508 678
509 if (iwl_is_alive(priv) && 679 if (!cleared)
510 !test_bit(STATUS_EXIT_PENDING, &priv->status) && 680 IWL_DEBUG_INFO(priv, "No active stations found to be cleared\n");
511 iwl_send_cmd_pdu_async(priv, REPLY_REMOVE_ALL_STA, 0, NULL, NULL)) 681}
512 IWL_ERR(priv, "Couldn't clear the station table\n"); 682EXPORT_SYMBOL(iwl_clear_ucode_stations);
683
684/**
685 * iwl_restore_stations() - Restore driver known stations to device
686 *
687 * All stations considered active by driver, but not present in ucode, is
688 * restored.
689 *
690 * Function sleeps.
691 */
692void iwl_restore_stations(struct iwl_priv *priv)
693{
694 struct iwl_station_entry *station;
695 unsigned long flags_spin;
696 int i;
697 bool found = false;
698 int ret;
513 699
514 priv->num_stations = 0; 700 if (!iwl_is_ready(priv)) {
515 memset(priv->stations, 0, sizeof(priv->stations)); 701 IWL_DEBUG_INFO(priv, "Not ready yet, not restoring any stations.\n");
702 return;
703 }
516 704
517 /* clean ucode key table bit map */ 705 IWL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n");
518 priv->ucode_key_table = 0; 706 spin_lock_irqsave(&priv->sta_lock, flags_spin);
707 for (i = 0; i < priv->hw_params.max_stations; i++) {
708 if ((priv->stations[i].used & IWL_STA_DRIVER_ACTIVE) &&
709 !(priv->stations[i].used & IWL_STA_UCODE_ACTIVE)) {
710 IWL_DEBUG_ASSOC(priv, "Restoring sta %pM\n",
711 priv->stations[i].sta.sta.addr);
712 priv->stations[i].sta.mode = 0;
713 priv->stations[i].used |= IWL_STA_UCODE_INPROGRESS;
714 found = true;
715 }
716 }
519 717
520 /* keep track of static keys */ 718 for (i = 0; i < priv->hw_params.max_stations; i++) {
521 for (i = 0; i < WEP_KEYS_MAX ; i++) { 719 if ((priv->stations[i].used & IWL_STA_UCODE_INPROGRESS)) {
522 if (priv->wep_keys[i].key_size) 720 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
523 set_bit(i, &priv->ucode_key_table); 721 station = &priv->stations[i];
722 ret = iwl_send_add_sta(priv, &priv->stations[i].sta, CMD_SYNC);
723 if (ret) {
724 IWL_ERR(priv, "Adding station %pM failed.\n",
725 station->sta.sta.addr);
726 spin_lock_irqsave(&priv->sta_lock, flags_spin);
727 priv->stations[i].used &= ~IWL_STA_DRIVER_ACTIVE;
728 priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS;
729 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
730 }
731 /*
732 * Rate scaling has already been initialized, send
733 * current LQ command
734 */
735 if (station->lq)
736 iwl_send_lq_cmd(priv, station->lq, CMD_SYNC, true);
737 spin_lock_irqsave(&priv->sta_lock, flags_spin);
738 priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS;
739 }
524 } 740 }
525 741
526 spin_unlock_irqrestore(&priv->sta_lock, flags); 742 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
743 if (!found)
744 IWL_DEBUG_INFO(priv, "Restoring all known stations .... no stations to be restored.\n");
745 else
746 IWL_DEBUG_INFO(priv, "Restoring all known stations .... complete.\n");
527} 747}
528EXPORT_SYMBOL(iwl_clear_stations_table); 748EXPORT_SYMBOL(iwl_restore_stations);
529 749
530int iwl_get_free_ucode_key_index(struct iwl_priv *priv) 750int iwl_get_free_ucode_key_index(struct iwl_priv *priv)
531{ 751{
@@ -549,9 +769,11 @@ int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
549 struct iwl_host_cmd cmd = { 769 struct iwl_host_cmd cmd = {
550 .id = REPLY_WEPKEY, 770 .id = REPLY_WEPKEY,
551 .data = wep_cmd, 771 .data = wep_cmd,
552 .flags = CMD_ASYNC, 772 .flags = CMD_SYNC,
553 }; 773 };
554 774
775 might_sleep();
776
555 memset(wep_cmd, 0, cmd_size + 777 memset(wep_cmd, 0, cmd_size +
556 (sizeof(struct iwl_wep_key) * WEP_KEYS_MAX)); 778 (sizeof(struct iwl_wep_key) * WEP_KEYS_MAX));
557 779
@@ -587,9 +809,9 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv,
587 struct ieee80211_key_conf *keyconf) 809 struct ieee80211_key_conf *keyconf)
588{ 810{
589 int ret; 811 int ret;
590 unsigned long flags;
591 812
592 spin_lock_irqsave(&priv->sta_lock, flags); 813 WARN_ON(!mutex_is_locked(&priv->mutex));
814
593 IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", 815 IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n",
594 keyconf->keyidx); 816 keyconf->keyidx);
595 817
@@ -601,13 +823,12 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv,
601 memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0])); 823 memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0]));
602 if (iwl_is_rfkill(priv)) { 824 if (iwl_is_rfkill(priv)) {
603 IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n"); 825 IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n");
604 spin_unlock_irqrestore(&priv->sta_lock, flags); 826 /* but keys in device are clear anyway so return success */
605 return 0; 827 return 0;
606 } 828 }
607 ret = iwl_send_static_wepkey_cmd(priv, 1); 829 ret = iwl_send_static_wepkey_cmd(priv, 1);
608 IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n", 830 IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n",
609 keyconf->keyidx, ret); 831 keyconf->keyidx, ret);
610 spin_unlock_irqrestore(&priv->sta_lock, flags);
611 832
612 return ret; 833 return ret;
613} 834}
@@ -617,7 +838,8 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
617 struct ieee80211_key_conf *keyconf) 838 struct ieee80211_key_conf *keyconf)
618{ 839{
619 int ret; 840 int ret;
620 unsigned long flags; 841
842 WARN_ON(!mutex_is_locked(&priv->mutex));
621 843
622 if (keyconf->keylen != WEP_KEY_LEN_128 && 844 if (keyconf->keylen != WEP_KEY_LEN_128 &&
623 keyconf->keylen != WEP_KEY_LEN_64) { 845 keyconf->keylen != WEP_KEY_LEN_64) {
@@ -629,12 +851,11 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
629 keyconf->hw_key_idx = HW_KEY_DEFAULT; 851 keyconf->hw_key_idx = HW_KEY_DEFAULT;
630 priv->stations[IWL_AP_ID].keyinfo.alg = ALG_WEP; 852 priv->stations[IWL_AP_ID].keyinfo.alg = ALG_WEP;
631 853
632 spin_lock_irqsave(&priv->sta_lock, flags);
633 priv->default_wep_key++; 854 priv->default_wep_key++;
634 855
635 if (test_and_set_bit(keyconf->keyidx, &priv->ucode_key_table)) 856 if (test_and_set_bit(keyconf->keyidx, &priv->ucode_key_table))
636 IWL_ERR(priv, "index %d already used in uCode key table.\n", 857 IWL_ERR(priv, "index %d already used in uCode key table.\n",
637 keyconf->keyidx); 858 keyconf->keyidx);
638 859
639 priv->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; 860 priv->wep_keys[keyconf->keyidx].key_size = keyconf->keylen;
640 memcpy(&priv->wep_keys[keyconf->keyidx].key, &keyconf->key, 861 memcpy(&priv->wep_keys[keyconf->keyidx].key, &keyconf->key,
@@ -643,7 +864,6 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
643 ret = iwl_send_static_wepkey_cmd(priv, 0); 864 ret = iwl_send_static_wepkey_cmd(priv, 0);
644 IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n", 865 IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n",
645 keyconf->keylen, keyconf->keyidx, ret); 866 keyconf->keylen, keyconf->keyidx, ret);
646 spin_unlock_irqrestore(&priv->sta_lock, flags);
647 867
648 return ret; 868 return ret;
649} 869}
@@ -948,9 +1168,22 @@ static inline void iwl_dump_lq_cmd(struct iwl_priv *priv,
948} 1168}
949#endif 1169#endif
950 1170
1171/**
1172 * iwl_send_lq_cmd() - Send link quality command
1173 * @init: This command is sent as part of station initialization right
1174 * after station has been added.
1175 *
1176 * The link quality command is sent as the last step of station creation.
1177 * This is the special case in which init is set and we call a callback in
1178 * this case to clear the state indicating that station creation is in
1179 * progress.
1180 */
951int iwl_send_lq_cmd(struct iwl_priv *priv, 1181int iwl_send_lq_cmd(struct iwl_priv *priv,
952 struct iwl_link_quality_cmd *lq, u8 flags) 1182 struct iwl_link_quality_cmd *lq, u8 flags, bool init)
953{ 1183{
1184 int ret = 0;
1185 unsigned long flags_spin;
1186
954 struct iwl_host_cmd cmd = { 1187 struct iwl_host_cmd cmd = {
955 .id = REPLY_TX_LINK_QUALITY_CMD, 1188 .id = REPLY_TX_LINK_QUALITY_CMD,
956 .len = sizeof(struct iwl_link_quality_cmd), 1189 .len = sizeof(struct iwl_link_quality_cmd),
@@ -966,167 +1199,31 @@ int iwl_send_lq_cmd(struct iwl_priv *priv,
966 lq->sta_id = IWL_AP_ID; 1199 lq->sta_id = IWL_AP_ID;
967 1200
968 iwl_dump_lq_cmd(priv, lq); 1201 iwl_dump_lq_cmd(priv, lq);
1202 BUG_ON(init && (cmd.flags & CMD_ASYNC));
969 1203
970 if (iwl_is_associated(priv) && priv->assoc_station_added) 1204 iwl_dump_lq_cmd(priv, lq);
971 return iwl_send_cmd(priv, &cmd); 1205 ret = iwl_send_cmd(priv, &cmd);
1206 if (ret || (cmd.flags & CMD_ASYNC))
1207 return ret;
972 1208
1209 if (init) {
1210 IWL_DEBUG_INFO(priv, "init LQ command complete, clearing sta addition status for sta %d \n",
1211 lq->sta_id);
1212 spin_lock_irqsave(&priv->sta_lock, flags_spin);
1213 priv->stations[lq->sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
1214 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
1215 }
973 return 0; 1216 return 0;
974} 1217}
975EXPORT_SYMBOL(iwl_send_lq_cmd); 1218EXPORT_SYMBOL(iwl_send_lq_cmd);
976 1219
977/** 1220/**
978 * iwl_sta_init_lq - Initialize a station's hardware rate table
979 *
980 * The uCode's station table contains a table of fallback rates
981 * for automatic fallback during transmission.
982 *
983 * NOTE: This sets up a default set of values. These will be replaced later
984 * if the driver's iwl-agn-rs rate scaling algorithm is used, instead of
985 * rc80211_simple.
986 *
987 * NOTE: Run REPLY_ADD_STA command to set up station table entry, before
988 * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD,
989 * which requires station table entry to exist).
990 */
991static void iwl_sta_init_lq(struct iwl_priv *priv, const u8 *addr, bool is_ap)
992{
993 int i, r;
994 struct iwl_link_quality_cmd link_cmd = {
995 .reserved1 = 0,
996 };
997 u32 rate_flags;
998
999 /* Set up the rate scaling to start at selected rate, fall back
1000 * all the way down to 1M in IEEE order, and then spin on 1M */
1001 if (is_ap)
1002 r = IWL_RATE_54M_INDEX;
1003 else if (priv->band == IEEE80211_BAND_5GHZ)
1004 r = IWL_RATE_6M_INDEX;
1005 else
1006 r = IWL_RATE_1M_INDEX;
1007
1008 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
1009 rate_flags = 0;
1010 if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE)
1011 rate_flags |= RATE_MCS_CCK_MSK;
1012
1013 rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) <<
1014 RATE_MCS_ANT_POS;
1015
1016 link_cmd.rs_table[i].rate_n_flags =
1017 iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags);
1018 r = iwl_get_prev_ieee_rate(r);
1019 }
1020
1021 link_cmd.general_params.single_stream_ant_msk =
1022 first_antenna(priv->hw_params.valid_tx_ant);
1023 link_cmd.general_params.dual_stream_ant_msk = 3;
1024 link_cmd.agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF;
1025 link_cmd.agg_params.agg_time_limit =
1026 cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF);
1027
1028 /* Update the rate scaling for control frame Tx to AP */
1029 link_cmd.sta_id = is_ap ? IWL_AP_ID : priv->hw_params.bcast_sta_id;
1030
1031 iwl_send_cmd_pdu_async(priv, REPLY_TX_LINK_QUALITY_CMD,
1032 sizeof(link_cmd), &link_cmd, NULL);
1033}
1034
1035/**
1036 * iwl_rxon_add_station - add station into station table.
1037 *
1038 * there is only one AP station with id= IWL_AP_ID
1039 * NOTE: mutex must be held before calling this function
1040 */
1041int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap)
1042{
1043 struct ieee80211_sta *sta;
1044 struct ieee80211_sta_ht_cap ht_config;
1045 struct ieee80211_sta_ht_cap *cur_ht_config = NULL;
1046 u8 sta_id;
1047
1048 /*
1049 * Set HT capabilities. It is ok to set this struct even if not using
1050 * HT config: the priv->current_ht_config.is_ht flag will just be false
1051 */
1052 rcu_read_lock();
1053 sta = ieee80211_find_sta(priv->vif, addr);
1054 if (sta) {
1055 memcpy(&ht_config, &sta->ht_cap, sizeof(ht_config));
1056 cur_ht_config = &ht_config;
1057 }
1058 rcu_read_unlock();
1059
1060 /* Add station to device's station table */
1061 sta_id = iwl_add_station(priv, addr, is_ap, CMD_SYNC, cur_ht_config);
1062
1063 /* Set up default rate scaling table in device's station table */
1064 iwl_sta_init_lq(priv, addr, is_ap);
1065
1066 return sta_id;
1067}
1068EXPORT_SYMBOL(iwl_rxon_add_station);
1069
1070/**
1071 * iwl_sta_init_bcast_lq - Initialize a bcast station's hardware rate table
1072 *
1073 * NOTE: Run REPLY_ADD_STA command to set up station table entry, before
1074 * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD,
1075 * which requires station table entry to exist).
1076 */
1077static void iwl_sta_init_bcast_lq(struct iwl_priv *priv)
1078{
1079 int i, r;
1080 struct iwl_link_quality_cmd link_cmd = {
1081 .reserved1 = 0,
1082 };
1083 u32 rate_flags;
1084
1085 /* Set up the rate scaling to start at selected rate, fall back
1086 * all the way down to 1M in IEEE order, and then spin on 1M */
1087 if (priv->band == IEEE80211_BAND_5GHZ)
1088 r = IWL_RATE_6M_INDEX;
1089 else
1090 r = IWL_RATE_1M_INDEX;
1091
1092 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
1093 rate_flags = 0;
1094 if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE)
1095 rate_flags |= RATE_MCS_CCK_MSK;
1096
1097 rate_flags |= first_antenna(priv->hw_params.valid_tx_ant) <<
1098 RATE_MCS_ANT_POS;
1099
1100 link_cmd.rs_table[i].rate_n_flags =
1101 iwl_hw_set_rate_n_flags(iwl_rates[r].plcp, rate_flags);
1102 r = iwl_get_prev_ieee_rate(r);
1103 }
1104
1105 link_cmd.general_params.single_stream_ant_msk =
1106 first_antenna(priv->hw_params.valid_tx_ant);
1107 link_cmd.general_params.dual_stream_ant_msk = 3;
1108 link_cmd.agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF;
1109 link_cmd.agg_params.agg_time_limit =
1110 cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF);
1111
1112 /* Update the rate scaling for control frame Tx to AP */
1113 link_cmd.sta_id = priv->hw_params.bcast_sta_id;
1114
1115 iwl_send_cmd_pdu_async(priv, REPLY_TX_LINK_QUALITY_CMD,
1116 sizeof(link_cmd), &link_cmd, NULL);
1117}
1118
1119
1120/**
1121 * iwl_add_bcast_station - add broadcast station into station table. 1221 * iwl_add_bcast_station - add broadcast station into station table.
1122 */ 1222 */
1123void iwl_add_bcast_station(struct iwl_priv *priv) 1223void iwl_add_bcast_station(struct iwl_priv *priv)
1124{ 1224{
1125 IWL_DEBUG_INFO(priv, "Adding broadcast station to station table\n"); 1225 IWL_DEBUG_INFO(priv, "Adding broadcast station to station table\n");
1126 iwl_add_station(priv, iwl_bcast_addr, false, CMD_SYNC, NULL); 1226 iwl_add_local_station(priv, iwl_bcast_addr, true);
1127
1128 /* Set up default rate scaling table in device's station table */
1129 iwl_sta_init_bcast_lq(priv);
1130} 1227}
1131EXPORT_SYMBOL(iwl_add_bcast_station); 1228EXPORT_SYMBOL(iwl_add_bcast_station);
1132 1229
@@ -1136,7 +1233,14 @@ EXPORT_SYMBOL(iwl_add_bcast_station);
1136void iwl3945_add_bcast_station(struct iwl_priv *priv) 1233void iwl3945_add_bcast_station(struct iwl_priv *priv)
1137{ 1234{
1138 IWL_DEBUG_INFO(priv, "Adding broadcast station to station table\n"); 1235 IWL_DEBUG_INFO(priv, "Adding broadcast station to station table\n");
1139 iwl_add_station(priv, iwl_bcast_addr, false, CMD_SYNC, NULL); 1236 iwl_add_local_station(priv, iwl_bcast_addr, false);
1237 /*
1238 * It is assumed that when station is added more initialization
1239 * needs to be done, but for 3945 it is not the case and we can
1240 * just release station table access right here.
1241 */
1242 priv->stations[priv->hw_params.bcast_sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
1243
1140} 1244}
1141EXPORT_SYMBOL(iwl3945_add_bcast_station); 1245EXPORT_SYMBOL(iwl3945_add_bcast_station);
1142 1246
@@ -1159,6 +1263,13 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
1159 /* If we are a client station in a BSS network, use the special 1263 /* If we are a client station in a BSS network, use the special
1160 * AP station entry (that's the only station we communicate with) */ 1264 * AP station entry (that's the only station we communicate with) */
1161 case NL80211_IFTYPE_STATION: 1265 case NL80211_IFTYPE_STATION:
1266 /*
1267 * If addition of station not complete yet, which means
1268 * that rate scaling has not been initialized, then return
1269 * the broadcast station.
1270 */
1271 if (!(priv->stations[IWL_AP_ID].used & IWL_STA_UCODE_ACTIVE))
1272 return priv->hw_params.bcast_sta_id;
1162 return IWL_AP_ID; 1273 return IWL_AP_ID;
1163 1274
1164 /* If we are an AP, then find the station, or use BCAST */ 1275 /* If we are an AP, then find the station, or use BCAST */
@@ -1175,13 +1286,6 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
1175 if (sta_id != IWL_INVALID_STATION) 1286 if (sta_id != IWL_INVALID_STATION)
1176 return sta_id; 1287 return sta_id;
1177 1288
1178 /* Create new station table entry */
1179 sta_id = iwl_add_station(priv, hdr->addr1, false,
1180 CMD_ASYNC, NULL);
1181
1182 if (sta_id != IWL_INVALID_STATION)
1183 return sta_id;
1184
1185 IWL_DEBUG_DROP(priv, "Station %pM not in station map. " 1289 IWL_DEBUG_DROP(priv, "Station %pM not in station map. "
1186 "Defaulting to broadcast...\n", 1290 "Defaulting to broadcast...\n",
1187 hdr->addr1); 1291 hdr->addr1);
@@ -1291,3 +1395,19 @@ void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt)
1291 1395
1292 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); 1396 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
1293} 1397}
1398
1399int iwl_mac_sta_remove(struct ieee80211_hw *hw,
1400 struct ieee80211_vif *vif,
1401 struct ieee80211_sta *sta)
1402{
1403 int ret;
1404 struct iwl_priv *priv = hw->priv;
1405 IWL_DEBUG_INFO(priv, "received request to remove station %pM\n",
1406 sta->addr);
1407 ret = iwl_remove_station(priv, sta);
1408 if (ret)
1409 IWL_ERR(priv, "Error removing station %pM\n",
1410 sta->addr);
1411 return ret;
1412}
1413EXPORT_SYMBOL(iwl_mac_sta_remove);
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.h b/drivers/net/wireless/iwlwifi/iwl-sta.h
index 2dc35fe28f56..87a34997a758 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.h
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.h
@@ -32,6 +32,12 @@
32#define HW_KEY_DYNAMIC 0 32#define HW_KEY_DYNAMIC 0
33#define HW_KEY_DEFAULT 1 33#define HW_KEY_DEFAULT 1
34 34
35#define IWL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */
36#define IWL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */
37#define IWL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of
38 being activated */
39
40
35/** 41/**
36 * iwl_find_station - Find station id for a given BSSID 42 * iwl_find_station - Find station id for a given BSSID
37 * @bssid: MAC address of station ID to find 43 * @bssid: MAC address of station ID to find
@@ -51,18 +57,22 @@ void iwl_update_tkip_key(struct iwl_priv *priv,
51 struct ieee80211_key_conf *keyconf, 57 struct ieee80211_key_conf *keyconf,
52 const u8 *addr, u32 iv32, u16 *phase1key); 58 const u8 *addr, u32 iv32, u16 *phase1key);
53 59
54int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap);
55void iwl_add_bcast_station(struct iwl_priv *priv); 60void iwl_add_bcast_station(struct iwl_priv *priv);
56void iwl3945_add_bcast_station(struct iwl_priv *priv); 61void iwl3945_add_bcast_station(struct iwl_priv *priv);
57int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, bool is_ap); 62void iwl_restore_stations(struct iwl_priv *priv);
58void iwl_clear_stations_table(struct iwl_priv *priv); 63void iwl_clear_ucode_stations(struct iwl_priv *priv, bool force);
59int iwl_get_free_ucode_key_index(struct iwl_priv *priv); 64int iwl_get_free_ucode_key_index(struct iwl_priv *priv);
60int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr); 65int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr);
61int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr); 66int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr);
62int iwl_send_add_sta(struct iwl_priv *priv, 67int iwl_send_add_sta(struct iwl_priv *priv,
63 struct iwl_addsta_cmd *sta, u8 flags); 68 struct iwl_addsta_cmd *sta, u8 flags);
64u8 iwl_add_station(struct iwl_priv *priv, const u8 *addr, bool is_ap, u8 flags, 69int iwl_add_local_station(struct iwl_priv *priv, const u8 *addr, bool init_rs);
65 struct ieee80211_sta_ht_cap *ht_info); 70int iwl_add_station_common(struct iwl_priv *priv, const u8 *addr,
71 bool is_ap,
72 struct ieee80211_sta_ht_cap *ht_info,
73 u8 *sta_id_r);
74int iwl_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
75 struct ieee80211_sta *sta);
66void iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid); 76void iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid);
67int iwl_sta_rx_agg_start(struct iwl_priv *priv, 77int iwl_sta_rx_agg_start(struct iwl_priv *priv,
68 const u8 *addr, int tid, u16 ssn); 78 const u8 *addr, int tid, u16 ssn);
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 8c12311dbb0a..1e481f3fcabf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -37,26 +37,63 @@
37#include "iwl-io.h" 37#include "iwl-io.h"
38#include "iwl-helpers.h" 38#include "iwl-helpers.h"
39 39
40static const u16 default_tid_to_tx_fifo[] = { 40/*
41 IWL_TX_FIFO_AC1, 41 * mac80211 queues, ACs, hardware queues, FIFOs.
42 IWL_TX_FIFO_AC0, 42 *
43 IWL_TX_FIFO_AC0, 43 * Cf. http://wireless.kernel.org/en/developers/Documentation/mac80211/queues
44 IWL_TX_FIFO_AC1, 44 *
45 IWL_TX_FIFO_AC2, 45 * Mac80211 uses the following numbers, which we get as from it
46 IWL_TX_FIFO_AC2, 46 * by way of skb_get_queue_mapping(skb):
47 IWL_TX_FIFO_AC3, 47 *
48 IWL_TX_FIFO_AC3, 48 * VO 0
49 IWL_TX_FIFO_NONE, 49 * VI 1
50 IWL_TX_FIFO_NONE, 50 * BE 2
51 IWL_TX_FIFO_NONE, 51 * BK 3
52 IWL_TX_FIFO_NONE, 52 *
53 IWL_TX_FIFO_NONE, 53 *
54 IWL_TX_FIFO_NONE, 54 * Regular (not A-MPDU) frames are put into hardware queues corresponding
55 IWL_TX_FIFO_NONE, 55 * to the FIFOs, see comments in iwl-prph.h. Aggregated frames get their
56 IWL_TX_FIFO_NONE, 56 * own queue per aggregation session (RA/TID combination), such queues are
57 IWL_TX_FIFO_AC3 57 * set up to map into FIFOs too, for which we need an AC->FIFO mapping. In
58 * order to map frames to the right queue, we also need an AC->hw queue
59 * mapping. This is implemented here.
60 *
61 * Due to the way hw queues are set up (by the hw specific modules like
62 * iwl-4965.c, iwl-5000.c etc.), the AC->hw queue mapping is the identity
63 * mapping.
64 */
65
66static const u8 tid_to_ac[] = {
67 /* this matches the mac80211 numbers */
68 2, 3, 3, 2, 1, 1, 0, 0
69};
70
71static const u8 ac_to_fifo[] = {
72 IWL_TX_FIFO_VO,
73 IWL_TX_FIFO_VI,
74 IWL_TX_FIFO_BE,
75 IWL_TX_FIFO_BK,
58}; 76};
59 77
78static inline int get_fifo_from_ac(u8 ac)
79{
80 return ac_to_fifo[ac];
81}
82
83static inline int get_queue_from_ac(u16 ac)
84{
85 return ac;
86}
87
88static inline int get_fifo_from_tid(u16 tid)
89{
90 if (likely(tid < ARRAY_SIZE(tid_to_ac)))
91 return get_fifo_from_ac(tid_to_ac[tid]);
92
93 /* no support for TIDs 8-15 yet */
94 return -EINVAL;
95}
96
60static inline int iwl_alloc_dma_ptr(struct iwl_priv *priv, 97static inline int iwl_alloc_dma_ptr(struct iwl_priv *priv,
61 struct iwl_dma_ptr *ptr, size_t size) 98 struct iwl_dma_ptr *ptr, size_t size)
62{ 99{
@@ -285,6 +322,8 @@ static int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
285 q->high_mark = 2; 322 q->high_mark = 2;
286 323
287 q->write_ptr = q->read_ptr = 0; 324 q->write_ptr = q->read_ptr = 0;
325 q->last_read_ptr = 0;
326 q->repeat_same_read_ptr = 0;
288 327
289 return 0; 328 return 0;
290} 329}
@@ -591,13 +630,12 @@ static void iwl_tx_cmd_build_basic(struct iwl_priv *priv,
591 tx_cmd->next_frame_len = 0; 630 tx_cmd->next_frame_len = 0;
592} 631}
593 632
594#define RTS_HCCA_RETRY_LIMIT 3
595#define RTS_DFAULT_RETRY_LIMIT 60 633#define RTS_DFAULT_RETRY_LIMIT 60
596 634
597static void iwl_tx_cmd_build_rate(struct iwl_priv *priv, 635static void iwl_tx_cmd_build_rate(struct iwl_priv *priv,
598 struct iwl_tx_cmd *tx_cmd, 636 struct iwl_tx_cmd *tx_cmd,
599 struct ieee80211_tx_info *info, 637 struct ieee80211_tx_info *info,
600 __le16 fc, int is_hcca) 638 __le16 fc)
601{ 639{
602 u32 rate_flags; 640 u32 rate_flags;
603 int rate_idx; 641 int rate_idx;
@@ -613,8 +651,7 @@ static void iwl_tx_cmd_build_rate(struct iwl_priv *priv,
613 tx_cmd->data_retry_limit = data_retry_limit; 651 tx_cmd->data_retry_limit = data_retry_limit;
614 652
615 /* Set retry limit on RTS packets */ 653 /* Set retry limit on RTS packets */
616 rts_retry_limit = (is_hcca) ? RTS_HCCA_RETRY_LIMIT : 654 rts_retry_limit = RTS_DFAULT_RETRY_LIMIT;
617 RTS_DFAULT_RETRY_LIMIT;
618 if (data_retry_limit < rts_retry_limit) 655 if (data_retry_limit < rts_retry_limit)
619 rts_retry_limit = data_retry_limit; 656 rts_retry_limit = data_retry_limit;
620 tx_cmd->rts_retry_limit = rts_retry_limit; 657 tx_cmd->rts_retry_limit = rts_retry_limit;
@@ -761,16 +798,6 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
761 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n"); 798 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n");
762#endif 799#endif
763 800
764 /* drop all non-injected data frame if we are not associated */
765 if (ieee80211_is_data(fc) &&
766 !(info->flags & IEEE80211_TX_CTL_INJECTED) &&
767 (!iwl_is_associated(priv) ||
768 ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id) ||
769 !priv->assoc_station_added)) {
770 IWL_DEBUG_DROP(priv, "Dropping - !iwl_is_associated\n");
771 goto drop_unlock;
772 }
773
774 hdr_len = ieee80211_hdrlen(fc); 801 hdr_len = ieee80211_hdrlen(fc);
775 802
776 /* Find (or create) index into station table for destination station */ 803 /* Find (or create) index into station table for destination station */
@@ -804,7 +831,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
804 iwl_sta_modify_sleep_tx_count(priv, sta_id, 1); 831 iwl_sta_modify_sleep_tx_count(priv, sta_id, 1);
805 } 832 }
806 833
807 txq_id = skb_get_queue_mapping(skb); 834 txq_id = get_queue_from_ac(skb_get_queue_mapping(skb));
808 if (ieee80211_is_data_qos(fc)) { 835 if (ieee80211_is_data_qos(fc)) {
809 qc = ieee80211_get_qos_ctl(hdr); 836 qc = ieee80211_get_qos_ctl(hdr);
810 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; 837 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
@@ -869,8 +896,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
869 iwl_tx_cmd_build_basic(priv, tx_cmd, info, hdr, sta_id); 896 iwl_tx_cmd_build_basic(priv, tx_cmd, info, hdr, sta_id);
870 iwl_dbg_log_tx_data_frame(priv, len, hdr); 897 iwl_dbg_log_tx_data_frame(priv, len, hdr);
871 898
872 /* set is_hcca to 0; it probably will never be implemented */ 899 iwl_tx_cmd_build_rate(priv, tx_cmd, info, fc);
873 iwl_tx_cmd_build_rate(priv, tx_cmd, info, fc, 0);
874 900
875 iwl_update_stats(priv, true, fc, len); 901 iwl_update_stats(priv, true, fc, len);
876 /* 902 /*
@@ -1270,7 +1296,7 @@ EXPORT_SYMBOL(iwl_tx_cmd_complete);
1270 * Find first available (lowest unused) Tx Queue, mark it "active". 1296 * Find first available (lowest unused) Tx Queue, mark it "active".
1271 * Called only when finding queue for aggregation. 1297 * Called only when finding queue for aggregation.
1272 * Should never return anything < 7, because they should already 1298 * Should never return anything < 7, because they should already
1273 * be in use as EDCA AC (0-3), Command (4), HCCA (5, 6). 1299 * be in use as EDCA AC (0-3), Command (4), reserved (5, 6)
1274 */ 1300 */
1275static int iwl_txq_ctx_activate_free(struct iwl_priv *priv) 1301static int iwl_txq_ctx_activate_free(struct iwl_priv *priv)
1276{ 1302{
@@ -1291,10 +1317,9 @@ int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn)
1291 unsigned long flags; 1317 unsigned long flags;
1292 struct iwl_tid_data *tid_data; 1318 struct iwl_tid_data *tid_data;
1293 1319
1294 if (likely(tid < ARRAY_SIZE(default_tid_to_tx_fifo))) 1320 tx_fifo = get_fifo_from_tid(tid);
1295 tx_fifo = default_tid_to_tx_fifo[tid]; 1321 if (unlikely(tx_fifo < 0))
1296 else 1322 return tx_fifo;
1297 return -EINVAL;
1298 1323
1299 IWL_WARN(priv, "%s on ra = %pM tid = %d\n", 1324 IWL_WARN(priv, "%s on ra = %pM tid = %d\n",
1300 __func__, ra, tid); 1325 __func__, ra, tid);
@@ -1355,13 +1380,9 @@ int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid)
1355 return -EINVAL; 1380 return -EINVAL;
1356 } 1381 }
1357 1382
1358 if (unlikely(tid >= MAX_TID_COUNT)) 1383 tx_fifo_id = get_fifo_from_tid(tid);
1359 return -EINVAL; 1384 if (unlikely(tx_fifo_id < 0))
1360 1385 return tx_fifo_id;
1361 if (likely(tid < ARRAY_SIZE(default_tid_to_tx_fifo)))
1362 tx_fifo_id = default_tid_to_tx_fifo[tid];
1363 else
1364 return -EINVAL;
1365 1386
1366 sta_id = iwl_find_station(priv, ra); 1387 sta_id = iwl_find_station(priv, ra);
1367 1388
@@ -1429,7 +1450,7 @@ int iwl_txq_check_empty(struct iwl_priv *priv, int sta_id, u8 tid, int txq_id)
1429 if ((txq_id == tid_data->agg.txq_id) && 1450 if ((txq_id == tid_data->agg.txq_id) &&
1430 (q->read_ptr == q->write_ptr)) { 1451 (q->read_ptr == q->write_ptr)) {
1431 u16 ssn = SEQ_TO_SN(tid_data->seq_number); 1452 u16 ssn = SEQ_TO_SN(tid_data->seq_number);
1432 int tx_fifo = default_tid_to_tx_fifo[tid]; 1453 int tx_fifo = get_fifo_from_tid(tid);
1433 IWL_DEBUG_HT(priv, "HW queue empty: continue DELBA flow\n"); 1454 IWL_DEBUG_HT(priv, "HW queue empty: continue DELBA flow\n");
1434 priv->cfg->ops->lib->txq_agg_disable(priv, txq_id, 1455 priv->cfg->ops->lib->txq_agg_disable(priv, txq_id,
1435 ssn, tx_fifo); 1456 ssn, tx_fifo);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index e276f2a4e835..64f150b19771 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -351,11 +351,11 @@ static int iwl3945_send_beacon_cmd(struct iwl_priv *priv)
351 351
352static void iwl3945_unset_hw_params(struct iwl_priv *priv) 352static void iwl3945_unset_hw_params(struct iwl_priv *priv)
353{ 353{
354 if (priv->shared_virt) 354 if (priv->_3945.shared_virt)
355 dma_free_coherent(&priv->pci_dev->dev, 355 dma_free_coherent(&priv->pci_dev->dev,
356 sizeof(struct iwl3945_shared), 356 sizeof(struct iwl3945_shared),
357 priv->shared_virt, 357 priv->_3945.shared_virt,
358 priv->shared_phys); 358 priv->_3945.shared_phys);
359} 359}
360 360
361static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, 361static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
@@ -504,15 +504,6 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
504 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n"); 504 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n");
505#endif 505#endif
506 506
507 /* drop all non-injected data frame if we are not associated */
508 if (ieee80211_is_data(fc) &&
509 !(info->flags & IEEE80211_TX_CTL_INJECTED) &&
510 (!iwl_is_associated(priv) ||
511 ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id))) {
512 IWL_DEBUG_DROP(priv, "Dropping - !iwl_is_associated\n");
513 goto drop_unlock;
514 }
515
516 spin_unlock_irqrestore(&priv->lock, flags); 507 spin_unlock_irqrestore(&priv->lock, flags);
517 508
518 hdr_len = ieee80211_hdrlen(fc); 509 hdr_len = ieee80211_hdrlen(fc);
@@ -753,7 +744,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv,
753 if (iwl_is_associated(priv)) 744 if (iwl_is_associated(priv))
754 add_time = 745 add_time =
755 iwl3945_usecs_to_beacons( 746 iwl3945_usecs_to_beacons(
756 le64_to_cpu(params->start_time) - priv->last_tsf, 747 le64_to_cpu(params->start_time) - priv->_3945.last_tsf,
757 le16_to_cpu(priv->rxon_timing.beacon_interval)); 748 le16_to_cpu(priv->rxon_timing.beacon_interval));
758 749
759 memset(&spectrum, 0, sizeof(spectrum)); 750 memset(&spectrum, 0, sizeof(spectrum));
@@ -767,7 +758,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv,
767 758
768 if (iwl_is_associated(priv)) 759 if (iwl_is_associated(priv))
769 spectrum.start_time = 760 spectrum.start_time =
770 iwl3945_add_beacon_time(priv->last_beacon_time, 761 iwl3945_add_beacon_time(priv->_3945.last_beacon_time,
771 add_time, 762 add_time,
772 le16_to_cpu(priv->rxon_timing.beacon_interval)); 763 le16_to_cpu(priv->rxon_timing.beacon_interval));
773 else 764 else
@@ -2489,8 +2480,6 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2489 goto restart; 2480 goto restart;
2490 } 2481 }
2491 2482
2492 iwl_clear_stations_table(priv);
2493
2494 rfkill = iwl_read_prph(priv, APMG_RFKILL_REG); 2483 rfkill = iwl_read_prph(priv, APMG_RFKILL_REG);
2495 IWL_DEBUG_INFO(priv, "RFKILL status: 0x%x\n", rfkill); 2484 IWL_DEBUG_INFO(priv, "RFKILL status: 0x%x\n", rfkill);
2496 2485
@@ -2512,13 +2501,19 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2512 /* After the ALIVE response, we can send commands to 3945 uCode */ 2501 /* After the ALIVE response, we can send commands to 3945 uCode */
2513 set_bit(STATUS_ALIVE, &priv->status); 2502 set_bit(STATUS_ALIVE, &priv->status);
2514 2503
2504 if (priv->cfg->ops->lib->recover_from_tx_stall) {
2505 /* Enable timer to monitor the driver queues */
2506 mod_timer(&priv->monitor_recover,
2507 jiffies +
2508 msecs_to_jiffies(priv->cfg->monitor_recover_period));
2509 }
2510
2515 if (iwl_is_rfkill(priv)) 2511 if (iwl_is_rfkill(priv))
2516 return; 2512 return;
2517 2513
2518 ieee80211_wake_queues(priv->hw); 2514 ieee80211_wake_queues(priv->hw);
2519 2515
2520 priv->active_rate = priv->rates_mask; 2516 priv->active_rate = IWL_RATES_MASK;
2521 priv->active_rate_basic = priv->rates_mask & IWL_BASIC_RATES_MASK;
2522 2517
2523 iwl_power_update_mode(priv, true); 2518 iwl_power_update_mode(priv, true);
2524 2519
@@ -2547,17 +2542,6 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2547 set_bit(STATUS_READY, &priv->status); 2542 set_bit(STATUS_READY, &priv->status);
2548 wake_up_interruptible(&priv->wait_command_queue); 2543 wake_up_interruptible(&priv->wait_command_queue);
2549 2544
2550 /* reassociate for ADHOC mode */
2551 if (priv->vif && (priv->iw_mode == NL80211_IFTYPE_ADHOC)) {
2552 struct sk_buff *beacon = ieee80211_beacon_get(priv->hw,
2553 priv->vif);
2554 if (beacon)
2555 iwl_mac_beacon_update(priv->hw, beacon);
2556 }
2557
2558 if (test_and_clear_bit(STATUS_MODE_PENDING, &priv->status))
2559 iwl_set_mode(priv, priv->iw_mode);
2560
2561 return; 2545 return;
2562 2546
2563 restart: 2547 restart:
@@ -2579,7 +2563,8 @@ static void __iwl3945_down(struct iwl_priv *priv)
2579 if (!exit_pending) 2563 if (!exit_pending)
2580 set_bit(STATUS_EXIT_PENDING, &priv->status); 2564 set_bit(STATUS_EXIT_PENDING, &priv->status);
2581 2565
2582 iwl_clear_stations_table(priv); 2566 /* Station information will now be cleared in device */
2567 iwl_clear_ucode_stations(priv, true);
2583 2568
2584 /* Unblock any waiting calls */ 2569 /* Unblock any waiting calls */
2585 wake_up_interruptible_all(&priv->wait_command_queue); 2570 wake_up_interruptible_all(&priv->wait_command_queue);
@@ -2713,12 +2698,10 @@ static int __iwl3945_up(struct iwl_priv *priv)
2713 2698
2714 for (i = 0; i < MAX_HW_RESTARTS; i++) { 2699 for (i = 0; i < MAX_HW_RESTARTS; i++) {
2715 2700
2716 iwl_clear_stations_table(priv);
2717
2718 /* load bootstrap state machine, 2701 /* load bootstrap state machine,
2719 * load bootstrap program into processor's memory, 2702 * load bootstrap program into processor's memory,
2720 * prepare to load the "initialize" uCode */ 2703 * prepare to load the "initialize" uCode */
2721 priv->cfg->ops->lib->load_ucode(priv); 2704 rc = priv->cfg->ops->lib->load_ucode(priv);
2722 2705
2723 if (rc) { 2706 if (rc) {
2724 IWL_ERR(priv, 2707 IWL_ERR(priv,
@@ -2786,7 +2769,7 @@ static void iwl3945_bg_alive_start(struct work_struct *data)
2786static void iwl3945_rfkill_poll(struct work_struct *data) 2769static void iwl3945_rfkill_poll(struct work_struct *data)
2787{ 2770{
2788 struct iwl_priv *priv = 2771 struct iwl_priv *priv =
2789 container_of(data, struct iwl_priv, rfkill_poll.work); 2772 container_of(data, struct iwl_priv, _3945.rfkill_poll.work);
2790 bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &priv->status); 2773 bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &priv->status);
2791 bool new_rfkill = !(iwl_read32(priv, CSR_GP_CNTRL) 2774 bool new_rfkill = !(iwl_read32(priv, CSR_GP_CNTRL)
2792 & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); 2775 & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW);
@@ -2805,7 +2788,7 @@ static void iwl3945_rfkill_poll(struct work_struct *data)
2805 2788
2806 /* Keep this running, even if radio now enabled. This will be 2789 /* Keep this running, even if radio now enabled. This will be
2807 * cancelled in mac_start() if system decides to start again */ 2790 * cancelled in mac_start() if system decides to start again */
2808 queue_delayed_work(priv->workqueue, &priv->rfkill_poll, 2791 queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll,
2809 round_jiffies_relative(2 * HZ)); 2792 round_jiffies_relative(2 * HZ));
2810 2793
2811} 2794}
@@ -2820,7 +2803,6 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2820 .len = sizeof(struct iwl3945_scan_cmd), 2803 .len = sizeof(struct iwl3945_scan_cmd),
2821 .flags = CMD_SIZE_HUGE, 2804 .flags = CMD_SIZE_HUGE,
2822 }; 2805 };
2823 int rc = 0;
2824 struct iwl3945_scan_cmd *scan; 2806 struct iwl3945_scan_cmd *scan;
2825 struct ieee80211_conf *conf = NULL; 2807 struct ieee80211_conf *conf = NULL;
2826 u8 n_probes = 0; 2808 u8 n_probes = 0;
@@ -2848,7 +2830,6 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2848 if (test_bit(STATUS_SCAN_HW, &priv->status)) { 2830 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
2849 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests " 2831 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests "
2850 "Ignoring second request.\n"); 2832 "Ignoring second request.\n");
2851 rc = -EIO;
2852 goto done; 2833 goto done;
2853 } 2834 }
2854 2835
@@ -2883,7 +2864,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2883 priv->scan = kmalloc(sizeof(struct iwl3945_scan_cmd) + 2864 priv->scan = kmalloc(sizeof(struct iwl3945_scan_cmd) +
2884 IWL_MAX_SCAN_SIZE, GFP_KERNEL); 2865 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
2885 if (!priv->scan) { 2866 if (!priv->scan) {
2886 rc = -ENOMEM; 2867 IWL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n");
2887 goto done; 2868 goto done;
2888 } 2869 }
2889 } 2870 }
@@ -2926,7 +2907,9 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2926 scan_suspend_time, interval); 2907 scan_suspend_time, interval);
2927 } 2908 }
2928 2909
2929 if (priv->scan_request->n_ssids) { 2910 if (priv->is_internal_short_scan) {
2911 IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n");
2912 } else if (priv->scan_request->n_ssids) {
2930 int i, p = 0; 2913 int i, p = 0;
2931 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n"); 2914 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n");
2932 for (i = 0; i < priv->scan_request->n_ssids; i++) { 2915 for (i = 0; i < priv->scan_request->n_ssids; i++) {
@@ -2973,13 +2956,20 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
2973 goto done; 2956 goto done;
2974 } 2957 }
2975 2958
2976 scan->tx_cmd.len = cpu_to_le16( 2959 if (!priv->is_internal_short_scan) {
2960 scan->tx_cmd.len = cpu_to_le16(
2977 iwl_fill_probe_req(priv, 2961 iwl_fill_probe_req(priv,
2978 (struct ieee80211_mgmt *)scan->data, 2962 (struct ieee80211_mgmt *)scan->data,
2979 priv->scan_request->ie, 2963 priv->scan_request->ie,
2980 priv->scan_request->ie_len, 2964 priv->scan_request->ie_len,
2981 IWL_MAX_SCAN_SIZE - sizeof(*scan))); 2965 IWL_MAX_SCAN_SIZE - sizeof(*scan)));
2982 2966 } else {
2967 scan->tx_cmd.len = cpu_to_le16(
2968 iwl_fill_probe_req(priv,
2969 (struct ieee80211_mgmt *)scan->data,
2970 NULL, 0,
2971 IWL_MAX_SCAN_SIZE - sizeof(*scan)));
2972 }
2983 /* select Rx antennas */ 2973 /* select Rx antennas */
2984 scan->flags |= iwl3945_get_antenna_flags(priv); 2974 scan->flags |= iwl3945_get_antenna_flags(priv);
2985 2975
@@ -3001,8 +2991,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
3001 scan->len = cpu_to_le16(cmd.len); 2991 scan->len = cpu_to_le16(cmd.len);
3002 2992
3003 set_bit(STATUS_SCAN_HW, &priv->status); 2993 set_bit(STATUS_SCAN_HW, &priv->status);
3004 rc = iwl_send_cmd_sync(priv, &cmd); 2994 if (iwl_send_cmd_sync(priv, &cmd))
3005 if (rc)
3006 goto done; 2995 goto done;
3007 2996
3008 queue_delayed_work(priv->workqueue, &priv->scan_check, 2997 queue_delayed_work(priv->workqueue, &priv->scan_check,
@@ -3134,12 +3123,13 @@ void iwl3945_post_associate(struct iwl_priv *priv)
3134 case NL80211_IFTYPE_ADHOC: 3123 case NL80211_IFTYPE_ADHOC:
3135 3124
3136 priv->assoc_id = 1; 3125 priv->assoc_id = 1;
3137 iwl_add_station(priv, priv->bssid, 0, CMD_SYNC, NULL); 3126 iwl_add_local_station(priv, priv->bssid, false);
3138 iwl3945_sync_sta(priv, IWL_STA_ID, 3127 iwl3945_sync_sta(priv, IWL_STA_ID,
3139 (priv->band == IEEE80211_BAND_5GHZ) ? 3128 (priv->band == IEEE80211_BAND_5GHZ) ?
3140 IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP, 3129 IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP,
3141 CMD_ASYNC); 3130 CMD_ASYNC);
3142 iwl3945_rate_scale_init(priv->hw, IWL_STA_ID); 3131 iwl3945_rate_scale_init(priv->hw, IWL_STA_ID);
3132
3143 iwl3945_send_beacon_cmd(priv); 3133 iwl3945_send_beacon_cmd(priv);
3144 3134
3145 break; 3135 break;
@@ -3212,7 +3202,7 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw)
3212 3202
3213 /* ucode is running and will send rfkill notifications, 3203 /* ucode is running and will send rfkill notifications,
3214 * no need to poll the killswitch state anymore */ 3204 * no need to poll the killswitch state anymore */
3215 cancel_delayed_work(&priv->rfkill_poll); 3205 cancel_delayed_work(&priv->_3945.rfkill_poll);
3216 3206
3217 iwl_led_start(priv); 3207 iwl_led_start(priv);
3218 3208
@@ -3253,7 +3243,7 @@ static void iwl3945_mac_stop(struct ieee80211_hw *hw)
3253 flush_workqueue(priv->workqueue); 3243 flush_workqueue(priv->workqueue);
3254 3244
3255 /* start polling the killswitch state again */ 3245 /* start polling the killswitch state again */
3256 queue_delayed_work(priv->workqueue, &priv->rfkill_poll, 3246 queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll,
3257 round_jiffies_relative(2 * HZ)); 3247 round_jiffies_relative(2 * HZ));
3258 3248
3259 IWL_DEBUG_MAC80211(priv, "leave\n"); 3249 IWL_DEBUG_MAC80211(priv, "leave\n");
@@ -3324,7 +3314,7 @@ void iwl3945_config_ap(struct iwl_priv *priv)
3324 /* restore RXON assoc */ 3314 /* restore RXON assoc */
3325 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 3315 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
3326 iwlcore_commit_rxon(priv); 3316 iwlcore_commit_rxon(priv);
3327 iwl_add_station(priv, iwl_bcast_addr, 0, CMD_SYNC, NULL); 3317 iwl_add_local_station(priv, iwl_bcast_addr, false);
3328 } 3318 }
3329 iwl3945_send_beacon_cmd(priv); 3319 iwl3945_send_beacon_cmd(priv);
3330 3320
@@ -3365,7 +3355,6 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3365 3355
3366 mutex_lock(&priv->mutex); 3356 mutex_lock(&priv->mutex);
3367 iwl_scan_cancel_timeout(priv, 100); 3357 iwl_scan_cancel_timeout(priv, 100);
3368 mutex_unlock(&priv->mutex);
3369 3358
3370 switch (cmd) { 3359 switch (cmd) {
3371 case SET_KEY: 3360 case SET_KEY:
@@ -3386,11 +3375,44 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3386 ret = -EINVAL; 3375 ret = -EINVAL;
3387 } 3376 }
3388 3377
3378 mutex_unlock(&priv->mutex);
3389 IWL_DEBUG_MAC80211(priv, "leave\n"); 3379 IWL_DEBUG_MAC80211(priv, "leave\n");
3390 3380
3391 return ret; 3381 return ret;
3392} 3382}
3393 3383
3384static int iwl3945_mac_sta_add(struct ieee80211_hw *hw,
3385 struct ieee80211_vif *vif,
3386 struct ieee80211_sta *sta)
3387{
3388 struct iwl_priv *priv = hw->priv;
3389 int ret;
3390 bool is_ap = priv->iw_mode == NL80211_IFTYPE_STATION;
3391 u8 sta_id;
3392
3393 IWL_DEBUG_INFO(priv, "received request to add station %pM\n",
3394 sta->addr);
3395
3396 ret = iwl_add_station_common(priv, sta->addr, is_ap, &sta->ht_cap,
3397 &sta_id);
3398 if (ret) {
3399 IWL_ERR(priv, "Unable to add station %pM (%d)\n",
3400 sta->addr, ret);
3401 /* Should we return success if return code is EEXIST ? */
3402 return ret;
3403 }
3404
3405 /* Initialize rate scaling */
3406 IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM \n",
3407 sta->addr);
3408 iwl3945_rs_rate_init(priv, sta, sta_id);
3409
3410 return 0;
3411
3412
3413
3414 return ret;
3415}
3394/***************************************************************************** 3416/*****************************************************************************
3395 * 3417 *
3396 * sysfs attributes 3418 * sysfs attributes
@@ -3590,7 +3612,7 @@ static ssize_t store_measurement(struct device *d,
3590 struct iwl_priv *priv = dev_get_drvdata(d); 3612 struct iwl_priv *priv = dev_get_drvdata(d);
3591 struct ieee80211_measurement_params params = { 3613 struct ieee80211_measurement_params params = {
3592 .channel = le16_to_cpu(priv->active_rxon.channel), 3614 .channel = le16_to_cpu(priv->active_rxon.channel),
3593 .start_time = cpu_to_le64(priv->last_tsf), 3615 .start_time = cpu_to_le64(priv->_3945.last_tsf),
3594 .duration = cpu_to_le16(1), 3616 .duration = cpu_to_le16(1),
3595 }; 3617 };
3596 u8 type = IWL_MEASURE_BASIC; 3618 u8 type = IWL_MEASURE_BASIC;
@@ -3660,7 +3682,7 @@ static ssize_t show_statistics(struct device *d,
3660 struct iwl_priv *priv = dev_get_drvdata(d); 3682 struct iwl_priv *priv = dev_get_drvdata(d);
3661 u32 size = sizeof(struct iwl3945_notif_statistics); 3683 u32 size = sizeof(struct iwl3945_notif_statistics);
3662 u32 len = 0, ofs = 0; 3684 u32 len = 0, ofs = 0;
3663 u8 *data = (u8 *)&priv->statistics_39; 3685 u8 *data = (u8 *)&priv->_3945.statistics;
3664 int rc = 0; 3686 int rc = 0;
3665 3687
3666 if (!iwl_is_alive(priv)) 3688 if (!iwl_is_alive(priv))
@@ -3773,7 +3795,7 @@ static void iwl3945_setup_deferred_work(struct iwl_priv *priv)
3773 INIT_WORK(&priv->beacon_update, iwl3945_bg_beacon_update); 3795 INIT_WORK(&priv->beacon_update, iwl3945_bg_beacon_update);
3774 INIT_DELAYED_WORK(&priv->init_alive_start, iwl3945_bg_init_alive_start); 3796 INIT_DELAYED_WORK(&priv->init_alive_start, iwl3945_bg_init_alive_start);
3775 INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start); 3797 INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start);
3776 INIT_DELAYED_WORK(&priv->rfkill_poll, iwl3945_rfkill_poll); 3798 INIT_DELAYED_WORK(&priv->_3945.rfkill_poll, iwl3945_rfkill_poll);
3777 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); 3799 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed);
3778 INIT_WORK(&priv->request_scan, iwl3945_bg_request_scan); 3800 INIT_WORK(&priv->request_scan, iwl3945_bg_request_scan);
3779 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan); 3801 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan);
@@ -3781,6 +3803,13 @@ static void iwl3945_setup_deferred_work(struct iwl_priv *priv)
3781 3803
3782 iwl3945_hw_setup_deferred_work(priv); 3804 iwl3945_hw_setup_deferred_work(priv);
3783 3805
3806 if (priv->cfg->ops->lib->recover_from_tx_stall) {
3807 init_timer(&priv->monitor_recover);
3808 priv->monitor_recover.data = (unsigned long)priv;
3809 priv->monitor_recover.function =
3810 priv->cfg->ops->lib->recover_from_tx_stall;
3811 }
3812
3784 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 3813 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
3785 iwl3945_irq_tasklet, (unsigned long)priv); 3814 iwl3945_irq_tasklet, (unsigned long)priv);
3786} 3815}
@@ -3793,6 +3822,8 @@ static void iwl3945_cancel_deferred_work(struct iwl_priv *priv)
3793 cancel_delayed_work(&priv->scan_check); 3822 cancel_delayed_work(&priv->scan_check);
3794 cancel_delayed_work(&priv->alive_start); 3823 cancel_delayed_work(&priv->alive_start);
3795 cancel_work_sync(&priv->beacon_update); 3824 cancel_work_sync(&priv->beacon_update);
3825 if (priv->cfg->ops->lib->recover_from_tx_stall)
3826 del_timer_sync(&priv->monitor_recover);
3796} 3827}
3797 3828
3798static struct attribute *iwl3945_sysfs_entries[] = { 3829static struct attribute *iwl3945_sysfs_entries[] = {
@@ -3830,7 +3861,9 @@ static struct ieee80211_ops iwl3945_hw_ops = {
3830 .conf_tx = iwl_mac_conf_tx, 3861 .conf_tx = iwl_mac_conf_tx,
3831 .reset_tsf = iwl_mac_reset_tsf, 3862 .reset_tsf = iwl_mac_reset_tsf,
3832 .bss_info_changed = iwl_bss_info_changed, 3863 .bss_info_changed = iwl_bss_info_changed,
3833 .hw_scan = iwl_mac_hw_scan 3864 .hw_scan = iwl_mac_hw_scan,
3865 .sta_add = iwl3945_mac_sta_add,
3866 .sta_remove = iwl_mac_sta_remove,
3834}; 3867};
3835 3868
3836static int iwl3945_init_drv(struct iwl_priv *priv) 3869static int iwl3945_init_drv(struct iwl_priv *priv)
@@ -3849,9 +3882,6 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
3849 mutex_init(&priv->mutex); 3882 mutex_init(&priv->mutex);
3850 mutex_init(&priv->sync_cmd_mutex); 3883 mutex_init(&priv->sync_cmd_mutex);
3851 3884
3852 /* Clear the driver's (not device's) station table */
3853 iwl_clear_stations_table(priv);
3854
3855 priv->ieee_channels = NULL; 3885 priv->ieee_channels = NULL;
3856 priv->ieee_rates = NULL; 3886 priv->ieee_rates = NULL;
3857 priv->band = IEEE80211_BAND_2GHZ; 3887 priv->band = IEEE80211_BAND_2GHZ;
@@ -3864,7 +3894,6 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
3864 priv->qos_data.qos_active = 0; 3894 priv->qos_data.qos_active = 0;
3865 priv->qos_data.qos_cap.val = 0; 3895 priv->qos_data.qos_cap.val = 0;
3866 3896
3867 priv->rates_mask = IWL_RATES_MASK;
3868 priv->tx_power_user_lmt = IWL_DEFAULT_TX_POWER; 3897 priv->tx_power_user_lmt = IWL_DEFAULT_TX_POWER;
3869 3898
3870 if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { 3899 if (eeprom->version < EEPROM_3945_EEPROM_VERSION) {
@@ -4129,7 +4158,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
4129 IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); 4158 IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err);
4130 4159
4131 /* Start monitoring the killswitch */ 4160 /* Start monitoring the killswitch */
4132 queue_delayed_work(priv->workqueue, &priv->rfkill_poll, 4161 queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll,
4133 2 * HZ); 4162 2 * HZ);
4134 4163
4135 return 0; 4164 return 0;
@@ -4203,7 +4232,7 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
4203 4232
4204 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); 4233 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group);
4205 4234
4206 cancel_delayed_work_sync(&priv->rfkill_poll); 4235 cancel_delayed_work_sync(&priv->_3945.rfkill_poll);
4207 4236
4208 iwl3945_dealloc_ucode_pci(priv); 4237 iwl3945_dealloc_ucode_pci(priv);
4209 4238
@@ -4212,7 +4241,6 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
4212 iwl3945_hw_txq_ctx_free(priv); 4241 iwl3945_hw_txq_ctx_free(priv);
4213 4242
4214 iwl3945_unset_hw_params(priv); 4243 iwl3945_unset_hw_params(priv);
4215 iwl_clear_stations_table(priv);
4216 4244
4217 /*netif_stop_queue(dev); */ 4245 /*netif_stop_queue(dev); */
4218 flush_workqueue(priv->workqueue); 4246 flush_workqueue(priv->workqueue);
diff --git a/drivers/net/wireless/iwmc3200wifi/Kconfig b/drivers/net/wireless/iwmc3200wifi/Kconfig
index b9d34a766964..03f998d098c5 100644
--- a/drivers/net/wireless/iwmc3200wifi/Kconfig
+++ b/drivers/net/wireless/iwmc3200wifi/Kconfig
@@ -17,7 +17,7 @@ config IWM
17config IWM_DEBUG 17config IWM_DEBUG
18 bool "Enable full debugging output in iwmc3200wifi" 18 bool "Enable full debugging output in iwmc3200wifi"
19 depends on IWM && DEBUG_FS 19 depends on IWM && DEBUG_FS
20 ---help--- 20 help
21 This option will enable debug tracing and setting for iwm 21 This option will enable debug tracing and setting for iwm
22 22
23 You can set the debug level and module through debugfs. By 23 You can set the debug level and module through debugfs. By
@@ -30,3 +30,10 @@ config IWM_DEBUG
30 Or, if you want the full debug, for all modules: 30 Or, if you want the full debug, for all modules:
31 echo 0xff > /sys/kernel/debug/iwm/phyN/debug/level 31 echo 0xff > /sys/kernel/debug/iwm/phyN/debug/level
32 echo 0xff > /sys/kernel/debug/iwm/phyN/debug/modules 32 echo 0xff > /sys/kernel/debug/iwm/phyN/debug/modules
33
34config IWM_TRACING
35 bool "Enable event tracing for iwmc3200wifi"
36 depends on IWM && EVENT_TRACING
37 help
38 Say Y here to trace all the commands and responses between
39 the driver and firmware (including TX/RX frames) with ftrace.
diff --git a/drivers/net/wireless/iwmc3200wifi/Makefile b/drivers/net/wireless/iwmc3200wifi/Makefile
index d34291b652d3..aeed5cd80819 100644
--- a/drivers/net/wireless/iwmc3200wifi/Makefile
+++ b/drivers/net/wireless/iwmc3200wifi/Makefile
@@ -3,3 +3,6 @@ iwmc3200wifi-objs += main.o netdev.o rx.o tx.o sdio.o hal.o fw.o
3iwmc3200wifi-objs += commands.o cfg80211.o eeprom.o 3iwmc3200wifi-objs += commands.o cfg80211.o eeprom.o
4 4
5iwmc3200wifi-$(CONFIG_IWM_DEBUG) += debugfs.o 5iwmc3200wifi-$(CONFIG_IWM_DEBUG) += debugfs.o
6iwmc3200wifi-$(CONFIG_IWM_TRACING) += trace.o
7
8CFLAGS_trace.o := -I$(src)
diff --git a/drivers/net/wireless/iwmc3200wifi/cfg80211.c b/drivers/net/wireless/iwmc3200wifi/cfg80211.c
index 7c4f44a9c3e6..fc239a32cb6b 100644
--- a/drivers/net/wireless/iwmc3200wifi/cfg80211.c
+++ b/drivers/net/wireless/iwmc3200wifi/cfg80211.c
@@ -263,7 +263,7 @@ static int iwm_cfg80211_get_station(struct wiphy *wiphy,
263int iwm_cfg80211_inform_bss(struct iwm_priv *iwm) 263int iwm_cfg80211_inform_bss(struct iwm_priv *iwm)
264{ 264{
265 struct wiphy *wiphy = iwm_to_wiphy(iwm); 265 struct wiphy *wiphy = iwm_to_wiphy(iwm);
266 struct iwm_bss_info *bss, *next; 266 struct iwm_bss_info *bss;
267 struct iwm_umac_notif_bss_info *umac_bss; 267 struct iwm_umac_notif_bss_info *umac_bss;
268 struct ieee80211_mgmt *mgmt; 268 struct ieee80211_mgmt *mgmt;
269 struct ieee80211_channel *channel; 269 struct ieee80211_channel *channel;
@@ -271,7 +271,7 @@ int iwm_cfg80211_inform_bss(struct iwm_priv *iwm)
271 s32 signal; 271 s32 signal;
272 int freq; 272 int freq;
273 273
274 list_for_each_entry_safe(bss, next, &iwm->bss_list, node) { 274 list_for_each_entry(bss, &iwm->bss_list, node) {
275 umac_bss = bss->bss; 275 umac_bss = bss->bss;
276 mgmt = (struct ieee80211_mgmt *)(umac_bss->frame_buf); 276 mgmt = (struct ieee80211_mgmt *)(umac_bss->frame_buf);
277 277
@@ -725,23 +725,26 @@ static int iwm_cfg80211_set_power_mgmt(struct wiphy *wiphy,
725 CFG_POWER_INDEX, iwm->conf.power_index); 725 CFG_POWER_INDEX, iwm->conf.power_index);
726} 726}
727 727
728int iwm_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *netdev, 728static int iwm_cfg80211_set_pmksa(struct wiphy *wiphy,
729 struct cfg80211_pmksa *pmksa) 729 struct net_device *netdev,
730 struct cfg80211_pmksa *pmksa)
730{ 731{
731 struct iwm_priv *iwm = wiphy_to_iwm(wiphy); 732 struct iwm_priv *iwm = wiphy_to_iwm(wiphy);
732 733
733 return iwm_send_pmkid_update(iwm, pmksa, IWM_CMD_PMKID_ADD); 734 return iwm_send_pmkid_update(iwm, pmksa, IWM_CMD_PMKID_ADD);
734} 735}
735 736
736int iwm_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *netdev, 737static int iwm_cfg80211_del_pmksa(struct wiphy *wiphy,
737 struct cfg80211_pmksa *pmksa) 738 struct net_device *netdev,
739 struct cfg80211_pmksa *pmksa)
738{ 740{
739 struct iwm_priv *iwm = wiphy_to_iwm(wiphy); 741 struct iwm_priv *iwm = wiphy_to_iwm(wiphy);
740 742
741 return iwm_send_pmkid_update(iwm, pmksa, IWM_CMD_PMKID_DEL); 743 return iwm_send_pmkid_update(iwm, pmksa, IWM_CMD_PMKID_DEL);
742} 744}
743 745
744int iwm_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) 746static int iwm_cfg80211_flush_pmksa(struct wiphy *wiphy,
747 struct net_device *netdev)
745{ 748{
746 struct iwm_priv *iwm = wiphy_to_iwm(wiphy); 749 struct iwm_priv *iwm = wiphy_to_iwm(wiphy);
747 struct cfg80211_pmksa pmksa; 750 struct cfg80211_pmksa pmksa;
diff --git a/drivers/net/wireless/iwmc3200wifi/commands.c b/drivers/net/wireless/iwmc3200wifi/commands.c
index 1e41ad0fcad5..b5cbd2bfd52a 100644
--- a/drivers/net/wireless/iwmc3200wifi/commands.c
+++ b/drivers/net/wireless/iwmc3200wifi/commands.c
@@ -506,7 +506,7 @@ static int iwm_target_read(struct iwm_priv *iwm, __le32 address,
506 return ret; 506 return ret;
507 } 507 }
508 508
509 /* When succeding, the send_target routine returns the seq number */ 509 /* When succeeding, the send_target routine returns the seq number */
510 seq_num = ret; 510 seq_num = ret;
511 511
512 ret = wait_event_interruptible_timeout(iwm->nonwifi_queue, 512 ret = wait_event_interruptible_timeout(iwm->nonwifi_queue,
@@ -781,10 +781,9 @@ int iwm_send_mlme_profile(struct iwm_priv *iwm)
781 return 0; 781 return 0;
782} 782}
783 783
784int iwm_invalidate_mlme_profile(struct iwm_priv *iwm) 784int __iwm_invalidate_mlme_profile(struct iwm_priv *iwm)
785{ 785{
786 struct iwm_umac_invalidate_profile invalid; 786 struct iwm_umac_invalidate_profile invalid;
787 int ret;
788 787
789 invalid.hdr.oid = UMAC_WIFI_IF_CMD_INVALIDATE_PROFILE; 788 invalid.hdr.oid = UMAC_WIFI_IF_CMD_INVALIDATE_PROFILE;
790 invalid.hdr.buf_size = 789 invalid.hdr.buf_size =
@@ -793,7 +792,14 @@ int iwm_invalidate_mlme_profile(struct iwm_priv *iwm)
793 792
794 invalid.reason = WLAN_REASON_UNSPECIFIED; 793 invalid.reason = WLAN_REASON_UNSPECIFIED;
795 794
796 ret = iwm_send_wifi_if_cmd(iwm, &invalid, sizeof(invalid), 1); 795 return iwm_send_wifi_if_cmd(iwm, &invalid, sizeof(invalid), 1);
796}
797
798int iwm_invalidate_mlme_profile(struct iwm_priv *iwm)
799{
800 int ret;
801
802 ret = __iwm_invalidate_mlme_profile(iwm);
797 if (ret) 803 if (ret)
798 return ret; 804 return ret;
799 805
diff --git a/drivers/net/wireless/iwmc3200wifi/commands.h b/drivers/net/wireless/iwmc3200wifi/commands.h
index 3dfd9f0e9003..7e16bcf59978 100644
--- a/drivers/net/wireless/iwmc3200wifi/commands.h
+++ b/drivers/net/wireless/iwmc3200wifi/commands.h
@@ -488,6 +488,7 @@ int iwm_umac_set_config_var(struct iwm_priv *iwm, u16 key,
488 void *payload, u16 payload_size); 488 void *payload, u16 payload_size);
489int iwm_send_umac_config(struct iwm_priv *iwm, __le32 reset_flags); 489int iwm_send_umac_config(struct iwm_priv *iwm, __le32 reset_flags);
490int iwm_send_mlme_profile(struct iwm_priv *iwm); 490int iwm_send_mlme_profile(struct iwm_priv *iwm);
491int __iwm_invalidate_mlme_profile(struct iwm_priv *iwm);
491int iwm_invalidate_mlme_profile(struct iwm_priv *iwm); 492int iwm_invalidate_mlme_profile(struct iwm_priv *iwm);
492int iwm_send_packet(struct iwm_priv *iwm, struct sk_buff *skb, int pool_id); 493int iwm_send_packet(struct iwm_priv *iwm, struct sk_buff *skb, int pool_id);
493int iwm_set_tx_key(struct iwm_priv *iwm, u8 key_idx); 494int iwm_set_tx_key(struct iwm_priv *iwm, u8 key_idx);
diff --git a/drivers/net/wireless/iwmc3200wifi/debugfs.c b/drivers/net/wireless/iwmc3200wifi/debugfs.c
index c29c994de0e2..5b75a0ddac1c 100644
--- a/drivers/net/wireless/iwmc3200wifi/debugfs.c
+++ b/drivers/net/wireless/iwmc3200wifi/debugfs.c
@@ -265,7 +265,7 @@ static ssize_t iwm_debugfs_rx_ticket_read(struct file *filp,
265 size_t count, loff_t *ppos) 265 size_t count, loff_t *ppos)
266{ 266{
267 struct iwm_priv *iwm = filp->private_data; 267 struct iwm_priv *iwm = filp->private_data;
268 struct iwm_rx_ticket_node *ticket, *next; 268 struct iwm_rx_ticket_node *ticket;
269 char *buf; 269 char *buf;
270 int buf_len = 4096, i; 270 int buf_len = 4096, i;
271 size_t len = 0; 271 size_t len = 0;
@@ -280,7 +280,8 @@ static ssize_t iwm_debugfs_rx_ticket_read(struct file *filp,
280 if (!buf) 280 if (!buf)
281 return -ENOMEM; 281 return -ENOMEM;
282 282
283 list_for_each_entry_safe(ticket, next, &iwm->rx_tickets, node) { 283 spin_lock(&iwm->ticket_lock);
284 list_for_each_entry(ticket, &iwm->rx_tickets, node) {
284 len += snprintf(buf + len, buf_len - len, "Ticket #%d\n", 285 len += snprintf(buf + len, buf_len - len, "Ticket #%d\n",
285 ticket->ticket->id); 286 ticket->ticket->id);
286 len += snprintf(buf + len, buf_len - len, "\taction: 0x%x\n", 287 len += snprintf(buf + len, buf_len - len, "\taction: 0x%x\n",
@@ -288,14 +289,17 @@ static ssize_t iwm_debugfs_rx_ticket_read(struct file *filp,
288 len += snprintf(buf + len, buf_len - len, "\tflags: 0x%x\n", 289 len += snprintf(buf + len, buf_len - len, "\tflags: 0x%x\n",
289 ticket->ticket->flags); 290 ticket->ticket->flags);
290 } 291 }
292 spin_unlock(&iwm->ticket_lock);
291 293
292 for (i = 0; i < IWM_RX_ID_HASH; i++) { 294 for (i = 0; i < IWM_RX_ID_HASH; i++) {
293 struct iwm_rx_packet *packet, *nxt; 295 struct iwm_rx_packet *packet;
294 struct list_head *pkt_list = &iwm->rx_packets[i]; 296 struct list_head *pkt_list = &iwm->rx_packets[i];
297
295 if (!list_empty(pkt_list)) { 298 if (!list_empty(pkt_list)) {
296 len += snprintf(buf + len, buf_len - len, 299 len += snprintf(buf + len, buf_len - len,
297 "Packet hash #%d\n", i); 300 "Packet hash #%d\n", i);
298 list_for_each_entry_safe(packet, nxt, pkt_list, node) { 301 spin_lock(&iwm->packet_lock[i]);
302 list_for_each_entry(packet, pkt_list, node) {
299 len += snprintf(buf + len, buf_len - len, 303 len += snprintf(buf + len, buf_len - len,
300 "\tPacket id: %d\n", 304 "\tPacket id: %d\n",
301 packet->id); 305 packet->id);
@@ -303,6 +307,7 @@ static ssize_t iwm_debugfs_rx_ticket_read(struct file *filp,
303 "\tPacket length: %lu\n", 307 "\tPacket length: %lu\n",
304 packet->pkt_size); 308 packet->pkt_size);
305 } 309 }
310 spin_unlock(&iwm->packet_lock[i]);
306 } 311 }
307 } 312 }
308 313
diff --git a/drivers/net/wireless/iwmc3200wifi/hal.c b/drivers/net/wireless/iwmc3200wifi/hal.c
index d13c8853ee82..373b5b5001d2 100644
--- a/drivers/net/wireless/iwmc3200wifi/hal.c
+++ b/drivers/net/wireless/iwmc3200wifi/hal.c
@@ -104,6 +104,7 @@
104#include "hal.h" 104#include "hal.h"
105#include "umac.h" 105#include "umac.h"
106#include "debug.h" 106#include "debug.h"
107#include "trace.h"
107 108
108static int iwm_nonwifi_cmd_init(struct iwm_priv *iwm, 109static int iwm_nonwifi_cmd_init(struct iwm_priv *iwm,
109 struct iwm_nonwifi_cmd *cmd, 110 struct iwm_nonwifi_cmd *cmd,
@@ -206,9 +207,9 @@ void iwm_cmd_flush(struct iwm_priv *iwm)
206 207
207struct iwm_wifi_cmd *iwm_get_pending_wifi_cmd(struct iwm_priv *iwm, u16 seq_num) 208struct iwm_wifi_cmd *iwm_get_pending_wifi_cmd(struct iwm_priv *iwm, u16 seq_num)
208{ 209{
209 struct iwm_wifi_cmd *cmd, *next; 210 struct iwm_wifi_cmd *cmd;
210 211
211 list_for_each_entry_safe(cmd, next, &iwm->wifi_pending_cmd, pending) 212 list_for_each_entry(cmd, &iwm->wifi_pending_cmd, pending)
212 if (cmd->seq_num == seq_num) { 213 if (cmd->seq_num == seq_num) {
213 list_del(&cmd->pending); 214 list_del(&cmd->pending);
214 return cmd; 215 return cmd;
@@ -217,12 +218,12 @@ struct iwm_wifi_cmd *iwm_get_pending_wifi_cmd(struct iwm_priv *iwm, u16 seq_num)
217 return NULL; 218 return NULL;
218} 219}
219 220
220struct iwm_nonwifi_cmd * 221struct iwm_nonwifi_cmd *iwm_get_pending_nonwifi_cmd(struct iwm_priv *iwm,
221iwm_get_pending_nonwifi_cmd(struct iwm_priv *iwm, u8 seq_num, u8 cmd_opcode) 222 u8 seq_num, u8 cmd_opcode)
222{ 223{
223 struct iwm_nonwifi_cmd *cmd, *next; 224 struct iwm_nonwifi_cmd *cmd;
224 225
225 list_for_each_entry_safe(cmd, next, &iwm->nonwifi_pending_cmd, pending) 226 list_for_each_entry(cmd, &iwm->nonwifi_pending_cmd, pending)
226 if ((cmd->seq_num == seq_num) && 227 if ((cmd->seq_num == seq_num) &&
227 (cmd->udma_cmd.opcode == cmd_opcode) && 228 (cmd->udma_cmd.opcode == cmd_opcode) &&
228 (cmd->resp_received)) { 229 (cmd->resp_received)) {
@@ -276,6 +277,7 @@ static int iwm_send_udma_nonwifi_cmd(struct iwm_priv *iwm,
276 udma_cmd->handle_by_hw, cmd->seq_num, udma_cmd->addr, 277 udma_cmd->handle_by_hw, cmd->seq_num, udma_cmd->addr,
277 udma_cmd->op1_sz, udma_cmd->op2); 278 udma_cmd->op1_sz, udma_cmd->op2);
278 279
280 trace_iwm_tx_nonwifi_cmd(iwm, udma_hdr);
279 return iwm_bus_send_chunk(iwm, buf->start, buf->len); 281 return iwm_bus_send_chunk(iwm, buf->start, buf->len);
280} 282}
281 283
@@ -362,6 +364,7 @@ static int iwm_send_udma_wifi_cmd(struct iwm_priv *iwm,
362 return ret; 364 return ret;
363 } 365 }
364 366
367 trace_iwm_tx_wifi_cmd(iwm, umac_hdr);
365 return iwm_bus_send_chunk(iwm, buf->start, buf->len); 368 return iwm_bus_send_chunk(iwm, buf->start, buf->len);
366} 369}
367 370
diff --git a/drivers/net/wireless/iwmc3200wifi/hal.h b/drivers/net/wireless/iwmc3200wifi/hal.h
index 0adfdc85765d..c20936d9b6b7 100644
--- a/drivers/net/wireless/iwmc3200wifi/hal.h
+++ b/drivers/net/wireless/iwmc3200wifi/hal.h
@@ -75,7 +75,8 @@ do { \
75 75
76 76
77/* UDMA IN OP CODE -- cmd bits [3:0] */ 77/* UDMA IN OP CODE -- cmd bits [3:0] */
78#define UDMA_IN_OPCODE_MASK 0xF 78#define UDMA_HDI_IN_NW_CMD_OPCODE_POS 0
79#define UDMA_HDI_IN_NW_CMD_OPCODE_SEED 0xF
79 80
80#define UDMA_IN_OPCODE_GENERAL_RESP 0x0 81#define UDMA_IN_OPCODE_GENERAL_RESP 0x0
81#define UDMA_IN_OPCODE_READ_RESP 0x1 82#define UDMA_IN_OPCODE_READ_RESP 0x1
@@ -130,7 +131,7 @@ do { \
130#define IWM_MAX_WIFI_CMD_BUFF_SIZE (IWM_SDIO_FW_MAX_CHUNK_SIZE - \ 131#define IWM_MAX_WIFI_CMD_BUFF_SIZE (IWM_SDIO_FW_MAX_CHUNK_SIZE - \
131 IWM_MAX_WIFI_HEADERS_SIZE) 132 IWM_MAX_WIFI_HEADERS_SIZE)
132 133
133#define IWM_HAL_CONCATENATE_BUF_SIZE 8192 134#define IWM_HAL_CONCATENATE_BUF_SIZE (32 * 1024)
134 135
135struct iwm_wifi_cmd_buff { 136struct iwm_wifi_cmd_buff {
136 u16 len; 137 u16 len;
diff --git a/drivers/net/wireless/iwmc3200wifi/iwm.h b/drivers/net/wireless/iwmc3200wifi/iwm.h
index 79ffa3b98d73..13266c3842f8 100644
--- a/drivers/net/wireless/iwmc3200wifi/iwm.h
+++ b/drivers/net/wireless/iwmc3200wifi/iwm.h
@@ -48,6 +48,7 @@
48#include "umac.h" 48#include "umac.h"
49#include "lmac.h" 49#include "lmac.h"
50#include "eeprom.h" 50#include "eeprom.h"
51#include "trace.h"
51 52
52#define IWM_COPYRIGHT "Copyright(c) 2009 Intel Corporation" 53#define IWM_COPYRIGHT "Copyright(c) 2009 Intel Corporation"
53#define IWM_AUTHOR "<ilw@linux.intel.com>" 54#define IWM_AUTHOR "<ilw@linux.intel.com>"
@@ -268,7 +269,9 @@ struct iwm_priv {
268 269
269 struct sk_buff_head rx_list; 270 struct sk_buff_head rx_list;
270 struct list_head rx_tickets; 271 struct list_head rx_tickets;
272 spinlock_t ticket_lock;
271 struct list_head rx_packets[IWM_RX_ID_HASH]; 273 struct list_head rx_packets[IWM_RX_ID_HASH];
274 spinlock_t packet_lock[IWM_RX_ID_HASH];
272 struct workqueue_struct *rx_wq; 275 struct workqueue_struct *rx_wq;
273 struct work_struct rx_worker; 276 struct work_struct rx_worker;
274 277
diff --git a/drivers/net/wireless/iwmc3200wifi/main.c b/drivers/net/wireless/iwmc3200wifi/main.c
index 7f34d6dd3c41..3a3510a6223a 100644
--- a/drivers/net/wireless/iwmc3200wifi/main.c
+++ b/drivers/net/wireless/iwmc3200wifi/main.c
@@ -276,8 +276,11 @@ int iwm_priv_init(struct iwm_priv *iwm)
276 276
277 skb_queue_head_init(&iwm->rx_list); 277 skb_queue_head_init(&iwm->rx_list);
278 INIT_LIST_HEAD(&iwm->rx_tickets); 278 INIT_LIST_HEAD(&iwm->rx_tickets);
279 for (i = 0; i < IWM_RX_ID_HASH; i++) 279 spin_lock_init(&iwm->ticket_lock);
280 for (i = 0; i < IWM_RX_ID_HASH; i++) {
280 INIT_LIST_HEAD(&iwm->rx_packets[i]); 281 INIT_LIST_HEAD(&iwm->rx_packets[i]);
282 spin_lock_init(&iwm->packet_lock[i]);
283 }
281 284
282 INIT_WORK(&iwm->rx_worker, iwm_rx_worker); 285 INIT_WORK(&iwm->rx_worker, iwm_rx_worker);
283 286
@@ -423,9 +426,9 @@ int iwm_notif_send(struct iwm_priv *iwm, struct iwm_wifi_cmd *cmd,
423static struct iwm_notif *iwm_notif_find(struct iwm_priv *iwm, u32 cmd, 426static struct iwm_notif *iwm_notif_find(struct iwm_priv *iwm, u32 cmd,
424 u8 source) 427 u8 source)
425{ 428{
426 struct iwm_notif *notif, *next; 429 struct iwm_notif *notif;
427 430
428 list_for_each_entry_safe(notif, next, &iwm->pending_notif, pending) { 431 list_for_each_entry(notif, &iwm->pending_notif, pending) {
429 if ((notif->cmd_id == cmd) && (notif->src == source)) { 432 if ((notif->cmd_id == cmd) && (notif->src == source)) {
430 list_del(&notif->pending); 433 list_del(&notif->pending);
431 return notif; 434 return notif;
diff --git a/drivers/net/wireless/iwmc3200wifi/rx.c b/drivers/net/wireless/iwmc3200wifi/rx.c
index 8456b4dbd146..ce36baf34039 100644
--- a/drivers/net/wireless/iwmc3200wifi/rx.c
+++ b/drivers/net/wireless/iwmc3200wifi/rx.c
@@ -342,15 +342,17 @@ static void iwm_rx_ticket_node_free(struct iwm_rx_ticket_node *ticket_node)
342static struct iwm_rx_packet *iwm_rx_packet_get(struct iwm_priv *iwm, u16 id) 342static struct iwm_rx_packet *iwm_rx_packet_get(struct iwm_priv *iwm, u16 id)
343{ 343{
344 u8 id_hash = IWM_RX_ID_GET_HASH(id); 344 u8 id_hash = IWM_RX_ID_GET_HASH(id);
345 struct list_head *packet_list; 345 struct iwm_rx_packet *packet;
346 struct iwm_rx_packet *packet, *next;
347
348 packet_list = &iwm->rx_packets[id_hash];
349 346
350 list_for_each_entry_safe(packet, next, packet_list, node) 347 spin_lock(&iwm->packet_lock[id_hash]);
351 if (packet->id == id) 348 list_for_each_entry(packet, &iwm->rx_packets[id_hash], node)
349 if (packet->id == id) {
350 list_del(&packet->node);
351 spin_unlock(&iwm->packet_lock[id_hash]);
352 return packet; 352 return packet;
353 }
353 354
355 spin_unlock(&iwm->packet_lock[id_hash]);
354 return NULL; 356 return NULL;
355} 357}
356 358
@@ -388,18 +390,22 @@ void iwm_rx_free(struct iwm_priv *iwm)
388 struct iwm_rx_packet *packet, *np; 390 struct iwm_rx_packet *packet, *np;
389 int i; 391 int i;
390 392
393 spin_lock(&iwm->ticket_lock);
391 list_for_each_entry_safe(ticket, nt, &iwm->rx_tickets, node) { 394 list_for_each_entry_safe(ticket, nt, &iwm->rx_tickets, node) {
392 list_del(&ticket->node); 395 list_del(&ticket->node);
393 iwm_rx_ticket_node_free(ticket); 396 iwm_rx_ticket_node_free(ticket);
394 } 397 }
398 spin_unlock(&iwm->ticket_lock);
395 399
396 for (i = 0; i < IWM_RX_ID_HASH; i++) { 400 for (i = 0; i < IWM_RX_ID_HASH; i++) {
401 spin_lock(&iwm->packet_lock[i]);
397 list_for_each_entry_safe(packet, np, &iwm->rx_packets[i], 402 list_for_each_entry_safe(packet, np, &iwm->rx_packets[i],
398 node) { 403 node) {
399 list_del(&packet->node); 404 list_del(&packet->node);
400 kfree_skb(packet->skb); 405 kfree_skb(packet->skb);
401 kfree(packet); 406 kfree(packet);
402 } 407 }
408 spin_unlock(&iwm->packet_lock[i]);
403 } 409 }
404} 410}
405 411
@@ -427,7 +433,9 @@ static int iwm_ntf_rx_ticket(struct iwm_priv *iwm, u8 *buf,
427 ticket->action == IWM_RX_TICKET_RELEASE ? 433 ticket->action == IWM_RX_TICKET_RELEASE ?
428 "RELEASE" : "DROP", 434 "RELEASE" : "DROP",
429 ticket->id); 435 ticket->id);
436 spin_lock(&iwm->ticket_lock);
430 list_add_tail(&ticket_node->node, &iwm->rx_tickets); 437 list_add_tail(&ticket_node->node, &iwm->rx_tickets);
438 spin_unlock(&iwm->ticket_lock);
431 439
432 /* 440 /*
433 * We received an Rx ticket, most likely there's 441 * We received an Rx ticket, most likely there's
@@ -460,6 +468,7 @@ static int iwm_ntf_rx_packet(struct iwm_priv *iwm, u8 *buf,
460 struct iwm_rx_packet *packet; 468 struct iwm_rx_packet *packet;
461 u16 id, buf_offset; 469 u16 id, buf_offset;
462 u32 packet_size; 470 u32 packet_size;
471 u8 id_hash;
463 472
464 IWM_DBG_RX(iwm, DBG, "\n"); 473 IWM_DBG_RX(iwm, DBG, "\n");
465 474
@@ -477,7 +486,10 @@ static int iwm_ntf_rx_packet(struct iwm_priv *iwm, u8 *buf,
477 if (IS_ERR(packet)) 486 if (IS_ERR(packet))
478 return PTR_ERR(packet); 487 return PTR_ERR(packet);
479 488
480 list_add_tail(&packet->node, &iwm->rx_packets[IWM_RX_ID_GET_HASH(id)]); 489 id_hash = IWM_RX_ID_GET_HASH(id);
490 spin_lock(&iwm->packet_lock[id_hash]);
491 list_add_tail(&packet->node, &iwm->rx_packets[id_hash]);
492 spin_unlock(&iwm->packet_lock[id_hash]);
481 493
482 /* We might (unlikely) have received the packet _after_ the ticket */ 494 /* We might (unlikely) have received the packet _after_ the ticket */
483 queue_work(iwm->rx_wq, &iwm->rx_worker); 495 queue_work(iwm->rx_wq, &iwm->rx_worker);
@@ -518,6 +530,8 @@ static int iwm_mlme_assoc_complete(struct iwm_priv *iwm, u8 *buf,
518 unsigned long buf_size, 530 unsigned long buf_size,
519 struct iwm_wifi_cmd *cmd) 531 struct iwm_wifi_cmd *cmd)
520{ 532{
533 struct wiphy *wiphy = iwm_to_wiphy(iwm);
534 struct ieee80211_channel *chan;
521 struct iwm_umac_notif_assoc_complete *complete = 535 struct iwm_umac_notif_assoc_complete *complete =
522 (struct iwm_umac_notif_assoc_complete *)buf; 536 (struct iwm_umac_notif_assoc_complete *)buf;
523 537
@@ -526,6 +540,18 @@ static int iwm_mlme_assoc_complete(struct iwm_priv *iwm, u8 *buf,
526 540
527 switch (le32_to_cpu(complete->status)) { 541 switch (le32_to_cpu(complete->status)) {
528 case UMAC_ASSOC_COMPLETE_SUCCESS: 542 case UMAC_ASSOC_COMPLETE_SUCCESS:
543 chan = ieee80211_get_channel(wiphy,
544 ieee80211_channel_to_frequency(complete->channel));
545 if (!chan || chan->flags & IEEE80211_CHAN_DISABLED) {
546 /* Associated to a unallowed channel, disassociate. */
547 __iwm_invalidate_mlme_profile(iwm);
548 IWM_WARN(iwm, "Couldn't associate with %pM due to "
549 "channel %d is disabled. Check your local "
550 "regulatory setting.\n",
551 complete->bssid, complete->channel);
552 goto failure;
553 }
554
529 set_bit(IWM_STATUS_ASSOCIATED, &iwm->status); 555 set_bit(IWM_STATUS_ASSOCIATED, &iwm->status);
530 memcpy(iwm->bssid, complete->bssid, ETH_ALEN); 556 memcpy(iwm->bssid, complete->bssid, ETH_ALEN);
531 iwm->channel = complete->channel; 557 iwm->channel = complete->channel;
@@ -562,6 +588,7 @@ static int iwm_mlme_assoc_complete(struct iwm_priv *iwm, u8 *buf,
562 GFP_KERNEL); 588 GFP_KERNEL);
563 break; 589 break;
564 case UMAC_ASSOC_COMPLETE_FAILURE: 590 case UMAC_ASSOC_COMPLETE_FAILURE:
591 failure:
565 clear_bit(IWM_STATUS_ASSOCIATED, &iwm->status); 592 clear_bit(IWM_STATUS_ASSOCIATED, &iwm->status);
566 memset(iwm->bssid, 0, ETH_ALEN); 593 memset(iwm->bssid, 0, ETH_ALEN);
567 iwm->channel = 0; 594 iwm->channel = 0;
@@ -756,7 +783,7 @@ static int iwm_mlme_update_bss_table(struct iwm_priv *iwm, u8 *buf,
756 (struct iwm_umac_notif_bss_info *)buf; 783 (struct iwm_umac_notif_bss_info *)buf;
757 struct ieee80211_channel *channel; 784 struct ieee80211_channel *channel;
758 struct ieee80211_supported_band *band; 785 struct ieee80211_supported_band *band;
759 struct iwm_bss_info *bss, *next; 786 struct iwm_bss_info *bss;
760 s32 signal; 787 s32 signal;
761 int freq; 788 int freq;
762 u16 frame_len = le16_to_cpu(umac_bss->frame_len); 789 u16 frame_len = le16_to_cpu(umac_bss->frame_len);
@@ -775,7 +802,7 @@ static int iwm_mlme_update_bss_table(struct iwm_priv *iwm, u8 *buf,
775 IWM_DBG_MLME(iwm, DBG, "\tRSSI: %d\n", umac_bss->rssi); 802 IWM_DBG_MLME(iwm, DBG, "\tRSSI: %d\n", umac_bss->rssi);
776 IWM_DBG_MLME(iwm, DBG, "\tFrame Length: %d\n", frame_len); 803 IWM_DBG_MLME(iwm, DBG, "\tFrame Length: %d\n", frame_len);
777 804
778 list_for_each_entry_safe(bss, next, &iwm->bss_list, node) 805 list_for_each_entry(bss, &iwm->bss_list, node)
779 if (bss->bss->table_idx == umac_bss->table_idx) 806 if (bss->bss->table_idx == umac_bss->table_idx)
780 break; 807 break;
781 808
@@ -842,16 +869,15 @@ static int iwm_mlme_remove_bss(struct iwm_priv *iwm, u8 *buf,
842 int i; 869 int i;
843 870
844 for (i = 0; i < le32_to_cpu(bss_rm->count); i++) { 871 for (i = 0; i < le32_to_cpu(bss_rm->count); i++) {
845 table_idx = (le16_to_cpu(bss_rm->entries[i]) 872 table_idx = le16_to_cpu(bss_rm->entries[i]) &
846 & IWM_BSS_REMOVE_INDEX_MSK); 873 IWM_BSS_REMOVE_INDEX_MSK;
847 list_for_each_entry_safe(bss, next, &iwm->bss_list, node) 874 list_for_each_entry_safe(bss, next, &iwm->bss_list, node)
848 if (bss->bss->table_idx == cpu_to_le16(table_idx)) { 875 if (bss->bss->table_idx == cpu_to_le16(table_idx)) {
849 struct ieee80211_mgmt *mgmt; 876 struct ieee80211_mgmt *mgmt;
850 877
851 mgmt = (struct ieee80211_mgmt *) 878 mgmt = (struct ieee80211_mgmt *)
852 (bss->bss->frame_buf); 879 (bss->bss->frame_buf);
853 IWM_DBG_MLME(iwm, ERR, 880 IWM_DBG_MLME(iwm, ERR, "BSS removed: %pM\n",
854 "BSS removed: %pM\n",
855 mgmt->bssid); 881 mgmt->bssid);
856 list_del(&bss->node); 882 list_del(&bss->node);
857 kfree(bss->bss); 883 kfree(bss->bss);
@@ -1223,18 +1249,24 @@ static int iwm_rx_handle_wifi(struct iwm_priv *iwm, u8 *buf,
1223 u8 source, cmd_id; 1249 u8 source, cmd_id;
1224 u16 seq_num; 1250 u16 seq_num;
1225 u32 count; 1251 u32 count;
1226 u8 resp;
1227 1252
1228 wifi_hdr = (struct iwm_umac_wifi_in_hdr *)buf; 1253 wifi_hdr = (struct iwm_umac_wifi_in_hdr *)buf;
1229 cmd_id = wifi_hdr->sw_hdr.cmd.cmd; 1254 cmd_id = wifi_hdr->sw_hdr.cmd.cmd;
1230
1231 source = GET_VAL32(wifi_hdr->hw_hdr.cmd, UMAC_HDI_IN_CMD_SOURCE); 1255 source = GET_VAL32(wifi_hdr->hw_hdr.cmd, UMAC_HDI_IN_CMD_SOURCE);
1232 if (source >= IWM_SRC_NUM) { 1256 if (source >= IWM_SRC_NUM) {
1233 IWM_CRIT(iwm, "invalid source %d\n", source); 1257 IWM_CRIT(iwm, "invalid source %d\n", source);
1234 return -EINVAL; 1258 return -EINVAL;
1235 } 1259 }
1236 1260
1237 count = (GET_VAL32(wifi_hdr->sw_hdr.meta_data, UMAC_FW_CMD_BYTE_COUNT)); 1261 if (cmd_id == REPLY_RX_MPDU_CMD)
1262 trace_iwm_rx_packet(iwm, buf, buf_size);
1263 else if ((cmd_id == UMAC_NOTIFY_OPCODE_RX_TICKET) &&
1264 (source == UMAC_HDI_IN_SOURCE_FW))
1265 trace_iwm_rx_ticket(iwm, buf, buf_size);
1266 else
1267 trace_iwm_rx_wifi_cmd(iwm, wifi_hdr);
1268
1269 count = GET_VAL32(wifi_hdr->sw_hdr.meta_data, UMAC_FW_CMD_BYTE_COUNT);
1238 count += sizeof(struct iwm_umac_wifi_in_hdr) - 1270 count += sizeof(struct iwm_umac_wifi_in_hdr) -
1239 sizeof(struct iwm_dev_cmd_hdr); 1271 sizeof(struct iwm_dev_cmd_hdr);
1240 if (count > buf_size) { 1272 if (count > buf_size) {
@@ -1242,8 +1274,6 @@ static int iwm_rx_handle_wifi(struct iwm_priv *iwm, u8 *buf,
1242 return -EINVAL; 1274 return -EINVAL;
1243 } 1275 }
1244 1276
1245 resp = GET_VAL32(wifi_hdr->sw_hdr.meta_data, UMAC_FW_CMD_STATUS);
1246
1247 seq_num = le16_to_cpu(wifi_hdr->sw_hdr.cmd.seq_num); 1277 seq_num = le16_to_cpu(wifi_hdr->sw_hdr.cmd.seq_num);
1248 1278
1249 IWM_DBG_RX(iwm, DBG, "CMD:0x%x, source: 0x%x, seqnum: %d\n", 1279 IWM_DBG_RX(iwm, DBG, "CMD:0x%x, source: 0x%x, seqnum: %d\n",
@@ -1316,8 +1346,9 @@ static int iwm_rx_handle_nonwifi(struct iwm_priv *iwm, u8 *buf,
1316{ 1346{
1317 u8 seq_num; 1347 u8 seq_num;
1318 struct iwm_udma_in_hdr *hdr = (struct iwm_udma_in_hdr *)buf; 1348 struct iwm_udma_in_hdr *hdr = (struct iwm_udma_in_hdr *)buf;
1319 struct iwm_nonwifi_cmd *cmd, *next; 1349 struct iwm_nonwifi_cmd *cmd;
1320 1350
1351 trace_iwm_rx_nonwifi_cmd(iwm, buf, buf_size);
1321 seq_num = GET_VAL32(hdr->cmd, UDMA_HDI_IN_CMD_NON_WIFI_HW_SEQ_NUM); 1352 seq_num = GET_VAL32(hdr->cmd, UDMA_HDI_IN_CMD_NON_WIFI_HW_SEQ_NUM);
1322 1353
1323 /* 1354 /*
@@ -1328,7 +1359,7 @@ static int iwm_rx_handle_nonwifi(struct iwm_priv *iwm, u8 *buf,
1328 * That means we only support synchronised non wifi command response 1359 * That means we only support synchronised non wifi command response
1329 * schemes. 1360 * schemes.
1330 */ 1361 */
1331 list_for_each_entry_safe(cmd, next, &iwm->nonwifi_pending_cmd, pending) 1362 list_for_each_entry(cmd, &iwm->nonwifi_pending_cmd, pending)
1332 if (cmd->seq_num == seq_num) { 1363 if (cmd->seq_num == seq_num) {
1333 cmd->resp_received = 1; 1364 cmd->resp_received = 1;
1334 cmd->buf.len = buf_size; 1365 cmd->buf.len = buf_size;
@@ -1647,6 +1678,7 @@ void iwm_rx_worker(struct work_struct *work)
1647 * We stop whenever a ticket is missing its packet, as we're 1678 * We stop whenever a ticket is missing its packet, as we're
1648 * supposed to send the packets in order. 1679 * supposed to send the packets in order.
1649 */ 1680 */
1681 spin_lock(&iwm->ticket_lock);
1650 list_for_each_entry_safe(ticket, next, &iwm->rx_tickets, node) { 1682 list_for_each_entry_safe(ticket, next, &iwm->rx_tickets, node) {
1651 struct iwm_rx_packet *packet = 1683 struct iwm_rx_packet *packet =
1652 iwm_rx_packet_get(iwm, le16_to_cpu(ticket->ticket->id)); 1684 iwm_rx_packet_get(iwm, le16_to_cpu(ticket->ticket->id));
@@ -1655,12 +1687,12 @@ void iwm_rx_worker(struct work_struct *work)
1655 IWM_DBG_RX(iwm, DBG, "Skip rx_work: Wait for ticket %d " 1687 IWM_DBG_RX(iwm, DBG, "Skip rx_work: Wait for ticket %d "
1656 "to be handled first\n", 1688 "to be handled first\n",
1657 le16_to_cpu(ticket->ticket->id)); 1689 le16_to_cpu(ticket->ticket->id));
1658 return; 1690 break;
1659 } 1691 }
1660 1692
1661 list_del(&ticket->node); 1693 list_del(&ticket->node);
1662 list_del(&packet->node);
1663 iwm_rx_process_packet(iwm, packet, ticket); 1694 iwm_rx_process_packet(iwm, packet, ticket);
1664 } 1695 }
1696 spin_unlock(&iwm->ticket_lock);
1665} 1697}
1666 1698
diff --git a/drivers/net/wireless/iwmc3200wifi/trace.c b/drivers/net/wireless/iwmc3200wifi/trace.c
new file mode 100644
index 000000000000..904d36f22311
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/trace.c
@@ -0,0 +1,3 @@
1#include "iwm.h"
2#define CREATE_TRACE_POINTS
3#include "trace.h"
diff --git a/drivers/net/wireless/iwmc3200wifi/trace.h b/drivers/net/wireless/iwmc3200wifi/trace.h
new file mode 100644
index 000000000000..320e54fbb38c
--- /dev/null
+++ b/drivers/net/wireless/iwmc3200wifi/trace.h
@@ -0,0 +1,283 @@
1#if !defined(__IWM_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ)
2#define __IWM_TRACE_H__
3
4#include <linux/tracepoint.h>
5
6#if !defined(CONFIG_IWM_TRACING)
7#undef TRACE_EVENT
8#define TRACE_EVENT(name, proto, ...) \
9static inline void trace_ ## name(proto) {}
10#endif
11
12#undef TRACE_SYSTEM
13#define TRACE_SYSTEM iwm
14
15#define IWM_ENTRY __array(char, ndev_name, 16)
16#define IWM_ASSIGN strlcpy(__entry->ndev_name, iwm_to_ndev(iwm)->name, 16)
17#define IWM_PR_FMT "%s"
18#define IWM_PR_ARG __entry->ndev_name
19
20TRACE_EVENT(iwm_tx_nonwifi_cmd,
21 TP_PROTO(struct iwm_priv *iwm, struct iwm_udma_out_nonwifi_hdr *hdr),
22
23 TP_ARGS(iwm, hdr),
24
25 TP_STRUCT__entry(
26 IWM_ENTRY
27 __field(u8, opcode)
28 __field(u8, resp)
29 __field(u8, eot)
30 __field(u8, hw)
31 __field(u16, seq)
32 __field(u32, addr)
33 __field(u32, op1)
34 __field(u32, op2)
35 ),
36
37 TP_fast_assign(
38 IWM_ASSIGN;
39 __entry->opcode = GET_VAL32(hdr->cmd, UMAC_HDI_OUT_CMD_OPCODE);
40 __entry->resp = GET_VAL32(hdr->cmd, UDMA_HDI_OUT_NW_CMD_RESP);
41 __entry->eot = GET_VAL32(hdr->cmd, UMAC_HDI_OUT_CMD_EOT);
42 __entry->hw = GET_VAL32(hdr->cmd, UDMA_HDI_OUT_NW_CMD_HANDLE_BY_HW);
43 __entry->seq = GET_VAL32(hdr->cmd, UDMA_HDI_OUT_CMD_NON_WIFI_HW_SEQ_NUM);
44 __entry->addr = le32_to_cpu(hdr->addr);
45 __entry->op1 = le32_to_cpu(hdr->op1_sz);
46 __entry->op2 = le32_to_cpu(hdr->op2);
47 ),
48
49 TP_printk(
50 IWM_PR_FMT " Tx TARGET CMD: opcode 0x%x, resp %d, eot %d, "
51 "hw %d, seq 0x%x, addr 0x%x, op1 0x%x, op2 0x%x",
52 IWM_PR_ARG, __entry->opcode, __entry->resp, __entry->eot,
53 __entry->hw, __entry->seq, __entry->addr, __entry->op1,
54 __entry->op2
55 )
56);
57
58TRACE_EVENT(iwm_tx_wifi_cmd,
59 TP_PROTO(struct iwm_priv *iwm, struct iwm_umac_wifi_out_hdr *hdr),
60
61 TP_ARGS(iwm, hdr),
62
63 TP_STRUCT__entry(
64 IWM_ENTRY
65 __field(u8, opcode)
66 __field(u8, lmac)
67 __field(u8, resp)
68 __field(u8, eot)
69 __field(u8, ra_tid)
70 __field(u8, credit_group)
71 __field(u8, color)
72 __field(u16, seq)
73 ),
74
75 TP_fast_assign(
76 IWM_ASSIGN;
77 __entry->opcode = hdr->sw_hdr.cmd.cmd;
78 __entry->lmac = 0;
79 __entry->seq = hdr->sw_hdr.cmd.seq_num;
80 __entry->resp = GET_VAL8(hdr->sw_hdr.cmd.flags, UMAC_DEV_CMD_FLAGS_RESP_REQ);
81 __entry->color = GET_VAL32(hdr->sw_hdr.meta_data, UMAC_FW_CMD_TX_STA_COLOR);
82 __entry->eot = GET_VAL32(hdr->hw_hdr.cmd, UMAC_HDI_OUT_CMD_EOT);
83 __entry->ra_tid = GET_VAL32(hdr->hw_hdr.meta_data, UMAC_HDI_OUT_RATID);
84 __entry->credit_group = GET_VAL32(hdr->hw_hdr.meta_data, UMAC_HDI_OUT_CREDIT_GRP);
85 if (__entry->opcode == UMAC_CMD_OPCODE_WIFI_PASS_THROUGH ||
86 __entry->opcode == UMAC_CMD_OPCODE_WIFI_IF_WRAPPER) {
87 __entry->lmac = 1;
88 __entry->opcode = ((struct iwm_lmac_hdr *)(hdr + 1))->id;
89 }
90 ),
91
92 TP_printk(
93 IWM_PR_FMT " Tx %cMAC CMD: opcode 0x%x, resp %d, eot %d, "
94 "seq 0x%x, sta_color 0x%x, ra_tid 0x%x, credit_group 0x%x",
95 IWM_PR_ARG, __entry->lmac ? 'L' : 'U', __entry->opcode,
96 __entry->resp, __entry->eot, __entry->seq, __entry->color,
97 __entry->ra_tid, __entry->credit_group
98 )
99);
100
101TRACE_EVENT(iwm_tx_packets,
102 TP_PROTO(struct iwm_priv *iwm, u8 *buf, int len),
103
104 TP_ARGS(iwm, buf, len),
105
106 TP_STRUCT__entry(
107 IWM_ENTRY
108 __field(u8, eot)
109 __field(u8, ra_tid)
110 __field(u8, credit_group)
111 __field(u8, color)
112 __field(u16, seq)
113 __field(u8, npkt)
114 __field(u32, bytes)
115 ),
116
117 TP_fast_assign(
118 struct iwm_umac_wifi_out_hdr *hdr =
119 (struct iwm_umac_wifi_out_hdr *)buf;
120
121 IWM_ASSIGN;
122 __entry->eot = GET_VAL32(hdr->hw_hdr.cmd, UMAC_HDI_OUT_CMD_EOT);
123 __entry->ra_tid = GET_VAL32(hdr->hw_hdr.meta_data, UMAC_HDI_OUT_RATID);
124 __entry->credit_group = GET_VAL32(hdr->hw_hdr.meta_data, UMAC_HDI_OUT_CREDIT_GRP);
125 __entry->color = GET_VAL32(hdr->sw_hdr.meta_data, UMAC_FW_CMD_TX_STA_COLOR);
126 __entry->seq = hdr->sw_hdr.cmd.seq_num;
127 __entry->npkt = 1;
128 __entry->bytes = len;
129
130 if (!__entry->eot) {
131 int count;
132 u8 *ptr = buf;
133
134 __entry->npkt = 0;
135 while (ptr < buf + len) {
136 count = GET_VAL32(hdr->sw_hdr.meta_data,
137 UMAC_FW_CMD_BYTE_COUNT);
138 ptr += ALIGN(sizeof(*hdr) + count, 16);
139 hdr = (struct iwm_umac_wifi_out_hdr *)ptr;
140 __entry->npkt++;
141 }
142 }
143 ),
144
145 TP_printk(
146 IWM_PR_FMT " Tx %spacket: eot %d, seq 0x%x, sta_color 0x%x, "
147 "ra_tid 0x%x, credit_group 0x%x, embeded_packets %d, %d bytes",
148 IWM_PR_ARG, !__entry->eot ? "concatenated " : "",
149 __entry->eot, __entry->seq, __entry->color, __entry->ra_tid,
150 __entry->credit_group, __entry->npkt, __entry->bytes
151 )
152);
153
154TRACE_EVENT(iwm_rx_nonwifi_cmd,
155 TP_PROTO(struct iwm_priv *iwm, void *buf, int len),
156
157 TP_ARGS(iwm, buf, len),
158
159 TP_STRUCT__entry(
160 IWM_ENTRY
161 __field(u8, opcode)
162 __field(u16, seq)
163 __field(u32, len)
164 ),
165
166 TP_fast_assign(
167 struct iwm_udma_in_hdr *hdr = buf;
168
169 IWM_ASSIGN;
170 __entry->opcode = GET_VAL32(hdr->cmd, UDMA_HDI_IN_NW_CMD_OPCODE);
171 __entry->seq = GET_VAL32(hdr->cmd, UDMA_HDI_IN_CMD_NON_WIFI_HW_SEQ_NUM);
172 __entry->len = len;
173 ),
174
175 TP_printk(
176 IWM_PR_FMT " Rx TARGET RESP: opcode 0x%x, seq 0x%x, len 0x%x",
177 IWM_PR_ARG, __entry->opcode, __entry->seq, __entry->len
178 )
179);
180
181TRACE_EVENT(iwm_rx_wifi_cmd,
182 TP_PROTO(struct iwm_priv *iwm, struct iwm_umac_wifi_in_hdr *hdr),
183
184 TP_ARGS(iwm, hdr),
185
186 TP_STRUCT__entry(
187 IWM_ENTRY
188 __field(u8, cmd)
189 __field(u8, source)
190 __field(u16, seq)
191 __field(u32, count)
192 ),
193
194 TP_fast_assign(
195 IWM_ASSIGN;
196 __entry->cmd = hdr->sw_hdr.cmd.cmd;
197 __entry->source = GET_VAL32(hdr->hw_hdr.cmd, UMAC_HDI_IN_CMD_SOURCE);
198 __entry->count = GET_VAL32(hdr->sw_hdr.meta_data, UMAC_FW_CMD_BYTE_COUNT);
199 __entry->seq = le16_to_cpu(hdr->sw_hdr.cmd.seq_num);
200 ),
201
202 TP_printk(
203 IWM_PR_FMT " Rx %s RESP: cmd 0x%x, seq 0x%x, count 0x%x",
204 IWM_PR_ARG, __entry->source == UMAC_HDI_IN_SOURCE_FHRX ? "LMAC" :
205 __entry->source == UMAC_HDI_IN_SOURCE_FW ? "UMAC" : "UDMA",
206 __entry->cmd, __entry->seq, __entry->count
207 )
208);
209
210#define iwm_ticket_action_symbol \
211 { IWM_RX_TICKET_DROP, "DROP" }, \
212 { IWM_RX_TICKET_RELEASE, "RELEASE" }, \
213 { IWM_RX_TICKET_SNIFFER, "SNIFFER" }, \
214 { IWM_RX_TICKET_ENQUEUE, "ENQUEUE" }
215
216TRACE_EVENT(iwm_rx_ticket,
217 TP_PROTO(struct iwm_priv *iwm, void *buf, int len),
218
219 TP_ARGS(iwm, buf, len),
220
221 TP_STRUCT__entry(
222 IWM_ENTRY
223 __field(u8, action)
224 __field(u8, reason)
225 __field(u16, id)
226 __field(u16, flags)
227 ),
228
229 TP_fast_assign(
230 struct iwm_rx_ticket *ticket =
231 ((struct iwm_umac_notif_rx_ticket *)buf)->tickets;
232
233 IWM_ASSIGN;
234 __entry->id = le16_to_cpu(ticket->id);
235 __entry->action = le16_to_cpu(ticket->action);
236 __entry->flags = le16_to_cpu(ticket->flags);
237 __entry->reason = (__entry->flags & IWM_RX_TICKET_DROP_REASON_MSK) >> IWM_RX_TICKET_DROP_REASON_POS;
238 ),
239
240 TP_printk(
241 IWM_PR_FMT " Rx ticket: id 0x%x, action %s, %s 0x%x%s",
242 IWM_PR_ARG, __entry->id,
243 __print_symbolic(__entry->action, iwm_ticket_action_symbol),
244 __entry->reason ? "reason" : "flags",
245 __entry->reason ? __entry->reason : __entry->flags,
246 __entry->flags & IWM_RX_TICKET_AMSDU_MSK ? ", AMSDU frame" : ""
247 )
248);
249
250TRACE_EVENT(iwm_rx_packet,
251 TP_PROTO(struct iwm_priv *iwm, void *buf, int len),
252
253 TP_ARGS(iwm, buf, len),
254
255 TP_STRUCT__entry(
256 IWM_ENTRY
257 __field(u8, source)
258 __field(u16, id)
259 __field(u32, len)
260 ),
261
262 TP_fast_assign(
263 struct iwm_umac_wifi_in_hdr *hdr = buf;
264
265 IWM_ASSIGN;
266 __entry->source = GET_VAL32(hdr->hw_hdr.cmd, UMAC_HDI_IN_CMD_SOURCE);
267 __entry->id = le16_to_cpu(hdr->sw_hdr.cmd.seq_num);
268 __entry->len = len - sizeof(*hdr);
269 ),
270
271 TP_printk(
272 IWM_PR_FMT " Rx %s packet: id 0x%x, %d bytes",
273 IWM_PR_ARG, __entry->source == UMAC_HDI_IN_SOURCE_FHRX ?
274 "LMAC" : "UMAC", __entry->id, __entry->len
275 )
276);
277#endif
278
279#undef TRACE_INCLUDE_PATH
280#define TRACE_INCLUDE_PATH .
281#undef TRACE_INCLUDE_FILE
282#define TRACE_INCLUDE_FILE trace
283#include <trace/define_trace.h>
diff --git a/drivers/net/wireless/iwmc3200wifi/tx.c b/drivers/net/wireless/iwmc3200wifi/tx.c
index 55905f02309c..a20b936ae21f 100644
--- a/drivers/net/wireless/iwmc3200wifi/tx.c
+++ b/drivers/net/wireless/iwmc3200wifi/tx.c
@@ -346,6 +346,7 @@ static int iwm_tx_send_concat_packets(struct iwm_priv *iwm,
346 /* mark EOP for the last packet */ 346 /* mark EOP for the last packet */
347 iwm_udma_wifi_hdr_set_eop(iwm, txq->concat_ptr, 1); 347 iwm_udma_wifi_hdr_set_eop(iwm, txq->concat_ptr, 1);
348 348
349 trace_iwm_tx_packets(iwm, txq->concat_buf, txq->concat_count);
349 ret = iwm_bus_send_chunk(iwm, txq->concat_buf, txq->concat_count); 350 ret = iwm_bus_send_chunk(iwm, txq->concat_buf, txq->concat_count);
350 351
351 txq->concat_count = 0; 352 txq->concat_count = 0;
@@ -450,7 +451,6 @@ void iwm_tx_worker(struct work_struct *work)
450int iwm_xmit_frame(struct sk_buff *skb, struct net_device *netdev) 451int iwm_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
451{ 452{
452 struct iwm_priv *iwm = ndev_to_iwm(netdev); 453 struct iwm_priv *iwm = ndev_to_iwm(netdev);
453 struct net_device *ndev = iwm_to_ndev(iwm);
454 struct wireless_dev *wdev = iwm_to_wdev(iwm); 454 struct wireless_dev *wdev = iwm_to_wdev(iwm);
455 struct iwm_tx_info *tx_info; 455 struct iwm_tx_info *tx_info;
456 struct iwm_tx_queue *txq; 456 struct iwm_tx_queue *txq;
@@ -517,12 +517,12 @@ int iwm_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
517 517
518 queue_work(iwm->txq[queue].wq, &iwm->txq[queue].worker); 518 queue_work(iwm->txq[queue].wq, &iwm->txq[queue].worker);
519 519
520 ndev->stats.tx_packets++; 520 netdev->stats.tx_packets++;
521 ndev->stats.tx_bytes += skb->len; 521 netdev->stats.tx_bytes += skb->len;
522 return NETDEV_TX_OK; 522 return NETDEV_TX_OK;
523 523
524 drop: 524 drop:
525 ndev->stats.tx_dropped++; 525 netdev->stats.tx_dropped++;
526 dev_kfree_skb_any(skb); 526 dev_kfree_skb_any(skb);
527 return NETDEV_TX_OK; 527 return NETDEV_TX_OK;
528} 528}
diff --git a/drivers/net/wireless/iwmc3200wifi/umac.h b/drivers/net/wireless/iwmc3200wifi/umac.h
index 7f54a145ca65..0cbba3ecc813 100644
--- a/drivers/net/wireless/iwmc3200wifi/umac.h
+++ b/drivers/net/wireless/iwmc3200wifi/umac.h
@@ -362,7 +362,7 @@ struct iwm_udma_out_wifi_hdr {
362#define IWM_RX_TICKET_SPECIAL_SNAP_MSK 0x4 362#define IWM_RX_TICKET_SPECIAL_SNAP_MSK 0x4
363#define IWM_RX_TICKET_AMSDU_MSK 0x8 363#define IWM_RX_TICKET_AMSDU_MSK 0x8
364#define IWM_RX_TICKET_DROP_REASON_POS 4 364#define IWM_RX_TICKET_DROP_REASON_POS 4
365#define IWM_RX_TICKET_DROP_REASON_MSK (0x1F << RX_TICKET_FLAGS_DROP_REASON_POS) 365#define IWM_RX_TICKET_DROP_REASON_MSK (0x1F << IWM_RX_TICKET_DROP_REASON_POS)
366 366
367#define IWM_RX_DROP_NO_DROP 0x0 367#define IWM_RX_DROP_NO_DROP 0x0
368#define IWM_RX_DROP_BAD_CRC 0x1 368#define IWM_RX_DROP_BAD_CRC 0x1
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index f03d5e4e59c3..95d3d4c5e08b 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -31,6 +31,9 @@ u8 lbs_bg_rates[MAX_RATES] =
310x00, 0x00 }; 310x00, 0x00 };
32 32
33 33
34static int assoc_helper_wep_keys(struct lbs_private *priv,
35 struct assoc_request *assoc_req);
36
34/** 37/**
35 * @brief This function finds common rates between rates and card rates. 38 * @brief This function finds common rates between rates and card rates.
36 * 39 *
@@ -610,7 +613,7 @@ static int lbs_assoc_post(struct lbs_private *priv,
610 613
611 if (status_code) { 614 if (status_code) {
612 lbs_mac_event_disconnected(priv); 615 lbs_mac_event_disconnected(priv);
613 ret = -1; 616 ret = status_code;
614 goto done; 617 goto done;
615 } 618 }
616 619
@@ -813,7 +816,24 @@ static int lbs_try_associate(struct lbs_private *priv,
813 goto out; 816 goto out;
814 817
815 ret = lbs_associate(priv, assoc_req, CMD_802_11_ASSOCIATE); 818 ret = lbs_associate(priv, assoc_req, CMD_802_11_ASSOCIATE);
819 /* If the association fails with current auth mode, let's
820 * try by changing the auth mode
821 */
822 if ((priv->authtype_auto) &&
823 (ret == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) &&
824 (assoc_req->secinfo.wep_enabled) &&
825 (priv->connect_status != LBS_CONNECTED)) {
826 if (priv->secinfo.auth_mode == IW_AUTH_ALG_OPEN_SYSTEM)
827 priv->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
828 else
829 priv->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
830 if (!assoc_helper_wep_keys(priv, assoc_req))
831 ret = lbs_associate(priv, assoc_req,
832 CMD_802_11_ASSOCIATE);
833 }
816 834
835 if (ret)
836 ret = -1;
817out: 837out:
818 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 838 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
819 return ret; 839 return ret;
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index 6875e1498bd5..a54880e4ad2b 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -134,6 +134,7 @@ struct lbs_private {
134 u8 wpa_ie_len; 134 u8 wpa_ie_len;
135 u16 wep_tx_keyidx; 135 u16 wep_tx_keyidx;
136 struct enc_key wep_keys[4]; 136 struct enc_key wep_keys[4];
137 u8 authtype_auto;
137 138
138 /* Wake On LAN */ 139 /* Wake On LAN */
139 uint32_t wol_criteria; 140 uint32_t wol_criteria;
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 28a1c9d1627a..ff7b0d0cca56 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -318,7 +318,7 @@ static int lbs_add_mcast_addrs(struct cmd_ds_mac_multicast_adr *cmd,
318 struct net_device *dev, int nr_addrs) 318 struct net_device *dev, int nr_addrs)
319{ 319{
320 int i = nr_addrs; 320 int i = nr_addrs;
321 struct dev_mc_list *mc_list; 321 struct netdev_hw_addr *ha;
322 int cnt; 322 int cnt;
323 323
324 if ((dev->flags & (IFF_UP|IFF_MULTICAST)) != (IFF_UP|IFF_MULTICAST)) 324 if ((dev->flags & (IFF_UP|IFF_MULTICAST)) != (IFF_UP|IFF_MULTICAST))
@@ -326,19 +326,19 @@ static int lbs_add_mcast_addrs(struct cmd_ds_mac_multicast_adr *cmd,
326 326
327 netif_addr_lock_bh(dev); 327 netif_addr_lock_bh(dev);
328 cnt = netdev_mc_count(dev); 328 cnt = netdev_mc_count(dev);
329 netdev_for_each_mc_addr(mc_list, dev) { 329 netdev_for_each_mc_addr(ha, dev) {
330 if (mac_in_list(cmd->maclist, nr_addrs, mc_list->dmi_addr)) { 330 if (mac_in_list(cmd->maclist, nr_addrs, ha->addr)) {
331 lbs_deb_net("mcast address %s:%pM skipped\n", dev->name, 331 lbs_deb_net("mcast address %s:%pM skipped\n", dev->name,
332 mc_list->dmi_addr); 332 ha->addr);
333 cnt--; 333 cnt--;
334 continue; 334 continue;
335 } 335 }
336 336
337 if (i == MRVDRV_MAX_MULTICAST_LIST_SIZE) 337 if (i == MRVDRV_MAX_MULTICAST_LIST_SIZE)
338 break; 338 break;
339 memcpy(&cmd->maclist[6*i], mc_list->dmi_addr, ETH_ALEN); 339 memcpy(&cmd->maclist[6*i], ha->addr, ETH_ALEN);
340 lbs_deb_net("mcast address %s:%pM added to filter\n", dev->name, 340 lbs_deb_net("mcast address %s:%pM added to filter\n", dev->name,
341 mc_list->dmi_addr); 341 ha->addr);
342 i++; 342 i++;
343 cnt--; 343 cnt--;
344 } 344 }
@@ -835,6 +835,7 @@ static int lbs_init_adapter(struct lbs_private *priv)
835 priv->is_auto_deep_sleep_enabled = 0; 835 priv->is_auto_deep_sleep_enabled = 0;
836 priv->wakeup_dev_required = 0; 836 priv->wakeup_dev_required = 0;
837 init_waitqueue_head(&priv->ds_awake_q); 837 init_waitqueue_head(&priv->ds_awake_q);
838 priv->authtype_auto = 1;
838 839
839 mutex_init(&priv->lock); 840 mutex_init(&priv->lock);
840 841
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c
index 2daf8ffdb7e1..7a867e31ca5a 100644
--- a/drivers/net/wireless/libertas/rx.c
+++ b/drivers/net/wireless/libertas/rx.c
@@ -38,10 +38,10 @@ static int process_rxed_802_11_packet(struct lbs_private *priv,
38 struct sk_buff *skb); 38 struct sk_buff *skb);
39 39
40/** 40/**
41 * @brief This function computes the avgSNR . 41 * @brief This function computes the avgSNR .
42 * 42 *
43 * @param priv A pointer to struct lbs_private structure 43 * @param priv A pointer to struct lbs_private structure
44 * @return avgSNR 44 * @return avgSNR
45 */ 45 */
46static u8 lbs_getavgsnr(struct lbs_private *priv) 46static u8 lbs_getavgsnr(struct lbs_private *priv)
47{ 47{
@@ -56,10 +56,10 @@ static u8 lbs_getavgsnr(struct lbs_private *priv)
56} 56}
57 57
58/** 58/**
59 * @brief This function computes the AvgNF 59 * @brief This function computes the AvgNF
60 * 60 *
61 * @param priv A pointer to struct lbs_private structure 61 * @param priv A pointer to struct lbs_private structure
62 * @return AvgNF 62 * @return AvgNF
63 */ 63 */
64static u8 lbs_getavgnf(struct lbs_private *priv) 64static u8 lbs_getavgnf(struct lbs_private *priv)
65{ 65{
@@ -74,11 +74,11 @@ static u8 lbs_getavgnf(struct lbs_private *priv)
74} 74}
75 75
76/** 76/**
77 * @brief This function save the raw SNR/NF to our internel buffer 77 * @brief This function save the raw SNR/NF to our internel buffer
78 * 78 *
79 * @param priv A pointer to struct lbs_private structure 79 * @param priv A pointer to struct lbs_private structure
80 * @param prxpd A pointer to rxpd structure of received packet 80 * @param prxpd A pointer to rxpd structure of received packet
81 * @return n/a 81 * @return n/a
82 */ 82 */
83static void lbs_save_rawSNRNF(struct lbs_private *priv, struct rxpd *p_rx_pd) 83static void lbs_save_rawSNRNF(struct lbs_private *priv, struct rxpd *p_rx_pd)
84{ 84{
@@ -93,11 +93,11 @@ static void lbs_save_rawSNRNF(struct lbs_private *priv, struct rxpd *p_rx_pd)
93} 93}
94 94
95/** 95/**
96 * @brief This function computes the RSSI in received packet. 96 * @brief This function computes the RSSI in received packet.
97 * 97 *
98 * @param priv A pointer to struct lbs_private structure 98 * @param priv A pointer to struct lbs_private structure
99 * @param prxpd A pointer to rxpd structure of received packet 99 * @param prxpd A pointer to rxpd structure of received packet
100 * @return n/a 100 * @return n/a
101 */ 101 */
102static void lbs_compute_rssi(struct lbs_private *priv, struct rxpd *p_rx_pd) 102static void lbs_compute_rssi(struct lbs_private *priv, struct rxpd *p_rx_pd)
103{ 103{
@@ -134,9 +134,9 @@ static void lbs_compute_rssi(struct lbs_private *priv, struct rxpd *p_rx_pd)
134 * @brief This function processes received packet and forwards it 134 * @brief This function processes received packet and forwards it
135 * to kernel/upper layer 135 * to kernel/upper layer
136 * 136 *
137 * @param priv A pointer to struct lbs_private 137 * @param priv A pointer to struct lbs_private
138 * @param skb A pointer to skb which includes the received packet 138 * @param skb A pointer to skb which includes the received packet
139 * @return 0 or -1 139 * @return 0 or -1
140 */ 140 */
141int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb) 141int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
142{ 142{
@@ -196,7 +196,7 @@ int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
196 * before the snap_type. 196 * before the snap_type.
197 */ 197 */
198 p_ethhdr = (struct ethhdr *) 198 p_ethhdr = (struct ethhdr *)
199 ((u8 *) & p_rx_pkt->eth803_hdr 199 ((u8 *) &p_rx_pkt->eth803_hdr
200 + sizeof(p_rx_pkt->eth803_hdr) + sizeof(p_rx_pkt->rfc1042_hdr) 200 + sizeof(p_rx_pkt->eth803_hdr) + sizeof(p_rx_pkt->rfc1042_hdr)
201 - sizeof(p_rx_pkt->eth803_hdr.dest_addr) 201 - sizeof(p_rx_pkt->eth803_hdr.dest_addr)
202 - sizeof(p_rx_pkt->eth803_hdr.src_addr) 202 - sizeof(p_rx_pkt->eth803_hdr.src_addr)
@@ -213,7 +213,7 @@ int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
213 hdrchop = (u8 *)p_ethhdr - (u8 *)p_rx_pd; 213 hdrchop = (u8 *)p_ethhdr - (u8 *)p_rx_pd;
214 } else { 214 } else {
215 lbs_deb_hex(LBS_DEB_RX, "RX Data: LLC/SNAP", 215 lbs_deb_hex(LBS_DEB_RX, "RX Data: LLC/SNAP",
216 (u8 *) & p_rx_pkt->rfc1042_hdr, 216 (u8 *) &p_rx_pkt->rfc1042_hdr,
217 sizeof(p_rx_pkt->rfc1042_hdr)); 217 sizeof(p_rx_pkt->rfc1042_hdr));
218 218
219 /* Chop off the rxpd */ 219 /* Chop off the rxpd */
@@ -254,8 +254,8 @@ EXPORT_SYMBOL_GPL(lbs_process_rxed_packet);
254 * @brief This function converts Tx/Rx rates from the Marvell WLAN format 254 * @brief This function converts Tx/Rx rates from the Marvell WLAN format
255 * (see Table 2 in Section 3.1) to IEEE80211_RADIOTAP_RATE units (500 Kb/s) 255 * (see Table 2 in Section 3.1) to IEEE80211_RADIOTAP_RATE units (500 Kb/s)
256 * 256 *
257 * @param rate Input rate 257 * @param rate Input rate
258 * @return Output Rate (0 if invalid) 258 * @return Output Rate (0 if invalid)
259 */ 259 */
260static u8 convert_mv_rate_to_radiotap(u8 rate) 260static u8 convert_mv_rate_to_radiotap(u8 rate)
261{ 261{
@@ -294,9 +294,9 @@ static u8 convert_mv_rate_to_radiotap(u8 rate)
294 * @brief This function processes a received 802.11 packet and forwards it 294 * @brief This function processes a received 802.11 packet and forwards it
295 * to kernel/upper layer 295 * to kernel/upper layer
296 * 296 *
297 * @param priv A pointer to struct lbs_private 297 * @param priv A pointer to struct lbs_private
298 * @param skb A pointer to skb which includes the received packet 298 * @param skb A pointer to skb which includes the received packet
299 * @return 0 or -1 299 * @return 0 or -1
300 */ 300 */
301static int process_rxed_802_11_packet(struct lbs_private *priv, 301static int process_rxed_802_11_packet(struct lbs_private *priv,
302 struct sk_buff *skb) 302 struct sk_buff *skb)
@@ -313,7 +313,7 @@ static int process_rxed_802_11_packet(struct lbs_private *priv,
313 p_rx_pkt = (struct rx80211packethdr *) skb->data; 313 p_rx_pkt = (struct rx80211packethdr *) skb->data;
314 prxpd = &p_rx_pkt->rx_pd; 314 prxpd = &p_rx_pkt->rx_pd;
315 315
316 // lbs_deb_hex(LBS_DEB_RX, "RX Data: Before chop rxpd", skb->data, min(skb->len, 100)); 316 /* lbs_deb_hex(LBS_DEB_RX, "RX Data: Before chop rxpd", skb->data, min(skb->len, 100)); */
317 317
318 if (skb->len < (ETH_HLEN + 8 + sizeof(struct rxpd))) { 318 if (skb->len < (ETH_HLEN + 8 + sizeof(struct rxpd))) {
319 lbs_deb_rx("rx err: frame received with bad length\n"); 319 lbs_deb_rx("rx err: frame received with bad length\n");
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 71f88a08e090..aad6263dee6d 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -1440,8 +1440,10 @@ static int lbs_set_encode(struct net_device *dev,
1440 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); 1440 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
1441 1441
1442 if (dwrq->flags & IW_ENCODE_RESTRICTED) { 1442 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
1443 priv->authtype_auto = 0;
1443 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; 1444 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
1444 } else if (dwrq->flags & IW_ENCODE_OPEN) { 1445 } else if (dwrq->flags & IW_ENCODE_OPEN) {
1446 priv->authtype_auto = 0;
1445 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; 1447 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1446 } 1448 }
1447 1449
@@ -1620,8 +1622,10 @@ static int lbs_set_encodeext(struct net_device *dev,
1620 goto out; 1622 goto out;
1621 1623
1622 if (dwrq->flags & IW_ENCODE_RESTRICTED) { 1624 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
1625 priv->authtype_auto = 0;
1623 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY; 1626 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
1624 } else if (dwrq->flags & IW_ENCODE_OPEN) { 1627 } else if (dwrq->flags & IW_ENCODE_OPEN) {
1628 priv->authtype_auto = 0;
1625 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; 1629 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1626 } 1630 }
1627 1631
diff --git a/drivers/net/wireless/libertas_tf/main.c b/drivers/net/wireless/libertas_tf/main.c
index 6ab30033c26c..c20eef6b95c2 100644
--- a/drivers/net/wireless/libertas_tf/main.c
+++ b/drivers/net/wireless/libertas_tf/main.c
@@ -367,22 +367,20 @@ static int lbtf_op_config(struct ieee80211_hw *hw, u32 changed)
367} 367}
368 368
369static u64 lbtf_op_prepare_multicast(struct ieee80211_hw *hw, 369static u64 lbtf_op_prepare_multicast(struct ieee80211_hw *hw,
370 int mc_count, struct dev_addr_list *mclist) 370 struct netdev_hw_addr_list *mc_list)
371{ 371{
372 struct lbtf_private *priv = hw->priv; 372 struct lbtf_private *priv = hw->priv;
373 int i; 373 int i;
374 struct netdev_hw_addr *ha;
375 int mc_count = netdev_hw_addr_list_count(mc_list);
374 376
375 if (!mc_count || mc_count > MRVDRV_MAX_MULTICAST_LIST_SIZE) 377 if (!mc_count || mc_count > MRVDRV_MAX_MULTICAST_LIST_SIZE)
376 return mc_count; 378 return mc_count;
377 379
378 priv->nr_of_multicastmacaddr = mc_count; 380 priv->nr_of_multicastmacaddr = mc_count;
379 for (i = 0; i < mc_count; i++) { 381 i = 0;
380 if (!mclist) 382 netdev_hw_addr_list_for_each(ha, mc_list)
381 break; 383 memcpy(&priv->multicastlist[i++], ha->addr, ETH_ALEN);
382 memcpy(&priv->multicastlist[i], mclist->da_addr,
383 ETH_ALEN);
384 mclist = mclist->next;
385 }
386 384
387 return mc_count; 385 return mc_count;
388} 386}
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index 4e58ebe15580..1b5d0aebbb0e 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -1938,11 +1938,15 @@ struct mwl8k_cmd_mac_multicast_adr {
1938 1938
1939static struct mwl8k_cmd_pkt * 1939static struct mwl8k_cmd_pkt *
1940__mwl8k_cmd_mac_multicast_adr(struct ieee80211_hw *hw, int allmulti, 1940__mwl8k_cmd_mac_multicast_adr(struct ieee80211_hw *hw, int allmulti,
1941 int mc_count, struct dev_addr_list *mclist) 1941 struct netdev_hw_addr_list *mc_list)
1942{ 1942{
1943 struct mwl8k_priv *priv = hw->priv; 1943 struct mwl8k_priv *priv = hw->priv;
1944 struct mwl8k_cmd_mac_multicast_adr *cmd; 1944 struct mwl8k_cmd_mac_multicast_adr *cmd;
1945 int size; 1945 int size;
1946 int mc_count = 0;
1947
1948 if (mc_list)
1949 mc_count = netdev_hw_addr_list_count(mc_list);
1946 1950
1947 if (allmulti || mc_count > priv->num_mcaddrs) { 1951 if (allmulti || mc_count > priv->num_mcaddrs) {
1948 allmulti = 1; 1952 allmulti = 1;
@@ -1963,17 +1967,13 @@ __mwl8k_cmd_mac_multicast_adr(struct ieee80211_hw *hw, int allmulti,
1963 if (allmulti) { 1967 if (allmulti) {
1964 cmd->action |= cpu_to_le16(MWL8K_ENABLE_RX_ALL_MULTICAST); 1968 cmd->action |= cpu_to_le16(MWL8K_ENABLE_RX_ALL_MULTICAST);
1965 } else if (mc_count) { 1969 } else if (mc_count) {
1966 int i; 1970 struct netdev_hw_addr *ha;
1971 int i = 0;
1967 1972
1968 cmd->action |= cpu_to_le16(MWL8K_ENABLE_RX_MULTICAST); 1973 cmd->action |= cpu_to_le16(MWL8K_ENABLE_RX_MULTICAST);
1969 cmd->numaddr = cpu_to_le16(mc_count); 1974 cmd->numaddr = cpu_to_le16(mc_count);
1970 for (i = 0; i < mc_count && mclist; i++) { 1975 netdev_hw_addr_list_for_each(ha, mc_list) {
1971 if (mclist->da_addrlen != ETH_ALEN) { 1976 memcpy(cmd->addr[i], ha->addr, ETH_ALEN);
1972 kfree(cmd);
1973 return NULL;
1974 }
1975 memcpy(cmd->addr[i], mclist->da_addr, ETH_ALEN);
1976 mclist = mclist->next;
1977 } 1977 }
1978 } 1978 }
1979 1979
@@ -3552,7 +3552,7 @@ mwl8k_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3552} 3552}
3553 3553
3554static u64 mwl8k_prepare_multicast(struct ieee80211_hw *hw, 3554static u64 mwl8k_prepare_multicast(struct ieee80211_hw *hw,
3555 int mc_count, struct dev_addr_list *mclist) 3555 struct netdev_hw_addr_list *mc_list)
3556{ 3556{
3557 struct mwl8k_cmd_pkt *cmd; 3557 struct mwl8k_cmd_pkt *cmd;
3558 3558
@@ -3563,7 +3563,7 @@ static u64 mwl8k_prepare_multicast(struct ieee80211_hw *hw,
3563 * we'll end up throwing this packet away and creating a new 3563 * we'll end up throwing this packet away and creating a new
3564 * one in mwl8k_configure_filter(). 3564 * one in mwl8k_configure_filter().
3565 */ 3565 */
3566 cmd = __mwl8k_cmd_mac_multicast_adr(hw, 0, mc_count, mclist); 3566 cmd = __mwl8k_cmd_mac_multicast_adr(hw, 0, mc_list);
3567 3567
3568 return (unsigned long)cmd; 3568 return (unsigned long)cmd;
3569} 3569}
@@ -3686,7 +3686,7 @@ static void mwl8k_configure_filter(struct ieee80211_hw *hw,
3686 */ 3686 */
3687 if (*total_flags & FIF_ALLMULTI) { 3687 if (*total_flags & FIF_ALLMULTI) {
3688 kfree(cmd); 3688 kfree(cmd);
3689 cmd = __mwl8k_cmd_mac_multicast_adr(hw, 1, 0, NULL); 3689 cmd = __mwl8k_cmd_mac_multicast_adr(hw, 1, NULL);
3690 } 3690 }
3691 3691
3692 if (cmd != NULL) { 3692 if (cmd != NULL) {
diff --git a/drivers/net/wireless/orinoco/Kconfig b/drivers/net/wireless/orinoco/Kconfig
index e2a2c18920aa..6116b546861d 100644
--- a/drivers/net/wireless/orinoco/Kconfig
+++ b/drivers/net/wireless/orinoco/Kconfig
@@ -27,6 +27,17 @@ config HERMES
27 configure your card and that /etc/pcmcia/wireless.opts works : 27 configure your card and that /etc/pcmcia/wireless.opts works :
28 <http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html> 28 <http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>
29 29
30config HERMES_PRISM
31 bool "Support Prism 2/2.5 chipset"
32 depends on HERMES
33 ---help---
34
35 Say Y to enable support for Prism 2 and 2.5 chipsets. These
36 chipsets are better handled by the hostap driver. This driver
37 would not support WPA or firmware download for Prism chipset.
38
39 If you are not sure, say N.
40
30config HERMES_CACHE_FW_ON_INIT 41config HERMES_CACHE_FW_ON_INIT
31 bool "Cache Hermes firmware on driver initialisation" 42 bool "Cache Hermes firmware on driver initialisation"
32 depends on HERMES 43 depends on HERMES
@@ -86,7 +97,7 @@ config NORTEL_HERMES
86 97
87config PCI_HERMES 98config PCI_HERMES
88 tristate "Prism 2.5 PCI 802.11b adaptor support" 99 tristate "Prism 2.5 PCI 802.11b adaptor support"
89 depends on PCI && HERMES 100 depends on PCI && HERMES && HERMES_PRISM
90 help 101 help
91 Enable support for PCI and mini-PCI 802.11b wireless NICs based on 102 Enable support for PCI and mini-PCI 802.11b wireless NICs based on
92 the Prism 2.5 chipset. These are true PCI cards, not the 802.11b 103 the Prism 2.5 chipset. These are true PCI cards, not the 802.11b
diff --git a/drivers/net/wireless/orinoco/hw.c b/drivers/net/wireless/orinoco/hw.c
index e6369242e49c..9f657afaa3e5 100644
--- a/drivers/net/wireless/orinoco/hw.c
+++ b/drivers/net/wireless/orinoco/hw.c
@@ -262,6 +262,13 @@ int determine_fw_capabilities(struct orinoco_private *priv,
262 if (fw_name) 262 if (fw_name)
263 dev_info(dev, "Firmware determined as %s\n", fw_name); 263 dev_info(dev, "Firmware determined as %s\n", fw_name);
264 264
265#ifndef CONFIG_HERMES_PRISM
266 if (priv->firmware_type == FIRMWARE_TYPE_INTERSIL) {
267 dev_err(dev, "Support for Prism chipset is not enabled\n");
268 return -ENODEV;
269 }
270#endif
271
265 return 0; 272 return 0;
266} 273}
267 274
@@ -1049,14 +1056,14 @@ int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
1049 * group address if either we want to multicast, or if we were 1056 * group address if either we want to multicast, or if we were
1050 * multicasting and want to stop */ 1057 * multicasting and want to stop */
1051 if (!promisc && (mc_count || priv->mc_count)) { 1058 if (!promisc && (mc_count || priv->mc_count)) {
1052 struct dev_mc_list *p; 1059 struct netdev_hw_addr *ha;
1053 struct hermes_multicast mclist; 1060 struct hermes_multicast mclist;
1054 int i = 0; 1061 int i = 0;
1055 1062
1056 netdev_for_each_mc_addr(p, dev) { 1063 netdev_for_each_mc_addr(ha, dev) {
1057 if (i == mc_count) 1064 if (i == mc_count)
1058 break; 1065 break;
1059 memcpy(mclist.addr[i++], p->dmi_addr, ETH_ALEN); 1066 memcpy(mclist.addr[i++], ha->addr, ETH_ALEN);
1060 } 1067 }
1061 1068
1062 err = hermes_write_ltv(hw, USER_BAP, 1069 err = hermes_write_ltv(hw, USER_BAP,
diff --git a/drivers/net/wireless/orinoco/hw.h b/drivers/net/wireless/orinoco/hw.h
index 9799a1d14a63..97af71e79950 100644
--- a/drivers/net/wireless/orinoco/hw.h
+++ b/drivers/net/wireless/orinoco/hw.h
@@ -22,7 +22,6 @@
22 22
23/* Forward declarations */ 23/* Forward declarations */
24struct orinoco_private; 24struct orinoco_private;
25struct dev_addr_list;
26 25
27int determine_fw_capabilities(struct orinoco_private *priv, char *fw_name, 26int determine_fw_capabilities(struct orinoco_private *priv, char *fw_name,
28 size_t fw_name_len, u32 *hw_ver); 27 size_t fw_name_len, u32 *hw_ver);
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index 1d4ada188eda..fdc961379170 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -374,87 +374,90 @@ static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
374 "Pavel Roskin <proski@gnu.org>, et al)"; 374 "Pavel Roskin <proski@gnu.org>, et al)";
375 375
376static struct pcmcia_device_id orinoco_cs_ids[] = { 376static struct pcmcia_device_id orinoco_cs_ids[] = {
377 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), /* SonicWALL Long Range Wireless Card */
378 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), /* Sohoware NCP110, Philips 802.11b */
379 PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0002), /* AnyPoint(TM) Wireless II PC Card */
380 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), /* 3Com AirConnect PCI 777A */ 377 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), /* 3Com AirConnect PCI 777A */
381 PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000), /* PROXIM RangeLAN-DS/LAN PC CARD */
382 PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), /* Compaq WL100 11 Mbps Wireless Adapter */
383 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), /* Lucent Orinoco and old Intersil */ 378 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), /* Lucent Orinoco and old Intersil */
384 PCMCIA_DEVICE_MANF_CARD(0x016b, 0x0001), /* Ericsson WLAN Card C11 */ 379 PCMCIA_DEVICE_MANF_CARD(0x016b, 0x0001), /* Ericsson WLAN Card C11 */
385 PCMCIA_DEVICE_MANF_CARD(0x01eb, 0x080a), /* Nortel Networks eMobility 802.11 Wireless Adapter */ 380 PCMCIA_DEVICE_MANF_CARD(0x01eb, 0x080a), /* Nortel Networks eMobility 802.11 Wireless Adapter */
386 PCMCIA_DEVICE_MANF_CARD(0x01ff, 0x0008), /* Intermec MobileLAN 11Mbps 802.11b WLAN Card */
387 PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), /* Samsung SWL2000-N 11Mb/s WLAN Card */
388 PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), /* AirWay 802.11 Adapter (PCMCIA) */ 381 PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), /* AirWay 802.11 Adapter (PCMCIA) */
389 PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), /* ARtem Onair */ 382 PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), /* ARtem Onair */
390 PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0003), /* ARtem Onair Comcard 11 */ 383 PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0003), /* ARtem Onair Comcard 11 */
391 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), /* Buffalo WLI-PCM-S11 */ 384 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), /* Buffalo WLI-PCM-S11 */
392 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), /* Linksys WPC11 Version 2.5 */
393 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), /* Linksys WPC11 Version 3 */
394 PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), /* Compaq HNW-100 11 Mbps Wireless Adapter */
395 PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0673), /* Linksys WCF12 Wireless CompactFlash Card */
396 PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), /* ASUS SpaceLink WL-100 */ 385 PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), /* ASUS SpaceLink WL-100 */
397 PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x0002), /* SpeedStream SS1021 Wireless Adapter */ 386 PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x0002), /* SpeedStream SS1021 Wireless Adapter */
398 PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x3021), /* SpeedStream Wireless Adapter */ 387 PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x3021), /* SpeedStream Wireless Adapter */
399 PCMCIA_DEVICE_MANF_CARD(0x14ea, 0xb001), /* PLANEX RoadLannerWave GW-NS11H */ 388 PCMCIA_DEVICE_MANF_CARD(0x14ea, 0xb001), /* PLANEX RoadLannerWave GW-NS11H */
389 PCMCIA_DEVICE_PROD_ID12("3Com", "3CRWE737A AirConnect Wireless LAN PC Card", 0x41240e5b, 0x56010af3),
390 PCMCIA_DEVICE_PROD_ID12("Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio", 0x5cd01705, 0x4271660f),
391 PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11B_CF_CARD_25", 0x78fc06ee, 0x45a50c1e),
392 PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11b_PC_CARD_25", 0x78fc06ee, 0xdb9aa842),
393 PCMCIA_DEVICE_PROD_ID12("Avaya Communication", "Avaya Wireless PC Card", 0xd8a43b78, 0x0d341169),
394 PCMCIA_DEVICE_PROD_ID12("BENQ", "AWL100 PCMCIA ADAPTER", 0x35dadc74, 0x01f7fedb),
395 PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90),
396 PCMCIA_DEVICE_PROD_ID12("D-Link Corporation", "D-Link DWL-650H 11Mbps WLAN Adapter", 0xef544d24, 0xcd8ea916),
397 PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3),
398 PCMCIA_DEVICE_PROD_ID12("HyperLink", "Wireless PC Card 11Mbps", 0x56cc3f1a, 0x0bcf220c),
399 PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless 2011 LAN PC Card", 0x816cc815, 0x07f58077),
400 PCMCIA_DEVICE_PROD_ID12("LeArtery", "SYNCBYAIR 11Mbps Wireless LAN PC Card", 0x7e3b326a, 0x49893e92),
401 PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/IEEE", 0x23eb9949, 0xc562e72a),
402 PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11", 0x481e0094, 0x7360e410),
403 PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11G", 0x481e0094, 0xf57ca4b3),
404 PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/IEEE", 0x24358cd4, 0xc562e72a),
405 PCMCIA_DEVICE_PROD_ID12("Nortel Networks", "emobility 802.11 Wireless LAN PC Card", 0x2d617ea0, 0x88cd5767),
406 PCMCIA_DEVICE_PROD_ID12("OTC", "Wireless AirEZY 2411-PCC WLAN Card", 0x4ac44287, 0x235a6bed),
407 PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PC CARD HARMONY 80211B", 0xc6536a5e, 0x090c3cd9),
408 PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PCI CARD HARMONY 80211B", 0xc6536a5e, 0x9f494e26),
409 PCMCIA_DEVICE_PROD_ID12("SAMSUNG", "11Mbps WLAN Card", 0x43d74cb4, 0x579bd91b),
410 PCMCIA_DEVICE_PROD_ID12("Symbol Technologies", "LA4111 Spectrum24 Wireless LAN PC Card", 0x3f02b4d6, 0x3663cb0e),
411#ifdef CONFIG_HERMES_PRISM
412 /* Only entries that certainly identify Prism chipset */
413 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), /* SonicWALL Long Range Wireless Card */
414 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), /* Sohoware NCP110, Philips 802.11b */
415 PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0002), /* AnyPoint(TM) Wireless II PC Card */
416 PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000), /* PROXIM RangeLAN-DS/LAN PC CARD */
417 PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), /* Compaq WL100 11 Mbps Wireless Adapter */
418 PCMCIA_DEVICE_MANF_CARD(0x01ff, 0x0008), /* Intermec MobileLAN 11Mbps 802.11b WLAN Card */
419 PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), /* Samsung SWL2000-N 11Mb/s WLAN Card */
420 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), /* Linksys WPC11 Version 2.5 */
421 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), /* Linksys WPC11 Version 3 */
422 PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), /* Compaq HNW-100 11 Mbps Wireless Adapter */
423 PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0673), /* Linksys WCF12 Wireless CompactFlash Card */
400 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), /* Airvast WN-100 */ 424 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), /* Airvast WN-100 */
401 PCMCIA_DEVICE_MANF_CARD(0x9005, 0x0021), /* Adaptec Ultra Wireless ANW-8030 */ 425 PCMCIA_DEVICE_MANF_CARD(0x9005, 0x0021), /* Adaptec Ultra Wireless ANW-8030 */
402 PCMCIA_DEVICE_MANF_CARD(0xc001, 0x0008), /* CONTEC FLEXSCAN/FX-DDS110-PCC */ 426 PCMCIA_DEVICE_MANF_CARD(0xc001, 0x0008), /* CONTEC FLEXSCAN/FX-DDS110-PCC */
403 PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002), /* Conceptronic CON11Cpro, EMTAC A2424i */ 427 PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002), /* Conceptronic CON11Cpro, EMTAC A2424i */
404 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), /* Safeway 802.11b, ZCOMAX AirRunner/XI-300 */ 428 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), /* Safeway 802.11b, ZCOMAX AirRunner/XI-300 */
405 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), /* D-Link DCF660, Sandisk Connect SDWCFB-000 */ 429 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), /* D-Link DCF660, Sandisk Connect SDWCFB-000 */
406 PCMCIA_DEVICE_PROD_ID12(" ", "IEEE 802.11 Wireless LAN/PC Card", 0x3b6e20c8, 0xefccafe9), 430 PCMCIA_DEVICE_PROD_ID123("Instant Wireless ", " Network PC CARD", "Version 01.02", 0x11d901af, 0x6e9bd926, 0x4b74baa0),
407 PCMCIA_DEVICE_PROD_ID12("3Com", "3CRWE737A AirConnect Wireless LAN PC Card", 0x41240e5b, 0x56010af3),
408 PCMCIA_DEVICE_PROD_ID12("ACTIONTEC", "PRISM Wireless LAN PC Card", 0x393089da, 0xa71e69d5), 431 PCMCIA_DEVICE_PROD_ID12("ACTIONTEC", "PRISM Wireless LAN PC Card", 0x393089da, 0xa71e69d5),
409 PCMCIA_DEVICE_PROD_ID12("Addtron", "AWP-100 Wireless PCMCIA", 0xe6ec52ce, 0x08649af2), 432 PCMCIA_DEVICE_PROD_ID12("Addtron", "AWP-100 Wireless PCMCIA", 0xe6ec52ce, 0x08649af2),
410 PCMCIA_DEVICE_PROD_ID12("Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio", 0x5cd01705, 0x4271660f),
411 PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11b_PC_CARD_25", 0x78fc06ee, 0xdb9aa842),
412 PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11B_CF_CARD_25", 0x78fc06ee, 0x45a50c1e),
413 PCMCIA_DEVICE_PROD_ID12("Avaya Communication", "Avaya Wireless PC Card", 0xd8a43b78, 0x0d341169),
414 PCMCIA_DEVICE_PROD_ID12("BENQ", "AWL100 PCMCIA ADAPTER", 0x35dadc74, 0x01f7fedb),
415 PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-PCM-L11G", 0x2decece3, 0xf57ca4b3),
416 PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G", 0x2decece3, 0x82067c18), 433 PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G", 0x2decece3, 0x82067c18),
417 PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90), 434 PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-PCM-L11G", 0x2decece3, 0xf57ca4b3),
418 PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card", 0x54f7c49c, 0x15a75e5b), 435 PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card", 0x54f7c49c, 0x15a75e5b),
419 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584), 436 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584),
420 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9), 437 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9),
421 PCMCIA_DEVICE_PROD_ID12("corega_K.K.", "Wireless_LAN_PCCB-11", 0x29e33311, 0xee7a27ae), 438 PCMCIA_DEVICE_PROD_ID12("corega_K.K.", "Wireless_LAN_PCCB-11", 0x29e33311, 0xee7a27ae),
439 PCMCIA_DEVICE_PROD_ID12("Digital Data Communications", "WPC-0100", 0xfdd73470, 0xe0b6f146),
422 PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac), 440 PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac),
423 PCMCIA_DEVICE_PROD_ID12("D", "Link DWL-650 11Mbps WLAN Card", 0x71b18589, 0xb6f1b0ab), 441 PCMCIA_DEVICE_PROD_ID12("D", "Link DWL-650 11Mbps WLAN Card", 0x71b18589, 0xb6f1b0ab),
424 PCMCIA_DEVICE_PROD_ID12("D-Link Corporation", "D-Link DWL-650H 11Mbps WLAN Adapter", 0xef544d24, 0xcd8ea916), 442 PCMCIA_DEVICE_PROD_ID12(" ", "IEEE 802.11 Wireless LAN/PC Card", 0x3b6e20c8, 0xefccafe9),
425 PCMCIA_DEVICE_PROD_ID12("Digital Data Communications", "WPC-0100", 0xfdd73470, 0xe0b6f146),
426 PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3),
427 PCMCIA_DEVICE_PROD_ID12("HyperLink", "Wireless PC Card 11Mbps", 0x56cc3f1a, 0x0bcf220c),
428 PCMCIA_DEVICE_PROD_ID123("Instant Wireless ", " Network PC CARD", "Version 01.02", 0x11d901af, 0x6e9bd926, 0x4b74baa0),
429 PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless 2011 LAN PC Card", 0x816cc815, 0x07f58077),
430 PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18), 443 PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18),
431 PCMCIA_DEVICE_PROD_ID12("INTERSIL", "I-GATE 11M PC Card / PC Card plus", 0x74c5e40d, 0x8304ff77), 444 PCMCIA_DEVICE_PROD_ID12("INTERSIL", "I-GATE 11M PC Card / PC Card plus", 0x74c5e40d, 0x8304ff77),
432 PCMCIA_DEVICE_PROD_ID12("Intersil", "PRISM 2_5 PCMCIA ADAPTER", 0x4b801a17, 0x6345a0bf), 445 PCMCIA_DEVICE_PROD_ID12("Intersil", "PRISM 2_5 PCMCIA ADAPTER", 0x4b801a17, 0x6345a0bf),
433 PCMCIA_DEVICE_PROD_ID12("LeArtery", "SYNCBYAIR 11Mbps Wireless LAN PC Card", 0x7e3b326a, 0x49893e92),
434 PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card", 0x0733cc81, 0x0c52f395), 446 PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card", 0x0733cc81, 0x0c52f395),
435 PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/IEEE", 0x23eb9949, 0xc562e72a),
436 PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11", 0x481e0094, 0x7360e410),
437 PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11G", 0x481e0094, 0xf57ca4b3),
438 PCMCIA_DEVICE_PROD_ID12("Microsoft", "Wireless Notebook Adapter MN-520", 0x5961bf85, 0x6eec8c01), 447 PCMCIA_DEVICE_PROD_ID12("Microsoft", "Wireless Notebook Adapter MN-520", 0x5961bf85, 0x6eec8c01),
439 PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/IEEE", 0x24358cd4, 0xc562e72a),
440 PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401 Wireless PC", "Card", 0xa37434e9, 0x9762e8f1),
441 PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401RA Wireless PC", "Card", 0x0306467f, 0x9762e8f1), 448 PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401RA Wireless PC", "Card", 0x0306467f, 0x9762e8f1),
442 PCMCIA_DEVICE_PROD_ID12("Nortel Networks", "emobility 802.11 Wireless LAN PC Card", 0x2d617ea0, 0x88cd5767), 449 PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401 Wireless PC", "Card", 0xa37434e9, 0x9762e8f1),
443 PCMCIA_DEVICE_PROD_ID12("OEM", "PRISM2 IEEE 802.11 PC-Card", 0xfea54c90, 0x48f2bdd6), 450 PCMCIA_DEVICE_PROD_ID12("OEM", "PRISM2 IEEE 802.11 PC-Card", 0xfea54c90, 0x48f2bdd6),
444 PCMCIA_DEVICE_PROD_ID12("OTC", "Wireless AirEZY 2411-PCC WLAN Card", 0x4ac44287, 0x235a6bed),
445 PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-CF110", 0x209f40ab, 0xd9715264), 451 PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-CF110", 0x209f40ab, 0xd9715264),
446 PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-NS110", 0x209f40ab, 0x46263178), 452 PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-NS110", 0x209f40ab, 0x46263178),
447 PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PC CARD HARMONY 80211B", 0xc6536a5e, 0x090c3cd9),
448 PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PCI CARD HARMONY 80211B", 0xc6536a5e, 0x9f494e26),
449 PCMCIA_DEVICE_PROD_ID12("SAMSUNG", "11Mbps WLAN Card", 0x43d74cb4, 0x579bd91b),
450 PCMCIA_DEVICE_PROD_ID12("SMC", "SMC2532W-B EliteConnect Wireless Adapter", 0xc4f8b18b, 0x196bd757), 453 PCMCIA_DEVICE_PROD_ID12("SMC", "SMC2532W-B EliteConnect Wireless Adapter", 0xc4f8b18b, 0x196bd757),
451 PCMCIA_DEVICE_PROD_ID12("SMC", "SMC2632W", 0xc4f8b18b, 0x474a1f2a), 454 PCMCIA_DEVICE_PROD_ID12("SMC", "SMC2632W", 0xc4f8b18b, 0x474a1f2a),
452 PCMCIA_DEVICE_PROD_ID12("Symbol Technologies", "LA4111 Spectrum24 Wireless LAN PC Card", 0x3f02b4d6, 0x3663cb0e),
453 PCMCIA_DEVICE_PROD_ID12("ZoomAir 11Mbps High", "Rate wireless Networking", 0x273fe3db, 0x32a1eaee), 455 PCMCIA_DEVICE_PROD_ID12("ZoomAir 11Mbps High", "Rate wireless Networking", 0x273fe3db, 0x32a1eaee),
454 PCMCIA_DEVICE_PROD_ID3("HFA3863", 0x355cb092), 456 PCMCIA_DEVICE_PROD_ID3("HFA3863", 0x355cb092),
455 PCMCIA_DEVICE_PROD_ID3("ISL37100P", 0x630d52b2), 457 PCMCIA_DEVICE_PROD_ID3("ISL37100P", 0x630d52b2),
456 PCMCIA_DEVICE_PROD_ID3("ISL37101P-10", 0xdd97a26b), 458 PCMCIA_DEVICE_PROD_ID3("ISL37101P-10", 0xdd97a26b),
457 PCMCIA_DEVICE_PROD_ID3("ISL37300P", 0xc9049a39), 459 PCMCIA_DEVICE_PROD_ID3("ISL37300P", 0xc9049a39),
460#endif
458 PCMCIA_DEVICE_NULL, 461 PCMCIA_DEVICE_NULL,
459}; 462};
460MODULE_DEVICE_TABLE(pcmcia, orinoco_cs_ids); 463MODULE_DEVICE_TABLE(pcmcia, orinoco_cs_ids);
diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c
index 31ca241f7753..29f9bc03190a 100644
--- a/drivers/net/wireless/orinoco/wext.c
+++ b/drivers/net/wireless/orinoco/wext.c
@@ -1505,46 +1505,44 @@ static const struct iw_priv_args orinoco_privtab[] = {
1505 * Structures to export the Wireless Handlers 1505 * Structures to export the Wireless Handlers
1506 */ 1506 */
1507 1507
1508#define STD_IW_HANDLER(id, func) \
1509 [IW_IOCTL_IDX(id)] = (iw_handler) func
1510static const iw_handler orinoco_handler[] = { 1508static const iw_handler orinoco_handler[] = {
1511 STD_IW_HANDLER(SIOCSIWCOMMIT, orinoco_ioctl_commit), 1509 IW_HANDLER(SIOCSIWCOMMIT, (iw_handler)orinoco_ioctl_commit),
1512 STD_IW_HANDLER(SIOCGIWNAME, cfg80211_wext_giwname), 1510 IW_HANDLER(SIOCGIWNAME, (iw_handler)cfg80211_wext_giwname),
1513 STD_IW_HANDLER(SIOCSIWFREQ, orinoco_ioctl_setfreq), 1511 IW_HANDLER(SIOCSIWFREQ, (iw_handler)orinoco_ioctl_setfreq),
1514 STD_IW_HANDLER(SIOCGIWFREQ, orinoco_ioctl_getfreq), 1512 IW_HANDLER(SIOCGIWFREQ, (iw_handler)orinoco_ioctl_getfreq),
1515 STD_IW_HANDLER(SIOCSIWMODE, cfg80211_wext_siwmode), 1513 IW_HANDLER(SIOCSIWMODE, (iw_handler)cfg80211_wext_siwmode),
1516 STD_IW_HANDLER(SIOCGIWMODE, cfg80211_wext_giwmode), 1514 IW_HANDLER(SIOCGIWMODE, (iw_handler)cfg80211_wext_giwmode),
1517 STD_IW_HANDLER(SIOCSIWSENS, orinoco_ioctl_setsens), 1515 IW_HANDLER(SIOCSIWSENS, (iw_handler)orinoco_ioctl_setsens),
1518 STD_IW_HANDLER(SIOCGIWSENS, orinoco_ioctl_getsens), 1516 IW_HANDLER(SIOCGIWSENS, (iw_handler)orinoco_ioctl_getsens),
1519 STD_IW_HANDLER(SIOCGIWRANGE, cfg80211_wext_giwrange), 1517 IW_HANDLER(SIOCGIWRANGE, (iw_handler)cfg80211_wext_giwrange),
1520 STD_IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy), 1518 IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy),
1521 STD_IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy), 1519 IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy),
1522 STD_IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy), 1520 IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy),
1523 STD_IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy), 1521 IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy),
1524 STD_IW_HANDLER(SIOCSIWAP, orinoco_ioctl_setwap), 1522 IW_HANDLER(SIOCSIWAP, (iw_handler)orinoco_ioctl_setwap),
1525 STD_IW_HANDLER(SIOCGIWAP, orinoco_ioctl_getwap), 1523 IW_HANDLER(SIOCGIWAP, (iw_handler)orinoco_ioctl_getwap),
1526 STD_IW_HANDLER(SIOCSIWSCAN, cfg80211_wext_siwscan), 1524 IW_HANDLER(SIOCSIWSCAN, (iw_handler)cfg80211_wext_siwscan),
1527 STD_IW_HANDLER(SIOCGIWSCAN, cfg80211_wext_giwscan), 1525 IW_HANDLER(SIOCGIWSCAN, (iw_handler)cfg80211_wext_giwscan),
1528 STD_IW_HANDLER(SIOCSIWESSID, orinoco_ioctl_setessid), 1526 IW_HANDLER(SIOCSIWESSID, (iw_handler)orinoco_ioctl_setessid),
1529 STD_IW_HANDLER(SIOCGIWESSID, orinoco_ioctl_getessid), 1527 IW_HANDLER(SIOCGIWESSID, (iw_handler)orinoco_ioctl_getessid),
1530 STD_IW_HANDLER(SIOCSIWRATE, orinoco_ioctl_setrate), 1528 IW_HANDLER(SIOCSIWRATE, (iw_handler)orinoco_ioctl_setrate),
1531 STD_IW_HANDLER(SIOCGIWRATE, orinoco_ioctl_getrate), 1529 IW_HANDLER(SIOCGIWRATE, (iw_handler)orinoco_ioctl_getrate),
1532 STD_IW_HANDLER(SIOCSIWRTS, orinoco_ioctl_setrts), 1530 IW_HANDLER(SIOCSIWRTS, (iw_handler)orinoco_ioctl_setrts),
1533 STD_IW_HANDLER(SIOCGIWRTS, orinoco_ioctl_getrts), 1531 IW_HANDLER(SIOCGIWRTS, (iw_handler)orinoco_ioctl_getrts),
1534 STD_IW_HANDLER(SIOCSIWFRAG, orinoco_ioctl_setfrag), 1532 IW_HANDLER(SIOCSIWFRAG, (iw_handler)orinoco_ioctl_setfrag),
1535 STD_IW_HANDLER(SIOCGIWFRAG, orinoco_ioctl_getfrag), 1533 IW_HANDLER(SIOCGIWFRAG, (iw_handler)orinoco_ioctl_getfrag),
1536 STD_IW_HANDLER(SIOCGIWRETRY, orinoco_ioctl_getretry), 1534 IW_HANDLER(SIOCGIWRETRY, (iw_handler)orinoco_ioctl_getretry),
1537 STD_IW_HANDLER(SIOCSIWENCODE, orinoco_ioctl_setiwencode), 1535 IW_HANDLER(SIOCSIWENCODE, (iw_handler)orinoco_ioctl_setiwencode),
1538 STD_IW_HANDLER(SIOCGIWENCODE, orinoco_ioctl_getiwencode), 1536 IW_HANDLER(SIOCGIWENCODE, (iw_handler)orinoco_ioctl_getiwencode),
1539 STD_IW_HANDLER(SIOCSIWPOWER, orinoco_ioctl_setpower), 1537 IW_HANDLER(SIOCSIWPOWER, (iw_handler)orinoco_ioctl_setpower),
1540 STD_IW_HANDLER(SIOCGIWPOWER, orinoco_ioctl_getpower), 1538 IW_HANDLER(SIOCGIWPOWER, (iw_handler)orinoco_ioctl_getpower),
1541 STD_IW_HANDLER(SIOCSIWGENIE, orinoco_ioctl_set_genie), 1539 IW_HANDLER(SIOCSIWGENIE, orinoco_ioctl_set_genie),
1542 STD_IW_HANDLER(SIOCGIWGENIE, orinoco_ioctl_get_genie), 1540 IW_HANDLER(SIOCGIWGENIE, orinoco_ioctl_get_genie),
1543 STD_IW_HANDLER(SIOCSIWMLME, orinoco_ioctl_set_mlme), 1541 IW_HANDLER(SIOCSIWMLME, orinoco_ioctl_set_mlme),
1544 STD_IW_HANDLER(SIOCSIWAUTH, orinoco_ioctl_set_auth), 1542 IW_HANDLER(SIOCSIWAUTH, orinoco_ioctl_set_auth),
1545 STD_IW_HANDLER(SIOCGIWAUTH, orinoco_ioctl_get_auth), 1543 IW_HANDLER(SIOCGIWAUTH, orinoco_ioctl_get_auth),
1546 STD_IW_HANDLER(SIOCSIWENCODEEXT, orinoco_ioctl_set_encodeext), 1544 IW_HANDLER(SIOCSIWENCODEEXT, orinoco_ioctl_set_encodeext),
1547 STD_IW_HANDLER(SIOCGIWENCODEEXT, orinoco_ioctl_get_encodeext), 1545 IW_HANDLER(SIOCGIWENCODEEXT, orinoco_ioctl_get_encodeext),
1548}; 1546};
1549 1547
1550 1548
@@ -1552,15 +1550,15 @@ static const iw_handler orinoco_handler[] = {
1552 Added typecasting since we no longer use iwreq_data -- Moustafa 1550 Added typecasting since we no longer use iwreq_data -- Moustafa
1553 */ 1551 */
1554static const iw_handler orinoco_private_handler[] = { 1552static const iw_handler orinoco_private_handler[] = {
1555 [0] = (iw_handler) orinoco_ioctl_reset, 1553 [0] = (iw_handler)orinoco_ioctl_reset,
1556 [1] = (iw_handler) orinoco_ioctl_reset, 1554 [1] = (iw_handler)orinoco_ioctl_reset,
1557 [2] = (iw_handler) orinoco_ioctl_setport3, 1555 [2] = (iw_handler)orinoco_ioctl_setport3,
1558 [3] = (iw_handler) orinoco_ioctl_getport3, 1556 [3] = (iw_handler)orinoco_ioctl_getport3,
1559 [4] = (iw_handler) orinoco_ioctl_setpreamble, 1557 [4] = (iw_handler)orinoco_ioctl_setpreamble,
1560 [5] = (iw_handler) orinoco_ioctl_getpreamble, 1558 [5] = (iw_handler)orinoco_ioctl_getpreamble,
1561 [6] = (iw_handler) orinoco_ioctl_setibssport, 1559 [6] = (iw_handler)orinoco_ioctl_setibssport,
1562 [7] = (iw_handler) orinoco_ioctl_getibssport, 1560 [7] = (iw_handler)orinoco_ioctl_getibssport,
1563 [9] = (iw_handler) orinoco_ioctl_getrid, 1561 [9] = (iw_handler)orinoco_ioctl_getrid,
1564}; 1562};
1565 1563
1566const struct iw_handler_def orinoco_handler_def = { 1564const struct iw_handler_def orinoco_handler_def = {
diff --git a/drivers/net/wireless/p54/main.c b/drivers/net/wireless/p54/main.c
index 4f752a21495f..36f4c820ad01 100644
--- a/drivers/net/wireless/p54/main.c
+++ b/drivers/net/wireless/p54/main.c
@@ -545,6 +545,7 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
545 IEEE80211_HW_SUPPORTS_PS | 545 IEEE80211_HW_SUPPORTS_PS |
546 IEEE80211_HW_PS_NULLFUNC_STACK | 546 IEEE80211_HW_PS_NULLFUNC_STACK |
547 IEEE80211_HW_BEACON_FILTER | 547 IEEE80211_HW_BEACON_FILTER |
548 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
548 IEEE80211_HW_NOISE_DBM; 549 IEEE80211_HW_NOISE_DBM;
549 550
550 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | 551 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 84c530aa52f9..54680a3a5acb 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -1113,10 +1113,10 @@ static const struct ethtool_ops netdev_ethtool_ops = {
1113/* 1113/*
1114 * Wireless Handler : get protocol name 1114 * Wireless Handler : get protocol name
1115 */ 1115 */
1116static int ray_get_name(struct net_device *dev, 1116static int ray_get_name(struct net_device *dev, struct iw_request_info *info,
1117 struct iw_request_info *info, char *cwrq, char *extra) 1117 union iwreq_data *wrqu, char *extra)
1118{ 1118{
1119 strcpy(cwrq, "IEEE 802.11-FH"); 1119 strcpy(wrqu->name, "IEEE 802.11-FH");
1120 return 0; 1120 return 0;
1121} 1121}
1122 1122
@@ -1124,9 +1124,8 @@ static int ray_get_name(struct net_device *dev,
1124/* 1124/*
1125 * Wireless Handler : set frequency 1125 * Wireless Handler : set frequency
1126 */ 1126 */
1127static int ray_set_freq(struct net_device *dev, 1127static int ray_set_freq(struct net_device *dev, struct iw_request_info *info,
1128 struct iw_request_info *info, 1128 union iwreq_data *wrqu, char *extra)
1129 struct iw_freq *fwrq, char *extra)
1130{ 1129{
1131 ray_dev_t *local = netdev_priv(dev); 1130 ray_dev_t *local = netdev_priv(dev);
1132 int err = -EINPROGRESS; /* Call commit handler */ 1131 int err = -EINPROGRESS; /* Call commit handler */
@@ -1136,10 +1135,10 @@ static int ray_set_freq(struct net_device *dev,
1136 return -EBUSY; 1135 return -EBUSY;
1137 1136
1138 /* Setting by channel number */ 1137 /* Setting by channel number */
1139 if ((fwrq->m > USA_HOP_MOD) || (fwrq->e > 0)) 1138 if ((wrqu->freq.m > USA_HOP_MOD) || (wrqu->freq.e > 0))
1140 err = -EOPNOTSUPP; 1139 err = -EOPNOTSUPP;
1141 else 1140 else
1142 local->sparm.b5.a_hop_pattern = fwrq->m; 1141 local->sparm.b5.a_hop_pattern = wrqu->freq.m;
1143 1142
1144 return err; 1143 return err;
1145} 1144}
@@ -1148,14 +1147,13 @@ static int ray_set_freq(struct net_device *dev,
1148/* 1147/*
1149 * Wireless Handler : get frequency 1148 * Wireless Handler : get frequency
1150 */ 1149 */
1151static int ray_get_freq(struct net_device *dev, 1150static int ray_get_freq(struct net_device *dev, struct iw_request_info *info,
1152 struct iw_request_info *info, 1151 union iwreq_data *wrqu, char *extra)
1153 struct iw_freq *fwrq, char *extra)
1154{ 1152{
1155 ray_dev_t *local = netdev_priv(dev); 1153 ray_dev_t *local = netdev_priv(dev);
1156 1154
1157 fwrq->m = local->sparm.b5.a_hop_pattern; 1155 wrqu->freq.m = local->sparm.b5.a_hop_pattern;
1158 fwrq->e = 0; 1156 wrqu->freq.e = 0;
1159 return 0; 1157 return 0;
1160} 1158}
1161 1159
@@ -1163,9 +1161,8 @@ static int ray_get_freq(struct net_device *dev,
1163/* 1161/*
1164 * Wireless Handler : set ESSID 1162 * Wireless Handler : set ESSID
1165 */ 1163 */
1166static int ray_set_essid(struct net_device *dev, 1164static int ray_set_essid(struct net_device *dev, struct iw_request_info *info,
1167 struct iw_request_info *info, 1165 union iwreq_data *wrqu, char *extra)
1168 struct iw_point *dwrq, char *extra)
1169{ 1166{
1170 ray_dev_t *local = netdev_priv(dev); 1167 ray_dev_t *local = netdev_priv(dev);
1171 1168
@@ -1174,19 +1171,17 @@ static int ray_set_essid(struct net_device *dev,
1174 return -EBUSY; 1171 return -EBUSY;
1175 1172
1176 /* Check if we asked for `any' */ 1173 /* Check if we asked for `any' */
1177 if (dwrq->flags == 0) { 1174 if (wrqu->essid.flags == 0)
1178 /* Corey : can you do that ? */ 1175 /* Corey : can you do that ? */
1179 return -EOPNOTSUPP; 1176 return -EOPNOTSUPP;
1180 } else {
1181 /* Check the size of the string */
1182 if (dwrq->length > IW_ESSID_MAX_SIZE) {
1183 return -E2BIG;
1184 }
1185 1177
1186 /* Set the ESSID in the card */ 1178 /* Check the size of the string */
1187 memset(local->sparm.b5.a_current_ess_id, 0, IW_ESSID_MAX_SIZE); 1179 if (wrqu->essid.length > IW_ESSID_MAX_SIZE)
1188 memcpy(local->sparm.b5.a_current_ess_id, extra, dwrq->length); 1180 return -E2BIG;
1189 } 1181
1182 /* Set the ESSID in the card */
1183 memset(local->sparm.b5.a_current_ess_id, 0, IW_ESSID_MAX_SIZE);
1184 memcpy(local->sparm.b5.a_current_ess_id, extra, wrqu->essid.length);
1190 1185
1191 return -EINPROGRESS; /* Call commit handler */ 1186 return -EINPROGRESS; /* Call commit handler */
1192} 1187}
@@ -1195,9 +1190,8 @@ static int ray_set_essid(struct net_device *dev,
1195/* 1190/*
1196 * Wireless Handler : get ESSID 1191 * Wireless Handler : get ESSID
1197 */ 1192 */
1198static int ray_get_essid(struct net_device *dev, 1193static int ray_get_essid(struct net_device *dev, struct iw_request_info *info,
1199 struct iw_request_info *info, 1194 union iwreq_data *wrqu, char *extra)
1200 struct iw_point *dwrq, char *extra)
1201{ 1195{
1202 ray_dev_t *local = netdev_priv(dev); 1196 ray_dev_t *local = netdev_priv(dev);
1203 1197
@@ -1205,8 +1199,8 @@ static int ray_get_essid(struct net_device *dev,
1205 memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE); 1199 memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE);
1206 1200
1207 /* Push it out ! */ 1201 /* Push it out ! */
1208 dwrq->length = strlen(extra); 1202 wrqu->essid.length = strlen(extra);
1209 dwrq->flags = 1; /* active */ 1203 wrqu->essid.flags = 1; /* active */
1210 1204
1211 return 0; 1205 return 0;
1212} 1206}
@@ -1215,14 +1209,13 @@ static int ray_get_essid(struct net_device *dev,
1215/* 1209/*
1216 * Wireless Handler : get AP address 1210 * Wireless Handler : get AP address
1217 */ 1211 */
1218static int ray_get_wap(struct net_device *dev, 1212static int ray_get_wap(struct net_device *dev, struct iw_request_info *info,
1219 struct iw_request_info *info, 1213 union iwreq_data *wrqu, char *extra)
1220 struct sockaddr *awrq, char *extra)
1221{ 1214{
1222 ray_dev_t *local = netdev_priv(dev); 1215 ray_dev_t *local = netdev_priv(dev);
1223 1216
1224 memcpy(awrq->sa_data, local->bss_id, ETH_ALEN); 1217 memcpy(wrqu->ap_addr.sa_data, local->bss_id, ETH_ALEN);
1225 awrq->sa_family = ARPHRD_ETHER; 1218 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
1226 1219
1227 return 0; 1220 return 0;
1228} 1221}
@@ -1231,9 +1224,8 @@ static int ray_get_wap(struct net_device *dev,
1231/* 1224/*
1232 * Wireless Handler : set Bit-Rate 1225 * Wireless Handler : set Bit-Rate
1233 */ 1226 */
1234static int ray_set_rate(struct net_device *dev, 1227static int ray_set_rate(struct net_device *dev, struct iw_request_info *info,
1235 struct iw_request_info *info, 1228 union iwreq_data *wrqu, char *extra)
1236 struct iw_param *vwrq, char *extra)
1237{ 1229{
1238 ray_dev_t *local = netdev_priv(dev); 1230 ray_dev_t *local = netdev_priv(dev);
1239 1231
@@ -1242,15 +1234,15 @@ static int ray_set_rate(struct net_device *dev,
1242 return -EBUSY; 1234 return -EBUSY;
1243 1235
1244 /* Check if rate is in range */ 1236 /* Check if rate is in range */
1245 if ((vwrq->value != 1000000) && (vwrq->value != 2000000)) 1237 if ((wrqu->bitrate.value != 1000000) && (wrqu->bitrate.value != 2000000))
1246 return -EINVAL; 1238 return -EINVAL;
1247 1239
1248 /* Hack for 1.5 Mb/s instead of 2 Mb/s */ 1240 /* Hack for 1.5 Mb/s instead of 2 Mb/s */
1249 if ((local->fw_ver == 0x55) && /* Please check */ 1241 if ((local->fw_ver == 0x55) && /* Please check */
1250 (vwrq->value == 2000000)) 1242 (wrqu->bitrate.value == 2000000))
1251 local->net_default_tx_rate = 3; 1243 local->net_default_tx_rate = 3;
1252 else 1244 else
1253 local->net_default_tx_rate = vwrq->value / 500000; 1245 local->net_default_tx_rate = wrqu->bitrate.value / 500000;
1254 1246
1255 return 0; 1247 return 0;
1256} 1248}
@@ -1259,17 +1251,16 @@ static int ray_set_rate(struct net_device *dev,
1259/* 1251/*
1260 * Wireless Handler : get Bit-Rate 1252 * Wireless Handler : get Bit-Rate
1261 */ 1253 */
1262static int ray_get_rate(struct net_device *dev, 1254static int ray_get_rate(struct net_device *dev, struct iw_request_info *info,
1263 struct iw_request_info *info, 1255 union iwreq_data *wrqu, char *extra)
1264 struct iw_param *vwrq, char *extra)
1265{ 1256{
1266 ray_dev_t *local = netdev_priv(dev); 1257 ray_dev_t *local = netdev_priv(dev);
1267 1258
1268 if (local->net_default_tx_rate == 3) 1259 if (local->net_default_tx_rate == 3)
1269 vwrq->value = 2000000; /* Hum... */ 1260 wrqu->bitrate.value = 2000000; /* Hum... */
1270 else 1261 else
1271 vwrq->value = local->net_default_tx_rate * 500000; 1262 wrqu->bitrate.value = local->net_default_tx_rate * 500000;
1272 vwrq->fixed = 0; /* We are in auto mode */ 1263 wrqu->bitrate.fixed = 0; /* We are in auto mode */
1273 1264
1274 return 0; 1265 return 0;
1275} 1266}
@@ -1278,19 +1269,18 @@ static int ray_get_rate(struct net_device *dev,
1278/* 1269/*
1279 * Wireless Handler : set RTS threshold 1270 * Wireless Handler : set RTS threshold
1280 */ 1271 */
1281static int ray_set_rts(struct net_device *dev, 1272static int ray_set_rts(struct net_device *dev, struct iw_request_info *info,
1282 struct iw_request_info *info, 1273 union iwreq_data *wrqu, char *extra)
1283 struct iw_param *vwrq, char *extra)
1284{ 1274{
1285 ray_dev_t *local = netdev_priv(dev); 1275 ray_dev_t *local = netdev_priv(dev);
1286 int rthr = vwrq->value; 1276 int rthr = wrqu->rts.value;
1287 1277
1288 /* Reject if card is already initialised */ 1278 /* Reject if card is already initialised */
1289 if (local->card_status != CARD_AWAITING_PARAM) 1279 if (local->card_status != CARD_AWAITING_PARAM)
1290 return -EBUSY; 1280 return -EBUSY;
1291 1281
1292 /* if(wrq->u.rts.fixed == 0) we should complain */ 1282 /* if(wrq->u.rts.fixed == 0) we should complain */
1293 if (vwrq->disabled) 1283 if (wrqu->rts.disabled)
1294 rthr = 32767; 1284 rthr = 32767;
1295 else { 1285 else {
1296 if ((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */ 1286 if ((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */
@@ -1306,16 +1296,15 @@ static int ray_set_rts(struct net_device *dev,
1306/* 1296/*
1307 * Wireless Handler : get RTS threshold 1297 * Wireless Handler : get RTS threshold
1308 */ 1298 */
1309static int ray_get_rts(struct net_device *dev, 1299static int ray_get_rts(struct net_device *dev, struct iw_request_info *info,
1310 struct iw_request_info *info, 1300 union iwreq_data *wrqu, char *extra)
1311 struct iw_param *vwrq, char *extra)
1312{ 1301{
1313 ray_dev_t *local = netdev_priv(dev); 1302 ray_dev_t *local = netdev_priv(dev);
1314 1303
1315 vwrq->value = (local->sparm.b5.a_rts_threshold[0] << 8) 1304 wrqu->rts.value = (local->sparm.b5.a_rts_threshold[0] << 8)
1316 + local->sparm.b5.a_rts_threshold[1]; 1305 + local->sparm.b5.a_rts_threshold[1];
1317 vwrq->disabled = (vwrq->value == 32767); 1306 wrqu->rts.disabled = (wrqu->rts.value == 32767);
1318 vwrq->fixed = 1; 1307 wrqu->rts.fixed = 1;
1319 1308
1320 return 0; 1309 return 0;
1321} 1310}
@@ -1324,19 +1313,18 @@ static int ray_get_rts(struct net_device *dev,
1324/* 1313/*
1325 * Wireless Handler : set Fragmentation threshold 1314 * Wireless Handler : set Fragmentation threshold
1326 */ 1315 */
1327static int ray_set_frag(struct net_device *dev, 1316static int ray_set_frag(struct net_device *dev, struct iw_request_info *info,
1328 struct iw_request_info *info, 1317 union iwreq_data *wrqu, char *extra)
1329 struct iw_param *vwrq, char *extra)
1330{ 1318{
1331 ray_dev_t *local = netdev_priv(dev); 1319 ray_dev_t *local = netdev_priv(dev);
1332 int fthr = vwrq->value; 1320 int fthr = wrqu->frag.value;
1333 1321
1334 /* Reject if card is already initialised */ 1322 /* Reject if card is already initialised */
1335 if (local->card_status != CARD_AWAITING_PARAM) 1323 if (local->card_status != CARD_AWAITING_PARAM)
1336 return -EBUSY; 1324 return -EBUSY;
1337 1325
1338 /* if(wrq->u.frag.fixed == 0) should complain */ 1326 /* if(wrq->u.frag.fixed == 0) should complain */
1339 if (vwrq->disabled) 1327 if (wrqu->frag.disabled)
1340 fthr = 32767; 1328 fthr = 32767;
1341 else { 1329 else {
1342 if ((fthr < 256) || (fthr > 2347)) /* To check out ! */ 1330 if ((fthr < 256) || (fthr > 2347)) /* To check out ! */
@@ -1352,16 +1340,15 @@ static int ray_set_frag(struct net_device *dev,
1352/* 1340/*
1353 * Wireless Handler : get Fragmentation threshold 1341 * Wireless Handler : get Fragmentation threshold
1354 */ 1342 */
1355static int ray_get_frag(struct net_device *dev, 1343static int ray_get_frag(struct net_device *dev, struct iw_request_info *info,
1356 struct iw_request_info *info, 1344 union iwreq_data *wrqu, char *extra)
1357 struct iw_param *vwrq, char *extra)
1358{ 1345{
1359 ray_dev_t *local = netdev_priv(dev); 1346 ray_dev_t *local = netdev_priv(dev);
1360 1347
1361 vwrq->value = (local->sparm.b5.a_frag_threshold[0] << 8) 1348 wrqu->frag.value = (local->sparm.b5.a_frag_threshold[0] << 8)
1362 + local->sparm.b5.a_frag_threshold[1]; 1349 + local->sparm.b5.a_frag_threshold[1];
1363 vwrq->disabled = (vwrq->value == 32767); 1350 wrqu->frag.disabled = (wrqu->frag.value == 32767);
1364 vwrq->fixed = 1; 1351 wrqu->frag.fixed = 1;
1365 1352
1366 return 0; 1353 return 0;
1367} 1354}
@@ -1370,8 +1357,8 @@ static int ray_get_frag(struct net_device *dev,
1370/* 1357/*
1371 * Wireless Handler : set Mode of Operation 1358 * Wireless Handler : set Mode of Operation
1372 */ 1359 */
1373static int ray_set_mode(struct net_device *dev, 1360static int ray_set_mode(struct net_device *dev, struct iw_request_info *info,
1374 struct iw_request_info *info, __u32 *uwrq, char *extra) 1361 union iwreq_data *wrqu, char *extra)
1375{ 1362{
1376 ray_dev_t *local = netdev_priv(dev); 1363 ray_dev_t *local = netdev_priv(dev);
1377 int err = -EINPROGRESS; /* Call commit handler */ 1364 int err = -EINPROGRESS; /* Call commit handler */
@@ -1381,7 +1368,7 @@ static int ray_set_mode(struct net_device *dev,
1381 if (local->card_status != CARD_AWAITING_PARAM) 1368 if (local->card_status != CARD_AWAITING_PARAM)
1382 return -EBUSY; 1369 return -EBUSY;
1383 1370
1384 switch (*uwrq) { 1371 switch (wrqu->mode) {
1385 case IW_MODE_ADHOC: 1372 case IW_MODE_ADHOC:
1386 card_mode = 0; 1373 card_mode = 0;
1387 /* Fall through */ 1374 /* Fall through */
@@ -1399,15 +1386,15 @@ static int ray_set_mode(struct net_device *dev,
1399/* 1386/*
1400 * Wireless Handler : get Mode of Operation 1387 * Wireless Handler : get Mode of Operation
1401 */ 1388 */
1402static int ray_get_mode(struct net_device *dev, 1389static int ray_get_mode(struct net_device *dev, struct iw_request_info *info,
1403 struct iw_request_info *info, __u32 *uwrq, char *extra) 1390 union iwreq_data *wrqu, char *extra)
1404{ 1391{
1405 ray_dev_t *local = netdev_priv(dev); 1392 ray_dev_t *local = netdev_priv(dev);
1406 1393
1407 if (local->sparm.b5.a_network_type) 1394 if (local->sparm.b5.a_network_type)
1408 *uwrq = IW_MODE_INFRA; 1395 wrqu->mode = IW_MODE_INFRA;
1409 else 1396 else
1410 *uwrq = IW_MODE_ADHOC; 1397 wrqu->mode = IW_MODE_ADHOC;
1411 1398
1412 return 0; 1399 return 0;
1413} 1400}
@@ -1416,16 +1403,15 @@ static int ray_get_mode(struct net_device *dev,
1416/* 1403/*
1417 * Wireless Handler : get range info 1404 * Wireless Handler : get range info
1418 */ 1405 */
1419static int ray_get_range(struct net_device *dev, 1406static int ray_get_range(struct net_device *dev, struct iw_request_info *info,
1420 struct iw_request_info *info, 1407 union iwreq_data *wrqu, char *extra)
1421 struct iw_point *dwrq, char *extra)
1422{ 1408{
1423 struct iw_range *range = (struct iw_range *)extra; 1409 struct iw_range *range = (struct iw_range *)extra;
1424 1410
1425 memset((char *)range, 0, sizeof(struct iw_range)); 1411 memset(range, 0, sizeof(struct iw_range));
1426 1412
1427 /* Set the length (very important for backward compatibility) */ 1413 /* Set the length (very important for backward compatibility) */
1428 dwrq->length = sizeof(struct iw_range); 1414 wrqu->data.length = sizeof(struct iw_range);
1429 1415
1430 /* Set the Wireless Extension versions */ 1416 /* Set the Wireless Extension versions */
1431 range->we_version_compiled = WIRELESS_EXT; 1417 range->we_version_compiled = WIRELESS_EXT;
@@ -1448,8 +1434,7 @@ static int ray_get_range(struct net_device *dev,
1448/* 1434/*
1449 * Wireless Private Handler : set framing mode 1435 * Wireless Private Handler : set framing mode
1450 */ 1436 */
1451static int ray_set_framing(struct net_device *dev, 1437static int ray_set_framing(struct net_device *dev, struct iw_request_info *info,
1452 struct iw_request_info *info,
1453 union iwreq_data *wrqu, char *extra) 1438 union iwreq_data *wrqu, char *extra)
1454{ 1439{
1455 translate = *(extra); /* Set framing mode */ 1440 translate = *(extra); /* Set framing mode */
@@ -1461,8 +1446,7 @@ static int ray_set_framing(struct net_device *dev,
1461/* 1446/*
1462 * Wireless Private Handler : get framing mode 1447 * Wireless Private Handler : get framing mode
1463 */ 1448 */
1464static int ray_get_framing(struct net_device *dev, 1449static int ray_get_framing(struct net_device *dev, struct iw_request_info *info,
1465 struct iw_request_info *info,
1466 union iwreq_data *wrqu, char *extra) 1450 union iwreq_data *wrqu, char *extra)
1467{ 1451{
1468 *(extra) = translate; 1452 *(extra) = translate;
@@ -1474,8 +1458,7 @@ static int ray_get_framing(struct net_device *dev,
1474/* 1458/*
1475 * Wireless Private Handler : get country 1459 * Wireless Private Handler : get country
1476 */ 1460 */
1477static int ray_get_country(struct net_device *dev, 1461static int ray_get_country(struct net_device *dev, struct iw_request_info *info,
1478 struct iw_request_info *info,
1479 union iwreq_data *wrqu, char *extra) 1462 union iwreq_data *wrqu, char *extra)
1480{ 1463{
1481 *(extra) = country; 1464 *(extra) = country;
@@ -1487,10 +1470,9 @@ static int ray_get_country(struct net_device *dev,
1487/* 1470/*
1488 * Commit handler : called after a bunch of SET operations 1471 * Commit handler : called after a bunch of SET operations
1489 */ 1472 */
1490static int ray_commit(struct net_device *dev, struct iw_request_info *info, /* NULL */ 1473static int ray_commit(struct net_device *dev, struct iw_request_info *info,
1491 void *zwrq, /* NULL */ 1474 union iwreq_data *wrqu, char *extra)
1492 char *extra) 1475{
1493{ /* NULL */
1494 return 0; 1476 return 0;
1495} 1477}
1496 1478
@@ -1531,28 +1513,28 @@ static iw_stats *ray_get_wireless_stats(struct net_device *dev)
1531 */ 1513 */
1532 1514
1533static const iw_handler ray_handler[] = { 1515static const iw_handler ray_handler[] = {
1534 [SIOCSIWCOMMIT - SIOCIWFIRST] = (iw_handler) ray_commit, 1516 IW_HANDLER(SIOCSIWCOMMIT, ray_commit),
1535 [SIOCGIWNAME - SIOCIWFIRST] = (iw_handler) ray_get_name, 1517 IW_HANDLER(SIOCGIWNAME, ray_get_name),
1536 [SIOCSIWFREQ - SIOCIWFIRST] = (iw_handler) ray_set_freq, 1518 IW_HANDLER(SIOCSIWFREQ, ray_set_freq),
1537 [SIOCGIWFREQ - SIOCIWFIRST] = (iw_handler) ray_get_freq, 1519 IW_HANDLER(SIOCGIWFREQ, ray_get_freq),
1538 [SIOCSIWMODE - SIOCIWFIRST] = (iw_handler) ray_set_mode, 1520 IW_HANDLER(SIOCSIWMODE, ray_set_mode),
1539 [SIOCGIWMODE - SIOCIWFIRST] = (iw_handler) ray_get_mode, 1521 IW_HANDLER(SIOCGIWMODE, ray_get_mode),
1540 [SIOCGIWRANGE - SIOCIWFIRST] = (iw_handler) ray_get_range, 1522 IW_HANDLER(SIOCGIWRANGE, ray_get_range),
1541#ifdef WIRELESS_SPY 1523#ifdef WIRELESS_SPY
1542 [SIOCSIWSPY - SIOCIWFIRST] = (iw_handler) iw_handler_set_spy, 1524 IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy),
1543 [SIOCGIWSPY - SIOCIWFIRST] = (iw_handler) iw_handler_get_spy, 1525 IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy),
1544 [SIOCSIWTHRSPY - SIOCIWFIRST] = (iw_handler) iw_handler_set_thrspy, 1526 IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy),
1545 [SIOCGIWTHRSPY - SIOCIWFIRST] = (iw_handler) iw_handler_get_thrspy, 1527 IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy),
1546#endif /* WIRELESS_SPY */ 1528#endif /* WIRELESS_SPY */
1547 [SIOCGIWAP - SIOCIWFIRST] = (iw_handler) ray_get_wap, 1529 IW_HANDLER(SIOCGIWAP, ray_get_wap),
1548 [SIOCSIWESSID - SIOCIWFIRST] = (iw_handler) ray_set_essid, 1530 IW_HANDLER(SIOCSIWESSID, ray_set_essid),
1549 [SIOCGIWESSID - SIOCIWFIRST] = (iw_handler) ray_get_essid, 1531 IW_HANDLER(SIOCGIWESSID, ray_get_essid),
1550 [SIOCSIWRATE - SIOCIWFIRST] = (iw_handler) ray_set_rate, 1532 IW_HANDLER(SIOCSIWRATE, ray_set_rate),
1551 [SIOCGIWRATE - SIOCIWFIRST] = (iw_handler) ray_get_rate, 1533 IW_HANDLER(SIOCGIWRATE, ray_get_rate),
1552 [SIOCSIWRTS - SIOCIWFIRST] = (iw_handler) ray_set_rts, 1534 IW_HANDLER(SIOCSIWRTS, ray_set_rts),
1553 [SIOCGIWRTS - SIOCIWFIRST] = (iw_handler) ray_get_rts, 1535 IW_HANDLER(SIOCGIWRTS, ray_get_rts),
1554 [SIOCSIWFRAG - SIOCIWFIRST] = (iw_handler) ray_set_frag, 1536 IW_HANDLER(SIOCSIWFRAG, ray_set_frag),
1555 [SIOCGIWFRAG - SIOCIWFIRST] = (iw_handler) ray_get_frag, 1537 IW_HANDLER(SIOCGIWFRAG, ray_get_frag),
1556}; 1538};
1557 1539
1558#define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */ 1540#define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */
@@ -1560,9 +1542,9 @@ static const iw_handler ray_handler[] = {
1560#define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3 /* Get country code */ 1542#define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3 /* Get country code */
1561 1543
1562static const iw_handler ray_private_handler[] = { 1544static const iw_handler ray_private_handler[] = {
1563 [0] = (iw_handler) ray_set_framing, 1545 [0] = ray_set_framing,
1564 [1] = (iw_handler) ray_get_framing, 1546 [1] = ray_get_framing,
1565 [3] = (iw_handler) ray_get_country, 1547 [3] = ray_get_country,
1566}; 1548};
1567 1549
1568static const struct iw_priv_args ray_private_args[] = { 1550static const struct iw_priv_args ray_private_args[] = {
@@ -1893,17 +1875,17 @@ static void ray_update_multi_list(struct net_device *dev, int all)
1893 writeb(0xff, &pccs->var); 1875 writeb(0xff, &pccs->var);
1894 local->num_multi = 0xff; 1876 local->num_multi = 0xff;
1895 } else { 1877 } else {
1896 struct dev_mc_list *dmi; 1878 struct netdev_hw_addr *ha;
1897 int i = 0; 1879 int i = 0;
1898 1880
1899 /* Copy the kernel's list of MC addresses to card */ 1881 /* Copy the kernel's list of MC addresses to card */
1900 netdev_for_each_mc_addr(dmi, dev) { 1882 netdev_for_each_mc_addr(ha, dev) {
1901 memcpy_toio(p, dmi->dmi_addr, ETH_ALEN); 1883 memcpy_toio(p, ha->addr, ETH_ALEN);
1902 dev_dbg(&link->dev, 1884 dev_dbg(&link->dev,
1903 "ray_update_multi add addr %02x%02x%02x%02x%02x%02x\n", 1885 "ray_update_multi add addr %02x%02x%02x%02x%02x%02x\n",
1904 dmi->dmi_addr[0], dmi->dmi_addr[1], 1886 ha->addr[0], ha->addr[1],
1905 dmi->dmi_addr[2], dmi->dmi_addr[3], 1887 ha->addr[2], ha->addr[3],
1906 dmi->dmi_addr[4], dmi->dmi_addr[5]); 1888 ha->addr[4], ha->addr[5]);
1907 p += ETH_ALEN; 1889 p += ETH_ALEN;
1908 i++; 1890 i++;
1909 } 1891 }
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 2887047069f2..8ab9f094747b 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -117,6 +117,7 @@ MODULE_PARM_DESC(workaround_interval,
117#define OID_802_11_ADD_KEY cpu_to_le32(0x0d01011d) 117#define OID_802_11_ADD_KEY cpu_to_le32(0x0d01011d)
118#define OID_802_11_REMOVE_KEY cpu_to_le32(0x0d01011e) 118#define OID_802_11_REMOVE_KEY cpu_to_le32(0x0d01011e)
119#define OID_802_11_ASSOCIATION_INFORMATION cpu_to_le32(0x0d01011f) 119#define OID_802_11_ASSOCIATION_INFORMATION cpu_to_le32(0x0d01011f)
120#define OID_802_11_CAPABILITY cpu_to_le32(0x0d010122)
120#define OID_802_11_PMKID cpu_to_le32(0x0d010123) 121#define OID_802_11_PMKID cpu_to_le32(0x0d010123)
121#define OID_802_11_NETWORK_TYPES_SUPPORTED cpu_to_le32(0x0d010203) 122#define OID_802_11_NETWORK_TYPES_SUPPORTED cpu_to_le32(0x0d010203)
122#define OID_802_11_NETWORK_TYPE_IN_USE cpu_to_le32(0x0d010204) 123#define OID_802_11_NETWORK_TYPE_IN_USE cpu_to_le32(0x0d010204)
@@ -358,6 +359,30 @@ struct ndis_80211_assoc_info {
358 __le32 offset_resp_ies; 359 __le32 offset_resp_ies;
359} __attribute__((packed)); 360} __attribute__((packed));
360 361
362struct ndis_80211_auth_encr_pair {
363 __le32 auth_mode;
364 __le32 encr_mode;
365} __attribute__((packed));
366
367struct ndis_80211_capability {
368 __le32 length;
369 __le32 version;
370 __le32 num_pmkids;
371 __le32 num_auth_encr_pair;
372 struct ndis_80211_auth_encr_pair auth_encr_pair[0];
373} __attribute__((packed));
374
375struct ndis_80211_bssid_info {
376 u8 bssid[6];
377 u8 pmkid[16];
378};
379
380struct ndis_80211_pmkid {
381 __le32 length;
382 __le32 bssid_info_count;
383 struct ndis_80211_bssid_info bssid_info[0];
384};
385
361/* 386/*
362 * private data 387 * private data
363 */ 388 */
@@ -476,13 +501,7 @@ struct rndis_wlan_private {
476 /* encryption stuff */ 501 /* encryption stuff */
477 int encr_tx_key_index; 502 int encr_tx_key_index;
478 struct rndis_wlan_encr_key encr_keys[4]; 503 struct rndis_wlan_encr_key encr_keys[4];
479 enum nl80211_auth_type wpa_auth_type;
480 int wpa_version; 504 int wpa_version;
481 int wpa_keymgmt;
482 int wpa_ie_len;
483 u8 *wpa_ie;
484 int wpa_cipher_pair;
485 int wpa_cipher_group;
486 505
487 u8 command_buffer[COMMAND_BUFFER_SIZE]; 506 u8 command_buffer[COMMAND_BUFFER_SIZE];
488}; 507};
@@ -534,6 +553,14 @@ static int rndis_get_station(struct wiphy *wiphy, struct net_device *dev,
534static int rndis_dump_station(struct wiphy *wiphy, struct net_device *dev, 553static int rndis_dump_station(struct wiphy *wiphy, struct net_device *dev,
535 int idx, u8 *mac, struct station_info *sinfo); 554 int idx, u8 *mac, struct station_info *sinfo);
536 555
556static int rndis_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
557 struct cfg80211_pmksa *pmksa);
558
559static int rndis_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
560 struct cfg80211_pmksa *pmksa);
561
562static int rndis_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev);
563
537static struct cfg80211_ops rndis_config_ops = { 564static struct cfg80211_ops rndis_config_ops = {
538 .change_virtual_intf = rndis_change_virtual_intf, 565 .change_virtual_intf = rndis_change_virtual_intf,
539 .scan = rndis_scan, 566 .scan = rndis_scan,
@@ -550,6 +577,9 @@ static struct cfg80211_ops rndis_config_ops = {
550 .set_default_key = rndis_set_default_key, 577 .set_default_key = rndis_set_default_key,
551 .get_station = rndis_get_station, 578 .get_station = rndis_get_station,
552 .dump_station = rndis_dump_station, 579 .dump_station = rndis_dump_station,
580 .set_pmksa = rndis_set_pmksa,
581 .del_pmksa = rndis_del_pmksa,
582 .flush_pmksa = rndis_flush_pmksa,
553}; 583};
554 584
555static void *rndis_wiphy_privid = &rndis_wiphy_privid; 585static void *rndis_wiphy_privid = &rndis_wiphy_privid;
@@ -704,6 +734,7 @@ static int rndis_query_oid(struct usbnet *dev, __le32 oid, void *data, int *len)
704 struct rndis_query_c *get_c; 734 struct rndis_query_c *get_c;
705 } u; 735 } u;
706 int ret, buflen; 736 int ret, buflen;
737 int resplen, respoffs, copylen;
707 738
708 buflen = *len + sizeof(*u.get); 739 buflen = *len + sizeof(*u.get);
709 if (buflen < CONTROL_BUFFER_SIZE) 740 if (buflen < CONTROL_BUFFER_SIZE)
@@ -733,11 +764,34 @@ static int rndis_query_oid(struct usbnet *dev, __le32 oid, void *data, int *len)
733 le32_to_cpu(u.get_c->status)); 764 le32_to_cpu(u.get_c->status));
734 765
735 if (ret == 0) { 766 if (ret == 0) {
736 memcpy(data, u.buf + le32_to_cpu(u.get_c->offset) + 8, *len); 767 resplen = le32_to_cpu(u.get_c->len);
768 respoffs = le32_to_cpu(u.get_c->offset) + 8;
737 769
738 ret = le32_to_cpu(u.get_c->len); 770 if (respoffs > buflen) {
739 if (ret > *len) 771 /* Device returned data offset outside buffer, error. */
740 *len = ret; 772 netdev_dbg(dev->net, "%s(%s): received invalid "
773 "data offset: %d > %d\n", __func__,
774 oid_to_string(oid), respoffs, buflen);
775
776 ret = -EINVAL;
777 goto exit_unlock;
778 }
779
780 if ((resplen + respoffs) > buflen) {
781 /* Device would have returned more data if buffer would
782 * have been big enough. Copy just the bits that we got.
783 */
784 copylen = buflen - respoffs;
785 } else {
786 copylen = resplen;
787 }
788
789 if (copylen > *len)
790 copylen = *len;
791
792 memcpy(data, u.buf + respoffs, copylen);
793
794 *len = resplen;
741 795
742 ret = rndis_error_status(u.get_c->status); 796 ret = rndis_error_status(u.get_c->status);
743 if (ret < 0) 797 if (ret < 0)
@@ -746,6 +800,7 @@ static int rndis_query_oid(struct usbnet *dev, __le32 oid, void *data, int *len)
746 le32_to_cpu(u.get_c->status), ret); 800 le32_to_cpu(u.get_c->status), ret);
747 } 801 }
748 802
803exit_unlock:
749 mutex_unlock(&priv->command_lock); 804 mutex_unlock(&priv->command_lock);
750 805
751 if (u.buf != priv->command_buffer) 806 if (u.buf != priv->command_buffer)
@@ -1091,8 +1146,6 @@ static int set_auth_mode(struct usbnet *usbdev, u32 wpa_version,
1091 } 1146 }
1092 1147
1093 priv->wpa_version = wpa_version; 1148 priv->wpa_version = wpa_version;
1094 priv->wpa_auth_type = auth_type;
1095 priv->wpa_keymgmt = keymgmt;
1096 1149
1097 return 0; 1150 return 0;
1098} 1151}
@@ -1117,7 +1170,6 @@ static int set_priv_filter(struct usbnet *usbdev)
1117 1170
1118static int set_encr_mode(struct usbnet *usbdev, int pairwise, int groupwise) 1171static int set_encr_mode(struct usbnet *usbdev, int pairwise, int groupwise)
1119{ 1172{
1120 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1121 __le32 tmp; 1173 __le32 tmp;
1122 int encr_mode, ret; 1174 int encr_mode, ret;
1123 1175
@@ -1146,8 +1198,6 @@ static int set_encr_mode(struct usbnet *usbdev, int pairwise, int groupwise)
1146 return ret; 1198 return ret;
1147 } 1199 }
1148 1200
1149 priv->wpa_cipher_pair = pairwise;
1150 priv->wpa_cipher_group = groupwise;
1151 return 0; 1201 return 0;
1152} 1202}
1153 1203
@@ -1495,7 +1545,7 @@ static int remove_key(struct usbnet *usbdev, int index, const u8 *bssid)
1495static void set_multicast_list(struct usbnet *usbdev) 1545static void set_multicast_list(struct usbnet *usbdev)
1496{ 1546{
1497 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 1547 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1498 struct dev_mc_list *mclist; 1548 struct netdev_hw_addr *ha;
1499 __le32 filter, basefilter; 1549 __le32 filter, basefilter;
1500 int ret; 1550 int ret;
1501 char *mc_addrs = NULL; 1551 char *mc_addrs = NULL;
@@ -1534,9 +1584,9 @@ static void set_multicast_list(struct usbnet *usbdev)
1534 return; 1584 return;
1535 } 1585 }
1536 1586
1537 netdev_for_each_mc_addr(mclist, usbdev->net) 1587 netdev_for_each_mc_addr(ha, usbdev->net)
1538 memcpy(mc_addrs + i++ * ETH_ALEN, 1588 memcpy(mc_addrs + i++ * ETH_ALEN,
1539 mclist->dmi_addr, ETH_ALEN); 1589 ha->addr, ETH_ALEN);
1540 } 1590 }
1541 netif_addr_unlock_bh(usbdev->net); 1591 netif_addr_unlock_bh(usbdev->net);
1542 1592
@@ -1568,6 +1618,194 @@ set_filter:
1568 le32_to_cpu(filter), ret); 1618 le32_to_cpu(filter), ret);
1569} 1619}
1570 1620
1621#ifdef DEBUG
1622static void debug_print_pmkids(struct usbnet *usbdev,
1623 struct ndis_80211_pmkid *pmkids,
1624 const char *func_str)
1625{
1626 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1627 int i, len, count, max_pmkids, entry_len;
1628
1629 max_pmkids = priv->wdev.wiphy->max_num_pmkids;
1630 len = le32_to_cpu(pmkids->length);
1631 count = le32_to_cpu(pmkids->bssid_info_count);
1632
1633 entry_len = (count > 0) ? (len - sizeof(*pmkids)) / count : -1;
1634
1635 netdev_dbg(usbdev->net, "%s(): %d PMKIDs (data len: %d, entry len: "
1636 "%d)\n", func_str, count, len, entry_len);
1637
1638 if (count > max_pmkids)
1639 count = max_pmkids;
1640
1641 for (i = 0; i < count; i++) {
1642 u32 *tmp = (u32 *)pmkids->bssid_info[i].pmkid;
1643
1644 netdev_dbg(usbdev->net, "%s(): bssid: %pM, "
1645 "pmkid: %08X:%08X:%08X:%08X\n",
1646 func_str, pmkids->bssid_info[i].bssid,
1647 cpu_to_be32(tmp[0]), cpu_to_be32(tmp[1]),
1648 cpu_to_be32(tmp[2]), cpu_to_be32(tmp[3]));
1649 }
1650}
1651#else
1652static void debug_print_pmkids(struct usbnet *usbdev,
1653 struct ndis_80211_pmkid *pmkids,
1654 const char *func_str)
1655{
1656 return;
1657}
1658#endif
1659
1660static struct ndis_80211_pmkid *get_device_pmkids(struct usbnet *usbdev)
1661{
1662 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
1663 struct ndis_80211_pmkid *pmkids;
1664 int len, ret, max_pmkids;
1665
1666 max_pmkids = priv->wdev.wiphy->max_num_pmkids;
1667 len = sizeof(*pmkids) + max_pmkids * sizeof(pmkids->bssid_info[0]);
1668
1669 pmkids = kzalloc(len, GFP_KERNEL);
1670 if (!pmkids)
1671 return ERR_PTR(-ENOMEM);
1672
1673 pmkids->length = cpu_to_le32(len);
1674 pmkids->bssid_info_count = cpu_to_le32(max_pmkids);
1675
1676 ret = rndis_query_oid(usbdev, OID_802_11_PMKID, pmkids, &len);
1677 if (ret < 0) {
1678 netdev_dbg(usbdev->net, "%s(): OID_802_11_PMKID(%d, %d)"
1679 " -> %d\n", __func__, len, max_pmkids, ret);
1680
1681 kfree(pmkids);
1682 return ERR_PTR(ret);
1683 }
1684
1685 if (le32_to_cpu(pmkids->bssid_info_count) > max_pmkids)
1686 pmkids->bssid_info_count = cpu_to_le32(max_pmkids);
1687
1688 debug_print_pmkids(usbdev, pmkids, __func__);
1689
1690 return pmkids;
1691}
1692
1693static int set_device_pmkids(struct usbnet *usbdev,
1694 struct ndis_80211_pmkid *pmkids)
1695{
1696 int ret, len, num_pmkids;
1697
1698 num_pmkids = le32_to_cpu(pmkids->bssid_info_count);
1699 len = sizeof(*pmkids) + num_pmkids * sizeof(pmkids->bssid_info[0]);
1700 pmkids->length = cpu_to_le32(len);
1701
1702 debug_print_pmkids(usbdev, pmkids, __func__);
1703
1704 ret = rndis_set_oid(usbdev, OID_802_11_PMKID, pmkids,
1705 le32_to_cpu(pmkids->length));
1706 if (ret < 0) {
1707 netdev_dbg(usbdev->net, "%s(): OID_802_11_PMKID(%d, %d) -> %d"
1708 "\n", __func__, len, num_pmkids, ret);
1709 }
1710
1711 kfree(pmkids);
1712 return ret;
1713}
1714
1715static struct ndis_80211_pmkid *remove_pmkid(struct usbnet *usbdev,
1716 struct ndis_80211_pmkid *pmkids,
1717 struct cfg80211_pmksa *pmksa,
1718 int max_pmkids)
1719{
1720 int i, len, count, newlen, err;
1721
1722 len = le32_to_cpu(pmkids->length);
1723 count = le32_to_cpu(pmkids->bssid_info_count);
1724
1725 if (count > max_pmkids)
1726 count = max_pmkids;
1727
1728 for (i = 0; i < count; i++)
1729 if (!compare_ether_addr(pmkids->bssid_info[i].bssid,
1730 pmksa->bssid))
1731 break;
1732
1733 /* pmkid not found */
1734 if (i == count) {
1735 netdev_dbg(usbdev->net, "%s(): bssid not found (%pM)\n",
1736 __func__, pmksa->bssid);
1737 err = -ENOENT;
1738 goto error;
1739 }
1740
1741 for (; i + 1 < count; i++)
1742 pmkids->bssid_info[i] = pmkids->bssid_info[i + 1];
1743
1744 count--;
1745 newlen = sizeof(*pmkids) + count * sizeof(pmkids->bssid_info[0]);
1746
1747 pmkids->length = cpu_to_le32(newlen);
1748 pmkids->bssid_info_count = cpu_to_le32(count);
1749
1750 return pmkids;
1751error:
1752 kfree(pmkids);
1753 return ERR_PTR(err);
1754}
1755
1756static struct ndis_80211_pmkid *update_pmkid(struct usbnet *usbdev,
1757 struct ndis_80211_pmkid *pmkids,
1758 struct cfg80211_pmksa *pmksa,
1759 int max_pmkids)
1760{
1761 int i, err, len, count, newlen;
1762
1763 len = le32_to_cpu(pmkids->length);
1764 count = le32_to_cpu(pmkids->bssid_info_count);
1765
1766 if (count > max_pmkids)
1767 count = max_pmkids;
1768
1769 /* update with new pmkid */
1770 for (i = 0; i < count; i++) {
1771 if (compare_ether_addr(pmkids->bssid_info[i].bssid,
1772 pmksa->bssid))
1773 continue;
1774
1775 memcpy(pmkids->bssid_info[i].pmkid, pmksa->pmkid,
1776 WLAN_PMKID_LEN);
1777
1778 return pmkids;
1779 }
1780
1781 /* out of space, return error */
1782 if (i == max_pmkids) {
1783 netdev_dbg(usbdev->net, "%s(): out of space\n", __func__);
1784 err = -ENOSPC;
1785 goto error;
1786 }
1787
1788 /* add new pmkid */
1789 newlen = sizeof(*pmkids) + (count + 1) * sizeof(pmkids->bssid_info[0]);
1790
1791 pmkids = krealloc(pmkids, newlen, GFP_KERNEL);
1792 if (!pmkids) {
1793 err = -ENOMEM;
1794 goto error;
1795 }
1796
1797 pmkids->length = cpu_to_le32(newlen);
1798 pmkids->bssid_info_count = cpu_to_le32(count + 1);
1799
1800 memcpy(pmkids->bssid_info[count].bssid, pmksa->bssid, ETH_ALEN);
1801 memcpy(pmkids->bssid_info[count].pmkid, pmksa->pmkid, WLAN_PMKID_LEN);
1802
1803 return pmkids;
1804error:
1805 kfree(pmkids);
1806 return ERR_PTR(err);
1807}
1808
1571/* 1809/*
1572 * cfg80211 ops 1810 * cfg80211 ops
1573 */ 1811 */
@@ -2178,6 +2416,78 @@ static int rndis_dump_station(struct wiphy *wiphy, struct net_device *dev,
2178 return 0; 2416 return 0;
2179} 2417}
2180 2418
2419static int rndis_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
2420 struct cfg80211_pmksa *pmksa)
2421{
2422 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
2423 struct usbnet *usbdev = priv->usbdev;
2424 struct ndis_80211_pmkid *pmkids;
2425 u32 *tmp = (u32 *)pmksa->pmkid;
2426
2427 netdev_dbg(usbdev->net, "%s(%pM, %08X:%08X:%08X:%08X)\n", __func__,
2428 pmksa->bssid,
2429 cpu_to_be32(tmp[0]), cpu_to_be32(tmp[1]),
2430 cpu_to_be32(tmp[2]), cpu_to_be32(tmp[3]));
2431
2432 pmkids = get_device_pmkids(usbdev);
2433 if (IS_ERR(pmkids)) {
2434 /* couldn't read PMKID cache from device */
2435 return PTR_ERR(pmkids);
2436 }
2437
2438 pmkids = update_pmkid(usbdev, pmkids, pmksa, wiphy->max_num_pmkids);
2439 if (IS_ERR(pmkids)) {
2440 /* not found, list full, etc */
2441 return PTR_ERR(pmkids);
2442 }
2443
2444 return set_device_pmkids(usbdev, pmkids);
2445}
2446
2447static int rndis_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
2448 struct cfg80211_pmksa *pmksa)
2449{
2450 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
2451 struct usbnet *usbdev = priv->usbdev;
2452 struct ndis_80211_pmkid *pmkids;
2453 u32 *tmp = (u32 *)pmksa->pmkid;
2454
2455 netdev_dbg(usbdev->net, "%s(%pM, %08X:%08X:%08X:%08X)\n", __func__,
2456 pmksa->bssid,
2457 cpu_to_be32(tmp[0]), cpu_to_be32(tmp[1]),
2458 cpu_to_be32(tmp[2]), cpu_to_be32(tmp[3]));
2459
2460 pmkids = get_device_pmkids(usbdev);
2461 if (IS_ERR(pmkids)) {
2462 /* Couldn't read PMKID cache from device */
2463 return PTR_ERR(pmkids);
2464 }
2465
2466 pmkids = remove_pmkid(usbdev, pmkids, pmksa, wiphy->max_num_pmkids);
2467 if (IS_ERR(pmkids)) {
2468 /* not found, etc */
2469 return PTR_ERR(pmkids);
2470 }
2471
2472 return set_device_pmkids(usbdev, pmkids);
2473}
2474
2475static int rndis_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
2476{
2477 struct rndis_wlan_private *priv = wiphy_priv(wiphy);
2478 struct usbnet *usbdev = priv->usbdev;
2479 struct ndis_80211_pmkid pmkid;
2480
2481 netdev_dbg(usbdev->net, "%s()\n", __func__);
2482
2483 memset(&pmkid, 0, sizeof(pmkid));
2484
2485 pmkid.length = cpu_to_le32(sizeof(pmkid));
2486 pmkid.bssid_info_count = cpu_to_le32(0);
2487
2488 return rndis_set_oid(usbdev, OID_802_11_PMKID, &pmkid, sizeof(pmkid));
2489}
2490
2181/* 2491/*
2182 * workers, indication handlers, device poller 2492 * workers, indication handlers, device poller
2183 */ 2493 */
@@ -2522,12 +2832,14 @@ static void rndis_wlan_indication(struct usbnet *usbdev, void *ind, int buflen)
2522 } 2832 }
2523} 2833}
2524 2834
2525static int rndis_wlan_get_caps(struct usbnet *usbdev) 2835static int rndis_wlan_get_caps(struct usbnet *usbdev, struct wiphy *wiphy)
2526{ 2836{
2527 struct { 2837 struct {
2528 __le32 num_items; 2838 __le32 num_items;
2529 __le32 items[8]; 2839 __le32 items[8];
2530 } networks_supported; 2840 } networks_supported;
2841 struct ndis_80211_capability *caps;
2842 u8 caps_buf[sizeof(*caps) + sizeof(caps->auth_encr_pair) * 16];
2531 int len, retval, i, n; 2843 int len, retval, i, n;
2532 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 2844 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
2533 2845
@@ -2555,6 +2867,21 @@ static int rndis_wlan_get_caps(struct usbnet *usbdev)
2555 } 2867 }
2556 } 2868 }
2557 2869
2870 /* get device 802.11 capabilities, number of PMKIDs */
2871 caps = (struct ndis_80211_capability *)caps_buf;
2872 len = sizeof(caps_buf);
2873 retval = rndis_query_oid(usbdev, OID_802_11_CAPABILITY, caps, &len);
2874 if (retval >= 0) {
2875 netdev_dbg(usbdev->net, "OID_802_11_CAPABILITY -> len %d, "
2876 "ver %d, pmkids %d, auth-encr-pairs %d\n",
2877 le32_to_cpu(caps->length),
2878 le32_to_cpu(caps->version),
2879 le32_to_cpu(caps->num_pmkids),
2880 le32_to_cpu(caps->num_auth_encr_pair));
2881 wiphy->max_num_pmkids = le32_to_cpu(caps->num_pmkids);
2882 } else
2883 wiphy->max_num_pmkids = 0;
2884
2558 return retval; 2885 return retval;
2559} 2886}
2560 2887
@@ -2802,7 +3129,7 @@ static int rndis_wlan_bind(struct usbnet *usbdev, struct usb_interface *intf)
2802 wiphy->max_scan_ssids = 1; 3129 wiphy->max_scan_ssids = 1;
2803 3130
2804 /* TODO: fill-out band/encr information based on priv->caps */ 3131 /* TODO: fill-out band/encr information based on priv->caps */
2805 rndis_wlan_get_caps(usbdev); 3132 rndis_wlan_get_caps(usbdev, wiphy);
2806 3133
2807 memcpy(priv->channels, rndis_channels, sizeof(rndis_channels)); 3134 memcpy(priv->channels, rndis_channels, sizeof(rndis_channels));
2808 memcpy(priv->rates, rndis_rates, sizeof(rndis_rates)); 3135 memcpy(priv->rates, rndis_rates, sizeof(rndis_rates));
@@ -2862,9 +3189,6 @@ static void rndis_wlan_unbind(struct usbnet *usbdev, struct usb_interface *intf)
2862 flush_workqueue(priv->workqueue); 3189 flush_workqueue(priv->workqueue);
2863 destroy_workqueue(priv->workqueue); 3190 destroy_workqueue(priv->workqueue);
2864 3191
2865 if (priv && priv->wpa_ie_len)
2866 kfree(priv->wpa_ie);
2867
2868 rndis_unbind(usbdev, intf); 3192 rndis_unbind(usbdev, intf);
2869 3193
2870 wiphy_unregister(priv->wdev.wiphy); 3194 wiphy_unregister(priv->wdev.wiphy);
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index 91cce2d0f6db..b1f5643f83fc 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -907,14 +907,12 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev)
907{ 907{
908 struct data_queue *queue; 908 struct data_queue *queue;
909 struct queue_entry *entry; 909 struct queue_entry *entry;
910 struct queue_entry *entry_done; 910 __le32 *txwi;
911 struct queue_entry_priv_pci *entry_priv;
912 struct txdone_entry_desc txdesc; 911 struct txdone_entry_desc txdesc;
913 u32 word; 912 u32 word;
914 u32 reg; 913 u32 reg;
915 u32 old_reg; 914 u32 old_reg;
916 unsigned int type; 915 int wcid, ack, pid, tx_wcid, tx_ack, tx_pid;
917 unsigned int index;
918 u16 mcs, real_mcs; 916 u16 mcs, real_mcs;
919 917
920 /* 918 /*
@@ -936,71 +934,76 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev)
936 break; 934 break;
937 old_reg = reg; 935 old_reg = reg;
938 936
937 wcid = rt2x00_get_field32(reg, TX_STA_FIFO_WCID);
938 ack = rt2x00_get_field32(reg, TX_STA_FIFO_TX_ACK_REQUIRED);
939 pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE);
940
939 /* 941 /*
940 * Skip this entry when it contains an invalid 942 * Skip this entry when it contains an invalid
941 * queue identication number. 943 * queue identication number.
942 */ 944 */
943 type = rt2x00_get_field32(reg, TX_STA_FIFO_PID_TYPE) - 1; 945 if (pid <= 0 || pid > QID_RX)
944 if (type >= QID_RX)
945 continue; 946 continue;
946 947
947 queue = rt2x00queue_get_queue(rt2x00dev, type); 948 queue = rt2x00queue_get_queue(rt2x00dev, pid - 1);
948 if (unlikely(!queue)) 949 if (unlikely(!queue))
949 continue; 950 continue;
950 951
951 /* 952 /*
952 * Skip this entry when it contains an invalid 953 * Inside each queue, we process each entry in a chronological
953 * index number. 954 * order. We first check that the queue is not empty.
954 */ 955 */
955 index = rt2x00_get_field32(reg, TX_STA_FIFO_WCID) - 1; 956 if (rt2x00queue_empty(queue))
956 if (unlikely(index >= queue->limit))
957 continue; 957 continue;
958 entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
958 959
959 entry = &queue->entries[index]; 960 /* Check if we got a match by looking at WCID/ACK/PID
960 entry_priv = entry->priv_data; 961 * fields */
961 rt2x00_desc_read((__le32 *)entry->skb->data, 0, &word); 962 txwi = (__le32 *)(entry->skb->data -
962 963 rt2x00dev->ops->extra_tx_headroom);
963 entry_done = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
964 while (entry != entry_done) {
965 /*
966 * Catch up.
967 * Just report any entries we missed as failed.
968 */
969 WARNING(rt2x00dev,
970 "TX status report missed for entry %d\n",
971 entry_done->entry_idx);
972 964
973 txdesc.flags = 0; 965 rt2x00_desc_read(txwi, 1, &word);
974 __set_bit(TXDONE_UNKNOWN, &txdesc.flags); 966 tx_wcid = rt2x00_get_field32(word, TXWI_W1_WIRELESS_CLI_ID);
975 txdesc.retry = 0; 967 tx_ack = rt2x00_get_field32(word, TXWI_W1_ACK);
968 tx_pid = rt2x00_get_field32(word, TXWI_W1_PACKETID);
976 969
977 rt2x00lib_txdone(entry_done, &txdesc); 970 if ((wcid != tx_wcid) || (ack != tx_ack) || (pid != tx_pid))
978 entry_done = rt2x00queue_get_entry(queue, Q_INDEX_DONE); 971 WARNING(rt2x00dev, "invalid TX_STA_FIFO content\n");
979 }
980 972
981 /* 973 /*
982 * Obtain the status about this packet. 974 * Obtain the status about this packet.
983 */ 975 */
984 txdesc.flags = 0; 976 txdesc.flags = 0;
985 if (rt2x00_get_field32(reg, TX_STA_FIFO_TX_SUCCESS)) 977 rt2x00_desc_read(txwi, 0, &word);
986 __set_bit(TXDONE_SUCCESS, &txdesc.flags); 978 mcs = rt2x00_get_field32(word, TXWI_W0_MCS);
987 else 979 real_mcs = rt2x00_get_field32(reg, TX_STA_FIFO_MCS);
988 __set_bit(TXDONE_FAILURE, &txdesc.flags);
989 980
990 /* 981 /*
991 * Ralink has a retry mechanism using a global fallback 982 * Ralink has a retry mechanism using a global fallback
992 * table. We setup this fallback table to try immediate 983 * table. We setup this fallback table to try the immediate
993 * lower rate for all rates. In the TX_STA_FIFO, 984 * lower rate for all rates. In the TX_STA_FIFO, the MCS field
994 * the MCS field contains the MCS used for the successfull 985 * always contains the MCS used for the last transmission, be
995 * transmission. If the first transmission succeed, 986 * it successful or not.
996 * we have mcs == tx_mcs. On the second transmission,
997 * we have mcs = tx_mcs - 1. So the number of
998 * retry is (tx_mcs - mcs).
999 */ 987 */
1000 mcs = rt2x00_get_field32(word, TXWI_W0_MCS); 988 if (rt2x00_get_field32(reg, TX_STA_FIFO_TX_SUCCESS)) {
1001 real_mcs = rt2x00_get_field32(reg, TX_STA_FIFO_MCS); 989 /*
990 * Transmission succeeded. The number of retries is
991 * mcs - real_mcs
992 */
993 __set_bit(TXDONE_SUCCESS, &txdesc.flags);
994 txdesc.retry = ((mcs > real_mcs) ? mcs - real_mcs : 0);
995 } else {
996 /*
997 * Transmission failed. The number of retries is
998 * always 7 in this case (for a total number of 8
999 * frames sent).
1000 */
1001 __set_bit(TXDONE_FAILURE, &txdesc.flags);
1002 txdesc.retry = 7;
1003 }
1004
1002 __set_bit(TXDONE_FALLBACK, &txdesc.flags); 1005 __set_bit(TXDONE_FALLBACK, &txdesc.flags);
1003 txdesc.retry = mcs - min(mcs, real_mcs); 1006
1004 1007
1005 rt2x00lib_txdone(entry, &txdesc); 1008 rt2x00lib_txdone(entry, &txdesc);
1006 } 1009 }
@@ -1184,6 +1187,7 @@ static const struct rt2x00_ops rt2800pci_ops = {
1184/* 1187/*
1185 * RT2800pci module information. 1188 * RT2800pci module information.
1186 */ 1189 */
1190#ifdef CONFIG_RT2800PCI_PCI
1187static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = { 1191static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = {
1188 { PCI_DEVICE(0x1814, 0x0601), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1192 { PCI_DEVICE(0x1814, 0x0601), PCI_DEVICE_DATA(&rt2800pci_ops) },
1189 { PCI_DEVICE(0x1814, 0x0681), PCI_DEVICE_DATA(&rt2800pci_ops) }, 1193 { PCI_DEVICE(0x1814, 0x0681), PCI_DEVICE_DATA(&rt2800pci_ops) },
@@ -1211,6 +1215,7 @@ static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = {
1211#endif 1215#endif
1212 { 0, } 1216 { 0, }
1213}; 1217};
1218#endif /* CONFIG_RT2800PCI_PCI */
1214 1219
1215MODULE_AUTHOR(DRV_PROJECT); 1220MODULE_AUTHOR(DRV_PROJECT);
1216MODULE_VERSION(DRV_VERSION); 1221MODULE_VERSION(DRV_VERSION);
diff --git a/drivers/net/wireless/rtl818x/rtl8180_dev.c b/drivers/net/wireless/rtl818x/rtl8180_dev.c
index 2b928ecf47bd..fb8a62f2b9b4 100644
--- a/drivers/net/wireless/rtl818x/rtl8180_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8180_dev.c
@@ -723,10 +723,10 @@ static void rtl8180_bss_info_changed(struct ieee80211_hw *dev,
723 priv->rf->conf_erp(dev, info); 723 priv->rf->conf_erp(dev, info);
724} 724}
725 725
726static u64 rtl8180_prepare_multicast(struct ieee80211_hw *dev, int mc_count, 726static u64 rtl8180_prepare_multicast(struct ieee80211_hw *dev,
727 struct dev_addr_list *mc_list) 727 struct netdev_hw_addr_list *mc_list)
728{ 728{
729 return mc_count; 729 return netdev_hw_addr_list_count(mc_list);
730} 730}
731 731
732static void rtl8180_configure_filter(struct ieee80211_hw *dev, 732static void rtl8180_configure_filter(struct ieee80211_hw *dev,
diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 0fb850e0c656..441d817ed489 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -1193,9 +1193,9 @@ static void rtl8187_bss_info_changed(struct ieee80211_hw *dev,
1193} 1193}
1194 1194
1195static u64 rtl8187_prepare_multicast(struct ieee80211_hw *dev, 1195static u64 rtl8187_prepare_multicast(struct ieee80211_hw *dev,
1196 int mc_count, struct dev_addr_list *mc_list) 1196 struct netdev_hw_addr_list *mc_list)
1197{ 1197{
1198 return mc_count; 1198 return netdev_hw_addr_list_count(mc_list);
1199} 1199}
1200 1200
1201static void rtl8187_configure_filter(struct ieee80211_hw *dev, 1201static void rtl8187_configure_filter(struct ieee80211_hw *dev,
diff --git a/drivers/net/wireless/wl12xx/Kconfig b/drivers/net/wireless/wl12xx/Kconfig
index 785e0244e305..337fc7bec5a5 100644
--- a/drivers/net/wireless/wl12xx/Kconfig
+++ b/drivers/net/wireless/wl12xx/Kconfig
@@ -51,3 +51,27 @@ config WL1271
51 51
52 If you choose to build a module, it'll be called wl1271. Say N if 52 If you choose to build a module, it'll be called wl1271. Say N if
53 unsure. 53 unsure.
54
55config WL1271_SPI
56 tristate "TI wl1271 SPI support"
57 depends on WL1271 && SPI_MASTER
58 ---help---
59 This module adds support for the SPI interface of adapters using
60 TI wl1271 chipset. Select this if your platform is using
61 the SPI bus.
62
63 If you choose to build a module, it'll be called wl1251_spi.
64 Say N if unsure.
65
66config WL1271_SDIO
67 tristate "TI wl1271 SDIO support"
68 depends on WL1271 && MMC && ARM
69 ---help---
70 This module adds support for the SDIO interface of adapters using
71 TI wl1271 chipset. Select this if your platform is using
72 the SDIO bus.
73
74 If you choose to build a module, it'll be called
75 wl1271_sdio. Say N if unsure.
76
77
diff --git a/drivers/net/wireless/wl12xx/Makefile b/drivers/net/wireless/wl12xx/Makefile
index f47ec94c16dc..27ddd2be0a91 100644
--- a/drivers/net/wireless/wl12xx/Makefile
+++ b/drivers/net/wireless/wl12xx/Makefile
@@ -7,10 +7,12 @@ obj-$(CONFIG_WL1251) += wl1251.o
7obj-$(CONFIG_WL1251_SPI) += wl1251_spi.o 7obj-$(CONFIG_WL1251_SPI) += wl1251_spi.o
8obj-$(CONFIG_WL1251_SDIO) += wl1251_sdio.o 8obj-$(CONFIG_WL1251_SDIO) += wl1251_sdio.o
9 9
10wl1271-objs = wl1271_main.o wl1271_spi.o wl1271_cmd.o \ 10wl1271-objs = wl1271_main.o wl1271_cmd.o wl1271_io.o \
11 wl1271_event.o wl1271_tx.o wl1271_rx.o \ 11 wl1271_event.o wl1271_tx.o wl1271_rx.o \
12 wl1271_ps.o wl1271_acx.o wl1271_boot.o \ 12 wl1271_ps.o wl1271_acx.o wl1271_boot.o \
13 wl1271_init.o wl1271_debugfs.o wl1271_io.o 13 wl1271_init.o wl1271_debugfs.o
14 14
15wl1271-$(CONFIG_NL80211_TESTMODE) += wl1271_testmode.o 15wl1271-$(CONFIG_NL80211_TESTMODE) += wl1271_testmode.o
16obj-$(CONFIG_WL1271) += wl1271.o 16obj-$(CONFIG_WL1271) += wl1271.o
17obj-$(CONFIG_WL1271_SPI) += wl1271_spi.o
18obj-$(CONFIG_WL1271_SDIO) += wl1271_sdio.o
diff --git a/drivers/net/wireless/wl12xx/wl1251.h b/drivers/net/wireless/wl12xx/wl1251.h
index 37c61c19cae5..4f5f02a26e62 100644
--- a/drivers/net/wireless/wl12xx/wl1251.h
+++ b/drivers/net/wireless/wl12xx/wl1251.h
@@ -256,6 +256,8 @@ struct wl1251_debugfs {
256struct wl1251_if_operations { 256struct wl1251_if_operations {
257 void (*read)(struct wl1251 *wl, int addr, void *buf, size_t len); 257 void (*read)(struct wl1251 *wl, int addr, void *buf, size_t len);
258 void (*write)(struct wl1251 *wl, int addr, void *buf, size_t len); 258 void (*write)(struct wl1251 *wl, int addr, void *buf, size_t len);
259 void (*read_elp)(struct wl1251 *wl, int addr, u32 *val);
260 void (*write_elp)(struct wl1251 *wl, int addr, u32 val);
259 void (*reset)(struct wl1251 *wl); 261 void (*reset)(struct wl1251 *wl);
260 void (*enable_irq)(struct wl1251 *wl); 262 void (*enable_irq)(struct wl1251 *wl);
261 void (*disable_irq)(struct wl1251 *wl); 263 void (*disable_irq)(struct wl1251 *wl);
diff --git a/drivers/net/wireless/wl12xx/wl1251_boot.c b/drivers/net/wireless/wl12xx/wl1251_boot.c
index 28a808674080..acb334184d70 100644
--- a/drivers/net/wireless/wl12xx/wl1251_boot.c
+++ b/drivers/net/wireless/wl12xx/wl1251_boot.c
@@ -496,7 +496,8 @@ int wl1251_boot(struct wl1251 *wl)
496 /* 2. start processing NVS file */ 496 /* 2. start processing NVS file */
497 if (wl->use_eeprom) { 497 if (wl->use_eeprom) {
498 wl1251_reg_write32(wl, ACX_REG_EE_START, START_EEPROM_MGR); 498 wl1251_reg_write32(wl, ACX_REG_EE_START, START_EEPROM_MGR);
499 msleep(4000); 499 /* Wait for EEPROM NVS burst read to complete */
500 msleep(40);
500 wl1251_reg_write32(wl, ACX_EEPROMLESS_IND_REG, USE_EEPROM); 501 wl1251_reg_write32(wl, ACX_EEPROMLESS_IND_REG, USE_EEPROM);
501 } else { 502 } else {
502 ret = wl1251_boot_upload_nvs(wl); 503 ret = wl1251_boot_upload_nvs(wl);
diff --git a/drivers/net/wireless/wl12xx/wl1251_io.h b/drivers/net/wireless/wl12xx/wl1251_io.h
index b89d2ac62efb..c545e9d5f512 100644
--- a/drivers/net/wireless/wl12xx/wl1251_io.h
+++ b/drivers/net/wireless/wl12xx/wl1251_io.h
@@ -48,6 +48,26 @@ static inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val)
48 wl->if_ops->write(wl, addr, &val, sizeof(u32)); 48 wl->if_ops->write(wl, addr, &val, sizeof(u32));
49} 49}
50 50
51static inline u32 wl1251_read_elp(struct wl1251 *wl, int addr)
52{
53 u32 response;
54
55 if (wl->if_ops->read_elp)
56 wl->if_ops->read_elp(wl, addr, &response);
57 else
58 wl->if_ops->read(wl, addr, &response, sizeof(u32));
59
60 return response;
61}
62
63static inline void wl1251_write_elp(struct wl1251 *wl, int addr, u32 val)
64{
65 if (wl->if_ops->write_elp)
66 wl->if_ops->write_elp(wl, addr, val);
67 else
68 wl->if_ops->write(wl, addr, &val, sizeof(u32));
69}
70
51/* Memory target IO, address is translated to partition 0 */ 71/* Memory target IO, address is translated to partition 0 */
52void wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len); 72void wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len);
53void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len); 73void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len);
diff --git a/drivers/net/wireless/wl12xx/wl1251_main.c b/drivers/net/wireless/wl12xx/wl1251_main.c
index 24ae6a360ac8..0155653b7105 100644
--- a/drivers/net/wireless/wl12xx/wl1251_main.c
+++ b/drivers/net/wireless/wl12xx/wl1251_main.c
@@ -146,8 +146,8 @@ static void wl1251_fw_wakeup(struct wl1251 *wl)
146 u32 elp_reg; 146 u32 elp_reg;
147 147
148 elp_reg = ELPCTRL_WAKE_UP; 148 elp_reg = ELPCTRL_WAKE_UP;
149 wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg); 149 wl1251_write_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg);
150 elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); 150 elp_reg = wl1251_read_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
151 151
152 if (!(elp_reg & ELPCTRL_WLAN_READY)) 152 if (!(elp_reg & ELPCTRL_WLAN_READY))
153 wl1251_warning("WLAN not ready"); 153 wl1251_warning("WLAN not ready");
diff --git a/drivers/net/wireless/wl12xx/wl1251_ps.c b/drivers/net/wireless/wl12xx/wl1251_ps.c
index 851dfb65e474..b55cb2bd459a 100644
--- a/drivers/net/wireless/wl12xx/wl1251_ps.c
+++ b/drivers/net/wireless/wl12xx/wl1251_ps.c
@@ -45,7 +45,7 @@ void wl1251_elp_work(struct work_struct *work)
45 goto out; 45 goto out;
46 46
47 wl1251_debug(DEBUG_PSM, "chip to elp"); 47 wl1251_debug(DEBUG_PSM, "chip to elp");
48 wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP); 48 wl1251_write_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP);
49 wl->elp = true; 49 wl->elp = true;
50 50
51out: 51out:
@@ -79,9 +79,9 @@ int wl1251_ps_elp_wakeup(struct wl1251 *wl)
79 start = jiffies; 79 start = jiffies;
80 timeout = jiffies + msecs_to_jiffies(WL1251_WAKEUP_TIMEOUT); 80 timeout = jiffies + msecs_to_jiffies(WL1251_WAKEUP_TIMEOUT);
81 81
82 wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_WAKE_UP); 82 wl1251_write_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_WAKE_UP);
83 83
84 elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); 84 elp_reg = wl1251_read_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
85 85
86 /* 86 /*
87 * FIXME: we should wait for irq from chip but, as a temporary 87 * FIXME: we should wait for irq from chip but, as a temporary
@@ -93,7 +93,7 @@ int wl1251_ps_elp_wakeup(struct wl1251 *wl)
93 return -ETIMEDOUT; 93 return -ETIMEDOUT;
94 } 94 }
95 msleep(1); 95 msleep(1);
96 elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); 96 elp_reg = wl1251_read_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
97 } 97 }
98 98
99 wl1251_debug(DEBUG_PSM, "wakeup time: %u ms", 99 wl1251_debug(DEBUG_PSM, "wakeup time: %u ms",
diff --git a/drivers/net/wireless/wl12xx/wl1251_sdio.c b/drivers/net/wireless/wl12xx/wl1251_sdio.c
index 9423f22bdced..2051ef06e9ec 100644
--- a/drivers/net/wireless/wl12xx/wl1251_sdio.c
+++ b/drivers/net/wireless/wl12xx/wl1251_sdio.c
@@ -20,20 +20,11 @@
20 * Copyright (C) 2009 Bob Copeland (me@bobcopeland.com) 20 * Copyright (C) 2009 Bob Copeland (me@bobcopeland.com)
21 */ 21 */
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/crc7.h>
24#include <linux/mod_devicetable.h> 23#include <linux/mod_devicetable.h>
25#include <linux/irq.h>
26#include <linux/mmc/sdio_func.h> 24#include <linux/mmc/sdio_func.h>
27#include <linux/mmc/sdio_ids.h> 25#include <linux/mmc/sdio_ids.h>
28#include <linux/platform_device.h>
29 26
30#include "wl1251.h" 27#include "wl1251.h"
31#include "wl12xx_80211.h"
32#include "wl1251_reg.h"
33#include "wl1251_ps.h"
34#include "wl1251_io.h"
35#include "wl1251_tx.h"
36#include "wl1251_debugfs.h"
37 28
38#ifndef SDIO_VENDOR_ID_TI 29#ifndef SDIO_VENDOR_ID_TI
39#define SDIO_VENDOR_ID_TI 0x104c 30#define SDIO_VENDOR_ID_TI 0x104c
@@ -65,7 +56,8 @@ static const struct sdio_device_id wl1251_devices[] = {
65MODULE_DEVICE_TABLE(sdio, wl1251_devices); 56MODULE_DEVICE_TABLE(sdio, wl1251_devices);
66 57
67 58
68void wl1251_sdio_read(struct wl1251 *wl, int addr, void *buf, size_t len) 59static void wl1251_sdio_read(struct wl1251 *wl, int addr,
60 void *buf, size_t len)
69{ 61{
70 int ret; 62 int ret;
71 struct sdio_func *func = wl_to_func(wl); 63 struct sdio_func *func = wl_to_func(wl);
@@ -77,7 +69,8 @@ void wl1251_sdio_read(struct wl1251 *wl, int addr, void *buf, size_t len)
77 sdio_release_host(func); 69 sdio_release_host(func);
78} 70}
79 71
80void wl1251_sdio_write(struct wl1251 *wl, int addr, void *buf, size_t len) 72static void wl1251_sdio_write(struct wl1251 *wl, int addr,
73 void *buf, size_t len)
81{ 74{
82 int ret; 75 int ret;
83 struct sdio_func *func = wl_to_func(wl); 76 struct sdio_func *func = wl_to_func(wl);
@@ -89,7 +82,33 @@ void wl1251_sdio_write(struct wl1251 *wl, int addr, void *buf, size_t len)
89 sdio_release_host(func); 82 sdio_release_host(func);
90} 83}
91 84
92void wl1251_sdio_reset(struct wl1251 *wl) 85static void wl1251_sdio_read_elp(struct wl1251 *wl, int addr, u32 *val)
86{
87 int ret = 0;
88 struct sdio_func *func = wl_to_func(wl);
89
90 sdio_claim_host(func);
91 *val = sdio_readb(func, addr, &ret);
92 sdio_release_host(func);
93
94 if (ret)
95 wl1251_error("sdio_readb failed (%d)", ret);
96}
97
98static void wl1251_sdio_write_elp(struct wl1251 *wl, int addr, u32 val)
99{
100 int ret = 0;
101 struct sdio_func *func = wl_to_func(wl);
102
103 sdio_claim_host(func);
104 sdio_writeb(func, val, addr, &ret);
105 sdio_release_host(func);
106
107 if (ret)
108 wl1251_error("sdio_writeb failed (%d)", ret);
109}
110
111static void wl1251_sdio_reset(struct wl1251 *wl)
93{ 112{
94} 113}
95 114
@@ -111,19 +130,22 @@ static void wl1251_sdio_disable_irq(struct wl1251 *wl)
111 sdio_release_host(func); 130 sdio_release_host(func);
112} 131}
113 132
114void wl1251_sdio_set_power(bool enable) 133static void wl1251_sdio_set_power(bool enable)
115{ 134{
116} 135}
117 136
118struct wl1251_if_operations wl1251_sdio_ops = { 137static const struct wl1251_if_operations wl1251_sdio_ops = {
119 .read = wl1251_sdio_read, 138 .read = wl1251_sdio_read,
120 .write = wl1251_sdio_write, 139 .write = wl1251_sdio_write,
140 .write_elp = wl1251_sdio_write_elp,
141 .read_elp = wl1251_sdio_read_elp,
121 .reset = wl1251_sdio_reset, 142 .reset = wl1251_sdio_reset,
122 .enable_irq = wl1251_sdio_enable_irq, 143 .enable_irq = wl1251_sdio_enable_irq,
123 .disable_irq = wl1251_sdio_disable_irq, 144 .disable_irq = wl1251_sdio_disable_irq,
124}; 145};
125 146
126int wl1251_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) 147static int wl1251_sdio_probe(struct sdio_func *func,
148 const struct sdio_device_id *id)
127{ 149{
128 int ret; 150 int ret;
129 struct wl1251 *wl; 151 struct wl1251 *wl;
diff --git a/drivers/net/wireless/wl12xx/wl1271.h b/drivers/net/wireless/wl12xx/wl1271.h
index 97ea5096bc8c..8f11506f8310 100644
--- a/drivers/net/wireless/wl12xx/wl1271.h
+++ b/drivers/net/wireless/wl12xx/wl1271.h
@@ -53,6 +53,8 @@ enum {
53 DEBUG_MAC80211 = BIT(11), 53 DEBUG_MAC80211 = BIT(11),
54 DEBUG_CMD = BIT(12), 54 DEBUG_CMD = BIT(12),
55 DEBUG_ACX = BIT(13), 55 DEBUG_ACX = BIT(13),
56 DEBUG_SDIO = BIT(14),
57 DEBUG_FILTERS = BIT(15),
56 DEBUG_ALL = ~0, 58 DEBUG_ALL = ~0,
57}; 59};
58 60
@@ -110,6 +112,9 @@ enum {
110#define WL1271_FW_NAME "wl1271-fw.bin" 112#define WL1271_FW_NAME "wl1271-fw.bin"
111#define WL1271_NVS_NAME "wl1271-nvs.bin" 113#define WL1271_NVS_NAME "wl1271-nvs.bin"
112 114
115#define WL1271_TX_SECURITY_LO16(s) ((u16)((s) & 0xffff))
116#define WL1271_TX_SECURITY_HI32(s) ((u32)(((s) >> 16) & 0xffffffff))
117
113/* NVS data structure */ 118/* NVS data structure */
114#define WL1271_NVS_SECTION_SIZE 468 119#define WL1271_NVS_SECTION_SIZE 468
115 120
@@ -334,11 +339,27 @@ struct wl1271_scan {
334 u8 probe_requests; 339 u8 probe_requests;
335}; 340};
336 341
342struct wl1271_if_operations {
343 void (*read)(struct wl1271 *wl, int addr, void *buf, size_t len,
344 bool fixed);
345 void (*write)(struct wl1271 *wl, int addr, void *buf, size_t len,
346 bool fixed);
347 void (*reset)(struct wl1271 *wl);
348 void (*init)(struct wl1271 *wl);
349 void (*power)(struct wl1271 *wl, bool enable);
350 struct device* (*dev)(struct wl1271 *wl);
351 void (*enable_irq)(struct wl1271 *wl);
352 void (*disable_irq)(struct wl1271 *wl);
353};
354
337struct wl1271 { 355struct wl1271 {
356 struct platform_device *plat_dev;
338 struct ieee80211_hw *hw; 357 struct ieee80211_hw *hw;
339 bool mac80211_registered; 358 bool mac80211_registered;
340 359
341 struct spi_device *spi; 360 void *if_priv;
361
362 struct wl1271_if_operations *if_ops;
342 363
343 void (*set_power)(bool enable); 364 void (*set_power)(bool enable);
344 int irq; 365 int irq;
@@ -357,6 +378,8 @@ struct wl1271 {
357#define WL1271_FLAG_IN_ELP (6) 378#define WL1271_FLAG_IN_ELP (6)
358#define WL1271_FLAG_PSM (7) 379#define WL1271_FLAG_PSM (7)
359#define WL1271_FLAG_PSM_REQUESTED (8) 380#define WL1271_FLAG_PSM_REQUESTED (8)
381#define WL1271_FLAG_IRQ_PENDING (9)
382#define WL1271_FLAG_IRQ_RUNNING (10)
360 unsigned long flags; 383 unsigned long flags;
361 384
362 struct wl1271_partition_set part; 385 struct wl1271_partition_set part;
@@ -382,13 +405,13 @@ struct wl1271 {
382 /* Accounting for allocated / available TX blocks on HW */ 405 /* Accounting for allocated / available TX blocks on HW */
383 u32 tx_blocks_freed[NUM_TX_QUEUES]; 406 u32 tx_blocks_freed[NUM_TX_QUEUES];
384 u32 tx_blocks_available; 407 u32 tx_blocks_available;
385 u8 tx_results_count; 408 u32 tx_results_count;
386 409
387 /* Transmitted TX packets counter for chipset interface */ 410 /* Transmitted TX packets counter for chipset interface */
388 int tx_packets_count; 411 u32 tx_packets_count;
389 412
390 /* Time-offset between host and chipset clocks */ 413 /* Time-offset between host and chipset clocks */
391 int time_offset; 414 s64 time_offset;
392 415
393 /* Session counter for the chipset */ 416 /* Session counter for the chipset */
394 int session_counter; 417 int session_counter;
@@ -403,8 +426,7 @@ struct wl1271 {
403 426
404 /* Security sequence number counters */ 427 /* Security sequence number counters */
405 u8 tx_security_last_seq; 428 u8 tx_security_last_seq;
406 u16 tx_security_seq_16; 429 s64 tx_security_seq;
407 u32 tx_security_seq_32;
408 430
409 /* FW Rx counter */ 431 /* FW Rx counter */
410 u32 rx_counter; 432 u32 rx_counter;
@@ -438,6 +460,7 @@ struct wl1271 {
438 /* Default key (for WEP) */ 460 /* Default key (for WEP) */
439 u32 default_key; 461 u32 default_key;
440 462
463 unsigned int filters;
441 unsigned int rx_config; 464 unsigned int rx_config;
442 unsigned int rx_filter; 465 unsigned int rx_filter;
443 466
@@ -465,6 +488,8 @@ struct wl1271 {
465 /* Current chipset configuration */ 488 /* Current chipset configuration */
466 struct conf_drv_settings conf; 489 struct conf_drv_settings conf;
467 490
491 bool sg_enabled;
492
468 struct list_head list; 493 struct list_head list;
469}; 494};
470 495
@@ -477,7 +502,8 @@ int wl1271_plt_stop(struct wl1271 *wl);
477 502
478#define WL1271_DEFAULT_POWER_LEVEL 0 503#define WL1271_DEFAULT_POWER_LEVEL 0
479 504
480#define WL1271_TX_QUEUE_MAX_LENGTH 20 505#define WL1271_TX_QUEUE_LOW_WATERMARK 10
506#define WL1271_TX_QUEUE_HIGH_WATERMARK 25
481 507
482/* WL1271 needs a 200ms sleep after power on, and a 20ms sleep before power 508/* WL1271 needs a 200ms sleep after power on, and a 20ms sleep before power
483 on in case is has been shut down shortly before */ 509 on in case is has been shut down shortly before */
diff --git a/drivers/net/wireless/wl12xx/wl1271_acx.c b/drivers/net/wireless/wl12xx/wl1271_acx.c
index 60f10dce4800..7e337cea9905 100644
--- a/drivers/net/wireless/wl12xx/wl1271_acx.c
+++ b/drivers/net/wireless/wl12xx/wl1271_acx.c
@@ -31,7 +31,6 @@
31#include "wl1271.h" 31#include "wl1271.h"
32#include "wl12xx_80211.h" 32#include "wl12xx_80211.h"
33#include "wl1271_reg.h" 33#include "wl1271_reg.h"
34#include "wl1271_spi.h"
35#include "wl1271_ps.h" 34#include "wl1271_ps.h"
36 35
37int wl1271_acx_wake_up_conditions(struct wl1271 *wl) 36int wl1271_acx_wake_up_conditions(struct wl1271 *wl)
@@ -136,12 +135,7 @@ int wl1271_acx_tx_power(struct wl1271 *wl, int power)
136 goto out; 135 goto out;
137 } 136 }
138 137
139 /* 138 acx->current_tx_power = power * 10;
140 * FIXME: This is a workaround needed while we don't the correct
141 * calibration, to avoid distortions
142 */
143 /* acx->current_tx_power = power * 10; */
144 acx->current_tx_power = 120;
145 139
146 ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx)); 140 ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx));
147 if (ret < 0) { 141 if (ret < 0) {
@@ -540,7 +534,7 @@ out:
540} 534}
541 535
542 536
543int wl1271_acx_sg_enable(struct wl1271 *wl) 537int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable)
544{ 538{
545 struct acx_bt_wlan_coex *pta; 539 struct acx_bt_wlan_coex *pta;
546 int ret; 540 int ret;
@@ -553,7 +547,10 @@ int wl1271_acx_sg_enable(struct wl1271 *wl)
553 goto out; 547 goto out;
554 } 548 }
555 549
556 pta->enable = SG_ENABLE; 550 if (enable)
551 pta->enable = wl->conf.sg.state;
552 else
553 pta->enable = CONF_SG_DISABLE;
557 554
558 ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta)); 555 ret = wl1271_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
559 if (ret < 0) { 556 if (ret < 0) {
@@ -570,7 +567,7 @@ int wl1271_acx_sg_cfg(struct wl1271 *wl)
570{ 567{
571 struct acx_bt_wlan_coex_param *param; 568 struct acx_bt_wlan_coex_param *param;
572 struct conf_sg_settings *c = &wl->conf.sg; 569 struct conf_sg_settings *c = &wl->conf.sg;
573 int ret; 570 int i, ret;
574 571
575 wl1271_debug(DEBUG_ACX, "acx sg cfg"); 572 wl1271_debug(DEBUG_ACX, "acx sg cfg");
576 573
@@ -581,19 +578,9 @@ int wl1271_acx_sg_cfg(struct wl1271 *wl)
581 } 578 }
582 579
583 /* BT-WLAN coext parameters */ 580 /* BT-WLAN coext parameters */
584 param->per_threshold = cpu_to_le32(c->per_threshold); 581 for (i = 0; i < CONF_SG_PARAMS_MAX; i++)
585 param->max_scan_compensation_time = 582 param->params[i] = c->params[i];
586 cpu_to_le32(c->max_scan_compensation_time); 583 param->param_idx = CONF_SG_PARAMS_ALL;
587 param->nfs_sample_interval = cpu_to_le16(c->nfs_sample_interval);
588 param->load_ratio = c->load_ratio;
589 param->auto_ps_mode = c->auto_ps_mode;
590 param->probe_req_compensation = c->probe_req_compensation;
591 param->scan_window_compensation = c->scan_window_compensation;
592 param->antenna_config = c->antenna_config;
593 param->beacon_miss_threshold = c->beacon_miss_threshold;
594 param->rate_adaptation_threshold =
595 cpu_to_le32(c->rate_adaptation_threshold);
596 param->rate_adaptation_snr = c->rate_adaptation_snr;
597 584
598 ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param)); 585 ret = wl1271_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
599 if (ret < 0) { 586 if (ret < 0) {
diff --git a/drivers/net/wireless/wl12xx/wl1271_acx.h b/drivers/net/wireless/wl12xx/wl1271_acx.h
index aeccc98581eb..8e5870fa9609 100644
--- a/drivers/net/wireless/wl12xx/wl1271_acx.h
+++ b/drivers/net/wireless/wl12xx/wl1271_acx.h
@@ -392,81 +392,27 @@ struct acx_conn_monit_params {
392 __le32 bss_lose_timeout; /* number of TU's from synch fail */ 392 __le32 bss_lose_timeout; /* number of TU's from synch fail */
393} __attribute__ ((packed)); 393} __attribute__ ((packed));
394 394
395enum {
396 SG_ENABLE = 0,
397 SG_DISABLE,
398 SG_SENSE_NO_ACTIVITY,
399 SG_SENSE_ACTIVE
400};
401
402struct acx_bt_wlan_coex { 395struct acx_bt_wlan_coex {
403 struct acx_header header; 396 struct acx_header header;
404 397
405 /*
406 * 0 -> PTA enabled
407 * 1 -> PTA disabled
408 * 2 -> sense no active mode, i.e.
409 * an interrupt is sent upon
410 * BT activity.
411 * 3 -> PTA is switched on in response
412 * to the interrupt sending.
413 */
414 u8 enable; 398 u8 enable;
415 u8 pad[3]; 399 u8 pad[3];
416} __attribute__ ((packed)); 400} __attribute__ ((packed));
417 401
418struct acx_dco_itrim_params { 402struct acx_bt_wlan_coex_param {
419 struct acx_header header; 403 struct acx_header header;
420 404
421 u8 enable; 405 __le32 params[CONF_SG_PARAMS_MAX];
406 u8 param_idx;
422 u8 padding[3]; 407 u8 padding[3];
423 __le32 timeout;
424} __attribute__ ((packed)); 408} __attribute__ ((packed));
425 409
426#define PTA_ANTENNA_TYPE_DEF (0) 410struct acx_dco_itrim_params {
427#define PTA_BT_HP_MAXTIME_DEF (2000)
428#define PTA_WLAN_HP_MAX_TIME_DEF (5000)
429#define PTA_SENSE_DISABLE_TIMER_DEF (1350)
430#define PTA_PROTECTIVE_RX_TIME_DEF (1500)
431#define PTA_PROTECTIVE_TX_TIME_DEF (1500)
432#define PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF (3000)
433#define PTA_SIGNALING_TYPE_DEF (1)
434#define PTA_AFH_LEVERAGE_ON_DEF (0)
435#define PTA_NUMBER_QUIET_CYCLE_DEF (0)
436#define PTA_MAX_NUM_CTS_DEF (3)
437#define PTA_NUMBER_OF_WLAN_PACKETS_DEF (2)
438#define PTA_NUMBER_OF_BT_PACKETS_DEF (2)
439#define PTA_PROTECTIVE_RX_TIME_FAST_DEF (1500)
440#define PTA_PROTECTIVE_TX_TIME_FAST_DEF (3000)
441#define PTA_CYCLE_TIME_FAST_DEF (8700)
442#define PTA_RX_FOR_AVALANCHE_DEF (5)
443#define PTA_ELP_HP_DEF (0)
444#define PTA_ANTI_STARVE_PERIOD_DEF (500)
445#define PTA_ANTI_STARVE_NUM_CYCLE_DEF (4)
446#define PTA_ALLOW_PA_SD_DEF (1)
447#define PTA_TIME_BEFORE_BEACON_DEF (6300)
448#define PTA_HPDM_MAX_TIME_DEF (1600)
449#define PTA_TIME_OUT_NEXT_WLAN_DEF (2550)
450#define PTA_AUTO_MODE_NO_CTS_DEF (0)
451#define PTA_BT_HP_RESPECTED_DEF (3)
452#define PTA_WLAN_RX_MIN_RATE_DEF (24)
453#define PTA_ACK_MODE_DEF (1)
454
455struct acx_bt_wlan_coex_param {
456 struct acx_header header; 411 struct acx_header header;
457 412
458 __le32 per_threshold; 413 u8 enable;
459 __le32 max_scan_compensation_time;
460 __le16 nfs_sample_interval;
461 u8 load_ratio;
462 u8 auto_ps_mode;
463 u8 probe_req_compensation;
464 u8 scan_window_compensation;
465 u8 antenna_config;
466 u8 beacon_miss_threshold;
467 __le32 rate_adaptation_threshold;
468 s8 rate_adaptation_snr;
469 u8 padding[3]; 414 u8 padding[3];
415 __le32 timeout;
470} __attribute__ ((packed)); 416} __attribute__ ((packed));
471 417
472struct acx_energy_detection { 418struct acx_energy_detection {
@@ -1059,7 +1005,7 @@ int wl1271_acx_dco_itrim_params(struct wl1271 *wl);
1059int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter); 1005int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter);
1060int wl1271_acx_beacon_filter_table(struct wl1271 *wl); 1006int wl1271_acx_beacon_filter_table(struct wl1271 *wl);
1061int wl1271_acx_conn_monit_params(struct wl1271 *wl); 1007int wl1271_acx_conn_monit_params(struct wl1271 *wl);
1062int wl1271_acx_sg_enable(struct wl1271 *wl); 1008int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable);
1063int wl1271_acx_sg_cfg(struct wl1271 *wl); 1009int wl1271_acx_sg_cfg(struct wl1271 *wl);
1064int wl1271_acx_cca_threshold(struct wl1271 *wl); 1010int wl1271_acx_cca_threshold(struct wl1271 *wl);
1065int wl1271_acx_bcn_dtim_options(struct wl1271 *wl); 1011int wl1271_acx_bcn_dtim_options(struct wl1271 *wl);
diff --git a/drivers/net/wireless/wl12xx/wl1271_boot.c b/drivers/net/wireless/wl12xx/wl1271_boot.c
index 2be76ee42bb9..41c6affbee29 100644
--- a/drivers/net/wireless/wl12xx/wl1271_boot.c
+++ b/drivers/net/wireless/wl12xx/wl1271_boot.c
@@ -26,7 +26,6 @@
26#include "wl1271_acx.h" 26#include "wl1271_acx.h"
27#include "wl1271_reg.h" 27#include "wl1271_reg.h"
28#include "wl1271_boot.h" 28#include "wl1271_boot.h"
29#include "wl1271_spi.h"
30#include "wl1271_io.h" 29#include "wl1271_io.h"
31#include "wl1271_event.h" 30#include "wl1271_event.h"
32 31
@@ -229,6 +228,14 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
229 nvs_len = sizeof(wl->nvs->nvs); 228 nvs_len = sizeof(wl->nvs->nvs);
230 nvs_ptr = (u8 *)wl->nvs->nvs; 229 nvs_ptr = (u8 *)wl->nvs->nvs;
231 230
231 /* update current MAC address to NVS */
232 nvs_ptr[11] = wl->mac_addr[0];
233 nvs_ptr[10] = wl->mac_addr[1];
234 nvs_ptr[6] = wl->mac_addr[2];
235 nvs_ptr[5] = wl->mac_addr[3];
236 nvs_ptr[4] = wl->mac_addr[4];
237 nvs_ptr[3] = wl->mac_addr[5];
238
232 /* 239 /*
233 * Layout before the actual NVS tables: 240 * Layout before the actual NVS tables:
234 * 1 byte : burst length. 241 * 1 byte : burst length.
@@ -299,7 +306,7 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
299 306
300static void wl1271_boot_enable_interrupts(struct wl1271 *wl) 307static void wl1271_boot_enable_interrupts(struct wl1271 *wl)
301{ 308{
302 enable_irq(wl->irq); 309 wl1271_enable_interrupts(wl);
303 wl1271_write32(wl, ACX_REG_INTERRUPT_MASK, 310 wl1271_write32(wl, ACX_REG_INTERRUPT_MASK,
304 WL1271_ACX_INTR_ALL & ~(WL1271_INTR_MASK)); 311 WL1271_ACX_INTR_ALL & ~(WL1271_INTR_MASK));
305 wl1271_write32(wl, HI_CFG, HI_CFG_DEF_VAL); 312 wl1271_write32(wl, HI_CFG, HI_CFG_DEF_VAL);
diff --git a/drivers/net/wireless/wl12xx/wl1271_cmd.c b/drivers/net/wireless/wl12xx/wl1271_cmd.c
index 36a64e06f290..d005729e0312 100644
--- a/drivers/net/wireless/wl12xx/wl1271_cmd.c
+++ b/drivers/net/wireless/wl12xx/wl1271_cmd.c
@@ -26,10 +26,10 @@
26#include <linux/crc7.h> 26#include <linux/crc7.h>
27#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
28#include <linux/etherdevice.h> 28#include <linux/etherdevice.h>
29#include <linux/ieee80211.h>
29 30
30#include "wl1271.h" 31#include "wl1271.h"
31#include "wl1271_reg.h" 32#include "wl1271_reg.h"
32#include "wl1271_spi.h"
33#include "wl1271_io.h" 33#include "wl1271_io.h"
34#include "wl1271_acx.h" 34#include "wl1271_acx.h"
35#include "wl12xx_80211.h" 35#include "wl12xx_80211.h"
@@ -248,7 +248,7 @@ int wl1271_cmd_radio_parms(struct wl1271 *wl)
248 return ret; 248 return ret;
249} 249}
250 250
251int wl1271_cmd_join(struct wl1271 *wl) 251int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type)
252{ 252{
253 static bool do_cal = true; 253 static bool do_cal = true;
254 struct wl1271_cmd_join *join; 254 struct wl1271_cmd_join *join;
@@ -279,16 +279,7 @@ int wl1271_cmd_join(struct wl1271 *wl)
279 279
280 join->rx_config_options = cpu_to_le32(wl->rx_config); 280 join->rx_config_options = cpu_to_le32(wl->rx_config);
281 join->rx_filter_options = cpu_to_le32(wl->rx_filter); 281 join->rx_filter_options = cpu_to_le32(wl->rx_filter);
282 join->bss_type = wl->bss_type; 282 join->bss_type = bss_type;
283
284 /*
285 * FIXME: disable temporarily all filters because after commit
286 * 9cef8737 "mac80211: fix managed mode BSSID handling" broke
287 * association. The filter logic needs to be implemented properly
288 * and once that is done, this hack can be removed.
289 */
290 join->rx_config_options = cpu_to_le32(0);
291 join->rx_filter_options = cpu_to_le32(WL1271_DEFAULT_RX_FILTER);
292 283
293 if (wl->band == IEEE80211_BAND_2GHZ) 284 if (wl->band == IEEE80211_BAND_2GHZ)
294 join->basic_rate_set = cpu_to_le32(CONF_HW_BIT_RATE_1MBPS | 285 join->basic_rate_set = cpu_to_le32(CONF_HW_BIT_RATE_1MBPS |
@@ -319,8 +310,7 @@ int wl1271_cmd_join(struct wl1271 *wl)
319 310
320 /* reset TX security counters */ 311 /* reset TX security counters */
321 wl->tx_security_last_seq = 0; 312 wl->tx_security_last_seq = 0;
322 wl->tx_security_seq_16 = 0; 313 wl->tx_security_seq = 0;
323 wl->tx_security_seq_32 = 0;
324 314
325 ret = wl1271_cmd_send(wl, CMD_START_JOIN, join, sizeof(*join), 0); 315 ret = wl1271_cmd_send(wl, CMD_START_JOIN, join, sizeof(*join), 0);
326 if (ret < 0) { 316 if (ret < 0) {
@@ -548,9 +538,9 @@ out:
548 return ret; 538 return ret;
549} 539}
550 540
551int wl1271_cmd_scan(struct wl1271 *wl, u8 *ssid, size_t len, 541int wl1271_cmd_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len,
552 u8 active_scan, u8 high_prio, u8 band, 542 const u8 *ie, size_t ie_len, u8 active_scan,
553 u8 probe_requests) 543 u8 high_prio, u8 band, u8 probe_requests)
554{ 544{
555 545
556 struct wl1271_cmd_trigger_scan_to *trigger = NULL; 546 struct wl1271_cmd_trigger_scan_to *trigger = NULL;
@@ -621,12 +611,13 @@ int wl1271_cmd_scan(struct wl1271 *wl, u8 *ssid, size_t len,
621 611
622 params->params.num_channels = j; 612 params->params.num_channels = j;
623 613
624 if (len && ssid) { 614 if (ssid_len && ssid) {
625 params->params.ssid_len = len; 615 params->params.ssid_len = ssid_len;
626 memcpy(params->params.ssid, ssid, len); 616 memcpy(params->params.ssid, ssid, ssid_len);
627 } 617 }
628 618
629 ret = wl1271_cmd_build_probe_req(wl, ssid, len, ieee_band); 619 ret = wl1271_cmd_build_probe_req(wl, ssid, ssid_len,
620 ie, ie_len, ieee_band);
630 if (ret < 0) { 621 if (ret < 0) {
631 wl1271_error("PROBE request template failed"); 622 wl1271_error("PROBE request template failed");
632 goto out; 623 goto out;
@@ -657,9 +648,9 @@ int wl1271_cmd_scan(struct wl1271 *wl, u8 *ssid, size_t len,
657 wl->scan.active = active_scan; 648 wl->scan.active = active_scan;
658 wl->scan.high_prio = high_prio; 649 wl->scan.high_prio = high_prio;
659 wl->scan.probe_requests = probe_requests; 650 wl->scan.probe_requests = probe_requests;
660 if (len && ssid) { 651 if (ssid_len && ssid) {
661 wl->scan.ssid_len = len; 652 wl->scan.ssid_len = ssid_len;
662 memcpy(wl->scan.ssid, ssid, len); 653 memcpy(wl->scan.ssid, ssid, ssid_len);
663 } else 654 } else
664 wl->scan.ssid_len = 0; 655 wl->scan.ssid_len = 0;
665 } 656 }
@@ -716,155 +707,102 @@ out:
716 return ret; 707 return ret;
717} 708}
718 709
719static int wl1271_build_basic_rates(u8 *rates, u8 band) 710int wl1271_cmd_build_null_data(struct wl1271 *wl)
720{ 711{
721 u8 index = 0; 712 struct sk_buff *skb = NULL;
722 713 int size;
723 if (band == IEEE80211_BAND_2GHZ) { 714 void *ptr;
724 rates[index++] = 715 int ret = -ENOMEM;
725 IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
726 rates[index++] =
727 IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
728 rates[index++] =
729 IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
730 rates[index++] =
731 IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
732 } else if (band == IEEE80211_BAND_5GHZ) {
733 rates[index++] =
734 IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
735 rates[index++] =
736 IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB;
737 rates[index++] =
738 IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_24MB;
739 } else {
740 wl1271_error("build_basic_rates invalid band: %d", band);
741 }
742 716
743 return index;
744}
745 717
746static int wl1271_build_extended_rates(u8 *rates, u8 band) 718 if (wl->bss_type == BSS_TYPE_IBSS) {
747{ 719 size = sizeof(struct wl12xx_null_data_template);
748 u8 index = 0; 720 ptr = NULL;
749
750 if (band == IEEE80211_BAND_2GHZ) {
751 rates[index++] = IEEE80211_OFDM_RATE_6MB;
752 rates[index++] = IEEE80211_OFDM_RATE_9MB;
753 rates[index++] = IEEE80211_OFDM_RATE_12MB;
754 rates[index++] = IEEE80211_OFDM_RATE_18MB;
755 rates[index++] = IEEE80211_OFDM_RATE_24MB;
756 rates[index++] = IEEE80211_OFDM_RATE_36MB;
757 rates[index++] = IEEE80211_OFDM_RATE_48MB;
758 rates[index++] = IEEE80211_OFDM_RATE_54MB;
759 } else if (band == IEEE80211_BAND_5GHZ) {
760 rates[index++] =
761 IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB;
762 rates[index++] =
763 IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_18MB;
764 rates[index++] =
765 IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_24MB;
766 rates[index++] =
767 IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
768 rates[index++] =
769 IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
770 rates[index++] =
771 IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
772 } else { 721 } else {
773 wl1271_error("build_basic_rates invalid band: %d", band); 722 skb = ieee80211_nullfunc_get(wl->hw, wl->vif);
723 if (!skb)
724 goto out;
725 size = skb->len;
726 ptr = skb->data;
774 } 727 }
775 728
776 return index; 729 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, ptr, size);
777}
778 730
779int wl1271_cmd_build_null_data(struct wl1271 *wl) 731out:
780{ 732 dev_kfree_skb(skb);
781 struct wl12xx_null_data_template template; 733 if (ret)
782 734 wl1271_warning("cmd buld null data failed %d", ret);
783 if (!is_zero_ether_addr(wl->bssid)) {
784 memcpy(template.header.da, wl->bssid, ETH_ALEN);
785 memcpy(template.header.bssid, wl->bssid, ETH_ALEN);
786 } else {
787 memset(template.header.da, 0xff, ETH_ALEN);
788 memset(template.header.bssid, 0xff, ETH_ALEN);
789 }
790
791 memcpy(template.header.sa, wl->mac_addr, ETH_ALEN);
792 template.header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
793 IEEE80211_STYPE_NULLFUNC |
794 IEEE80211_FCTL_TODS);
795 735
796 return wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, &template, 736 return ret;
797 sizeof(template));
798 737
799} 738}
800 739
801int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid) 740int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid)
802{ 741{
803 struct wl12xx_ps_poll_template template; 742 struct sk_buff *skb;
804 743 int ret = 0;
805 memcpy(template.bssid, wl->bssid, ETH_ALEN);
806 memcpy(template.ta, wl->mac_addr, ETH_ALEN);
807
808 /* aid in PS-Poll has its two MSBs each set to 1 */
809 template.aid = cpu_to_le16(1 << 15 | 1 << 14 | aid);
810 744
811 template.fc = cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL); 745 skb = ieee80211_pspoll_get(wl->hw, wl->vif);
746 if (!skb)
747 goto out;
812 748
813 return wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, &template, 749 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, skb->data,
814 sizeof(template)); 750 skb->len);
815 751
752out:
753 dev_kfree_skb(skb);
754 return ret;
816} 755}
817 756
818int wl1271_cmd_build_probe_req(struct wl1271 *wl, u8 *ssid, size_t ssid_len, 757int wl1271_cmd_build_probe_req(struct wl1271 *wl,
819 u8 band) 758 const u8 *ssid, size_t ssid_len,
759 const u8 *ie, size_t ie_len, u8 band)
820{ 760{
821 struct wl12xx_probe_req_template template; 761 struct sk_buff *skb;
822 struct wl12xx_ie_rates *rates;
823 char *ptr;
824 u16 size;
825 int ret; 762 int ret;
826 763
827 ptr = (char *)&template; 764 skb = ieee80211_probereq_get(wl->hw, wl->vif, ssid, ssid_len,
828 size = sizeof(struct ieee80211_header); 765 ie, ie_len);
829 766 if (!skb) {
830 memset(template.header.da, 0xff, ETH_ALEN); 767 ret = -ENOMEM;
831 memset(template.header.bssid, 0xff, ETH_ALEN); 768 goto out;
832 memcpy(template.header.sa, wl->mac_addr, ETH_ALEN); 769 }
833 template.header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); 770
834 771 wl1271_dump(DEBUG_SCAN, "PROBE REQ: ", skb->data, skb->len);
835 /* IEs */
836 /* SSID */
837 template.ssid.header.id = WLAN_EID_SSID;
838 template.ssid.header.len = ssid_len;
839 if (ssid_len && ssid)
840 memcpy(template.ssid.ssid, ssid, ssid_len);
841 size += sizeof(struct wl12xx_ie_header) + ssid_len;
842 ptr += size;
843
844 /* Basic Rates */
845 rates = (struct wl12xx_ie_rates *)ptr;
846 rates->header.id = WLAN_EID_SUPP_RATES;
847 rates->header.len = wl1271_build_basic_rates(rates->rates, band);
848 size += sizeof(struct wl12xx_ie_header) + rates->header.len;
849 ptr += sizeof(struct wl12xx_ie_header) + rates->header.len;
850
851 /* Extended rates */
852 rates = (struct wl12xx_ie_rates *)ptr;
853 rates->header.id = WLAN_EID_EXT_SUPP_RATES;
854 rates->header.len = wl1271_build_extended_rates(rates->rates, band);
855 size += sizeof(struct wl12xx_ie_header) + rates->header.len;
856
857 wl1271_dump(DEBUG_SCAN, "PROBE REQ: ", &template, size);
858 772
859 if (band == IEEE80211_BAND_2GHZ) 773 if (band == IEEE80211_BAND_2GHZ)
860 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, 774 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4,
861 &template, size); 775 skb->data, skb->len);
862 else 776 else
863 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5, 777 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
864 &template, size); 778 skb->data, skb->len);
779
780out:
781 dev_kfree_skb(skb);
865 return ret; 782 return ret;
866} 783}
867 784
785int wl1271_build_qos_null_data(struct wl1271 *wl)
786{
787 struct ieee80211_qos_hdr template;
788
789 memset(&template, 0, sizeof(template));
790
791 memcpy(template.addr1, wl->bssid, ETH_ALEN);
792 memcpy(template.addr2, wl->mac_addr, ETH_ALEN);
793 memcpy(template.addr3, wl->bssid, ETH_ALEN);
794
795 template.frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
796 IEEE80211_STYPE_QOS_NULLFUNC |
797 IEEE80211_FCTL_TODS);
798
799 /* FIXME: not sure what priority to use here */
800 template.qos_ctrl = cpu_to_le16(0);
801
802 return wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, &template,
803 sizeof(template));
804}
805
868int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id) 806int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id)
869{ 807{
870 struct wl1271_cmd_set_keys *cmd; 808 struct wl1271_cmd_set_keys *cmd;
diff --git a/drivers/net/wireless/wl12xx/wl1271_cmd.h b/drivers/net/wireless/wl12xx/wl1271_cmd.h
index 2dc06c73532b..6324bbf36843 100644
--- a/drivers/net/wireless/wl12xx/wl1271_cmd.h
+++ b/drivers/net/wireless/wl12xx/wl1271_cmd.h
@@ -33,7 +33,7 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
33 size_t res_len); 33 size_t res_len);
34int wl1271_cmd_general_parms(struct wl1271 *wl); 34int wl1271_cmd_general_parms(struct wl1271 *wl);
35int wl1271_cmd_radio_parms(struct wl1271 *wl); 35int wl1271_cmd_radio_parms(struct wl1271 *wl);
36int wl1271_cmd_join(struct wl1271 *wl); 36int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type);
37int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer); 37int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer);
38int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len); 38int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len);
39int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len); 39int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len);
@@ -41,15 +41,17 @@ int wl1271_cmd_data_path(struct wl1271 *wl, bool enable);
41int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, bool send); 41int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, bool send);
42int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer, 42int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
43 size_t len); 43 size_t len);
44int wl1271_cmd_scan(struct wl1271 *wl, u8 *ssid, size_t len, 44int wl1271_cmd_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len,
45 u8 active_scan, u8 high_prio, u8 band, 45 const u8 *ie, size_t ie_len, u8 active_scan,
46 u8 probe_requests); 46 u8 high_prio, u8 band, u8 probe_requests);
47int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, 47int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
48 void *buf, size_t buf_len); 48 void *buf, size_t buf_len);
49int wl1271_cmd_build_null_data(struct wl1271 *wl); 49int wl1271_cmd_build_null_data(struct wl1271 *wl);
50int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid); 50int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid);
51int wl1271_cmd_build_probe_req(struct wl1271 *wl, u8 *ssid, size_t ssid_len, 51int wl1271_cmd_build_probe_req(struct wl1271 *wl,
52 u8 band); 52 const u8 *ssid, size_t ssid_len,
53 const u8 *ie, size_t ie_len, u8 band);
54int wl1271_build_qos_null_data(struct wl1271 *wl);
53int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id); 55int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id);
54int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, 56int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
55 u8 key_size, const u8 *key, const u8 *addr, 57 u8 key_size, const u8 *key, const u8 *addr,
diff --git a/drivers/net/wireless/wl12xx/wl1271_conf.h b/drivers/net/wireless/wl12xx/wl1271_conf.h
index 6f9e75cc5640..7fcfe06b1412 100644
--- a/drivers/net/wireless/wl12xx/wl1271_conf.h
+++ b/drivers/net/wireless/wl12xx/wl1271_conf.h
@@ -65,110 +65,318 @@ enum {
65 CONF_HW_RATE_INDEX_MAX = CONF_HW_RATE_INDEX_54MBPS, 65 CONF_HW_RATE_INDEX_MAX = CONF_HW_RATE_INDEX_54MBPS,
66}; 66};
67 67
68struct conf_sg_settings { 68enum {
69 CONF_SG_DISABLE = 0,
70 CONF_SG_PROTECTIVE,
71 CONF_SG_OPPORTUNISTIC
72};
73
74enum {
69 /* 75 /*
70 * Defines the PER threshold in PPM of the BT voice of which reaching 76 * PER threshold in PPM of the BT voice
71 * this value will trigger raising the priority of the BT voice by
72 * the BT IP until next NFS sample interval time as defined in
73 * nfs_sample_interval.
74 * 77 *
75 * Unit: PER value in PPM (parts per million) 78 * Range: 0 - 10000000
76 * #Error_packets / #Total_packets 79 */
80 CONF_SG_BT_PER_THRESHOLD = 0,
77 81
78 * Range: u32 82 /*
83 * Number of consequent RX_ACTIVE activities to override BT voice
84 * frames to ensure WLAN connection
85 *
86 * Range: 0 - 100
87 */
88 CONF_SG_HV3_MAX_OVERRIDE,
89
90 /*
91 * Defines the PER threshold of the BT voice
92 *
93 * Range: 0 - 65000
94 */
95 CONF_SG_BT_NFS_SAMPLE_INTERVAL,
96
97 /*
98 * Defines the load ratio of BT
99 *
100 * Range: 0 - 100 (%)
101 */
102 CONF_SG_BT_LOAD_RATIO,
103
104 /*
105 * Defines whether the SG will force WLAN host to enter/exit PSM
106 *
107 * Range: 1 - SG can force, 0 - host handles PSM
108 */
109 CONF_SG_AUTO_PS_MODE,
110
111 /*
112 * Compensation percentage of probe requests when scan initiated
113 * during BT voice/ACL link.
114 *
115 * Range: 0 - 255 (%)
116 */
117 CONF_SG_AUTO_SCAN_PROBE_REQ,
118
119 /*
120 * Compensation percentage of probe requests when active scan initiated
121 * during BT voice
122 *
123 * Range: 0 - 255 (%)
124 */
125 CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_HV3,
126
127 /*
128 * Defines antenna configuration (single/dual antenna)
129 *
130 * Range: 0 - single antenna, 1 - dual antenna
131 */
132 CONF_SG_ANTENNA_CONFIGURATION,
133
134 /*
135 * The threshold (percent) of max consequtive beacon misses before
136 * increasing priority of beacon reception.
137 *
138 * Range: 0 - 100 (%)
139 */
140 CONF_SG_BEACON_MISS_PERCENT,
141
142 /*
143 * The rate threshold below which receiving a data frame from the AP
144 * will increase the priority of the data frame above BT traffic.
145 *
146 * Range: 0,2, 5(=5.5), 6, 9, 11, 12, 18, 24, 36, 48, 54
147 */
148 CONF_SG_RATE_ADAPT_THRESH,
149
150 /*
151 * Not used currently.
152 *
153 * Range: 0
154 */
155 CONF_SG_RATE_ADAPT_SNR,
156
157 /*
158 * Configure the min and max time BT gains the antenna
159 * in WLAN PSM / BT master basic rate
160 *
161 * Range: 0 - 255 (ms)
162 */
163 CONF_SG_WLAN_PS_BT_ACL_MASTER_MIN_BR,
164 CONF_SG_WLAN_PS_BT_ACL_MASTER_MAX_BR,
165
166 /*
167 * The time after it expires no new WLAN trigger frame is trasmitted
168 * in WLAN PSM / BT master basic rate
169 *
170 * Range: 0 - 255 (ms)
171 */
172 CONF_SG_WLAN_PS_MAX_BT_ACL_MASTER_BR,
173
174 /*
175 * Configure the min and max time BT gains the antenna
176 * in WLAN PSM / BT slave basic rate
177 *
178 * Range: 0 - 255 (ms)
79 */ 179 */
80 u32 per_threshold; 180 CONF_SG_WLAN_PS_BT_ACL_SLAVE_MIN_BR,
181 CONF_SG_WLAN_PS_BT_ACL_SLAVE_MAX_BR,
81 182
82 /* 183 /*
83 * This value is an absolute time in micro-seconds to limit the 184 * The time after it expires no new WLAN trigger frame is trasmitted
84 * maximum scan duration compensation while in SG 185 * in WLAN PSM / BT slave basic rate
186 *
187 * Range: 0 - 255 (ms)
85 */ 188 */
86 u32 max_scan_compensation_time; 189 CONF_SG_WLAN_PS_MAX_BT_ACL_SLAVE_BR,
87 190
88 /* Defines the PER threshold of the BT voice of which reaching this 191 /*
89 * value will trigger raising the priority of the BT voice until next 192 * Configure the min and max time BT gains the antenna
90 * NFS sample interval time as defined in sample_interval. 193 * in WLAN PSM / BT master EDR
91 * 194 *
92 * Unit: msec 195 * Range: 0 - 255 (ms)
93 * Range: 1-65000
94 */ 196 */
95 u16 nfs_sample_interval; 197 CONF_SG_WLAN_PS_BT_ACL_MASTER_MIN_EDR,
198 CONF_SG_WLAN_PS_BT_ACL_MASTER_MAX_EDR,
96 199
97 /* 200 /*
98 * Defines the load ratio for the BT. 201 * The time after it expires no new WLAN trigger frame is trasmitted
99 * The WLAN ratio is: 100 - load_ratio 202 * in WLAN PSM / BT master EDR
100 * 203 *
101 * Unit: Percent 204 * Range: 0 - 255 (ms)
102 * Range: 0-100
103 */ 205 */
104 u8 load_ratio; 206 CONF_SG_WLAN_PS_MAX_BT_ACL_MASTER_EDR,
105 207
106 /* 208 /*
107 * true - Co-ex is allowed to enter/exit P.S automatically and 209 * Configure the min and max time BT gains the antenna
108 * transparently to the host 210 * in WLAN PSM / BT slave EDR
109 * 211 *
110 * false - Co-ex is disallowed to enter/exit P.S and will trigger an 212 * Range: 0 - 255 (ms)
111 * event to the host to notify for the need to enter/exit P.S 213 */
112 * due to BT change state 214 CONF_SG_WLAN_PS_BT_ACL_SLAVE_MIN_EDR,
215 CONF_SG_WLAN_PS_BT_ACL_SLAVE_MAX_EDR,
216
217 /*
218 * The time after it expires no new WLAN trigger frame is trasmitted
219 * in WLAN PSM / BT slave EDR
113 * 220 *
221 * Range: 0 - 255 (ms)
114 */ 222 */
115 u8 auto_ps_mode; 223 CONF_SG_WLAN_PS_MAX_BT_ACL_SLAVE_EDR,
116 224
117 /* 225 /*
118 * This parameter defines the compensation percentage of num of probe 226 * RX guard time before the beginning of a new BT voice frame during
119 * requests in case scan is initiated during BT voice/BT ACL 227 * which no new WLAN trigger frame is transmitted.
120 * guaranteed link.
121 * 228 *
122 * Unit: Percent 229 * Range: 0 - 100000 (us)
123 * Range: 0-255 (0 - No compensation)
124 */ 230 */
125 u8 probe_req_compensation; 231 CONF_SG_RXT,
126 232
127 /* 233 /*
128 * This parameter defines the compensation percentage of scan window 234 * TX guard time before the beginning of a new BT voice frame during
129 * size in case scan is initiated during BT voice/BT ACL Guaranteed 235 * which no new WLAN frame is transmitted.
130 * link.
131 * 236 *
132 * Unit: Percent 237 * Range: 0 - 100000 (us)
133 * Range: 0-255 (0 - No compensation)
134 */ 238 */
135 u8 scan_window_compensation; 239
240 CONF_SG_TXT,
136 241
137 /* 242 /*
138 * Defines the antenna configuration. 243 * Enable adaptive RXT/TXT algorithm. If disabled, the host values
244 * will be utilized.
139 * 245 *
140 * Range: 0 - Single Antenna; 1 - Dual Antenna 246 * Range: 0 - disable, 1 - enable
141 */ 247 */
142 u8 antenna_config; 248 CONF_SG_ADAPTIVE_RXT_TXT,
143 249
144 /* 250 /*
145 * The percent out of the Max consecutive beacon miss roaming trigger 251 * The used WLAN legacy service period during active BT ACL link
146 * which is the threshold for raising the priority of beacon
147 * reception.
148 * 252 *
149 * Range: 1-100 253 * Range: 0 - 255 (ms)
150 * N = MaxConsecutiveBeaconMiss
151 * P = coexMaxConsecutiveBeaconMissPrecent
152 * Threshold = MIN( N-1, round(N * P / 100))
153 */ 254 */
154 u8 beacon_miss_threshold; 255 CONF_SG_PS_POLL_TIMEOUT,
155 256
156 /* 257 /*
157 * The RX rate threshold below which rate adaptation is assumed to be 258 * The used WLAN UPSD service period during active BT ACL link
158 * occurring at the AP which will raise priority for ACTIVE_RX and RX
159 * SP.
160 * 259 *
161 * Range: HW_BIT_RATE_* 260 * Range: 0 - 255 (ms)
162 */ 261 */
163 u32 rate_adaptation_threshold; 262 CONF_SG_UPSD_TIMEOUT,
164 263
165 /* 264 /*
166 * The SNR above which the RX rate threshold indicating AP rate 265 * Configure the min and max time BT gains the antenna
167 * adaptation is valid 266 * in WLAN Active / BT master EDR
168 * 267 *
169 * Range: -128 - 127 268 * Range: 0 - 255 (ms)
170 */ 269 */
171 s8 rate_adaptation_snr; 270 CONF_SG_WLAN_ACTIVE_BT_ACL_MASTER_MIN_EDR,
271 CONF_SG_WLAN_ACTIVE_BT_ACL_MASTER_MAX_EDR,
272
273 /*
274 * The maximum time WLAN can gain the antenna for
275 * in WLAN Active / BT master EDR
276 *
277 * Range: 0 - 255 (ms)
278 */
279 CONF_SG_WLAN_ACTIVE_MAX_BT_ACL_MASTER_EDR,
280
281 /*
282 * Configure the min and max time BT gains the antenna
283 * in WLAN Active / BT slave EDR
284 *
285 * Range: 0 - 255 (ms)
286 */
287 CONF_SG_WLAN_ACTIVE_BT_ACL_SLAVE_MIN_EDR,
288 CONF_SG_WLAN_ACTIVE_BT_ACL_SLAVE_MAX_EDR,
289
290 /*
291 * The maximum time WLAN can gain the antenna for
292 * in WLAN Active / BT slave EDR
293 *
294 * Range: 0 - 255 (ms)
295 */
296 CONF_SG_WLAN_ACTIVE_MAX_BT_ACL_SLAVE_EDR,
297
298 /*
299 * Configure the min and max time BT gains the antenna
300 * in WLAN Active / BT basic rate
301 *
302 * Range: 0 - 255 (ms)
303 */
304 CONF_SG_WLAN_ACTIVE_BT_ACL_MIN_BR,
305 CONF_SG_WLAN_ACTIVE_BT_ACL_MAX_BR,
306
307 /*
308 * The maximum time WLAN can gain the antenna for
309 * in WLAN Active / BT basic rate
310 *
311 * Range: 0 - 255 (ms)
312 */
313 CONF_SG_WLAN_ACTIVE_MAX_BT_ACL_BR,
314
315 /*
316 * Compensation percentage of WLAN passive scan window if initiated
317 * during BT voice
318 *
319 * Range: 0 - 1000 (%)
320 */
321 CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_HV3,
322
323 /*
324 * Compensation percentage of WLAN passive scan window if initiated
325 * during BT A2DP
326 *
327 * Range: 0 - 1000 (%)
328 */
329 CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_A2DP,
330
331 /*
332 * Fixed time ensured for BT traffic to gain the antenna during WLAN
333 * passive scan.
334 *
335 * Range: 0 - 1000 ms
336 */
337 CONF_SG_PASSIVE_SCAN_A2DP_BT_TIME,
338
339 /*
340 * Fixed time ensured for WLAN traffic to gain the antenna during WLAN
341 * passive scan.
342 *
343 * Range: 0 - 1000 ms
344 */
345 CONF_SG_PASSIVE_SCAN_A2DP_WLAN_TIME,
346
347 /*
348 * Number of consequent BT voice frames not interrupted by WLAN
349 *
350 * Range: 0 - 100
351 */
352 CONF_SG_HV3_MAX_SERVED,
353
354 /*
355 * Protection time of the DHCP procedure.
356 *
357 * Range: 0 - 100000 (ms)
358 */
359 CONF_SG_DHCP_TIME,
360
361 /*
362 * Compensation percentage of WLAN active scan window if initiated
363 * during BT A2DP
364 *
365 * Range: 0 - 1000 (%)
366 */
367 CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_A2DP,
368 CONF_SG_TEMP_PARAM_1,
369 CONF_SG_TEMP_PARAM_2,
370 CONF_SG_TEMP_PARAM_3,
371 CONF_SG_TEMP_PARAM_4,
372 CONF_SG_TEMP_PARAM_5,
373 CONF_SG_PARAMS_MAX,
374 CONF_SG_PARAMS_ALL = 0xff
375};
376
377struct conf_sg_settings {
378 __le32 params[CONF_SG_PARAMS_MAX];
379 u8 state;
172}; 380};
173 381
174enum conf_rx_queue_type { 382enum conf_rx_queue_type {
diff --git a/drivers/net/wireless/wl12xx/wl1271_debugfs.c b/drivers/net/wireless/wl12xx/wl1271_debugfs.c
index 8d7588ca68fd..3c0f5b1ac272 100644
--- a/drivers/net/wireless/wl12xx/wl1271_debugfs.c
+++ b/drivers/net/wireless/wl12xx/wl1271_debugfs.c
@@ -28,6 +28,7 @@
28#include "wl1271.h" 28#include "wl1271.h"
29#include "wl1271_acx.h" 29#include "wl1271_acx.h"
30#include "wl1271_ps.h" 30#include "wl1271_ps.h"
31#include "wl1271_io.h"
31 32
32/* ms */ 33/* ms */
33#define WL1271_DEBUGFS_STATS_LIFETIME 1000 34#define WL1271_DEBUGFS_STATS_LIFETIME 1000
@@ -276,13 +277,10 @@ static ssize_t gpio_power_write(struct file *file,
276 goto out; 277 goto out;
277 } 278 }
278 279
279 if (value) { 280 if (value)
280 wl->set_power(true); 281 wl1271_power_on(wl);
281 set_bit(WL1271_FLAG_GPIO_POWER, &wl->flags); 282 else
282 } else { 283 wl1271_power_off(wl);
283 wl->set_power(false);
284 clear_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
285 }
286 284
287out: 285out:
288 mutex_unlock(&wl->mutex); 286 mutex_unlock(&wl->mutex);
diff --git a/drivers/net/wireless/wl12xx/wl1271_event.c b/drivers/net/wireless/wl12xx/wl1271_event.c
index 7468ef10194b..4d35af96c597 100644
--- a/drivers/net/wireless/wl12xx/wl1271_event.c
+++ b/drivers/net/wireless/wl12xx/wl1271_event.c
@@ -23,7 +23,6 @@
23 23
24#include "wl1271.h" 24#include "wl1271.h"
25#include "wl1271_reg.h" 25#include "wl1271_reg.h"
26#include "wl1271_spi.h"
27#include "wl1271_io.h" 26#include "wl1271_io.h"
28#include "wl1271_event.h" 27#include "wl1271_event.h"
29#include "wl1271_ps.h" 28#include "wl1271_ps.h"
@@ -45,7 +44,9 @@ static int wl1271_event_scan_complete(struct wl1271 *wl,
45 * scanning as it checks that. 44 * scanning as it checks that.
46 */ 45 */
47 clear_bit(WL1271_FLAG_SCANNING, &wl->flags); 46 clear_bit(WL1271_FLAG_SCANNING, &wl->flags);
47 /* FIXME: ie missing! */
48 wl1271_cmd_scan(wl, wl->scan.ssid, wl->scan.ssid_len, 48 wl1271_cmd_scan(wl, wl->scan.ssid, wl->scan.ssid_len,
49 NULL, 0,
49 wl->scan.active, 50 wl->scan.active,
50 wl->scan.high_prio, 51 wl->scan.high_prio,
51 WL1271_SCAN_BAND_5_GHZ, 52 WL1271_SCAN_BAND_5_GHZ,
diff --git a/drivers/net/wireless/wl12xx/wl1271_init.c b/drivers/net/wireless/wl12xx/wl1271_init.c
index 86c30a86a456..d9335fc2a575 100644
--- a/drivers/net/wireless/wl12xx/wl1271_init.c
+++ b/drivers/net/wireless/wl12xx/wl1271_init.c
@@ -160,11 +160,11 @@ int wl1271_init_pta(struct wl1271 *wl)
160{ 160{
161 int ret; 161 int ret;
162 162
163 ret = wl1271_acx_sg_enable(wl); 163 ret = wl1271_acx_sg_cfg(wl);
164 if (ret < 0) 164 if (ret < 0)
165 return ret; 165 return ret;
166 166
167 ret = wl1271_acx_sg_cfg(wl); 167 ret = wl1271_acx_sg_enable(wl, wl->sg_enabled);
168 if (ret < 0) 168 if (ret < 0)
169 return ret; 169 return ret;
170 170
diff --git a/drivers/net/wireless/wl12xx/wl1271_io.c b/drivers/net/wireless/wl12xx/wl1271_io.c
index 5cd94d5666c2..c8759acef131 100644
--- a/drivers/net/wireless/wl12xx/wl1271_io.c
+++ b/drivers/net/wireless/wl12xx/wl1271_io.c
@@ -28,30 +28,29 @@
28 28
29#include "wl1271.h" 29#include "wl1271.h"
30#include "wl12xx_80211.h" 30#include "wl12xx_80211.h"
31#include "wl1271_spi.h"
32#include "wl1271_io.h" 31#include "wl1271_io.h"
33 32
34static int wl1271_translate_addr(struct wl1271 *wl, int addr) 33#define OCP_CMD_LOOP 32
34
35#define OCP_CMD_WRITE 0x1
36#define OCP_CMD_READ 0x2
37
38#define OCP_READY_MASK BIT(18)
39#define OCP_STATUS_MASK (BIT(16) | BIT(17))
40
41#define OCP_STATUS_NO_RESP 0x00000
42#define OCP_STATUS_OK 0x10000
43#define OCP_STATUS_REQ_FAILED 0x20000
44#define OCP_STATUS_RESP_ERROR 0x30000
45
46void wl1271_disable_interrupts(struct wl1271 *wl)
35{ 47{
36 /* 48 wl->if_ops->disable_irq(wl);
37 * To translate, first check to which window of addresses the 49}
38 * particular address belongs. Then subtract the starting address 50
39 * of that window from the address. Then, add offset of the 51void wl1271_enable_interrupts(struct wl1271 *wl)
40 * translated region. 52{
41 * 53 wl->if_ops->enable_irq(wl);
42 * The translated regions occur next to each other in physical device
43 * memory, so just add the sizes of the preceeding address regions to
44 * get the offset to the new region.
45 *
46 * Currently, only the two first regions are addressed, and the
47 * assumption is that all addresses will fall into either of those
48 * two.
49 */
50 if ((addr >= wl->part.reg.start) &&
51 (addr < wl->part.reg.start + wl->part.reg.size))
52 return addr - wl->part.reg.start + wl->part.mem.size;
53 else
54 return addr - wl->part.mem.start;
55} 54}
56 55
57/* Set the SPI partitions to access the chip addresses 56/* Set the SPI partitions to access the chip addresses
@@ -117,54 +116,12 @@ int wl1271_set_partition(struct wl1271 *wl,
117 116
118void wl1271_io_reset(struct wl1271 *wl) 117void wl1271_io_reset(struct wl1271 *wl)
119{ 118{
120 wl1271_spi_reset(wl); 119 wl->if_ops->reset(wl);
121} 120}
122 121
123void wl1271_io_init(struct wl1271 *wl) 122void wl1271_io_init(struct wl1271 *wl)
124{ 123{
125 wl1271_spi_init(wl); 124 wl->if_ops->init(wl);
126}
127
128void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf,
129 size_t len, bool fixed)
130{
131 wl1271_spi_raw_write(wl, addr, buf, len, fixed);
132}
133
134void wl1271_raw_read(struct wl1271 *wl, int addr, void *buf,
135 size_t len, bool fixed)
136{
137 wl1271_spi_raw_read(wl, addr, buf, len, fixed);
138}
139
140void wl1271_read(struct wl1271 *wl, int addr, void *buf, size_t len,
141 bool fixed)
142{
143 int physical;
144
145 physical = wl1271_translate_addr(wl, addr);
146
147 wl1271_spi_raw_read(wl, physical, buf, len, fixed);
148}
149
150void wl1271_write(struct wl1271 *wl, int addr, void *buf, size_t len,
151 bool fixed)
152{
153 int physical;
154
155 physical = wl1271_translate_addr(wl, addr);
156
157 wl1271_spi_raw_write(wl, physical, buf, len, fixed);
158}
159
160u32 wl1271_read32(struct wl1271 *wl, int addr)
161{
162 return wl1271_raw_read32(wl, wl1271_translate_addr(wl, addr));
163}
164
165void wl1271_write32(struct wl1271 *wl, int addr, u32 val)
166{
167 wl1271_raw_write32(wl, wl1271_translate_addr(wl, addr), val);
168} 125}
169 126
170void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val) 127void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val)
diff --git a/drivers/net/wireless/wl12xx/wl1271_io.h b/drivers/net/wireless/wl12xx/wl1271_io.h
index fa9a0b35788f..d8837ef0bb40 100644
--- a/drivers/net/wireless/wl12xx/wl1271_io.h
+++ b/drivers/net/wireless/wl12xx/wl1271_io.h
@@ -25,31 +25,49 @@
25#ifndef __WL1271_IO_H__ 25#ifndef __WL1271_IO_H__
26#define __WL1271_IO_H__ 26#define __WL1271_IO_H__
27 27
28#include "wl1271_reg.h"
29
30#define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0
31
32#define HW_PARTITION_REGISTERS_ADDR 0x1FFC0
33#define HW_PART0_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR)
34#define HW_PART0_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 4)
35#define HW_PART1_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR + 8)
36#define HW_PART1_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 12)
37#define HW_PART2_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR + 16)
38#define HW_PART2_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 20)
39#define HW_PART3_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 24)
40
41#define HW_ACCESS_REGISTER_SIZE 4
42
43#define HW_ACCESS_PRAM_MAX_RANGE 0x3c000
44
28struct wl1271; 45struct wl1271;
29 46
47void wl1271_disable_interrupts(struct wl1271 *wl);
48void wl1271_enable_interrupts(struct wl1271 *wl);
49
30void wl1271_io_reset(struct wl1271 *wl); 50void wl1271_io_reset(struct wl1271 *wl);
31void wl1271_io_init(struct wl1271 *wl); 51void wl1271_io_init(struct wl1271 *wl);
32 52
33/* Raw target IO, address is not translated */ 53static inline struct device *wl1271_wl_to_dev(struct wl1271 *wl)
34void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf, 54{
35 size_t len, bool fixed); 55 return wl->if_ops->dev(wl);
36void wl1271_raw_read(struct wl1271 *wl, int addr, void *buf, 56}
37 size_t len, bool fixed);
38 57
39/* Translated target IO */
40void wl1271_read(struct wl1271 *wl, int addr, void *buf, size_t len,
41 bool fixed);
42void wl1271_write(struct wl1271 *wl, int addr, void *buf, size_t len,
43 bool fixed);
44u32 wl1271_read32(struct wl1271 *wl, int addr);
45void wl1271_write32(struct wl1271 *wl, int addr, u32 val);
46 58
47/* Top Register IO */ 59/* Raw target IO, address is not translated */
48void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val); 60static inline void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf,
49u16 wl1271_top_reg_read(struct wl1271 *wl, int addr); 61 size_t len, bool fixed)
62{
63 wl->if_ops->write(wl, addr, buf, len, fixed);
64}
50 65
51int wl1271_set_partition(struct wl1271 *wl, 66static inline void wl1271_raw_read(struct wl1271 *wl, int addr, void *buf,
52 struct wl1271_partition_set *p); 67 size_t len, bool fixed)
68{
69 wl->if_ops->read(wl, addr, buf, len, fixed);
70}
53 71
54static inline u32 wl1271_raw_read32(struct wl1271 *wl, int addr) 72static inline u32 wl1271_raw_read32(struct wl1271 *wl, int addr)
55{ 73{
@@ -65,4 +83,87 @@ static inline void wl1271_raw_write32(struct wl1271 *wl, int addr, u32 val)
65 wl1271_raw_write(wl, addr, &wl->buffer_32, 83 wl1271_raw_write(wl, addr, &wl->buffer_32,
66 sizeof(wl->buffer_32), false); 84 sizeof(wl->buffer_32), false);
67} 85}
86
87/* Translated target IO */
88static inline int wl1271_translate_addr(struct wl1271 *wl, int addr)
89{
90 /*
91 * To translate, first check to which window of addresses the
92 * particular address belongs. Then subtract the starting address
93 * of that window from the address. Then, add offset of the
94 * translated region.
95 *
96 * The translated regions occur next to each other in physical device
97 * memory, so just add the sizes of the preceeding address regions to
98 * get the offset to the new region.
99 *
100 * Currently, only the two first regions are addressed, and the
101 * assumption is that all addresses will fall into either of those
102 * two.
103 */
104 if ((addr >= wl->part.reg.start) &&
105 (addr < wl->part.reg.start + wl->part.reg.size))
106 return addr - wl->part.reg.start + wl->part.mem.size;
107 else
108 return addr - wl->part.mem.start;
109}
110
111static inline void wl1271_read(struct wl1271 *wl, int addr, void *buf,
112 size_t len, bool fixed)
113{
114 int physical;
115
116 physical = wl1271_translate_addr(wl, addr);
117
118 wl1271_raw_read(wl, physical, buf, len, fixed);
119}
120
121static inline void wl1271_write(struct wl1271 *wl, int addr, void *buf,
122 size_t len, bool fixed)
123{
124 int physical;
125
126 physical = wl1271_translate_addr(wl, addr);
127
128 wl1271_raw_write(wl, physical, buf, len, fixed);
129}
130
131static inline u32 wl1271_read32(struct wl1271 *wl, int addr)
132{
133 return wl1271_raw_read32(wl, wl1271_translate_addr(wl, addr));
134}
135
136static inline void wl1271_write32(struct wl1271 *wl, int addr, u32 val)
137{
138 wl1271_raw_write32(wl, wl1271_translate_addr(wl, addr), val);
139}
140
141static inline void wl1271_power_off(struct wl1271 *wl)
142{
143 wl->if_ops->power(wl, false);
144 clear_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
145}
146
147static inline void wl1271_power_on(struct wl1271 *wl)
148{
149 wl->if_ops->power(wl, true);
150 set_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
151}
152
153
154/* Top Register IO */
155void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val);
156u16 wl1271_top_reg_read(struct wl1271 *wl, int addr);
157
158int wl1271_set_partition(struct wl1271 *wl,
159 struct wl1271_partition_set *p);
160
161/* Functions from wl1271_main.c */
162
163int wl1271_register_hw(struct wl1271 *wl);
164void wl1271_unregister_hw(struct wl1271 *wl);
165int wl1271_init_ieee80211(struct wl1271 *wl);
166struct ieee80211_hw *wl1271_alloc_hw(void);
167int wl1271_free_hw(struct wl1271 *wl);
168
68#endif 169#endif
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c
index 2a864b24291d..6036d0206fec 100644
--- a/drivers/net/wireless/wl12xx/wl1271_main.c
+++ b/drivers/net/wireless/wl12xx/wl1271_main.c
@@ -22,22 +22,18 @@
22 */ 22 */
23 23
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/platform_device.h>
26#include <linux/interrupt.h>
27#include <linux/firmware.h> 25#include <linux/firmware.h>
28#include <linux/delay.h> 26#include <linux/delay.h>
29#include <linux/irq.h>
30#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
31#include <linux/crc32.h> 28#include <linux/crc32.h>
32#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
33#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
34#include <linux/spi/wl12xx.h>
35#include <linux/inetdevice.h> 31#include <linux/inetdevice.h>
32#include <linux/platform_device.h>
36 33
37#include "wl1271.h" 34#include "wl1271.h"
38#include "wl12xx_80211.h" 35#include "wl12xx_80211.h"
39#include "wl1271_reg.h" 36#include "wl1271_reg.h"
40#include "wl1271_spi.h"
41#include "wl1271_io.h" 37#include "wl1271_io.h"
42#include "wl1271_event.h" 38#include "wl1271_event.h"
43#include "wl1271_tx.h" 39#include "wl1271_tx.h"
@@ -53,17 +49,57 @@
53 49
54static struct conf_drv_settings default_conf = { 50static struct conf_drv_settings default_conf = {
55 .sg = { 51 .sg = {
56 .per_threshold = 7500, 52 .params = {
57 .max_scan_compensation_time = 120000, 53 [CONF_SG_BT_PER_THRESHOLD] = 7500,
58 .nfs_sample_interval = 400, 54 [CONF_SG_HV3_MAX_OVERRIDE] = 0,
59 .load_ratio = 50, 55 [CONF_SG_BT_NFS_SAMPLE_INTERVAL] = 400,
60 .auto_ps_mode = 0, 56 [CONF_SG_BT_LOAD_RATIO] = 50,
61 .probe_req_compensation = 170, 57 [CONF_SG_AUTO_PS_MODE] = 0,
62 .scan_window_compensation = 50, 58 [CONF_SG_AUTO_SCAN_PROBE_REQ] = 170,
63 .antenna_config = 0, 59 [CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_HV3] = 50,
64 .beacon_miss_threshold = 60, 60 [CONF_SG_ANTENNA_CONFIGURATION] = 0,
65 .rate_adaptation_threshold = CONF_HW_BIT_RATE_12MBPS, 61 [CONF_SG_BEACON_MISS_PERCENT] = 60,
66 .rate_adaptation_snr = 0 62 [CONF_SG_RATE_ADAPT_THRESH] = 12,
63 [CONF_SG_RATE_ADAPT_SNR] = 0,
64 [CONF_SG_WLAN_PS_BT_ACL_MASTER_MIN_BR] = 10,
65 [CONF_SG_WLAN_PS_BT_ACL_MASTER_MAX_BR] = 30,
66 [CONF_SG_WLAN_PS_MAX_BT_ACL_MASTER_BR] = 8,
67 [CONF_SG_WLAN_PS_BT_ACL_SLAVE_MIN_BR] = 20,
68 [CONF_SG_WLAN_PS_BT_ACL_SLAVE_MAX_BR] = 50,
69 /* Note: with UPSD, this should be 4 */
70 [CONF_SG_WLAN_PS_MAX_BT_ACL_SLAVE_BR] = 8,
71 [CONF_SG_WLAN_PS_BT_ACL_MASTER_MIN_EDR] = 7,
72 [CONF_SG_WLAN_PS_BT_ACL_MASTER_MAX_EDR] = 25,
73 [CONF_SG_WLAN_PS_MAX_BT_ACL_MASTER_EDR] = 20,
74 /* Note: with UPDS, this should be 15 */
75 [CONF_SG_WLAN_PS_BT_ACL_SLAVE_MIN_EDR] = 8,
76 /* Note: with UPDS, this should be 50 */
77 [CONF_SG_WLAN_PS_BT_ACL_SLAVE_MAX_EDR] = 40,
78 /* Note: with UPDS, this should be 10 */
79 [CONF_SG_WLAN_PS_MAX_BT_ACL_SLAVE_EDR] = 20,
80 [CONF_SG_RXT] = 1200,
81 [CONF_SG_TXT] = 1000,
82 [CONF_SG_ADAPTIVE_RXT_TXT] = 1,
83 [CONF_SG_PS_POLL_TIMEOUT] = 10,
84 [CONF_SG_UPSD_TIMEOUT] = 10,
85 [CONF_SG_WLAN_ACTIVE_BT_ACL_MASTER_MIN_EDR] = 7,
86 [CONF_SG_WLAN_ACTIVE_BT_ACL_MASTER_MAX_EDR] = 15,
87 [CONF_SG_WLAN_ACTIVE_MAX_BT_ACL_MASTER_EDR] = 15,
88 [CONF_SG_WLAN_ACTIVE_BT_ACL_SLAVE_MIN_EDR] = 8,
89 [CONF_SG_WLAN_ACTIVE_BT_ACL_SLAVE_MAX_EDR] = 20,
90 [CONF_SG_WLAN_ACTIVE_MAX_BT_ACL_SLAVE_EDR] = 15,
91 [CONF_SG_WLAN_ACTIVE_BT_ACL_MIN_BR] = 20,
92 [CONF_SG_WLAN_ACTIVE_BT_ACL_MAX_BR] = 50,
93 [CONF_SG_WLAN_ACTIVE_MAX_BT_ACL_BR] = 10,
94 [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_HV3] = 200,
95 [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_A2DP] = 800,
96 [CONF_SG_PASSIVE_SCAN_A2DP_BT_TIME] = 75,
97 [CONF_SG_PASSIVE_SCAN_A2DP_WLAN_TIME] = 15,
98 [CONF_SG_HV3_MAX_SERVED] = 6,
99 [CONF_SG_DHCP_TIME] = 5000,
100 [CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_A2DP] = 100,
101 },
102 .state = CONF_SG_PROTECTIVE,
67 }, 103 },
68 .rx = { 104 .rx = {
69 .rx_msdu_life_time = 512000, 105 .rx_msdu_life_time = 512000,
@@ -245,6 +281,21 @@ static struct conf_drv_settings default_conf = {
245 } 281 }
246}; 282};
247 283
284static void wl1271_device_release(struct device *dev)
285{
286
287}
288
289static struct platform_device wl1271_device = {
290 .name = "wl1271",
291 .id = -1,
292
293 /* device model insists to have a release function */
294 .dev = {
295 .release = wl1271_device_release,
296 },
297};
298
248static LIST_HEAD(wl_list); 299static LIST_HEAD(wl_list);
249 300
250static void wl1271_conf_init(struct wl1271 *wl) 301static void wl1271_conf_init(struct wl1271 *wl)
@@ -364,30 +415,14 @@ static int wl1271_plt_init(struct wl1271 *wl)
364 return ret; 415 return ret;
365} 416}
366 417
367static void wl1271_disable_interrupts(struct wl1271 *wl)
368{
369 disable_irq(wl->irq);
370}
371
372static void wl1271_power_off(struct wl1271 *wl)
373{
374 wl->set_power(false);
375 clear_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
376}
377
378static void wl1271_power_on(struct wl1271 *wl)
379{
380 wl->set_power(true);
381 set_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
382}
383
384static void wl1271_fw_status(struct wl1271 *wl, 418static void wl1271_fw_status(struct wl1271 *wl,
385 struct wl1271_fw_status *status) 419 struct wl1271_fw_status *status)
386{ 420{
421 struct timespec ts;
387 u32 total = 0; 422 u32 total = 0;
388 int i; 423 int i;
389 424
390 wl1271_read(wl, FW_STATUS_ADDR, status, sizeof(*status), false); 425 wl1271_raw_read(wl, FW_STATUS_ADDR, status, sizeof(*status), false);
391 426
392 wl1271_debug(DEBUG_IRQ, "intr: 0x%x (fw_rx_counter = %d, " 427 wl1271_debug(DEBUG_IRQ, "intr: 0x%x (fw_rx_counter = %d, "
393 "drv_rx_counter = %d, tx_results_counter = %d)", 428 "drv_rx_counter = %d, tx_results_counter = %d)",
@@ -412,14 +447,19 @@ static void wl1271_fw_status(struct wl1271 *wl,
412 ieee80211_queue_work(wl->hw, &wl->tx_work); 447 ieee80211_queue_work(wl->hw, &wl->tx_work);
413 448
414 /* update the host-chipset time offset */ 449 /* update the host-chipset time offset */
415 wl->time_offset = jiffies_to_usecs(jiffies) - 450 getnstimeofday(&ts);
416 le32_to_cpu(status->fw_localtime); 451 wl->time_offset = (timespec_to_ns(&ts) >> 10) -
452 (s64)le32_to_cpu(status->fw_localtime);
417} 453}
418 454
455#define WL1271_IRQ_MAX_LOOPS 10
456
419static void wl1271_irq_work(struct work_struct *work) 457static void wl1271_irq_work(struct work_struct *work)
420{ 458{
421 int ret; 459 int ret;
422 u32 intr; 460 u32 intr;
461 int loopcount = WL1271_IRQ_MAX_LOOPS;
462 unsigned long flags;
423 struct wl1271 *wl = 463 struct wl1271 *wl =
424 container_of(work, struct wl1271, irq_work); 464 container_of(work, struct wl1271, irq_work);
425 465
@@ -427,91 +467,77 @@ static void wl1271_irq_work(struct work_struct *work)
427 467
428 wl1271_debug(DEBUG_IRQ, "IRQ work"); 468 wl1271_debug(DEBUG_IRQ, "IRQ work");
429 469
430 if (wl->state == WL1271_STATE_OFF) 470 if (unlikely(wl->state == WL1271_STATE_OFF))
431 goto out; 471 goto out;
432 472
433 ret = wl1271_ps_elp_wakeup(wl, true); 473 ret = wl1271_ps_elp_wakeup(wl, true);
434 if (ret < 0) 474 if (ret < 0)
435 goto out; 475 goto out;
436 476
437 wl1271_write32(wl, ACX_REG_INTERRUPT_MASK, WL1271_ACX_INTR_ALL); 477 spin_lock_irqsave(&wl->wl_lock, flags);
438 478 while (test_bit(WL1271_FLAG_IRQ_PENDING, &wl->flags) && loopcount) {
439 wl1271_fw_status(wl, wl->fw_status); 479 clear_bit(WL1271_FLAG_IRQ_PENDING, &wl->flags);
440 intr = le32_to_cpu(wl->fw_status->intr); 480 spin_unlock_irqrestore(&wl->wl_lock, flags);
441 if (!intr) { 481 loopcount--;
442 wl1271_debug(DEBUG_IRQ, "Zero interrupt received."); 482
443 goto out_sleep; 483 wl1271_fw_status(wl, wl->fw_status);
444 } 484 intr = le32_to_cpu(wl->fw_status->intr);
485 if (!intr) {
486 wl1271_debug(DEBUG_IRQ, "Zero interrupt received.");
487 continue;
488 }
445 489
446 intr &= WL1271_INTR_MASK; 490 intr &= WL1271_INTR_MASK;
447 491
448 if (intr & WL1271_ACX_INTR_EVENT_A) { 492 if (intr & WL1271_ACX_INTR_DATA) {
449 wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_EVENT_A"); 493 wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_DATA");
450 wl1271_event_handle(wl, 0);
451 }
452 494
453 if (intr & WL1271_ACX_INTR_EVENT_B) { 495 /* check for tx results */
454 wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_EVENT_B"); 496 if (wl->fw_status->tx_results_counter !=
455 wl1271_event_handle(wl, 1); 497 (wl->tx_results_count & 0xff))
456 } 498 wl1271_tx_complete(wl);
457 499
458 if (intr & WL1271_ACX_INTR_INIT_COMPLETE) 500 wl1271_rx(wl, wl->fw_status);
459 wl1271_debug(DEBUG_IRQ, 501 }
460 "WL1271_ACX_INTR_INIT_COMPLETE");
461 502
462 if (intr & WL1271_ACX_INTR_HW_AVAILABLE) 503 if (intr & WL1271_ACX_INTR_EVENT_A) {
463 wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_HW_AVAILABLE"); 504 wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_EVENT_A");
505 wl1271_event_handle(wl, 0);
506 }
464 507
465 if (intr & WL1271_ACX_INTR_DATA) { 508 if (intr & WL1271_ACX_INTR_EVENT_B) {
466 u8 tx_res_cnt = wl->fw_status->tx_results_counter - 509 wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_EVENT_B");
467 wl->tx_results_count; 510 wl1271_event_handle(wl, 1);
511 }
468 512
469 wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_DATA"); 513 if (intr & WL1271_ACX_INTR_INIT_COMPLETE)
514 wl1271_debug(DEBUG_IRQ,
515 "WL1271_ACX_INTR_INIT_COMPLETE");
470 516
471 /* check for tx results */ 517 if (intr & WL1271_ACX_INTR_HW_AVAILABLE)
472 if (tx_res_cnt) 518 wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_HW_AVAILABLE");
473 wl1271_tx_complete(wl, tx_res_cnt);
474 519
475 wl1271_rx(wl, wl->fw_status); 520 spin_lock_irqsave(&wl->wl_lock, flags);
476 } 521 }
477 522
478out_sleep: 523 if (test_bit(WL1271_FLAG_IRQ_PENDING, &wl->flags))
479 wl1271_write32(wl, ACX_REG_INTERRUPT_MASK, 524 ieee80211_queue_work(wl->hw, &wl->irq_work);
480 WL1271_ACX_INTR_ALL & ~(WL1271_INTR_MASK)); 525 else
526 clear_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags);
527 spin_unlock_irqrestore(&wl->wl_lock, flags);
528
481 wl1271_ps_elp_sleep(wl); 529 wl1271_ps_elp_sleep(wl);
482 530
483out: 531out:
484 mutex_unlock(&wl->mutex); 532 mutex_unlock(&wl->mutex);
485} 533}
486 534
487static irqreturn_t wl1271_irq(int irq, void *cookie)
488{
489 struct wl1271 *wl;
490 unsigned long flags;
491
492 wl1271_debug(DEBUG_IRQ, "IRQ");
493
494 wl = cookie;
495
496 /* complete the ELP completion */
497 spin_lock_irqsave(&wl->wl_lock, flags);
498 if (wl->elp_compl) {
499 complete(wl->elp_compl);
500 wl->elp_compl = NULL;
501 }
502
503 ieee80211_queue_work(wl->hw, &wl->irq_work);
504 spin_unlock_irqrestore(&wl->wl_lock, flags);
505
506 return IRQ_HANDLED;
507}
508
509static int wl1271_fetch_firmware(struct wl1271 *wl) 535static int wl1271_fetch_firmware(struct wl1271 *wl)
510{ 536{
511 const struct firmware *fw; 537 const struct firmware *fw;
512 int ret; 538 int ret;
513 539
514 ret = request_firmware(&fw, WL1271_FW_NAME, &wl->spi->dev); 540 ret = request_firmware(&fw, WL1271_FW_NAME, wl1271_wl_to_dev(wl));
515 541
516 if (ret < 0) { 542 if (ret < 0) {
517 wl1271_error("could not get firmware: %d", ret); 543 wl1271_error("could not get firmware: %d", ret);
@@ -544,46 +570,12 @@ out:
544 return ret; 570 return ret;
545} 571}
546 572
547static int wl1271_update_mac_addr(struct wl1271 *wl)
548{
549 int ret = 0;
550 u8 *nvs_ptr = (u8 *)wl->nvs->nvs;
551
552 /* get mac address from the NVS */
553 wl->mac_addr[0] = nvs_ptr[11];
554 wl->mac_addr[1] = nvs_ptr[10];
555 wl->mac_addr[2] = nvs_ptr[6];
556 wl->mac_addr[3] = nvs_ptr[5];
557 wl->mac_addr[4] = nvs_ptr[4];
558 wl->mac_addr[5] = nvs_ptr[3];
559
560 /* FIXME: if it is a zero-address, we should bail out. Now, instead,
561 we randomize an address */
562 if (is_zero_ether_addr(wl->mac_addr)) {
563 static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
564 memcpy(wl->mac_addr, nokia_oui, 3);
565 get_random_bytes(wl->mac_addr + 3, 3);
566
567 /* update this address to the NVS */
568 nvs_ptr[11] = wl->mac_addr[0];
569 nvs_ptr[10] = wl->mac_addr[1];
570 nvs_ptr[6] = wl->mac_addr[2];
571 nvs_ptr[5] = wl->mac_addr[3];
572 nvs_ptr[4] = wl->mac_addr[4];
573 nvs_ptr[3] = wl->mac_addr[5];
574 }
575
576 SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr);
577
578 return ret;
579}
580
581static int wl1271_fetch_nvs(struct wl1271 *wl) 573static int wl1271_fetch_nvs(struct wl1271 *wl)
582{ 574{
583 const struct firmware *fw; 575 const struct firmware *fw;
584 int ret; 576 int ret;
585 577
586 ret = request_firmware(&fw, WL1271_NVS_NAME, &wl->spi->dev); 578 ret = request_firmware(&fw, WL1271_NVS_NAME, wl1271_wl_to_dev(wl));
587 579
588 if (ret < 0) { 580 if (ret < 0) {
589 wl1271_error("could not get nvs file: %d", ret); 581 wl1271_error("could not get nvs file: %d", ret);
@@ -607,8 +599,6 @@ static int wl1271_fetch_nvs(struct wl1271 *wl)
607 599
608 memcpy(wl->nvs, fw->data, sizeof(struct wl1271_nvs_file)); 600 memcpy(wl->nvs, fw->data, sizeof(struct wl1271_nvs_file));
609 601
610 ret = wl1271_update_mac_addr(wl);
611
612out: 602out:
613 release_firmware(fw); 603 release_firmware(fw);
614 604
@@ -825,15 +815,13 @@ static int wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
825 * The workqueue is slow to process the tx_queue and we need stop 815 * The workqueue is slow to process the tx_queue and we need stop
826 * the queue here, otherwise the queue will get too long. 816 * the queue here, otherwise the queue will get too long.
827 */ 817 */
828 if (skb_queue_len(&wl->tx_queue) >= WL1271_TX_QUEUE_MAX_LENGTH) { 818 if (skb_queue_len(&wl->tx_queue) >= WL1271_TX_QUEUE_HIGH_WATERMARK) {
829 ieee80211_stop_queues(wl->hw); 819 wl1271_debug(DEBUG_TX, "op_tx: stopping queues");
830 820
831 /* 821 spin_lock_irqsave(&wl->wl_lock, flags);
832 * FIXME: this is racy, the variable is not properly 822 ieee80211_stop_queues(wl->hw);
833 * protected. Maybe fix this by removing the stupid
834 * variable altogether and checking the real queue state?
835 */
836 set_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags); 823 set_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags);
824 spin_unlock_irqrestore(&wl->wl_lock, flags);
837 } 825 }
838 826
839 return NETDEV_TX_OK; 827 return NETDEV_TX_OK;
@@ -928,13 +916,58 @@ static struct notifier_block wl1271_dev_notifier = {
928 916
929static int wl1271_op_start(struct ieee80211_hw *hw) 917static int wl1271_op_start(struct ieee80211_hw *hw)
930{ 918{
919 wl1271_debug(DEBUG_MAC80211, "mac80211 start");
920
921 /*
922 * We have to delay the booting of the hardware because
923 * we need to know the local MAC address before downloading and
924 * initializing the firmware. The MAC address cannot be changed
925 * after boot, and without the proper MAC address, the firmware
926 * will not function properly.
927 *
928 * The MAC address is first known when the corresponding interface
929 * is added. That is where we will initialize the hardware.
930 */
931
932 return 0;
933}
934
935static void wl1271_op_stop(struct ieee80211_hw *hw)
936{
937 wl1271_debug(DEBUG_MAC80211, "mac80211 stop");
938}
939
940static int wl1271_op_add_interface(struct ieee80211_hw *hw,
941 struct ieee80211_vif *vif)
942{
931 struct wl1271 *wl = hw->priv; 943 struct wl1271 *wl = hw->priv;
932 int retries = WL1271_BOOT_RETRIES; 944 int retries = WL1271_BOOT_RETRIES;
933 int ret = 0; 945 int ret = 0;
934 946
935 wl1271_debug(DEBUG_MAC80211, "mac80211 start"); 947 wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM",
948 vif->type, vif->addr);
936 949
937 mutex_lock(&wl->mutex); 950 mutex_lock(&wl->mutex);
951 if (wl->vif) {
952 ret = -EBUSY;
953 goto out;
954 }
955
956 wl->vif = vif;
957
958 switch (vif->type) {
959 case NL80211_IFTYPE_STATION:
960 wl->bss_type = BSS_TYPE_STA_BSS;
961 break;
962 case NL80211_IFTYPE_ADHOC:
963 wl->bss_type = BSS_TYPE_IBSS;
964 break;
965 default:
966 ret = -EOPNOTSUPP;
967 goto out;
968 }
969
970 memcpy(wl->mac_addr, vif->addr, ETH_ALEN);
938 971
939 if (wl->state != WL1271_STATE_OFF) { 972 if (wl->state != WL1271_STATE_OFF) {
940 wl1271_error("cannot start because not in off state: %d", 973 wl1271_error("cannot start because not in off state: %d",
@@ -990,19 +1023,20 @@ out:
990 return ret; 1023 return ret;
991} 1024}
992 1025
993static void wl1271_op_stop(struct ieee80211_hw *hw) 1026static void wl1271_op_remove_interface(struct ieee80211_hw *hw,
1027 struct ieee80211_vif *vif)
994{ 1028{
995 struct wl1271 *wl = hw->priv; 1029 struct wl1271 *wl = hw->priv;
996 int i; 1030 int i;
997 1031
998 wl1271_info("down");
999
1000 wl1271_debug(DEBUG_MAC80211, "mac80211 stop");
1001
1002 unregister_inetaddr_notifier(&wl1271_dev_notifier); 1032 unregister_inetaddr_notifier(&wl1271_dev_notifier);
1003 list_del(&wl->list);
1004 1033
1005 mutex_lock(&wl->mutex); 1034 mutex_lock(&wl->mutex);
1035 wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface");
1036
1037 wl1271_info("down");
1038
1039 list_del(&wl->list);
1006 1040
1007 WARN_ON(wl->state != WL1271_STATE_ON); 1041 WARN_ON(wl->state != WL1271_STATE_ON);
1008 1042
@@ -1040,13 +1074,14 @@ static void wl1271_op_stop(struct ieee80211_hw *hw)
1040 wl->tx_results_count = 0; 1074 wl->tx_results_count = 0;
1041 wl->tx_packets_count = 0; 1075 wl->tx_packets_count = 0;
1042 wl->tx_security_last_seq = 0; 1076 wl->tx_security_last_seq = 0;
1043 wl->tx_security_seq_16 = 0; 1077 wl->tx_security_seq = 0;
1044 wl->tx_security_seq_32 = 0;
1045 wl->time_offset = 0; 1078 wl->time_offset = 0;
1046 wl->session_counter = 0; 1079 wl->session_counter = 0;
1047 wl->rate_set = CONF_TX_RATE_MASK_BASIC; 1080 wl->rate_set = CONF_TX_RATE_MASK_BASIC;
1048 wl->sta_rate_set = 0; 1081 wl->sta_rate_set = 0;
1049 wl->flags = 0; 1082 wl->flags = 0;
1083 wl->vif = NULL;
1084 wl->filters = 0;
1050 1085
1051 for (i = 0; i < NUM_TX_QUEUES; i++) 1086 for (i = 0; i < NUM_TX_QUEUES; i++)
1052 wl->tx_blocks_freed[i] = 0; 1087 wl->tx_blocks_freed[i] = 0;
@@ -1055,119 +1090,39 @@ static void wl1271_op_stop(struct ieee80211_hw *hw)
1055 mutex_unlock(&wl->mutex); 1090 mutex_unlock(&wl->mutex);
1056} 1091}
1057 1092
1058static int wl1271_op_add_interface(struct ieee80211_hw *hw, 1093static void wl1271_configure_filters(struct wl1271 *wl, unsigned int filters)
1059 struct ieee80211_vif *vif)
1060{ 1094{
1061 struct wl1271 *wl = hw->priv; 1095 wl->rx_config = WL1271_DEFAULT_RX_CONFIG;
1062 int ret = 0; 1096 wl->rx_filter = WL1271_DEFAULT_RX_FILTER;
1063
1064 wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM",
1065 vif->type, vif->addr);
1066 1097
1067 mutex_lock(&wl->mutex); 1098 /* combine requested filters with current filter config */
1068 if (wl->vif) { 1099 filters = wl->filters | filters;
1069 ret = -EBUSY;
1070 goto out;
1071 }
1072 1100
1073 wl->vif = vif; 1101 wl1271_debug(DEBUG_FILTERS, "RX filters set: ");
1074 1102
1075 switch (vif->type) { 1103 if (filters & FIF_PROMISC_IN_BSS) {
1076 case NL80211_IFTYPE_STATION: 1104 wl1271_debug(DEBUG_FILTERS, " - FIF_PROMISC_IN_BSS");
1077 wl->bss_type = BSS_TYPE_STA_BSS; 1105 wl->rx_config &= ~CFG_UNI_FILTER_EN;
1078 break; 1106 wl->rx_config |= CFG_BSSID_FILTER_EN;
1079 case NL80211_IFTYPE_ADHOC:
1080 wl->bss_type = BSS_TYPE_IBSS;
1081 break;
1082 default:
1083 ret = -EOPNOTSUPP;
1084 goto out;
1085 } 1107 }
1086 1108 if (filters & FIF_BCN_PRBRESP_PROMISC) {
1087 /* FIXME: what if conf->mac_addr changes? */ 1109 wl1271_debug(DEBUG_FILTERS, " - FIF_BCN_PRBRESP_PROMISC");
1088 1110 wl->rx_config &= ~CFG_BSSID_FILTER_EN;
1089out: 1111 wl->rx_config &= ~CFG_SSID_FILTER_EN;
1090 mutex_unlock(&wl->mutex);
1091 return ret;
1092}
1093
1094static void wl1271_op_remove_interface(struct ieee80211_hw *hw,
1095 struct ieee80211_vif *vif)
1096{
1097 struct wl1271 *wl = hw->priv;
1098
1099 mutex_lock(&wl->mutex);
1100 wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface");
1101 wl->vif = NULL;
1102 mutex_unlock(&wl->mutex);
1103}
1104
1105#if 0
1106static int wl1271_op_config_interface(struct ieee80211_hw *hw,
1107 struct ieee80211_vif *vif,
1108 struct ieee80211_if_conf *conf)
1109{
1110 struct wl1271 *wl = hw->priv;
1111 struct sk_buff *beacon;
1112 int ret;
1113
1114 wl1271_debug(DEBUG_MAC80211, "mac80211 config_interface bssid %pM",
1115 conf->bssid);
1116 wl1271_dump_ascii(DEBUG_MAC80211, "ssid: ", conf->ssid,
1117 conf->ssid_len);
1118
1119 mutex_lock(&wl->mutex);
1120
1121 ret = wl1271_ps_elp_wakeup(wl, false);
1122 if (ret < 0)
1123 goto out;
1124
1125 if (memcmp(wl->bssid, conf->bssid, ETH_ALEN)) {
1126 wl1271_debug(DEBUG_MAC80211, "bssid changed");
1127
1128 memcpy(wl->bssid, conf->bssid, ETH_ALEN);
1129
1130 ret = wl1271_cmd_join(wl);
1131 if (ret < 0)
1132 goto out_sleep;
1133
1134 ret = wl1271_cmd_build_null_data(wl);
1135 if (ret < 0)
1136 goto out_sleep;
1137 } 1112 }
1138 1113 if (filters & FIF_OTHER_BSS) {
1139 wl->ssid_len = conf->ssid_len; 1114 wl1271_debug(DEBUG_FILTERS, " - FIF_OTHER_BSS");
1140 if (wl->ssid_len) 1115 wl->rx_config &= ~CFG_BSSID_FILTER_EN;
1141 memcpy(wl->ssid, conf->ssid, wl->ssid_len); 1116 }
1142 1117 if (filters & FIF_CONTROL) {
1143 if (conf->changed & IEEE80211_IFCC_BEACON) { 1118 wl1271_debug(DEBUG_FILTERS, " - FIF_CONTROL");
1144 beacon = ieee80211_beacon_get(hw, vif); 1119 wl->rx_filter |= CFG_RX_CTL_EN;
1145 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, 1120 }
1146 beacon->data, beacon->len); 1121 if (filters & FIF_FCSFAIL) {
1147 1122 wl1271_debug(DEBUG_FILTERS, " - FIF_FCSFAIL");
1148 if (ret < 0) { 1123 wl->rx_filter |= CFG_RX_FCS_ERROR;
1149 dev_kfree_skb(beacon);
1150 goto out_sleep;
1151 }
1152
1153 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE,
1154 beacon->data, beacon->len);
1155
1156 dev_kfree_skb(beacon);
1157
1158 if (ret < 0)
1159 goto out_sleep;
1160 } 1124 }
1161
1162out_sleep:
1163 wl1271_ps_elp_sleep(wl);
1164
1165out:
1166 mutex_unlock(&wl->mutex);
1167
1168 return ret;
1169} 1125}
1170#endif
1171 1126
1172static int wl1271_join_channel(struct wl1271 *wl, int channel) 1127static int wl1271_join_channel(struct wl1271 *wl, int channel)
1173{ 1128{
@@ -1176,17 +1131,16 @@ static int wl1271_join_channel(struct wl1271 *wl, int channel)
1176 static const u8 dummy_bssid[ETH_ALEN] = { 0x0b, 0xad, 0xde, 1131 static const u8 dummy_bssid[ETH_ALEN] = { 0x0b, 0xad, 0xde,
1177 0xad, 0xbe, 0xef }; 1132 0xad, 0xbe, 0xef };
1178 1133
1179 /* the dummy join is not required for ad-hoc */
1180 if (wl->bss_type == BSS_TYPE_IBSS)
1181 goto out;
1182
1183 /* disable mac filter, so we hear everything */
1184 wl->rx_config &= ~CFG_BSSID_FILTER_EN;
1185
1186 wl->channel = channel; 1134 wl->channel = channel;
1187 memcpy(wl->bssid, dummy_bssid, ETH_ALEN); 1135 memcpy(wl->bssid, dummy_bssid, ETH_ALEN);
1188 1136
1189 ret = wl1271_cmd_join(wl); 1137 /* pass through frames from all BSS */
1138 wl1271_configure_filters(wl, FIF_OTHER_BSS);
1139
1140 /* the dummy join is performed always with STATION BSS type to allow
1141 also ad-hoc mode to listen to the surroundings without sending any
1142 beacons yet. */
1143 ret = wl1271_cmd_join(wl, BSS_TYPE_STA_BSS);
1190 if (ret < 0) 1144 if (ret < 0)
1191 goto out; 1145 goto out;
1192 1146
@@ -1208,7 +1162,9 @@ static int wl1271_unjoin_channel(struct wl1271 *wl)
1208 clear_bit(WL1271_FLAG_JOINED, &wl->flags); 1162 clear_bit(WL1271_FLAG_JOINED, &wl->flags);
1209 wl->channel = 0; 1163 wl->channel = 0;
1210 memset(wl->bssid, 0, ETH_ALEN); 1164 memset(wl->bssid, 0, ETH_ALEN);
1211 wl->rx_config = WL1271_DEFAULT_RX_CONFIG; 1165
1166 /* stop filterting packets based on bssid */
1167 wl1271_configure_filters(wl, FIF_OTHER_BSS);
1212 1168
1213out: 1169out:
1214 return ret; 1170 return ret;
@@ -1255,7 +1211,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
1255 test_bit(WL1271_FLAG_JOINED, &wl->flags)) { 1211 test_bit(WL1271_FLAG_JOINED, &wl->flags)) {
1256 wl->channel = channel; 1212 wl->channel = channel;
1257 /* FIXME: maybe use CMD_CHANNEL_SWITCH for this? */ 1213 /* FIXME: maybe use CMD_CHANNEL_SWITCH for this? */
1258 ret = wl1271_cmd_join(wl); 1214 ret = wl1271_cmd_join(wl, wl->bss_type);
1259 if (ret < 0) 1215 if (ret < 0)
1260 wl1271_warning("cmd join to update channel failed %d", 1216 wl1271_warning("cmd join to update channel failed %d",
1261 ret); 1217 ret);
@@ -1272,13 +1228,13 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
1272 * through the bss_info_changed() hook. 1228 * through the bss_info_changed() hook.
1273 */ 1229 */
1274 if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { 1230 if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) {
1275 wl1271_info("psm enabled"); 1231 wl1271_debug(DEBUG_PSM, "psm enabled");
1276 ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, 1232 ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE,
1277 true); 1233 true);
1278 } 1234 }
1279 } else if (!(conf->flags & IEEE80211_CONF_PS) && 1235 } else if (!(conf->flags & IEEE80211_CONF_PS) &&
1280 test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) { 1236 test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) {
1281 wl1271_info("psm disabled"); 1237 wl1271_debug(DEBUG_PSM, "psm disabled");
1282 1238
1283 clear_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags); 1239 clear_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags);
1284 1240
@@ -1310,11 +1266,11 @@ struct wl1271_filter_params {
1310 u8 mc_list[ACX_MC_ADDRESS_GROUP_MAX][ETH_ALEN]; 1266 u8 mc_list[ACX_MC_ADDRESS_GROUP_MAX][ETH_ALEN];
1311}; 1267};
1312 1268
1313static u64 wl1271_op_prepare_multicast(struct ieee80211_hw *hw, int mc_count, 1269static u64 wl1271_op_prepare_multicast(struct ieee80211_hw *hw,
1314 struct dev_addr_list *mc_list) 1270 struct netdev_hw_addr_list *mc_list)
1315{ 1271{
1316 struct wl1271_filter_params *fp; 1272 struct wl1271_filter_params *fp;
1317 int i; 1273 struct netdev_hw_addr *ha;
1318 1274
1319 fp = kzalloc(sizeof(*fp), GFP_ATOMIC); 1275 fp = kzalloc(sizeof(*fp), GFP_ATOMIC);
1320 if (!fp) { 1276 if (!fp) {
@@ -1323,21 +1279,16 @@ static u64 wl1271_op_prepare_multicast(struct ieee80211_hw *hw, int mc_count,
1323 } 1279 }
1324 1280
1325 /* update multicast filtering parameters */ 1281 /* update multicast filtering parameters */
1326 fp->enabled = true;
1327 if (mc_count > ACX_MC_ADDRESS_GROUP_MAX) {
1328 mc_count = 0;
1329 fp->enabled = false;
1330 }
1331
1332 fp->mc_list_length = 0; 1282 fp->mc_list_length = 0;
1333 for (i = 0; i < mc_count; i++) { 1283 if (netdev_hw_addr_list_count(mc_list) > ACX_MC_ADDRESS_GROUP_MAX) {
1334 if (mc_list->da_addrlen == ETH_ALEN) { 1284 fp->enabled = false;
1285 } else {
1286 fp->enabled = true;
1287 netdev_hw_addr_list_for_each(ha, mc_list) {
1335 memcpy(fp->mc_list[fp->mc_list_length], 1288 memcpy(fp->mc_list[fp->mc_list_length],
1336 mc_list->da_addr, ETH_ALEN); 1289 ha->addr, ETH_ALEN);
1337 fp->mc_list_length++; 1290 fp->mc_list_length++;
1338 } else 1291 }
1339 wl1271_warning("Unknown mc address length.");
1340 mc_list = mc_list->next;
1341 } 1292 }
1342 1293
1343 return (u64)(unsigned long)fp; 1294 return (u64)(unsigned long)fp;
@@ -1381,14 +1332,14 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw,
1381 if (ret < 0) 1332 if (ret < 0)
1382 goto out_sleep; 1333 goto out_sleep;
1383 1334
1384 kfree(fp);
1385
1386 /* FIXME: We still need to set our filters properly */
1387
1388 /* determine, whether supported filter values have changed */ 1335 /* determine, whether supported filter values have changed */
1389 if (changed == 0) 1336 if (changed == 0)
1390 goto out_sleep; 1337 goto out_sleep;
1391 1338
1339 /* configure filters */
1340 wl->filters = *total;
1341 wl1271_configure_filters(wl, 0);
1342
1392 /* apply configured filters */ 1343 /* apply configured filters */
1393 ret = wl1271_acx_rx_config(wl, wl->rx_config, wl->rx_filter); 1344 ret = wl1271_acx_rx_config(wl, wl->rx_config, wl->rx_filter);
1394 if (ret < 0) 1345 if (ret < 0)
@@ -1399,6 +1350,7 @@ out_sleep:
1399 1350
1400out: 1351out:
1401 mutex_unlock(&wl->mutex); 1352 mutex_unlock(&wl->mutex);
1353 kfree(fp);
1402} 1354}
1403 1355
1404static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 1356static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
@@ -1449,15 +1401,15 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1449 key_type = KEY_TKIP; 1401 key_type = KEY_TKIP;
1450 1402
1451 key_conf->hw_key_idx = key_conf->keyidx; 1403 key_conf->hw_key_idx = key_conf->keyidx;
1452 tx_seq_32 = wl->tx_security_seq_32; 1404 tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq);
1453 tx_seq_16 = wl->tx_security_seq_16; 1405 tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq);
1454 break; 1406 break;
1455 case ALG_CCMP: 1407 case ALG_CCMP:
1456 key_type = KEY_AES; 1408 key_type = KEY_AES;
1457 1409
1458 key_conf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; 1410 key_conf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1459 tx_seq_32 = wl->tx_security_seq_32; 1411 tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq);
1460 tx_seq_16 = wl->tx_security_seq_16; 1412 tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq);
1461 break; 1413 break;
1462 default: 1414 default:
1463 wl1271_error("Unknown key algo 0x%x", key_conf->alg); 1415 wl1271_error("Unknown key algo 0x%x", key_conf->alg);
@@ -1544,10 +1496,12 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw,
1544 goto out; 1496 goto out;
1545 1497
1546 if (wl1271_11a_enabled()) 1498 if (wl1271_11a_enabled())
1547 ret = wl1271_cmd_scan(hw->priv, ssid, len, 1, 0, 1499 ret = wl1271_cmd_scan(hw->priv, ssid, len,
1500 req->ie, req->ie_len, 1, 0,
1548 WL1271_SCAN_BAND_DUAL, 3); 1501 WL1271_SCAN_BAND_DUAL, 3);
1549 else 1502 else
1550 ret = wl1271_cmd_scan(hw->priv, ssid, len, 1, 0, 1503 ret = wl1271_cmd_scan(hw->priv, ssid, len,
1504 req->ie, req->ie_len, 1, 0,
1551 WL1271_SCAN_BAND_2_4_GHZ, 3); 1505 WL1271_SCAN_BAND_2_4_GHZ, 3);
1552 1506
1553 wl1271_ps_elp_sleep(wl); 1507 wl1271_ps_elp_sleep(wl);
@@ -1660,14 +1614,14 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
1660 * and enable the BSSID filter 1614 * and enable the BSSID filter
1661 */ 1615 */
1662 memcmp(wl->bssid, bss_conf->bssid, ETH_ALEN)) { 1616 memcmp(wl->bssid, bss_conf->bssid, ETH_ALEN)) {
1663 wl->rx_config |= CFG_BSSID_FILTER_EN;
1664 memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN); 1617 memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN);
1618
1665 ret = wl1271_cmd_build_null_data(wl); 1619 ret = wl1271_cmd_build_null_data(wl);
1666 if (ret < 0) { 1620 if (ret < 0)
1667 wl1271_warning("cmd buld null data failed %d",
1668 ret);
1669 goto out_sleep; 1621 goto out_sleep;
1670 } 1622
1623 /* filter out all packets not from this BSSID */
1624 wl1271_configure_filters(wl, 0);
1671 1625
1672 /* Need to update the BSSID (for filtering etc) */ 1626 /* Need to update the BSSID (for filtering etc) */
1673 do_join = true; 1627 do_join = true;
@@ -1738,7 +1692,7 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
1738 } 1692 }
1739 1693
1740 if (do_join) { 1694 if (do_join) {
1741 ret = wl1271_cmd_join(wl); 1695 ret = wl1271_cmd_join(wl, wl->bss_type);
1742 if (ret < 0) { 1696 if (ret < 0) {
1743 wl1271_warning("cmd join failed %d", ret); 1697 wl1271_warning("cmd join failed %d", ret);
1744 goto out_sleep; 1698 goto out_sleep;
@@ -1757,6 +1711,7 @@ static int wl1271_op_conf_tx(struct ieee80211_hw *hw, u16 queue,
1757 const struct ieee80211_tx_queue_params *params) 1711 const struct ieee80211_tx_queue_params *params)
1758{ 1712{
1759 struct wl1271 *wl = hw->priv; 1713 struct wl1271 *wl = hw->priv;
1714 u8 ps_scheme;
1760 int ret; 1715 int ret;
1761 1716
1762 mutex_lock(&wl->mutex); 1717 mutex_lock(&wl->mutex);
@@ -1767,17 +1722,22 @@ static int wl1271_op_conf_tx(struct ieee80211_hw *hw, u16 queue,
1767 if (ret < 0) 1722 if (ret < 0)
1768 goto out; 1723 goto out;
1769 1724
1725 /* the txop is confed in units of 32us by the mac80211, we need us */
1770 ret = wl1271_acx_ac_cfg(wl, wl1271_tx_get_queue(queue), 1726 ret = wl1271_acx_ac_cfg(wl, wl1271_tx_get_queue(queue),
1771 params->cw_min, params->cw_max, 1727 params->cw_min, params->cw_max,
1772 params->aifs, params->txop); 1728 params->aifs, params->txop << 5);
1773 if (ret < 0) 1729 if (ret < 0)
1774 goto out_sleep; 1730 goto out_sleep;
1775 1731
1732 if (params->uapsd)
1733 ps_scheme = CONF_PS_SCHEME_UPSD_TRIGGER;
1734 else
1735 ps_scheme = CONF_PS_SCHEME_LEGACY;
1736
1776 ret = wl1271_acx_tid_cfg(wl, wl1271_tx_get_queue(queue), 1737 ret = wl1271_acx_tid_cfg(wl, wl1271_tx_get_queue(queue),
1777 CONF_CHANNEL_TYPE_EDCF, 1738 CONF_CHANNEL_TYPE_EDCF,
1778 wl1271_tx_get_queue(queue), 1739 wl1271_tx_get_queue(queue),
1779 CONF_PS_SCHEME_LEGACY_PSPOLL, 1740 ps_scheme, CONF_ACK_POLICY_LEGACY, 0, 0);
1780 CONF_ACK_POLICY_LEGACY, 0, 0);
1781 if (ret < 0) 1741 if (ret < 0)
1782 goto out_sleep; 1742 goto out_sleep;
1783 1743
@@ -1947,7 +1907,6 @@ static const struct ieee80211_ops wl1271_ops = {
1947 .add_interface = wl1271_op_add_interface, 1907 .add_interface = wl1271_op_add_interface,
1948 .remove_interface = wl1271_op_remove_interface, 1908 .remove_interface = wl1271_op_remove_interface,
1949 .config = wl1271_op_config, 1909 .config = wl1271_op_config,
1950/* .config_interface = wl1271_op_config_interface, */
1951 .prepare_multicast = wl1271_op_prepare_multicast, 1910 .prepare_multicast = wl1271_op_prepare_multicast,
1952 .configure_filter = wl1271_op_configure_filter, 1911 .configure_filter = wl1271_op_configure_filter,
1953 .tx = wl1271_op_tx, 1912 .tx = wl1271_op_tx,
@@ -1959,7 +1918,69 @@ static const struct ieee80211_ops wl1271_ops = {
1959 CFG80211_TESTMODE_CMD(wl1271_tm_cmd) 1918 CFG80211_TESTMODE_CMD(wl1271_tm_cmd)
1960}; 1919};
1961 1920
1962static int wl1271_register_hw(struct wl1271 *wl) 1921static ssize_t wl1271_sysfs_show_bt_coex_state(struct device *dev,
1922 struct device_attribute *attr,
1923 char *buf)
1924{
1925 struct wl1271 *wl = dev_get_drvdata(dev);
1926 ssize_t len;
1927
1928 /* FIXME: what's the maximum length of buf? page size?*/
1929 len = 500;
1930
1931 mutex_lock(&wl->mutex);
1932 len = snprintf(buf, len, "%d\n\n0 - off\n1 - on\n",
1933 wl->sg_enabled);
1934 mutex_unlock(&wl->mutex);
1935
1936 return len;
1937
1938}
1939
1940static ssize_t wl1271_sysfs_store_bt_coex_state(struct device *dev,
1941 struct device_attribute *attr,
1942 const char *buf, size_t count)
1943{
1944 struct wl1271 *wl = dev_get_drvdata(dev);
1945 unsigned long res;
1946 int ret;
1947
1948 ret = strict_strtoul(buf, 10, &res);
1949
1950 if (ret < 0) {
1951 wl1271_warning("incorrect value written to bt_coex_mode");
1952 return count;
1953 }
1954
1955 mutex_lock(&wl->mutex);
1956
1957 res = !!res;
1958
1959 if (res == wl->sg_enabled)
1960 goto out;
1961
1962 wl->sg_enabled = res;
1963
1964 if (wl->state == WL1271_STATE_OFF)
1965 goto out;
1966
1967 ret = wl1271_ps_elp_wakeup(wl, false);
1968 if (ret < 0)
1969 goto out;
1970
1971 wl1271_acx_sg_enable(wl, wl->sg_enabled);
1972 wl1271_ps_elp_sleep(wl);
1973
1974 out:
1975 mutex_unlock(&wl->mutex);
1976 return count;
1977}
1978
1979static DEVICE_ATTR(bt_coex_state, S_IRUGO | S_IWUSR,
1980 wl1271_sysfs_show_bt_coex_state,
1981 wl1271_sysfs_store_bt_coex_state);
1982
1983int wl1271_register_hw(struct wl1271 *wl)
1963{ 1984{
1964 int ret; 1985 int ret;
1965 1986
@@ -1980,8 +2001,17 @@ static int wl1271_register_hw(struct wl1271 *wl)
1980 2001
1981 return 0; 2002 return 0;
1982} 2003}
2004EXPORT_SYMBOL_GPL(wl1271_register_hw);
1983 2005
1984static int wl1271_init_ieee80211(struct wl1271 *wl) 2006void wl1271_unregister_hw(struct wl1271 *wl)
2007{
2008 ieee80211_unregister_hw(wl->hw);
2009 wl->mac80211_registered = false;
2010
2011}
2012EXPORT_SYMBOL_GPL(wl1271_unregister_hw);
2013
2014int wl1271_init_ieee80211(struct wl1271 *wl)
1985{ 2015{
1986 /* The tx descriptor buffer and the TKIP space. */ 2016 /* The tx descriptor buffer and the TKIP space. */
1987 wl->hw->extra_tx_headroom = WL1271_TKIP_IV_SPACE + 2017 wl->hw->extra_tx_headroom = WL1271_TKIP_IV_SPACE +
@@ -1994,7 +2024,9 @@ static int wl1271_init_ieee80211(struct wl1271 *wl)
1994 wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | 2024 wl->hw->flags = IEEE80211_HW_SIGNAL_DBM |
1995 IEEE80211_HW_NOISE_DBM | 2025 IEEE80211_HW_NOISE_DBM |
1996 IEEE80211_HW_BEACON_FILTER | 2026 IEEE80211_HW_BEACON_FILTER |
1997 IEEE80211_HW_SUPPORTS_PS; 2027 IEEE80211_HW_SUPPORTS_PS |
2028 IEEE80211_HW_SUPPORTS_UAPSD |
2029 IEEE80211_HW_HAS_RATE_CONTROL;
1998 2030
1999 wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | 2031 wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
2000 BIT(NL80211_IFTYPE_ADHOC); 2032 BIT(NL80211_IFTYPE_ADHOC);
@@ -2004,46 +2036,47 @@ static int wl1271_init_ieee80211(struct wl1271 *wl)
2004 if (wl1271_11a_enabled()) 2036 if (wl1271_11a_enabled())
2005 wl->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &wl1271_band_5ghz; 2037 wl->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &wl1271_band_5ghz;
2006 2038
2007 SET_IEEE80211_DEV(wl->hw, &wl->spi->dev); 2039 wl->hw->queues = 4;
2008
2009 return 0;
2010}
2011 2040
2012static void wl1271_device_release(struct device *dev) 2041 SET_IEEE80211_DEV(wl->hw, wl1271_wl_to_dev(wl));
2013{
2014 2042
2043 return 0;
2015} 2044}
2016 2045EXPORT_SYMBOL_GPL(wl1271_init_ieee80211);
2017static struct platform_device wl1271_device = {
2018 .name = "wl1271",
2019 .id = -1,
2020
2021 /* device model insists to have a release function */
2022 .dev = {
2023 .release = wl1271_device_release,
2024 },
2025};
2026 2046
2027#define WL1271_DEFAULT_CHANNEL 0 2047#define WL1271_DEFAULT_CHANNEL 0
2028 2048
2029static struct ieee80211_hw *wl1271_alloc_hw(void) 2049struct ieee80211_hw *wl1271_alloc_hw(void)
2030{ 2050{
2031 struct ieee80211_hw *hw; 2051 struct ieee80211_hw *hw;
2052 struct platform_device *plat_dev = NULL;
2032 struct wl1271 *wl; 2053 struct wl1271 *wl;
2033 int i; 2054 int i, ret;
2055 static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
2034 2056
2035 hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops); 2057 hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops);
2036 if (!hw) { 2058 if (!hw) {
2037 wl1271_error("could not alloc ieee80211_hw"); 2059 wl1271_error("could not alloc ieee80211_hw");
2038 return ERR_PTR(-ENOMEM); 2060 ret = -ENOMEM;
2061 goto err_hw_alloc;
2039 } 2062 }
2040 2063
2064 plat_dev = kmalloc(sizeof(wl1271_device), GFP_KERNEL);
2065 if (!plat_dev) {
2066 wl1271_error("could not allocate platform_device");
2067 ret = -ENOMEM;
2068 goto err_plat_alloc;
2069 }
2070
2071 memcpy(plat_dev, &wl1271_device, sizeof(wl1271_device));
2072
2041 wl = hw->priv; 2073 wl = hw->priv;
2042 memset(wl, 0, sizeof(*wl)); 2074 memset(wl, 0, sizeof(*wl));
2043 2075
2044 INIT_LIST_HEAD(&wl->list); 2076 INIT_LIST_HEAD(&wl->list);
2045 2077
2046 wl->hw = hw; 2078 wl->hw = hw;
2079 wl->plat_dev = plat_dev;
2047 2080
2048 skb_queue_head_init(&wl->tx_queue); 2081 skb_queue_head_init(&wl->tx_queue);
2049 2082
@@ -2061,6 +2094,7 @@ static struct ieee80211_hw *wl1271_alloc_hw(void)
2061 wl->band = IEEE80211_BAND_2GHZ; 2094 wl->band = IEEE80211_BAND_2GHZ;
2062 wl->vif = NULL; 2095 wl->vif = NULL;
2063 wl->flags = 0; 2096 wl->flags = 0;
2097 wl->sg_enabled = true;
2064 2098
2065 for (i = 0; i < ACX_TX_DESCRIPTORS; i++) 2099 for (i = 0; i < ACX_TX_DESCRIPTORS; i++)
2066 wl->tx_frames[i] = NULL; 2100 wl->tx_frames[i] = NULL;
@@ -2070,15 +2104,55 @@ static struct ieee80211_hw *wl1271_alloc_hw(void)
2070 wl->state = WL1271_STATE_OFF; 2104 wl->state = WL1271_STATE_OFF;
2071 mutex_init(&wl->mutex); 2105 mutex_init(&wl->mutex);
2072 2106
2107 /*
2108 * FIXME: we should use a zero MAC address here, but for now we
2109 * generate a random Nokia address.
2110 */
2111 memcpy(wl->mac_addr, nokia_oui, 3);
2112 get_random_bytes(wl->mac_addr + 3, 3);
2113
2073 /* Apply default driver configuration. */ 2114 /* Apply default driver configuration. */
2074 wl1271_conf_init(wl); 2115 wl1271_conf_init(wl);
2075 2116
2117 wl1271_debugfs_init(wl);
2118
2119 /* Register platform device */
2120 ret = platform_device_register(wl->plat_dev);
2121 if (ret) {
2122 wl1271_error("couldn't register platform device");
2123 goto err_hw;
2124 }
2125 dev_set_drvdata(&wl->plat_dev->dev, wl);
2126
2127 /* Create sysfs file to control bt coex state */
2128 ret = device_create_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state);
2129 if (ret < 0) {
2130 wl1271_error("failed to create sysfs file bt_coex_state");
2131 goto err_platform;
2132 }
2133
2076 return hw; 2134 return hw;
2135
2136err_platform:
2137 platform_device_unregister(wl->plat_dev);
2138
2139err_hw:
2140 wl1271_debugfs_exit(wl);
2141 kfree(plat_dev);
2142
2143err_plat_alloc:
2144 ieee80211_free_hw(hw);
2145
2146err_hw_alloc:
2147
2148 return ERR_PTR(ret);
2077} 2149}
2150EXPORT_SYMBOL_GPL(wl1271_alloc_hw);
2078 2151
2079int wl1271_free_hw(struct wl1271 *wl) 2152int wl1271_free_hw(struct wl1271 *wl)
2080{ 2153{
2081 ieee80211_unregister_hw(wl->hw); 2154 platform_device_unregister(wl->plat_dev);
2155 kfree(wl->plat_dev);
2082 2156
2083 wl1271_debugfs_exit(wl); 2157 wl1271_debugfs_exit(wl);
2084 2158
@@ -2095,145 +2169,8 @@ int wl1271_free_hw(struct wl1271 *wl)
2095 2169
2096 return 0; 2170 return 0;
2097} 2171}
2098 2172EXPORT_SYMBOL_GPL(wl1271_free_hw);
2099static int __devinit wl1271_probe(struct spi_device *spi)
2100{
2101 struct wl12xx_platform_data *pdata;
2102 struct ieee80211_hw *hw;
2103 struct wl1271 *wl;
2104 int ret;
2105
2106 pdata = spi->dev.platform_data;
2107 if (!pdata) {
2108 wl1271_error("no platform data");
2109 return -ENODEV;
2110 }
2111
2112 hw = wl1271_alloc_hw();
2113 if (IS_ERR(hw))
2114 return PTR_ERR(hw);
2115
2116 wl = hw->priv;
2117
2118 dev_set_drvdata(&spi->dev, wl);
2119 wl->spi = spi;
2120
2121 /* This is the only SPI value that we need to set here, the rest
2122 * comes from the board-peripherals file */
2123 spi->bits_per_word = 32;
2124
2125 ret = spi_setup(spi);
2126 if (ret < 0) {
2127 wl1271_error("spi_setup failed");
2128 goto out_free;
2129 }
2130
2131 wl->set_power = pdata->set_power;
2132 if (!wl->set_power) {
2133 wl1271_error("set power function missing in platform data");
2134 ret = -ENODEV;
2135 goto out_free;
2136 }
2137
2138 wl->irq = spi->irq;
2139 if (wl->irq < 0) {
2140 wl1271_error("irq missing in platform data");
2141 ret = -ENODEV;
2142 goto out_free;
2143 }
2144
2145 ret = request_irq(wl->irq, wl1271_irq, 0, DRIVER_NAME, wl);
2146 if (ret < 0) {
2147 wl1271_error("request_irq() failed: %d", ret);
2148 goto out_free;
2149 }
2150
2151 set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
2152
2153 disable_irq(wl->irq);
2154
2155 ret = platform_device_register(&wl1271_device);
2156 if (ret) {
2157 wl1271_error("couldn't register platform device");
2158 goto out_irq;
2159 }
2160 dev_set_drvdata(&wl1271_device.dev, wl);
2161
2162 ret = wl1271_init_ieee80211(wl);
2163 if (ret)
2164 goto out_platform;
2165
2166 ret = wl1271_register_hw(wl);
2167 if (ret)
2168 goto out_platform;
2169
2170 wl1271_debugfs_init(wl);
2171
2172 wl1271_notice("initialized");
2173
2174 return 0;
2175
2176 out_platform:
2177 platform_device_unregister(&wl1271_device);
2178
2179 out_irq:
2180 free_irq(wl->irq, wl);
2181
2182 out_free:
2183 ieee80211_free_hw(hw);
2184
2185 return ret;
2186}
2187
2188static int __devexit wl1271_remove(struct spi_device *spi)
2189{
2190 struct wl1271 *wl = dev_get_drvdata(&spi->dev);
2191
2192 platform_device_unregister(&wl1271_device);
2193 free_irq(wl->irq, wl);
2194
2195 wl1271_free_hw(wl);
2196
2197 return 0;
2198}
2199
2200
2201static struct spi_driver wl1271_spi_driver = {
2202 .driver = {
2203 .name = "wl1271",
2204 .bus = &spi_bus_type,
2205 .owner = THIS_MODULE,
2206 },
2207
2208 .probe = wl1271_probe,
2209 .remove = __devexit_p(wl1271_remove),
2210};
2211
2212static int __init wl1271_init(void)
2213{
2214 int ret;
2215
2216 ret = spi_register_driver(&wl1271_spi_driver);
2217 if (ret < 0) {
2218 wl1271_error("failed to register spi driver: %d", ret);
2219 goto out;
2220 }
2221
2222out:
2223 return ret;
2224}
2225
2226static void __exit wl1271_exit(void)
2227{
2228 spi_unregister_driver(&wl1271_spi_driver);
2229
2230 wl1271_notice("unloaded");
2231}
2232
2233module_init(wl1271_init);
2234module_exit(wl1271_exit);
2235 2173
2236MODULE_LICENSE("GPL"); 2174MODULE_LICENSE("GPL");
2237MODULE_AUTHOR("Luciano Coelho <luciano.coelho@nokia.com>"); 2175MODULE_AUTHOR("Luciano Coelho <luciano.coelho@nokia.com>");
2238MODULE_AUTHOR("Juuso Oikarinen <juuso.oikarinen@nokia.com>"); 2176MODULE_AUTHOR("Juuso Oikarinen <juuso.oikarinen@nokia.com>");
2239MODULE_FIRMWARE(WL1271_FW_NAME);
diff --git a/drivers/net/wireless/wl12xx/wl1271_ps.c b/drivers/net/wireless/wl12xx/wl1271_ps.c
index e2b1ebf096e8..5a04482b9353 100644
--- a/drivers/net/wireless/wl12xx/wl1271_ps.c
+++ b/drivers/net/wireless/wl12xx/wl1271_ps.c
@@ -23,7 +23,6 @@
23 23
24#include "wl1271_reg.h" 24#include "wl1271_reg.h"
25#include "wl1271_ps.h" 25#include "wl1271_ps.h"
26#include "wl1271_spi.h"
27#include "wl1271_io.h" 26#include "wl1271_io.h"
28 27
29#define WL1271_WAKEUP_TIMEOUT 500 28#define WL1271_WAKEUP_TIMEOUT 500
diff --git a/drivers/net/wireless/wl12xx/wl1271_rx.c b/drivers/net/wireless/wl12xx/wl1271_rx.c
index 6730f5b96e76..b824c6cc2cc5 100644
--- a/drivers/net/wireless/wl12xx/wl1271_rx.c
+++ b/drivers/net/wireless/wl12xx/wl1271_rx.c
@@ -25,7 +25,6 @@
25#include "wl1271_acx.h" 25#include "wl1271_acx.h"
26#include "wl1271_reg.h" 26#include "wl1271_reg.h"
27#include "wl1271_rx.h" 27#include "wl1271_rx.h"
28#include "wl1271_spi.h"
29#include "wl1271_io.h" 28#include "wl1271_io.h"
30 29
31static u8 wl1271_rx_get_mem_block(struct wl1271_fw_status *status, 30static u8 wl1271_rx_get_mem_block(struct wl1271_fw_status *status,
@@ -160,6 +159,13 @@ static void wl1271_rx_handle_data(struct wl1271 *wl, u32 length)
160 u8 *buf; 159 u8 *buf;
161 u8 beacon = 0; 160 u8 beacon = 0;
162 161
162 /*
163 * In PLT mode we seem to get frames and mac80211 warns about them,
164 * workaround this by not retrieving them at all.
165 */
166 if (unlikely(wl->state == WL1271_STATE_PLT))
167 return;
168
163 skb = __dev_alloc_skb(length, GFP_KERNEL); 169 skb = __dev_alloc_skb(length, GFP_KERNEL);
164 if (!skb) { 170 if (!skb) {
165 wl1271_error("Couldn't allocate RX frame"); 171 wl1271_error("Couldn't allocate RX frame");
@@ -218,6 +224,7 @@ void wl1271_rx(struct wl1271 *wl, struct wl1271_fw_status *status)
218 224
219 wl->rx_counter++; 225 wl->rx_counter++;
220 drv_rx_counter = wl->rx_counter & NUM_RX_PKT_DESC_MOD_MASK; 226 drv_rx_counter = wl->rx_counter & NUM_RX_PKT_DESC_MOD_MASK;
221 wl1271_write32(wl, RX_DRIVER_COUNTER_ADDRESS, wl->rx_counter);
222 } 227 }
228
229 wl1271_write32(wl, RX_DRIVER_COUNTER_ADDRESS, wl->rx_counter);
223} 230}
diff --git a/drivers/net/wireless/wl12xx/wl1271_sdio.c b/drivers/net/wireless/wl12xx/wl1271_sdio.c
new file mode 100644
index 000000000000..3c03de74dbfc
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/wl1271_sdio.c
@@ -0,0 +1,291 @@
1/*
2 * This file is part of wl1271
3 *
4 * Copyright (C) 2009-2010 Nokia Corporation
5 *
6 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#include <linux/irq.h>
25#include <linux/module.h>
26#include <linux/crc7.h>
27#include <linux/vmalloc.h>
28#include <linux/mmc/sdio_func.h>
29#include <linux/mmc/sdio_ids.h>
30#include <linux/mmc/card.h>
31#include <plat/gpio.h>
32
33#include "wl1271.h"
34#include "wl12xx_80211.h"
35#include "wl1271_io.h"
36
37
38#define RX71_WL1271_IRQ_GPIO 42
39
40#ifndef SDIO_VENDOR_ID_TI
41#define SDIO_VENDOR_ID_TI 0x0097
42#endif
43
44#ifndef SDIO_DEVICE_ID_TI_WL1271
45#define SDIO_DEVICE_ID_TI_WL1271 0x4076
46#endif
47
48static const struct sdio_device_id wl1271_devices[] = {
49 { SDIO_DEVICE(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271) },
50 {}
51};
52MODULE_DEVICE_TABLE(sdio, wl1271_devices);
53
54static inline struct sdio_func *wl_to_func(struct wl1271 *wl)
55{
56 return wl->if_priv;
57}
58
59static struct device *wl1271_sdio_wl_to_dev(struct wl1271 *wl)
60{
61 return &(wl_to_func(wl)->dev);
62}
63
64static irqreturn_t wl1271_irq(int irq, void *cookie)
65{
66 struct wl1271 *wl = cookie;
67 unsigned long flags;
68
69 wl1271_debug(DEBUG_IRQ, "IRQ");
70
71 /* complete the ELP completion */
72 spin_lock_irqsave(&wl->wl_lock, flags);
73 if (wl->elp_compl) {
74 complete(wl->elp_compl);
75 wl->elp_compl = NULL;
76 }
77
78 if (!test_and_set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags))
79 ieee80211_queue_work(wl->hw, &wl->irq_work);
80 set_bit(WL1271_FLAG_IRQ_PENDING, &wl->flags);
81 spin_unlock_irqrestore(&wl->wl_lock, flags);
82
83 return IRQ_HANDLED;
84}
85
86static void wl1271_sdio_disable_interrupts(struct wl1271 *wl)
87{
88 disable_irq(wl->irq);
89}
90
91static void wl1271_sdio_enable_interrupts(struct wl1271 *wl)
92{
93 enable_irq(wl->irq);
94}
95
96static void wl1271_sdio_reset(struct wl1271 *wl)
97{
98}
99
100static void wl1271_sdio_init(struct wl1271 *wl)
101{
102}
103
104static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf,
105 size_t len, bool fixed)
106{
107 int ret;
108 struct sdio_func *func = wl_to_func(wl);
109
110 if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) {
111 ((u8 *)buf)[0] = sdio_f0_readb(func, addr, &ret);
112 wl1271_debug(DEBUG_SDIO, "sdio read 52 addr 0x%x, byte 0x%02x",
113 addr, ((u8 *)buf)[0]);
114 } else {
115 if (fixed)
116 ret = sdio_readsb(func, buf, addr, len);
117 else
118 ret = sdio_memcpy_fromio(func, buf, addr, len);
119
120 wl1271_debug(DEBUG_SDIO, "sdio read 53 addr 0x%x, %d bytes",
121 addr, len);
122 wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len);
123 }
124
125 if (ret)
126 wl1271_error("sdio read failed (%d)", ret);
127
128}
129
130static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf,
131 size_t len, bool fixed)
132{
133 int ret;
134 struct sdio_func *func = wl_to_func(wl);
135
136 if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) {
137 sdio_f0_writeb(func, ((u8 *)buf)[0], addr, &ret);
138 wl1271_debug(DEBUG_SDIO, "sdio write 52 addr 0x%x, byte 0x%02x",
139 addr, ((u8 *)buf)[0]);
140 } else {
141 wl1271_debug(DEBUG_SDIO, "sdio write 53 addr 0x%x, %d bytes",
142 addr, len);
143 wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len);
144
145 if (fixed)
146 ret = sdio_writesb(func, addr, buf, len);
147 else
148 ret = sdio_memcpy_toio(func, addr, buf, len);
149 }
150 if (ret)
151 wl1271_error("sdio write failed (%d)", ret);
152
153}
154
155static void wl1271_sdio_set_power(struct wl1271 *wl, bool enable)
156{
157 struct sdio_func *func = wl_to_func(wl);
158
159 /* Let the SDIO stack handle wlan_enable control, so we
160 * keep host claimed while wlan is in use to keep wl1271
161 * alive.
162 */
163 if (enable) {
164 sdio_claim_host(func);
165 sdio_enable_func(func);
166 } else {
167 sdio_disable_func(func);
168 sdio_release_host(func);
169 }
170}
171
172static struct wl1271_if_operations sdio_ops = {
173 .read = wl1271_sdio_raw_read,
174 .write = wl1271_sdio_raw_write,
175 .reset = wl1271_sdio_reset,
176 .init = wl1271_sdio_init,
177 .power = wl1271_sdio_set_power,
178 .dev = wl1271_sdio_wl_to_dev,
179 .enable_irq = wl1271_sdio_enable_interrupts,
180 .disable_irq = wl1271_sdio_disable_interrupts
181};
182
183static int __devinit wl1271_probe(struct sdio_func *func,
184 const struct sdio_device_id *id)
185{
186 struct ieee80211_hw *hw;
187 struct wl1271 *wl;
188 int ret;
189
190 /* We are only able to handle the wlan function */
191 if (func->num != 0x02)
192 return -ENODEV;
193
194 hw = wl1271_alloc_hw();
195 if (IS_ERR(hw))
196 return PTR_ERR(hw);
197
198 wl = hw->priv;
199
200 wl->if_priv = func;
201 wl->if_ops = &sdio_ops;
202
203 /* Grab access to FN0 for ELP reg. */
204 func->card->quirks |= MMC_QUIRK_LENIENT_FN0;
205
206 wl->irq = gpio_to_irq(RX71_WL1271_IRQ_GPIO);
207 if (wl->irq < 0) {
208 ret = wl->irq;
209 wl1271_error("could not get irq!");
210 goto out_free;
211 }
212
213 ret = request_irq(wl->irq, wl1271_irq, 0, DRIVER_NAME, wl);
214 if (ret < 0) {
215 wl1271_error("request_irq() failed: %d", ret);
216 goto out_free;
217 }
218
219 set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
220
221 disable_irq(wl->irq);
222
223 ret = wl1271_init_ieee80211(wl);
224 if (ret)
225 goto out_irq;
226
227 ret = wl1271_register_hw(wl);
228 if (ret)
229 goto out_irq;
230
231 sdio_set_drvdata(func, wl);
232
233 wl1271_notice("initialized");
234
235 return 0;
236
237 out_irq:
238 free_irq(wl->irq, wl);
239
240
241 out_free:
242 wl1271_free_hw(wl);
243
244 return ret;
245}
246
247static void __devexit wl1271_remove(struct sdio_func *func)
248{
249 struct wl1271 *wl = sdio_get_drvdata(func);
250
251 free_irq(wl->irq, wl);
252
253 wl1271_unregister_hw(wl);
254 wl1271_free_hw(wl);
255}
256
257static struct sdio_driver wl1271_sdio_driver = {
258 .name = "wl1271",
259 .id_table = wl1271_devices,
260 .probe = wl1271_probe,
261 .remove = __devexit_p(wl1271_remove),
262};
263
264static int __init wl1271_init(void)
265{
266 int ret;
267
268 ret = sdio_register_driver(&wl1271_sdio_driver);
269 if (ret < 0) {
270 wl1271_error("failed to register sdio driver: %d", ret);
271 goto out;
272 }
273
274out:
275 return ret;
276}
277
278static void __exit wl1271_exit(void)
279{
280 sdio_unregister_driver(&wl1271_sdio_driver);
281
282 wl1271_notice("unloaded");
283}
284
285module_init(wl1271_init);
286module_exit(wl1271_exit);
287
288MODULE_LICENSE("GPL");
289MODULE_AUTHOR("Luciano Coelho <luciano.coelho@nokia.com>");
290MODULE_AUTHOR("Juuso Oikarinen <juuso.oikarinen@nokia.com>");
291MODULE_FIRMWARE(WL1271_FW_NAME);
diff --git a/drivers/net/wireless/wl12xx/wl1271_spi.c b/drivers/net/wireless/wl12xx/wl1271_spi.c
index 67a82934f36e..f44b05a32b0d 100644
--- a/drivers/net/wireless/wl12xx/wl1271_spi.c
+++ b/drivers/net/wireless/wl12xx/wl1271_spi.c
@@ -21,17 +21,68 @@
21 * 21 *
22 */ 22 */
23 23
24#include <linux/irq.h>
24#include <linux/module.h> 25#include <linux/module.h>
25#include <linux/platform_device.h>
26#include <linux/crc7.h> 26#include <linux/crc7.h>
27#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
28#include <linux/spi/wl12xx.h>
28 29
29#include "wl1271.h" 30#include "wl1271.h"
30#include "wl12xx_80211.h" 31#include "wl12xx_80211.h"
31#include "wl1271_spi.h" 32#include "wl1271_io.h"
33
34#include "wl1271_reg.h"
35
36#define WSPI_CMD_READ 0x40000000
37#define WSPI_CMD_WRITE 0x00000000
38#define WSPI_CMD_FIXED 0x20000000
39#define WSPI_CMD_BYTE_LENGTH 0x1FFE0000
40#define WSPI_CMD_BYTE_LENGTH_OFFSET 17
41#define WSPI_CMD_BYTE_ADDR 0x0001FFFF
42
43#define WSPI_INIT_CMD_CRC_LEN 5
44
45#define WSPI_INIT_CMD_START 0x00
46#define WSPI_INIT_CMD_TX 0x40
47/* the extra bypass bit is sampled by the TNET as '1' */
48#define WSPI_INIT_CMD_BYPASS_BIT 0x80
49#define WSPI_INIT_CMD_FIXEDBUSY_LEN 0x07
50#define WSPI_INIT_CMD_EN_FIXEDBUSY 0x80
51#define WSPI_INIT_CMD_DIS_FIXEDBUSY 0x00
52#define WSPI_INIT_CMD_IOD 0x40
53#define WSPI_INIT_CMD_IP 0x20
54#define WSPI_INIT_CMD_CS 0x10
55#define WSPI_INIT_CMD_WS 0x08
56#define WSPI_INIT_CMD_WSPI 0x01
57#define WSPI_INIT_CMD_END 0x01
58
59#define WSPI_INIT_CMD_LEN 8
60
61#define HW_ACCESS_WSPI_FIXED_BUSY_LEN \
62 ((WL1271_BUSY_WORD_LEN - 4) / sizeof(u32))
63#define HW_ACCESS_WSPI_INIT_CMD_MASK 0
64
65static inline struct spi_device *wl_to_spi(struct wl1271 *wl)
66{
67 return wl->if_priv;
68}
69
70static struct device *wl1271_spi_wl_to_dev(struct wl1271 *wl)
71{
72 return &(wl_to_spi(wl)->dev);
73}
32 74
75static void wl1271_spi_disable_interrupts(struct wl1271 *wl)
76{
77 disable_irq(wl->irq);
78}
79
80static void wl1271_spi_enable_interrupts(struct wl1271 *wl)
81{
82 enable_irq(wl->irq);
83}
33 84
34void wl1271_spi_reset(struct wl1271 *wl) 85static void wl1271_spi_reset(struct wl1271 *wl)
35{ 86{
36 u8 *cmd; 87 u8 *cmd;
37 struct spi_transfer t; 88 struct spi_transfer t;
@@ -52,12 +103,12 @@ void wl1271_spi_reset(struct wl1271 *wl)
52 t.len = WSPI_INIT_CMD_LEN; 103 t.len = WSPI_INIT_CMD_LEN;
53 spi_message_add_tail(&t, &m); 104 spi_message_add_tail(&t, &m);
54 105
55 spi_sync(wl->spi, &m); 106 spi_sync(wl_to_spi(wl), &m);
56 107
57 wl1271_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); 108 wl1271_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN);
58} 109}
59 110
60void wl1271_spi_init(struct wl1271 *wl) 111static void wl1271_spi_init(struct wl1271 *wl)
61{ 112{
62 u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd; 113 u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd;
63 struct spi_transfer t; 114 struct spi_transfer t;
@@ -106,7 +157,7 @@ void wl1271_spi_init(struct wl1271 *wl)
106 t.len = WSPI_INIT_CMD_LEN; 157 t.len = WSPI_INIT_CMD_LEN;
107 spi_message_add_tail(&t, &m); 158 spi_message_add_tail(&t, &m);
108 159
109 spi_sync(wl->spi, &m); 160 spi_sync(wl_to_spi(wl), &m);
110 161
111 wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); 162 wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN);
112} 163}
@@ -138,7 +189,7 @@ static void wl1271_spi_read_busy(struct wl1271 *wl, void *buf, size_t len)
138 t[0].rx_buf = buf + (len - num_busy_bytes); 189 t[0].rx_buf = buf + (len - num_busy_bytes);
139 t[0].len = num_busy_bytes; 190 t[0].len = num_busy_bytes;
140 spi_message_add_tail(&t[0], &m); 191 spi_message_add_tail(&t[0], &m);
141 spi_sync(wl->spi, &m); 192 spi_sync(wl_to_spi(wl), &m);
142 return; 193 return;
143 } 194 }
144 } 195 }
@@ -158,7 +209,7 @@ static void wl1271_spi_read_busy(struct wl1271 *wl, void *buf, size_t len)
158 t[0].rx_buf = busy_buf; 209 t[0].rx_buf = busy_buf;
159 t[0].len = sizeof(u32); 210 t[0].len = sizeof(u32);
160 spi_message_add_tail(&t[0], &m); 211 spi_message_add_tail(&t[0], &m);
161 spi_sync(wl->spi, &m); 212 spi_sync(wl_to_spi(wl), &m);
162 213
163 if (*busy_buf & 0x1) { 214 if (*busy_buf & 0x1) {
164 spi_message_init(&m); 215 spi_message_init(&m);
@@ -166,7 +217,7 @@ static void wl1271_spi_read_busy(struct wl1271 *wl, void *buf, size_t len)
166 t[0].rx_buf = buf; 217 t[0].rx_buf = buf;
167 t[0].len = len; 218 t[0].len = len;
168 spi_message_add_tail(&t[0], &m); 219 spi_message_add_tail(&t[0], &m);
169 spi_sync(wl->spi, &m); 220 spi_sync(wl_to_spi(wl), &m);
170 return; 221 return;
171 } 222 }
172 } 223 }
@@ -177,7 +228,7 @@ static void wl1271_spi_read_busy(struct wl1271 *wl, void *buf, size_t len)
177} 228}
178#endif 229#endif
179 230
180void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, 231static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
181 size_t len, bool fixed) 232 size_t len, bool fixed)
182{ 233{
183 struct spi_transfer t[3]; 234 struct spi_transfer t[3];
@@ -212,7 +263,7 @@ void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
212 t[2].len = len; 263 t[2].len = len;
213 spi_message_add_tail(&t[2], &m); 264 spi_message_add_tail(&t[2], &m);
214 265
215 spi_sync(wl->spi, &m); 266 spi_sync(wl_to_spi(wl), &m);
216 267
217 /* FIXME: Check busy words, removed due to SPI bug */ 268 /* FIXME: Check busy words, removed due to SPI bug */
218 /* if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1)) 269 /* if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1))
@@ -222,7 +273,7 @@ void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
222 wl1271_dump(DEBUG_SPI, "spi_read buf <- ", buf, len); 273 wl1271_dump(DEBUG_SPI, "spi_read buf <- ", buf, len);
223} 274}
224 275
225void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf, 276static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf,
226 size_t len, bool fixed) 277 size_t len, bool fixed)
227{ 278{
228 struct spi_transfer t[2]; 279 struct spi_transfer t[2];
@@ -250,8 +301,181 @@ void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf,
250 t[1].len = len; 301 t[1].len = len;
251 spi_message_add_tail(&t[1], &m); 302 spi_message_add_tail(&t[1], &m);
252 303
253 spi_sync(wl->spi, &m); 304 spi_sync(wl_to_spi(wl), &m);
254 305
255 wl1271_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd)); 306 wl1271_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd));
256 wl1271_dump(DEBUG_SPI, "spi_write buf -> ", buf, len); 307 wl1271_dump(DEBUG_SPI, "spi_write buf -> ", buf, len);
257} 308}
309
310static irqreturn_t wl1271_irq(int irq, void *cookie)
311{
312 struct wl1271 *wl;
313 unsigned long flags;
314
315 wl1271_debug(DEBUG_IRQ, "IRQ");
316
317 wl = cookie;
318
319 /* complete the ELP completion */
320 spin_lock_irqsave(&wl->wl_lock, flags);
321 if (wl->elp_compl) {
322 complete(wl->elp_compl);
323 wl->elp_compl = NULL;
324 }
325
326 if (!test_and_set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags))
327 ieee80211_queue_work(wl->hw, &wl->irq_work);
328 set_bit(WL1271_FLAG_IRQ_PENDING, &wl->flags);
329 spin_unlock_irqrestore(&wl->wl_lock, flags);
330
331 return IRQ_HANDLED;
332}
333
334static void wl1271_spi_set_power(struct wl1271 *wl, bool enable)
335{
336 if (wl->set_power)
337 wl->set_power(enable);
338}
339
340static struct wl1271_if_operations spi_ops = {
341 .read = wl1271_spi_raw_read,
342 .write = wl1271_spi_raw_write,
343 .reset = wl1271_spi_reset,
344 .init = wl1271_spi_init,
345 .power = wl1271_spi_set_power,
346 .dev = wl1271_spi_wl_to_dev,
347 .enable_irq = wl1271_spi_enable_interrupts,
348 .disable_irq = wl1271_spi_disable_interrupts
349};
350
351static int __devinit wl1271_probe(struct spi_device *spi)
352{
353 struct wl12xx_platform_data *pdata;
354 struct ieee80211_hw *hw;
355 struct wl1271 *wl;
356 int ret;
357
358 pdata = spi->dev.platform_data;
359 if (!pdata) {
360 wl1271_error("no platform data");
361 return -ENODEV;
362 }
363
364 hw = wl1271_alloc_hw();
365 if (IS_ERR(hw))
366 return PTR_ERR(hw);
367
368 wl = hw->priv;
369
370 dev_set_drvdata(&spi->dev, wl);
371 wl->if_priv = spi;
372
373 wl->if_ops = &spi_ops;
374
375 /* This is the only SPI value that we need to set here, the rest
376 * comes from the board-peripherals file */
377 spi->bits_per_word = 32;
378
379 ret = spi_setup(spi);
380 if (ret < 0) {
381 wl1271_error("spi_setup failed");
382 goto out_free;
383 }
384
385 wl->set_power = pdata->set_power;
386 if (!wl->set_power) {
387 wl1271_error("set power function missing in platform data");
388 ret = -ENODEV;
389 goto out_free;
390 }
391
392 wl->irq = spi->irq;
393 if (wl->irq < 0) {
394 wl1271_error("irq missing in platform data");
395 ret = -ENODEV;
396 goto out_free;
397 }
398
399 ret = request_irq(wl->irq, wl1271_irq, 0, DRIVER_NAME, wl);
400 if (ret < 0) {
401 wl1271_error("request_irq() failed: %d", ret);
402 goto out_free;
403 }
404
405 set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
406
407 disable_irq(wl->irq);
408
409 ret = wl1271_init_ieee80211(wl);
410 if (ret)
411 goto out_irq;
412
413 ret = wl1271_register_hw(wl);
414 if (ret)
415 goto out_irq;
416
417 wl1271_notice("initialized");
418
419 return 0;
420
421 out_irq:
422 free_irq(wl->irq, wl);
423
424 out_free:
425 wl1271_free_hw(wl);
426
427 return ret;
428}
429
430static int __devexit wl1271_remove(struct spi_device *spi)
431{
432 struct wl1271 *wl = dev_get_drvdata(&spi->dev);
433
434 free_irq(wl->irq, wl);
435
436 wl1271_unregister_hw(wl);
437 wl1271_free_hw(wl);
438
439 return 0;
440}
441
442
443static struct spi_driver wl1271_spi_driver = {
444 .driver = {
445 .name = "wl1271",
446 .bus = &spi_bus_type,
447 .owner = THIS_MODULE,
448 },
449
450 .probe = wl1271_probe,
451 .remove = __devexit_p(wl1271_remove),
452};
453
454static int __init wl1271_init(void)
455{
456 int ret;
457
458 ret = spi_register_driver(&wl1271_spi_driver);
459 if (ret < 0) {
460 wl1271_error("failed to register spi driver: %d", ret);
461 goto out;
462 }
463
464out:
465 return ret;
466}
467
468static void __exit wl1271_exit(void)
469{
470 spi_unregister_driver(&wl1271_spi_driver);
471
472 wl1271_notice("unloaded");
473}
474
475module_init(wl1271_init);
476module_exit(wl1271_exit);
477
478MODULE_LICENSE("GPL");
479MODULE_AUTHOR("Luciano Coelho <luciano.coelho@nokia.com>");
480MODULE_AUTHOR("Juuso Oikarinen <juuso.oikarinen@nokia.com>");
481MODULE_FIRMWARE(WL1271_FW_NAME);
diff --git a/drivers/net/wireless/wl12xx/wl1271_spi.h b/drivers/net/wireless/wl12xx/wl1271_spi.h
deleted file mode 100644
index a803596dad4a..000000000000
--- a/drivers/net/wireless/wl12xx/wl1271_spi.h
+++ /dev/null
@@ -1,96 +0,0 @@
1/*
2 * This file is part of wl1271
3 *
4 * Copyright (C) 1998-2009 Texas Instruments. All rights reserved.
5 * Copyright (C) 2008-2009 Nokia Corporation
6 *
7 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#ifndef __WL1271_SPI_H__
26#define __WL1271_SPI_H__
27
28#include "wl1271_reg.h"
29
30#define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0
31
32#define HW_PARTITION_REGISTERS_ADDR 0x1ffc0
33#define HW_PART0_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR)
34#define HW_PART0_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 4)
35#define HW_PART1_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR + 8)
36#define HW_PART1_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 12)
37#define HW_PART2_SIZE_ADDR (HW_PARTITION_REGISTERS_ADDR + 16)
38#define HW_PART2_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 20)
39#define HW_PART3_START_ADDR (HW_PARTITION_REGISTERS_ADDR + 24)
40
41#define HW_ACCESS_REGISTER_SIZE 4
42
43#define HW_ACCESS_PRAM_MAX_RANGE 0x3c000
44
45#define WSPI_CMD_READ 0x40000000
46#define WSPI_CMD_WRITE 0x00000000
47#define WSPI_CMD_FIXED 0x20000000
48#define WSPI_CMD_BYTE_LENGTH 0x1FFE0000
49#define WSPI_CMD_BYTE_LENGTH_OFFSET 17
50#define WSPI_CMD_BYTE_ADDR 0x0001FFFF
51
52#define WSPI_INIT_CMD_CRC_LEN 5
53
54#define WSPI_INIT_CMD_START 0x00
55#define WSPI_INIT_CMD_TX 0x40
56/* the extra bypass bit is sampled by the TNET as '1' */
57#define WSPI_INIT_CMD_BYPASS_BIT 0x80
58#define WSPI_INIT_CMD_FIXEDBUSY_LEN 0x07
59#define WSPI_INIT_CMD_EN_FIXEDBUSY 0x80
60#define WSPI_INIT_CMD_DIS_FIXEDBUSY 0x00
61#define WSPI_INIT_CMD_IOD 0x40
62#define WSPI_INIT_CMD_IP 0x20
63#define WSPI_INIT_CMD_CS 0x10
64#define WSPI_INIT_CMD_WS 0x08
65#define WSPI_INIT_CMD_WSPI 0x01
66#define WSPI_INIT_CMD_END 0x01
67
68#define WSPI_INIT_CMD_LEN 8
69
70#define HW_ACCESS_WSPI_FIXED_BUSY_LEN \
71 ((WL1271_BUSY_WORD_LEN - 4) / sizeof(u32))
72#define HW_ACCESS_WSPI_INIT_CMD_MASK 0
73
74#define OCP_CMD_LOOP 32
75
76#define OCP_CMD_WRITE 0x1
77#define OCP_CMD_READ 0x2
78
79#define OCP_READY_MASK BIT(18)
80#define OCP_STATUS_MASK (BIT(16) | BIT(17))
81
82#define OCP_STATUS_NO_RESP 0x00000
83#define OCP_STATUS_OK 0x10000
84#define OCP_STATUS_REQ_FAILED 0x20000
85#define OCP_STATUS_RESP_ERROR 0x30000
86
87/* Raw target IO, address is not translated */
88void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf,
89 size_t len, bool fixed);
90void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
91 size_t len, bool fixed);
92
93/* INIT and RESET words */
94void wl1271_spi_reset(struct wl1271 *wl);
95void wl1271_spi_init(struct wl1271 *wl);
96#endif /* __WL1271_SPI_H__ */
diff --git a/drivers/net/wireless/wl12xx/wl1271_testmode.c b/drivers/net/wireless/wl12xx/wl1271_testmode.c
index 3919102e942e..2401e6035d51 100644
--- a/drivers/net/wireless/wl12xx/wl1271_testmode.c
+++ b/drivers/net/wireless/wl12xx/wl1271_testmode.c
@@ -25,7 +25,6 @@
25#include <net/genetlink.h> 25#include <net/genetlink.h>
26 26
27#include "wl1271.h" 27#include "wl1271.h"
28#include "wl1271_spi.h"
29#include "wl1271_acx.h" 28#include "wl1271_acx.h"
30 29
31#define WL1271_TM_MAX_DATA_LENGTH 1024 30#define WL1271_TM_MAX_DATA_LENGTH 1024
diff --git a/drivers/net/wireless/wl12xx/wl1271_tx.c b/drivers/net/wireless/wl12xx/wl1271_tx.c
index 811e739d05bf..6d109df9a0a0 100644
--- a/drivers/net/wireless/wl12xx/wl1271_tx.c
+++ b/drivers/net/wireless/wl12xx/wl1271_tx.c
@@ -25,7 +25,6 @@
25#include <linux/module.h> 25#include <linux/module.h>
26 26
27#include "wl1271.h" 27#include "wl1271.h"
28#include "wl1271_spi.h"
29#include "wl1271_io.h" 28#include "wl1271_io.h"
30#include "wl1271_reg.h" 29#include "wl1271_reg.h"
31#include "wl1271_ps.h" 30#include "wl1271_ps.h"
@@ -47,7 +46,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra)
47{ 46{
48 struct wl1271_tx_hw_descr *desc; 47 struct wl1271_tx_hw_descr *desc;
49 u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra; 48 u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra;
50 u32 total_blocks, excluded; 49 u32 total_blocks;
51 int id, ret = -EBUSY; 50 int id, ret = -EBUSY;
52 51
53 /* allocate free identifier for the packet */ 52 /* allocate free identifier for the packet */
@@ -57,12 +56,8 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra)
57 56
58 /* approximate the number of blocks required for this packet 57 /* approximate the number of blocks required for this packet
59 in the firmware */ 58 in the firmware */
60 /* FIXME: try to figure out what is done here and make it cleaner */ 59 total_blocks = total_len + TX_HW_BLOCK_SIZE - 1;
61 total_blocks = (total_len + 20) >> TX_HW_BLOCK_SHIFT_DIV; 60 total_blocks = total_blocks / TX_HW_BLOCK_SIZE + TX_HW_BLOCK_SPARE;
62 excluded = (total_blocks << 2) + ((total_len + 20) & 0xff) + 34;
63 total_blocks += (excluded > 252) ? 2 : 1;
64 total_blocks += TX_HW_BLOCK_SPARE;
65
66 if (total_blocks <= wl->tx_blocks_available) { 61 if (total_blocks <= wl->tx_blocks_available) {
67 desc = (struct wl1271_tx_hw_descr *)skb_push( 62 desc = (struct wl1271_tx_hw_descr *)skb_push(
68 skb, total_len - skb->len); 63 skb, total_len - skb->len);
@@ -87,8 +82,10 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra)
87static int wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb, 82static int wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb,
88 u32 extra, struct ieee80211_tx_info *control) 83 u32 extra, struct ieee80211_tx_info *control)
89{ 84{
85 struct timespec ts;
90 struct wl1271_tx_hw_descr *desc; 86 struct wl1271_tx_hw_descr *desc;
91 int pad, ac; 87 int pad, ac;
88 s64 hosttime;
92 u16 tx_attr; 89 u16 tx_attr;
93 90
94 desc = (struct wl1271_tx_hw_descr *) skb->data; 91 desc = (struct wl1271_tx_hw_descr *) skb->data;
@@ -102,8 +99,9 @@ static int wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb,
102 } 99 }
103 100
104 /* configure packet life time */ 101 /* configure packet life time */
105 desc->start_time = cpu_to_le32(jiffies_to_usecs(jiffies) - 102 getnstimeofday(&ts);
106 wl->time_offset); 103 hosttime = (timespec_to_ns(&ts) >> 10);
104 desc->start_time = cpu_to_le32(hosttime - wl->time_offset);
107 desc->life_time = cpu_to_le16(TX_HW_MGMT_PKT_LIFETIME_TU); 105 desc->life_time = cpu_to_le16(TX_HW_MGMT_PKT_LIFETIME_TU);
108 106
109 /* configure the tx attributes */ 107 /* configure the tx attributes */
@@ -170,7 +168,6 @@ static int wl1271_tx_send_packet(struct wl1271 *wl, struct sk_buff *skb,
170 168
171 /* write packet new counter into the write access register */ 169 /* write packet new counter into the write access register */
172 wl->tx_packets_count++; 170 wl->tx_packets_count++;
173 wl1271_write32(wl, WL1271_HOST_WR_ACCESS, wl->tx_packets_count);
174 171
175 desc = (struct wl1271_tx_hw_descr *) skb->data; 172 desc = (struct wl1271_tx_hw_descr *) skb->data;
176 wl1271_debug(DEBUG_TX, "tx id %u skb 0x%p payload %u (%u words)", 173 wl1271_debug(DEBUG_TX, "tx id %u skb 0x%p payload %u (%u words)",
@@ -245,6 +242,7 @@ void wl1271_tx_work(struct work_struct *work)
245 struct sk_buff *skb; 242 struct sk_buff *skb;
246 bool woken_up = false; 243 bool woken_up = false;
247 u32 sta_rates = 0; 244 u32 sta_rates = 0;
245 u32 prev_tx_packets_count;
248 int ret; 246 int ret;
249 247
250 /* check if the rates supported by the AP have changed */ 248 /* check if the rates supported by the AP have changed */
@@ -261,6 +259,8 @@ void wl1271_tx_work(struct work_struct *work)
261 if (unlikely(wl->state == WL1271_STATE_OFF)) 259 if (unlikely(wl->state == WL1271_STATE_OFF))
262 goto out; 260 goto out;
263 261
262 prev_tx_packets_count = wl->tx_packets_count;
263
264 /* if rates have changed, re-configure the rate policy */ 264 /* if rates have changed, re-configure the rate policy */
265 if (unlikely(sta_rates)) { 265 if (unlikely(sta_rates)) {
266 wl->rate_set = wl1271_tx_enabled_rates_get(wl, sta_rates); 266 wl->rate_set = wl1271_tx_enabled_rates_get(wl, sta_rates);
@@ -271,31 +271,26 @@ void wl1271_tx_work(struct work_struct *work)
271 if (!woken_up) { 271 if (!woken_up) {
272 ret = wl1271_ps_elp_wakeup(wl, false); 272 ret = wl1271_ps_elp_wakeup(wl, false);
273 if (ret < 0) 273 if (ret < 0)
274 goto out; 274 goto out_ack;
275 woken_up = true; 275 woken_up = true;
276 } 276 }
277 277
278 ret = wl1271_tx_frame(wl, skb); 278 ret = wl1271_tx_frame(wl, skb);
279 if (ret == -EBUSY) { 279 if (ret == -EBUSY) {
280 /* firmware buffer is full, stop queues */ 280 /* firmware buffer is full, lets stop transmitting. */
281 wl1271_debug(DEBUG_TX, "tx_work: fw buffer full, "
282 "stop queues");
283 ieee80211_stop_queues(wl->hw);
284 set_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags);
285 skb_queue_head(&wl->tx_queue, skb); 281 skb_queue_head(&wl->tx_queue, skb);
286 goto out; 282 goto out_ack;
287 } else if (ret < 0) { 283 } else if (ret < 0) {
288 dev_kfree_skb(skb); 284 dev_kfree_skb(skb);
289 goto out; 285 goto out_ack;
290 } else if (test_and_clear_bit(WL1271_FLAG_TX_QUEUE_STOPPED,
291 &wl->flags)) {
292 /* firmware buffer has space, restart queues */
293 wl1271_debug(DEBUG_TX,
294 "complete_packet: waking queues");
295 ieee80211_wake_queues(wl->hw);
296 } 286 }
297 } 287 }
298 288
289out_ack:
290 /* interrupt the firmware with the new packets */
291 if (prev_tx_packets_count != wl->tx_packets_count)
292 wl1271_write32(wl, WL1271_HOST_WR_ACCESS, wl->tx_packets_count);
293
299out: 294out:
300 if (woken_up) 295 if (woken_up)
301 wl1271_ps_elp_sleep(wl); 296 wl1271_ps_elp_sleep(wl);
@@ -308,11 +303,10 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl,
308{ 303{
309 struct ieee80211_tx_info *info; 304 struct ieee80211_tx_info *info;
310 struct sk_buff *skb; 305 struct sk_buff *skb;
311 u16 seq;
312 int id = result->id; 306 int id = result->id;
313 307
314 /* check for id legality */ 308 /* check for id legality */
315 if (id >= ACX_TX_DESCRIPTORS || wl->tx_frames[id] == NULL) { 309 if (unlikely(id >= ACX_TX_DESCRIPTORS || wl->tx_frames[id] == NULL)) {
316 wl1271_warning("TX result illegal id: %d", id); 310 wl1271_warning("TX result illegal id: %d", id);
317 return; 311 return;
318 } 312 }
@@ -336,15 +330,10 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl,
336 wl->stats.retry_count += result->ack_failures; 330 wl->stats.retry_count += result->ack_failures;
337 331
338 /* update security sequence number */ 332 /* update security sequence number */
339 seq = wl->tx_security_seq_16 + 333 wl->tx_security_seq += (result->lsb_security_sequence_number -
340 (result->lsb_security_sequence_number - 334 wl->tx_security_last_seq);
341 wl->tx_security_last_seq);
342 wl->tx_security_last_seq = result->lsb_security_sequence_number; 335 wl->tx_security_last_seq = result->lsb_security_sequence_number;
343 336
344 if (seq < wl->tx_security_seq_16)
345 wl->tx_security_seq_32++;
346 wl->tx_security_seq_16 = seq;
347
348 /* remove private header from packet */ 337 /* remove private header from packet */
349 skb_pull(skb, sizeof(struct wl1271_tx_hw_descr)); 338 skb_pull(skb, sizeof(struct wl1271_tx_hw_descr));
350 339
@@ -361,29 +350,37 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl,
361 result->id, skb, result->ack_failures, 350 result->id, skb, result->ack_failures,
362 result->rate_class_index, result->status); 351 result->rate_class_index, result->status);
363 352
353 /* FIXME: do we need to tell the stack about the used rate? */
354
364 /* return the packet to the stack */ 355 /* return the packet to the stack */
365 ieee80211_tx_status(wl->hw, skb); 356 ieee80211_tx_status(wl->hw, skb);
366 wl->tx_frames[result->id] = NULL; 357 wl->tx_frames[result->id] = NULL;
367} 358}
368 359
369/* Called upon reception of a TX complete interrupt */ 360/* Called upon reception of a TX complete interrupt */
370void wl1271_tx_complete(struct wl1271 *wl, u32 count) 361void wl1271_tx_complete(struct wl1271 *wl)
371{ 362{
372 struct wl1271_acx_mem_map *memmap = 363 struct wl1271_acx_mem_map *memmap =
373 (struct wl1271_acx_mem_map *)wl->target_mem_map; 364 (struct wl1271_acx_mem_map *)wl->target_mem_map;
365 u32 count, fw_counter;
374 u32 i; 366 u32 i;
375 367
376 wl1271_debug(DEBUG_TX, "tx_complete received, packets: %d", count);
377
378 /* read the tx results from the chipset */ 368 /* read the tx results from the chipset */
379 wl1271_read(wl, le32_to_cpu(memmap->tx_result), 369 wl1271_read(wl, le32_to_cpu(memmap->tx_result),
380 wl->tx_res_if, sizeof(*wl->tx_res_if), false); 370 wl->tx_res_if, sizeof(*wl->tx_res_if), false);
371 fw_counter = le32_to_cpu(wl->tx_res_if->tx_result_fw_counter);
372
373 /* write host counter to chipset (to ack) */
374 wl1271_write32(wl, le32_to_cpu(memmap->tx_result) +
375 offsetof(struct wl1271_tx_hw_res_if,
376 tx_result_host_counter), fw_counter);
377
378 count = fw_counter - wl->tx_results_count;
379 wl1271_debug(DEBUG_TX, "tx_complete received, packets: %d", count);
381 380
382 /* verify that the result buffer is not getting overrun */ 381 /* verify that the result buffer is not getting overrun */
383 if (count > TX_HW_RESULT_QUEUE_LEN) { 382 if (unlikely(count > TX_HW_RESULT_QUEUE_LEN))
384 wl1271_warning("TX result overflow from chipset: %d", count); 383 wl1271_warning("TX result overflow from chipset: %d", count);
385 count = TX_HW_RESULT_QUEUE_LEN;
386 }
387 384
388 /* process the results */ 385 /* process the results */
389 for (i = 0; i < count; i++) { 386 for (i = 0; i < count; i++) {
@@ -397,11 +394,18 @@ void wl1271_tx_complete(struct wl1271 *wl, u32 count)
397 wl->tx_results_count++; 394 wl->tx_results_count++;
398 } 395 }
399 396
400 /* write host counter to chipset (to ack) */ 397 if (test_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags) &&
401 wl1271_write32(wl, le32_to_cpu(memmap->tx_result) + 398 skb_queue_len(&wl->tx_queue) <= WL1271_TX_QUEUE_LOW_WATERMARK) {
402 offsetof(struct wl1271_tx_hw_res_if, 399 unsigned long flags;
403 tx_result_host_counter), 400
404 le32_to_cpu(wl->tx_res_if->tx_result_fw_counter)); 401 /* firmware buffer has space, restart queues */
402 wl1271_debug(DEBUG_TX, "tx_complete: waking queues");
403 spin_lock_irqsave(&wl->wl_lock, flags);
404 ieee80211_wake_queues(wl->hw);
405 clear_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags);
406 spin_unlock_irqrestore(&wl->wl_lock, flags);
407 ieee80211_queue_work(wl->hw, &wl->tx_work);
408 }
405} 409}
406 410
407/* caller must hold wl->mutex */ 411/* caller must hold wl->mutex */
diff --git a/drivers/net/wireless/wl12xx/wl1271_tx.h b/drivers/net/wireless/wl12xx/wl1271_tx.h
index 17e405a09caa..5e6c27a57415 100644
--- a/drivers/net/wireless/wl12xx/wl1271_tx.h
+++ b/drivers/net/wireless/wl12xx/wl1271_tx.h
@@ -26,7 +26,7 @@
26#define __WL1271_TX_H__ 26#define __WL1271_TX_H__
27 27
28#define TX_HW_BLOCK_SPARE 2 28#define TX_HW_BLOCK_SPARE 2
29#define TX_HW_BLOCK_SHIFT_DIV 8 29#define TX_HW_BLOCK_SIZE 252
30 30
31#define TX_HW_MGMT_PKT_LIFETIME_TU 2000 31#define TX_HW_MGMT_PKT_LIFETIME_TU 2000
32/* The chipset reference driver states, that the "aid" value 1 32/* The chipset reference driver states, that the "aid" value 1
@@ -125,9 +125,6 @@ struct wl1271_tx_hw_res_if {
125 125
126static inline int wl1271_tx_get_queue(int queue) 126static inline int wl1271_tx_get_queue(int queue)
127{ 127{
128 /* FIXME: use best effort until WMM is enabled */
129 return CONF_TX_AC_BE;
130
131 switch (queue) { 128 switch (queue) {
132 case 0: 129 case 0:
133 return CONF_TX_AC_VO; 130 return CONF_TX_AC_VO;
@@ -160,7 +157,7 @@ static inline int wl1271_tx_ac_to_tid(int ac)
160} 157}
161 158
162void wl1271_tx_work(struct work_struct *work); 159void wl1271_tx_work(struct work_struct *work);
163void wl1271_tx_complete(struct wl1271 *wl, u32 count); 160void wl1271_tx_complete(struct wl1271 *wl);
164void wl1271_tx_flush(struct wl1271 *wl); 161void wl1271_tx_flush(struct wl1271 *wl);
165 162
166#endif 163#endif
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 7b9621de239f..65dd502eab0d 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -1834,32 +1834,32 @@ out:
1834} 1834}
1835 1835
1836static const iw_handler wl3501_handler[] = { 1836static const iw_handler wl3501_handler[] = {
1837 [SIOCGIWNAME - SIOCIWFIRST] = wl3501_get_name, 1837 IW_HANDLER(SIOCGIWNAME, wl3501_get_name),
1838 [SIOCSIWFREQ - SIOCIWFIRST] = wl3501_set_freq, 1838 IW_HANDLER(SIOCSIWFREQ, wl3501_set_freq),
1839 [SIOCGIWFREQ - SIOCIWFIRST] = wl3501_get_freq, 1839 IW_HANDLER(SIOCGIWFREQ, wl3501_get_freq),
1840 [SIOCSIWMODE - SIOCIWFIRST] = wl3501_set_mode, 1840 IW_HANDLER(SIOCSIWMODE, wl3501_set_mode),
1841 [SIOCGIWMODE - SIOCIWFIRST] = wl3501_get_mode, 1841 IW_HANDLER(SIOCGIWMODE, wl3501_get_mode),
1842 [SIOCGIWSENS - SIOCIWFIRST] = wl3501_get_sens, 1842 IW_HANDLER(SIOCGIWSENS, wl3501_get_sens),
1843 [SIOCGIWRANGE - SIOCIWFIRST] = wl3501_get_range, 1843 IW_HANDLER(SIOCGIWRANGE, wl3501_get_range),
1844 [SIOCSIWSPY - SIOCIWFIRST] = iw_handler_set_spy, 1844 IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy),
1845 [SIOCGIWSPY - SIOCIWFIRST] = iw_handler_get_spy, 1845 IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy),
1846 [SIOCSIWTHRSPY - SIOCIWFIRST] = iw_handler_set_thrspy, 1846 IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy),
1847 [SIOCGIWTHRSPY - SIOCIWFIRST] = iw_handler_get_thrspy, 1847 IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy),
1848 [SIOCSIWAP - SIOCIWFIRST] = wl3501_set_wap, 1848 IW_HANDLER(SIOCSIWAP, wl3501_set_wap),
1849 [SIOCGIWAP - SIOCIWFIRST] = wl3501_get_wap, 1849 IW_HANDLER(SIOCGIWAP, wl3501_get_wap),
1850 [SIOCSIWSCAN - SIOCIWFIRST] = wl3501_set_scan, 1850 IW_HANDLER(SIOCSIWSCAN, wl3501_set_scan),
1851 [SIOCGIWSCAN - SIOCIWFIRST] = wl3501_get_scan, 1851 IW_HANDLER(SIOCGIWSCAN, wl3501_get_scan),
1852 [SIOCSIWESSID - SIOCIWFIRST] = wl3501_set_essid, 1852 IW_HANDLER(SIOCSIWESSID, wl3501_set_essid),
1853 [SIOCGIWESSID - SIOCIWFIRST] = wl3501_get_essid, 1853 IW_HANDLER(SIOCGIWESSID, wl3501_get_essid),
1854 [SIOCSIWNICKN - SIOCIWFIRST] = wl3501_set_nick, 1854 IW_HANDLER(SIOCSIWNICKN, wl3501_set_nick),
1855 [SIOCGIWNICKN - SIOCIWFIRST] = wl3501_get_nick, 1855 IW_HANDLER(SIOCGIWNICKN, wl3501_get_nick),
1856 [SIOCGIWRATE - SIOCIWFIRST] = wl3501_get_rate, 1856 IW_HANDLER(SIOCGIWRATE, wl3501_get_rate),
1857 [SIOCGIWRTS - SIOCIWFIRST] = wl3501_get_rts_threshold, 1857 IW_HANDLER(SIOCGIWRTS, wl3501_get_rts_threshold),
1858 [SIOCGIWFRAG - SIOCIWFIRST] = wl3501_get_frag_threshold, 1858 IW_HANDLER(SIOCGIWFRAG, wl3501_get_frag_threshold),
1859 [SIOCGIWTXPOW - SIOCIWFIRST] = wl3501_get_txpow, 1859 IW_HANDLER(SIOCGIWTXPOW, wl3501_get_txpow),
1860 [SIOCGIWRETRY - SIOCIWFIRST] = wl3501_get_retry, 1860 IW_HANDLER(SIOCGIWRETRY, wl3501_get_retry),
1861 [SIOCGIWENCODE - SIOCIWFIRST] = wl3501_get_encode, 1861 IW_HANDLER(SIOCGIWENCODE, wl3501_get_encode),
1862 [SIOCGIWPOWER - SIOCIWFIRST] = wl3501_get_power, 1862 IW_HANDLER(SIOCGIWPOWER, wl3501_get_power),
1863}; 1863};
1864 1864
1865static const struct iw_handler_def wl3501_handler_def = { 1865static const struct iw_handler_def wl3501_handler_def = {
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index 6917286edcae..74530b2d672c 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -875,7 +875,7 @@ static struct iw_statistics *zd1201_get_wireless_stats(struct net_device *dev)
875static void zd1201_set_multicast(struct net_device *dev) 875static void zd1201_set_multicast(struct net_device *dev)
876{ 876{
877 struct zd1201 *zd = netdev_priv(dev); 877 struct zd1201 *zd = netdev_priv(dev);
878 struct dev_mc_list *mc; 878 struct netdev_hw_addr *ha;
879 unsigned char reqbuf[ETH_ALEN*ZD1201_MAXMULTI]; 879 unsigned char reqbuf[ETH_ALEN*ZD1201_MAXMULTI];
880 int i; 880 int i;
881 881
@@ -883,8 +883,8 @@ static void zd1201_set_multicast(struct net_device *dev)
883 return; 883 return;
884 884
885 i = 0; 885 i = 0;
886 netdev_for_each_mc_addr(mc, dev) 886 netdev_for_each_mc_addr(ha, dev)
887 memcpy(reqbuf + i++ * ETH_ALEN, mc->dmi_addr, ETH_ALEN); 887 memcpy(reqbuf + i++ * ETH_ALEN, ha->addr, ETH_ALEN);
888 zd1201_setconfig(zd, ZD1201_RID_CNFGROUPADDRESS, reqbuf, 888 zd1201_setconfig(zd, ZD1201_RID_CNFGROUPADDRESS, reqbuf,
889 netdev_mc_count(dev) * ETH_ALEN, 0); 889 netdev_mc_count(dev) * ETH_ALEN, 0);
890} 890}
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 00e09e26c826..6d95e4d74d7f 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -947,20 +947,17 @@ static void set_rx_filter_handler(struct work_struct *work)
947} 947}
948 948
949static u64 zd_op_prepare_multicast(struct ieee80211_hw *hw, 949static u64 zd_op_prepare_multicast(struct ieee80211_hw *hw,
950 int mc_count, struct dev_addr_list *mclist) 950 struct netdev_hw_addr_list *mc_list)
951{ 951{
952 struct zd_mac *mac = zd_hw_mac(hw); 952 struct zd_mac *mac = zd_hw_mac(hw);
953 struct zd_mc_hash hash; 953 struct zd_mc_hash hash;
954 int i; 954 struct netdev_hw_addr *ha;
955 955
956 zd_mc_clear(&hash); 956 zd_mc_clear(&hash);
957 957
958 for (i = 0; i < mc_count; i++) { 958 netdev_hw_addr_list_for_each(ha, mc_list) {
959 if (!mclist) 959 dev_dbg_f(zd_mac_dev(mac), "mc addr %pM\n", ha->addr);
960 break; 960 zd_mc_add_addr(&hash, ha->addr);
961 dev_dbg_f(zd_mac_dev(mac), "mc addr %pM\n", mclist->dmi_addr);
962 zd_mc_add_addr(&hash, mclist->dmi_addr);
963 mclist = mclist->next;
964 } 961 }
965 962
966 return hash.low | ((u64)hash.high << 32); 963 return hash.low | ((u64)hash.high << 32);
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index 1a74594224b1..eaebba8df6fc 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -638,7 +638,6 @@ static void xemaclite_rx_handler(struct net_device *dev)
638 } 638 }
639 639
640 skb_put(skb, len); /* Tell the skb how much data we got */ 640 skb_put(skb, len); /* Tell the skb how much data we got */
641 skb->dev = dev; /* Fill out required meta-data */
642 641
643 skb->protocol = eth_type_trans(skb, dev); 642 skb->protocol = eth_type_trans(skb, dev);
644 skb->ip_summed = CHECKSUM_NONE; 643 skb->ip_summed = CHECKSUM_NONE;
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
index 7d4107f5eeb0..34c91cf5d839 100644
--- a/drivers/net/yellowfin.c
+++ b/drivers/net/yellowfin.c
@@ -1300,25 +1300,25 @@ static void set_rx_mode(struct net_device *dev)
1300 /* Too many to filter well, or accept all multicasts. */ 1300 /* Too many to filter well, or accept all multicasts. */
1301 iowrite16(0x000B, ioaddr + AddrMode); 1301 iowrite16(0x000B, ioaddr + AddrMode);
1302 } else if (!netdev_mc_empty(dev)) { /* Must use the multicast hash table. */ 1302 } else if (!netdev_mc_empty(dev)) { /* Must use the multicast hash table. */
1303 struct dev_mc_list *mclist; 1303 struct netdev_hw_addr *ha;
1304 u16 hash_table[4]; 1304 u16 hash_table[4];
1305 int i; 1305 int i;
1306 1306
1307 memset(hash_table, 0, sizeof(hash_table)); 1307 memset(hash_table, 0, sizeof(hash_table));
1308 netdev_for_each_mc_addr(mclist, dev) { 1308 netdev_for_each_mc_addr(ha, dev) {
1309 unsigned int bit; 1309 unsigned int bit;
1310 1310
1311 /* Due to a bug in the early chip versions, multiple filter 1311 /* Due to a bug in the early chip versions, multiple filter
1312 slots must be set for each address. */ 1312 slots must be set for each address. */
1313 if (yp->drv_flags & HasMulticastBug) { 1313 if (yp->drv_flags & HasMulticastBug) {
1314 bit = (ether_crc_le(3, mclist->dmi_addr) >> 3) & 0x3f; 1314 bit = (ether_crc_le(3, ha->addr) >> 3) & 0x3f;
1315 hash_table[bit >> 4] |= (1 << bit); 1315 hash_table[bit >> 4] |= (1 << bit);
1316 bit = (ether_crc_le(4, mclist->dmi_addr) >> 3) & 0x3f; 1316 bit = (ether_crc_le(4, ha->addr) >> 3) & 0x3f;
1317 hash_table[bit >> 4] |= (1 << bit); 1317 hash_table[bit >> 4] |= (1 << bit);
1318 bit = (ether_crc_le(5, mclist->dmi_addr) >> 3) & 0x3f; 1318 bit = (ether_crc_le(5, ha->addr) >> 3) & 0x3f;
1319 hash_table[bit >> 4] |= (1 << bit); 1319 hash_table[bit >> 4] |= (1 << bit);
1320 } 1320 }
1321 bit = (ether_crc_le(6, mclist->dmi_addr) >> 3) & 0x3f; 1321 bit = (ether_crc_le(6, ha->addr) >> 3) & 0x3f;
1322 hash_table[bit >> 4] |= (1 << bit); 1322 hash_table[bit >> 4] |= (1 << bit);
1323 } 1323 }
1324 /* Copy the hash table to the chip. */ 1324 /* Copy the hash table to the chip. */
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 6f1e3036bafd..945f3e0a9f06 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -607,7 +607,6 @@ static int qeth_l2_set_mac_address(struct net_device *dev, void *p)
607static void qeth_l2_set_multicast_list(struct net_device *dev) 607static void qeth_l2_set_multicast_list(struct net_device *dev)
608{ 608{
609 struct qeth_card *card = dev->ml_priv; 609 struct qeth_card *card = dev->ml_priv;
610 struct dev_addr_list *dm;
611 struct netdev_hw_addr *ha; 610 struct netdev_hw_addr *ha;
612 611
613 if (card->info.type == QETH_CARD_TYPE_OSN) 612 if (card->info.type == QETH_CARD_TYPE_OSN)
@@ -619,8 +618,8 @@ static void qeth_l2_set_multicast_list(struct net_device *dev)
619 return; 618 return;
620 qeth_l2_del_all_mc(card); 619 qeth_l2_del_all_mc(card);
621 spin_lock_bh(&card->mclock); 620 spin_lock_bh(&card->mclock);
622 for (dm = dev->mc_list; dm; dm = dm->next) 621 netdev_for_each_mc_addr(ha, dev)
623 qeth_l2_add_mc(card, dm->da_addr, 0); 622 qeth_l2_add_mc(card, ha->addr, 0);
624 623
625 netdev_for_each_uc_addr(ha, dev) 624 netdev_for_each_uc_addr(ha, dev)
626 qeth_l2_add_mc(card, ha->addr, 1); 625 qeth_l2_add_mc(card, ha->addr, 1);
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index b3b6e872d806..0b06f065b18b 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -1928,7 +1928,7 @@ static void qeth_l3_free_vlan_addresses6(struct qeth_card *card,
1928 in6_dev = in6_dev_get(vlan_group_get_device(card->vlangrp, vid)); 1928 in6_dev = in6_dev_get(vlan_group_get_device(card->vlangrp, vid));
1929 if (!in6_dev) 1929 if (!in6_dev)
1930 return; 1930 return;
1931 for (ifa = in6_dev->addr_list; ifa; ifa = ifa->lst_next) { 1931 list_for_each_entry(ifa, &in6_dev->addr_list, if_list) {
1932 addr = qeth_l3_get_addr_buffer(QETH_PROT_IPV6); 1932 addr = qeth_l3_get_addr_buffer(QETH_PROT_IPV6);
1933 if (addr) { 1933 if (addr) {
1934 memcpy(&addr->u.a6.addr, &ifa->addr, 1934 memcpy(&addr->u.a6.addr, &ifa->addr,
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 2f47ae7cce91..37de40e01684 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -308,10 +308,10 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,
308 * for multiple unicast MACs. 308 * for multiple unicast MACs.
309 */ 309 */
310 memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); 310 memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
311 dev_unicast_add(netdev, flogi_maddr); 311 dev_uc_add(netdev, flogi_maddr);
312 if (fip->spma) 312 if (fip->spma)
313 dev_unicast_add(netdev, fip->ctl_src_addr); 313 dev_uc_add(netdev, fip->ctl_src_addr);
314 dev_mc_add(netdev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0); 314 dev_mc_add(netdev, FIP_ALL_ENODE_MACS);
315 315
316 /* 316 /*
317 * setup the receive function from ethernet driver 317 * setup the receive function from ethernet driver
@@ -394,10 +394,10 @@ void fcoe_interface_cleanup(struct fcoe_interface *fcoe)
394 394
395 /* Delete secondary MAC addresses */ 395 /* Delete secondary MAC addresses */
396 memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); 396 memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
397 dev_unicast_delete(netdev, flogi_maddr); 397 dev_uc_del(netdev, flogi_maddr);
398 if (fip->spma) 398 if (fip->spma)
399 dev_unicast_delete(netdev, fip->ctl_src_addr); 399 dev_uc_del(netdev, fip->ctl_src_addr);
400 dev_mc_delete(netdev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0); 400 dev_mc_del(netdev, FIP_ALL_ENODE_MACS);
401 401
402 /* Tell the LLD we are done w/ FCoE */ 402 /* Tell the LLD we are done w/ FCoE */
403 ops = netdev->netdev_ops; 403 ops = netdev->netdev_ops;
@@ -490,9 +490,9 @@ static void fcoe_update_src_mac(struct fc_lport *lport, u8 *addr)
490 490
491 rtnl_lock(); 491 rtnl_lock();
492 if (!is_zero_ether_addr(port->data_src_addr)) 492 if (!is_zero_ether_addr(port->data_src_addr))
493 dev_unicast_delete(fcoe->netdev, port->data_src_addr); 493 dev_uc_del(fcoe->netdev, port->data_src_addr);
494 if (!is_zero_ether_addr(addr)) 494 if (!is_zero_ether_addr(addr))
495 dev_unicast_add(fcoe->netdev, addr); 495 dev_uc_add(fcoe->netdev, addr);
496 memcpy(port->data_src_addr, addr, ETH_ALEN); 496 memcpy(port->data_src_addr, addr, ETH_ALEN);
497 rtnl_unlock(); 497 rtnl_unlock();
498} 498}
@@ -819,7 +819,7 @@ static void fcoe_if_destroy(struct fc_lport *lport)
819 819
820 rtnl_lock(); 820 rtnl_lock();
821 if (!is_zero_ether_addr(port->data_src_addr)) 821 if (!is_zero_ether_addr(port->data_src_addr))
822 dev_unicast_delete(netdev, port->data_src_addr); 822 dev_uc_del(netdev, port->data_src_addr);
823 rtnl_unlock(); 823 rtnl_unlock();
824 824
825 /* receives may not be stopped until after this */ 825 /* receives may not be stopped until after this */
diff --git a/drivers/ssb/driver_chipcommon.c b/drivers/ssb/driver_chipcommon.c
index 9681536163ca..59c3c0fdbecd 100644
--- a/drivers/ssb/driver_chipcommon.c
+++ b/drivers/ssb/driver_chipcommon.c
@@ -370,6 +370,7 @@ u32 ssb_chipco_gpio_control(struct ssb_chipcommon *cc, u32 mask, u32 value)
370{ 370{
371 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOCTL, mask, value); 371 return chipco_write32_masked(cc, SSB_CHIPCO_GPIOCTL, mask, value);
372} 372}
373EXPORT_SYMBOL(ssb_chipco_gpio_control);
373 374
374u32 ssb_chipco_gpio_intmask(struct ssb_chipcommon *cc, u32 mask, u32 value) 375u32 ssb_chipco_gpio_intmask(struct ssb_chipcommon *cc, u32 mask, u32 value)
375{ 376{
diff --git a/drivers/staging/arlan/arlan-main.c b/drivers/staging/arlan/arlan-main.c
index 88fdd53cf5d3..80284522c42b 100644
--- a/drivers/staging/arlan/arlan-main.c
+++ b/drivers/staging/arlan/arlan-main.c
@@ -1458,7 +1458,7 @@ static void arlan_rx_interrupt(struct net_device *dev, u_char rxStatus, u_short
1458 !netdev_mc_empty(dev)) 1458 !netdev_mc_empty(dev))
1459 { 1459 {
1460 char hw_dst_addr[6]; 1460 char hw_dst_addr[6];
1461 struct dev_mc_list *dmi; 1461 struct netdev_hw_addr *ha;
1462 int i; 1462 int i;
1463 1463
1464 memcpy_fromio(hw_dst_addr, arlan->ultimateDestAddress, 6); 1464 memcpy_fromio(hw_dst_addr, arlan->ultimateDestAddress, 6);
@@ -1469,12 +1469,13 @@ static void arlan_rx_interrupt(struct net_device *dev, u_char rxStatus, u_short
1469 printk(KERN_ERR "%s mcast 0x0100 \n", dev->name); 1469 printk(KERN_ERR "%s mcast 0x0100 \n", dev->name);
1470 else if (hw_dst_addr[1] == 0x40) 1470 else if (hw_dst_addr[1] == 0x40)
1471 printk(KERN_ERR "%s m/bcast 0x0140 \n", dev->name); 1471 printk(KERN_ERR "%s m/bcast 0x0140 \n", dev->name);
1472 netdev_for_each_mc_entry(dmi, dev) { 1472 netdev_for_each_mc_entry(ha, dev) {
1473 if (arlan_debug & ARLAN_DEBUG_HEADER_DUMP) 1473 if (arlan_debug & ARLAN_DEBUG_HEADER_DUMP)
1474 printk(KERN_ERR "%s mcl %pM\n", 1474 printk(KERN_ERR "%s mcl %pM\n",
1475 dev->name, dmi->dmi_addr); 1475 dev->name,
1476 ha->addr);
1476 for (i = 0; i < 6; i++) 1477 for (i = 0; i < 6; i++)
1477 if (dmi->dmi_addr[i] != hw_dst_addr[i]) 1478 if (ha->addr[i] != hw_dst_addr[i])
1478 break; 1479 break;
1479 if (i == 6) 1480 if (i == 6)
1480 break; 1481 break;
diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c
index 40f8954dde47..2fb89cddef16 100644
--- a/drivers/staging/et131x/et131x_netdev.c
+++ b/drivers/staging/et131x/et131x_netdev.c
@@ -405,7 +405,7 @@ void et131x_multicast(struct net_device *netdev)
405 struct et131x_adapter *adapter = netdev_priv(netdev); 405 struct et131x_adapter *adapter = netdev_priv(netdev);
406 uint32_t PacketFilter = 0; 406 uint32_t PacketFilter = 0;
407 unsigned long flags; 407 unsigned long flags;
408 struct dev_mc_list *mclist; 408 struct netdev_hw_addr *ha;
409 int i; 409 int i;
410 410
411 spin_lock_irqsave(&adapter->Lock, flags); 411 spin_lock_irqsave(&adapter->Lock, flags);
@@ -450,10 +450,10 @@ void et131x_multicast(struct net_device *netdev)
450 450
451 /* Set values in the private adapter struct */ 451 /* Set values in the private adapter struct */
452 i = 0; 452 i = 0;
453 netdev_for_each_mc_addr(mclist, netdev) { 453 netdev_for_each_mc_addr(ha, netdev) {
454 if (i == NIC_MAX_MCAST_LIST) 454 if (i == NIC_MAX_MCAST_LIST)
455 break; 455 break;
456 memcpy(adapter->MCList[i++], mclist->dmi_addr, ETH_ALEN); 456 memcpy(adapter->MCList[i++], ha->addr, ETH_ALEN);
457 } 457 }
458 adapter->MCAddressCount = i; 458 adapter->MCAddressCount = i;
459 459
diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c
index 7daeced317c4..bebf0fd2af85 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -1367,12 +1367,12 @@ static void slic_mcast_set_list(struct net_device *dev)
1367 struct adapter *adapter = netdev_priv(dev); 1367 struct adapter *adapter = netdev_priv(dev);
1368 int status = STATUS_SUCCESS; 1368 int status = STATUS_SUCCESS;
1369 char *addresses; 1369 char *addresses;
1370 struct dev_mc_list *mc_list; 1370 struct netdev_hw_addr *ha;
1371 1371
1372 ASSERT(adapter); 1372 ASSERT(adapter);
1373 1373
1374 netdev_for_each_mc_addr(mc_list, dev) { 1374 netdev_for_each_mc_addr(ha, dev) {
1375 addresses = (char *) &mc_list->dmi_addr; 1375 addresses = (char *) &ha->addr;
1376 status = slic_mcast_add_list(adapter, addresses); 1376 status = slic_mcast_add_list(adapter, addresses);
1377 if (status != STATUS_SUCCESS) 1377 if (status != STATUS_SUCCESS)
1378 break; 1378 break;
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 1d643653a7ed..b698de40a60e 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -3079,7 +3079,7 @@ static void device_set_multi(struct net_device *dev) {
3079 3079
3080 PSMgmtObject pMgmt = pDevice->pMgmt; 3080 PSMgmtObject pMgmt = pDevice->pMgmt;
3081 u32 mc_filter[2]; 3081 u32 mc_filter[2];
3082 struct dev_mc_list *mclist; 3082 struct netdev_hw_addr *ha;
3083 3083
3084 3084
3085 VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byRxMode)); 3085 VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byRxMode));
@@ -3099,8 +3099,8 @@ static void device_set_multi(struct net_device *dev) {
3099 } 3099 }
3100 else { 3100 else {
3101 memset(mc_filter, 0, sizeof(mc_filter)); 3101 memset(mc_filter, 0, sizeof(mc_filter));
3102 netdev_for_each_mc_addr(mclist, dev) { 3102 netdev_for_each_mc_addr(ha, dev) {
3103 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; 3103 int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
3104 mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31)); 3104 mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
3105 } 3105 }
3106 MACvSelectPage1(pDevice->PortOffset); 3106 MACvSelectPage1(pDevice->PortOffset);
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index a8e1adbc9592..49270db98fbb 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -1596,7 +1596,7 @@ static void device_set_multi(struct net_device *dev) {
1596 PSMgmtObject pMgmt = &(pDevice->sMgmtObj); 1596 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1597 u32 mc_filter[2]; 1597 u32 mc_filter[2];
1598 int ii; 1598 int ii;
1599 struct dev_mc_list *mclist; 1599 struct netdev_hw_addr *ha;
1600 BYTE pbyData[8] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; 1600 BYTE pbyData[8] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
1601 BYTE byTmpMode = 0; 1601 BYTE byTmpMode = 0;
1602 int rc; 1602 int rc;
@@ -1632,8 +1632,8 @@ static void device_set_multi(struct net_device *dev) {
1632 } 1632 }
1633 else { 1633 else {
1634 memset(mc_filter, 0, sizeof(mc_filter)); 1634 memset(mc_filter, 0, sizeof(mc_filter));
1635 netdev_for_each_mc_addr(mclist, dev) { 1635 netdev_for_each_mc_addr(ha, dev) {
1636 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; 1636 int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
1637 mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31)); 1637 mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
1638 } 1638 }
1639 for (ii = 0; ii < 4; ii++) { 1639 for (ii = 0; ii < 4; ii++) {
diff --git a/drivers/staging/wavelan/wavelan.c b/drivers/staging/wavelan/wavelan.c
index 54ca63196fdd..f44ef351647b 100644
--- a/drivers/staging/wavelan/wavelan.c
+++ b/drivers/staging/wavelan/wavelan.c
@@ -3419,7 +3419,7 @@ static void wv_82586_config(struct net_device * dev)
3419 ac_cfg_t cfg; /* Configure action */ 3419 ac_cfg_t cfg; /* Configure action */
3420 ac_ias_t ias; /* IA-setup action */ 3420 ac_ias_t ias; /* IA-setup action */
3421 ac_mcs_t mcs; /* Multicast setup */ 3421 ac_mcs_t mcs; /* Multicast setup */
3422 struct dev_mc_list *dmi; 3422 struct netdev_hw_addr *ha;
3423 3423
3424#ifdef DEBUG_CONFIG_TRACE 3424#ifdef DEBUG_CONFIG_TRACE
3425 printk(KERN_DEBUG "%s: ->wv_82586_config()\n", dev->name); 3425 printk(KERN_DEBUG "%s: ->wv_82586_config()\n", dev->name);
@@ -3531,16 +3531,16 @@ static void wv_82586_config(struct net_device * dev)
3531 3531
3532 /* Any address to set? */ 3532 /* Any address to set? */
3533 if (lp->mc_count) { 3533 if (lp->mc_count) {
3534 netdev_for_each_mc_addr(dmi, dev) 3534 netdev_for_each_mc_addr(ha, dev)
3535 outsw(PIOP1(ioaddr), (u16 *) dmi->dmi_addr, 3535 outsw(PIOP1(ioaddr), (u16 *) ha->addr,
3536 WAVELAN_ADDR_SIZE >> 1); 3536 WAVELAN_ADDR_SIZE >> 1);
3537 3537
3538#ifdef DEBUG_CONFIG_INFO 3538#ifdef DEBUG_CONFIG_INFO
3539 printk(KERN_DEBUG 3539 printk(KERN_DEBUG
3540 "%s: wv_82586_config(): set %d multicast addresses:\n", 3540 "%s: wv_82586_config(): set %d multicast addresses:\n",
3541 dev->name, lp->mc_count); 3541 dev->name, lp->mc_count);
3542 netdev_for_each_mc_addr(dmi, dev) 3542 netdev_for_each_mc_addr(ha, dev)
3543 printk(KERN_DEBUG " %pM\n", dmi->dmi_addr); 3543 printk(KERN_DEBUG " %pM\n", ha->addr);
3544#endif 3544#endif
3545 } 3545 }
3546 3546
diff --git a/drivers/staging/wavelan/wavelan_cs.c b/drivers/staging/wavelan/wavelan_cs.c
index 04f691d127b4..a90132a204e6 100644
--- a/drivers/staging/wavelan/wavelan_cs.c
+++ b/drivers/staging/wavelan/wavelan_cs.c
@@ -3591,20 +3591,20 @@ wv_82593_config(struct net_device * dev)
3591 /* If roaming is enabled, join the "Beacon Request" multicast group... */ 3591 /* If roaming is enabled, join the "Beacon Request" multicast group... */
3592 /* But only if it's not in there already! */ 3592 /* But only if it's not in there already! */
3593 if(do_roaming) 3593 if(do_roaming)
3594 dev_mc_add(dev,WAVELAN_BEACON_ADDRESS, WAVELAN_ADDR_SIZE, 1); 3594 dev_mc_add(dev, WAVELAN_BEACON_ADDRESS);
3595#endif /* WAVELAN_ROAMING */ 3595#endif /* WAVELAN_ROAMING */
3596 3596
3597 /* If any multicast address to set */ 3597 /* If any multicast address to set */
3598 if(lp->mc_count) 3598 if(lp->mc_count)
3599 { 3599 {
3600 struct dev_mc_list *dmi; 3600 struct netdev_hw_addr *ha;
3601 int addrs_len = WAVELAN_ADDR_SIZE * lp->mc_count; 3601 int addrs_len = WAVELAN_ADDR_SIZE * lp->mc_count;
3602 3602
3603#ifdef DEBUG_CONFIG_INFO 3603#ifdef DEBUG_CONFIG_INFO
3604 printk(KERN_DEBUG "%s: wv_hw_config(): set %d multicast addresses:\n", 3604 printk(KERN_DEBUG "%s: wv_hw_config(): set %d multicast addresses:\n",
3605 dev->name, lp->mc_count); 3605 dev->name, lp->mc_count);
3606 netdev_for_each_mc_addr(dmi, dev) 3606 netdev_for_each_mc_addr(ha, dev)
3607 printk(KERN_DEBUG " %pM\n", dmi->dmi_addr); 3607 printk(KERN_DEBUG " %pM\n", ha->addr);
3608#endif 3608#endif
3609 3609
3610 /* Initialize adapter's ethernet multicast addresses */ 3610 /* Initialize adapter's ethernet multicast addresses */
@@ -3612,8 +3612,8 @@ wv_82593_config(struct net_device * dev)
3612 outb(((TX_BASE >> 8) & PIORH_MASK) | PIORH_SEL_TX, PIORH(base)); 3612 outb(((TX_BASE >> 8) & PIORH_MASK) | PIORH_SEL_TX, PIORH(base));
3613 outb(addrs_len & 0xff, PIOP(base)); /* byte count lsb */ 3613 outb(addrs_len & 0xff, PIOP(base)); /* byte count lsb */
3614 outb((addrs_len >> 8), PIOP(base)); /* byte count msb */ 3614 outb((addrs_len >> 8), PIOP(base)); /* byte count msb */
3615 netdev_for_each_mc_addr(dmi, dev) 3615 netdev_for_each_mc_addr(ha, dev)
3616 outsb(PIOP(base), dmi->dmi_addr, dmi->dmi_addrlen); 3616 outsb(PIOP(base), ha->addr, dev->addr_len);
3617 3617
3618 /* reset transmit DMA pointer */ 3618 /* reset transmit DMA pointer */
3619 hacr_write_slow(base, HACR_PWR_STAT | HACR_TX_DMA_RESET); 3619 hacr_write_slow(base, HACR_PWR_STAT | HACR_TX_DMA_RESET);
diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c
index 3482eec18651..5d9499bba9cc 100644
--- a/drivers/staging/winbond/wbusb.c
+++ b/drivers/staging/winbond/wbusb.c
@@ -92,10 +92,10 @@ static int wbsoft_get_stats(struct ieee80211_hw *hw,
92 return 0; 92 return 0;
93} 93}
94 94
95static u64 wbsoft_prepare_multicast(struct ieee80211_hw *hw, int mc_count, 95static u64 wbsoft_prepare_multicast(struct ieee80211_hw *hw,
96 struct dev_addr_list *mc_list) 96 struct netdev_hw_addr_list *mc_list)
97{ 97{
98 return mc_count; 98 return netdev_hw_addr_list_count(mc_list);
99} 99}
100 100
101static void wbsoft_configure_filter(struct ieee80211_hw *dev, 101static void wbsoft_configure_filter(struct ieee80211_hw *dev,
diff --git a/drivers/staging/wlags49_h2/wl_netdev.c b/drivers/staging/wlags49_h2/wl_netdev.c
index fa082d90fcad..d7532e89f5fc 100644
--- a/drivers/staging/wlags49_h2/wl_netdev.c
+++ b/drivers/staging/wlags49_h2/wl_netdev.c
@@ -1049,7 +1049,7 @@ void wl_multicast( struct net_device *dev )
1049//;?seems reasonable that even an AP-only driver could afford this small additional footprint 1049//;?seems reasonable that even an AP-only driver could afford this small additional footprint
1050 1050
1051 int x; 1051 int x;
1052 struct dev_mc_list *mclist; 1052 struct netdev_hw_addr *ha;
1053 struct wl_private *lp = wl_priv(dev); 1053 struct wl_private *lp = wl_priv(dev);
1054 unsigned long flags; 1054 unsigned long flags;
1055 /*------------------------------------------------------------------------*/ 1055 /*------------------------------------------------------------------------*/
@@ -1072,9 +1072,9 @@ void wl_multicast( struct net_device *dev )
1072 1072
1073 DBG_PRINT( " mc_count: %d\n", netdev_mc_count(dev)); 1073 DBG_PRINT( " mc_count: %d\n", netdev_mc_count(dev));
1074 1074
1075 netdev_for_each_mc_addr(mclist, dev) 1075 netdev_for_each_mc_addr(ha, dev)
1076 DBG_PRINT( " %s (%d)\n", DbgHwAddr(mclist->dmi_addr), 1076 DBG_PRINT(" %s (%d)\n", DbgHwAddr(ha->addr),
1077 mclist->dmi_addrlen ); 1077 dev->addr_len);
1078 } 1078 }
1079#endif /* DBG */ 1079#endif /* DBG */
1080 1080
@@ -1119,9 +1119,9 @@ void wl_multicast( struct net_device *dev )
1119 lp->ltvRecord.typ = CFG_GROUP_ADDR; 1119 lp->ltvRecord.typ = CFG_GROUP_ADDR;
1120 1120
1121 x = 0; 1121 x = 0;
1122 netdev_for_each_mc_addr(mclist, dev) 1122 netdev_for_each_mc_addr(ha, dev)
1123 memcpy(&(lp->ltvRecord.u.u8[x++ * ETH_ALEN]), 1123 memcpy(&(lp->ltvRecord.u.u8[x++ * ETH_ALEN]),
1124 mclist->dmi_addr, ETH_ALEN); 1124 ha->addr, ETH_ALEN);
1125 DBG_PRINT( "Setting multicast list\n" ); 1125 DBG_PRINT( "Setting multicast list\n" );
1126 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord )); 1126 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1127 } else { 1127 } else {