aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/magic-number.txt2
-rw-r--r--Documentation/networking/LICENSE.qlge328
-rw-r--r--Documentation/networking/phy.txt3
-rw-r--r--Documentation/zh_CN/magic-number.txt2
-rw-r--r--MAINTAINERS12
-rw-r--r--arch/s390/include/asm/qeth.h7
-rw-r--r--drivers/atm/lanai.c2
-rw-r--r--drivers/bcma/sprom.c180
-rw-r--r--drivers/infiniband/core/addr.c14
-rw-r--r--drivers/infiniband/hw/cxgb4/cm.c10
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c8
-rw-r--r--drivers/isdn/hardware/eicon/capi20.h60
-rw-r--r--drivers/isdn/mISDN/l1oip_core.c16
-rw-r--r--drivers/net/bonding/bond_3ad.c2
-rw-r--r--drivers/net/bonding/bond_alb.c12
-rw-r--r--drivers/net/caif/caif_hsi.c145
-rw-r--r--drivers/net/can/Kconfig6
-rw-r--r--drivers/net/can/bfin_can.c36
-rw-r--r--drivers/net/can/dev.c33
-rw-r--r--drivers/net/can/flexcan.c61
-rw-r--r--drivers/net/can/mcp251x.c3
-rw-r--r--drivers/net/can/mscan/mscan.c33
-rw-r--r--drivers/net/can/pch_can.c2
-rw-r--r--drivers/net/can/sja1000/Kconfig1
-rw-r--r--drivers/net/can/sja1000/plx_pci.c22
-rw-r--r--drivers/net/can/sja1000/sja1000.c19
-rw-r--r--drivers/net/can/slcan.c6
-rw-r--r--drivers/net/can/ti_hecc.c32
-rw-r--r--drivers/net/can/usb/ems_usb.c63
-rw-r--r--drivers/net/can/usb/esd_usb2.c27
-rw-r--r--drivers/net/ethernet/3com/3c501.c2
-rw-r--r--drivers/net/ethernet/3com/3c509.c2
-rw-r--r--drivers/net/ethernet/3com/3c515.c10
-rw-r--r--drivers/net/ethernet/3com/3c574_cs.c2
-rw-r--r--drivers/net/ethernet/3com/3c589_cs.c2
-rw-r--r--drivers/net/ethernet/3com/3c59x.c10
-rw-r--r--drivers/net/ethernet/3com/Kconfig2
-rw-r--r--drivers/net/ethernet/3com/typhoon.c5
-rw-r--r--drivers/net/ethernet/8390/ax88796.c2
-rw-r--r--drivers/net/ethernet/8390/axnet_cs.c4
-rw-r--r--drivers/net/ethernet/8390/lib8390.c2
-rw-r--r--drivers/net/ethernet/8390/pcnet_cs.c2
-rw-r--r--drivers/net/ethernet/adaptec/starfire.c13
-rw-r--r--drivers/net/ethernet/adi/bfin_mac.c12
-rw-r--r--drivers/net/ethernet/aeroflex/greth.c1
-rw-r--r--drivers/net/ethernet/alteon/acenic.c5
-rw-r--r--drivers/net/ethernet/amd/7990.c2
-rw-r--r--drivers/net/ethernet/amd/Kconfig2
-rw-r--r--drivers/net/ethernet/amd/a2065.c2
-rw-r--r--drivers/net/ethernet/amd/am79c961a.c4
-rw-r--r--drivers/net/ethernet/amd/am79c961a.h2
-rw-r--r--drivers/net/ethernet/amd/amd8111e.c7
-rw-r--r--drivers/net/ethernet/amd/ariadne.c2
-rw-r--r--drivers/net/ethernet/amd/atarilance.c2
-rw-r--r--drivers/net/ethernet/amd/au1000_eth.c3
-rw-r--r--drivers/net/ethernet/amd/declance.c4
-rw-r--r--drivers/net/ethernet/amd/depca.c2
-rw-r--r--drivers/net/ethernet/amd/ni65.c6
-rw-r--r--drivers/net/ethernet/amd/nmclan_cs.c2
-rw-r--r--drivers/net/ethernet/amd/pcnet32.c16
-rw-r--r--drivers/net/ethernet/amd/sun3lance.c2
-rw-r--r--drivers/net/ethernet/amd/sunlance.c4
-rw-r--r--drivers/net/ethernet/apple/bmac.c19
-rw-r--r--drivers/net/ethernet/apple/mace.c9
-rw-r--r--drivers/net/ethernet/apple/macmace.c2
-rw-r--r--drivers/net/ethernet/atheros/atl1c/atl1c_main.c3
-rw-r--r--drivers/net/ethernet/atheros/atl1e/atl1e_main.c1
-rw-r--r--drivers/net/ethernet/broadcom/b44.c1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2.c106
-rw-r--r--drivers/net/ethernet/broadcom/bnx2.h3
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x.h9
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c51
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h17
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c36
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_file_hdr.h2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h55
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c323
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h12
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c3
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h6
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h6
-rw-r--r--drivers/net/ethernet/broadcom/cnic.c42
-rw-r--r--drivers/net/ethernet/broadcom/cnic_defs.h3
-rw-r--r--drivers/net/ethernet/broadcom/cnic_if.h4
-rw-r--r--drivers/net/ethernet/broadcom/sb1250-mac.c2
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c1
-rw-r--r--drivers/net/ethernet/brocade/bna/bfa_defs.h1
-rw-r--r--drivers/net/ethernet/brocade/bna/bnad.c1
-rw-r--r--drivers/net/ethernet/brocade/bna/bnad_debugfs.c21
-rw-r--r--drivers/net/ethernet/brocade/bna/bnad_ethtool.c42
-rw-r--r--drivers/net/ethernet/cadence/at91_ether.c2
-rw-r--r--drivers/net/ethernet/cadence/macb.c6
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c2
-rw-r--r--drivers/net/ethernet/cirrus/cs89x0.c4
-rw-r--r--drivers/net/ethernet/cirrus/ep93xx_eth.c2
-rw-r--r--drivers/net/ethernet/cisco/enic/enic.h4
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_main.c5
-rw-r--r--drivers/net/ethernet/cisco/enic/vnic_dev.c58
-rw-r--r--drivers/net/ethernet/cisco/enic/vnic_rq.c4
-rw-r--r--drivers/net/ethernet/cisco/enic/vnic_wq.c4
-rw-r--r--drivers/net/ethernet/davicom/dm9000.c6
-rw-r--r--drivers/net/ethernet/dec/ewrk3.c4
-rw-r--r--drivers/net/ethernet/dec/tulip/21142.c2
-rw-r--r--drivers/net/ethernet/dec/tulip/de2104x.c6
-rw-r--r--drivers/net/ethernet/dec/tulip/de4x5.c4
-rw-r--r--drivers/net/ethernet/dec/tulip/dmfe.c20
-rw-r--r--drivers/net/ethernet/dec/tulip/eeprom.c2
-rw-r--r--drivers/net/ethernet/dec/tulip/interrupt.c10
-rw-r--r--drivers/net/ethernet/dec/tulip/media.c2
-rw-r--r--drivers/net/ethernet/dec/tulip/pnic.c2
-rw-r--r--drivers/net/ethernet/dec/tulip/pnic2.c2
-rw-r--r--drivers/net/ethernet/dec/tulip/timer.c2
-rw-r--r--drivers/net/ethernet/dec/tulip/tulip.h2
-rw-r--r--drivers/net/ethernet/dec/tulip/tulip_core.c9
-rw-r--r--drivers/net/ethernet/dec/tulip/uli526x.c21
-rw-r--r--drivers/net/ethernet/dec/tulip/winbond-840.c6
-rw-r--r--drivers/net/ethernet/dec/tulip/xircom_cb.c7
-rw-r--r--drivers/net/ethernet/dlink/de600.c2
-rw-r--r--drivers/net/ethernet/dlink/de620.c2
-rw-r--r--drivers/net/ethernet/dlink/sundance.c9
-rw-r--r--drivers/net/ethernet/dnet.c6
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h6
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c73
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h46
-rw-r--r--drivers/net/ethernet/emulex/benet/be_ethtool.c64
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c46
-rw-r--r--drivers/net/ethernet/ethoc.c3
-rw-r--r--drivers/net/ethernet/fealnx.c8
-rw-r--r--drivers/net/ethernet/freescale/fec.c21
-rw-r--r--drivers/net/ethernet/freescale/fec_mpc52xx.c4
-rw-r--r--drivers/net/ethernet/freescale/fec_mpc52xx.h2
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c12
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c2
-rw-r--r--drivers/net/ethernet/freescale/gianfar.h2
-rw-r--r--drivers/net/ethernet/freescale/gianfar_ethtool.c2
-rw-r--r--drivers/net/ethernet/freescale/gianfar_sysfs.c2
-rw-r--r--drivers/net/ethernet/freescale/ucc_geth.c7
-rw-r--r--drivers/net/ethernet/fujitsu/at1700.c2
-rw-r--r--drivers/net/ethernet/fujitsu/eth16i.c2
-rw-r--r--drivers/net/ethernet/fujitsu/fmvj18x_cs.c2
-rw-r--r--drivers/net/ethernet/hp/hp100.c6
-rw-r--r--drivers/net/ethernet/i825xx/3c505.c2
-rw-r--r--drivers/net/ethernet/i825xx/3c507.c2
-rw-r--r--drivers/net/ethernet/i825xx/3c523.c2
-rw-r--r--drivers/net/ethernet/i825xx/3c527.c4
-rw-r--r--drivers/net/ethernet/i825xx/82596.c8
-rw-r--r--drivers/net/ethernet/i825xx/eepro.c2
-rw-r--r--drivers/net/ethernet/i825xx/eexpress.c2
-rw-r--r--drivers/net/ethernet/i825xx/ether1.c2
-rw-r--r--drivers/net/ethernet/i825xx/lp486e.c4
-rw-r--r--drivers/net/ethernet/i825xx/ni52.c2
-rw-r--r--drivers/net/ethernet/i825xx/sun3_82586.c27
-rw-r--r--drivers/net/ethernet/i825xx/znet.c2
-rw-r--r--drivers/net/ethernet/ibm/ehea/ehea.h2
-rw-r--r--drivers/net/ethernet/ibm/ehea/ehea_ethtool.c2
-rw-r--r--drivers/net/ethernet/ibm/ehea/ehea_hw.h2
-rw-r--r--drivers/net/ethernet/ibm/ehea/ehea_main.c3
-rw-r--r--drivers/net/ethernet/ibm/ehea/ehea_phyp.c2
-rw-r--r--drivers/net/ethernet/ibm/ehea/ehea_phyp.h2
-rw-r--r--drivers/net/ethernet/ibm/ehea/ehea_qmr.c2
-rw-r--r--drivers/net/ethernet/ibm/ehea/ehea_qmr.h2
-rw-r--r--drivers/net/ethernet/ibm/emac/core.c8
-rw-r--r--drivers/net/ethernet/ibm/emac/core.h2
-rw-r--r--drivers/net/ethernet/ibm/emac/debug.c2
-rw-r--r--drivers/net/ethernet/ibm/emac/debug.h2
-rw-r--r--drivers/net/ethernet/ibm/emac/emac.h2
-rw-r--r--drivers/net/ethernet/ibm/emac/mal.c2
-rw-r--r--drivers/net/ethernet/ibm/emac/mal.h2
-rw-r--r--drivers/net/ethernet/ibm/emac/phy.c2
-rw-r--r--drivers/net/ethernet/ibm/emac/phy.h2
-rw-r--r--drivers/net/ethernet/ibm/emac/rgmii.c7
-rw-r--r--drivers/net/ethernet/ibm/emac/rgmii.h2
-rw-r--r--drivers/net/ethernet/ibm/emac/tah.c7
-rw-r--r--drivers/net/ethernet/ibm/emac/tah.h2
-rw-r--r--drivers/net/ethernet/ibm/emac/zmii.c7
-rw-r--r--drivers/net/ethernet/ibm/emac/zmii.h2
-rw-r--r--drivers/net/ethernet/ibm/iseries_veth.c4
-rw-r--r--drivers/net/ethernet/icplus/ipg.c4
-rw-r--r--drivers/net/ethernet/intel/e100.c5
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000.h1
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000_hw.h10
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000_main.c228
-rw-r--r--drivers/net/ethernet/intel/e1000e/80003es2lan.c43
-rw-r--r--drivers/net/ethernet/intel/e1000e/82571.c87
-rw-r--r--drivers/net/ethernet/intel/e1000e/Makefile5
-rw-r--r--drivers/net/ethernet/intel/e1000e/defines.h10
-rw-r--r--drivers/net/ethernet/intel/e1000e/e1000.h33
-rw-r--r--drivers/net/ethernet/intel/e1000e/ethtool.c201
-rw-r--r--drivers/net/ethernet/intel/e1000e/hw.h11
-rw-r--r--drivers/net/ethernet/intel/e1000e/ich8lan.c183
-rw-r--r--drivers/net/ethernet/intel/e1000e/mac.c (renamed from drivers/net/ethernet/intel/e1000e/lib.c)1076
-rw-r--r--drivers/net/ethernet/intel/e1000e/manage.c377
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c612
-rw-r--r--drivers/net/ethernet/intel/e1000e/nvm.c647
-rw-r--r--drivers/net/ethernet/intel/e1000e/param.c50
-rw-r--r--drivers/net/ethernet/intel/e1000e/phy.c17
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c4
-rw-r--r--drivers/net/ethernet/intel/igbvf/ethtool.c19
-rw-r--r--drivers/net/ethernet/intel/igbvf/igbvf.h27
-rw-r--r--drivers/net/ethernet/intel/igbvf/netdev.c131
-rw-r--r--drivers/net/ethernet/intel/ixgb/ixgb_main.c4
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c8
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c14
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_type.h1
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c6
-rw-r--r--drivers/net/ethernet/jme.c1
-rw-r--r--drivers/net/ethernet/korina.c6
-rw-r--r--drivers/net/ethernet/lantiq_etop.c6
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c2
-rw-r--r--drivers/net/ethernet/marvell/pxa168_eth.c12
-rw-r--r--drivers/net/ethernet/marvell/skge.c4
-rw-r--r--drivers/net/ethernet/marvell/sky2.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cmd.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c6
-rw-r--r--drivers/net/ethernet/micrel/ks8695net.c8
-rw-r--r--drivers/net/ethernet/micrel/ks8851.c6
-rw-r--r--drivers/net/ethernet/micrel/ks8851.h2
-rw-r--r--drivers/net/ethernet/micrel/ks8851_mll.c8
-rw-r--r--drivers/net/ethernet/micrel/ksz884x.c8
-rw-r--r--drivers/net/ethernet/microchip/enc28j60.c6
-rw-r--r--drivers/net/ethernet/mipsnet.c2
-rw-r--r--drivers/net/ethernet/myricom/myri10ge/myri10ge.c4
-rw-r--r--drivers/net/ethernet/natsemi/ibmlana.c2
-rw-r--r--drivers/net/ethernet/natsemi/natsemi.c5
-rw-r--r--drivers/net/ethernet/natsemi/sonic.c4
-rw-r--r--drivers/net/ethernet/neterion/s2io.c7
-rw-r--r--drivers/net/ethernet/netx-eth.c5
-rw-r--r--drivers/net/ethernet/nuvoton/w90p910_ether.c2
-rw-r--r--drivers/net/ethernet/nvidia/forcedeth.c8
-rw-r--r--drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c11
-rw-r--r--drivers/net/ethernet/packetengines/hamachi.c8
-rw-r--r--drivers/net/ethernet/packetengines/yellowfin.c13
-rw-r--r--drivers/net/ethernet/pasemi/pasemi_mac.c4
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic.h437
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c296
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c109
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h1
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c629
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c17
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c132
-rw-r--r--drivers/net/ethernet/qlogic/qla3xxx.c1
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic.h2
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c14
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c10
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c17
-rw-r--r--drivers/net/ethernet/qlogic/qlge/qlge.h2
-rw-r--r--drivers/net/ethernet/qlogic/qlge/qlge_dbg.c4
-rw-r--r--drivers/net/ethernet/qlogic/qlge/qlge_main.c86
-rw-r--r--drivers/net/ethernet/racal/ni5010.c2
-rw-r--r--drivers/net/ethernet/rdc/r6040.c1
-rw-r--r--drivers/net/ethernet/realtek/8139too.c5
-rw-r--r--drivers/net/ethernet/realtek/Kconfig10
-rw-r--r--drivers/net/ethernet/realtek/atp.c2
-rw-r--r--drivers/net/ethernet/realtek/r8169.c569
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c69
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.h1
-rw-r--r--drivers/net/ethernet/s6gmac.c15
-rw-r--r--drivers/net/ethernet/seeq/ether3.c2
-rw-r--r--drivers/net/ethernet/seeq/seeq8005.c2
-rw-r--r--drivers/net/ethernet/seeq/sgiseeq.c1
-rw-r--r--drivers/net/ethernet/sfc/Kconfig13
-rw-r--r--drivers/net/ethernet/sfc/Makefile2
-rw-r--r--drivers/net/ethernet/sfc/bitfield.h18
-rw-r--r--drivers/net/ethernet/sfc/efx.c198
-rw-r--r--drivers/net/ethernet/sfc/efx.h10
-rw-r--r--drivers/net/ethernet/sfc/ethtool.c138
-rw-r--r--drivers/net/ethernet/sfc/falcon.c42
-rw-r--r--drivers/net/ethernet/sfc/falcon_boards.c12
-rw-r--r--drivers/net/ethernet/sfc/falcon_xmac.c15
-rw-r--r--drivers/net/ethernet/sfc/mac.h21
-rw-r--r--drivers/net/ethernet/sfc/mcdi.c115
-rw-r--r--drivers/net/ethernet/sfc/mcdi.h34
-rw-r--r--drivers/net/ethernet/sfc/mcdi_mac.c61
-rw-r--r--drivers/net/ethernet/sfc/mcdi_mon.c415
-rw-r--r--drivers/net/ethernet/sfc/mcdi_pcol.h3542
-rw-r--r--drivers/net/ethernet/sfc/mcdi_phy.c36
-rw-r--r--drivers/net/ethernet/sfc/mdio_10g.c2
-rw-r--r--drivers/net/ethernet/sfc/mtd.c13
-rw-r--r--drivers/net/ethernet/sfc/net_driver.h189
-rw-r--r--drivers/net/ethernet/sfc/nic.c69
-rw-r--r--drivers/net/ethernet/sfc/nic.h20
-rw-r--r--drivers/net/ethernet/sfc/qt202x_phy.c6
-rw-r--r--drivers/net/ethernet/sfc/rx.c119
-rw-r--r--drivers/net/ethernet/sfc/selftest.c110
-rw-r--r--drivers/net/ethernet/sfc/selftest.h1
-rw-r--r--drivers/net/ethernet/sfc/siena.c33
-rw-r--r--drivers/net/ethernet/sfc/spi.h2
-rw-r--r--drivers/net/ethernet/sfc/tenxpress.c2
-rw-r--r--drivers/net/ethernet/sfc/tx.c4
-rw-r--r--drivers/net/ethernet/sfc/txc43128_phy.c2
-rw-r--r--drivers/net/ethernet/sis/sis190.c2
-rw-r--r--drivers/net/ethernet/sis/sis900.c7
-rw-r--r--drivers/net/ethernet/smsc/epic100.c11
-rw-r--r--drivers/net/ethernet/smsc/smc911x.c3
-rw-r--r--drivers/net/ethernet/smsc/smc9194.c2
-rw-r--r--drivers/net/ethernet/smsc/smc91c92_cs.c2
-rw-r--r--drivers/net/ethernet/smsc/smc91x.c3
-rw-r--r--drivers/net/ethernet/smsc/smsc911x.c1
-rw-r--r--drivers/net/ethernet/smsc/smsc9420.c6
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c9
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c2
-rw-r--r--drivers/net/ethernet/sun/cassini.c4
-rw-r--r--drivers/net/ethernet/sun/niu.c4
-rw-r--r--drivers/net/ethernet/sun/sunbmac.c2
-rw-r--r--drivers/net/ethernet/sun/sungem.c1
-rw-r--r--drivers/net/ethernet/sun/sunhme.c2
-rw-r--r--drivers/net/ethernet/sun/sunqe.c2
-rw-r--r--drivers/net/ethernet/sun/sunvnet.c13
-rw-r--r--drivers/net/ethernet/tehuti/tehuti.c8
-rw-r--r--drivers/net/ethernet/ti/cpmac.c5
-rw-r--r--drivers/net/ethernet/ti/davinci_emac.c4
-rw-r--r--drivers/net/ethernet/ti/tlan.c1
-rw-r--r--drivers/net/ethernet/tile/tilepro.c4
-rw-r--r--drivers/net/ethernet/toshiba/ps3_gelic_wireless.c5
-rw-r--r--drivers/net/ethernet/toshiba/tc35815.c7
-rw-r--r--drivers/net/ethernet/tundra/tsi108_eth.c4
-rw-r--r--drivers/net/ethernet/via/via-rhine.c3
-rw-r--r--drivers/net/ethernet/via/via-velocity.c6
-rw-r--r--drivers/net/ethernet/xilinx/Kconfig8
-rw-r--r--drivers/net/ethernet/xilinx/Makefile2
-rw-r--r--drivers/net/ethernet/xilinx/ll_temac_main.c5
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet.h508
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_main.c1680
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c238
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_emaclite.c6
-rw-r--r--drivers/net/ethernet/xircom/xirc2ps_cs.c3
-rw-r--r--drivers/net/hamradio/baycom_epp.c2
-rw-r--r--drivers/net/hamradio/baycom_par.c2
-rw-r--r--drivers/net/hamradio/yam.c1
-rw-r--r--drivers/net/hippi/rrunner.c8
-rw-r--r--drivers/net/hyperv/netvsc_drv.c7
-rw-r--r--drivers/net/hyperv/rndis_filter.c60
-rw-r--r--drivers/net/irda/donauboe.c2
-rw-r--r--drivers/net/netconsole.c8
-rw-r--r--drivers/net/plip/plip.c4
-rw-r--r--drivers/net/ppp/pptp.c4
-rw-r--r--drivers/net/rionet.c2
-rw-r--r--drivers/net/slip/slip.c4
-rw-r--r--drivers/net/tokenring/3c359.c4
-rw-r--r--drivers/net/tokenring/madgemc.c1
-rw-r--r--drivers/net/tokenring/tms380tr.c179
-rw-r--r--drivers/net/usb/Kconfig22
-rw-r--r--drivers/net/usb/Makefile1
-rw-r--r--drivers/net/usb/pegasus.c4
-rw-r--r--drivers/net/usb/qmi_wwan.c228
-rw-r--r--drivers/net/usb/rtl8150.c4
-rw-r--r--drivers/net/usb/usbnet.c4
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c44
-rw-r--r--drivers/net/wan/c101.c4
-rw-r--r--drivers/net/wan/dscc4.c8
-rw-r--r--drivers/net/wan/lmc/lmc_main.c1
-rw-r--r--drivers/net/wan/n2.c4
-rw-r--r--drivers/net/wan/pc300too.c1
-rw-r--r--drivers/net/wan/pci200syn.c1
-rw-r--r--drivers/net/wan/wanxl.c1
-rw-r--r--drivers/net/wan/x25_asy.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c5
-rw-r--r--drivers/net/wireless/ath/ath5k/mac80211-ops.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c154
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.h3
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_init.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c15
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_hst.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c4
-rw-r--r--drivers/net/wireless/ath/carl9170/carl9170.h2
-rw-r--r--drivers/net/wireless/ath/carl9170/fw.c33
-rw-r--r--drivers/net/wireless/ath/carl9170/mac.c35
-rw-r--r--drivers/net/wireless/ath/carl9170/main.c18
-rw-r--r--drivers/net/wireless/ath/carl9170/phy.c36
-rw-r--r--drivers/net/wireless/ath/carl9170/tx.c2
-rw-r--r--drivers/net/wireless/atmel.c5
-rw-r--r--drivers/net/wireless/b43/b43.h12
-rw-r--r--drivers/net/wireless/b43/main.c67
-rw-r--r--drivers/net/wireless/b43/phy_n.c532
-rw-r--r--drivers/net/wireless/b43/phy_n.h1
-rw-r--r--drivers/net/wireless/b43/tables_nphy.c76
-rw-r--r--drivers/net/wireless/b43/tables_nphy.h14
-rw-r--r--drivers/net/wireless/brcm80211/Makefile2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c3
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd.h4
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c17
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h20
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c10
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c216
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c6
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h36
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/aiutils.c4
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/ampdu.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/dma.c8
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c24
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h2
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/main.c194
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/main.h6
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c5
-rw-r--r--drivers/net/wireless/brcm80211/brcmutil/utils.c26
-rw-r--r--drivers/net/wireless/brcm80211/include/brcmu_utils.h15
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c18
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2100.c5
-rw-r--r--drivers/net/wireless/ipw2x00/libipw_module.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-2000.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-hw.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rx.c30
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rxon.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-sta.c13
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tt.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tt.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c103
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-bus.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-cfg.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-csr.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-devtrace.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-devtrace.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-fh.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-io.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-io.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-mac80211.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-pci.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-prph.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c23
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-shared.h8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-testmode.c64
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-testmode.h32
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-ucode.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-wifi.h4
-rw-r--r--drivers/net/wireless/libertas/if_cs.c5
-rw-r--r--drivers/net/wireless/libertas/if_usb.c4
-rw-r--r--drivers/net/wireless/libertas_tf/if_usb.c4
-rw-r--r--drivers/net/wireless/mwifiex/11n_aggr.c3
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c37
-rw-r--r--drivers/net/wireless/mwifiex/cmdevt.c3
-rw-r--r--drivers/net/wireless/mwifiex/decl.h6
-rw-r--r--drivers/net/wireless/mwifiex/init.c5
-rw-r--r--drivers/net/wireless/mwifiex/main.c25
-rw-r--r--drivers/net/wireless/mwifiex/main.h4
-rw-r--r--drivers/net/wireless/mwifiex/pcie.c4
-rw-r--r--drivers/net/wireless/mwifiex/scan.c8
-rw-r--r--drivers/net/wireless/mwifiex/sdio.c4
-rw-r--r--drivers/net/wireless/mwifiex/sta_rx.c6
-rw-r--r--drivers/net/wireless/mwifiex/sta_tx.c3
-rw-r--r--drivers/net/wireless/mwifiex/txrx.c6
-rw-r--r--drivers/net/wireless/mwifiex/util.c3
-rw-r--r--drivers/net/wireless/mwifiex/wmm.c5
-rw-r--r--drivers/net/wireless/mwifiex/wmm.h4
-rw-r--r--drivers/net/wireless/mwl8k.c2
-rw-r--r--drivers/net/wireless/orinoco/main.c6
-rw-r--r--drivers/net/wireless/orinoco/orinoco_usb.c5
-rw-r--r--drivers/net/wireless/p54/main.c3
-rw-r--r--drivers/net/wireless/prism54/islpci_mgt.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c23
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c4
-rw-r--r--drivers/net/wireless/rtlwifi/Kconfig5
-rw-r--r--drivers/net/wireless/rtlwifi/base.c67
-rw-r--r--drivers/net/wireless/rtlwifi/base.h2
-rw-r--r--drivers/net/wireless/rtlwifi/cam.c85
-rw-r--r--drivers/net/wireless/rtlwifi/cam.h2
-rw-r--r--drivers/net/wireless/rtlwifi/core.c174
-rw-r--r--drivers/net/wireless/rtlwifi/core.h6
-rw-r--r--drivers/net/wireless/rtlwifi/debug.c4
-rw-r--r--drivers/net/wireless/rtlwifi/debug.h121
-rw-r--r--drivers/net/wireless/rtlwifi/efuse.c63
-rw-r--r--drivers/net/wireless/rtlwifi/efuse.h2
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c243
-rw-r--r--drivers/net/wireless/rtlwifi/pci.h3
-rw-r--r--drivers/net/wireless/rtlwifi/ps.c36
-rw-r--r--drivers/net/wireless/rtlwifi/ps.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rc.c4
-rw-r--r--drivers/net/wireless/rtlwifi/rc.h2
-rw-r--r--drivers/net/wireless/rtlwifi/regd.c14
-rw-r--r--drivers/net/wireless/rtlwifi/regd.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c191
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c99
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/main.c4
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c213
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/def.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/dm.c26
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/dm.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/hw.c279
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/hw.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/led.c18
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/led.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/phy.c110
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/phy.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/reg.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/rf.c85
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/rf.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/sw.c37
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/sw.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/table.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/table.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/trx.c25
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/trx.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/def.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/dm.c26
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/dm.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/hw.c464
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/hw.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/led.c17
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/led.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/mac.c133
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/mac.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/phy.c123
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/phy.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/reg.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/rf.c73
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/rf.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/sw.c34
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/sw.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/table.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/table.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/trx.c44
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/trx.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/def.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/dm.c241
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/dm.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/fw.c137
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/fw.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/hw.c193
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/hw.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/led.c16
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/led.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/phy.c684
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/phy.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/reg.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/rf.c97
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/rf.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/sw.c57
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/sw.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/table.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/table.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/trx.c28
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/trx.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/def.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/dm.c32
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/dm.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/fw.c70
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/fw.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/hw.c262
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/hw.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/led.c22
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/led.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/phy.c208
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/phy.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/reg.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/rf.c64
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/rf.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/sw.c87
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/sw.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/table.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/table.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/trx.c20
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/trx.h2
-rw-r--r--drivers/net/wireless/rtlwifi/usb.c92
-rw-r--r--drivers/net/wireless/rtlwifi/usb.h3
-rw-r--r--drivers/net/wireless/rtlwifi/wifi.h8
-rw-r--r--drivers/net/wireless/wl1251/main.c7
-rw-r--r--drivers/net/wireless/wl12xx/main.c5
-rw-r--r--drivers/net/xen-netback/netback.c4
-rw-r--r--drivers/net/xen-netfront.c62
-rw-r--r--drivers/nfc/nfcwilink.c305
-rw-r--r--drivers/s390/net/qeth_core.h1
-rw-r--r--drivers/s390/net/qeth_core_main.c100
-rw-r--r--drivers/s390/net/qeth_core_mpc.h13
-rw-r--r--drivers/s390/net/qeth_l2_main.c3
-rw-r--r--drivers/s390/net/qeth_l3_main.c38
-rw-r--r--drivers/ssb/pci.c40
-rw-r--r--include/linux/can/dev.h2
-rw-r--r--include/linux/in.h1
-rw-r--r--include/linux/in6.h1
-rw-r--r--include/linux/ipv6.h1
-rw-r--r--include/linux/netlink.h18
-rw-r--r--include/linux/nfc.h7
-rw-r--r--include/linux/nl80211.h8
-rw-r--r--include/linux/pkt_sched.h21
-rw-r--r--include/linux/snmp.h1
-rw-r--r--include/linux/ssb/ssb.h8
-rw-r--r--include/linux/ssb/ssb_regs.h34
-rw-r--r--include/linux/tcp.h5
-rw-r--r--include/net/addrconf.h1
-rw-r--r--include/net/caif/caif_hsi.h1
-rw-r--r--include/net/cfg80211.h6
-rw-r--r--include/net/genetlink.h31
-rw-r--r--include/net/inet_sock.h2
-rw-r--r--include/net/iucv/af_iucv.h2
-rw-r--r--include/net/mac80211.h44
-rw-r--r--include/net/ndisc.h1
-rw-r--r--include/net/netlink.h35
-rw-r--r--include/net/nfc/nci.h53
-rw-r--r--include/net/nfc/nci_core.h26
-rw-r--r--include/net/nfc/nfc.h9
-rw-r--r--include/net/tcp.h66
-rw-r--r--net/atm/clip.c17
-rw-r--r--net/caif/caif_dev.c2
-rw-r--r--net/caif/caif_socket.c113
-rw-r--r--net/caif/chnl_net.c15
-rw-r--r--net/core/dev.c94
-rw-r--r--net/core/neighbour.c90
-rw-r--r--net/core/netpoll.c71
-rw-r--r--net/decnet/dn_neigh.c24
-rw-r--r--net/decnet/dn_route.c3
-rw-r--r--net/ipv4/ip_gre.c19
-rw-r--r--net/ipv4/ip_sockglue.c33
-rw-r--r--net/ipv4/ipip.c3
-rw-r--r--net/ipv4/ping.c3
-rw-r--r--net/ipv4/proc.c1
-rw-r--r--net/ipv4/raw.c3
-rw-r--r--net/ipv4/route.c5
-rw-r--r--net/ipv4/tcp_ipv4.c296
-rw-r--r--net/ipv4/tcp_minisocks.c12
-rw-r--r--net/ipv4/tcp_output.c4
-rw-r--r--net/ipv4/udp.c3
-rw-r--r--net/ipv6/anycast.c29
-rw-r--r--net/ipv6/icmp.c4
-rw-r--r--net/ipv6/ip6_fib.c19
-rw-r--r--net/ipv6/ip6_output.c10
-rw-r--r--net/ipv6/ipv6_sockglue.c34
-rw-r--r--net/ipv6/ndisc.c30
-rw-r--r--net/ipv6/raw.c2
-rw-r--r--net/ipv6/reassembly.c7
-rw-r--r--net/ipv6/route.c15
-rw-r--r--net/ipv6/sit.c20
-rw-r--r--net/ipv6/tcp_ipv6.c227
-rw-r--r--net/ipv6/udp.c3
-rw-r--r--net/ipv6/xfrm6_output.c2
-rw-r--r--net/iucv/af_iucv.c202
-rw-r--r--net/mac80211/cfg.c46
-rw-r--r--net/mac80211/chan.c28
-rw-r--r--net/mac80211/debugfs.c4
-rw-r--r--net/mac80211/debugfs_netdev.c35
-rw-r--r--net/mac80211/debugfs_sta.c5
-rw-r--r--net/mac80211/ibss.c94
-rw-r--r--net/mac80211/ieee80211_i.h3
-rw-r--r--net/mac80211/iface.c13
-rw-r--r--net/mac80211/main.c3
-rw-r--r--net/mac80211/mesh_hwmp.c2
-rw-r--r--net/mac80211/mesh_plink.c6
-rw-r--r--net/mac80211/mlme.c25
-rw-r--r--net/mac80211/rate.c151
-rw-r--r--net/mac80211/rate.h4
-rw-r--r--net/mac80211/rx.c11
-rw-r--r--net/mac80211/sta_info.c84
-rw-r--r--net/mac80211/sta_info.h17
-rw-r--r--net/mac80211/status.c6
-rw-r--r--net/mac80211/tx.c5
-rw-r--r--net/mac80211/util.c21
-rw-r--r--net/mac80211/work.c5
-rw-r--r--net/netlink/af_netlink.c18
-rw-r--r--net/netlink/genetlink.c31
-rw-r--r--net/nfc/core.c5
-rw-r--r--net/nfc/nci/core.c118
-rw-r--r--net/nfc/nci/data.c4
-rw-r--r--net/nfc/nci/ntf.c337
-rw-r--r--net/nfc/nci/rsp.c28
-rw-r--r--net/nfc/netlink.c6
-rw-r--r--net/nfc/rawsock.c12
-rw-r--r--net/sched/Kconfig26
-rw-r--r--net/sched/Makefile1
-rw-r--r--net/sched/sch_plug.c233
-rw-r--r--net/tipc/bcast.c324
-rw-r--r--net/tipc/bcast.h2
-rw-r--r--net/tipc/link.c148
-rw-r--r--net/tipc/name_distr.c4
-rw-r--r--net/tipc/node.c14
-rw-r--r--net/tipc/node.h18
-rw-r--r--net/tipc/port.c5
-rw-r--r--net/wireless/mesh.c1
-rw-r--r--net/wireless/nl80211.c74
-rw-r--r--net/wireless/reg.c19
713 files changed, 18506 insertions, 10991 deletions
diff --git a/Documentation/magic-number.txt b/Documentation/magic-number.txt
index abf481f780ec..82761a31d64d 100644
--- a/Documentation/magic-number.txt
+++ b/Documentation/magic-number.txt
@@ -89,7 +89,7 @@ TTY_DRIVER_MAGIC 0x5402 tty_driver include/linux/tty_driver.h
89MGSLPC_MAGIC 0x5402 mgslpc_info drivers/char/pcmcia/synclink_cs.c 89MGSLPC_MAGIC 0x5402 mgslpc_info drivers/char/pcmcia/synclink_cs.c
90TTY_LDISC_MAGIC 0x5403 tty_ldisc include/linux/tty_ldisc.h 90TTY_LDISC_MAGIC 0x5403 tty_ldisc include/linux/tty_ldisc.h
91USB_SERIAL_MAGIC 0x6702 usb_serial drivers/usb/serial/usb-serial.h 91USB_SERIAL_MAGIC 0x6702 usb_serial drivers/usb/serial/usb-serial.h
92FULL_DUPLEX_MAGIC 0x6969 drivers/net/tulip/de2104x.c 92FULL_DUPLEX_MAGIC 0x6969 drivers/net/ethernet/dec/tulip/de2104x.c
93USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth drivers/usb/class/bluetty.c 93USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth drivers/usb/class/bluetty.c
94RFCOMM_TTY_MAGIC 0x6d02 net/bluetooth/rfcomm/tty.c 94RFCOMM_TTY_MAGIC 0x6d02 net/bluetooth/rfcomm/tty.c
95USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port drivers/usb/serial/usb-serial.h 95USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port drivers/usb/serial/usb-serial.h
diff --git a/Documentation/networking/LICENSE.qlge b/Documentation/networking/LICENSE.qlge
index 123b6edd7f18..ce64e4d15b21 100644
--- a/Documentation/networking/LICENSE.qlge
+++ b/Documentation/networking/LICENSE.qlge
@@ -1,46 +1,288 @@
1Copyright (c) 2003-2008 QLogic Corporation 1Copyright (c) 2003-2011 QLogic Corporation
2QLogic Linux Networking HBA Driver 2QLogic Linux qlge NIC Driver
3 3
4This program includes a device driver for Linux 2.6 that may be
5distributed with QLogic hardware specific firmware binary file.
6You may modify and redistribute the device driver code under the 4You may modify and redistribute the device driver code under the
7GNU General Public License as published by the Free Software 5GNU General Public License (a copy of which is attached hereto as
8Foundation (version 2 or a later version). 6Exhibit A) published by the Free Software Foundation (version 2).
9
10You may redistribute the hardware specific firmware binary file
11under the following terms:
12
13 1. Redistribution of source code (only if applicable),
14 must retain the above copyright notice, this list of
15 conditions and the following disclaimer.
16
17 2. Redistribution in binary form must reproduce the above
18 copyright notice, this list of conditions and the
19 following disclaimer in the documentation and/or other
20 materials provided with the distribution.
21
22 3. The name of QLogic Corporation may not be used to
23 endorse or promote products derived from this software
24 without specific prior written permission
25
26REGARDLESS OF WHAT LICENSING MECHANISM IS USED OR APPLICABLE,
27THIS PROGRAM IS PROVIDED BY QLOGIC CORPORATION "AS IS'' AND ANY
28EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
30PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR
31BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
33TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
35ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38POSSIBILITY OF SUCH DAMAGE.
39
40USER ACKNOWLEDGES AND AGREES THAT USE OF THIS PROGRAM WILL NOT
41CREATE OR GIVE GROUNDS FOR A LICENSE BY IMPLICATION, ESTOPPEL, OR
42OTHERWISE IN ANY INTELLECTUAL PROPERTY RIGHTS (PATENT, COPYRIGHT,
43TRADE SECRET, MASK WORK, OR OTHER PROPRIETARY RIGHT) EMBODIED IN
44ANY OTHER QLOGIC HARDWARE OR SOFTWARE EITHER SOLELY OR IN
45COMBINATION WITH THIS PROGRAM.
46 7
8
9EXHIBIT A
10
11 GNU GENERAL PUBLIC LICENSE
12 Version 2, June 1991
13
14 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 Everyone is permitted to copy and distribute verbatim copies
17 of this license document, but changing it is not allowed.
18
19 Preamble
20
21 The licenses for most software are designed to take away your
22freedom to share and change it. By contrast, the GNU General Public
23License is intended to guarantee your freedom to share and change free
24software--to make sure the software is free for all its users. This
25General Public License applies to most of the Free Software
26Foundation's software and to any other program whose authors commit to
27using it. (Some other Free Software Foundation software is covered by
28the GNU Lesser General Public License instead.) You can apply it to
29your programs, too.
30
31 When we speak of free software, we are referring to freedom, not
32price. Our General Public Licenses are designed to make sure that you
33have the freedom to distribute copies of free software (and charge for
34this service if you wish), that you receive source code or can get it
35if you want it, that you can change the software or use pieces of it
36in new free programs; and that you know you can do these things.
37
38 To protect your rights, we need to make restrictions that forbid
39anyone to deny you these rights or to ask you to surrender the rights.
40These restrictions translate to certain responsibilities for you if you
41distribute copies of the software, or if you modify it.
42
43 For example, if you distribute copies of such a program, whether
44gratis or for a fee, you must give the recipients all the rights that
45you have. You must make sure that they, too, receive or can get the
46source code. And you must show them these terms so they know their
47rights.
48
49 We protect your rights with two steps: (1) copyright the software, and
50(2) offer you this license which gives you legal permission to copy,
51distribute and/or modify the software.
52
53 Also, for each author's protection and ours, we want to make certain
54that everyone understands that there is no warranty for this free
55software. If the software is modified by someone else and passed on, we
56want its recipients to know that what they have is not the original, so
57that any problems introduced by others will not reflect on the original
58authors' reputations.
59
60 Finally, any free program is threatened constantly by software
61patents. We wish to avoid the danger that redistributors of a free
62program will individually obtain patent licenses, in effect making the
63program proprietary. To prevent this, we have made it clear that any
64patent must be licensed for everyone's free use or not licensed at all.
65
66 The precise terms and conditions for copying, distribution and
67modification follow.
68
69 GNU GENERAL PUBLIC LICENSE
70 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
71
72 0. This License applies to any program or other work which contains
73a notice placed by the copyright holder saying it may be distributed
74under the terms of this General Public License. The "Program", below,
75refers to any such program or work, and a "work based on the Program"
76means either the Program or any derivative work under copyright law:
77that is to say, a work containing the Program or a portion of it,
78either verbatim or with modifications and/or translated into another
79language. (Hereinafter, translation is included without limitation in
80the term "modification".) Each licensee is addressed as "you".
81
82Activities other than copying, distribution and modification are not
83covered by this License; they are outside its scope. The act of
84running the Program is not restricted, and the output from the Program
85is covered only if its contents constitute a work based on the
86Program (independent of having been made by running the Program).
87Whether that is true depends on what the Program does.
88
89 1. You may copy and distribute verbatim copies of the Program's
90source code as you receive it, in any medium, provided that you
91conspicuously and appropriately publish on each copy an appropriate
92copyright notice and disclaimer of warranty; keep intact all the
93notices that refer to this License and to the absence of any warranty;
94and give any other recipients of the Program a copy of this License
95along with the Program.
96
97You may charge a fee for the physical act of transferring a copy, and
98you may at your option offer warranty protection in exchange for a fee.
99
100 2. You may modify your copy or copies of the Program or any portion
101of it, thus forming a work based on the Program, and copy and
102distribute such modifications or work under the terms of Section 1
103above, provided that you also meet all of these conditions:
104
105 a) You must cause the modified files to carry prominent notices
106 stating that you changed the files and the date of any change.
107
108 b) You must cause any work that you distribute or publish, that in
109 whole or in part contains or is derived from the Program or any
110 part thereof, to be licensed as a whole at no charge to all third
111 parties under the terms of this License.
112
113 c) If the modified program normally reads commands interactively
114 when run, you must cause it, when started running for such
115 interactive use in the most ordinary way, to print or display an
116 announcement including an appropriate copyright notice and a
117 notice that there is no warranty (or else, saying that you provide
118 a warranty) and that users may redistribute the program under
119 these conditions, and telling the user how to view a copy of this
120 License. (Exception: if the Program itself is interactive but
121 does not normally print such an announcement, your work based on
122 the Program is not required to print an announcement.)
123
124These requirements apply to the modified work as a whole. If
125identifiable sections of that work are not derived from the Program,
126and can be reasonably considered independent and separate works in
127themselves, then this License, and its terms, do not apply to those
128sections when you distribute them as separate works. But when you
129distribute the same sections as part of a whole which is a work based
130on the Program, the distribution of the whole must be on the terms of
131this License, whose permissions for other licensees extend to the
132entire whole, and thus to each and every part regardless of who wrote it.
133
134Thus, it is not the intent of this section to claim rights or contest
135your rights to work written entirely by you; rather, the intent is to
136exercise the right to control the distribution of derivative or
137collective works based on the Program.
138
139In addition, mere aggregation of another work not based on the Program
140with the Program (or with a work based on the Program) on a volume of
141a storage or distribution medium does not bring the other work under
142the scope of this License.
143
144 3. You may copy and distribute the Program (or a work based on it,
145under Section 2) in object code or executable form under the terms of
146Sections 1 and 2 above provided that you also do one of the following:
147
148 a) Accompany it with the complete corresponding machine-readable
149 source code, which must be distributed under the terms of Sections
150 1 and 2 above on a medium customarily used for software interchange; or,
151
152 b) Accompany it with a written offer, valid for at least three
153 years, to give any third party, for a charge no more than your
154 cost of physically performing source distribution, a complete
155 machine-readable copy of the corresponding source code, to be
156 distributed under the terms of Sections 1 and 2 above on a medium
157 customarily used for software interchange; or,
158
159 c) Accompany it with the information you received as to the offer
160 to distribute corresponding source code. (This alternative is
161 allowed only for noncommercial distribution and only if you
162 received the program in object code or executable form with such
163 an offer, in accord with Subsection b above.)
164
165The source code for a work means the preferred form of the work for
166making modifications to it. For an executable work, complete source
167code means all the source code for all modules it contains, plus any
168associated interface definition files, plus the scripts used to
169control compilation and installation of the executable. However, as a
170special exception, the source code distributed need not include
171anything that is normally distributed (in either source or binary
172form) with the major components (compiler, kernel, and so on) of the
173operating system on which the executable runs, unless that component
174itself accompanies the executable.
175
176If distribution of executable or object code is made by offering
177access to copy from a designated place, then offering equivalent
178access to copy the source code from the same place counts as
179distribution of the source code, even though third parties are not
180compelled to copy the source along with the object code.
181
182 4. You may not copy, modify, sublicense, or distribute the Program
183except as expressly provided under this License. Any attempt
184otherwise to copy, modify, sublicense or distribute the Program is
185void, and will automatically terminate your rights under this License.
186However, parties who have received copies, or rights, from you under
187this License will not have their licenses terminated so long as such
188parties remain in full compliance.
189
190 5. You are not required to accept this License, since you have not
191signed it. However, nothing else grants you permission to modify or
192distribute the Program or its derivative works. These actions are
193prohibited by law if you do not accept this License. Therefore, by
194modifying or distributing the Program (or any work based on the
195Program), you indicate your acceptance of this License to do so, and
196all its terms and conditions for copying, distributing or modifying
197the Program or works based on it.
198
199 6. Each time you redistribute the Program (or any work based on the
200Program), the recipient automatically receives a license from the
201original licensor to copy, distribute or modify the Program subject to
202these terms and conditions. You may not impose any further
203restrictions on the recipients' exercise of the rights granted herein.
204You are not responsible for enforcing compliance by third parties to
205this License.
206
207 7. If, as a consequence of a court judgment or allegation of patent
208infringement or for any other reason (not limited to patent issues),
209conditions are imposed on you (whether by court order, agreement or
210otherwise) that contradict the conditions of this License, they do not
211excuse you from the conditions of this License. If you cannot
212distribute so as to satisfy simultaneously your obligations under this
213License and any other pertinent obligations, then as a consequence you
214may not distribute the Program at all. For example, if a patent
215license would not permit royalty-free redistribution of the Program by
216all those who receive copies directly or indirectly through you, then
217the only way you could satisfy both it and this License would be to
218refrain entirely from distribution of the Program.
219
220If any portion of this section is held invalid or unenforceable under
221any particular circumstance, the balance of the section is intended to
222apply and the section as a whole is intended to apply in other
223circumstances.
224
225It is not the purpose of this section to induce you to infringe any
226patents or other property right claims or to contest validity of any
227such claims; this section has the sole purpose of protecting the
228integrity of the free software distribution system, which is
229implemented by public license practices. Many people have made
230generous contributions to the wide range of software distributed
231through that system in reliance on consistent application of that
232system; it is up to the author/donor to decide if he or she is willing
233to distribute software through any other system and a licensee cannot
234impose that choice.
235
236This section is intended to make thoroughly clear what is believed to
237be a consequence of the rest of this License.
238
239 8. If the distribution and/or use of the Program is restricted in
240certain countries either by patents or by copyrighted interfaces, the
241original copyright holder who places the Program under this License
242may add an explicit geographical distribution limitation excluding
243those countries, so that distribution is permitted only in or among
244countries not thus excluded. In such case, this License incorporates
245the limitation as if written in the body of this License.
246
247 9. The Free Software Foundation may publish revised and/or new versions
248of the General Public License from time to time. Such new versions will
249be similar in spirit to the present version, but may differ in detail to
250address new problems or concerns.
251
252Each version is given a distinguishing version number. If the Program
253specifies a version number of this License which applies to it and "any
254later version", you have the option of following the terms and conditions
255either of that version or of any later version published by the Free
256Software Foundation. If the Program does not specify a version number of
257this License, you may choose any version ever published by the Free Software
258Foundation.
259
260 10. If you wish to incorporate parts of the Program into other free
261programs whose distribution conditions are different, write to the author
262to ask for permission. For software which is copyrighted by the Free
263Software Foundation, write to the Free Software Foundation; we sometimes
264make exceptions for this. Our decision will be guided by the two goals
265of preserving the free status of all derivatives of our free software and
266of promoting the sharing and reuse of software generally.
267
268 NO WARRANTY
269
270 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
271FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
272OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
273PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
274OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
275MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
276TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
277PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
278REPAIR OR CORRECTION.
279
280 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
281WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
282REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
283INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
284OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
285TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
286YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
287PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
288POSSIBILITY OF SUCH DAMAGES.
diff --git a/Documentation/networking/phy.txt b/Documentation/networking/phy.txt
index 9eb1ba52013d..95e5f5985a2a 100644
--- a/Documentation/networking/phy.txt
+++ b/Documentation/networking/phy.txt
@@ -62,7 +62,8 @@ The MDIO bus
62 5) The bus must also be declared somewhere as a device, and registered. 62 5) The bus must also be declared somewhere as a device, and registered.
63 63
64 As an example for how one driver implemented an mdio bus driver, see 64 As an example for how one driver implemented an mdio bus driver, see
65 drivers/net/gianfar_mii.c and arch/ppc/syslib/mpc85xx_devices.c 65 drivers/net/ethernet/freescale/fsl_pq_mdio.c and an associated DTS file
66 for one of the users. (e.g. "git grep fsl,.*-mdio arch/powerpc/boot/dts/")
66 67
67Connecting to a PHY 68Connecting to a PHY
68 69
diff --git a/Documentation/zh_CN/magic-number.txt b/Documentation/zh_CN/magic-number.txt
index c278f412dc65..f606ba8598cf 100644
--- a/Documentation/zh_CN/magic-number.txt
+++ b/Documentation/zh_CN/magic-number.txt
@@ -89,7 +89,7 @@ TTY_DRIVER_MAGIC 0x5402 tty_driver include/linux/tty_driver.h
89MGSLPC_MAGIC 0x5402 mgslpc_info drivers/char/pcmcia/synclink_cs.c 89MGSLPC_MAGIC 0x5402 mgslpc_info drivers/char/pcmcia/synclink_cs.c
90TTY_LDISC_MAGIC 0x5403 tty_ldisc include/linux/tty_ldisc.h 90TTY_LDISC_MAGIC 0x5403 tty_ldisc include/linux/tty_ldisc.h
91USB_SERIAL_MAGIC 0x6702 usb_serial drivers/usb/serial/usb-serial.h 91USB_SERIAL_MAGIC 0x6702 usb_serial drivers/usb/serial/usb-serial.h
92FULL_DUPLEX_MAGIC 0x6969 drivers/net/tulip/de2104x.c 92FULL_DUPLEX_MAGIC 0x6969 drivers/net/ethernet/dec/tulip/de2104x.c
93USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth drivers/usb/class/bluetty.c 93USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth drivers/usb/class/bluetty.c
94RFCOMM_TTY_MAGIC 0x6d02 net/bluetooth/rfcomm/tty.c 94RFCOMM_TTY_MAGIC 0x6d02 net/bluetooth/rfcomm/tty.c
95USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port drivers/usb/serial/usb-serial.h 95USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port drivers/usb/serial/usb-serial.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 9a648eb8e213..5f540bb733ce 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1406,7 +1406,7 @@ F: net/ax25/
1406B43 WIRELESS DRIVER 1406B43 WIRELESS DRIVER
1407M: Stefano Brivio <stefano.brivio@polimi.it> 1407M: Stefano Brivio <stefano.brivio@polimi.it>
1408L: linux-wireless@vger.kernel.org 1408L: linux-wireless@vger.kernel.org
1409L: b43-dev@lists.infradead.org (moderated for non-subscribers) 1409L: b43-dev@lists.infradead.org
1410W: http://linuxwireless.org/en/users/Drivers/b43 1410W: http://linuxwireless.org/en/users/Drivers/b43
1411S: Maintained 1411S: Maintained
1412F: drivers/net/wireless/b43/ 1412F: drivers/net/wireless/b43/
@@ -1415,6 +1415,7 @@ B43LEGACY WIRELESS DRIVER
1415M: Larry Finger <Larry.Finger@lwfinger.net> 1415M: Larry Finger <Larry.Finger@lwfinger.net>
1416M: Stefano Brivio <stefano.brivio@polimi.it> 1416M: Stefano Brivio <stefano.brivio@polimi.it>
1417L: linux-wireless@vger.kernel.org 1417L: linux-wireless@vger.kernel.org
1418L: b43-dev@lists.infradead.org
1418W: http://linuxwireless.org/en/users/Drivers/b43 1419W: http://linuxwireless.org/en/users/Drivers/b43
1419S: Maintained 1420S: Maintained
1420F: drivers/net/wireless/b43legacy/ 1421F: drivers/net/wireless/b43legacy/
@@ -1798,7 +1799,8 @@ F: Documentation/zh_CN/
1798CISCO VIC ETHERNET NIC DRIVER 1799CISCO VIC ETHERNET NIC DRIVER
1799M: Christian Benvenuti <benve@cisco.com> 1800M: Christian Benvenuti <benve@cisco.com>
1800M: Roopa Prabhu <roprabhu@cisco.com> 1801M: Roopa Prabhu <roprabhu@cisco.com>
1801M: David Wang <dwang2@cisco.com> 1802M: Neel Patel <neepatel@cisco.com>
1803M: Nishank Trivedi <nistrive@cisco.com>
1802S: Supported 1804S: Supported
1803F: drivers/net/ethernet/cisco/enic/ 1805F: drivers/net/ethernet/cisco/enic/
1804 1806
@@ -7461,6 +7463,12 @@ S: Supported
7461F: Documentation/filesystems/xfs.txt 7463F: Documentation/filesystems/xfs.txt
7462F: fs/xfs/ 7464F: fs/xfs/
7463 7465
7466XILINX AXI ETHERNET DRIVER
7467M: Ariane Keller <ariane.keller@tik.ee.ethz.ch>
7468M: Daniel Borkmann <daniel.borkmann@tik.ee.ethz.ch>
7469S: Maintained
7470F: drivers/net/ethernet/xilinx/xilinx_axienet*
7471
7464XILINX SYSTEMACE DRIVER 7472XILINX SYSTEMACE DRIVER
7465M: Grant Likely <grant.likely@secretlab.ca> 7473M: Grant Likely <grant.likely@secretlab.ca>
7466W: http://www.secretlab.ca/ 7474W: http://www.secretlab.ca/
diff --git a/arch/s390/include/asm/qeth.h b/arch/s390/include/asm/qeth.h
index 90efda0b137d..2c7c898c03e4 100644
--- a/arch/s390/include/asm/qeth.h
+++ b/arch/s390/include/asm/qeth.h
@@ -20,6 +20,7 @@
20#define SIOC_QETH_ARP_FLUSH_CACHE (SIOCDEVPRIVATE + 4) 20#define SIOC_QETH_ARP_FLUSH_CACHE (SIOCDEVPRIVATE + 4)
21#define SIOC_QETH_ADP_SET_SNMP_CONTROL (SIOCDEVPRIVATE + 5) 21#define SIOC_QETH_ADP_SET_SNMP_CONTROL (SIOCDEVPRIVATE + 5)
22#define SIOC_QETH_GET_CARD_TYPE (SIOCDEVPRIVATE + 6) 22#define SIOC_QETH_GET_CARD_TYPE (SIOCDEVPRIVATE + 6)
23#define SIOC_QETH_QUERY_OAT (SIOCDEVPRIVATE + 7)
23 24
24struct qeth_arp_cache_entry { 25struct qeth_arp_cache_entry {
25 __u8 macaddr[6]; 26 __u8 macaddr[6];
@@ -107,4 +108,10 @@ struct qeth_arp_query_user_data {
107 char *entries; 108 char *entries;
108} __attribute__((packed)); 109} __attribute__((packed));
109 110
111struct qeth_query_oat_data {
112 __u32 command;
113 __u32 buffer_len;
114 __u32 response_len;
115 __u64 ptr;
116};
110#endif /* __ASM_S390_QETH_IOCTL_H__ */ 117#endif /* __ASM_S390_QETH_IOCTL_H__ */
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index f5569699f31c..68c758871812 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -1572,7 +1572,7 @@ static inline void host_vcc_unbind(struct lanai_dev *lanai,
1572 1572
1573static void lanai_reset(struct lanai_dev *lanai) 1573static void lanai_reset(struct lanai_dev *lanai)
1574{ 1574{
1575 printk(KERN_CRIT DEV_LABEL "(itf %d): *NOT* reseting - not " 1575 printk(KERN_CRIT DEV_LABEL "(itf %d): *NOT* resetting - not "
1576 "implemented\n", lanai->number); 1576 "implemented\n", lanai->number);
1577 /* TODO */ 1577 /* TODO */
1578 /* The following is just a hack until we write the real 1578 /* The following is just a hack until we write the real
diff --git a/drivers/bcma/sprom.c b/drivers/bcma/sprom.c
index 6f230fb087c5..e35134f724f6 100644
--- a/drivers/bcma/sprom.c
+++ b/drivers/bcma/sprom.c
@@ -14,8 +14,6 @@
14#include <linux/dma-mapping.h> 14#include <linux/dma-mapping.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16 16
17#define SPOFF(offset) ((offset) / sizeof(u16))
18
19/************************************************** 17/**************************************************
20 * R/W ops. 18 * R/W ops.
21 **************************************************/ 19 **************************************************/
@@ -124,10 +122,21 @@ static int bcma_sprom_valid(const u16 *sprom)
124 * SPROM extraction. 122 * SPROM extraction.
125 **************************************************/ 123 **************************************************/
126 124
125#define SPOFF(offset) ((offset) / sizeof(u16))
126
127#define SPEX(_field, _offset, _mask, _shift) \
128 bus->sprom._field = ((sprom[SPOFF(_offset)] & (_mask)) >> (_shift))
129
127static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom) 130static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
128{ 131{
129 u16 v; 132 u16 v, o;
130 int i; 133 int i;
134 u16 pwr_info_offset[] = {
135 SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1,
136 SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3
137 };
138 BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
139 ARRAY_SIZE(bus->sprom.core_pwr_info));
131 140
132 bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & 141 bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] &
133 SSB_SPROM_REVISION_REV; 142 SSB_SPROM_REVISION_REV;
@@ -137,72 +146,104 @@ static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
137 *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v); 146 *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v);
138 } 147 }
139 148
140 bus->sprom.board_rev = sprom[SPOFF(SSB_SPROM8_BOARDREV)]; 149 SPEX(board_rev, SSB_SPROM8_BOARDREV, ~0, 0);
141 150
142 bus->sprom.txpid2g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] & 151 SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G0,
143 SSB_SPROM4_TXPID2G0) >> SSB_SPROM4_TXPID2G0_SHIFT; 152 SSB_SPROM4_TXPID2G0_SHIFT);
144 bus->sprom.txpid2g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID2G01)] & 153 SPEX(txpid2g[1], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G1,
145 SSB_SPROM4_TXPID2G1) >> SSB_SPROM4_TXPID2G1_SHIFT; 154 SSB_SPROM4_TXPID2G1_SHIFT);
146 bus->sprom.txpid2g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] & 155 SPEX(txpid2g[2], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G2,
147 SSB_SPROM4_TXPID2G2) >> SSB_SPROM4_TXPID2G2_SHIFT; 156 SSB_SPROM4_TXPID2G2_SHIFT);
148 bus->sprom.txpid2g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID2G23)] & 157 SPEX(txpid2g[3], SSB_SPROM4_TXPID2G23, SSB_SPROM4_TXPID2G3,
149 SSB_SPROM4_TXPID2G3) >> SSB_SPROM4_TXPID2G3_SHIFT; 158 SSB_SPROM4_TXPID2G3_SHIFT);
150 159
151 bus->sprom.txpid5gl[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] & 160 SPEX(txpid5gl[0], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL0,
152 SSB_SPROM4_TXPID5GL0) >> SSB_SPROM4_TXPID5GL0_SHIFT; 161 SSB_SPROM4_TXPID5GL0_SHIFT);
153 bus->sprom.txpid5gl[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL01)] & 162 SPEX(txpid5gl[1], SSB_SPROM4_TXPID5GL01, SSB_SPROM4_TXPID5GL1,
154 SSB_SPROM4_TXPID5GL1) >> SSB_SPROM4_TXPID5GL1_SHIFT; 163 SSB_SPROM4_TXPID5GL1_SHIFT);
155 bus->sprom.txpid5gl[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] & 164 SPEX(txpid5gl[2], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL2,
156 SSB_SPROM4_TXPID5GL2) >> SSB_SPROM4_TXPID5GL2_SHIFT; 165 SSB_SPROM4_TXPID5GL2_SHIFT);
157 bus->sprom.txpid5gl[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GL23)] & 166 SPEX(txpid5gl[3], SSB_SPROM4_TXPID5GL23, SSB_SPROM4_TXPID5GL3,
158 SSB_SPROM4_TXPID5GL3) >> SSB_SPROM4_TXPID5GL3_SHIFT; 167 SSB_SPROM4_TXPID5GL3_SHIFT);
159 168
160 bus->sprom.txpid5g[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] & 169 SPEX(txpid5g[0], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G0,
161 SSB_SPROM4_TXPID5G0) >> SSB_SPROM4_TXPID5G0_SHIFT; 170 SSB_SPROM4_TXPID5G0_SHIFT);
162 bus->sprom.txpid5g[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5G01)] & 171 SPEX(txpid5g[1], SSB_SPROM4_TXPID5G01, SSB_SPROM4_TXPID5G1,
163 SSB_SPROM4_TXPID5G1) >> SSB_SPROM4_TXPID5G1_SHIFT; 172 SSB_SPROM4_TXPID5G1_SHIFT);
164 bus->sprom.txpid5g[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] & 173 SPEX(txpid5g[2], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G2,
165 SSB_SPROM4_TXPID5G2) >> SSB_SPROM4_TXPID5G2_SHIFT; 174 SSB_SPROM4_TXPID5G2_SHIFT);
166 bus->sprom.txpid5g[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5G23)] & 175 SPEX(txpid5g[3], SSB_SPROM4_TXPID5G23, SSB_SPROM4_TXPID5G3,
167 SSB_SPROM4_TXPID5G3) >> SSB_SPROM4_TXPID5G3_SHIFT; 176 SSB_SPROM4_TXPID5G3_SHIFT);
168 177
169 bus->sprom.txpid5gh[0] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] & 178 SPEX(txpid5gh[0], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH0,
170 SSB_SPROM4_TXPID5GH0) >> SSB_SPROM4_TXPID5GH0_SHIFT; 179 SSB_SPROM4_TXPID5GH0_SHIFT);
171 bus->sprom.txpid5gh[1] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH01)] & 180 SPEX(txpid5gh[1], SSB_SPROM4_TXPID5GH01, SSB_SPROM4_TXPID5GH1,
172 SSB_SPROM4_TXPID5GH1) >> SSB_SPROM4_TXPID5GH1_SHIFT; 181 SSB_SPROM4_TXPID5GH1_SHIFT);
173 bus->sprom.txpid5gh[2] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] & 182 SPEX(txpid5gh[2], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH2,
174 SSB_SPROM4_TXPID5GH2) >> SSB_SPROM4_TXPID5GH2_SHIFT; 183 SSB_SPROM4_TXPID5GH2_SHIFT);
175 bus->sprom.txpid5gh[3] = (sprom[SPOFF(SSB_SPROM4_TXPID5GH23)] & 184 SPEX(txpid5gh[3], SSB_SPROM4_TXPID5GH23, SSB_SPROM4_TXPID5GH3,
176 SSB_SPROM4_TXPID5GH3) >> SSB_SPROM4_TXPID5GH3_SHIFT; 185 SSB_SPROM4_TXPID5GH3_SHIFT);
177 186
178 bus->sprom.boardflags_lo = sprom[SPOFF(SSB_SPROM8_BFLLO)]; 187 SPEX(boardflags_lo, SSB_SPROM8_BFLLO, ~0, 0);
179 bus->sprom.boardflags_hi = sprom[SPOFF(SSB_SPROM8_BFLHI)]; 188 SPEX(boardflags_hi, SSB_SPROM8_BFLHI, ~0, 0);
180 bus->sprom.boardflags2_lo = sprom[SPOFF(SSB_SPROM8_BFL2LO)]; 189 SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, ~0, 0);
181 bus->sprom.boardflags2_hi = sprom[SPOFF(SSB_SPROM8_BFL2HI)]; 190 SPEX(boardflags2_hi, SSB_SPROM8_BFL2HI, ~0, 0);
182 191
183 bus->sprom.country_code = sprom[SPOFF(SSB_SPROM8_CCODE)]; 192 SPEX(country_code, SSB_SPROM8_CCODE, ~0, 0);
184 193
185 bus->sprom.fem.ghz2.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & 194 /* Extract cores power info info */
186 SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT; 195 for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
187 bus->sprom.fem.ghz2.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & 196 o = pwr_info_offset[i];
188 SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT; 197 SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
189 bus->sprom.fem.ghz2.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & 198 SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT);
190 SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT; 199 SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
191 bus->sprom.fem.ghz2.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & 200 SSB_SPROM8_2G_MAXP, 0);
192 SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT; 201
193 bus->sprom.fem.ghz2.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM2G)] & 202 SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0);
194 SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT; 203 SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0);
195 204 SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0);
196 bus->sprom.fem.ghz5.tssipos = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & 205
197 SSB_SROM8_FEM_TSSIPOS) >> SSB_SROM8_FEM_TSSIPOS_SHIFT; 206 SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
198 bus->sprom.fem.ghz5.extpa_gain = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & 207 SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT);
199 SSB_SROM8_FEM_EXTPA_GAIN) >> SSB_SROM8_FEM_EXTPA_GAIN_SHIFT; 208 SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
200 bus->sprom.fem.ghz5.pdet_range = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & 209 SSB_SPROM8_5G_MAXP, 0);
201 SSB_SROM8_FEM_PDET_RANGE) >> SSB_SROM8_FEM_PDET_RANGE_SHIFT; 210 SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP,
202 bus->sprom.fem.ghz5.tr_iso = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & 211 SSB_SPROM8_5GH_MAXP, 0);
203 SSB_SROM8_FEM_TR_ISO) >> SSB_SROM8_FEM_TR_ISO_SHIFT; 212 SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP,
204 bus->sprom.fem.ghz5.antswlut = (sprom[SPOFF(SSB_SPROM8_FEM5G)] & 213 SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT);
205 SSB_SROM8_FEM_ANTSWLUT) >> SSB_SROM8_FEM_ANTSWLUT_SHIFT; 214
215 SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0);
216 SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0);
217 SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0);
218 SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0);
219 SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0);
220 SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0);
221 SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0);
222 SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0);
223 SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0);
224 }
225
226 SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TSSIPOS,
227 SSB_SROM8_FEM_TSSIPOS_SHIFT);
228 SPEX(fem.ghz2.extpa_gain, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_EXTPA_GAIN,
229 SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
230 SPEX(fem.ghz2.pdet_range, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_PDET_RANGE,
231 SSB_SROM8_FEM_PDET_RANGE_SHIFT);
232 SPEX(fem.ghz2.tr_iso, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_TR_ISO,
233 SSB_SROM8_FEM_TR_ISO_SHIFT);
234 SPEX(fem.ghz2.antswlut, SSB_SPROM8_FEM2G, SSB_SROM8_FEM_ANTSWLUT,
235 SSB_SROM8_FEM_ANTSWLUT_SHIFT);
236
237 SPEX(fem.ghz5.tssipos, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TSSIPOS,
238 SSB_SROM8_FEM_TSSIPOS_SHIFT);
239 SPEX(fem.ghz5.extpa_gain, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_EXTPA_GAIN,
240 SSB_SROM8_FEM_EXTPA_GAIN_SHIFT);
241 SPEX(fem.ghz5.pdet_range, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_PDET_RANGE,
242 SSB_SROM8_FEM_PDET_RANGE_SHIFT);
243 SPEX(fem.ghz5.tr_iso, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_TR_ISO,
244 SSB_SROM8_FEM_TR_ISO_SHIFT);
245 SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_ANTSWLUT,
246 SSB_SROM8_FEM_ANTSWLUT_SHIFT);
206} 247}
207 248
208int bcma_sprom_get(struct bcma_bus *bus) 249int bcma_sprom_get(struct bcma_bus *bus)
@@ -230,6 +271,7 @@ int bcma_sprom_get(struct bcma_bus *bus)
230 * TODO: understand this condition and use it */ 271 * TODO: understand this condition and use it */
231 offset = (bus->chipinfo.id == 0x4331) ? BCMA_CC_SPROM : 272 offset = (bus->chipinfo.id == 0x4331) ? BCMA_CC_SPROM :
232 BCMA_CC_SPROM_PCIE6; 273 BCMA_CC_SPROM_PCIE6;
274 pr_debug("SPROM offset 0x%x\n", offset);
233 bcma_sprom_read(bus, offset, sprom); 275 bcma_sprom_read(bus, offset, sprom);
234 276
235 if (bus->chipinfo.id == 0x4331) 277 if (bus->chipinfo.id == 0x4331)
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 1612cfd50f39..6ef660c1332f 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -178,22 +178,26 @@ static void queue_req(struct addr_req *req)
178 mutex_unlock(&lock); 178 mutex_unlock(&lock);
179} 179}
180 180
181static int dst_fetch_ha(struct dst_entry *dst, struct rdma_dev_addr *addr) 181static int dst_fetch_ha(struct dst_entry *dst, struct rdma_dev_addr *dev_addr, void *daddr)
182{ 182{
183 struct neighbour *n; 183 struct neighbour *n;
184 int ret; 184 int ret;
185 185
186 n = dst_neigh_lookup(dst, daddr);
187
186 rcu_read_lock(); 188 rcu_read_lock();
187 n = dst_get_neighbour_noref(dst);
188 if (!n || !(n->nud_state & NUD_VALID)) { 189 if (!n || !(n->nud_state & NUD_VALID)) {
189 if (n) 190 if (n)
190 neigh_event_send(n, NULL); 191 neigh_event_send(n, NULL);
191 ret = -ENODATA; 192 ret = -ENODATA;
192 } else { 193 } else {
193 ret = rdma_copy_addr(addr, dst->dev, n->ha); 194 ret = rdma_copy_addr(dev_addr, dst->dev, n->ha);
194 } 195 }
195 rcu_read_unlock(); 196 rcu_read_unlock();
196 197
198 if (n)
199 neigh_release(n);
200
197 return ret; 201 return ret;
198} 202}
199 203
@@ -232,7 +236,7 @@ static int addr4_resolve(struct sockaddr_in *src_in,
232 goto put; 236 goto put;
233 } 237 }
234 238
235 ret = dst_fetch_ha(&rt->dst, addr); 239 ret = dst_fetch_ha(&rt->dst, addr, &fl4.daddr);
236put: 240put:
237 ip_rt_put(rt); 241 ip_rt_put(rt);
238out: 242out:
@@ -280,7 +284,7 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
280 goto put; 284 goto put;
281 } 285 }
282 286
283 ret = dst_fetch_ha(dst, addr); 287 ret = dst_fetch_ha(dst, addr, &fl6.daddr);
284put: 288put:
285 dst_release(dst); 289 dst_release(dst);
286 return ret; 290 return ret;
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 0668bb3472d0..0cf61554f176 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -1562,11 +1562,11 @@ static int import_ep(struct c4iw_ep *ep, __be32 peer_ip, struct dst_entry *dst,
1562 struct neighbour *n; 1562 struct neighbour *n;
1563 int err, step; 1563 int err, step;
1564 1564
1565 rcu_read_lock(); 1565 n = dst_neigh_lookup(dst, &peer_ip);
1566 n = dst_get_neighbour_noref(dst);
1567 err = -ENODEV;
1568 if (!n) 1566 if (!n)
1569 goto out; 1567 return -ENODEV;
1568
1569 rcu_read_lock();
1570 err = -ENOMEM; 1570 err = -ENOMEM;
1571 if (n->dev->flags & IFF_LOOPBACK) { 1571 if (n->dev->flags & IFF_LOOPBACK) {
1572 struct net_device *pdev; 1572 struct net_device *pdev;
@@ -1614,6 +1614,8 @@ static int import_ep(struct c4iw_ep *ep, __be32 peer_ip, struct dst_entry *dst,
1614out: 1614out:
1615 rcu_read_unlock(); 1615 rcu_read_unlock();
1616 1616
1617 neigh_release(n);
1618
1617 return err; 1619 return err;
1618} 1620}
1619 1621
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index a4972abedef1..c5e4cb2d3223 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -1351,8 +1351,9 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpi
1351 else 1351 else
1352 netdev = nesvnic->netdev; 1352 netdev = nesvnic->netdev;
1353 1353
1354 neigh = dst_neigh_lookup(&rt->dst, &dst_ip);
1355
1354 rcu_read_lock(); 1356 rcu_read_lock();
1355 neigh = dst_get_neighbour_noref(&rt->dst);
1356 if (neigh) { 1357 if (neigh) {
1357 if (neigh->nud_state & NUD_VALID) { 1358 if (neigh->nud_state & NUD_VALID) {
1358 nes_debug(NES_DBG_CM, "Neighbor MAC address for 0x%08X" 1359 nes_debug(NES_DBG_CM, "Neighbor MAC address for 0x%08X"
@@ -1379,9 +1380,12 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpi
1379 neigh_event_send(neigh, NULL); 1380 neigh_event_send(neigh, NULL);
1380 } 1381 }
1381 } 1382 }
1382
1383out: 1383out:
1384 rcu_read_unlock(); 1384 rcu_read_unlock();
1385
1386 if (neigh)
1387 neigh_release(neigh);
1388
1385 ip_rt_put(rt); 1389 ip_rt_put(rt);
1386 return rc; 1390 return rc;
1387} 1391}
diff --git a/drivers/isdn/hardware/eicon/capi20.h b/drivers/isdn/hardware/eicon/capi20.h
index 7ebcccda74d8..27ecd61888de 100644
--- a/drivers/isdn/hardware/eicon/capi20.h
+++ b/drivers/isdn/hardware/eicon/capi20.h
@@ -117,7 +117,7 @@ typedef struct api_profile_s {
117/*------------------------------------------------------------------*/ 117/*------------------------------------------------------------------*/
118 /* ALERT-REQUEST */ 118 /* ALERT-REQUEST */
119typedef struct { 119typedef struct {
120 byte structs[1]; /* Additional Info */ 120 byte structs[0]; /* Additional Info */
121} _ALT_REQP; 121} _ALT_REQP;
122 /* ALERT-CONFIRM */ 122 /* ALERT-CONFIRM */
123typedef struct { 123typedef struct {
@@ -126,7 +126,7 @@ typedef struct {
126 /* CONNECT-REQUEST */ 126 /* CONNECT-REQUEST */
127typedef struct { 127typedef struct {
128 word CIP_Value; 128 word CIP_Value;
129 byte structs[1]; /* Called party number, 129 byte structs[0]; /* Called party number,
130 Called party subaddress, 130 Called party subaddress,
131 Calling party number, 131 Calling party number,
132 Calling party subaddress, 132 Calling party subaddress,
@@ -143,7 +143,7 @@ typedef struct {
143 /* CONNECT-INDICATION */ 143 /* CONNECT-INDICATION */
144typedef struct { 144typedef struct {
145 word CIP_Value; 145 word CIP_Value;
146 byte structs[1]; /* Called party number, 146 byte structs[0]; /* Called party number,
147 Called party subaddress, 147 Called party subaddress,
148 Calling party number, 148 Calling party number,
149 Calling party subaddress, 149 Calling party subaddress,
@@ -155,24 +155,24 @@ typedef struct {
155 /* CONNECT-RESPONSE */ 155 /* CONNECT-RESPONSE */
156typedef struct { 156typedef struct {
157 word Accept; 157 word Accept;
158 byte structs[1]; /* B_protocol, 158 byte structs[0]; /* B_protocol,
159 Connected party number, 159 Connected party number,
160 Connected party subaddress, 160 Connected party subaddress,
161 LLC */ 161 LLC */
162} _CON_RESP; 162} _CON_RESP;
163 /* CONNECT-ACTIVE-INDICATION */ 163 /* CONNECT-ACTIVE-INDICATION */
164typedef struct { 164typedef struct {
165 byte structs[1]; /* Connected party number, 165 byte structs[0]; /* Connected party number,
166 Connected party subaddress, 166 Connected party subaddress,
167 LLC */ 167 LLC */
168} _CON_A_INDP; 168} _CON_A_INDP;
169 /* CONNECT-ACTIVE-RESPONSE */ 169 /* CONNECT-ACTIVE-RESPONSE */
170typedef struct { 170typedef struct {
171 byte structs[1]; /* empty */ 171 byte structs[0]; /* empty */
172} _CON_A_RESP; 172} _CON_A_RESP;
173 /* DISCONNECT-REQUEST */ 173 /* DISCONNECT-REQUEST */
174typedef struct { 174typedef struct {
175 byte structs[1]; /* Additional Info */ 175 byte structs[0]; /* Additional Info */
176} _DIS_REQP; 176} _DIS_REQP;
177 /* DISCONNECT-CONFIRM */ 177 /* DISCONNECT-CONFIRM */
178typedef struct { 178typedef struct {
@@ -184,13 +184,13 @@ typedef struct {
184} _DIS_INDP; 184} _DIS_INDP;
185 /* DISCONNECT-RESPONSE */ 185 /* DISCONNECT-RESPONSE */
186typedef struct { 186typedef struct {
187 byte structs[1]; /* empty */ 187 byte structs[0]; /* empty */
188} _DIS_RESP; 188} _DIS_RESP;
189 /* LISTEN-REQUEST */ 189 /* LISTEN-REQUEST */
190typedef struct { 190typedef struct {
191 dword Info_Mask; 191 dword Info_Mask;
192 dword CIP_Mask; 192 dword CIP_Mask;
193 byte structs[1]; /* Calling party number, 193 byte structs[0]; /* Calling party number,
194 Calling party subaddress */ 194 Calling party subaddress */
195} _LIS_REQP; 195} _LIS_REQP;
196 /* LISTEN-CONFIRM */ 196 /* LISTEN-CONFIRM */
@@ -199,7 +199,7 @@ typedef struct {
199} _LIS_CONP; 199} _LIS_CONP;
200 /* INFO-REQUEST */ 200 /* INFO-REQUEST */
201typedef struct { 201typedef struct {
202 byte structs[1]; /* Called party number, 202 byte structs[0]; /* Called party number,
203 Additional Info */ 203 Additional Info */
204} _INF_REQP; 204} _INF_REQP;
205 /* INFO-CONFIRM */ 205 /* INFO-CONFIRM */
@@ -209,15 +209,15 @@ typedef struct {
209 /* INFO-INDICATION */ 209 /* INFO-INDICATION */
210typedef struct { 210typedef struct {
211 word Number; 211 word Number;
212 byte structs[1]; /* Info element */ 212 byte structs[0]; /* Info element */
213} _INF_INDP; 213} _INF_INDP;
214 /* INFO-RESPONSE */ 214 /* INFO-RESPONSE */
215typedef struct { 215typedef struct {
216 byte structs[1]; /* empty */ 216 byte structs[0]; /* empty */
217} _INF_RESP; 217} _INF_RESP;
218 /* SELECT-B-REQUEST */ 218 /* SELECT-B-REQUEST */
219typedef struct { 219typedef struct {
220 byte structs[1]; /* B-protocol */ 220 byte structs[0]; /* B-protocol */
221} _SEL_B_REQP; 221} _SEL_B_REQP;
222 /* SELECT-B-CONFIRM */ 222 /* SELECT-B-CONFIRM */
223typedef struct { 223typedef struct {
@@ -226,7 +226,7 @@ typedef struct {
226 /* FACILITY-REQUEST */ 226 /* FACILITY-REQUEST */
227typedef struct { 227typedef struct {
228 word Selector; 228 word Selector;
229 byte structs[1]; /* Facility parameters */ 229 byte structs[0]; /* Facility parameters */
230} _FAC_REQP; 230} _FAC_REQP;
231 /* FACILITY-CONFIRM STRUCT FOR SUPPLEMENT. SERVICES */ 231 /* FACILITY-CONFIRM STRUCT FOR SUPPLEMENT. SERVICES */
232typedef struct { 232typedef struct {
@@ -240,21 +240,21 @@ typedef struct {
240typedef struct { 240typedef struct {
241 word Info; 241 word Info;
242 word Selector; 242 word Selector;
243 byte structs[1]; /* Facility parameters */ 243 byte structs[0]; /* Facility parameters */
244} _FAC_CONP; 244} _FAC_CONP;
245 /* FACILITY-INDICATION */ 245 /* FACILITY-INDICATION */
246typedef struct { 246typedef struct {
247 word Selector; 247 word Selector;
248 byte structs[1]; /* Facility parameters */ 248 byte structs[0]; /* Facility parameters */
249} _FAC_INDP; 249} _FAC_INDP;
250 /* FACILITY-RESPONSE */ 250 /* FACILITY-RESPONSE */
251typedef struct { 251typedef struct {
252 word Selector; 252 word Selector;
253 byte structs[1]; /* Facility parameters */ 253 byte structs[0]; /* Facility parameters */
254} _FAC_RESP; 254} _FAC_RESP;
255 /* CONNECT-B3-REQUEST */ 255 /* CONNECT-B3-REQUEST */
256typedef struct { 256typedef struct {
257 byte structs[1]; /* NCPI */ 257 byte structs[0]; /* NCPI */
258} _CON_B3_REQP; 258} _CON_B3_REQP;
259 /* CONNECT-B3-CONFIRM */ 259 /* CONNECT-B3-CONFIRM */
260typedef struct { 260typedef struct {
@@ -262,24 +262,24 @@ typedef struct {
262} _CON_B3_CONP; 262} _CON_B3_CONP;
263 /* CONNECT-B3-INDICATION */ 263 /* CONNECT-B3-INDICATION */
264typedef struct { 264typedef struct {
265 byte structs[1]; /* NCPI */ 265 byte structs[0]; /* NCPI */
266} _CON_B3_INDP; 266} _CON_B3_INDP;
267 /* CONNECT-B3-RESPONSE */ 267 /* CONNECT-B3-RESPONSE */
268typedef struct { 268typedef struct {
269 word Accept; 269 word Accept;
270 byte structs[1]; /* NCPI */ 270 byte structs[0]; /* NCPI */
271} _CON_B3_RESP; 271} _CON_B3_RESP;
272 /* CONNECT-B3-ACTIVE-INDICATION */ 272 /* CONNECT-B3-ACTIVE-INDICATION */
273typedef struct { 273typedef struct {
274 byte structs[1]; /* NCPI */ 274 byte structs[0]; /* NCPI */
275} _CON_B3_A_INDP; 275} _CON_B3_A_INDP;
276 /* CONNECT-B3-ACTIVE-RESPONSE */ 276 /* CONNECT-B3-ACTIVE-RESPONSE */
277typedef struct { 277typedef struct {
278 byte structs[1]; /* empty */ 278 byte structs[0]; /* empty */
279} _CON_B3_A_RESP; 279} _CON_B3_A_RESP;
280 /* DISCONNECT-B3-REQUEST */ 280 /* DISCONNECT-B3-REQUEST */
281typedef struct { 281typedef struct {
282 byte structs[1]; /* NCPI */ 282 byte structs[0]; /* NCPI */
283} _DIS_B3_REQP; 283} _DIS_B3_REQP;
284 /* DISCONNECT-B3-CONFIRM */ 284 /* DISCONNECT-B3-CONFIRM */
285typedef struct { 285typedef struct {
@@ -288,11 +288,11 @@ typedef struct {
288 /* DISCONNECT-B3-INDICATION */ 288 /* DISCONNECT-B3-INDICATION */
289typedef struct { 289typedef struct {
290 word Info; 290 word Info;
291 byte structs[1]; /* NCPI */ 291 byte structs[0]; /* NCPI */
292} _DIS_B3_INDP; 292} _DIS_B3_INDP;
293 /* DISCONNECT-B3-RESPONSE */ 293 /* DISCONNECT-B3-RESPONSE */
294typedef struct { 294typedef struct {
295 byte structs[1]; /* empty */ 295 byte structs[0]; /* empty */
296} _DIS_B3_RESP; 296} _DIS_B3_RESP;
297 /* DATA-B3-REQUEST */ 297 /* DATA-B3-REQUEST */
298typedef struct { 298typedef struct {
@@ -335,7 +335,7 @@ typedef struct {
335} _DAT_B3_RESP; 335} _DAT_B3_RESP;
336 /* RESET-B3-REQUEST */ 336 /* RESET-B3-REQUEST */
337typedef struct { 337typedef struct {
338 byte structs[1]; /* NCPI */ 338 byte structs[0]; /* NCPI */
339} _RES_B3_REQP; 339} _RES_B3_REQP;
340 /* RESET-B3-CONFIRM */ 340 /* RESET-B3-CONFIRM */
341typedef struct { 341typedef struct {
@@ -343,20 +343,20 @@ typedef struct {
343} _RES_B3_CONP; 343} _RES_B3_CONP;
344 /* RESET-B3-INDICATION */ 344 /* RESET-B3-INDICATION */
345typedef struct { 345typedef struct {
346 byte structs[1]; /* NCPI */ 346 byte structs[0]; /* NCPI */
347} _RES_B3_INDP; 347} _RES_B3_INDP;
348 /* RESET-B3-RESPONSE */ 348 /* RESET-B3-RESPONSE */
349typedef struct { 349typedef struct {
350 byte structs[1]; /* empty */ 350 byte structs[0]; /* empty */
351} _RES_B3_RESP; 351} _RES_B3_RESP;
352 /* CONNECT-B3-T90-ACTIVE-INDICATION */ 352 /* CONNECT-B3-T90-ACTIVE-INDICATION */
353typedef struct { 353typedef struct {
354 byte structs[1]; /* NCPI */ 354 byte structs[0]; /* NCPI */
355} _CON_B3_T90_A_INDP; 355} _CON_B3_T90_A_INDP;
356 /* CONNECT-B3-T90-ACTIVE-RESPONSE */ 356 /* CONNECT-B3-T90-ACTIVE-RESPONSE */
357typedef struct { 357typedef struct {
358 word Reject; 358 word Reject;
359 byte structs[1]; /* NCPI */ 359 byte structs[0]; /* NCPI */
360} _CON_B3_T90_A_RESP; 360} _CON_B3_T90_A_RESP;
361/*------------------------------------------------------------------*/ 361/*------------------------------------------------------------------*/
362/* message structure */ 362/* message structure */
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
index 22f8ec8b9247..04f115a9c43e 100644
--- a/drivers/isdn/mISDN/l1oip_core.c
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -1112,7 +1112,7 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb)
1112 struct l1oip *hc = bch->hw; 1112 struct l1oip *hc = bch->hw;
1113 int ret = -EINVAL; 1113 int ret = -EINVAL;
1114 struct mISDNhead *hh = mISDN_HEAD_P(skb); 1114 struct mISDNhead *hh = mISDN_HEAD_P(skb);
1115 int l, ll, i; 1115 int l, ll;
1116 unsigned char *p; 1116 unsigned char *p;
1117 1117
1118 switch (hh->prim) { 1118 switch (hh->prim) {
@@ -1128,13 +1128,8 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb)
1128 break; 1128 break;
1129 } 1129 }
1130 /* check for AIS / ulaw-silence */ 1130 /* check for AIS / ulaw-silence */
1131 p = skb->data;
1132 l = skb->len; 1131 l = skb->len;
1133 for (i = 0; i < l; i++) { 1132 if (!memchr_inv(skb->data, 0xff, l)) {
1134 if (*p++ != 0xff)
1135 break;
1136 }
1137 if (i == l) {
1138 if (debug & DEBUG_L1OIP_MSG) 1133 if (debug & DEBUG_L1OIP_MSG)
1139 printk(KERN_DEBUG "%s: got AIS, not sending, " 1134 printk(KERN_DEBUG "%s: got AIS, not sending, "
1140 "but counting\n", __func__); 1135 "but counting\n", __func__);
@@ -1144,13 +1139,8 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb)
1144 return 0; 1139 return 0;
1145 } 1140 }
1146 /* check for silence */ 1141 /* check for silence */
1147 p = skb->data;
1148 l = skb->len; 1142 l = skb->len;
1149 for (i = 0; i < l; i++) { 1143 if (!memchr_inv(skb->data, 0x2a, l)) {
1150 if (*p++ != 0x2a)
1151 break;
1152 }
1153 if (i == l) {
1154 if (debug & DEBUG_L1OIP_MSG) 1144 if (debug & DEBUG_L1OIP_MSG)
1155 printk(KERN_DEBUG "%s: got silence, not sending" 1145 printk(KERN_DEBUG "%s: got silence, not sending"
1156 ", but counting\n", __func__); 1146 ", but counting\n", __func__);
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 0ae0d7c54ccf..793b00138275 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -660,7 +660,7 @@ static void __attach_bond_to_agg(struct port *port)
660static void __detach_bond_from_agg(struct port *port) 660static void __detach_bond_from_agg(struct port *port)
661{ 661{
662 port = NULL; /* just to satisfy the compiler */ 662 port = NULL; /* just to satisfy the compiler */
663 // This function does nothing sience the parser/multiplexer of the receive 663 // This function does nothing since the parser/multiplexer of the receive
664 // and the parser/multiplexer of the aggregator are already combined 664 // and the parser/multiplexer of the aggregator are already combined
665} 665}
666 666
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index f820b26b9db3..9abfde479316 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -180,11 +180,9 @@ static int tlb_initialize(struct bonding *bond)
180 int i; 180 int i;
181 181
182 new_hashtbl = kzalloc(size, GFP_KERNEL); 182 new_hashtbl = kzalloc(size, GFP_KERNEL);
183 if (!new_hashtbl) { 183 if (!new_hashtbl)
184 pr_err("%s: Error: Failed to allocate TLB hash table\n",
185 bond->dev->name);
186 return -1; 184 return -1;
187 } 185
188 _lock_tx_hashtbl_bh(bond); 186 _lock_tx_hashtbl_bh(bond);
189 187
190 bond_info->tx_hashtbl = new_hashtbl; 188 bond_info->tx_hashtbl = new_hashtbl;
@@ -784,11 +782,9 @@ static int rlb_initialize(struct bonding *bond)
784 int i; 782 int i;
785 783
786 new_hashtbl = kmalloc(size, GFP_KERNEL); 784 new_hashtbl = kmalloc(size, GFP_KERNEL);
787 if (!new_hashtbl) { 785 if (!new_hashtbl)
788 pr_err("%s: Error: Failed to allocate RLB hash table\n",
789 bond->dev->name);
790 return -1; 786 return -1;
791 } 787
792 _lock_rx_hashtbl_bh(bond); 788 _lock_rx_hashtbl_bh(bond);
793 789
794 bond_info->rx_hashtbl = new_hashtbl; 790 bond_info->rx_hashtbl = new_hashtbl;
diff --git a/drivers/net/caif/caif_hsi.c b/drivers/net/caif/caif_hsi.c
index 0a4fc62a381d..c8afd62239e9 100644
--- a/drivers/net/caif/caif_hsi.c
+++ b/drivers/net/caif/caif_hsi.c
@@ -426,6 +426,35 @@ static int cfhsi_rx_desc(struct cfhsi_desc *desc, struct cfhsi *cfhsi)
426 return xfer_sz; 426 return xfer_sz;
427} 427}
428 428
429static int cfhsi_rx_desc_len(struct cfhsi_desc *desc)
430{
431 int xfer_sz = 0;
432 int nfrms = 0;
433 u16 *plen;
434
435 if ((desc->header & ~CFHSI_PIGGY_DESC) ||
436 (desc->offset > CFHSI_MAX_EMB_FRM_SZ)) {
437
438 pr_err("Invalid descriptor. %x %x\n", desc->header,
439 desc->offset);
440 return -EPROTO;
441 }
442
443 /* Calculate transfer length. */
444 plen = desc->cffrm_len;
445 while (nfrms < CFHSI_MAX_PKTS && *plen) {
446 xfer_sz += *plen;
447 plen++;
448 nfrms++;
449 }
450
451 if (xfer_sz % 4) {
452 pr_err("Invalid payload len: %d, ignored.\n", xfer_sz);
453 return -EPROTO;
454 }
455 return xfer_sz;
456}
457
429static int cfhsi_rx_pld(struct cfhsi_desc *desc, struct cfhsi *cfhsi) 458static int cfhsi_rx_pld(struct cfhsi_desc *desc, struct cfhsi *cfhsi)
430{ 459{
431 int rx_sz = 0; 460 int rx_sz = 0;
@@ -517,8 +546,10 @@ static int cfhsi_rx_pld(struct cfhsi_desc *desc, struct cfhsi *cfhsi)
517static void cfhsi_rx_done(struct cfhsi *cfhsi) 546static void cfhsi_rx_done(struct cfhsi *cfhsi)
518{ 547{
519 int res; 548 int res;
520 int desc_pld_len = 0; 549 int desc_pld_len = 0, rx_len, rx_state;
521 struct cfhsi_desc *desc = NULL; 550 struct cfhsi_desc *desc = NULL;
551 u8 *rx_ptr, *rx_buf;
552 struct cfhsi_desc *piggy_desc = NULL;
522 553
523 desc = (struct cfhsi_desc *)cfhsi->rx_buf; 554 desc = (struct cfhsi_desc *)cfhsi->rx_buf;
524 555
@@ -534,65 +565,71 @@ static void cfhsi_rx_done(struct cfhsi *cfhsi)
534 spin_unlock_bh(&cfhsi->lock); 565 spin_unlock_bh(&cfhsi->lock);
535 566
536 if (cfhsi->rx_state.state == CFHSI_RX_STATE_DESC) { 567 if (cfhsi->rx_state.state == CFHSI_RX_STATE_DESC) {
537 desc_pld_len = cfhsi_rx_desc(desc, cfhsi); 568 desc_pld_len = cfhsi_rx_desc_len(desc);
538 if (desc_pld_len == -ENOMEM) 569
539 goto restart; 570 if (desc_pld_len < 0)
540 if (desc_pld_len == -EPROTO)
541 goto out_of_sync; 571 goto out_of_sync;
572
573 rx_buf = cfhsi->rx_buf;
574 rx_len = desc_pld_len;
575 if (desc_pld_len > 0 && (desc->header & CFHSI_PIGGY_DESC))
576 rx_len += CFHSI_DESC_SZ;
577 if (desc_pld_len == 0)
578 rx_buf = cfhsi->rx_flip_buf;
542 } else { 579 } else {
543 int pld_len; 580 rx_buf = cfhsi->rx_flip_buf;
544 581
545 if (!cfhsi->rx_state.piggy_desc) { 582 rx_len = CFHSI_DESC_SZ;
546 pld_len = cfhsi_rx_pld(desc, cfhsi); 583 if (cfhsi->rx_state.pld_len > 0 &&
547 if (pld_len == -ENOMEM) 584 (desc->header & CFHSI_PIGGY_DESC)) {
548 goto restart;
549 if (pld_len == -EPROTO)
550 goto out_of_sync;
551 cfhsi->rx_state.pld_len = pld_len;
552 } else {
553 pld_len = cfhsi->rx_state.pld_len;
554 }
555 585
556 if ((pld_len > 0) && (desc->header & CFHSI_PIGGY_DESC)) {
557 struct cfhsi_desc *piggy_desc;
558 piggy_desc = (struct cfhsi_desc *) 586 piggy_desc = (struct cfhsi_desc *)
559 (desc->emb_frm + CFHSI_MAX_EMB_FRM_SZ + 587 (desc->emb_frm + CFHSI_MAX_EMB_FRM_SZ +
560 pld_len); 588 cfhsi->rx_state.pld_len);
589
561 cfhsi->rx_state.piggy_desc = true; 590 cfhsi->rx_state.piggy_desc = true;
562 591
563 /* Extract piggy-backed descriptor. */ 592 /* Extract payload len from piggy-backed descriptor. */
564 desc_pld_len = cfhsi_rx_desc(piggy_desc, cfhsi); 593 desc_pld_len = cfhsi_rx_desc_len(piggy_desc);
565 if (desc_pld_len == -ENOMEM) 594 if (desc_pld_len < 0)
566 goto restart; 595 goto out_of_sync;
596
597 if (desc_pld_len > 0)
598 rx_len = desc_pld_len;
599
600 if (desc_pld_len > 0 &&
601 (piggy_desc->header & CFHSI_PIGGY_DESC))
602 rx_len += CFHSI_DESC_SZ;
567 603
568 /* 604 /*
569 * Copy needed information from the piggy-backed 605 * Copy needed information from the piggy-backed
570 * descriptor to the descriptor in the start. 606 * descriptor to the descriptor in the start.
571 */ 607 */
572 memcpy((u8 *)desc, (u8 *)piggy_desc, 608 memcpy(rx_buf, (u8 *)piggy_desc,
573 CFHSI_DESC_SHORT_SZ); 609 CFHSI_DESC_SHORT_SZ);
574 610 /* Mark no embedded frame here */
611 piggy_desc->offset = 0;
575 if (desc_pld_len == -EPROTO) 612 if (desc_pld_len == -EPROTO)
576 goto out_of_sync; 613 goto out_of_sync;
577 } 614 }
578 } 615 }
579 616
580 memset(&cfhsi->rx_state, 0, sizeof(cfhsi->rx_state));
581 if (desc_pld_len) { 617 if (desc_pld_len) {
582 cfhsi->rx_state.state = CFHSI_RX_STATE_PAYLOAD; 618 rx_state = CFHSI_RX_STATE_PAYLOAD;
583 cfhsi->rx_ptr = cfhsi->rx_buf + CFHSI_DESC_SZ; 619 rx_ptr = rx_buf + CFHSI_DESC_SZ;
584 cfhsi->rx_len = desc_pld_len;
585 } else { 620 } else {
586 cfhsi->rx_state.state = CFHSI_RX_STATE_DESC; 621 rx_state = CFHSI_RX_STATE_DESC;
587 cfhsi->rx_ptr = cfhsi->rx_buf; 622 rx_ptr = rx_buf;
588 cfhsi->rx_len = CFHSI_DESC_SZ; 623 rx_len = CFHSI_DESC_SZ;
589 } 624 }
590 625
626 /* Initiate next read */
591 if (test_bit(CFHSI_AWAKE, &cfhsi->bits)) { 627 if (test_bit(CFHSI_AWAKE, &cfhsi->bits)) {
592 /* Set up new transfer. */ 628 /* Set up new transfer. */
593 dev_dbg(&cfhsi->ndev->dev, "%s: Start RX.\n", 629 dev_dbg(&cfhsi->ndev->dev, "%s: Start RX.\n",
594 __func__); 630 __func__);
595 res = cfhsi->dev->cfhsi_rx(cfhsi->rx_ptr, cfhsi->rx_len, 631
632 res = cfhsi->dev->cfhsi_rx(rx_ptr, rx_len,
596 cfhsi->dev); 633 cfhsi->dev);
597 if (WARN_ON(res < 0)) { 634 if (WARN_ON(res < 0)) {
598 dev_err(&cfhsi->ndev->dev, "%s: RX error %d.\n", 635 dev_err(&cfhsi->ndev->dev, "%s: RX error %d.\n",
@@ -601,16 +638,32 @@ static void cfhsi_rx_done(struct cfhsi *cfhsi)
601 cfhsi->ndev->stats.rx_dropped++; 638 cfhsi->ndev->stats.rx_dropped++;
602 } 639 }
603 } 640 }
604 return;
605 641
606restart: 642 if (cfhsi->rx_state.state == CFHSI_RX_STATE_DESC) {
607 if (++cfhsi->rx_state.retries > CFHSI_MAX_RX_RETRIES) { 643 /* Extract payload from descriptor */
608 dev_err(&cfhsi->ndev->dev, "%s: No memory available " 644 if (cfhsi_rx_desc(desc, cfhsi) < 0)
609 "in %d iterations.\n", 645 goto out_of_sync;
610 __func__, CFHSI_MAX_RX_RETRIES); 646 } else {
611 BUG(); 647 /* Extract payload */
648 if (cfhsi_rx_pld(desc, cfhsi) < 0)
649 goto out_of_sync;
650 if (piggy_desc) {
651 /* Extract any payload in piggyback descriptor. */
652 if (cfhsi_rx_desc(piggy_desc, cfhsi) < 0)
653 goto out_of_sync;
654 }
612 } 655 }
613 mod_timer(&cfhsi->rx_slowpath_timer, jiffies + 1); 656
657 /* Update state info */
658 memset(&cfhsi->rx_state, 0, sizeof(cfhsi->rx_state));
659 cfhsi->rx_state.state = rx_state;
660 cfhsi->rx_ptr = rx_ptr;
661 cfhsi->rx_len = rx_len;
662 cfhsi->rx_state.pld_len = desc_pld_len;
663 cfhsi->rx_state.piggy_desc = desc->header & CFHSI_PIGGY_DESC;
664
665 if (rx_buf != cfhsi->rx_buf)
666 swap(cfhsi->rx_buf, cfhsi->rx_flip_buf);
614 return; 667 return;
615 668
616out_of_sync: 669out_of_sync:
@@ -1040,6 +1093,12 @@ int cfhsi_probe(struct platform_device *pdev)
1040 goto err_alloc_rx; 1093 goto err_alloc_rx;
1041 } 1094 }
1042 1095
1096 cfhsi->rx_flip_buf = kzalloc(CFHSI_BUF_SZ_RX, GFP_KERNEL);
1097 if (!cfhsi->rx_flip_buf) {
1098 res = -ENODEV;
1099 goto err_alloc_rx_flip;
1100 }
1101
1043 /* Pre-calculate inactivity timeout. */ 1102 /* Pre-calculate inactivity timeout. */
1044 if (inactivity_timeout != -1) { 1103 if (inactivity_timeout != -1) {
1045 cfhsi->inactivity_timeout = 1104 cfhsi->inactivity_timeout =
@@ -1138,6 +1197,8 @@ int cfhsi_probe(struct platform_device *pdev)
1138 err_activate: 1197 err_activate:
1139 destroy_workqueue(cfhsi->wq); 1198 destroy_workqueue(cfhsi->wq);
1140 err_create_wq: 1199 err_create_wq:
1200 kfree(cfhsi->rx_flip_buf);
1201 err_alloc_rx_flip:
1141 kfree(cfhsi->rx_buf); 1202 kfree(cfhsi->rx_buf);
1142 err_alloc_rx: 1203 err_alloc_rx:
1143 kfree(cfhsi->tx_buf); 1204 kfree(cfhsi->tx_buf);
diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
index ab45758c49a4..bb709fd66993 100644
--- a/drivers/net/can/Kconfig
+++ b/drivers/net/can/Kconfig
@@ -103,11 +103,11 @@ config CAN_FLEXCAN
103 Say Y here if you want to support for Freescale FlexCAN. 103 Say Y here if you want to support for Freescale FlexCAN.
104 104
105config PCH_CAN 105config PCH_CAN
106 tristate "PCH CAN" 106 tristate "Intel EG20T PCH CAN controller"
107 depends on CAN_DEV && PCI 107 depends on CAN_DEV && PCI
108 ---help--- 108 ---help---
109 This driver is for PCH CAN of Topcliff which is an IOH for x86 109 This driver is for PCH CAN of Topcliff (Intel EG20T PCH) which
110 embedded processor. 110 is an IOH for x86 embedded processor (Intel Atom E6xx series).
111 This driver can access CAN bus. 111 This driver can access CAN bus.
112 112
113source "drivers/net/can/mscan/Kconfig" 113source "drivers/net/can/mscan/Kconfig"
diff --git a/drivers/net/can/bfin_can.c b/drivers/net/can/bfin_can.c
index 349e0fabb63a..3f88473423e9 100644
--- a/drivers/net/can/bfin_can.c
+++ b/drivers/net/can/bfin_can.c
@@ -82,8 +82,7 @@ static int bfin_can_set_bittiming(struct net_device *dev)
82 bfin_write(&reg->clock, clk); 82 bfin_write(&reg->clock, clk);
83 bfin_write(&reg->timing, timing); 83 bfin_write(&reg->timing, timing);
84 84
85 dev_info(dev->dev.parent, "setting CLOCK=0x%04x TIMING=0x%04x\n", 85 netdev_info(dev, "setting CLOCK=0x%04x TIMING=0x%04x\n", clk, timing);
86 clk, timing);
87 86
88 return 0; 87 return 0;
89} 88}
@@ -108,8 +107,7 @@ static void bfin_can_set_reset_mode(struct net_device *dev)
108 while (!(bfin_read(&reg->control) & CCA)) { 107 while (!(bfin_read(&reg->control) & CCA)) {
109 udelay(10); 108 udelay(10);
110 if (--timeout == 0) { 109 if (--timeout == 0) {
111 dev_err(dev->dev.parent, 110 netdev_err(dev, "fail to enter configuration mode\n");
112 "fail to enter configuration mode\n");
113 BUG(); 111 BUG();
114 } 112 }
115 } 113 }
@@ -165,8 +163,7 @@ static void bfin_can_set_normal_mode(struct net_device *dev)
165 while (bfin_read(&reg->status) & CCA) { 163 while (bfin_read(&reg->status) & CCA) {
166 udelay(10); 164 udelay(10);
167 if (--timeout == 0) { 165 if (--timeout == 0) {
168 dev_err(dev->dev.parent, 166 netdev_err(dev, "fail to leave configuration mode\n");
169 "fail to leave configuration mode\n");
170 BUG(); 167 BUG();
171 } 168 }
172 } 169 }
@@ -224,6 +221,20 @@ static int bfin_can_set_mode(struct net_device *dev, enum can_mode mode)
224 return 0; 221 return 0;
225} 222}
226 223
224static int bfin_can_get_berr_counter(const struct net_device *dev,
225 struct can_berr_counter *bec)
226{
227 struct bfin_can_priv *priv = netdev_priv(dev);
228 struct bfin_can_regs __iomem *reg = priv->membase;
229
230 u16 cec = bfin_read(&reg->cec);
231
232 bec->txerr = cec >> 8;
233 bec->rxerr = cec;
234
235 return 0;
236}
237
227static int bfin_can_start_xmit(struct sk_buff *skb, struct net_device *dev) 238static int bfin_can_start_xmit(struct sk_buff *skb, struct net_device *dev)
228{ 239{
229 struct bfin_can_priv *priv = netdev_priv(dev); 240 struct bfin_can_priv *priv = netdev_priv(dev);
@@ -331,7 +342,7 @@ static int bfin_can_err(struct net_device *dev, u16 isrc, u16 status)
331 342
332 if (isrc & RMLIS) { 343 if (isrc & RMLIS) {
333 /* data overrun interrupt */ 344 /* data overrun interrupt */
334 dev_dbg(dev->dev.parent, "data overrun interrupt\n"); 345 netdev_dbg(dev, "data overrun interrupt\n");
335 cf->can_id |= CAN_ERR_CRTL; 346 cf->can_id |= CAN_ERR_CRTL;
336 cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; 347 cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
337 stats->rx_over_errors++; 348 stats->rx_over_errors++;
@@ -339,7 +350,7 @@ static int bfin_can_err(struct net_device *dev, u16 isrc, u16 status)
339 } 350 }
340 351
341 if (isrc & BOIS) { 352 if (isrc & BOIS) {
342 dev_dbg(dev->dev.parent, "bus-off mode interrupt\n"); 353 netdev_dbg(dev, "bus-off mode interrupt\n");
343 state = CAN_STATE_BUS_OFF; 354 state = CAN_STATE_BUS_OFF;
344 cf->can_id |= CAN_ERR_BUSOFF; 355 cf->can_id |= CAN_ERR_BUSOFF;
345 can_bus_off(dev); 356 can_bus_off(dev);
@@ -347,13 +358,12 @@ static int bfin_can_err(struct net_device *dev, u16 isrc, u16 status)
347 358
348 if (isrc & EPIS) { 359 if (isrc & EPIS) {
349 /* error passive interrupt */ 360 /* error passive interrupt */
350 dev_dbg(dev->dev.parent, "error passive interrupt\n"); 361 netdev_dbg(dev, "error passive interrupt\n");
351 state = CAN_STATE_ERROR_PASSIVE; 362 state = CAN_STATE_ERROR_PASSIVE;
352 } 363 }
353 364
354 if ((isrc & EWTIS) || (isrc & EWRIS)) { 365 if ((isrc & EWTIS) || (isrc & EWRIS)) {
355 dev_dbg(dev->dev.parent, 366 netdev_dbg(dev, "Error Warning Transmit/Receive Interrupt\n");
356 "Error Warning Transmit/Receive Interrupt\n");
357 state = CAN_STATE_ERROR_WARNING; 367 state = CAN_STATE_ERROR_WARNING;
358 } 368 }
359 369
@@ -509,6 +519,7 @@ struct net_device *alloc_bfin_candev(void)
509 priv->can.bittiming_const = &bfin_can_bittiming_const; 519 priv->can.bittiming_const = &bfin_can_bittiming_const;
510 priv->can.do_set_bittiming = bfin_can_set_bittiming; 520 priv->can.do_set_bittiming = bfin_can_set_bittiming;
511 priv->can.do_set_mode = bfin_can_set_mode; 521 priv->can.do_set_mode = bfin_can_set_mode;
522 priv->can.do_get_berr_counter = bfin_can_get_berr_counter;
512 priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES; 523 priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES;
513 524
514 return dev; 525 return dev;
@@ -636,8 +647,7 @@ static int bfin_can_suspend(struct platform_device *pdev, pm_message_t mesg)
636 while (!(bfin_read(&reg->intr) & SMACK)) { 647 while (!(bfin_read(&reg->intr) & SMACK)) {
637 udelay(10); 648 udelay(10);
638 if (--timeout == 0) { 649 if (--timeout == 0) {
639 dev_err(dev->dev.parent, 650 netdev_err(dev, "fail to enter sleep mode\n");
640 "fail to enter sleep mode\n");
641 BUG(); 651 BUG();
642 } 652 }
643 } 653 }
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 120f1ab5a2ce..c5fe3a3db8c9 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -130,13 +130,13 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt)
130 /* Error in one-tenth of a percent */ 130 /* Error in one-tenth of a percent */
131 error = (best_error * 1000) / bt->bitrate; 131 error = (best_error * 1000) / bt->bitrate;
132 if (error > CAN_CALC_MAX_ERROR) { 132 if (error > CAN_CALC_MAX_ERROR) {
133 dev_err(dev->dev.parent, 133 netdev_err(dev,
134 "bitrate error %ld.%ld%% too high\n", 134 "bitrate error %ld.%ld%% too high\n",
135 error / 10, error % 10); 135 error / 10, error % 10);
136 return -EDOM; 136 return -EDOM;
137 } else { 137 } else {
138 dev_warn(dev->dev.parent, "bitrate error %ld.%ld%%\n", 138 netdev_warn(dev, "bitrate error %ld.%ld%%\n",
139 error / 10, error % 10); 139 error / 10, error % 10);
140 } 140 }
141 } 141 }
142 142
@@ -172,7 +172,7 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt)
172#else /* !CONFIG_CAN_CALC_BITTIMING */ 172#else /* !CONFIG_CAN_CALC_BITTIMING */
173static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt) 173static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt)
174{ 174{
175 dev_err(dev->dev.parent, "bit-timing calculation not available\n"); 175 netdev_err(dev, "bit-timing calculation not available\n");
176 return -EINVAL; 176 return -EINVAL;
177} 177}
178#endif /* CONFIG_CAN_CALC_BITTIMING */ 178#endif /* CONFIG_CAN_CALC_BITTIMING */
@@ -313,8 +313,7 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
313 priv->echo_skb[idx] = skb; 313 priv->echo_skb[idx] = skb;
314 } else { 314 } else {
315 /* locking problem with netif_stop_queue() ?? */ 315 /* locking problem with netif_stop_queue() ?? */
316 dev_err(dev->dev.parent, "%s: BUG! echo_skb is occupied!\n", 316 netdev_err(dev, "%s: BUG! echo_skb is occupied!\n", __func__);
317 __func__);
318 kfree_skb(skb); 317 kfree_skb(skb);
319 } 318 }
320} 319}
@@ -327,16 +326,24 @@ EXPORT_SYMBOL_GPL(can_put_echo_skb);
327 * is handled in the device driver. The driver must protect 326 * is handled in the device driver. The driver must protect
328 * access to priv->echo_skb, if necessary. 327 * access to priv->echo_skb, if necessary.
329 */ 328 */
330void can_get_echo_skb(struct net_device *dev, unsigned int idx) 329unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
331{ 330{
332 struct can_priv *priv = netdev_priv(dev); 331 struct can_priv *priv = netdev_priv(dev);
333 332
334 BUG_ON(idx >= priv->echo_skb_max); 333 BUG_ON(idx >= priv->echo_skb_max);
335 334
336 if (priv->echo_skb[idx]) { 335 if (priv->echo_skb[idx]) {
336 struct sk_buff *skb = priv->echo_skb[idx];
337 struct can_frame *cf = (struct can_frame *)skb->data;
338 u8 dlc = cf->can_dlc;
339
337 netif_rx(priv->echo_skb[idx]); 340 netif_rx(priv->echo_skb[idx]);
338 priv->echo_skb[idx] = NULL; 341 priv->echo_skb[idx] = NULL;
342
343 return dlc;
339 } 344 }
345
346 return 0;
340} 347}
341EXPORT_SYMBOL_GPL(can_get_echo_skb); 348EXPORT_SYMBOL_GPL(can_get_echo_skb);
342 349
@@ -392,7 +399,7 @@ void can_restart(unsigned long data)
392 stats->rx_bytes += cf->can_dlc; 399 stats->rx_bytes += cf->can_dlc;
393 400
394restart: 401restart:
395 dev_dbg(dev->dev.parent, "restarted\n"); 402 netdev_dbg(dev, "restarted\n");
396 priv->can_stats.restarts++; 403 priv->can_stats.restarts++;
397 404
398 /* Now restart the device */ 405 /* Now restart the device */
@@ -400,7 +407,7 @@ restart:
400 407
401 netif_carrier_on(dev); 408 netif_carrier_on(dev);
402 if (err) 409 if (err)
403 dev_err(dev->dev.parent, "Error %d during restart", err); 410 netdev_err(dev, "Error %d during restart", err);
404} 411}
405 412
406int can_restart_now(struct net_device *dev) 413int can_restart_now(struct net_device *dev)
@@ -433,7 +440,7 @@ void can_bus_off(struct net_device *dev)
433{ 440{
434 struct can_priv *priv = netdev_priv(dev); 441 struct can_priv *priv = netdev_priv(dev);
435 442
436 dev_dbg(dev->dev.parent, "bus-off\n"); 443 netdev_dbg(dev, "bus-off\n");
437 444
438 netif_carrier_off(dev); 445 netif_carrier_off(dev);
439 priv->can_stats.bus_off++; 446 priv->can_stats.bus_off++;
@@ -545,7 +552,7 @@ int open_candev(struct net_device *dev)
545 struct can_priv *priv = netdev_priv(dev); 552 struct can_priv *priv = netdev_priv(dev);
546 553
547 if (!priv->bittiming.tq && !priv->bittiming.bitrate) { 554 if (!priv->bittiming.tq && !priv->bittiming.bitrate) {
548 dev_err(dev->dev.parent, "bit-timing not yet defined\n"); 555 netdev_err(dev, "bit-timing not yet defined\n");
549 return -EINVAL; 556 return -EINVAL;
550 } 557 }
551 558
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 96d235799ec1..1efb08386c61 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -272,7 +272,6 @@ static int flexcan_get_berr_counter(const struct net_device *dev,
272static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev) 272static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev)
273{ 273{
274 const struct flexcan_priv *priv = netdev_priv(dev); 274 const struct flexcan_priv *priv = netdev_priv(dev);
275 struct net_device_stats *stats = &dev->stats;
276 struct flexcan_regs __iomem *regs = priv->base; 275 struct flexcan_regs __iomem *regs = priv->base;
277 struct can_frame *cf = (struct can_frame *)skb->data; 276 struct can_frame *cf = (struct can_frame *)skb->data;
278 u32 can_id; 277 u32 can_id;
@@ -302,14 +301,11 @@ static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev)
302 flexcan_write(data, &regs->cantxfg[FLEXCAN_TX_BUF_ID].data[1]); 301 flexcan_write(data, &regs->cantxfg[FLEXCAN_TX_BUF_ID].data[1]);
303 } 302 }
304 303
304 can_put_echo_skb(skb, dev, 0);
305
305 flexcan_write(can_id, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_id); 306 flexcan_write(can_id, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_id);
306 flexcan_write(ctrl, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl); 307 flexcan_write(ctrl, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
307 308
308 kfree_skb(skb);
309
310 /* tx_packets is incremented in flexcan_irq */
311 stats->tx_bytes += cf->can_dlc;
312
313 return NETDEV_TX_OK; 309 return NETDEV_TX_OK;
314} 310}
315 311
@@ -322,34 +318,34 @@ static void do_bus_err(struct net_device *dev,
322 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; 318 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
323 319
324 if (reg_esr & FLEXCAN_ESR_BIT1_ERR) { 320 if (reg_esr & FLEXCAN_ESR_BIT1_ERR) {
325 dev_dbg(dev->dev.parent, "BIT1_ERR irq\n"); 321 netdev_dbg(dev, "BIT1_ERR irq\n");
326 cf->data[2] |= CAN_ERR_PROT_BIT1; 322 cf->data[2] |= CAN_ERR_PROT_BIT1;
327 tx_errors = 1; 323 tx_errors = 1;
328 } 324 }
329 if (reg_esr & FLEXCAN_ESR_BIT0_ERR) { 325 if (reg_esr & FLEXCAN_ESR_BIT0_ERR) {
330 dev_dbg(dev->dev.parent, "BIT0_ERR irq\n"); 326 netdev_dbg(dev, "BIT0_ERR irq\n");
331 cf->data[2] |= CAN_ERR_PROT_BIT0; 327 cf->data[2] |= CAN_ERR_PROT_BIT0;
332 tx_errors = 1; 328 tx_errors = 1;
333 } 329 }
334 if (reg_esr & FLEXCAN_ESR_ACK_ERR) { 330 if (reg_esr & FLEXCAN_ESR_ACK_ERR) {
335 dev_dbg(dev->dev.parent, "ACK_ERR irq\n"); 331 netdev_dbg(dev, "ACK_ERR irq\n");
336 cf->can_id |= CAN_ERR_ACK; 332 cf->can_id |= CAN_ERR_ACK;
337 cf->data[3] |= CAN_ERR_PROT_LOC_ACK; 333 cf->data[3] |= CAN_ERR_PROT_LOC_ACK;
338 tx_errors = 1; 334 tx_errors = 1;
339 } 335 }
340 if (reg_esr & FLEXCAN_ESR_CRC_ERR) { 336 if (reg_esr & FLEXCAN_ESR_CRC_ERR) {
341 dev_dbg(dev->dev.parent, "CRC_ERR irq\n"); 337 netdev_dbg(dev, "CRC_ERR irq\n");
342 cf->data[2] |= CAN_ERR_PROT_BIT; 338 cf->data[2] |= CAN_ERR_PROT_BIT;
343 cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ; 339 cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ;
344 rx_errors = 1; 340 rx_errors = 1;
345 } 341 }
346 if (reg_esr & FLEXCAN_ESR_FRM_ERR) { 342 if (reg_esr & FLEXCAN_ESR_FRM_ERR) {
347 dev_dbg(dev->dev.parent, "FRM_ERR irq\n"); 343 netdev_dbg(dev, "FRM_ERR irq\n");
348 cf->data[2] |= CAN_ERR_PROT_FORM; 344 cf->data[2] |= CAN_ERR_PROT_FORM;
349 rx_errors = 1; 345 rx_errors = 1;
350 } 346 }
351 if (reg_esr & FLEXCAN_ESR_STF_ERR) { 347 if (reg_esr & FLEXCAN_ESR_STF_ERR) {
352 dev_dbg(dev->dev.parent, "STF_ERR irq\n"); 348 netdev_dbg(dev, "STF_ERR irq\n");
353 cf->data[2] |= CAN_ERR_PROT_STUFF; 349 cf->data[2] |= CAN_ERR_PROT_STUFF;
354 rx_errors = 1; 350 rx_errors = 1;
355 } 351 }
@@ -396,7 +392,7 @@ static void do_state(struct net_device *dev,
396 */ 392 */
397 if (new_state >= CAN_STATE_ERROR_WARNING && 393 if (new_state >= CAN_STATE_ERROR_WARNING &&
398 new_state <= CAN_STATE_BUS_OFF) { 394 new_state <= CAN_STATE_BUS_OFF) {
399 dev_dbg(dev->dev.parent, "Error Warning IRQ\n"); 395 netdev_dbg(dev, "Error Warning IRQ\n");
400 priv->can.can_stats.error_warning++; 396 priv->can.can_stats.error_warning++;
401 397
402 cf->can_id |= CAN_ERR_CRTL; 398 cf->can_id |= CAN_ERR_CRTL;
@@ -412,7 +408,7 @@ static void do_state(struct net_device *dev,
412 */ 408 */
413 if (new_state >= CAN_STATE_ERROR_PASSIVE && 409 if (new_state >= CAN_STATE_ERROR_PASSIVE &&
414 new_state <= CAN_STATE_BUS_OFF) { 410 new_state <= CAN_STATE_BUS_OFF) {
415 dev_dbg(dev->dev.parent, "Error Passive IRQ\n"); 411 netdev_dbg(dev, "Error Passive IRQ\n");
416 priv->can.can_stats.error_passive++; 412 priv->can.can_stats.error_passive++;
417 413
418 cf->can_id |= CAN_ERR_CRTL; 414 cf->can_id |= CAN_ERR_CRTL;
@@ -422,8 +418,8 @@ static void do_state(struct net_device *dev,
422 } 418 }
423 break; 419 break;
424 case CAN_STATE_BUS_OFF: 420 case CAN_STATE_BUS_OFF:
425 dev_err(dev->dev.parent, 421 netdev_err(dev, "BUG! "
426 "BUG! hardware recovered automatically from BUS_OFF\n"); 422 "hardware recovered automatically from BUS_OFF\n");
427 break; 423 break;
428 default: 424 default:
429 break; 425 break;
@@ -432,7 +428,7 @@ static void do_state(struct net_device *dev,
432 /* process state changes depending on the new state */ 428 /* process state changes depending on the new state */
433 switch (new_state) { 429 switch (new_state) {
434 case CAN_STATE_ERROR_ACTIVE: 430 case CAN_STATE_ERROR_ACTIVE:
435 dev_dbg(dev->dev.parent, "Error Active\n"); 431 netdev_dbg(dev, "Error Active\n");
436 cf->can_id |= CAN_ERR_PROT; 432 cf->can_id |= CAN_ERR_PROT;
437 cf->data[2] = CAN_ERR_PROT_ACTIVE; 433 cf->data[2] = CAN_ERR_PROT_ACTIVE;
438 break; 434 break;
@@ -614,7 +610,7 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
614 610
615 /* transmission complete interrupt */ 611 /* transmission complete interrupt */
616 if (reg_iflag1 & (1 << FLEXCAN_TX_BUF_ID)) { 612 if (reg_iflag1 & (1 << FLEXCAN_TX_BUF_ID)) {
617 /* tx_bytes is incremented in flexcan_start_xmit */ 613 stats->tx_bytes += can_get_echo_skb(dev, 0);
618 stats->tx_packets++; 614 stats->tx_packets++;
619 flexcan_write((1 << FLEXCAN_TX_BUF_ID), &regs->iflag1); 615 flexcan_write((1 << FLEXCAN_TX_BUF_ID), &regs->iflag1);
620 netif_wake_queue(dev); 616 netif_wake_queue(dev);
@@ -653,12 +649,12 @@ static void flexcan_set_bittiming(struct net_device *dev)
653 if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) 649 if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
654 reg |= FLEXCAN_CTRL_SMP; 650 reg |= FLEXCAN_CTRL_SMP;
655 651
656 dev_info(dev->dev.parent, "writing ctrl=0x%08x\n", reg); 652 netdev_info(dev, "writing ctrl=0x%08x\n", reg);
657 flexcan_write(reg, &regs->ctrl); 653 flexcan_write(reg, &regs->ctrl);
658 654
659 /* print chip status */ 655 /* print chip status */
660 dev_dbg(dev->dev.parent, "%s: mcr=0x%08x ctrl=0x%08x\n", __func__, 656 netdev_dbg(dev, "%s: mcr=0x%08x ctrl=0x%08x\n", __func__,
661 flexcan_read(&regs->mcr), flexcan_read(&regs->ctrl)); 657 flexcan_read(&regs->mcr), flexcan_read(&regs->ctrl));
662} 658}
663 659
664/* 660/*
@@ -684,9 +680,8 @@ static int flexcan_chip_start(struct net_device *dev)
684 680
685 reg_mcr = flexcan_read(&regs->mcr); 681 reg_mcr = flexcan_read(&regs->mcr);
686 if (reg_mcr & FLEXCAN_MCR_SOFTRST) { 682 if (reg_mcr & FLEXCAN_MCR_SOFTRST) {
687 dev_err(dev->dev.parent, 683 netdev_err(dev, "Failed to softreset can module (mcr=0x%08x)\n",
688 "Failed to softreset can module (mcr=0x%08x)\n", 684 reg_mcr);
689 reg_mcr);
690 err = -ENODEV; 685 err = -ENODEV;
691 goto out; 686 goto out;
692 } 687 }
@@ -702,13 +697,14 @@ static int flexcan_chip_start(struct net_device *dev)
702 * only supervisor access 697 * only supervisor access
703 * enable warning int 698 * enable warning int
704 * choose format C 699 * choose format C
700 * disable local echo
705 * 701 *
706 */ 702 */
707 reg_mcr = flexcan_read(&regs->mcr); 703 reg_mcr = flexcan_read(&regs->mcr);
708 reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_FEN | FLEXCAN_MCR_HALT | 704 reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_FEN | FLEXCAN_MCR_HALT |
709 FLEXCAN_MCR_SUPV | FLEXCAN_MCR_WRN_EN | 705 FLEXCAN_MCR_SUPV | FLEXCAN_MCR_WRN_EN |
710 FLEXCAN_MCR_IDAM_C; 706 FLEXCAN_MCR_IDAM_C | FLEXCAN_MCR_SRX_DIS;
711 dev_dbg(dev->dev.parent, "%s: writing mcr=0x%08x", __func__, reg_mcr); 707 netdev_dbg(dev, "%s: writing mcr=0x%08x", __func__, reg_mcr);
712 flexcan_write(reg_mcr, &regs->mcr); 708 flexcan_write(reg_mcr, &regs->mcr);
713 709
714 /* 710 /*
@@ -734,7 +730,7 @@ static int flexcan_chip_start(struct net_device *dev)
734 730
735 /* save for later use */ 731 /* save for later use */
736 priv->reg_ctrl_default = reg_ctrl; 732 priv->reg_ctrl_default = reg_ctrl;
737 dev_dbg(dev->dev.parent, "%s: writing ctrl=0x%08x", __func__, reg_ctrl); 733 netdev_dbg(dev, "%s: writing ctrl=0x%08x", __func__, reg_ctrl);
738 flexcan_write(reg_ctrl, &regs->ctrl); 734 flexcan_write(reg_ctrl, &regs->ctrl);
739 735
740 for (i = 0; i < ARRAY_SIZE(regs->cantxfg); i++) { 736 for (i = 0; i < ARRAY_SIZE(regs->cantxfg); i++) {
@@ -766,8 +762,8 @@ static int flexcan_chip_start(struct net_device *dev)
766 flexcan_write(FLEXCAN_IFLAG_DEFAULT, &regs->imask1); 762 flexcan_write(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
767 763
768 /* print chip status */ 764 /* print chip status */
769 dev_dbg(dev->dev.parent, "%s: reading mcr=0x%08x ctrl=0x%08x\n", 765 netdev_dbg(dev, "%s: reading mcr=0x%08x ctrl=0x%08x\n", __func__,
770 __func__, flexcan_read(&regs->mcr), flexcan_read(&regs->ctrl)); 766 flexcan_read(&regs->mcr), flexcan_read(&regs->ctrl));
771 767
772 return 0; 768 return 0;
773 769
@@ -905,8 +901,7 @@ static int __devinit register_flexcandev(struct net_device *dev)
905 */ 901 */
906 reg = flexcan_read(&regs->mcr); 902 reg = flexcan_read(&regs->mcr);
907 if (!(reg & FLEXCAN_MCR_FEN)) { 903 if (!(reg & FLEXCAN_MCR_FEN)) {
908 dev_err(dev->dev.parent, 904 netdev_err(dev, "Could not enable RX FIFO, unsupported core\n");
909 "Could not enable RX FIFO, unsupported core\n");
910 err = -ENODEV; 905 err = -ENODEV;
911 goto out; 906 goto out;
912 } 907 }
@@ -975,7 +970,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
975 goto failed_map; 970 goto failed_map;
976 } 971 }
977 972
978 dev = alloc_candev(sizeof(struct flexcan_priv), 0); 973 dev = alloc_candev(sizeof(struct flexcan_priv), 1);
979 if (!dev) { 974 if (!dev) {
980 err = -ENOMEM; 975 err = -ENOMEM;
981 goto failed_alloc; 976 goto failed_alloc;
@@ -983,7 +978,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
983 978
984 dev->netdev_ops = &flexcan_netdev_ops; 979 dev->netdev_ops = &flexcan_netdev_ops;
985 dev->irq = irq; 980 dev->irq = irq;
986 dev->flags |= IFF_ECHO; /* we support local echo in hardware */ 981 dev->flags |= IFF_ECHO;
987 982
988 priv = netdev_priv(dev); 983 priv = netdev_priv(dev);
989 priv->can.clock.freq = clock_freq; 984 priv->can.clock.freq = clock_freq;
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index 330140ee266d..346785c56a25 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -712,8 +712,7 @@ static void mcp251x_error_skb(struct net_device *net, int can_id, int data1)
712 frame->data[1] = data1; 712 frame->data[1] = data1;
713 netif_rx_ni(skb); 713 netif_rx_ni(skb);
714 } else { 714 } else {
715 dev_err(&net->dev, 715 netdev_err(net, "cannot allocate error skb\n");
716 "cannot allocate error skb\n");
717 } 716 }
718} 717}
719 718
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c
index 1c82dd8b896e..41a2a2dda7ea 100644
--- a/drivers/net/can/mscan/mscan.c
+++ b/drivers/net/can/mscan/mscan.c
@@ -95,9 +95,9 @@ static int mscan_set_mode(struct net_device *dev, u8 mode)
95 * any, at once. 95 * any, at once.
96 */ 96 */
97 if (i >= MSCAN_SET_MODE_RETRIES) 97 if (i >= MSCAN_SET_MODE_RETRIES)
98 dev_dbg(dev->dev.parent, 98 netdev_dbg(dev,
99 "device failed to enter sleep mode. " 99 "device failed to enter sleep mode. "
100 "We proceed anyhow.\n"); 100 "We proceed anyhow.\n");
101 else 101 else
102 priv->can.state = CAN_STATE_SLEEPING; 102 priv->can.state = CAN_STATE_SLEEPING;
103 } 103 }
@@ -213,7 +213,7 @@ static netdev_tx_t mscan_start_xmit(struct sk_buff *skb, struct net_device *dev)
213 switch (hweight8(i)) { 213 switch (hweight8(i)) {
214 case 0: 214 case 0:
215 netif_stop_queue(dev); 215 netif_stop_queue(dev);
216 dev_err(dev->dev.parent, "Tx Ring full when queue awake!\n"); 216 netdev_err(dev, "Tx Ring full when queue awake!\n");
217 return NETDEV_TX_BUSY; 217 return NETDEV_TX_BUSY;
218 case 1: 218 case 1:
219 /* 219 /*
@@ -352,7 +352,7 @@ static void mscan_get_err_frame(struct net_device *dev, struct can_frame *frame,
352 struct net_device_stats *stats = &dev->stats; 352 struct net_device_stats *stats = &dev->stats;
353 enum can_state old_state; 353 enum can_state old_state;
354 354
355 dev_dbg(dev->dev.parent, "error interrupt (canrflg=%#x)\n", canrflg); 355 netdev_dbg(dev, "error interrupt (canrflg=%#x)\n", canrflg);
356 frame->can_id = CAN_ERR_FLAG; 356 frame->can_id = CAN_ERR_FLAG;
357 357
358 if (canrflg & MSCAN_OVRIF) { 358 if (canrflg & MSCAN_OVRIF) {
@@ -427,7 +427,7 @@ static int mscan_rx_poll(struct napi_struct *napi, int quota)
427 skb = alloc_can_skb(dev, &frame); 427 skb = alloc_can_skb(dev, &frame);
428 if (!skb) { 428 if (!skb) {
429 if (printk_ratelimit()) 429 if (printk_ratelimit())
430 dev_notice(dev->dev.parent, "packet dropped\n"); 430 netdev_notice(dev, "packet dropped\n");
431 stats->rx_dropped++; 431 stats->rx_dropped++;
432 out_8(&regs->canrflg, canrflg); 432 out_8(&regs->canrflg, canrflg);
433 continue; 433 continue;
@@ -551,8 +551,7 @@ static int mscan_do_set_bittiming(struct net_device *dev)
551 BTR1_SET_TSEG2(bt->phase_seg2) | 551 BTR1_SET_TSEG2(bt->phase_seg2) |
552 BTR1_SET_SAM(priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)); 552 BTR1_SET_SAM(priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES));
553 553
554 dev_info(dev->dev.parent, "setting BTR0=0x%02x BTR1=0x%02x\n", 554 netdev_info(dev, "setting BTR0=0x%02x BTR1=0x%02x\n", btr0, btr1);
555 btr0, btr1);
556 555
557 out_8(&regs->canbtr0, btr0); 556 out_8(&regs->canbtr0, btr0);
558 out_8(&regs->canbtr1, btr1); 557 out_8(&regs->canbtr1, btr1);
@@ -560,6 +559,18 @@ static int mscan_do_set_bittiming(struct net_device *dev)
560 return 0; 559 return 0;
561} 560}
562 561
562static int mscan_get_berr_counter(const struct net_device *dev,
563 struct can_berr_counter *bec)
564{
565 struct mscan_priv *priv = netdev_priv(dev);
566 struct mscan_regs __iomem *regs = priv->reg_base;
567
568 bec->txerr = in_8(&regs->cantxerr);
569 bec->rxerr = in_8(&regs->canrxerr);
570
571 return 0;
572}
573
563static int mscan_open(struct net_device *dev) 574static int mscan_open(struct net_device *dev)
564{ 575{
565 int ret; 576 int ret;
@@ -575,7 +586,7 @@ static int mscan_open(struct net_device *dev)
575 586
576 ret = request_irq(dev->irq, mscan_isr, 0, dev->name, dev); 587 ret = request_irq(dev->irq, mscan_isr, 0, dev->name, dev);
577 if (ret < 0) { 588 if (ret < 0) {
578 dev_err(dev->dev.parent, "failed to attach interrupt\n"); 589 netdev_err(dev, "failed to attach interrupt\n");
579 goto exit_napi_disable; 590 goto exit_napi_disable;
580 } 591 }
581 592
@@ -639,8 +650,10 @@ int register_mscandev(struct net_device *dev, int mscan_clksrc)
639 else 650 else
640 ctl1 &= ~MSCAN_CLKSRC; 651 ctl1 &= ~MSCAN_CLKSRC;
641 652
642 if (priv->type == MSCAN_TYPE_MPC5121) 653 if (priv->type == MSCAN_TYPE_MPC5121) {
654 priv->can.do_get_berr_counter = mscan_get_berr_counter;
643 ctl1 |= MSCAN_BORM; /* bus-off recovery upon request */ 655 ctl1 |= MSCAN_BORM; /* bus-off recovery upon request */
656 }
644 657
645 ctl1 |= MSCAN_CANE; 658 ctl1 |= MSCAN_CANE;
646 out_8(&regs->canctl1, ctl1); 659 out_8(&regs->canctl1, ctl1);
diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
index 6edc25e0dd15..2bb215e00eb1 100644
--- a/drivers/net/can/pch_can.c
+++ b/drivers/net/can/pch_can.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 1999 - 2010 Intel Corporation. 2 * Copyright (C) 1999 - 2010 Intel Corporation.
3 * Copyright (C) 2010 OKI SEMICONDUCTOR CO., LTD. 3 * Copyright (C) 2010 LAPIS SEMICONDUCTOR CO., LTD.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/can/sja1000/Kconfig b/drivers/net/can/sja1000/Kconfig
index 36e9d594069d..b21523ddff3c 100644
--- a/drivers/net/can/sja1000/Kconfig
+++ b/drivers/net/can/sja1000/Kconfig
@@ -71,6 +71,7 @@ config CAN_PLX_PCI
71 - esd CAN-PCIe/2000 71 - esd CAN-PCIe/2000
72 - Marathon CAN-bus-PCI card (http://www.marathon.ru/) 72 - Marathon CAN-bus-PCI card (http://www.marathon.ru/)
73 - TEWS TECHNOLOGIES TPMC810 card (http://www.tews.com/) 73 - TEWS TECHNOLOGIES TPMC810 card (http://www.tews.com/)
74 - IXXAT Automation PC-I 04/PCI card (http://www.ixxat.com/)
74 75
75config CAN_TSCAN1 76config CAN_TSCAN1
76 tristate "TS-CAN1 PC104 boards" 77 tristate "TS-CAN1 PC104 boards"
diff --git a/drivers/net/can/sja1000/plx_pci.c b/drivers/net/can/sja1000/plx_pci.c
index c7f3d4ea1167..a227586ddd52 100644
--- a/drivers/net/can/sja1000/plx_pci.c
+++ b/drivers/net/can/sja1000/plx_pci.c
@@ -43,7 +43,8 @@ MODULE_SUPPORTED_DEVICE("Adlink PCI-7841/cPCI-7841, "
43 "TEWS TECHNOLOGIES TPMC810, " 43 "TEWS TECHNOLOGIES TPMC810, "
44 "esd CAN-PCI/CPCI/PCI104/200, " 44 "esd CAN-PCI/CPCI/PCI104/200, "
45 "esd CAN-PCI/PMC/266, " 45 "esd CAN-PCI/PMC/266, "
46 "esd CAN-PCIe/2000") 46 "esd CAN-PCIe/2000, "
47 "IXXAT PC-I 04/PCI")
47MODULE_LICENSE("GPL v2"); 48MODULE_LICENSE("GPL v2");
48 49
49#define PLX_PCI_MAX_CHAN 2 50#define PLX_PCI_MAX_CHAN 2
@@ -121,6 +122,10 @@ struct plx_pci_card {
121#define ESD_PCI_SUB_SYS_ID_PCIE2000 0x0200 122#define ESD_PCI_SUB_SYS_ID_PCIE2000 0x0200
122#define ESD_PCI_SUB_SYS_ID_PCI104200 0x0501 123#define ESD_PCI_SUB_SYS_ID_PCI104200 0x0501
123 124
125#define IXXAT_PCI_VENDOR_ID 0x10b5
126#define IXXAT_PCI_DEVICE_ID 0x9050
127#define IXXAT_PCI_SUB_SYS_ID 0x2540
128
124#define MARATHON_PCI_DEVICE_ID 0x2715 129#define MARATHON_PCI_DEVICE_ID 0x2715
125 130
126#define TEWS_PCI_VENDOR_ID 0x1498 131#define TEWS_PCI_VENDOR_ID 0x1498
@@ -193,6 +198,14 @@ static struct plx_pci_card_info plx_pci_card_info_esd2000 __devinitdata = {
193 /* based on PEX8311 */ 198 /* based on PEX8311 */
194}; 199};
195 200
201static struct plx_pci_card_info plx_pci_card_info_ixxat __devinitdata = {
202 "IXXAT PC-I 04/PCI", 2,
203 PLX_PCI_CAN_CLOCK, PLX_PCI_OCR, PLX_PCI_CDR,
204 {0, 0x00, 0x00}, { {2, 0x00, 0x80}, {2, 0x200, 0x80} },
205 &plx_pci_reset_common
206 /* based on PLX9050 */
207};
208
196static struct plx_pci_card_info plx_pci_card_info_marathon __devinitdata = { 209static struct plx_pci_card_info plx_pci_card_info_marathon __devinitdata = {
197 "Marathon CAN-bus-PCI", 2, 210 "Marathon CAN-bus-PCI", 2,
198 PLX_PCI_CAN_CLOCK, PLX_PCI_OCR, PLX_PCI_CDR, 211 PLX_PCI_CAN_CLOCK, PLX_PCI_OCR, PLX_PCI_CDR,
@@ -267,6 +280,13 @@ static DEFINE_PCI_DEVICE_TABLE(plx_pci_tbl) = {
267 (kernel_ulong_t)&plx_pci_card_info_esd2000 280 (kernel_ulong_t)&plx_pci_card_info_esd2000
268 }, 281 },
269 { 282 {
283 /* IXXAT PC-I 04/PCI card */
284 IXXAT_PCI_VENDOR_ID, IXXAT_PCI_DEVICE_ID,
285 PCI_ANY_ID, IXXAT_PCI_SUB_SYS_ID,
286 0, 0,
287 (kernel_ulong_t)&plx_pci_card_info_ixxat
288 },
289 {
270 /* Marathon CAN-bus-PCI card */ 290 /* Marathon CAN-bus-PCI card */
271 PCI_VENDOR_ID_PLX, MARATHON_PCI_DEVICE_ID, 291 PCI_VENDOR_ID_PLX, MARATHON_PCI_DEVICE_ID,
272 PCI_ANY_ID, PCI_ANY_ID, 292 PCI_ANY_ID, PCI_ANY_ID,
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index 04a3f1b756a8..ebbcfcafe29b 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -128,7 +128,7 @@ static void set_reset_mode(struct net_device *dev)
128 status = priv->read_reg(priv, REG_MOD); 128 status = priv->read_reg(priv, REG_MOD);
129 } 129 }
130 130
131 dev_err(dev->dev.parent, "setting SJA1000 into reset mode failed!\n"); 131 netdev_err(dev, "setting SJA1000 into reset mode failed!\n");
132} 132}
133 133
134static void set_normal_mode(struct net_device *dev) 134static void set_normal_mode(struct net_device *dev)
@@ -156,7 +156,7 @@ static void set_normal_mode(struct net_device *dev)
156 status = priv->read_reg(priv, REG_MOD); 156 status = priv->read_reg(priv, REG_MOD);
157 } 157 }
158 158
159 dev_err(dev->dev.parent, "setting SJA1000 into normal mode failed!\n"); 159 netdev_err(dev, "setting SJA1000 into normal mode failed!\n");
160} 160}
161 161
162static void sja1000_start(struct net_device *dev) 162static void sja1000_start(struct net_device *dev)
@@ -209,8 +209,7 @@ static int sja1000_set_bittiming(struct net_device *dev)
209 if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) 209 if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
210 btr1 |= 0x80; 210 btr1 |= 0x80;
211 211
212 dev_info(dev->dev.parent, 212 netdev_info(dev, "setting BTR0=0x%02x BTR1=0x%02x\n", btr0, btr1);
213 "setting BTR0=0x%02x BTR1=0x%02x\n", btr0, btr1);
214 213
215 priv->write_reg(priv, REG_BTR0, btr0); 214 priv->write_reg(priv, REG_BTR0, btr0);
216 priv->write_reg(priv, REG_BTR1, btr1); 215 priv->write_reg(priv, REG_BTR1, btr1);
@@ -378,7 +377,7 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
378 377
379 if (isrc & IRQ_DOI) { 378 if (isrc & IRQ_DOI) {
380 /* data overrun interrupt */ 379 /* data overrun interrupt */
381 dev_dbg(dev->dev.parent, "data overrun interrupt\n"); 380 netdev_dbg(dev, "data overrun interrupt\n");
382 cf->can_id |= CAN_ERR_CRTL; 381 cf->can_id |= CAN_ERR_CRTL;
383 cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; 382 cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
384 stats->rx_over_errors++; 383 stats->rx_over_errors++;
@@ -388,7 +387,7 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
388 387
389 if (isrc & IRQ_EI) { 388 if (isrc & IRQ_EI) {
390 /* error warning interrupt */ 389 /* error warning interrupt */
391 dev_dbg(dev->dev.parent, "error warning interrupt\n"); 390 netdev_dbg(dev, "error warning interrupt\n");
392 391
393 if (status & SR_BS) { 392 if (status & SR_BS) {
394 state = CAN_STATE_BUS_OFF; 393 state = CAN_STATE_BUS_OFF;
@@ -429,7 +428,7 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
429 } 428 }
430 if (isrc & IRQ_EPI) { 429 if (isrc & IRQ_EPI) {
431 /* error passive interrupt */ 430 /* error passive interrupt */
432 dev_dbg(dev->dev.parent, "error passive interrupt\n"); 431 netdev_dbg(dev, "error passive interrupt\n");
433 if (status & SR_ES) 432 if (status & SR_ES)
434 state = CAN_STATE_ERROR_PASSIVE; 433 state = CAN_STATE_ERROR_PASSIVE;
435 else 434 else
@@ -437,7 +436,7 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
437 } 436 }
438 if (isrc & IRQ_ALI) { 437 if (isrc & IRQ_ALI) {
439 /* arbitration lost interrupt */ 438 /* arbitration lost interrupt */
440 dev_dbg(dev->dev.parent, "arbitration lost interrupt\n"); 439 netdev_dbg(dev, "arbitration lost interrupt\n");
441 alc = priv->read_reg(priv, REG_ALC); 440 alc = priv->read_reg(priv, REG_ALC);
442 priv->can.can_stats.arbitration_lost++; 441 priv->can.can_stats.arbitration_lost++;
443 stats->tx_errors++; 442 stats->tx_errors++;
@@ -495,7 +494,7 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
495 status = priv->read_reg(priv, REG_SR); 494 status = priv->read_reg(priv, REG_SR);
496 495
497 if (isrc & IRQ_WUI) 496 if (isrc & IRQ_WUI)
498 dev_warn(dev->dev.parent, "wakeup interrupt\n"); 497 netdev_warn(dev, "wakeup interrupt\n");
499 498
500 if (isrc & IRQ_TI) { 499 if (isrc & IRQ_TI) {
501 /* transmission complete interrupt */ 500 /* transmission complete interrupt */
@@ -522,7 +521,7 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
522 priv->post_irq(priv); 521 priv->post_irq(priv);
523 522
524 if (n >= SJA1000_MAX_IRQ) 523 if (n >= SJA1000_MAX_IRQ)
525 dev_dbg(dev->dev.parent, "%d messages handled in ISR", n); 524 netdev_dbg(dev, "%d messages handled in ISR", n);
526 525
527 return (n) ? IRQ_HANDLED : IRQ_NONE; 526 return (n) ? IRQ_HANDLED : IRQ_NONE;
528} 527}
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index 3f1ebcc2cb83..98a5a7d867f5 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * slcan.c - serial line CAN interface driver (using tty line discipline) 2 * slcan.c - serial line CAN interface driver (using tty line discipline)
3 * 3 *
4 * This file is derived from linux/drivers/net/slip.c 4 * This file is derived from linux/drivers/net/slip/slip.c
5 * 5 *
6 * slip.c Authors : Laurence Culhane <loz@holmes.demon.co.uk> 6 * slip.c Authors : Laurence Culhane <loz@holmes.demon.co.uk>
7 * Fred N. van Kempen <waltje@uwalt.nl.mugnet.org> 7 * Fred N. van Kempen <waltje@uwalt.nl.mugnet.org>
@@ -639,10 +639,8 @@ static int __init slcan_init(void)
639 printk(KERN_INFO "slcan: %d dynamic interface channels.\n", maxdev); 639 printk(KERN_INFO "slcan: %d dynamic interface channels.\n", maxdev);
640 640
641 slcan_devs = kzalloc(sizeof(struct net_device *)*maxdev, GFP_KERNEL); 641 slcan_devs = kzalloc(sizeof(struct net_device *)*maxdev, GFP_KERNEL);
642 if (!slcan_devs) { 642 if (!slcan_devs)
643 printk(KERN_ERR "slcan: can't allocate slcan device array!\n");
644 return -ENOMEM; 643 return -ENOMEM;
645 }
646 644
647 /* Fill in our line protocol discipline, and register it */ 645 /* Fill in our line protocol discipline, and register it */
648 status = tty_register_ldisc(N_SLCAN, &slc_ldisc); 646 status = tty_register_ldisc(N_SLCAN, &slc_ldisc);
diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 5a2e1e3588a1..4accd7ec6954 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -306,7 +306,7 @@ static int ti_hecc_set_btc(struct ti_hecc_priv *priv)
306 if (bit_timing->brp > 4) 306 if (bit_timing->brp > 4)
307 can_btc |= HECC_CANBTC_SAM; 307 can_btc |= HECC_CANBTC_SAM;
308 else 308 else
309 dev_warn(priv->ndev->dev.parent, "WARN: Triple" \ 309 netdev_warn(priv->ndev, "WARN: Triple"
310 "sampling not set due to h/w limitations"); 310 "sampling not set due to h/w limitations");
311 } 311 }
312 can_btc |= ((bit_timing->sjw - 1) & 0x3) << 8; 312 can_btc |= ((bit_timing->sjw - 1) & 0x3) << 8;
@@ -315,7 +315,7 @@ static int ti_hecc_set_btc(struct ti_hecc_priv *priv)
315 /* ERM being set to 0 by default meaning resync at falling edge */ 315 /* ERM being set to 0 by default meaning resync at falling edge */
316 316
317 hecc_write(priv, HECC_CANBTC, can_btc); 317 hecc_write(priv, HECC_CANBTC, can_btc);
318 dev_info(priv->ndev->dev.parent, "setting CANBTC=%#x\n", can_btc); 318 netdev_info(priv->ndev, "setting CANBTC=%#x\n", can_btc);
319 319
320 return 0; 320 return 0;
321} 321}
@@ -332,7 +332,7 @@ static void ti_hecc_reset(struct net_device *ndev)
332 u32 cnt; 332 u32 cnt;
333 struct ti_hecc_priv *priv = netdev_priv(ndev); 333 struct ti_hecc_priv *priv = netdev_priv(ndev);
334 334
335 dev_dbg(ndev->dev.parent, "resetting hecc ...\n"); 335 netdev_dbg(ndev, "resetting hecc ...\n");
336 hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_SRES); 336 hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_SRES);
337 337
338 /* Set change control request and wait till enabled */ 338 /* Set change control request and wait till enabled */
@@ -458,6 +458,17 @@ static int ti_hecc_do_set_mode(struct net_device *ndev, enum can_mode mode)
458 return ret; 458 return ret;
459} 459}
460 460
461static int ti_hecc_get_berr_counter(const struct net_device *ndev,
462 struct can_berr_counter *bec)
463{
464 struct ti_hecc_priv *priv = netdev_priv(ndev);
465
466 bec->txerr = hecc_read(priv, HECC_CANTEC);
467 bec->rxerr = hecc_read(priv, HECC_CANREC);
468
469 return 0;
470}
471
461/* 472/*
462 * ti_hecc_xmit: HECC Transmit 473 * ti_hecc_xmit: HECC Transmit
463 * 474 *
@@ -496,7 +507,7 @@ static netdev_tx_t ti_hecc_xmit(struct sk_buff *skb, struct net_device *ndev)
496 if (unlikely(hecc_read(priv, HECC_CANME) & mbx_mask)) { 507 if (unlikely(hecc_read(priv, HECC_CANME) & mbx_mask)) {
497 spin_unlock_irqrestore(&priv->mbx_lock, flags); 508 spin_unlock_irqrestore(&priv->mbx_lock, flags);
498 netif_stop_queue(ndev); 509 netif_stop_queue(ndev);
499 dev_err(priv->ndev->dev.parent, 510 netdev_err(priv->ndev,
500 "BUG: TX mbx not ready tx_head=%08X, tx_tail=%08X\n", 511 "BUG: TX mbx not ready tx_head=%08X, tx_tail=%08X\n",
501 priv->tx_head, priv->tx_tail); 512 priv->tx_head, priv->tx_tail);
502 return NETDEV_TX_BUSY; 513 return NETDEV_TX_BUSY;
@@ -550,7 +561,7 @@ static int ti_hecc_rx_pkt(struct ti_hecc_priv *priv, int mbxno)
550 skb = alloc_can_skb(priv->ndev, &cf); 561 skb = alloc_can_skb(priv->ndev, &cf);
551 if (!skb) { 562 if (!skb) {
552 if (printk_ratelimit()) 563 if (printk_ratelimit())
553 dev_err(priv->ndev->dev.parent, 564 netdev_err(priv->ndev,
554 "ti_hecc_rx_pkt: alloc_can_skb() failed\n"); 565 "ti_hecc_rx_pkt: alloc_can_skb() failed\n");
555 return -ENOMEM; 566 return -ENOMEM;
556 } 567 }
@@ -668,7 +679,7 @@ static int ti_hecc_error(struct net_device *ndev, int int_status,
668 skb = alloc_can_err_skb(ndev, &cf); 679 skb = alloc_can_err_skb(ndev, &cf);
669 if (!skb) { 680 if (!skb) {
670 if (printk_ratelimit()) 681 if (printk_ratelimit())
671 dev_err(priv->ndev->dev.parent, 682 netdev_err(priv->ndev,
672 "ti_hecc_error: alloc_can_err_skb() failed\n"); 683 "ti_hecc_error: alloc_can_err_skb() failed\n");
673 return -ENOMEM; 684 return -ENOMEM;
674 } 685 }
@@ -684,7 +695,7 @@ static int ti_hecc_error(struct net_device *ndev, int int_status,
684 cf->data[1] |= CAN_ERR_CRTL_RX_WARNING; 695 cf->data[1] |= CAN_ERR_CRTL_RX_WARNING;
685 } 696 }
686 hecc_set_bit(priv, HECC_CANES, HECC_CANES_EW); 697 hecc_set_bit(priv, HECC_CANES, HECC_CANES_EW);
687 dev_dbg(priv->ndev->dev.parent, "Error Warning interrupt\n"); 698 netdev_dbg(priv->ndev, "Error Warning interrupt\n");
688 hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR); 699 hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR);
689 } 700 }
690 701
@@ -699,7 +710,7 @@ static int ti_hecc_error(struct net_device *ndev, int int_status,
699 cf->data[1] |= CAN_ERR_CRTL_RX_PASSIVE; 710 cf->data[1] |= CAN_ERR_CRTL_RX_PASSIVE;
700 } 711 }
701 hecc_set_bit(priv, HECC_CANES, HECC_CANES_EP); 712 hecc_set_bit(priv, HECC_CANES, HECC_CANES_EP);
702 dev_dbg(priv->ndev->dev.parent, "Error passive interrupt\n"); 713 netdev_dbg(priv->ndev, "Error passive interrupt\n");
703 hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR); 714 hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_CCR);
704 } 715 }
705 716
@@ -825,7 +836,7 @@ static int ti_hecc_open(struct net_device *ndev)
825 err = request_irq(ndev->irq, ti_hecc_interrupt, IRQF_SHARED, 836 err = request_irq(ndev->irq, ti_hecc_interrupt, IRQF_SHARED,
826 ndev->name, ndev); 837 ndev->name, ndev);
827 if (err) { 838 if (err) {
828 dev_err(ndev->dev.parent, "error requesting interrupt\n"); 839 netdev_err(ndev, "error requesting interrupt\n");
829 return err; 840 return err;
830 } 841 }
831 842
@@ -834,7 +845,7 @@ static int ti_hecc_open(struct net_device *ndev)
834 /* Open common can device */ 845 /* Open common can device */
835 err = open_candev(ndev); 846 err = open_candev(ndev);
836 if (err) { 847 if (err) {
837 dev_err(ndev->dev.parent, "open_candev() failed %d\n", err); 848 netdev_err(ndev, "open_candev() failed %d\n", err);
838 ti_hecc_transceiver_switch(priv, 0); 849 ti_hecc_transceiver_switch(priv, 0);
839 free_irq(ndev->irq, ndev); 850 free_irq(ndev->irq, ndev);
840 return err; 851 return err;
@@ -923,6 +934,7 @@ static int ti_hecc_probe(struct platform_device *pdev)
923 priv->can.bittiming_const = &ti_hecc_bittiming_const; 934 priv->can.bittiming_const = &ti_hecc_bittiming_const;
924 priv->can.do_set_mode = ti_hecc_do_set_mode; 935 priv->can.do_set_mode = ti_hecc_do_set_mode;
925 priv->can.do_get_state = ti_hecc_get_state; 936 priv->can.do_get_state = ti_hecc_get_state;
937 priv->can.do_get_berr_counter = ti_hecc_get_berr_counter;
926 priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES; 938 priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES;
927 939
928 spin_lock_init(&priv->mbx_lock); 940 spin_lock_init(&priv->mbx_lock);
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
index 7dae64d44e83..7ae65fc80032 100644
--- a/drivers/net/can/usb/ems_usb.c
+++ b/drivers/net/can/usb/ems_usb.c
@@ -288,8 +288,7 @@ static void ems_usb_read_interrupt_callback(struct urb *urb)
288 return; 288 return;
289 289
290 default: 290 default:
291 dev_info(netdev->dev.parent, "Rx interrupt aborted %d\n", 291 netdev_info(netdev, "Rx interrupt aborted %d\n", urb->status);
292 urb->status);
293 break; 292 break;
294 } 293 }
295 294
@@ -298,8 +297,7 @@ static void ems_usb_read_interrupt_callback(struct urb *urb)
298 if (err == -ENODEV) 297 if (err == -ENODEV)
299 netif_device_detach(netdev); 298 netif_device_detach(netdev);
300 else if (err) 299 else if (err)
301 dev_err(netdev->dev.parent, 300 netdev_err(netdev, "failed resubmitting intr urb: %d\n", err);
302 "failed resubmitting intr urb: %d\n", err);
303} 301}
304 302
305static void ems_usb_rx_can_msg(struct ems_usb *dev, struct ems_cpc_msg *msg) 303static void ems_usb_rx_can_msg(struct ems_usb *dev, struct ems_cpc_msg *msg)
@@ -431,8 +429,7 @@ static void ems_usb_read_bulk_callback(struct urb *urb)
431 return; 429 return;
432 430
433 default: 431 default:
434 dev_info(netdev->dev.parent, "Rx URB aborted (%d)\n", 432 netdev_info(netdev, "Rx URB aborted (%d)\n", urb->status);
435 urb->status);
436 goto resubmit_urb; 433 goto resubmit_urb;
437 } 434 }
438 435
@@ -477,7 +474,7 @@ static void ems_usb_read_bulk_callback(struct urb *urb)
477 msg_count--; 474 msg_count--;
478 475
479 if (start > urb->transfer_buffer_length) { 476 if (start > urb->transfer_buffer_length) {
480 dev_err(netdev->dev.parent, "format error\n"); 477 netdev_err(netdev, "format error\n");
481 break; 478 break;
482 } 479 }
483 } 480 }
@@ -493,8 +490,8 @@ resubmit_urb:
493 if (retval == -ENODEV) 490 if (retval == -ENODEV)
494 netif_device_detach(netdev); 491 netif_device_detach(netdev);
495 else if (retval) 492 else if (retval)
496 dev_err(netdev->dev.parent, 493 netdev_err(netdev,
497 "failed resubmitting read bulk urb: %d\n", retval); 494 "failed resubmitting read bulk urb: %d\n", retval);
498} 495}
499 496
500/* 497/*
@@ -521,8 +518,7 @@ static void ems_usb_write_bulk_callback(struct urb *urb)
521 return; 518 return;
522 519
523 if (urb->status) 520 if (urb->status)
524 dev_info(netdev->dev.parent, "Tx URB aborted (%d)\n", 521 netdev_info(netdev, "Tx URB aborted (%d)\n", urb->status);
525 urb->status);
526 522
527 netdev->trans_start = jiffies; 523 netdev->trans_start = jiffies;
528 524
@@ -605,18 +601,18 @@ static int ems_usb_start(struct ems_usb *dev)
605 /* create a URB, and a buffer for it */ 601 /* create a URB, and a buffer for it */
606 urb = usb_alloc_urb(0, GFP_KERNEL); 602 urb = usb_alloc_urb(0, GFP_KERNEL);
607 if (!urb) { 603 if (!urb) {
608 dev_err(netdev->dev.parent, 604 netdev_err(netdev, "No memory left for URBs\n");
609 "No memory left for URBs\n"); 605 err = -ENOMEM;
610 return -ENOMEM; 606 break;
611 } 607 }
612 608
613 buf = usb_alloc_coherent(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL, 609 buf = usb_alloc_coherent(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL,
614 &urb->transfer_dma); 610 &urb->transfer_dma);
615 if (!buf) { 611 if (!buf) {
616 dev_err(netdev->dev.parent, 612 netdev_err(netdev, "No memory left for USB buffer\n");
617 "No memory left for USB buffer\n");
618 usb_free_urb(urb); 613 usb_free_urb(urb);
619 return -ENOMEM; 614 err = -ENOMEM;
615 break;
620 } 616 }
621 617
622 usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 2), 618 usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 2),
@@ -639,13 +635,13 @@ static int ems_usb_start(struct ems_usb *dev)
639 635
640 /* Did we submit any URBs */ 636 /* Did we submit any URBs */
641 if (i == 0) { 637 if (i == 0) {
642 dev_warn(netdev->dev.parent, "couldn't setup read URBs\n"); 638 netdev_warn(netdev, "couldn't setup read URBs\n");
643 return err; 639 return err;
644 } 640 }
645 641
646 /* Warn if we've couldn't transmit all the URBs */ 642 /* Warn if we've couldn't transmit all the URBs */
647 if (i < MAX_RX_URBS) 643 if (i < MAX_RX_URBS)
648 dev_warn(netdev->dev.parent, "rx performance may be slow\n"); 644 netdev_warn(netdev, "rx performance may be slow\n");
649 645
650 /* Setup and start interrupt URB */ 646 /* Setup and start interrupt URB */
651 usb_fill_int_urb(dev->intr_urb, dev->udev, 647 usb_fill_int_urb(dev->intr_urb, dev->udev,
@@ -656,8 +652,7 @@ static int ems_usb_start(struct ems_usb *dev)
656 652
657 err = usb_submit_urb(dev->intr_urb, GFP_KERNEL); 653 err = usb_submit_urb(dev->intr_urb, GFP_KERNEL);
658 if (err) { 654 if (err) {
659 dev_warn(netdev->dev.parent, "intr URB submit failed: %d\n", 655 netdev_warn(netdev, "intr URB submit failed: %d\n", err);
660 err);
661 656
662 return err; 657 return err;
663 } 658 }
@@ -686,7 +681,7 @@ static int ems_usb_start(struct ems_usb *dev)
686 return 0; 681 return 0;
687 682
688failed: 683failed:
689 dev_warn(netdev->dev.parent, "couldn't submit control: %d\n", err); 684 netdev_warn(netdev, "couldn't submit control: %d\n", err);
690 685
691 return err; 686 return err;
692} 687}
@@ -726,8 +721,7 @@ static int ems_usb_open(struct net_device *netdev)
726 if (err == -ENODEV) 721 if (err == -ENODEV)
727 netif_device_detach(dev->netdev); 722 netif_device_detach(dev->netdev);
728 723
729 dev_warn(netdev->dev.parent, "couldn't start device: %d\n", 724 netdev_warn(netdev, "couldn't start device: %d\n", err);
730 err);
731 725
732 close_candev(netdev); 726 close_candev(netdev);
733 727
@@ -760,13 +754,13 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne
760 /* create a URB, and a buffer for it, and copy the data to the URB */ 754 /* create a URB, and a buffer for it, and copy the data to the URB */
761 urb = usb_alloc_urb(0, GFP_ATOMIC); 755 urb = usb_alloc_urb(0, GFP_ATOMIC);
762 if (!urb) { 756 if (!urb) {
763 dev_err(netdev->dev.parent, "No memory left for URBs\n"); 757 netdev_err(netdev, "No memory left for URBs\n");
764 goto nomem; 758 goto nomem;
765 } 759 }
766 760
767 buf = usb_alloc_coherent(dev->udev, size, GFP_ATOMIC, &urb->transfer_dma); 761 buf = usb_alloc_coherent(dev->udev, size, GFP_ATOMIC, &urb->transfer_dma);
768 if (!buf) { 762 if (!buf) {
769 dev_err(netdev->dev.parent, "No memory left for USB buffer\n"); 763 netdev_err(netdev, "No memory left for USB buffer\n");
770 usb_free_urb(urb); 764 usb_free_urb(urb);
771 goto nomem; 765 goto nomem;
772 } 766 }
@@ -809,7 +803,7 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne
809 usb_unanchor_urb(urb); 803 usb_unanchor_urb(urb);
810 usb_free_coherent(dev->udev, size, buf, urb->transfer_dma); 804 usb_free_coherent(dev->udev, size, buf, urb->transfer_dma);
811 805
812 dev_warn(netdev->dev.parent, "couldn't find free context\n"); 806 netdev_warn(netdev, "couldn't find free context\n");
813 807
814 return NETDEV_TX_BUSY; 808 return NETDEV_TX_BUSY;
815 } 809 }
@@ -840,7 +834,7 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne
840 if (err == -ENODEV) { 834 if (err == -ENODEV) {
841 netif_device_detach(netdev); 835 netif_device_detach(netdev);
842 } else { 836 } else {
843 dev_warn(netdev->dev.parent, "failed tx_urb %d\n", err); 837 netdev_warn(netdev, "failed tx_urb %d\n", err);
844 838
845 stats->tx_dropped++; 839 stats->tx_dropped++;
846 } 840 }
@@ -880,7 +874,7 @@ static int ems_usb_close(struct net_device *netdev)
880 874
881 /* Set CAN controller to reset mode */ 875 /* Set CAN controller to reset mode */
882 if (ems_usb_write_mode(dev, SJA1000_MOD_RM)) 876 if (ems_usb_write_mode(dev, SJA1000_MOD_RM))
883 dev_warn(netdev->dev.parent, "couldn't stop device"); 877 netdev_warn(netdev, "couldn't stop device");
884 878
885 close_candev(netdev); 879 close_candev(netdev);
886 880
@@ -917,7 +911,7 @@ static int ems_usb_set_mode(struct net_device *netdev, enum can_mode mode)
917 switch (mode) { 911 switch (mode) {
918 case CAN_MODE_START: 912 case CAN_MODE_START:
919 if (ems_usb_write_mode(dev, SJA1000_MOD_NORMAL)) 913 if (ems_usb_write_mode(dev, SJA1000_MOD_NORMAL))
920 dev_warn(netdev->dev.parent, "couldn't start device"); 914 netdev_warn(netdev, "couldn't start device");
921 915
922 if (netif_queue_stopped(netdev)) 916 if (netif_queue_stopped(netdev))
923 netif_wake_queue(netdev); 917 netif_wake_queue(netdev);
@@ -942,8 +936,7 @@ static int ems_usb_set_bittiming(struct net_device *netdev)
942 if (dev->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) 936 if (dev->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
943 btr1 |= 0x80; 937 btr1 |= 0x80;
944 938
945 dev_info(netdev->dev.parent, "setting BTR0=0x%02x BTR1=0x%02x\n", 939 netdev_info(netdev, "setting BTR0=0x%02x BTR1=0x%02x\n", btr0, btr1);
946 btr0, btr1);
947 940
948 dev->active_params.msg.can_params.cc_params.sja1000.btr0 = btr0; 941 dev->active_params.msg.can_params.cc_params.sja1000.btr0 = btr0;
949 dev->active_params.msg.can_params.cc_params.sja1000.btr1 = btr1; 942 dev->active_params.msg.can_params.cc_params.sja1000.btr1 = btr1;
@@ -1048,15 +1041,13 @@ static int ems_usb_probe(struct usb_interface *intf,
1048 1041
1049 err = ems_usb_command_msg(dev, &dev->active_params); 1042 err = ems_usb_command_msg(dev, &dev->active_params);
1050 if (err) { 1043 if (err) {
1051 dev_err(netdev->dev.parent, 1044 netdev_err(netdev, "couldn't initialize controller: %d\n", err);
1052 "couldn't initialize controller: %d\n", err);
1053 goto cleanup_tx_msg_buffer; 1045 goto cleanup_tx_msg_buffer;
1054 } 1046 }
1055 1047
1056 err = register_candev(netdev); 1048 err = register_candev(netdev);
1057 if (err) { 1049 if (err) {
1058 dev_err(netdev->dev.parent, 1050 netdev_err(netdev, "couldn't register CAN device: %d\n", err);
1059 "couldn't register CAN device: %d\n", err);
1060 goto cleanup_tx_msg_buffer; 1051 goto cleanup_tx_msg_buffer;
1061 } 1052 }
1062 1053
diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c
index 92774637aad8..09b1da5bc512 100644
--- a/drivers/net/can/usb/esd_usb2.c
+++ b/drivers/net/can/usb/esd_usb2.c
@@ -470,8 +470,7 @@ static void esd_usb2_write_bulk_callback(struct urb *urb)
470 return; 470 return;
471 471
472 if (urb->status) 472 if (urb->status)
473 dev_info(netdev->dev.parent, "Tx URB aborted (%d)\n", 473 netdev_info(netdev, "Tx URB aborted (%d)\n", urb->status);
474 urb->status);
475 474
476 netdev->trans_start = jiffies; 475 netdev->trans_start = jiffies;
477} 476}
@@ -651,7 +650,7 @@ failed:
651 if (err == -ENODEV) 650 if (err == -ENODEV)
652 netif_device_detach(netdev); 651 netif_device_detach(netdev);
653 652
654 dev_err(netdev->dev.parent, "couldn't start device: %d\n", err); 653 netdev_err(netdev, "couldn't start device: %d\n", err);
655 654
656 return err; 655 return err;
657} 656}
@@ -687,8 +686,7 @@ static int esd_usb2_open(struct net_device *netdev)
687 /* finally start device */ 686 /* finally start device */
688 err = esd_usb2_start(priv); 687 err = esd_usb2_start(priv);
689 if (err) { 688 if (err) {
690 dev_warn(netdev->dev.parent, 689 netdev_warn(netdev, "couldn't start device: %d\n", err);
691 "couldn't start device: %d\n", err);
692 close_candev(netdev); 690 close_candev(netdev);
693 return err; 691 return err;
694 } 692 }
@@ -721,7 +719,7 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb,
721 /* create a URB, and a buffer for it, and copy the data to the URB */ 719 /* create a URB, and a buffer for it, and copy the data to the URB */
722 urb = usb_alloc_urb(0, GFP_ATOMIC); 720 urb = usb_alloc_urb(0, GFP_ATOMIC);
723 if (!urb) { 721 if (!urb) {
724 dev_err(netdev->dev.parent, "No memory left for URBs\n"); 722 netdev_err(netdev, "No memory left for URBs\n");
725 stats->tx_dropped++; 723 stats->tx_dropped++;
726 dev_kfree_skb(skb); 724 dev_kfree_skb(skb);
727 goto nourbmem; 725 goto nourbmem;
@@ -730,7 +728,7 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb,
730 buf = usb_alloc_coherent(dev->udev, size, GFP_ATOMIC, 728 buf = usb_alloc_coherent(dev->udev, size, GFP_ATOMIC,
731 &urb->transfer_dma); 729 &urb->transfer_dma);
732 if (!buf) { 730 if (!buf) {
733 dev_err(netdev->dev.parent, "No memory left for USB buffer\n"); 731 netdev_err(netdev, "No memory left for USB buffer\n");
734 stats->tx_dropped++; 732 stats->tx_dropped++;
735 dev_kfree_skb(skb); 733 dev_kfree_skb(skb);
736 goto nobufmem; 734 goto nobufmem;
@@ -766,7 +764,7 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb,
766 * This may never happen. 764 * This may never happen.
767 */ 765 */
768 if (!context) { 766 if (!context) {
769 dev_warn(netdev->dev.parent, "couldn't find free context\n"); 767 netdev_warn(netdev, "couldn't find free context\n");
770 ret = NETDEV_TX_BUSY; 768 ret = NETDEV_TX_BUSY;
771 goto releasebuf; 769 goto releasebuf;
772 } 770 }
@@ -806,7 +804,7 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb,
806 if (err == -ENODEV) 804 if (err == -ENODEV)
807 netif_device_detach(netdev); 805 netif_device_detach(netdev);
808 else 806 else
809 dev_warn(netdev->dev.parent, "failed tx_urb %d\n", err); 807 netdev_warn(netdev, "failed tx_urb %d\n", err);
810 808
811 goto releasebuf; 809 goto releasebuf;
812 } 810 }
@@ -845,7 +843,7 @@ static int esd_usb2_close(struct net_device *netdev)
845 for (i = 0; i <= ESD_MAX_ID_SEGMENT; i++) 843 for (i = 0; i <= ESD_MAX_ID_SEGMENT; i++)
846 msg.msg.filter.mask[i] = 0; 844 msg.msg.filter.mask[i] = 0;
847 if (esd_usb2_send_msg(priv->usb2, &msg) < 0) 845 if (esd_usb2_send_msg(priv->usb2, &msg) < 0)
848 dev_err(netdev->dev.parent, "sending idadd message failed\n"); 846 netdev_err(netdev, "sending idadd message failed\n");
849 847
850 /* set CAN controller to reset mode */ 848 /* set CAN controller to reset mode */
851 msg.msg.hdr.len = 2; 849 msg.msg.hdr.len = 2;
@@ -854,7 +852,7 @@ static int esd_usb2_close(struct net_device *netdev)
854 msg.msg.setbaud.rsvd = 0; 852 msg.msg.setbaud.rsvd = 0;
855 msg.msg.setbaud.baud = cpu_to_le32(ESD_USB2_NO_BAUDRATE); 853 msg.msg.setbaud.baud = cpu_to_le32(ESD_USB2_NO_BAUDRATE);
856 if (esd_usb2_send_msg(priv->usb2, &msg) < 0) 854 if (esd_usb2_send_msg(priv->usb2, &msg) < 0)
857 dev_err(netdev->dev.parent, "sending setbaud message failed\n"); 855 netdev_err(netdev, "sending setbaud message failed\n");
858 856
859 priv->can.state = CAN_STATE_STOPPED; 857 priv->can.state = CAN_STATE_STOPPED;
860 858
@@ -910,7 +908,7 @@ static int esd_usb2_set_bittiming(struct net_device *netdev)
910 msg.msg.setbaud.rsvd = 0; 908 msg.msg.setbaud.rsvd = 0;
911 msg.msg.setbaud.baud = cpu_to_le32(canbtr); 909 msg.msg.setbaud.baud = cpu_to_le32(canbtr);
912 910
913 dev_info(netdev->dev.parent, "setting BTR=%#x\n", canbtr); 911 netdev_info(netdev, "setting BTR=%#x\n", canbtr);
914 912
915 return esd_usb2_send_msg(priv->usb2, &msg); 913 return esd_usb2_send_msg(priv->usb2, &msg);
916} 914}
@@ -988,15 +986,14 @@ static int esd_usb2_probe_one_net(struct usb_interface *intf, int index)
988 986
989 err = register_candev(netdev); 987 err = register_candev(netdev);
990 if (err) { 988 if (err) {
991 dev_err(&intf->dev, 989 dev_err(&intf->dev, "couldn't register CAN device: %d\n", err);
992 "couldn't register CAN device: %d\n", err);
993 free_candev(netdev); 990 free_candev(netdev);
994 err = -ENOMEM; 991 err = -ENOMEM;
995 goto done; 992 goto done;
996 } 993 }
997 994
998 dev->nets[index] = priv; 995 dev->nets[index] = priv;
999 dev_info(netdev->dev.parent, "device %s registered\n", netdev->name); 996 netdev_info(netdev, "device %s registered\n", netdev->name);
1000 997
1001done: 998done:
1002 return err; 999 return err;
diff --git a/drivers/net/ethernet/3com/3c501.c b/drivers/net/ethernet/3com/3c501.c
index 68da81d476f3..bf73e1a02293 100644
--- a/drivers/net/ethernet/3com/3c501.c
+++ b/drivers/net/ethernet/3com/3c501.c
@@ -702,7 +702,7 @@ static void el_receive(struct net_device *dev)
702 */ 702 */
703 703
704 outb(AX_SYS, AX_CMD); 704 outb(AX_SYS, AX_CMD);
705 skb = dev_alloc_skb(pkt_len+2); 705 skb = netdev_alloc_skb(dev, pkt_len + 2);
706 706
707 /* 707 /*
708 * Start of frame 708 * Start of frame
diff --git a/drivers/net/ethernet/3com/3c509.c b/drivers/net/ethernet/3com/3c509.c
index 92053e6fc980..41719da2e178 100644
--- a/drivers/net/ethernet/3com/3c509.c
+++ b/drivers/net/ethernet/3com/3c509.c
@@ -1066,7 +1066,7 @@ el3_rx(struct net_device *dev)
1066 short pkt_len = rx_status & 0x7ff; 1066 short pkt_len = rx_status & 0x7ff;
1067 struct sk_buff *skb; 1067 struct sk_buff *skb;
1068 1068
1069 skb = dev_alloc_skb(pkt_len+5); 1069 skb = netdev_alloc_skb(dev, pkt_len + 5);
1070 if (el3_debug > 4) 1070 if (el3_debug > 4)
1071 pr_debug("Receiving packet size %d status %4.4x.\n", 1071 pr_debug("Receiving packet size %d status %4.4x.\n",
1072 pkt_len, rx_status); 1072 pkt_len, rx_status);
diff --git a/drivers/net/ethernet/3com/3c515.c b/drivers/net/ethernet/3com/3c515.c
index f67a5d3a200c..59e1e001bc3f 100644
--- a/drivers/net/ethernet/3com/3c515.c
+++ b/drivers/net/ethernet/3com/3c515.c
@@ -826,11 +826,10 @@ static int corkscrew_open(struct net_device *dev)
826 vp->rx_ring[i].next = 0; 826 vp->rx_ring[i].next = 0;
827 vp->rx_ring[i].status = 0; /* Clear complete bit. */ 827 vp->rx_ring[i].status = 0; /* Clear complete bit. */
828 vp->rx_ring[i].length = PKT_BUF_SZ | 0x80000000; 828 vp->rx_ring[i].length = PKT_BUF_SZ | 0x80000000;
829 skb = dev_alloc_skb(PKT_BUF_SZ); 829 skb = netdev_alloc_skb(dev, PKT_BUF_SZ);
830 vp->rx_skbuff[i] = skb; 830 vp->rx_skbuff[i] = skb;
831 if (skb == NULL) 831 if (skb == NULL)
832 break; /* Bad news! */ 832 break; /* Bad news! */
833 skb->dev = dev; /* Mark as being used by this device. */
834 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 833 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
835 vp->rx_ring[i].addr = isa_virt_to_bus(skb->data); 834 vp->rx_ring[i].addr = isa_virt_to_bus(skb->data);
836 } 835 }
@@ -1295,7 +1294,7 @@ static int corkscrew_rx(struct net_device *dev)
1295 short pkt_len = rx_status & 0x1fff; 1294 short pkt_len = rx_status & 0x1fff;
1296 struct sk_buff *skb; 1295 struct sk_buff *skb;
1297 1296
1298 skb = dev_alloc_skb(pkt_len + 5 + 2); 1297 skb = netdev_alloc_skb(dev, pkt_len + 5 + 2);
1299 if (corkscrew_debug > 4) 1298 if (corkscrew_debug > 4)
1300 pr_debug("Receiving packet size %d status %4.4x.\n", 1299 pr_debug("Receiving packet size %d status %4.4x.\n",
1301 pkt_len, rx_status); 1300 pkt_len, rx_status);
@@ -1368,7 +1367,7 @@ static int boomerang_rx(struct net_device *dev)
1368 /* Check if the packet is long enough to just accept without 1367 /* Check if the packet is long enough to just accept without
1369 copying to a properly sized skbuff. */ 1368 copying to a properly sized skbuff. */
1370 if (pkt_len < rx_copybreak && 1369 if (pkt_len < rx_copybreak &&
1371 (skb = dev_alloc_skb(pkt_len + 4)) != NULL) { 1370 (skb = netdev_alloc_skb(dev, pkt_len + 4)) != NULL) {
1372 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1371 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1373 /* 'skb_put()' points to the start of sk_buff data area. */ 1372 /* 'skb_put()' points to the start of sk_buff data area. */
1374 memcpy(skb_put(skb, pkt_len), 1373 memcpy(skb_put(skb, pkt_len),
@@ -1403,10 +1402,9 @@ static int boomerang_rx(struct net_device *dev)
1403 struct sk_buff *skb; 1402 struct sk_buff *skb;
1404 entry = vp->dirty_rx % RX_RING_SIZE; 1403 entry = vp->dirty_rx % RX_RING_SIZE;
1405 if (vp->rx_skbuff[entry] == NULL) { 1404 if (vp->rx_skbuff[entry] == NULL) {
1406 skb = dev_alloc_skb(PKT_BUF_SZ); 1405 skb = netdev_alloc_skb(dev, PKT_BUF_SZ);
1407 if (skb == NULL) 1406 if (skb == NULL)
1408 break; /* Bad news! */ 1407 break; /* Bad news! */
1409 skb->dev = dev; /* Mark as being used by this device. */
1410 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1408 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1411 vp->rx_ring[entry].addr = isa_virt_to_bus(skb->data); 1409 vp->rx_ring[entry].addr = isa_virt_to_bus(skb->data);
1412 vp->rx_skbuff[entry] = skb; 1410 vp->rx_skbuff[entry] = skb;
diff --git a/drivers/net/ethernet/3com/3c574_cs.c b/drivers/net/ethernet/3com/3c574_cs.c
index 9c01bc9235b3..e61b2f82ba3a 100644
--- a/drivers/net/ethernet/3com/3c574_cs.c
+++ b/drivers/net/ethernet/3com/3c574_cs.c
@@ -1012,7 +1012,7 @@ static int el3_rx(struct net_device *dev, int worklimit)
1012 short pkt_len = rx_status & 0x7ff; 1012 short pkt_len = rx_status & 0x7ff;
1013 struct sk_buff *skb; 1013 struct sk_buff *skb;
1014 1014
1015 skb = dev_alloc_skb(pkt_len+5); 1015 skb = netdev_alloc_skb(dev, pkt_len + 5);
1016 1016
1017 pr_debug(" Receiving packet size %d status %4.4x.\n", 1017 pr_debug(" Receiving packet size %d status %4.4x.\n",
1018 pkt_len, rx_status); 1018 pkt_len, rx_status);
diff --git a/drivers/net/ethernet/3com/3c589_cs.c b/drivers/net/ethernet/3com/3c589_cs.c
index da410f036869..b23253b9f742 100644
--- a/drivers/net/ethernet/3com/3c589_cs.c
+++ b/drivers/net/ethernet/3com/3c589_cs.c
@@ -819,7 +819,7 @@ static int el3_rx(struct net_device *dev)
819 short pkt_len = rx_status & 0x7ff; 819 short pkt_len = rx_status & 0x7ff;
820 struct sk_buff *skb; 820 struct sk_buff *skb;
821 821
822 skb = dev_alloc_skb(pkt_len+5); 822 skb = netdev_alloc_skb(dev, pkt_len + 5);
823 823
824 netdev_dbg(dev, " Receiving packet size %d status %4.4x.\n", 824 netdev_dbg(dev, " Receiving packet size %d status %4.4x.\n",
825 pkt_len, rx_status); 825 pkt_len, rx_status);
diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c
index 8153a3e0a1a4..1282f048dfad 100644
--- a/drivers/net/ethernet/3com/3c59x.c
+++ b/drivers/net/ethernet/3com/3c59x.c
@@ -1121,10 +1121,9 @@ static int __devinit vortex_probe1(struct device *gendev,
1121 1121
1122 dev = alloc_etherdev(sizeof(*vp)); 1122 dev = alloc_etherdev(sizeof(*vp));
1123 retval = -ENOMEM; 1123 retval = -ENOMEM;
1124 if (!dev) { 1124 if (!dev)
1125 pr_err(PFX "unable to allocate etherdev, aborting\n");
1126 goto out; 1125 goto out;
1127 } 1126
1128 SET_NETDEV_DEV(dev, gendev); 1127 SET_NETDEV_DEV(dev, gendev);
1129 vp = netdev_priv(dev); 1128 vp = netdev_priv(dev);
1130 1129
@@ -2500,7 +2499,7 @@ static int vortex_rx(struct net_device *dev)
2500 int pkt_len = rx_status & 0x1fff; 2499 int pkt_len = rx_status & 0x1fff;
2501 struct sk_buff *skb; 2500 struct sk_buff *skb;
2502 2501
2503 skb = dev_alloc_skb(pkt_len + 5); 2502 skb = netdev_alloc_skb(dev, pkt_len + 5);
2504 if (vortex_debug > 4) 2503 if (vortex_debug > 4)
2505 pr_debug("Receiving packet size %d status %4.4x.\n", 2504 pr_debug("Receiving packet size %d status %4.4x.\n",
2506 pkt_len, rx_status); 2505 pkt_len, rx_status);
@@ -2579,7 +2578,8 @@ boomerang_rx(struct net_device *dev)
2579 2578
2580 /* Check if the packet is long enough to just accept without 2579 /* Check if the packet is long enough to just accept without
2581 copying to a properly sized skbuff. */ 2580 copying to a properly sized skbuff. */
2582 if (pkt_len < rx_copybreak && (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { 2581 if (pkt_len < rx_copybreak &&
2582 (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) {
2583 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 2583 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
2584 pci_dma_sync_single_for_cpu(VORTEX_PCI(vp), dma, PKT_BUF_SZ, PCI_DMA_FROMDEVICE); 2584 pci_dma_sync_single_for_cpu(VORTEX_PCI(vp), dma, PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
2585 /* 'skb_put()' points to the start of sk_buff data area. */ 2585 /* 'skb_put()' points to the start of sk_buff data area. */
diff --git a/drivers/net/ethernet/3com/Kconfig b/drivers/net/ethernet/3com/Kconfig
index a8bb30cf512d..bad4fa6815c5 100644
--- a/drivers/net/ethernet/3com/Kconfig
+++ b/drivers/net/ethernet/3com/Kconfig
@@ -97,7 +97,7 @@ config VORTEX
97 available from <http://www.tldp.org/docs.html#howto>. More 97 available from <http://www.tldp.org/docs.html#howto>. More
98 specific information is in 98 specific information is in
99 <file:Documentation/networking/vortex.txt> and in the comments at 99 <file:Documentation/networking/vortex.txt> and in the comments at
100 the beginning of <file:drivers/net/3c59x.c>. 100 the beginning of <file:drivers/net/ethernet/3com/3c59x.c>.
101 101
102 To compile this support as a module, choose M here. 102 To compile this support as a module, choose M here.
103 103
diff --git a/drivers/net/ethernet/3com/typhoon.c b/drivers/net/ethernet/3com/typhoon.c
index 6d6bc754b1a8..f7d622eed203 100644
--- a/drivers/net/ethernet/3com/typhoon.c
+++ b/drivers/net/ethernet/3com/typhoon.c
@@ -1607,7 +1607,7 @@ typhoon_alloc_rx_skb(struct typhoon *tp, u32 idx)
1607 le32_to_cpu(indexes->rxBuffCleared)) 1607 le32_to_cpu(indexes->rxBuffCleared))
1608 return -ENOMEM; 1608 return -ENOMEM;
1609 1609
1610 skb = dev_alloc_skb(PKT_BUF_SZ); 1610 skb = netdev_alloc_skb(tp->dev, PKT_BUF_SZ);
1611 if(!skb) 1611 if(!skb)
1612 return -ENOMEM; 1612 return -ENOMEM;
1613 1613
@@ -1618,7 +1618,6 @@ typhoon_alloc_rx_skb(struct typhoon *tp, u32 idx)
1618 skb_reserve(skb, 2); 1618 skb_reserve(skb, 2);
1619#endif 1619#endif
1620 1620
1621 skb->dev = tp->dev;
1622 dma_addr = pci_map_single(tp->pdev, skb->data, 1621 dma_addr = pci_map_single(tp->pdev, skb->data,
1623 PKT_BUF_SZ, PCI_DMA_FROMDEVICE); 1622 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
1624 1623
@@ -1673,7 +1672,7 @@ typhoon_rx(struct typhoon *tp, struct basic_ring *rxRing, volatile __le32 * read
1673 pkt_len = le16_to_cpu(rx->frameLen); 1672 pkt_len = le16_to_cpu(rx->frameLen);
1674 1673
1675 if(pkt_len < rx_copybreak && 1674 if(pkt_len < rx_copybreak &&
1676 (new_skb = dev_alloc_skb(pkt_len + 2)) != NULL) { 1675 (new_skb = netdev_alloc_skb(tp->dev, pkt_len + 2)) != NULL) {
1677 skb_reserve(new_skb, 2); 1676 skb_reserve(new_skb, 2);
1678 pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, 1677 pci_dma_sync_single_for_cpu(tp->pdev, dma_addr,
1679 PKT_BUF_SZ, 1678 PKT_BUF_SZ,
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 0f92e3567f68..c30adcc9828a 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -1,4 +1,4 @@
1/* drivers/net/ax88796.c 1/* drivers/net/ethernet/8390/ax88796.c
2 * 2 *
3 * Copyright 2005,2007 Simtec Electronics 3 * Copyright 2005,2007 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk> 4 * Ben Dooks <ben@simtec.co.uk>
diff --git a/drivers/net/ethernet/8390/axnet_cs.c b/drivers/net/ethernet/8390/axnet_cs.c
index bba51cdc74a1..c5bd8eb7a9f5 100644
--- a/drivers/net/ethernet/8390/axnet_cs.c
+++ b/drivers/net/ethernet/8390/axnet_cs.c
@@ -192,7 +192,7 @@ static int get_prom(struct pcmcia_device *link)
192 unsigned int ioaddr = dev->base_addr; 192 unsigned int ioaddr = dev->base_addr;
193 int i, j; 193 int i, j;
194 194
195 /* This is based on drivers/net/ne.c */ 195 /* This is based on drivers/net/ethernet/8390/ne.c */
196 struct { 196 struct {
197 u_char value, offset; 197 u_char value, offset;
198 } program_seq[] = { 198 } program_seq[] = {
@@ -1408,7 +1408,7 @@ static void ei_receive(struct net_device *dev)
1408 { 1408 {
1409 struct sk_buff *skb; 1409 struct sk_buff *skb;
1410 1410
1411 skb = dev_alloc_skb(pkt_len+2); 1411 skb = netdev_alloc_skb(dev, pkt_len + 2);
1412 if (skb == NULL) 1412 if (skb == NULL)
1413 { 1413 {
1414 if (ei_debug > 1) 1414 if (ei_debug > 1)
diff --git a/drivers/net/ethernet/8390/lib8390.c b/drivers/net/ethernet/8390/lib8390.c
index 05ae21435bfd..e77f624e8194 100644
--- a/drivers/net/ethernet/8390/lib8390.c
+++ b/drivers/net/ethernet/8390/lib8390.c
@@ -717,7 +717,7 @@ static void ei_receive(struct net_device *dev)
717 } else if ((pkt_stat & 0x0F) == ENRSR_RXOK) { 717 } else if ((pkt_stat & 0x0F) == ENRSR_RXOK) {
718 struct sk_buff *skb; 718 struct sk_buff *skb;
719 719
720 skb = dev_alloc_skb(pkt_len+2); 720 skb = netdev_alloc_skb(dev, pkt_len + 2);
721 if (skb == NULL) { 721 if (skb == NULL) {
722 if (ei_debug > 1) 722 if (ei_debug > 1)
723 netdev_dbg(dev, "Couldn't allocate a sk_buff of size %d\n", 723 netdev_dbg(dev, "Couldn't allocate a sk_buff of size %d\n",
diff --git a/drivers/net/ethernet/8390/pcnet_cs.c b/drivers/net/ethernet/8390/pcnet_cs.c
index 053b2551a72d..f2a4e5de18c4 100644
--- a/drivers/net/ethernet/8390/pcnet_cs.c
+++ b/drivers/net/ethernet/8390/pcnet_cs.c
@@ -326,7 +326,7 @@ static hw_info_t *get_prom(struct pcmcia_device *link)
326 u_char prom[32]; 326 u_char prom[32];
327 int i, j; 327 int i, j;
328 328
329 /* This is lifted straight from drivers/net/ne.c */ 329 /* This is lifted straight from drivers/net/ethernet/8390/ne.c */
330 struct { 330 struct {
331 u_char value, offset; 331 u_char value, offset;
332 } program_seq[] = { 332 } program_seq[] = {
diff --git a/drivers/net/ethernet/adaptec/starfire.c b/drivers/net/ethernet/adaptec/starfire.c
index cb4f38a17f20..d896816512ca 100644
--- a/drivers/net/ethernet/adaptec/starfire.c
+++ b/drivers/net/ethernet/adaptec/starfire.c
@@ -686,10 +686,9 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
686 } 686 }
687 687
688 dev = alloc_etherdev(sizeof(*np)); 688 dev = alloc_etherdev(sizeof(*np));
689 if (!dev) { 689 if (!dev)
690 printk(KERN_ERR DRV_NAME " %d: cannot alloc etherdev, aborting\n", card_idx);
691 return -ENOMEM; 690 return -ENOMEM;
692 } 691
693 SET_NETDEV_DEV(dev, &pdev->dev); 692 SET_NETDEV_DEV(dev, &pdev->dev);
694 693
695 irq = pdev->irq; 694 irq = pdev->irq;
@@ -1180,12 +1179,11 @@ static void init_ring(struct net_device *dev)
1180 1179
1181 /* Fill in the Rx buffers. Handle allocation failure gracefully. */ 1180 /* Fill in the Rx buffers. Handle allocation failure gracefully. */
1182 for (i = 0; i < RX_RING_SIZE; i++) { 1181 for (i = 0; i < RX_RING_SIZE; i++) {
1183 struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz); 1182 struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz);
1184 np->rx_info[i].skb = skb; 1183 np->rx_info[i].skb = skb;
1185 if (skb == NULL) 1184 if (skb == NULL)
1186 break; 1185 break;
1187 np->rx_info[i].mapping = pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz, PCI_DMA_FROMDEVICE); 1186 np->rx_info[i].mapping = pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz, PCI_DMA_FROMDEVICE);
1188 skb->dev = dev; /* Mark as being used by this device. */
1189 /* Grrr, we cannot offset to correctly align the IP header. */ 1187 /* Grrr, we cannot offset to correctly align the IP header. */
1190 np->rx_ring[i].rxaddr = cpu_to_dma(np->rx_info[i].mapping | RxDescValid); 1188 np->rx_ring[i].rxaddr = cpu_to_dma(np->rx_info[i].mapping | RxDescValid);
1191 } 1189 }
@@ -1473,7 +1471,7 @@ static int __netdev_rx(struct net_device *dev, int *quota)
1473 /* Check if the packet is long enough to accept without copying 1471 /* Check if the packet is long enough to accept without copying
1474 to a minimally-sized skbuff. */ 1472 to a minimally-sized skbuff. */
1475 if (pkt_len < rx_copybreak && 1473 if (pkt_len < rx_copybreak &&
1476 (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { 1474 (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) {
1477 skb_reserve(skb, 2); /* 16 byte align the IP header */ 1475 skb_reserve(skb, 2); /* 16 byte align the IP header */
1478 pci_dma_sync_single_for_cpu(np->pci_dev, 1476 pci_dma_sync_single_for_cpu(np->pci_dev,
1479 np->rx_info[entry].mapping, 1477 np->rx_info[entry].mapping,
@@ -1597,13 +1595,12 @@ static void refill_rx_ring(struct net_device *dev)
1597 for (; np->cur_rx - np->dirty_rx > 0; np->dirty_rx++) { 1595 for (; np->cur_rx - np->dirty_rx > 0; np->dirty_rx++) {
1598 entry = np->dirty_rx % RX_RING_SIZE; 1596 entry = np->dirty_rx % RX_RING_SIZE;
1599 if (np->rx_info[entry].skb == NULL) { 1597 if (np->rx_info[entry].skb == NULL) {
1600 skb = dev_alloc_skb(np->rx_buf_sz); 1598 skb = netdev_alloc_skb(dev, np->rx_buf_sz);
1601 np->rx_info[entry].skb = skb; 1599 np->rx_info[entry].skb = skb;
1602 if (skb == NULL) 1600 if (skb == NULL)
1603 break; /* Better luck next round. */ 1601 break; /* Better luck next round. */
1604 np->rx_info[entry].mapping = 1602 np->rx_info[entry].mapping =
1605 pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz, PCI_DMA_FROMDEVICE); 1603 pci_map_single(np->pci_dev, skb->data, np->rx_buf_sz, PCI_DMA_FROMDEVICE);
1606 skb->dev = dev; /* Mark as being used by this device. */
1607 np->rx_ring[entry].rxaddr = 1604 np->rx_ring[entry].rxaddr =
1608 cpu_to_dma(np->rx_info[entry].mapping | RxDescValid); 1605 cpu_to_dma(np->rx_info[entry].mapping | RxDescValid);
1609 } 1606 }
diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c
index d812a103e032..49733696703a 100644
--- a/drivers/net/ethernet/adi/bfin_mac.c
+++ b/drivers/net/ethernet/adi/bfin_mac.c
@@ -113,7 +113,7 @@ static void desc_list_free(void)
113 } 113 }
114} 114}
115 115
116static int desc_list_init(void) 116static int desc_list_init(struct net_device *dev)
117{ 117{
118 int i; 118 int i;
119 struct sk_buff *new_skb; 119 struct sk_buff *new_skb;
@@ -187,7 +187,7 @@ static int desc_list_init(void)
187 struct dma_descriptor *b = &(r->desc_b); 187 struct dma_descriptor *b = &(r->desc_b);
188 188
189 /* allocate a new skb for next time receive */ 189 /* allocate a new skb for next time receive */
190 new_skb = dev_alloc_skb(PKT_BUF_SZ + NET_IP_ALIGN); 190 new_skb = netdev_alloc_skb(dev, PKT_BUF_SZ + NET_IP_ALIGN);
191 if (!new_skb) { 191 if (!new_skb) {
192 pr_notice("init: low on mem - packet dropped\n"); 192 pr_notice("init: low on mem - packet dropped\n");
193 goto init_error; 193 goto init_error;
@@ -1090,7 +1090,7 @@ static void bfin_mac_rx(struct net_device *dev)
1090 /* allocate a new skb for next time receive */ 1090 /* allocate a new skb for next time receive */
1091 skb = current_rx_ptr->skb; 1091 skb = current_rx_ptr->skb;
1092 1092
1093 new_skb = dev_alloc_skb(PKT_BUF_SZ + NET_IP_ALIGN); 1093 new_skb = netdev_alloc_skb(dev, PKT_BUF_SZ + NET_IP_ALIGN);
1094 if (!new_skb) { 1094 if (!new_skb) {
1095 netdev_notice(dev, "rx: low on mem - packet dropped\n"); 1095 netdev_notice(dev, "rx: low on mem - packet dropped\n");
1096 dev->stats.rx_dropped++; 1096 dev->stats.rx_dropped++;
@@ -1397,7 +1397,7 @@ static int bfin_mac_open(struct net_device *dev)
1397 } 1397 }
1398 1398
1399 /* initial rx and tx list */ 1399 /* initial rx and tx list */
1400 ret = desc_list_init(); 1400 ret = desc_list_init(dev);
1401 if (ret) 1401 if (ret)
1402 return ret; 1402 return ret;
1403 1403
@@ -1467,10 +1467,8 @@ static int __devinit bfin_mac_probe(struct platform_device *pdev)
1467 int rc; 1467 int rc;
1468 1468
1469 ndev = alloc_etherdev(sizeof(struct bfin_mac_local)); 1469 ndev = alloc_etherdev(sizeof(struct bfin_mac_local));
1470 if (!ndev) { 1470 if (!ndev)
1471 dev_err(&pdev->dev, "Cannot allocate net device!\n");
1472 return -ENOMEM; 1471 return -ENOMEM;
1473 }
1474 1472
1475 SET_NETDEV_DEV(ndev, &pdev->dev); 1473 SET_NETDEV_DEV(ndev, &pdev->dev);
1476 platform_set_drvdata(pdev, ndev); 1474 platform_set_drvdata(pdev, ndev);
diff --git a/drivers/net/ethernet/aeroflex/greth.c b/drivers/net/ethernet/aeroflex/greth.c
index c885aa905dec..b23751e683c8 100644
--- a/drivers/net/ethernet/aeroflex/greth.c
+++ b/drivers/net/ethernet/aeroflex/greth.c
@@ -785,7 +785,6 @@ static int greth_rx(struct net_device *dev, int limit)
785 785
786 } else { 786 } else {
787 skb_reserve(skb, NET_IP_ALIGN); 787 skb_reserve(skb, NET_IP_ALIGN);
788 skb->dev = dev;
789 788
790 dma_sync_single_for_cpu(greth->dev, 789 dma_sync_single_for_cpu(greth->dev,
791 dma_addr, 790 dma_addr,
diff --git a/drivers/net/ethernet/alteon/acenic.c b/drivers/net/ethernet/alteon/acenic.c
index f872748ab4e6..6c3b1c0adaa0 100644
--- a/drivers/net/ethernet/alteon/acenic.c
+++ b/drivers/net/ethernet/alteon/acenic.c
@@ -463,11 +463,8 @@ static int __devinit acenic_probe_one(struct pci_dev *pdev,
463 static int boards_found; 463 static int boards_found;
464 464
465 dev = alloc_etherdev(sizeof(struct ace_private)); 465 dev = alloc_etherdev(sizeof(struct ace_private));
466 if (dev == NULL) { 466 if (dev == NULL)
467 printk(KERN_ERR "acenic: Unable to allocate "
468 "net_device structure!\n");
469 return -ENOMEM; 467 return -ENOMEM;
470 }
471 468
472 SET_NETDEV_DEV(dev, &pdev->dev); 469 SET_NETDEV_DEV(dev, &pdev->dev);
473 470
diff --git a/drivers/net/ethernet/amd/7990.c b/drivers/net/ethernet/amd/7990.c
index 60b35fb5f524..1b046f58d58f 100644
--- a/drivers/net/ethernet/amd/7990.c
+++ b/drivers/net/ethernet/amd/7990.c
@@ -316,7 +316,7 @@ static int lance_rx (struct net_device *dev)
316 if (bits & LE_R1_EOP) dev->stats.rx_errors++; 316 if (bits & LE_R1_EOP) dev->stats.rx_errors++;
317 } else { 317 } else {
318 int len = (rd->mblength & 0xfff) - 4; 318 int len = (rd->mblength & 0xfff) - 4;
319 struct sk_buff *skb = dev_alloc_skb (len+2); 319 struct sk_buff *skb = netdev_alloc_skb(dev, len + 2);
320 320
321 if (!skb) { 321 if (!skb) {
322 printk ("%s: Memory squeeze, deferring packet.\n", 322 printk ("%s: Memory squeeze, deferring packet.\n",
diff --git a/drivers/net/ethernet/amd/Kconfig b/drivers/net/ethernet/amd/Kconfig
index 238b537b68fe..8350f4b37a8a 100644
--- a/drivers/net/ethernet/amd/Kconfig
+++ b/drivers/net/ethernet/amd/Kconfig
@@ -113,7 +113,7 @@ config DEPCA
113 If you have a network (Ethernet) card of this type, say Y and read 113 If you have a network (Ethernet) card of this type, say Y and read
114 the Ethernet-HOWTO, available from 114 the Ethernet-HOWTO, available from
115 <http://www.tldp.org/docs.html#howto> as well as 115 <http://www.tldp.org/docs.html#howto> as well as
116 <file:drivers/net/depca.c>. 116 <file:drivers/net/ethernet/amd/depca.c>.
117 117
118 To compile this driver as a module, choose M here. The module 118 To compile this driver as a module, choose M here. The module
119 will be called depca. 119 will be called depca.
diff --git a/drivers/net/ethernet/amd/a2065.c b/drivers/net/ethernet/amd/a2065.c
index 825e5d4ef4c3..689dfcafc6d4 100644
--- a/drivers/net/ethernet/amd/a2065.c
+++ b/drivers/net/ethernet/amd/a2065.c
@@ -290,7 +290,7 @@ static int lance_rx(struct net_device *dev)
290 dev->stats.rx_errors++; 290 dev->stats.rx_errors++;
291 } else { 291 } else {
292 int len = (rd->mblength & 0xfff) - 4; 292 int len = (rd->mblength & 0xfff) - 4;
293 struct sk_buff *skb = dev_alloc_skb(len + 2); 293 struct sk_buff *skb = netdev_alloc_skb(dev, len + 2);
294 294
295 if (!skb) { 295 if (!skb) {
296 netdev_warn(dev, "Memory squeeze, deferring packet\n"); 296 netdev_warn(dev, "Memory squeeze, deferring packet\n");
diff --git a/drivers/net/ethernet/amd/am79c961a.c b/drivers/net/ethernet/amd/am79c961a.c
index 7d5ded80d2d7..cc7b9e46780c 100644
--- a/drivers/net/ethernet/amd/am79c961a.c
+++ b/drivers/net/ethernet/amd/am79c961a.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/net/am79c961.c 2 * linux/drivers/net/ethernet/amd/am79c961a.c
3 * 3 *
4 * by Russell King <rmk@arm.linux.org.uk> 1995-2001. 4 * by Russell King <rmk@arm.linux.org.uk> 1995-2001.
5 * 5 *
@@ -516,7 +516,7 @@ am79c961_rx(struct net_device *dev, struct dev_priv *priv)
516 } 516 }
517 517
518 len = am_readword(dev, hdraddr + 6); 518 len = am_readword(dev, hdraddr + 6);
519 skb = dev_alloc_skb(len + 2); 519 skb = netdev_alloc_skb(dev, len + 2);
520 520
521 if (skb) { 521 if (skb) {
522 skb_reserve(skb, 2); 522 skb_reserve(skb, 2);
diff --git a/drivers/net/ethernet/amd/am79c961a.h b/drivers/net/ethernet/amd/am79c961a.h
index fd634d32756b..9f384b79507b 100644
--- a/drivers/net/ethernet/amd/am79c961a.h
+++ b/drivers/net/ethernet/amd/am79c961a.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/net/arm/am79c961a.h 2 * linux/drivers/net/ethernet/amd/am79c961a.h
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
diff --git a/drivers/net/ethernet/amd/amd8111e.c b/drivers/net/ethernet/amd/amd8111e.c
index 33e0a8c20f6b..9f62504d0086 100644
--- a/drivers/net/ethernet/amd/amd8111e.c
+++ b/drivers/net/ethernet/amd/amd8111e.c
@@ -336,7 +336,8 @@ static int amd8111e_init_ring(struct net_device *dev)
336 /* Allocating receive skbs */ 336 /* Allocating receive skbs */
337 for (i = 0; i < NUM_RX_BUFFERS; i++) { 337 for (i = 0; i < NUM_RX_BUFFERS; i++) {
338 338
339 if (!(lp->rx_skbuff[i] = dev_alloc_skb(lp->rx_buff_len))) { 339 lp->rx_skbuff[i] = netdev_alloc_skb(dev, lp->rx_buff_len);
340 if (!lp->rx_skbuff[i]) {
340 /* Release previos allocated skbs */ 341 /* Release previos allocated skbs */
341 for(--i; i >= 0 ;i--) 342 for(--i; i >= 0 ;i--)
342 dev_kfree_skb(lp->rx_skbuff[i]); 343 dev_kfree_skb(lp->rx_skbuff[i]);
@@ -768,7 +769,8 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget)
768 } 769 }
769 if(--rx_pkt_limit < 0) 770 if(--rx_pkt_limit < 0)
770 goto rx_not_empty; 771 goto rx_not_empty;
771 if(!(new_skb = dev_alloc_skb(lp->rx_buff_len))){ 772 new_skb = netdev_alloc_skb(dev, lp->rx_buff_len);
773 if (!new_skb) {
772 /* if allocation fail, 774 /* if allocation fail,
773 ignore that pkt and go to next one */ 775 ignore that pkt and go to next one */
774 lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; 776 lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS;
@@ -1859,7 +1861,6 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
1859 1861
1860 dev = alloc_etherdev(sizeof(struct amd8111e_priv)); 1862 dev = alloc_etherdev(sizeof(struct amd8111e_priv));
1861 if (!dev) { 1863 if (!dev) {
1862 printk(KERN_ERR "amd8111e: Etherdev alloc failed, exiting.\n");
1863 err = -ENOMEM; 1864 err = -ENOMEM;
1864 goto err_free_reg; 1865 goto err_free_reg;
1865 } 1866 }
diff --git a/drivers/net/ethernet/amd/ariadne.c b/drivers/net/ethernet/amd/ariadne.c
index eb18e1fe65c8..f4c228e4d76c 100644
--- a/drivers/net/ethernet/amd/ariadne.c
+++ b/drivers/net/ethernet/amd/ariadne.c
@@ -191,7 +191,7 @@ static int ariadne_rx(struct net_device *dev)
191 short pkt_len = swapw(priv->rx_ring[entry]->RMD3); 191 short pkt_len = swapw(priv->rx_ring[entry]->RMD3);
192 struct sk_buff *skb; 192 struct sk_buff *skb;
193 193
194 skb = dev_alloc_skb(pkt_len + 2); 194 skb = netdev_alloc_skb(dev, pkt_len + 2);
195 if (skb == NULL) { 195 if (skb == NULL) {
196 netdev_warn(dev, "Memory squeeze, deferring packet\n"); 196 netdev_warn(dev, "Memory squeeze, deferring packet\n");
197 for (i = 0; i < RX_RING_SIZE; i++) 197 for (i = 0; i < RX_RING_SIZE; i++)
diff --git a/drivers/net/ethernet/amd/atarilance.c b/drivers/net/ethernet/amd/atarilance.c
index 15bfa28d6c53..70ed79c46245 100644
--- a/drivers/net/ethernet/amd/atarilance.c
+++ b/drivers/net/ethernet/amd/atarilance.c
@@ -997,7 +997,7 @@ static int lance_rx( struct net_device *dev )
997 dev->stats.rx_errors++; 997 dev->stats.rx_errors++;
998 } 998 }
999 else { 999 else {
1000 skb = dev_alloc_skb( pkt_len+2 ); 1000 skb = netdev_alloc_skb(dev, pkt_len + 2);
1001 if (skb == NULL) { 1001 if (skb == NULL) {
1002 DPRINTK( 1, ( "%s: Memory squeeze, deferring packet.\n", 1002 DPRINTK( 1, ( "%s: Memory squeeze, deferring packet.\n",
1003 dev->name )); 1003 dev->name ));
diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index 8b95dd314253..c1dfdc8b7079 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -725,7 +725,7 @@ static int au1000_rx(struct net_device *dev)
725 /* good frame */ 725 /* good frame */
726 frmlen = (status & RX_FRAME_LEN_MASK); 726 frmlen = (status & RX_FRAME_LEN_MASK);
727 frmlen -= 4; /* Remove FCS */ 727 frmlen -= 4; /* Remove FCS */
728 skb = dev_alloc_skb(frmlen + 2); 728 skb = netdev_alloc_skb(dev, frmlen + 2);
729 if (skb == NULL) { 729 if (skb == NULL) {
730 netdev_err(dev, "Memory squeeze, dropping packet.\n"); 730 netdev_err(dev, "Memory squeeze, dropping packet.\n");
731 dev->stats.rx_dropped++; 731 dev->stats.rx_dropped++;
@@ -1077,7 +1077,6 @@ static int __devinit au1000_probe(struct platform_device *pdev)
1077 1077
1078 dev = alloc_etherdev(sizeof(struct au1000_private)); 1078 dev = alloc_etherdev(sizeof(struct au1000_private));
1079 if (!dev) { 1079 if (!dev) {
1080 dev_err(&pdev->dev, "alloc_etherdev failed\n");
1081 err = -ENOMEM; 1080 err = -ENOMEM;
1082 goto err_alloc; 1081 goto err_alloc;
1083 } 1082 }
diff --git a/drivers/net/ethernet/amd/declance.c b/drivers/net/ethernet/amd/declance.c
index 73f8d4fa682d..7dc508e5c72e 100644
--- a/drivers/net/ethernet/amd/declance.c
+++ b/drivers/net/ethernet/amd/declance.c
@@ -605,7 +605,7 @@ static int lance_rx(struct net_device *dev)
605 dev->stats.rx_errors++; 605 dev->stats.rx_errors++;
606 } else { 606 } else {
607 len = (*rds_ptr(rd, mblength, lp->type) & 0xfff) - 4; 607 len = (*rds_ptr(rd, mblength, lp->type) & 0xfff) - 4;
608 skb = dev_alloc_skb(len + 2); 608 skb = netdev_alloc_skb(dev, len + 2);
609 609
610 if (skb == 0) { 610 if (skb == 0) {
611 printk("%s: Memory squeeze, deferring packet.\n", 611 printk("%s: Memory squeeze, deferring packet.\n",
@@ -1052,8 +1052,6 @@ static int __devinit dec_lance_probe(struct device *bdev, const int type)
1052 1052
1053 dev = alloc_etherdev(sizeof(struct lance_private)); 1053 dev = alloc_etherdev(sizeof(struct lance_private));
1054 if (!dev) { 1054 if (!dev) {
1055 printk(KERN_ERR "%s: Unable to allocate etherdev, aborting.\n",
1056 name);
1057 ret = -ENOMEM; 1055 ret = -ENOMEM;
1058 goto err_out; 1056 goto err_out;
1059 } 1057 }
diff --git a/drivers/net/ethernet/amd/depca.c b/drivers/net/ethernet/amd/depca.c
index 681970c07f22..86dd95766a64 100644
--- a/drivers/net/ethernet/amd/depca.c
+++ b/drivers/net/ethernet/amd/depca.c
@@ -1042,7 +1042,7 @@ static int depca_rx(struct net_device *dev)
1042 short len, pkt_len = readw(&lp->rx_ring[entry].msg_length) - 4; 1042 short len, pkt_len = readw(&lp->rx_ring[entry].msg_length) - 4;
1043 struct sk_buff *skb; 1043 struct sk_buff *skb;
1044 1044
1045 skb = dev_alloc_skb(pkt_len + 2); 1045 skb = netdev_alloc_skb(dev, pkt_len + 2);
1046 if (skb != NULL) { 1046 if (skb != NULL) {
1047 unsigned char *buf; 1047 unsigned char *buf;
1048 skb_reserve(skb, 2); /* 16 byte align the IP header */ 1048 skb_reserve(skb, 2); /* 16 byte align the IP header */
diff --git a/drivers/net/ethernet/amd/ni65.c b/drivers/net/ethernet/amd/ni65.c
index 6e6aa7213aab..013b65108536 100644
--- a/drivers/net/ethernet/amd/ni65.c
+++ b/drivers/net/ethernet/amd/ni65.c
@@ -621,10 +621,8 @@ static void *ni65_alloc_mem(struct net_device *dev,char *what,int size,int type)
621 } 621 }
622 else { 622 else {
623 ret = ptr = kmalloc(T_BUF_SIZE,GFP_KERNEL | GFP_DMA); 623 ret = ptr = kmalloc(T_BUF_SIZE,GFP_KERNEL | GFP_DMA);
624 if(!ret) { 624 if(!ret)
625 printk(KERN_WARNING "%s: unable to allocate %s memory.\n",dev->name,what);
626 return NULL; 625 return NULL;
627 }
628 } 626 }
629 if( (u32) virt_to_phys(ptr+size) > 0x1000000) { 627 if( (u32) virt_to_phys(ptr+size) > 0x1000000) {
630 printk(KERN_WARNING "%s: unable to allocate %s memory in lower 16MB!\n",dev->name,what); 628 printk(KERN_WARNING "%s: unable to allocate %s memory in lower 16MB!\n",dev->name,what);
@@ -1091,7 +1089,7 @@ static void ni65_recv_intr(struct net_device *dev,int csr0)
1091 if (skb) 1089 if (skb)
1092 skb_reserve(skb,16); 1090 skb_reserve(skb,16);
1093#else 1091#else
1094 struct sk_buff *skb = dev_alloc_skb(len+2); 1092 struct sk_buff *skb = netdev_alloc_skb(dev, len + 2);
1095#endif 1093#endif
1096 if(skb) 1094 if(skb)
1097 { 1095 {
diff --git a/drivers/net/ethernet/amd/nmclan_cs.c b/drivers/net/ethernet/amd/nmclan_cs.c
index 6be0dd67631a..ebdb9e238a8d 100644
--- a/drivers/net/ethernet/amd/nmclan_cs.c
+++ b/drivers/net/ethernet/amd/nmclan_cs.c
@@ -1104,7 +1104,7 @@ static int mace_rx(struct net_device *dev, unsigned char RxCnt)
1104 pr_debug(" receiving packet size 0x%X rx_status" 1104 pr_debug(" receiving packet size 0x%X rx_status"
1105 " 0x%X.\n", pkt_len, rx_status); 1105 " 0x%X.\n", pkt_len, rx_status);
1106 1106
1107 skb = dev_alloc_skb(pkt_len+2); 1107 skb = netdev_alloc_skb(dev, pkt_len + 2);
1108 1108
1109 if (skb != NULL) { 1109 if (skb != NULL) {
1110 skb_reserve(skb, 2); 1110 skb_reserve(skb, 2);
diff --git a/drivers/net/ethernet/amd/pcnet32.c b/drivers/net/ethernet/amd/pcnet32.c
index 20e6dab0186c..86b6d8e4e6cd 100644
--- a/drivers/net/ethernet/amd/pcnet32.c
+++ b/drivers/net/ethernet/amd/pcnet32.c
@@ -588,11 +588,11 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev,
588 /* now allocate any new buffers needed */ 588 /* now allocate any new buffers needed */
589 for (; new < size; new++) { 589 for (; new < size; new++) {
590 struct sk_buff *rx_skbuff; 590 struct sk_buff *rx_skbuff;
591 new_skb_list[new] = dev_alloc_skb(PKT_BUF_SKB); 591 new_skb_list[new] = netdev_alloc_skb(dev, PKT_BUF_SKB);
592 rx_skbuff = new_skb_list[new]; 592 rx_skbuff = new_skb_list[new];
593 if (!rx_skbuff) { 593 if (!rx_skbuff) {
594 /* keep the original lists and buffers */ 594 /* keep the original lists and buffers */
595 netif_err(lp, drv, dev, "%s dev_alloc_skb failed\n", 595 netif_err(lp, drv, dev, "%s netdev_alloc_skb failed\n",
596 __func__); 596 __func__);
597 goto free_all_new; 597 goto free_all_new;
598 } 598 }
@@ -909,7 +909,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
909 /* Initialize Transmit buffers. */ 909 /* Initialize Transmit buffers. */
910 size = data_len + 15; 910 size = data_len + 15;
911 for (x = 0; x < numbuffs; x++) { 911 for (x = 0; x < numbuffs; x++) {
912 skb = dev_alloc_skb(size); 912 skb = netdev_alloc_skb(dev, size);
913 if (!skb) { 913 if (!skb) {
914 netif_printk(lp, hw, KERN_DEBUG, dev, 914 netif_printk(lp, hw, KERN_DEBUG, dev,
915 "Cannot allocate skb at line: %d!\n", 915 "Cannot allocate skb at line: %d!\n",
@@ -1152,7 +1152,7 @@ static void pcnet32_rx_entry(struct net_device *dev,
1152 if (pkt_len > rx_copybreak) { 1152 if (pkt_len > rx_copybreak) {
1153 struct sk_buff *newskb; 1153 struct sk_buff *newskb;
1154 1154
1155 newskb = dev_alloc_skb(PKT_BUF_SKB); 1155 newskb = netdev_alloc_skb(dev, PKT_BUF_SKB);
1156 if (newskb) { 1156 if (newskb) {
1157 skb_reserve(newskb, NET_IP_ALIGN); 1157 skb_reserve(newskb, NET_IP_ALIGN);
1158 skb = lp->rx_skbuff[entry]; 1158 skb = lp->rx_skbuff[entry];
@@ -1172,7 +1172,7 @@ static void pcnet32_rx_entry(struct net_device *dev,
1172 } else 1172 } else
1173 skb = NULL; 1173 skb = NULL;
1174 } else 1174 } else
1175 skb = dev_alloc_skb(pkt_len + NET_IP_ALIGN); 1175 skb = netdev_alloc_skb(dev, pkt_len + NET_IP_ALIGN);
1176 1176
1177 if (skb == NULL) { 1177 if (skb == NULL) {
1178 netif_err(lp, drv, dev, "Memory squeeze, dropping packet\n"); 1178 netif_err(lp, drv, dev, "Memory squeeze, dropping packet\n");
@@ -1649,8 +1649,6 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1649 1649
1650 dev = alloc_etherdev(sizeof(*lp)); 1650 dev = alloc_etherdev(sizeof(*lp));
1651 if (!dev) { 1651 if (!dev) {
1652 if (pcnet32_debug & NETIF_MSG_PROBE)
1653 pr_err("Memory allocation failed\n");
1654 ret = -ENOMEM; 1652 ret = -ENOMEM;
1655 goto err_release_region; 1653 goto err_release_region;
1656 } 1654 }
@@ -2273,11 +2271,11 @@ static int pcnet32_init_ring(struct net_device *dev)
2273 for (i = 0; i < lp->rx_ring_size; i++) { 2271 for (i = 0; i < lp->rx_ring_size; i++) {
2274 struct sk_buff *rx_skbuff = lp->rx_skbuff[i]; 2272 struct sk_buff *rx_skbuff = lp->rx_skbuff[i];
2275 if (rx_skbuff == NULL) { 2273 if (rx_skbuff == NULL) {
2276 lp->rx_skbuff[i] = dev_alloc_skb(PKT_BUF_SKB); 2274 lp->rx_skbuff[i] = netdev_alloc_skb(dev, PKT_BUF_SKB);
2277 rx_skbuff = lp->rx_skbuff[i]; 2275 rx_skbuff = lp->rx_skbuff[i];
2278 if (!rx_skbuff) { 2276 if (!rx_skbuff) {
2279 /* there is not much we can do at this point */ 2277 /* there is not much we can do at this point */
2280 netif_err(lp, drv, dev, "%s dev_alloc_skb failed\n", 2278 netif_err(lp, drv, dev, "%s netdev_alloc_skb failed\n",
2281 __func__); 2279 __func__);
2282 return -1; 2280 return -1;
2283 } 2281 }
diff --git a/drivers/net/ethernet/amd/sun3lance.c b/drivers/net/ethernet/amd/sun3lance.c
index 080b71fcc683..74b3891b6483 100644
--- a/drivers/net/ethernet/amd/sun3lance.c
+++ b/drivers/net/ethernet/amd/sun3lance.c
@@ -810,7 +810,7 @@ static int lance_rx( struct net_device *dev )
810 dev->stats.rx_errors++; 810 dev->stats.rx_errors++;
811 } 811 }
812 else { 812 else {
813 skb = dev_alloc_skb( pkt_len+2 ); 813 skb = netdev_alloc_skb(dev, pkt_len + 2);
814 if (skb == NULL) { 814 if (skb == NULL) {
815 DPRINTK( 1, ( "%s: Memory squeeze, deferring packet.\n", 815 DPRINTK( 1, ( "%s: Memory squeeze, deferring packet.\n",
816 dev->name )); 816 dev->name ));
diff --git a/drivers/net/ethernet/amd/sunlance.c b/drivers/net/ethernet/amd/sunlance.c
index 7ea16d32a5f5..e3fe3504e198 100644
--- a/drivers/net/ethernet/amd/sunlance.c
+++ b/drivers/net/ethernet/amd/sunlance.c
@@ -534,7 +534,7 @@ static void lance_rx_dvma(struct net_device *dev)
534 if (bits & LE_R1_EOP) dev->stats.rx_errors++; 534 if (bits & LE_R1_EOP) dev->stats.rx_errors++;
535 } else { 535 } else {
536 len = (rd->mblength & 0xfff) - 4; 536 len = (rd->mblength & 0xfff) - 4;
537 skb = dev_alloc_skb(len + 2); 537 skb = netdev_alloc_skb(dev, len + 2);
538 538
539 if (skb == NULL) { 539 if (skb == NULL) {
540 printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n", 540 printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n",
@@ -706,7 +706,7 @@ static void lance_rx_pio(struct net_device *dev)
706 if (bits & LE_R1_EOP) dev->stats.rx_errors++; 706 if (bits & LE_R1_EOP) dev->stats.rx_errors++;
707 } else { 707 } else {
708 len = (sbus_readw(&rd->mblength) & 0xfff) - 4; 708 len = (sbus_readw(&rd->mblength) & 0xfff) - 4;
709 skb = dev_alloc_skb(len + 2); 709 skb = netdev_alloc_skb(dev, len + 2);
710 710
711 if (skb == NULL) { 711 if (skb == NULL) {
712 printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n", 712 printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n",
diff --git a/drivers/net/ethernet/apple/bmac.c b/drivers/net/ethernet/apple/bmac.c
index d070b229dbf7..855bdafb1a87 100644
--- a/drivers/net/ethernet/apple/bmac.c
+++ b/drivers/net/ethernet/apple/bmac.c
@@ -607,8 +607,9 @@ bmac_init_tx_ring(struct bmac_data *bp)
607} 607}
608 608
609static int 609static int
610bmac_init_rx_ring(struct bmac_data *bp) 610bmac_init_rx_ring(struct net_device *dev)
611{ 611{
612 struct bmac_data *bp = netdev_priv(dev);
612 volatile struct dbdma_regs __iomem *rd = bp->rx_dma; 613 volatile struct dbdma_regs __iomem *rd = bp->rx_dma;
613 int i; 614 int i;
614 struct sk_buff *skb; 615 struct sk_buff *skb;
@@ -618,7 +619,7 @@ bmac_init_rx_ring(struct bmac_data *bp)
618 (N_RX_RING + 1) * sizeof(struct dbdma_cmd)); 619 (N_RX_RING + 1) * sizeof(struct dbdma_cmd));
619 for (i = 0; i < N_RX_RING; i++) { 620 for (i = 0; i < N_RX_RING; i++) {
620 if ((skb = bp->rx_bufs[i]) == NULL) { 621 if ((skb = bp->rx_bufs[i]) == NULL) {
621 bp->rx_bufs[i] = skb = dev_alloc_skb(RX_BUFLEN+2); 622 bp->rx_bufs[i] = skb = netdev_alloc_skb(dev, RX_BUFLEN + 2);
622 if (skb != NULL) 623 if (skb != NULL)
623 skb_reserve(skb, 2); 624 skb_reserve(skb, 2);
624 } 625 }
@@ -722,7 +723,7 @@ static irqreturn_t bmac_rxdma_intr(int irq, void *dev_id)
722 ++dev->stats.rx_dropped; 723 ++dev->stats.rx_dropped;
723 } 724 }
724 if ((skb = bp->rx_bufs[i]) == NULL) { 725 if ((skb = bp->rx_bufs[i]) == NULL) {
725 bp->rx_bufs[i] = skb = dev_alloc_skb(RX_BUFLEN+2); 726 bp->rx_bufs[i] = skb = netdev_alloc_skb(dev, RX_BUFLEN + 2);
726 if (skb != NULL) 727 if (skb != NULL)
727 skb_reserve(bp->rx_bufs[i], 2); 728 skb_reserve(bp->rx_bufs[i], 2);
728 } 729 }
@@ -1208,7 +1209,7 @@ static void bmac_reset_and_enable(struct net_device *dev)
1208 spin_lock_irqsave(&bp->lock, flags); 1209 spin_lock_irqsave(&bp->lock, flags);
1209 bmac_enable_and_reset_chip(dev); 1210 bmac_enable_and_reset_chip(dev);
1210 bmac_init_tx_ring(bp); 1211 bmac_init_tx_ring(bp);
1211 bmac_init_rx_ring(bp); 1212 bmac_init_rx_ring(dev);
1212 bmac_init_chip(dev); 1213 bmac_init_chip(dev);
1213 bmac_start_chip(dev); 1214 bmac_start_chip(dev);
1214 bmwrite(dev, INTDISABLE, EnableNormal); 1215 bmwrite(dev, INTDISABLE, EnableNormal);
@@ -1218,7 +1219,7 @@ static void bmac_reset_and_enable(struct net_device *dev)
1218 * It seems that the bmac can't receive until it's transmitted 1219 * It seems that the bmac can't receive until it's transmitted
1219 * a packet. So we give it a dummy packet to transmit. 1220 * a packet. So we give it a dummy packet to transmit.
1220 */ 1221 */
1221 skb = dev_alloc_skb(ETHERMINPACKET); 1222 skb = netdev_alloc_skb(dev, ETHERMINPACKET);
1222 if (skb != NULL) { 1223 if (skb != NULL) {
1223 data = skb_put(skb, ETHERMINPACKET); 1224 data = skb_put(skb, ETHERMINPACKET);
1224 memset(data, 0, ETHERMINPACKET); 1225 memset(data, 0, ETHERMINPACKET);
@@ -1269,10 +1270,8 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i
1269 memcpy(addr, prop_addr, sizeof(addr)); 1270 memcpy(addr, prop_addr, sizeof(addr));
1270 1271
1271 dev = alloc_etherdev(PRIV_BYTES); 1272 dev = alloc_etherdev(PRIV_BYTES);
1272 if (!dev) { 1273 if (!dev)
1273 printk(KERN_ERR "BMAC: alloc_etherdev failed, out of memory\n");
1274 return -ENOMEM; 1274 return -ENOMEM;
1275 }
1276 1275
1277 bp = netdev_priv(dev); 1276 bp = netdev_priv(dev);
1278 SET_NETDEV_DEV(dev, &mdev->ofdev.dev); 1277 SET_NETDEV_DEV(dev, &mdev->ofdev.dev);
@@ -1660,10 +1659,8 @@ static int __init bmac_init(void)
1660{ 1659{
1661 if (bmac_emergency_rxbuf == NULL) { 1660 if (bmac_emergency_rxbuf == NULL) {
1662 bmac_emergency_rxbuf = kmalloc(RX_BUFLEN, GFP_KERNEL); 1661 bmac_emergency_rxbuf = kmalloc(RX_BUFLEN, GFP_KERNEL);
1663 if (bmac_emergency_rxbuf == NULL) { 1662 if (bmac_emergency_rxbuf == NULL)
1664 printk(KERN_ERR "BMAC: can't allocate emergency RX buffer\n");
1665 return -ENOMEM; 1663 return -ENOMEM;
1666 }
1667 } 1664 }
1668 1665
1669 return macio_register_driver(&bmac_driver); 1666 return macio_register_driver(&bmac_driver);
diff --git a/drivers/net/ethernet/apple/mace.c b/drivers/net/ethernet/apple/mace.c
index bec87bd9195c..e1df4b76c885 100644
--- a/drivers/net/ethernet/apple/mace.c
+++ b/drivers/net/ethernet/apple/mace.c
@@ -136,10 +136,8 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
136 */ 136 */
137 if (dummy_buf == NULL) { 137 if (dummy_buf == NULL) {
138 dummy_buf = kmalloc(RX_BUFLEN+2, GFP_KERNEL); 138 dummy_buf = kmalloc(RX_BUFLEN+2, GFP_KERNEL);
139 if (dummy_buf == NULL) { 139 if (dummy_buf == NULL)
140 printk(KERN_ERR "MACE: couldn't allocate dummy buffer\n");
141 return -ENOMEM; 140 return -ENOMEM;
142 }
143 } 141 }
144 142
145 if (macio_request_resources(mdev, "mace")) { 143 if (macio_request_resources(mdev, "mace")) {
@@ -149,7 +147,6 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
149 147
150 dev = alloc_etherdev(PRIV_BYTES); 148 dev = alloc_etherdev(PRIV_BYTES);
151 if (!dev) { 149 if (!dev) {
152 printk(KERN_ERR "MACE: can't allocate ethernet device !\n");
153 rc = -ENOMEM; 150 rc = -ENOMEM;
154 goto err_release; 151 goto err_release;
155 } 152 }
@@ -447,7 +444,7 @@ static int mace_open(struct net_device *dev)
447 memset((char *)mp->rx_cmds, 0, N_RX_RING * sizeof(struct dbdma_cmd)); 444 memset((char *)mp->rx_cmds, 0, N_RX_RING * sizeof(struct dbdma_cmd));
448 cp = mp->rx_cmds; 445 cp = mp->rx_cmds;
449 for (i = 0; i < N_RX_RING - 1; ++i) { 446 for (i = 0; i < N_RX_RING - 1; ++i) {
450 skb = dev_alloc_skb(RX_BUFLEN + 2); 447 skb = netdev_alloc_skb(dev, RX_BUFLEN + 2);
451 if (!skb) { 448 if (!skb) {
452 data = dummy_buf; 449 data = dummy_buf;
453 } else { 450 } else {
@@ -959,7 +956,7 @@ static irqreturn_t mace_rxdma_intr(int irq, void *dev_id)
959 cp = mp->rx_cmds + i; 956 cp = mp->rx_cmds + i;
960 skb = mp->rx_bufs[i]; 957 skb = mp->rx_bufs[i];
961 if (!skb) { 958 if (!skb) {
962 skb = dev_alloc_skb(RX_BUFLEN + 2); 959 skb = netdev_alloc_skb(dev, RX_BUFLEN + 2);
963 if (skb) { 960 if (skb) {
964 skb_reserve(skb, 2); 961 skb_reserve(skb, 2);
965 mp->rx_bufs[i] = skb; 962 mp->rx_bufs[i] = skb;
diff --git a/drivers/net/ethernet/apple/macmace.c b/drivers/net/ethernet/apple/macmace.c
index 7cf81bbffe0e..ab7ff8645ab1 100644
--- a/drivers/net/ethernet/apple/macmace.c
+++ b/drivers/net/ethernet/apple/macmace.c
@@ -661,7 +661,7 @@ static void mace_dma_rx_frame(struct net_device *dev, struct mace_frame *mf)
661 } else { 661 } else {
662 unsigned int frame_length = mf->rcvcnt + ((frame_status & 0x0F) << 8 ); 662 unsigned int frame_length = mf->rcvcnt + ((frame_status & 0x0F) << 8 );
663 663
664 skb = dev_alloc_skb(frame_length + 2); 664 skb = netdev_alloc_skb(dev, frame_length + 2);
665 if (!skb) { 665 if (!skb) {
666 dev->stats.rx_dropped++; 666 dev->stats.rx_dropped++;
667 return; 667 return;
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index b8591246eb4c..2c8ed70704aa 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -1765,7 +1765,7 @@ static int atl1c_alloc_rx_buffer(struct atl1c_adapter *adapter, const int ringid
1765 while (next_info->flags & ATL1C_BUFFER_FREE) { 1765 while (next_info->flags & ATL1C_BUFFER_FREE) {
1766 rfd_desc = ATL1C_RFD_DESC(rfd_ring, rfd_next_to_use); 1766 rfd_desc = ATL1C_RFD_DESC(rfd_ring, rfd_next_to_use);
1767 1767
1768 skb = dev_alloc_skb(adapter->rx_buffer_len); 1768 skb = netdev_alloc_skb(adapter->netdev, adapter->rx_buffer_len);
1769 if (unlikely(!skb)) { 1769 if (unlikely(!skb)) {
1770 if (netif_msg_rx_err(adapter)) 1770 if (netif_msg_rx_err(adapter))
1771 dev_warn(&pdev->dev, "alloc rx buffer failed\n"); 1771 dev_warn(&pdev->dev, "alloc rx buffer failed\n");
@@ -2689,7 +2689,6 @@ static int __devinit atl1c_probe(struct pci_dev *pdev,
2689 netdev = alloc_etherdev(sizeof(struct atl1c_adapter)); 2689 netdev = alloc_etherdev(sizeof(struct atl1c_adapter));
2690 if (netdev == NULL) { 2690 if (netdev == NULL) {
2691 err = -ENOMEM; 2691 err = -ENOMEM;
2692 dev_err(&pdev->dev, "etherdev alloc failed\n");
2693 goto err_alloc_etherdev; 2692 goto err_alloc_etherdev;
2694 } 2693 }
2695 2694
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
index c915c0873810..93ff2b231284 100644
--- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
+++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
@@ -2300,7 +2300,6 @@ static int __devinit atl1e_probe(struct pci_dev *pdev,
2300 netdev = alloc_etherdev(sizeof(struct atl1e_adapter)); 2300 netdev = alloc_etherdev(sizeof(struct atl1e_adapter));
2301 if (netdev == NULL) { 2301 if (netdev == NULL) {
2302 err = -ENOMEM; 2302 err = -ENOMEM;
2303 dev_err(&pdev->dev, "etherdev alloc failed\n");
2304 goto err_alloc_etherdev; 2303 goto err_alloc_etherdev;
2305 } 2304 }
2306 2305
diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index 3fb66d09ece5..66f53c797e3a 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -2138,7 +2138,6 @@ static int __devinit b44_init_one(struct ssb_device *sdev,
2138 2138
2139 dev = alloc_etherdev(sizeof(*bp)); 2139 dev = alloc_etherdev(sizeof(*bp));
2140 if (!dev) { 2140 if (!dev) {
2141 dev_err(sdev->dev, "Etherdev alloc failed, aborting\n");
2142 err = -ENOMEM; 2141 err = -ENOMEM;
2143 goto out; 2142 goto out;
2144 } 2143 }
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index 021fb818007a..7105989ba658 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -2625,10 +2625,8 @@ bnx2_alloc_bad_rbuf(struct bnx2 *bp)
2625 u32 val; 2625 u32 val;
2626 2626
2627 good_mbuf = kmalloc(512 * sizeof(u16), GFP_KERNEL); 2627 good_mbuf = kmalloc(512 * sizeof(u16), GFP_KERNEL);
2628 if (good_mbuf == NULL) { 2628 if (good_mbuf == NULL)
2629 pr_err("Failed to allocate memory in %s\n", __func__);
2630 return -ENOMEM; 2629 return -ENOMEM;
2631 }
2632 2630
2633 REG_WR(bp, BNX2_MISC_ENABLE_SET_BITS, 2631 REG_WR(bp, BNX2_MISC_ENABLE_SET_BITS,
2634 BNX2_MISC_ENABLE_SET_BITS_RX_MBUF_ENABLE); 2632 BNX2_MISC_ENABLE_SET_BITS_RX_MBUF_ENABLE);
@@ -6248,7 +6246,16 @@ static int
6248bnx2_setup_int_mode(struct bnx2 *bp, int dis_msi) 6246bnx2_setup_int_mode(struct bnx2 *bp, int dis_msi)
6249{ 6247{
6250 int cpus = num_online_cpus(); 6248 int cpus = num_online_cpus();
6251 int msix_vecs = min(cpus + 1, RX_MAX_RINGS); 6249 int msix_vecs;
6250
6251 if (!bp->num_req_rx_rings)
6252 msix_vecs = max(cpus + 1, bp->num_req_tx_rings);
6253 else if (!bp->num_req_tx_rings)
6254 msix_vecs = max(cpus, bp->num_req_rx_rings);
6255 else
6256 msix_vecs = max(bp->num_req_rx_rings, bp->num_req_tx_rings);
6257
6258 msix_vecs = min(msix_vecs, RX_MAX_RINGS);
6252 6259
6253 bp->irq_tbl[0].handler = bnx2_interrupt; 6260 bp->irq_tbl[0].handler = bnx2_interrupt;
6254 strcpy(bp->irq_tbl[0].name, bp->dev->name); 6261 strcpy(bp->irq_tbl[0].name, bp->dev->name);
@@ -6272,10 +6279,18 @@ bnx2_setup_int_mode(struct bnx2 *bp, int dis_msi)
6272 } 6279 }
6273 } 6280 }
6274 6281
6275 bp->num_tx_rings = rounddown_pow_of_two(bp->irq_nvecs); 6282 if (!bp->num_req_tx_rings)
6283 bp->num_tx_rings = rounddown_pow_of_two(bp->irq_nvecs);
6284 else
6285 bp->num_tx_rings = min(bp->irq_nvecs, bp->num_req_tx_rings);
6286
6287 if (!bp->num_req_rx_rings)
6288 bp->num_rx_rings = bp->irq_nvecs;
6289 else
6290 bp->num_rx_rings = min(bp->irq_nvecs, bp->num_req_rx_rings);
6291
6276 netif_set_real_num_tx_queues(bp->dev, bp->num_tx_rings); 6292 netif_set_real_num_tx_queues(bp->dev, bp->num_tx_rings);
6277 6293
6278 bp->num_rx_rings = bp->irq_nvecs;
6279 return netif_set_real_num_rx_queues(bp->dev, bp->num_rx_rings); 6294 return netif_set_real_num_rx_queues(bp->dev, bp->num_rx_rings);
6280} 6295}
6281 6296
@@ -6550,6 +6565,9 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
6550 } 6565 }
6551 txbd->tx_bd_vlan_tag_flags |= TX_BD_FLAGS_END; 6566 txbd->tx_bd_vlan_tag_flags |= TX_BD_FLAGS_END;
6552 6567
6568 /* Sync BD data before updating TX mailbox */
6569 wmb();
6570
6553 netdev_tx_sent_queue(txq, skb->len); 6571 netdev_tx_sent_queue(txq, skb->len);
6554 6572
6555 prod = NEXT_TX_BD(prod); 6573 prod = NEXT_TX_BD(prod);
@@ -7164,7 +7182,7 @@ bnx2_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
7164} 7182}
7165 7183
7166static int 7184static int
7167bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx) 7185bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx, bool reset_irq)
7168{ 7186{
7169 if (netif_running(bp->dev)) { 7187 if (netif_running(bp->dev)) {
7170 /* Reset will erase chipset stats; save them */ 7188 /* Reset will erase chipset stats; save them */
@@ -7172,7 +7190,12 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx)
7172 7190
7173 bnx2_netif_stop(bp, true); 7191 bnx2_netif_stop(bp, true);
7174 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET); 7192 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET);
7175 __bnx2_free_irq(bp); 7193 if (reset_irq) {
7194 bnx2_free_irq(bp);
7195 bnx2_del_napi(bp);
7196 } else {
7197 __bnx2_free_irq(bp);
7198 }
7176 bnx2_free_skbs(bp); 7199 bnx2_free_skbs(bp);
7177 bnx2_free_mem(bp); 7200 bnx2_free_mem(bp);
7178 } 7201 }
@@ -7181,9 +7204,16 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx)
7181 bp->tx_ring_size = tx; 7204 bp->tx_ring_size = tx;
7182 7205
7183 if (netif_running(bp->dev)) { 7206 if (netif_running(bp->dev)) {
7184 int rc; 7207 int rc = 0;
7208
7209 if (reset_irq) {
7210 rc = bnx2_setup_int_mode(bp, disable_msi);
7211 bnx2_init_napi(bp);
7212 }
7213
7214 if (!rc)
7215 rc = bnx2_alloc_mem(bp);
7185 7216
7186 rc = bnx2_alloc_mem(bp);
7187 if (!rc) 7217 if (!rc)
7188 rc = bnx2_request_irq(bp); 7218 rc = bnx2_request_irq(bp);
7189 7219
@@ -7219,7 +7249,8 @@ bnx2_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
7219 7249
7220 return -EINVAL; 7250 return -EINVAL;
7221 } 7251 }
7222 rc = bnx2_change_ring_size(bp, ering->rx_pending, ering->tx_pending); 7252 rc = bnx2_change_ring_size(bp, ering->rx_pending, ering->tx_pending,
7253 false);
7223 return rc; 7254 return rc;
7224} 7255}
7225 7256
@@ -7607,6 +7638,54 @@ bnx2_set_features(struct net_device *dev, netdev_features_t features)
7607 return 0; 7638 return 0;
7608} 7639}
7609 7640
7641static void bnx2_get_channels(struct net_device *dev,
7642 struct ethtool_channels *channels)
7643{
7644 struct bnx2 *bp = netdev_priv(dev);
7645 u32 max_rx_rings = 1;
7646 u32 max_tx_rings = 1;
7647
7648 if ((bp->flags & BNX2_FLAG_MSIX_CAP) && !disable_msi) {
7649 max_rx_rings = RX_MAX_RINGS;
7650 max_tx_rings = TX_MAX_RINGS;
7651 }
7652
7653 channels->max_rx = max_rx_rings;
7654 channels->max_tx = max_tx_rings;
7655 channels->max_other = 0;
7656 channels->max_combined = 0;
7657 channels->rx_count = bp->num_rx_rings;
7658 channels->tx_count = bp->num_tx_rings;
7659 channels->other_count = 0;
7660 channels->combined_count = 0;
7661}
7662
7663static int bnx2_set_channels(struct net_device *dev,
7664 struct ethtool_channels *channels)
7665{
7666 struct bnx2 *bp = netdev_priv(dev);
7667 u32 max_rx_rings = 1;
7668 u32 max_tx_rings = 1;
7669 int rc = 0;
7670
7671 if ((bp->flags & BNX2_FLAG_MSIX_CAP) && !disable_msi) {
7672 max_rx_rings = RX_MAX_RINGS;
7673 max_tx_rings = TX_MAX_RINGS;
7674 }
7675 if (channels->rx_count > max_rx_rings ||
7676 channels->tx_count > max_tx_rings)
7677 return -EINVAL;
7678
7679 bp->num_req_rx_rings = channels->rx_count;
7680 bp->num_req_tx_rings = channels->tx_count;
7681
7682 if (netif_running(dev))
7683 rc = bnx2_change_ring_size(bp, bp->rx_ring_size,
7684 bp->tx_ring_size, true);
7685
7686 return rc;
7687}
7688
7610static const struct ethtool_ops bnx2_ethtool_ops = { 7689static const struct ethtool_ops bnx2_ethtool_ops = {
7611 .get_settings = bnx2_get_settings, 7690 .get_settings = bnx2_get_settings,
7612 .set_settings = bnx2_set_settings, 7691 .set_settings = bnx2_set_settings,
@@ -7631,6 +7710,8 @@ static const struct ethtool_ops bnx2_ethtool_ops = {
7631 .set_phys_id = bnx2_set_phys_id, 7710 .set_phys_id = bnx2_set_phys_id,
7632 .get_ethtool_stats = bnx2_get_ethtool_stats, 7711 .get_ethtool_stats = bnx2_get_ethtool_stats,
7633 .get_sset_count = bnx2_get_sset_count, 7712 .get_sset_count = bnx2_get_sset_count,
7713 .get_channels = bnx2_get_channels,
7714 .set_channels = bnx2_set_channels,
7634}; 7715};
7635 7716
7636/* Called with rtnl_lock */ 7717/* Called with rtnl_lock */
@@ -7712,7 +7793,8 @@ bnx2_change_mtu(struct net_device *dev, int new_mtu)
7712 return -EINVAL; 7793 return -EINVAL;
7713 7794
7714 dev->mtu = new_mtu; 7795 dev->mtu = new_mtu;
7715 return bnx2_change_ring_size(bp, bp->rx_ring_size, bp->tx_ring_size); 7796 return bnx2_change_ring_size(bp, bp->rx_ring_size, bp->tx_ring_size,
7797 false);
7716} 7798}
7717 7799
7718#ifdef CONFIG_NET_POLL_CONTROLLER 7800#ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/drivers/net/ethernet/broadcom/bnx2.h b/drivers/net/ethernet/broadcom/bnx2.h
index 1db2d51ba3f1..dc06bda73be7 100644
--- a/drivers/net/ethernet/broadcom/bnx2.h
+++ b/drivers/net/ethernet/broadcom/bnx2.h
@@ -6933,6 +6933,9 @@ struct bnx2 {
6933 u8 num_tx_rings; 6933 u8 num_tx_rings;
6934 u8 num_rx_rings; 6934 u8 num_rx_rings;
6935 6935
6936 int num_req_tx_rings;
6937 int num_req_rx_rings;
6938
6936 u32 leds_save; 6939 u32 leds_save;
6937 u32 idle_chk_status_idx; 6940 u32 idle_chk_status_idx;
6938 6941
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 8c73d34b2ff1..7d184fbffaf6 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -1,6 +1,6 @@
1/* bnx2x.h: Broadcom Everest network driver. 1/* bnx2x.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007-2011 Broadcom Corporation 3 * Copyright (c) 2007-2012 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -23,8 +23,8 @@
23 * (you will need to reboot afterwards) */ 23 * (you will need to reboot afterwards) */
24/* #define BNX2X_STOP_ON_ERROR */ 24/* #define BNX2X_STOP_ON_ERROR */
25 25
26#define DRV_MODULE_VERSION "1.70.35-0" 26#define DRV_MODULE_VERSION "1.72.00-0"
27#define DRV_MODULE_RELDATE "2011/11/10" 27#define DRV_MODULE_RELDATE "2012/01/26"
28#define BNX2X_BC_VER 0x040200 28#define BNX2X_BC_VER 0x040200
29 29
30#if defined(CONFIG_DCB) 30#if defined(CONFIG_DCB)
@@ -1088,7 +1088,8 @@ enum bnx2x_recovery_state {
1088 BNX2X_RECOVERY_DONE, 1088 BNX2X_RECOVERY_DONE,
1089 BNX2X_RECOVERY_INIT, 1089 BNX2X_RECOVERY_INIT,
1090 BNX2X_RECOVERY_WAIT, 1090 BNX2X_RECOVERY_WAIT,
1091 BNX2X_RECOVERY_FAILED 1091 BNX2X_RECOVERY_FAILED,
1092 BNX2X_RECOVERY_NIC_LOADING
1092}; 1093};
1093 1094
1094/* 1095/*
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 7aee46983be4..518ec5c6872d 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -1,6 +1,6 @@
1/* bnx2x_cmn.c: Broadcom Everest network driver. 1/* bnx2x_cmn.c: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007-2011 Broadcom Corporation 3 * Copyright (c) 2007-2012 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -1766,12 +1766,27 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
1766 1766
1767 bnx2x_napi_enable(bp); 1767 bnx2x_napi_enable(bp);
1768 1768
1769 /* set pf load just before approaching the MCP */
1770 bnx2x_set_pf_load(bp);
1771
1769 /* Send LOAD_REQUEST command to MCP 1772 /* Send LOAD_REQUEST command to MCP
1770 * Returns the type of LOAD command: 1773 * Returns the type of LOAD command:
1771 * if it is the first port to be initialized 1774 * if it is the first port to be initialized
1772 * common blocks should be initialized, otherwise - not 1775 * common blocks should be initialized, otherwise - not
1773 */ 1776 */
1774 if (!BP_NOMCP(bp)) { 1777 if (!BP_NOMCP(bp)) {
1778 /* init fw_seq */
1779 bp->fw_seq =
1780 (SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_mb_header) &
1781 DRV_MSG_SEQ_NUMBER_MASK);
1782 BNX2X_DEV_INFO("fw_seq 0x%08x\n", bp->fw_seq);
1783
1784 /* Get current FW pulse sequence */
1785 bp->fw_drv_pulse_wr_seq =
1786 (SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_pulse_mb) &
1787 DRV_PULSE_SEQ_MASK);
1788 BNX2X_DEV_INFO("drv_pulse 0x%x\n", bp->fw_drv_pulse_wr_seq);
1789
1775 load_code = bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_REQ, 0); 1790 load_code = bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_REQ, 0);
1776 if (!load_code) { 1791 if (!load_code) {
1777 BNX2X_ERR("MCP response failure, aborting\n"); 1792 BNX2X_ERR("MCP response failure, aborting\n");
@@ -1782,6 +1797,29 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
1782 rc = -EBUSY; /* other port in diagnostic mode */ 1797 rc = -EBUSY; /* other port in diagnostic mode */
1783 LOAD_ERROR_EXIT(bp, load_error1); 1798 LOAD_ERROR_EXIT(bp, load_error1);
1784 } 1799 }
1800 if (load_code != FW_MSG_CODE_DRV_LOAD_COMMON_CHIP &&
1801 load_code != FW_MSG_CODE_DRV_LOAD_COMMON) {
1802 /* build FW version dword */
1803 u32 my_fw = (BCM_5710_FW_MAJOR_VERSION) +
1804 (BCM_5710_FW_MINOR_VERSION << 8) +
1805 (BCM_5710_FW_REVISION_VERSION << 16) +
1806 (BCM_5710_FW_ENGINEERING_VERSION << 24);
1807
1808 /* read loaded FW from chip */
1809 u32 loaded_fw = REG_RD(bp, XSEM_REG_PRAM);
1810
1811 DP(BNX2X_MSG_SP, "loaded fw %x, my fw %x",
1812 loaded_fw, my_fw);
1813
1814 /* abort nic load if version mismatch */
1815 if (my_fw != loaded_fw) {
1816 BNX2X_ERR("bnx2x with FW %x already loaded, "
1817 "which mismatches my %x FW. aborting",
1818 loaded_fw, my_fw);
1819 rc = -EBUSY;
1820 LOAD_ERROR_EXIT(bp, load_error2);
1821 }
1822 }
1785 1823
1786 } else { 1824 } else {
1787 int path = BP_PATH(bp); 1825 int path = BP_PATH(bp);
@@ -1948,7 +1986,6 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
1948 if (bp->state == BNX2X_STATE_OPEN) 1986 if (bp->state == BNX2X_STATE_OPEN)
1949 bnx2x_cnic_notify(bp, CNIC_CTL_START_CMD); 1987 bnx2x_cnic_notify(bp, CNIC_CTL_START_CMD);
1950#endif 1988#endif
1951 bnx2x_inc_load_cnt(bp);
1952 1989
1953 /* Wait for all pending SP commands to complete */ 1990 /* Wait for all pending SP commands to complete */
1954 if (!bnx2x_wait_sp_comp(bp, ~0x0UL)) { 1991 if (!bnx2x_wait_sp_comp(bp, ~0x0UL)) {
@@ -1988,6 +2025,8 @@ load_error2:
1988 bp->port.pmf = 0; 2025 bp->port.pmf = 0;
1989load_error1: 2026load_error1:
1990 bnx2x_napi_disable(bp); 2027 bnx2x_napi_disable(bp);
2028 /* clear pf_load status, as it was already set */
2029 bnx2x_clear_pf_load(bp);
1991load_error0: 2030load_error0:
1992 bnx2x_free_mem(bp); 2031 bnx2x_free_mem(bp);
1993 2032
@@ -2108,7 +2147,7 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode)
2108 /* The last driver must disable a "close the gate" if there is no 2147 /* The last driver must disable a "close the gate" if there is no
2109 * parity attention or "process kill" pending. 2148 * parity attention or "process kill" pending.
2110 */ 2149 */
2111 if (!bnx2x_dec_load_cnt(bp) && bnx2x_reset_is_done(bp, BP_PATH(bp))) 2150 if (!bnx2x_clear_pf_load(bp) && bnx2x_reset_is_done(bp, BP_PATH(bp)))
2112 bnx2x_disable_close_the_gate(bp); 2151 bnx2x_disable_close_the_gate(bp);
2113 2152
2114 return 0; 2153 return 0;
@@ -3414,7 +3453,7 @@ int bnx2x_change_mtu(struct net_device *dev, int new_mtu)
3414 struct bnx2x *bp = netdev_priv(dev); 3453 struct bnx2x *bp = netdev_priv(dev);
3415 3454
3416 if (bp->recovery_state != BNX2X_RECOVERY_DONE) { 3455 if (bp->recovery_state != BNX2X_RECOVERY_DONE) {
3417 pr_err("Handling parity error recovery. Try again later\n"); 3456 netdev_err(dev, "Handling parity error recovery. Try again later\n");
3418 return -EAGAIN; 3457 return -EAGAIN;
3419 } 3458 }
3420 3459
@@ -3541,7 +3580,7 @@ int bnx2x_resume(struct pci_dev *pdev)
3541 bp = netdev_priv(dev); 3580 bp = netdev_priv(dev);
3542 3581
3543 if (bp->recovery_state != BNX2X_RECOVERY_DONE) { 3582 if (bp->recovery_state != BNX2X_RECOVERY_DONE) {
3544 pr_err("Handling parity error recovery. Try again later\n"); 3583 netdev_err(dev, "Handling parity error recovery. Try again later\n");
3545 return -EAGAIN; 3584 return -EAGAIN;
3546 } 3585 }
3547 3586
@@ -3557,8 +3596,6 @@ int bnx2x_resume(struct pci_dev *pdev)
3557 bnx2x_set_power_state(bp, PCI_D0); 3596 bnx2x_set_power_state(bp, PCI_D0);
3558 netif_device_attach(dev); 3597 netif_device_attach(dev);
3559 3598
3560 /* Since the chip was reset, clear the FW sequence number */
3561 bp->fw_seq = 0;
3562 rc = bnx2x_nic_load(bp, LOAD_OPEN); 3599 rc = bnx2x_nic_load(bp, LOAD_OPEN);
3563 3600
3564 rtnl_unlock(); 3601 rtnl_unlock();
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index bf27c54ff2e0..c7c7bf1e573a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -1,6 +1,6 @@
1/* bnx2x_cmn.h: Broadcom Everest network driver. 1/* bnx2x_cmn.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007-2011 Broadcom Corporation 3 * Copyright (c) 2007-2012 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -379,8 +379,8 @@ void bnx2x_set_q_rx_mode(struct bnx2x *bp, u8 cl_id,
379 unsigned long ramrod_flags); 379 unsigned long ramrod_flags);
380 380
381/* Parity errors related */ 381/* Parity errors related */
382void bnx2x_inc_load_cnt(struct bnx2x *bp); 382void bnx2x_set_pf_load(struct bnx2x *bp);
383u32 bnx2x_dec_load_cnt(struct bnx2x *bp); 383bool bnx2x_clear_pf_load(struct bnx2x *bp);
384bool bnx2x_chk_parity_attn(struct bnx2x *bp, bool *global, bool print); 384bool bnx2x_chk_parity_attn(struct bnx2x *bp, bool *global, bool print);
385bool bnx2x_reset_is_done(struct bnx2x *bp, int engine); 385bool bnx2x_reset_is_done(struct bnx2x *bp, int engine);
386void bnx2x_set_reset_in_progress(struct bnx2x *bp); 386void bnx2x_set_reset_in_progress(struct bnx2x *bp);
@@ -984,10 +984,11 @@ static inline int bnx2x_func_start(struct bnx2x *bp)
984 /* Function parameters */ 984 /* Function parameters */
985 start_params->mf_mode = bp->mf_mode; 985 start_params->mf_mode = bp->mf_mode;
986 start_params->sd_vlan_tag = bp->mf_ov; 986 start_params->sd_vlan_tag = bp->mf_ov;
987 if (CHIP_IS_E1x(bp)) 987
988 start_params->network_cos_mode = OVERRIDE_COS; 988 if (CHIP_IS_E2(bp) || CHIP_IS_E3(bp))
989 else
990 start_params->network_cos_mode = STATIC_COS; 989 start_params->network_cos_mode = STATIC_COS;
990 else /* CHIP_IS_E1X */
991 start_params->network_cos_mode = FW_WRR;
991 992
992 return bnx2x_func_state_change(bp, &func_params); 993 return bnx2x_func_state_change(bp, &func_params);
993} 994}
@@ -1539,7 +1540,7 @@ static inline void bnx2x_update_drv_flags(struct bnx2x *bp, u32 flags, u32 set)
1539{ 1540{
1540 if (SHMEM2_HAS(bp, drv_flags)) { 1541 if (SHMEM2_HAS(bp, drv_flags)) {
1541 u32 drv_flags; 1542 u32 drv_flags;
1542 bnx2x_acquire_hw_lock(bp, HW_LOCK_DRV_FLAGS); 1543 bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_DRV_FLAGS);
1543 drv_flags = SHMEM2_RD(bp, drv_flags); 1544 drv_flags = SHMEM2_RD(bp, drv_flags);
1544 1545
1545 if (set) 1546 if (set)
@@ -1549,7 +1550,7 @@ static inline void bnx2x_update_drv_flags(struct bnx2x *bp, u32 flags, u32 set)
1549 1550
1550 SHMEM2_WR(bp, drv_flags, drv_flags); 1551 SHMEM2_WR(bp, drv_flags, drv_flags);
1551 DP(NETIF_MSG_HW, "drv_flags 0x%08x\n", drv_flags); 1552 DP(NETIF_MSG_HW, "drv_flags 0x%08x\n", drv_flags);
1552 bnx2x_release_hw_lock(bp, HW_LOCK_DRV_FLAGS); 1553 bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_DRV_FLAGS);
1553 } 1554 }
1554} 1555}
1555 1556
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
index 5051cf3deb20..9a9bd3ab4793 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
@@ -1,6 +1,6 @@
1/* bnx2x_dcb.c: Broadcom Everest network driver. 1/* bnx2x_dcb.c: Broadcom Everest network driver.
2 * 2 *
3 * Copyright 2009-2011 Broadcom Corporation 3 * Copyright 2009-2012 Broadcom Corporation
4 * 4 *
5 * Unless you and Broadcom execute a separate written software license 5 * Unless you and Broadcom execute a separate written software license
6 * agreement governing use of this software, this software is licensed to you 6 * agreement governing use of this software, this software is licensed to you
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h
index 2ab9254e2d5e..06c7a0435948 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h
@@ -1,6 +1,6 @@
1/* bnx2x_dcb.h: Broadcom Everest network driver. 1/* bnx2x_dcb.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright 2009-2011 Broadcom Corporation 3 * Copyright 2009-2012 Broadcom Corporation
4 * 4 *
5 * Unless you and Broadcom execute a separate written software license 5 * Unless you and Broadcom execute a separate written software license
6 * agreement governing use of this software, this software is licensed to you 6 * agreement governing use of this software, this software is licensed to you
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h
index b983825d0ee9..3e4cff9b1ebe 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dump.h
@@ -1,6 +1,6 @@
1/* bnx2x_dump.h: Broadcom Everest network driver. 1/* bnx2x_dump.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2011 Broadcom Corporation 3 * Copyright (c) 2012 Broadcom Corporation
4 * 4 *
5 * Unless you and Broadcom execute a separate written software license 5 * Unless you and Broadcom execute a separate written software license
6 * agreement governing use of this software, this software is licensed to you 6 * agreement governing use of this software, this software is licensed to you
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index 31a8b38ab15e..137968d33d1e 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -1,6 +1,6 @@
1/* bnx2x_ethtool.c: Broadcom Everest network driver. 1/* bnx2x_ethtool.c: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007-2011 Broadcom Corporation 3 * Copyright (c) 2007-2012 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -175,7 +175,11 @@ static const struct {
175 { STATS_OFFSET32(total_tpa_aggregated_frames_hi), 175 { STATS_OFFSET32(total_tpa_aggregated_frames_hi),
176 8, STATS_FLAGS_FUNC, "tpa_aggregated_frames"}, 176 8, STATS_FLAGS_FUNC, "tpa_aggregated_frames"},
177 { STATS_OFFSET32(total_tpa_bytes_hi), 177 { STATS_OFFSET32(total_tpa_bytes_hi),
178 8, STATS_FLAGS_FUNC, "tpa_bytes"} 178 8, STATS_FLAGS_FUNC, "tpa_bytes"},
179 { STATS_OFFSET32(recoverable_error),
180 4, STATS_FLAGS_FUNC, "recoverable_errors" },
181 { STATS_OFFSET32(unrecoverable_error),
182 4, STATS_FLAGS_FUNC, "unrecoverable_errors" },
179}; 183};
180 184
181#define BNX2X_NUM_STATS ARRAY_SIZE(bnx2x_stats_arr) 185#define BNX2X_NUM_STATS ARRAY_SIZE(bnx2x_stats_arr)
@@ -882,11 +886,27 @@ static int bnx2x_get_eeprom_len(struct net_device *dev)
882 return bp->common.flash_size; 886 return bp->common.flash_size;
883} 887}
884 888
889/* Per pf misc lock must be aquired before the per port mcp lock. Otherwise, had
890 * we done things the other way around, if two pfs from the same port would
891 * attempt to access nvram at the same time, we could run into a scenario such
892 * as:
893 * pf A takes the port lock.
894 * pf B succeeds in taking the same lock since they are from the same port.
895 * pf A takes the per pf misc lock. Performs eeprom access.
896 * pf A finishes. Unlocks the per pf misc lock.
897 * Pf B takes the lock and proceeds to perform it's own access.
898 * pf A unlocks the per port lock, while pf B is still working (!).
899 * mcp takes the per port lock and corrupts pf B's access (and/or has it's own
900 * acess corrupted by pf B).*
901 */
885static int bnx2x_acquire_nvram_lock(struct bnx2x *bp) 902static int bnx2x_acquire_nvram_lock(struct bnx2x *bp)
886{ 903{
887 int port = BP_PORT(bp); 904 int port = BP_PORT(bp);
888 int count, i; 905 int count, i;
889 u32 val = 0; 906 u32 val;
907
908 /* acquire HW lock: protect against other PFs in PF Direct Assignment */
909 bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_NVRAM);
890 910
891 /* adjust timeout for emulation/FPGA */ 911 /* adjust timeout for emulation/FPGA */
892 count = BNX2X_NVRAM_TIMEOUT_COUNT; 912 count = BNX2X_NVRAM_TIMEOUT_COUNT;
@@ -917,7 +937,7 @@ static int bnx2x_release_nvram_lock(struct bnx2x *bp)
917{ 937{
918 int port = BP_PORT(bp); 938 int port = BP_PORT(bp);
919 int count, i; 939 int count, i;
920 u32 val = 0; 940 u32 val;
921 941
922 /* adjust timeout for emulation/FPGA */ 942 /* adjust timeout for emulation/FPGA */
923 count = BNX2X_NVRAM_TIMEOUT_COUNT; 943 count = BNX2X_NVRAM_TIMEOUT_COUNT;
@@ -941,6 +961,8 @@ static int bnx2x_release_nvram_lock(struct bnx2x *bp)
941 return -EBUSY; 961 return -EBUSY;
942 } 962 }
943 963
964 /* release HW lock: protect against other PFs in PF Direct Assignment */
965 bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_NVRAM);
944 return 0; 966 return 0;
945} 967}
946 968
@@ -1370,7 +1392,8 @@ static int bnx2x_set_ringparam(struct net_device *dev,
1370 struct bnx2x *bp = netdev_priv(dev); 1392 struct bnx2x *bp = netdev_priv(dev);
1371 1393
1372 if (bp->recovery_state != BNX2X_RECOVERY_DONE) { 1394 if (bp->recovery_state != BNX2X_RECOVERY_DONE) {
1373 pr_err("Handling parity error recovery. Try again later\n"); 1395 netdev_err(dev, "Handling parity error recovery. "
1396 "Try again later\n");
1374 return -EAGAIN; 1397 return -EAGAIN;
1375 } 1398 }
1376 1399
@@ -2024,7 +2047,8 @@ static void bnx2x_self_test(struct net_device *dev,
2024 struct bnx2x *bp = netdev_priv(dev); 2047 struct bnx2x *bp = netdev_priv(dev);
2025 u8 is_serdes; 2048 u8 is_serdes;
2026 if (bp->recovery_state != BNX2X_RECOVERY_DONE) { 2049 if (bp->recovery_state != BNX2X_RECOVERY_DONE) {
2027 pr_err("Handling parity error recovery. Try again later\n"); 2050 netdev_err(bp->dev, "Handling parity error recovery. "
2051 "Try again later\n");
2028 etest->flags |= ETH_TEST_FL_FAILED; 2052 etest->flags |= ETH_TEST_FL_FAILED;
2029 return; 2053 return;
2030 } 2054 }
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h
index 998652a1b858..e5c5982ae06d 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_defs.h
@@ -1,6 +1,6 @@
1/* bnx2x_fw_defs.h: Broadcom Everest network driver. 1/* bnx2x_fw_defs.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007-2011 Broadcom Corporation 3 * Copyright (c) 2007-2012 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_file_hdr.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_file_hdr.h
index f4a07fbaed05..4bed52ba300d 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_file_hdr.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_fw_file_hdr.h
@@ -1,6 +1,6 @@
1/* bnx2x_fw_file_hdr.h: FW binary file header structure. 1/* bnx2x_fw_file_hdr.h: FW binary file header structure.
2 * 2 *
3 * Copyright (c) 2007-2011 Broadcom Corporation 3 * Copyright (c) 2007-2012 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
index 3e30c8642c26..78b77de728b0 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
@@ -1,6 +1,6 @@
1/* bnx2x_hsi.h: Broadcom Everest network driver. 1/* bnx2x_hsi.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007-2011 Broadcom Corporation 3 * Copyright (c) 2007-2012 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h
index 4d748e77d1ac..29f5c3cca31a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h
@@ -1,7 +1,7 @@
1/* bnx2x_init.h: Broadcom Everest network driver. 1/* bnx2x_init.h: Broadcom Everest network driver.
2 * Structures and macroes needed during the initialization. 2 * Structures and macroes needed during the initialization.
3 * 3 *
4 * Copyright (c) 2007-2011 Broadcom Corporation 4 * Copyright (c) 2007-2012 Broadcom Corporation
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h
index 7ec1724753ad..fe66d902dc62 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h
@@ -2,7 +2,7 @@
2 * Static functions needed during the initialization. 2 * Static functions needed during the initialization.
3 * This file is "included" in bnx2x_main.c. 3 * This file is "included" in bnx2x_main.c.
4 * 4 *
5 * Copyright (c) 2007-2011 Broadcom Corporation 5 * Copyright (c) 2007-2012 Broadcom Corporation
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -69,12 +69,12 @@ static void bnx2x_write_big_buf(struct bnx2x *bp, u32 addr, u32 len,
69{ 69{
70 if (bp->dmae_ready) 70 if (bp->dmae_ready)
71 bnx2x_write_dmae_phys_len(bp, GUNZIP_PHYS(bp), addr, len); 71 bnx2x_write_dmae_phys_len(bp, GUNZIP_PHYS(bp), addr, len);
72 else if (wb) 72
73 /* 73 /* in E1 chips BIOS initiated ZLR may interrupt widebus writes */
74 * Wide bus registers with no dmae need to be written 74 else if (wb && CHIP_IS_E1(bp))
75 * using indirect write.
76 */
77 bnx2x_init_ind_wr(bp, addr, GUNZIP_BUF(bp), len); 75 bnx2x_init_ind_wr(bp, addr, GUNZIP_BUF(bp), len);
76
77 /* in later chips PXP root complex handles BIOS ZLR w/o interrupting */
78 else 78 else
79 bnx2x_init_str_wr(bp, addr, GUNZIP_BUF(bp), len); 79 bnx2x_init_str_wr(bp, addr, GUNZIP_BUF(bp), len);
80} 80}
@@ -99,8 +99,14 @@ static void bnx2x_write_big_buf_wb(struct bnx2x *bp, u32 addr, u32 len)
99{ 99{
100 if (bp->dmae_ready) 100 if (bp->dmae_ready)
101 bnx2x_write_dmae_phys_len(bp, GUNZIP_PHYS(bp), addr, len); 101 bnx2x_write_dmae_phys_len(bp, GUNZIP_PHYS(bp), addr, len);
102 else 102
103 /* in E1 chips BIOS initiated ZLR may interrupt widebus writes */
104 else if (CHIP_IS_E1(bp))
103 bnx2x_init_ind_wr(bp, addr, GUNZIP_BUF(bp), len); 105 bnx2x_init_ind_wr(bp, addr, GUNZIP_BUF(bp), len);
106
107 /* in later chips PXP root complex handles BIOS ZLR w/o interrupting */
108 else
109 bnx2x_init_str_wr(bp, addr, GUNZIP_BUF(bp), len);
104} 110}
105 111
106static void bnx2x_init_wr_64(struct bnx2x *bp, u32 addr, 112static void bnx2x_init_wr_64(struct bnx2x *bp, u32 addr,
@@ -177,8 +183,14 @@ static void bnx2x_init_wr_wb(struct bnx2x *bp, u32 addr,
177{ 183{
178 if (bp->dmae_ready) 184 if (bp->dmae_ready)
179 VIRT_WR_DMAE_LEN(bp, data, addr, len, 0); 185 VIRT_WR_DMAE_LEN(bp, data, addr, len, 0);
180 else 186
187 /* in E1 chips BIOS initiated ZLR may interrupt widebus writes */
188 else if (CHIP_IS_E1(bp))
181 bnx2x_init_ind_wr(bp, addr, data, len); 189 bnx2x_init_ind_wr(bp, addr, data, len);
190
191 /* in later chips PXP root complex handles BIOS ZLR w/o interrupting */
192 else
193 bnx2x_init_str_wr(bp, addr, data, len);
182} 194}
183 195
184static void bnx2x_wr_64(struct bnx2x *bp, u32 reg, u32 val_lo, 196static void bnx2x_wr_64(struct bnx2x *bp, u32 reg, u32 val_lo,
@@ -840,25 +852,15 @@ static void bnx2x_qm_init_cid_count(struct bnx2x *bp, int qm_cid_count,
840 } 852 }
841} 853}
842 854
843static void bnx2x_qm_set_ptr_table(struct bnx2x *bp, int qm_cid_count) 855static void bnx2x_qm_set_ptr_table(struct bnx2x *bp, int qm_cid_count,
856 u32 base_reg, u32 reg)
844{ 857{
845 int i; 858 int i;
846 u32 wb_data[2]; 859 u32 wb_data[2] = {0, 0};
847
848 wb_data[0] = wb_data[1] = 0;
849
850 for (i = 0; i < 4 * QM_QUEUES_PER_FUNC; i++) { 860 for (i = 0; i < 4 * QM_QUEUES_PER_FUNC; i++) {
851 REG_WR(bp, QM_REG_BASEADDR + i*4, 861 REG_WR(bp, base_reg + i*4,
852 qm_cid_count * 4 * (i % QM_QUEUES_PER_FUNC)); 862 qm_cid_count * 4 * (i % QM_QUEUES_PER_FUNC));
853 bnx2x_init_ind_wr(bp, QM_REG_PTRTBL + i*8, 863 bnx2x_init_wr_wb(bp, reg + i*8, wb_data, 2);
854 wb_data, 2);
855
856 if (CHIP_IS_E1H(bp)) {
857 REG_WR(bp, QM_REG_BASEADDR_EXT_A + i*4,
858 qm_cid_count * 4 * (i % QM_QUEUES_PER_FUNC));
859 bnx2x_init_ind_wr(bp, QM_REG_PTRTBL_EXT_A + i*8,
860 wb_data, 2);
861 }
862 } 864 }
863} 865}
864 866
@@ -873,7 +875,12 @@ static void bnx2x_qm_init_ptr_table(struct bnx2x *bp, int qm_cid_count,
873 case INITOP_INIT: 875 case INITOP_INIT:
874 /* set in the init-value array */ 876 /* set in the init-value array */
875 case INITOP_SET: 877 case INITOP_SET:
876 bnx2x_qm_set_ptr_table(bp, qm_cid_count); 878 bnx2x_qm_set_ptr_table(bp, qm_cid_count,
879 QM_REG_BASEADDR, QM_REG_PTRTBL);
880 if (CHIP_IS_E1H(bp))
881 bnx2x_qm_set_ptr_table(bp, qm_cid_count,
882 QM_REG_BASEADDR_EXT_A,
883 QM_REG_PTRTBL_EXT_A);
877 break; 884 break;
878 case INITOP_CLEAR: 885 case INITOP_CLEAR:
879 break; 886 break;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
index 2091e5dbbcdd..2102ad593c14 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
@@ -1,4 +1,4 @@
1/* Copyright 2008-2011 Broadcom Corporation 1/* Copyright 2008-2012 Broadcom Corporation
2 * 2 *
3 * Unless you and Broadcom execute a separate written software license 3 * Unless you and Broadcom execute a separate written software license
4 * agreement governing use of this software, this software is licensed to you 4 * agreement governing use of this software, this software is licensed to you
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h
index e02a68a7fb85..9cc7bafb3dfe 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h
@@ -1,4 +1,4 @@
1/* Copyright 2008-2011 Broadcom Corporation 1/* Copyright 2008-2012 Broadcom Corporation
2 * 2 *
3 * Unless you and Broadcom execute a separate written software license 3 * Unless you and Broadcom execute a separate written software license
4 * agreement governing use of this software, this software is licensed to you 4 * agreement governing use of this software, this software is licensed to you
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 1e3f978ee6da..ff19c3cf4409 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -1,6 +1,6 @@
1/* bnx2x_main.c: Broadcom Everest network driver. 1/* bnx2x_main.c: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007-2011 Broadcom Corporation 3 * Copyright (c) 2007-2012 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -468,7 +468,9 @@ static int bnx2x_issue_dmae_with_comp(struct bnx2x *bp,
468 while ((*wb_comp & ~DMAE_PCI_ERR_FLAG) != DMAE_COMP_VAL) { 468 while ((*wb_comp & ~DMAE_PCI_ERR_FLAG) != DMAE_COMP_VAL) {
469 DP(BNX2X_MSG_OFF, "wb_comp 0x%08x\n", *wb_comp); 469 DP(BNX2X_MSG_OFF, "wb_comp 0x%08x\n", *wb_comp);
470 470
471 if (!cnt) { 471 if (!cnt ||
472 (bp->recovery_state != BNX2X_RECOVERY_DONE &&
473 bp->recovery_state != BNX2X_RECOVERY_NIC_LOADING)) {
472 BNX2X_ERR("DMAE timeout!\n"); 474 BNX2X_ERR("DMAE timeout!\n");
473 rc = DMAE_TIMEOUT; 475 rc = DMAE_TIMEOUT;
474 goto unlock; 476 goto unlock;
@@ -498,9 +500,13 @@ void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
498 if (!bp->dmae_ready) { 500 if (!bp->dmae_ready) {
499 u32 *data = bnx2x_sp(bp, wb_data[0]); 501 u32 *data = bnx2x_sp(bp, wb_data[0]);
500 502
501 DP(BNX2X_MSG_OFF, "DMAE is not ready (dst_addr %08x len32 %d)" 503 DP(BNX2X_MSG_OFF,
502 " using indirect\n", dst_addr, len32); 504 "DMAE is not ready (dst_addr %08x len32 %d) using indirect\n",
503 bnx2x_init_ind_wr(bp, dst_addr, data, len32); 505 dst_addr, len32);
506 if (CHIP_IS_E1(bp))
507 bnx2x_init_ind_wr(bp, dst_addr, data, len32);
508 else
509 bnx2x_init_str_wr(bp, dst_addr, data, len32);
504 return; 510 return;
505 } 511 }
506 512
@@ -528,10 +534,16 @@ void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32)
528 u32 *data = bnx2x_sp(bp, wb_data[0]); 534 u32 *data = bnx2x_sp(bp, wb_data[0]);
529 int i; 535 int i;
530 536
531 DP(BNX2X_MSG_OFF, "DMAE is not ready (src_addr %08x len32 %d)" 537 if (CHIP_IS_E1(bp)) {
532 " using indirect\n", src_addr, len32); 538 DP(BNX2X_MSG_OFF,
533 for (i = 0; i < len32; i++) 539 "DMAE is not ready (src_addr %08x len32 %d) using indirect\n",
534 data[i] = bnx2x_reg_rd_ind(bp, src_addr + i*4); 540 src_addr, len32);
541 for (i = 0; i < len32; i++)
542 data[i] = bnx2x_reg_rd_ind(bp, src_addr + i*4);
543 } else
544 for (i = 0; i < len32; i++)
545 data[i] = REG_RD(bp, src_addr + i*4);
546
535 return; 547 return;
536 } 548 }
537 549
@@ -772,6 +784,7 @@ void bnx2x_panic_dump(struct bnx2x *bp)
772#endif 784#endif
773 785
774 bp->stats_state = STATS_STATE_DISABLED; 786 bp->stats_state = STATS_STATE_DISABLED;
787 bp->eth_stats.unrecoverable_error++;
775 DP(BNX2X_MSG_STATS, "stats_state - DISABLED\n"); 788 DP(BNX2X_MSG_STATS, "stats_state - DISABLED\n");
776 789
777 BNX2X_ERR("begin crash dump -----------------\n"); 790 BNX2X_ERR("begin crash dump -----------------\n");
@@ -1007,8 +1020,8 @@ void bnx2x_panic_dump(struct bnx2x *bp)
1007 * initialization. 1020 * initialization.
1008 */ 1021 */
1009#define FLR_WAIT_USEC 10000 /* 10 miliseconds */ 1022#define FLR_WAIT_USEC 10000 /* 10 miliseconds */
1010#define FLR_WAIT_INTERAVAL 50 /* usec */ 1023#define FLR_WAIT_INTERVAL 50 /* usec */
1011#define FLR_POLL_CNT (FLR_WAIT_USEC/FLR_WAIT_INTERAVAL) /* 200 */ 1024#define FLR_POLL_CNT (FLR_WAIT_USEC/FLR_WAIT_INTERVAL) /* 200 */
1012 1025
1013struct pbf_pN_buf_regs { 1026struct pbf_pN_buf_regs {
1014 int pN; 1027 int pN;
@@ -1041,7 +1054,7 @@ static void bnx2x_pbf_pN_buf_flushed(struct bnx2x *bp,
1041 while ((crd != init_crd) && ((u32)SUB_S32(crd_freed, crd_freed_start) < 1054 while ((crd != init_crd) && ((u32)SUB_S32(crd_freed, crd_freed_start) <
1042 (init_crd - crd_start))) { 1055 (init_crd - crd_start))) {
1043 if (cur_cnt--) { 1056 if (cur_cnt--) {
1044 udelay(FLR_WAIT_INTERAVAL); 1057 udelay(FLR_WAIT_INTERVAL);
1045 crd = REG_RD(bp, regs->crd); 1058 crd = REG_RD(bp, regs->crd);
1046 crd_freed = REG_RD(bp, regs->crd_freed); 1059 crd_freed = REG_RD(bp, regs->crd_freed);
1047 } else { 1060 } else {
@@ -1055,7 +1068,7 @@ static void bnx2x_pbf_pN_buf_flushed(struct bnx2x *bp,
1055 } 1068 }
1056 } 1069 }
1057 DP(BNX2X_MSG_SP, "Waited %d*%d usec for PBF tx buffer[%d]\n", 1070 DP(BNX2X_MSG_SP, "Waited %d*%d usec for PBF tx buffer[%d]\n",
1058 poll_count-cur_cnt, FLR_WAIT_INTERAVAL, regs->pN); 1071 poll_count-cur_cnt, FLR_WAIT_INTERVAL, regs->pN);
1059} 1072}
1060 1073
1061static void bnx2x_pbf_pN_cmd_flushed(struct bnx2x *bp, 1074static void bnx2x_pbf_pN_cmd_flushed(struct bnx2x *bp,
@@ -1073,7 +1086,7 @@ static void bnx2x_pbf_pN_cmd_flushed(struct bnx2x *bp,
1073 1086
1074 while (occup && ((u32)SUB_S32(freed, freed_start) < to_free)) { 1087 while (occup && ((u32)SUB_S32(freed, freed_start) < to_free)) {
1075 if (cur_cnt--) { 1088 if (cur_cnt--) {
1076 udelay(FLR_WAIT_INTERAVAL); 1089 udelay(FLR_WAIT_INTERVAL);
1077 occup = REG_RD(bp, regs->lines_occup); 1090 occup = REG_RD(bp, regs->lines_occup);
1078 freed = REG_RD(bp, regs->lines_freed); 1091 freed = REG_RD(bp, regs->lines_freed);
1079 } else { 1092 } else {
@@ -1087,7 +1100,7 @@ static void bnx2x_pbf_pN_cmd_flushed(struct bnx2x *bp,
1087 } 1100 }
1088 } 1101 }
1089 DP(BNX2X_MSG_SP, "Waited %d*%d usec for PBF cmd queue[%d]\n", 1102 DP(BNX2X_MSG_SP, "Waited %d*%d usec for PBF cmd queue[%d]\n",
1090 poll_count-cur_cnt, FLR_WAIT_INTERAVAL, regs->pN); 1103 poll_count-cur_cnt, FLR_WAIT_INTERVAL, regs->pN);
1091} 1104}
1092 1105
1093static inline u32 bnx2x_flr_clnup_reg_poll(struct bnx2x *bp, u32 reg, 1106static inline u32 bnx2x_flr_clnup_reg_poll(struct bnx2x *bp, u32 reg,
@@ -1097,7 +1110,7 @@ static inline u32 bnx2x_flr_clnup_reg_poll(struct bnx2x *bp, u32 reg,
1097 u32 val; 1110 u32 val;
1098 1111
1099 while ((val = REG_RD(bp, reg)) != expected && cur_cnt--) 1112 while ((val = REG_RD(bp, reg)) != expected && cur_cnt--)
1100 udelay(FLR_WAIT_INTERAVAL); 1113 udelay(FLR_WAIT_INTERVAL);
1101 1114
1102 return val; 1115 return val;
1103} 1116}
@@ -1210,7 +1223,7 @@ static inline int bnx2x_send_final_clnup(struct bnx2x *bp, u8 clnup_func,
1210 int ret = 0; 1223 int ret = 0;
1211 1224
1212 if (REG_RD(bp, comp_addr)) { 1225 if (REG_RD(bp, comp_addr)) {
1213 BNX2X_ERR("Cleanup complete is not 0\n"); 1226 BNX2X_ERR("Cleanup complete was not 0 before sending\n");
1214 return 1; 1227 return 1;
1215 } 1228 }
1216 1229
@@ -1219,7 +1232,7 @@ static inline int bnx2x_send_final_clnup(struct bnx2x *bp, u8 clnup_func,
1219 op_gen.command |= OP_GEN_AGG_VECT(clnup_func); 1232 op_gen.command |= OP_GEN_AGG_VECT(clnup_func);
1220 op_gen.command |= 1 << SDM_OP_GEN_AGG_VECT_IDX_VALID_SHIFT; 1233 op_gen.command |= 1 << SDM_OP_GEN_AGG_VECT_IDX_VALID_SHIFT;
1221 1234
1222 DP(BNX2X_MSG_SP, "FW Final cleanup\n"); 1235 DP(BNX2X_MSG_SP, "sending FW Final cleanup\n");
1223 REG_WR(bp, XSDM_REG_OPERATION_GEN, op_gen.command); 1236 REG_WR(bp, XSDM_REG_OPERATION_GEN, op_gen.command);
1224 1237
1225 if (bnx2x_flr_clnup_reg_poll(bp, comp_addr, 1, poll_cnt) != 1) { 1238 if (bnx2x_flr_clnup_reg_poll(bp, comp_addr, 1, poll_cnt) != 1) {
@@ -1334,6 +1347,7 @@ static int bnx2x_pf_flr_clnup(struct bnx2x *bp)
1334 REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ, 1); 1347 REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ, 1);
1335 1348
1336 /* Poll HW usage counters */ 1349 /* Poll HW usage counters */
1350 DP(BNX2X_MSG_SP, "Polling usage counters\n");
1337 if (bnx2x_poll_hw_usage_counters(bp, poll_cnt)) 1351 if (bnx2x_poll_hw_usage_counters(bp, poll_cnt))
1338 return -EBUSY; 1352 return -EBUSY;
1339 1353
@@ -3713,11 +3727,11 @@ static inline void bnx2x_attn_int_deasserted3(struct bnx2x *bp, u32 attn)
3713 */ 3727 */
3714void bnx2x_set_reset_global(struct bnx2x *bp) 3728void bnx2x_set_reset_global(struct bnx2x *bp)
3715{ 3729{
3716 u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); 3730 u32 val;
3717 3731 bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3732 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG);
3718 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val | BNX2X_GLOBAL_RESET_BIT); 3733 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val | BNX2X_GLOBAL_RESET_BIT);
3719 barrier(); 3734 bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3720 mmiowb();
3721} 3735}
3722 3736
3723/* 3737/*
@@ -3727,11 +3741,11 @@ void bnx2x_set_reset_global(struct bnx2x *bp)
3727 */ 3741 */
3728static inline void bnx2x_clear_reset_global(struct bnx2x *bp) 3742static inline void bnx2x_clear_reset_global(struct bnx2x *bp)
3729{ 3743{
3730 u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); 3744 u32 val;
3731 3745 bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3746 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG);
3732 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val & (~BNX2X_GLOBAL_RESET_BIT)); 3747 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val & (~BNX2X_GLOBAL_RESET_BIT));
3733 barrier(); 3748 bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3734 mmiowb();
3735} 3749}
3736 3750
3737/* 3751/*
@@ -3754,15 +3768,17 @@ static inline bool bnx2x_reset_is_global(struct bnx2x *bp)
3754 */ 3768 */
3755static inline void bnx2x_set_reset_done(struct bnx2x *bp) 3769static inline void bnx2x_set_reset_done(struct bnx2x *bp)
3756{ 3770{
3757 u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); 3771 u32 val;
3758 u32 bit = BP_PATH(bp) ? 3772 u32 bit = BP_PATH(bp) ?
3759 BNX2X_PATH1_RST_IN_PROG_BIT : BNX2X_PATH0_RST_IN_PROG_BIT; 3773 BNX2X_PATH1_RST_IN_PROG_BIT : BNX2X_PATH0_RST_IN_PROG_BIT;
3774 bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3775 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG);
3760 3776
3761 /* Clear the bit */ 3777 /* Clear the bit */
3762 val &= ~bit; 3778 val &= ~bit;
3763 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val); 3779 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val);
3764 barrier(); 3780
3765 mmiowb(); 3781 bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3766} 3782}
3767 3783
3768/* 3784/*
@@ -3772,15 +3788,16 @@ static inline void bnx2x_set_reset_done(struct bnx2x *bp)
3772 */ 3788 */
3773void bnx2x_set_reset_in_progress(struct bnx2x *bp) 3789void bnx2x_set_reset_in_progress(struct bnx2x *bp)
3774{ 3790{
3775 u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); 3791 u32 val;
3776 u32 bit = BP_PATH(bp) ? 3792 u32 bit = BP_PATH(bp) ?
3777 BNX2X_PATH1_RST_IN_PROG_BIT : BNX2X_PATH0_RST_IN_PROG_BIT; 3793 BNX2X_PATH1_RST_IN_PROG_BIT : BNX2X_PATH0_RST_IN_PROG_BIT;
3794 bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3795 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG);
3778 3796
3779 /* Set the bit */ 3797 /* Set the bit */
3780 val |= bit; 3798 val |= bit;
3781 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val); 3799 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val);
3782 barrier(); 3800 bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3783 mmiowb();
3784} 3801}
3785 3802
3786/* 3803/*
@@ -3798,25 +3815,28 @@ bool bnx2x_reset_is_done(struct bnx2x *bp, int engine)
3798} 3815}
3799 3816
3800/* 3817/*
3801 * Increment the load counter for the current engine. 3818 * set pf load for the current pf.
3802 * 3819 *
3803 * should be run under rtnl lock 3820 * should be run under rtnl lock
3804 */ 3821 */
3805void bnx2x_inc_load_cnt(struct bnx2x *bp) 3822void bnx2x_set_pf_load(struct bnx2x *bp)
3806{ 3823{
3807 u32 val1, val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); 3824 u32 val1, val;
3808 u32 mask = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK : 3825 u32 mask = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK :
3809 BNX2X_PATH0_LOAD_CNT_MASK; 3826 BNX2X_PATH0_LOAD_CNT_MASK;
3810 u32 shift = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_SHIFT : 3827 u32 shift = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_SHIFT :
3811 BNX2X_PATH0_LOAD_CNT_SHIFT; 3828 BNX2X_PATH0_LOAD_CNT_SHIFT;
3812 3829
3830 bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3831 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG);
3832
3813 DP(NETIF_MSG_HW, "Old GEN_REG_VAL=0x%08x\n", val); 3833 DP(NETIF_MSG_HW, "Old GEN_REG_VAL=0x%08x\n", val);
3814 3834
3815 /* get the current counter value */ 3835 /* get the current counter value */
3816 val1 = (val & mask) >> shift; 3836 val1 = (val & mask) >> shift;
3817 3837
3818 /* increment... */ 3838 /* set bit of that PF */
3819 val1++; 3839 val1 |= (1 << bp->pf_num);
3820 3840
3821 /* clear the old value */ 3841 /* clear the old value */
3822 val &= ~mask; 3842 val &= ~mask;
@@ -3825,34 +3845,35 @@ void bnx2x_inc_load_cnt(struct bnx2x *bp)
3825 val |= ((val1 << shift) & mask); 3845 val |= ((val1 << shift) & mask);
3826 3846
3827 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val); 3847 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val);
3828 barrier(); 3848 bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3829 mmiowb();
3830} 3849}
3831 3850
3832/** 3851/**
3833 * bnx2x_dec_load_cnt - decrement the load counter 3852 * bnx2x_clear_pf_load - clear pf load mark
3834 * 3853 *
3835 * @bp: driver handle 3854 * @bp: driver handle
3836 * 3855 *
3837 * Should be run under rtnl lock. 3856 * Should be run under rtnl lock.
3838 * Decrements the load counter for the current engine. Returns 3857 * Decrements the load counter for the current engine. Returns
3839 * the new counter value. 3858 * whether other functions are still loaded
3840 */ 3859 */
3841u32 bnx2x_dec_load_cnt(struct bnx2x *bp) 3860bool bnx2x_clear_pf_load(struct bnx2x *bp)
3842{ 3861{
3843 u32 val1, val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); 3862 u32 val1, val;
3844 u32 mask = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK : 3863 u32 mask = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK :
3845 BNX2X_PATH0_LOAD_CNT_MASK; 3864 BNX2X_PATH0_LOAD_CNT_MASK;
3846 u32 shift = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_SHIFT : 3865 u32 shift = BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_SHIFT :
3847 BNX2X_PATH0_LOAD_CNT_SHIFT; 3866 BNX2X_PATH0_LOAD_CNT_SHIFT;
3848 3867
3868 bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3869 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG);
3849 DP(NETIF_MSG_HW, "Old GEN_REG_VAL=0x%08x\n", val); 3870 DP(NETIF_MSG_HW, "Old GEN_REG_VAL=0x%08x\n", val);
3850 3871
3851 /* get the current counter value */ 3872 /* get the current counter value */
3852 val1 = (val & mask) >> shift; 3873 val1 = (val & mask) >> shift;
3853 3874
3854 /* decrement... */ 3875 /* clear bit of that PF */
3855 val1--; 3876 val1 &= ~(1 << bp->pf_num);
3856 3877
3857 /* clear the old value */ 3878 /* clear the old value */
3858 val &= ~mask; 3879 val &= ~mask;
@@ -3861,18 +3882,16 @@ u32 bnx2x_dec_load_cnt(struct bnx2x *bp)
3861 val |= ((val1 << shift) & mask); 3882 val |= ((val1 << shift) & mask);
3862 3883
3863 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val); 3884 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val);
3864 barrier(); 3885 bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3865 mmiowb(); 3886 return val1 != 0;
3866
3867 return val1;
3868} 3887}
3869 3888
3870/* 3889/*
3871 * Read the load counter for the current engine. 3890 * Read the load status for the current engine.
3872 * 3891 *
3873 * should be run under rtnl lock 3892 * should be run under rtnl lock
3874 */ 3893 */
3875static inline u32 bnx2x_get_load_cnt(struct bnx2x *bp, int engine) 3894static inline bool bnx2x_get_load_status(struct bnx2x *bp, int engine)
3876{ 3895{
3877 u32 mask = (engine ? BNX2X_PATH1_LOAD_CNT_MASK : 3896 u32 mask = (engine ? BNX2X_PATH1_LOAD_CNT_MASK :
3878 BNX2X_PATH0_LOAD_CNT_MASK); 3897 BNX2X_PATH0_LOAD_CNT_MASK);
@@ -3884,23 +3903,23 @@ static inline u32 bnx2x_get_load_cnt(struct bnx2x *bp, int engine)
3884 3903
3885 val = (val & mask) >> shift; 3904 val = (val & mask) >> shift;
3886 3905
3887 DP(NETIF_MSG_HW, "load_cnt for engine %d = %d\n", engine, val); 3906 DP(NETIF_MSG_HW, "load mask for engine %d = 0x%x\n", engine, val);
3888 3907
3889 return val; 3908 return val != 0;
3890} 3909}
3891 3910
3892/* 3911/*
3893 * Reset the load counter for the current engine. 3912 * Reset the load status for the current engine.
3894 *
3895 * should be run under rtnl lock
3896 */ 3913 */
3897static inline void bnx2x_clear_load_cnt(struct bnx2x *bp) 3914static inline void bnx2x_clear_load_status(struct bnx2x *bp)
3898{ 3915{
3899 u32 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG); 3916 u32 val;
3900 u32 mask = (BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK : 3917 u32 mask = (BP_PATH(bp) ? BNX2X_PATH1_LOAD_CNT_MASK :
3901 BNX2X_PATH0_LOAD_CNT_MASK); 3918 BNX2X_PATH0_LOAD_CNT_MASK);
3902 3919 bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3920 val = REG_RD(bp, BNX2X_RECOVERY_GLOB_REG);
3903 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val & (~mask)); 3921 REG_WR(bp, BNX2X_RECOVERY_GLOB_REG, val & (~mask));
3922 bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RECOVERY_REG);
3904} 3923}
3905 3924
3906static inline void _print_next_block(int idx, const char *blk) 3925static inline void _print_next_block(int idx, const char *blk)
@@ -5423,6 +5442,7 @@ static void bnx2x_init_eth_fp(struct bnx2x *bp, int fp_idx)
5423 5442
5424 /* init shortcut */ 5443 /* init shortcut */
5425 fp->ustorm_rx_prods_offset = bnx2x_rx_ustorm_prods_offset(fp); 5444 fp->ustorm_rx_prods_offset = bnx2x_rx_ustorm_prods_offset(fp);
5445
5426 /* Setup SB indicies */ 5446 /* Setup SB indicies */
5427 fp->rx_cons_sb = BNX2X_RX_SB_INDEX; 5447 fp->rx_cons_sb = BNX2X_RX_SB_INDEX;
5428 5448
@@ -6687,13 +6707,16 @@ static int bnx2x_init_hw_func(struct bnx2x *bp)
6687 u16 cdu_ilt_start; 6707 u16 cdu_ilt_start;
6688 u32 addr, val; 6708 u32 addr, val;
6689 u32 main_mem_base, main_mem_size, main_mem_prty_clr; 6709 u32 main_mem_base, main_mem_size, main_mem_prty_clr;
6690 int i, main_mem_width; 6710 int i, main_mem_width, rc;
6691 6711
6692 DP(BNX2X_MSG_MCP, "starting func init func %d\n", func); 6712 DP(BNX2X_MSG_MCP, "starting func init func %d\n", func);
6693 6713
6694 /* FLR cleanup - hmmm */ 6714 /* FLR cleanup - hmmm */
6695 if (!CHIP_IS_E1x(bp)) 6715 if (!CHIP_IS_E1x(bp)) {
6696 bnx2x_pf_flr_clnup(bp); 6716 rc = bnx2x_pf_flr_clnup(bp);
6717 if (rc)
6718 return rc;
6719 }
6697 6720
6698 /* set MSI reconfigure capability */ 6721 /* set MSI reconfigure capability */
6699 if (bp->common.int_block == INT_BLOCK_HC) { 6722 if (bp->common.int_block == INT_BLOCK_HC) {
@@ -8458,13 +8481,38 @@ int bnx2x_leader_reset(struct bnx2x *bp)
8458{ 8481{
8459 int rc = 0; 8482 int rc = 0;
8460 bool global = bnx2x_reset_is_global(bp); 8483 bool global = bnx2x_reset_is_global(bp);
8484 u32 load_code;
8485
8486 /* if not going to reset MCP - load "fake" driver to reset HW while
8487 * driver is owner of the HW
8488 */
8489 if (!global && !BP_NOMCP(bp)) {
8490 load_code = bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_REQ, 0);
8491 if (!load_code) {
8492 BNX2X_ERR("MCP response failure, aborting\n");
8493 rc = -EAGAIN;
8494 goto exit_leader_reset;
8495 }
8496 if ((load_code != FW_MSG_CODE_DRV_LOAD_COMMON_CHIP) &&
8497 (load_code != FW_MSG_CODE_DRV_LOAD_COMMON)) {
8498 BNX2X_ERR("MCP unexpected resp, aborting\n");
8499 rc = -EAGAIN;
8500 goto exit_leader_reset2;
8501 }
8502 load_code = bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_DONE, 0);
8503 if (!load_code) {
8504 BNX2X_ERR("MCP response failure, aborting\n");
8505 rc = -EAGAIN;
8506 goto exit_leader_reset2;
8507 }
8508 }
8461 8509
8462 /* Try to recover after the failure */ 8510 /* Try to recover after the failure */
8463 if (bnx2x_process_kill(bp, global)) { 8511 if (bnx2x_process_kill(bp, global)) {
8464 netdev_err(bp->dev, "Something bad had happen on engine %d! " 8512 netdev_err(bp->dev, "Something bad had happen on engine %d! "
8465 "Aii!\n", BP_PATH(bp)); 8513 "Aii!\n", BP_PATH(bp));
8466 rc = -EAGAIN; 8514 rc = -EAGAIN;
8467 goto exit_leader_reset; 8515 goto exit_leader_reset2;
8468 } 8516 }
8469 8517
8470 /* 8518 /*
@@ -8475,6 +8523,12 @@ int bnx2x_leader_reset(struct bnx2x *bp)
8475 if (global) 8523 if (global)
8476 bnx2x_clear_reset_global(bp); 8524 bnx2x_clear_reset_global(bp);
8477 8525
8526exit_leader_reset2:
8527 /* unload "fake driver" if it was loaded */
8528 if (!global && !BP_NOMCP(bp)) {
8529 bnx2x_fw_command(bp, DRV_MSG_CODE_UNLOAD_REQ_WOL_MCP, 0);
8530 bnx2x_fw_command(bp, DRV_MSG_CODE_UNLOAD_DONE, 0);
8531 }
8478exit_leader_reset: 8532exit_leader_reset:
8479 bp->is_leader = 0; 8533 bp->is_leader = 0;
8480 bnx2x_release_leader_lock(bp); 8534 bnx2x_release_leader_lock(bp);
@@ -8511,13 +8565,16 @@ static inline void bnx2x_recovery_failed(struct bnx2x *bp)
8511static void bnx2x_parity_recover(struct bnx2x *bp) 8565static void bnx2x_parity_recover(struct bnx2x *bp)
8512{ 8566{
8513 bool global = false; 8567 bool global = false;
8568 u32 error_recovered, error_unrecovered;
8569 bool is_parity;
8514 8570
8515 DP(NETIF_MSG_HW, "Handling parity\n"); 8571 DP(NETIF_MSG_HW, "Handling parity\n");
8516 while (1) { 8572 while (1) {
8517 switch (bp->recovery_state) { 8573 switch (bp->recovery_state) {
8518 case BNX2X_RECOVERY_INIT: 8574 case BNX2X_RECOVERY_INIT:
8519 DP(NETIF_MSG_HW, "State is BNX2X_RECOVERY_INIT\n"); 8575 DP(NETIF_MSG_HW, "State is BNX2X_RECOVERY_INIT\n");
8520 bnx2x_chk_parity_attn(bp, &global, false); 8576 is_parity = bnx2x_chk_parity_attn(bp, &global, false);
8577 WARN_ON(!is_parity);
8521 8578
8522 /* Try to get a LEADER_LOCK HW lock */ 8579 /* Try to get a LEADER_LOCK HW lock */
8523 if (bnx2x_trylock_leader_lock(bp)) { 8580 if (bnx2x_trylock_leader_lock(bp)) {
@@ -8541,15 +8598,6 @@ static void bnx2x_parity_recover(struct bnx2x *bp)
8541 8598
8542 bp->recovery_state = BNX2X_RECOVERY_WAIT; 8599 bp->recovery_state = BNX2X_RECOVERY_WAIT;
8543 8600
8544 /*
8545 * Reset MCP command sequence number and MCP mail box
8546 * sequence as we are going to reset the MCP.
8547 */
8548 if (global) {
8549 bp->fw_seq = 0;
8550 bp->fw_drv_pulse_wr_seq = 0;
8551 }
8552
8553 /* Ensure "is_leader", MCP command sequence and 8601 /* Ensure "is_leader", MCP command sequence and
8554 * "recovery_state" update values are seen on other 8602 * "recovery_state" update values are seen on other
8555 * CPUs. 8603 * CPUs.
@@ -8561,10 +8609,10 @@ static void bnx2x_parity_recover(struct bnx2x *bp)
8561 DP(NETIF_MSG_HW, "State is BNX2X_RECOVERY_WAIT\n"); 8609 DP(NETIF_MSG_HW, "State is BNX2X_RECOVERY_WAIT\n");
8562 if (bp->is_leader) { 8610 if (bp->is_leader) {
8563 int other_engine = BP_PATH(bp) ? 0 : 1; 8611 int other_engine = BP_PATH(bp) ? 0 : 1;
8564 u32 other_load_counter = 8612 bool other_load_status =
8565 bnx2x_get_load_cnt(bp, other_engine); 8613 bnx2x_get_load_status(bp, other_engine);
8566 u32 load_counter = 8614 bool load_status =
8567 bnx2x_get_load_cnt(bp, BP_PATH(bp)); 8615 bnx2x_get_load_status(bp, BP_PATH(bp));
8568 global = bnx2x_reset_is_global(bp); 8616 global = bnx2x_reset_is_global(bp);
8569 8617
8570 /* 8618 /*
@@ -8575,8 +8623,8 @@ static void bnx2x_parity_recover(struct bnx2x *bp)
8575 * the the gates will remain closed for that 8623 * the the gates will remain closed for that
8576 * engine. 8624 * engine.
8577 */ 8625 */
8578 if (load_counter || 8626 if (load_status ||
8579 (global && other_load_counter)) { 8627 (global && other_load_status)) {
8580 /* Wait until all other functions get 8628 /* Wait until all other functions get
8581 * down. 8629 * down.
8582 */ 8630 */
@@ -8633,13 +8681,34 @@ static void bnx2x_parity_recover(struct bnx2x *bp)
8633 return; 8681 return;
8634 } 8682 }
8635 8683
8636 if (bnx2x_nic_load(bp, LOAD_NORMAL)) 8684 error_recovered =
8637 bnx2x_recovery_failed(bp); 8685 bp->eth_stats.recoverable_error;
8638 else { 8686 error_unrecovered =
8687 bp->eth_stats.unrecoverable_error;
8688 bp->recovery_state =
8689 BNX2X_RECOVERY_NIC_LOADING;
8690 if (bnx2x_nic_load(bp, LOAD_NORMAL)) {
8691 error_unrecovered++;
8692 netdev_err(bp->dev,
8693 "Recovery failed. "
8694 "Power cycle "
8695 "needed\n");
8696 /* Disconnect this device */
8697 netif_device_detach(bp->dev);
8698 /* Shut down the power */
8699 bnx2x_set_power_state(
8700 bp, PCI_D3hot);
8701 smp_mb();
8702 } else {
8639 bp->recovery_state = 8703 bp->recovery_state =
8640 BNX2X_RECOVERY_DONE; 8704 BNX2X_RECOVERY_DONE;
8705 error_recovered++;
8641 smp_mb(); 8706 smp_mb();
8642 } 8707 }
8708 bp->eth_stats.recoverable_error =
8709 error_recovered;
8710 bp->eth_stats.unrecoverable_error =
8711 error_unrecovered;
8643 8712
8644 return; 8713 return;
8645 } 8714 }
@@ -8795,11 +8864,13 @@ static void __devinit bnx2x_undi_unload(struct bnx2x *bp)
8795{ 8864{
8796 u32 val; 8865 u32 val;
8797 8866
8798 /* Check if there is any driver already loaded */ 8867 /* possibly another driver is trying to reset the chip */
8799 val = REG_RD(bp, MISC_REG_UNPREPARED); 8868 bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RESET);
8800 if (val == 0x1) { 8869
8870 /* check if doorbell queue is reset */
8871 if (REG_RD(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_1_SET)
8872 & MISC_REGISTERS_RESET_REG_1_RST_DORQ) {
8801 8873
8802 bnx2x_acquire_hw_lock(bp, HW_LOCK_RESOURCE_RESET);
8803 /* 8874 /*
8804 * Check if it is the UNDI driver 8875 * Check if it is the UNDI driver
8805 * UNDI driver initializes CID offset for normal bell to 0x7 8876 * UNDI driver initializes CID offset for normal bell to 0x7
@@ -8887,14 +8958,11 @@ static void __devinit bnx2x_undi_unload(struct bnx2x *bp)
8887 8958
8888 /* restore our func and fw_seq */ 8959 /* restore our func and fw_seq */
8889 bp->pf_num = orig_pf_num; 8960 bp->pf_num = orig_pf_num;
8890 bp->fw_seq =
8891 (SHMEM_RD(bp, func_mb[bp->pf_num].drv_mb_header) &
8892 DRV_MSG_SEQ_NUMBER_MASK);
8893 } 8961 }
8894
8895 /* now it's safe to release the lock */
8896 bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RESET);
8897 } 8962 }
8963
8964 /* now it's safe to release the lock */
8965 bnx2x_release_hw_lock(bp, HW_LOCK_RESOURCE_RESET);
8898} 8966}
8899 8967
8900static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp) 8968static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp)
@@ -9915,16 +9983,6 @@ static int __devinit bnx2x_get_hwinfo(struct bnx2x *bp)
9915 9983
9916 bnx2x_get_cnic_info(bp); 9984 bnx2x_get_cnic_info(bp);
9917 9985
9918 /* Get current FW pulse sequence */
9919 if (!BP_NOMCP(bp)) {
9920 int mb_idx = BP_FW_MB_IDX(bp);
9921
9922 bp->fw_drv_pulse_wr_seq =
9923 (SHMEM_RD(bp, func_mb[mb_idx].drv_pulse_mb) &
9924 DRV_PULSE_SEQ_MASK);
9925 BNX2X_DEV_INFO("drv_pulse 0x%x\n", bp->fw_drv_pulse_wr_seq);
9926 }
9927
9928 return rc; 9986 return rc;
9929} 9987}
9930 9988
@@ -10094,14 +10152,6 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
10094 if (!BP_NOMCP(bp)) 10152 if (!BP_NOMCP(bp))
10095 bnx2x_undi_unload(bp); 10153 bnx2x_undi_unload(bp);
10096 10154
10097 /* init fw_seq after undi_unload! */
10098 if (!BP_NOMCP(bp)) {
10099 bp->fw_seq =
10100 (SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_mb_header) &
10101 DRV_MSG_SEQ_NUMBER_MASK);
10102 BNX2X_DEV_INFO("fw_seq 0x%08x\n", bp->fw_seq);
10103 }
10104
10105 if (CHIP_REV_IS_FPGA(bp)) 10155 if (CHIP_REV_IS_FPGA(bp))
10106 dev_err(&bp->pdev->dev, "FPGA detected\n"); 10156 dev_err(&bp->pdev->dev, "FPGA detected\n");
10107 10157
@@ -10183,14 +10233,14 @@ static int bnx2x_open(struct net_device *dev)
10183 struct bnx2x *bp = netdev_priv(dev); 10233 struct bnx2x *bp = netdev_priv(dev);
10184 bool global = false; 10234 bool global = false;
10185 int other_engine = BP_PATH(bp) ? 0 : 1; 10235 int other_engine = BP_PATH(bp) ? 0 : 1;
10186 u32 other_load_counter, load_counter; 10236 bool other_load_status, load_status;
10187 10237
10188 netif_carrier_off(dev); 10238 netif_carrier_off(dev);
10189 10239
10190 bnx2x_set_power_state(bp, PCI_D0); 10240 bnx2x_set_power_state(bp, PCI_D0);
10191 10241
10192 other_load_counter = bnx2x_get_load_cnt(bp, other_engine); 10242 other_load_status = bnx2x_get_load_status(bp, other_engine);
10193 load_counter = bnx2x_get_load_cnt(bp, BP_PATH(bp)); 10243 load_status = bnx2x_get_load_status(bp, BP_PATH(bp));
10194 10244
10195 /* 10245 /*
10196 * If parity had happen during the unload, then attentions 10246 * If parity had happen during the unload, then attentions
@@ -10216,8 +10266,8 @@ static int bnx2x_open(struct net_device *dev)
10216 * global blocks only the first in the chip should try 10266 * global blocks only the first in the chip should try
10217 * to recover. 10267 * to recover.
10218 */ 10268 */
10219 if ((!load_counter && 10269 if ((!load_status &&
10220 (!global || !other_load_counter)) && 10270 (!global || !other_load_status)) &&
10221 bnx2x_trylock_leader_lock(bp) && 10271 bnx2x_trylock_leader_lock(bp) &&
10222 !bnx2x_leader_reset(bp)) { 10272 !bnx2x_leader_reset(bp)) {
10223 netdev_info(bp->dev, "Recovered in open\n"); 10273 netdev_info(bp->dev, "Recovered in open\n");
@@ -10536,6 +10586,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,
10536{ 10586{
10537 struct bnx2x *bp; 10587 struct bnx2x *bp;
10538 int rc; 10588 int rc;
10589 u32 pci_cfg_dword;
10539 bool chip_is_e1x = (board_type == BCM57710 || 10590 bool chip_is_e1x = (board_type == BCM57710 ||
10540 board_type == BCM57711 || 10591 board_type == BCM57711 ||
10541 board_type == BCM57711E); 10592 board_type == BCM57711E);
@@ -10546,7 +10597,6 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,
10546 bp->dev = dev; 10597 bp->dev = dev;
10547 bp->pdev = pdev; 10598 bp->pdev = pdev;
10548 bp->flags = 0; 10599 bp->flags = 0;
10549 bp->pf_num = PCI_FUNC(pdev->devfn);
10550 10600
10551 rc = pci_enable_device(pdev); 10601 rc = pci_enable_device(pdev);
10552 if (rc) { 10602 if (rc) {
@@ -10613,6 +10663,21 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,
10613 goto err_out_release; 10663 goto err_out_release;
10614 } 10664 }
10615 10665
10666 /* In E1/E1H use pci device function given by kernel.
10667 * In E2/E3 read physical function from ME register since these chips
10668 * support Physical Device Assignment where kernel BDF maybe arbitrary
10669 * (depending on hypervisor).
10670 */
10671 if (chip_is_e1x)
10672 bp->pf_num = PCI_FUNC(pdev->devfn);
10673 else {/* chip is E2/3*/
10674 pci_read_config_dword(bp->pdev,
10675 PCICFG_ME_REGISTER, &pci_cfg_dword);
10676 bp->pf_num = (u8)((pci_cfg_dword & ME_REG_ABS_PF_NUM) >>
10677 ME_REG_ABS_PF_NUM_SHIFT);
10678 }
10679 DP(BNX2X_MSG_SP, "me reg PF num: %d\n", bp->pf_num);
10680
10616 bnx2x_set_power_state(bp, PCI_D0); 10681 bnx2x_set_power_state(bp, PCI_D0);
10617 10682
10618 /* clean indirect addresses */ 10683 /* clean indirect addresses */
@@ -10642,7 +10707,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,
10642 REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ, 1); 10707 REG_WR(bp, PGLUE_B_REG_INTERNAL_PFID_ENABLE_TARGET_READ, 1);
10643 10708
10644 /* Reset the load counter */ 10709 /* Reset the load counter */
10645 bnx2x_clear_load_cnt(bp); 10710 bnx2x_clear_load_status(bp);
10646 10711
10647 dev->watchdog_timeo = TX_TIMEOUT; 10712 dev->watchdog_timeo = TX_TIMEOUT;
10648 10713
@@ -10829,10 +10894,8 @@ static inline void be16_to_cpu_n(const u8 *_source, u8 *_target, u32 n)
10829do { \ 10894do { \
10830 u32 len = be32_to_cpu(fw_hdr->arr.len); \ 10895 u32 len = be32_to_cpu(fw_hdr->arr.len); \
10831 bp->arr = kmalloc(len, GFP_KERNEL); \ 10896 bp->arr = kmalloc(len, GFP_KERNEL); \
10832 if (!bp->arr) { \ 10897 if (!bp->arr) \
10833 pr_err("Failed to allocate %d bytes for "#arr"\n", len); \
10834 goto lbl; \ 10898 goto lbl; \
10835 } \
10836 func(bp->firmware->data + be32_to_cpu(fw_hdr->arr.offset), \ 10899 func(bp->firmware->data + be32_to_cpu(fw_hdr->arr.offset), \
10837 (u8 *)bp->arr, len); \ 10900 (u8 *)bp->arr, len); \
10838} while (0) 10901} while (0)
@@ -11070,10 +11133,8 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
11070 11133
11071 /* dev zeroed in init_etherdev */ 11134 /* dev zeroed in init_etherdev */
11072 dev = alloc_etherdev_mqs(sizeof(*bp), tx_count, rx_count); 11135 dev = alloc_etherdev_mqs(sizeof(*bp), tx_count, rx_count);
11073 if (!dev) { 11136 if (!dev)
11074 dev_err(&pdev->dev, "Cannot allocate net device\n");
11075 return -ENOMEM; 11137 return -ENOMEM;
11076 }
11077 11138
11078 bp = netdev_priv(dev); 11139 bp = netdev_priv(dev);
11079 11140
@@ -11295,13 +11356,6 @@ static void bnx2x_eeh_recover(struct bnx2x *bp)
11295 if ((val & (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) 11356 if ((val & (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB))
11296 != (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB)) 11357 != (SHR_MEM_VALIDITY_DEV_INFO | SHR_MEM_VALIDITY_MB))
11297 BNX2X_ERR("BAD MCP validity signature\n"); 11358 BNX2X_ERR("BAD MCP validity signature\n");
11298
11299 if (!BP_NOMCP(bp)) {
11300 bp->fw_seq =
11301 (SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_mb_header) &
11302 DRV_MSG_SEQ_NUMBER_MASK);
11303 BNX2X_DEV_INFO("fw_seq 0x%08x\n", bp->fw_seq);
11304 }
11305} 11359}
11306 11360
11307/** 11361/**
@@ -11557,6 +11611,13 @@ static int bnx2x_cnic_sp_queue(struct net_device *dev,
11557 return -EIO; 11611 return -EIO;
11558#endif 11612#endif
11559 11613
11614 if ((bp->recovery_state != BNX2X_RECOVERY_DONE) &&
11615 (bp->recovery_state != BNX2X_RECOVERY_NIC_LOADING)) {
11616 netdev_err(dev, "Handling parity error recovery. Try again "
11617 "later\n");
11618 return -EAGAIN;
11619 }
11620
11560 spin_lock_bh(&bp->spq_lock); 11621 spin_lock_bh(&bp->spq_lock);
11561 11622
11562 for (i = 0; i < count; i++) { 11623 for (i = 0; i < count; i++) {
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
index dddbcf6e154e..c95d9dcac6df 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
@@ -1,6 +1,6 @@
1/* bnx2x_reg.h: Broadcom Everest network driver. 1/* bnx2x_reg.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007-2011 Broadcom Corporation 3 * Copyright (c) 2007-2012 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -5731,6 +5731,7 @@
5731#define MISC_REGISTERS_GPIO_PORT_SHIFT 4 5731#define MISC_REGISTERS_GPIO_PORT_SHIFT 4
5732#define MISC_REGISTERS_GPIO_SET_POS 8 5732#define MISC_REGISTERS_GPIO_SET_POS 8
5733#define MISC_REGISTERS_RESET_REG_1_CLEAR 0x588 5733#define MISC_REGISTERS_RESET_REG_1_CLEAR 0x588
5734#define MISC_REGISTERS_RESET_REG_1_RST_DORQ (0x1<<19)
5734#define MISC_REGISTERS_RESET_REG_1_RST_HC (0x1<<29) 5735#define MISC_REGISTERS_RESET_REG_1_RST_HC (0x1<<29)
5735#define MISC_REGISTERS_RESET_REG_1_RST_NIG (0x1<<7) 5736#define MISC_REGISTERS_RESET_REG_1_RST_NIG (0x1<<7)
5736#define MISC_REGISTERS_RESET_REG_1_RST_PXP (0x1<<26) 5737#define MISC_REGISTERS_RESET_REG_1_RST_PXP (0x1<<26)
@@ -5783,15 +5784,17 @@
5783#define MISC_REGISTERS_SPIO_OUTPUT_HIGH 1 5784#define MISC_REGISTERS_SPIO_OUTPUT_HIGH 1
5784#define MISC_REGISTERS_SPIO_OUTPUT_LOW 0 5785#define MISC_REGISTERS_SPIO_OUTPUT_LOW 0
5785#define MISC_REGISTERS_SPIO_SET_POS 8 5786#define MISC_REGISTERS_SPIO_SET_POS 8
5786#define HW_LOCK_DRV_FLAGS 10
5787#define HW_LOCK_MAX_RESOURCE_VALUE 31 5787#define HW_LOCK_MAX_RESOURCE_VALUE 31
5788#define HW_LOCK_RESOURCE_DRV_FLAGS 10
5788#define HW_LOCK_RESOURCE_GPIO 1 5789#define HW_LOCK_RESOURCE_GPIO 1
5789#define HW_LOCK_RESOURCE_MDIO 0 5790#define HW_LOCK_RESOURCE_MDIO 0
5791#define HW_LOCK_RESOURCE_NVRAM 12
5790#define HW_LOCK_RESOURCE_PORT0_ATT_MASK 3 5792#define HW_LOCK_RESOURCE_PORT0_ATT_MASK 3
5791#define HW_LOCK_RESOURCE_RECOVERY_LEADER_0 8 5793#define HW_LOCK_RESOURCE_RECOVERY_LEADER_0 8
5792#define HW_LOCK_RESOURCE_RECOVERY_LEADER_1 9 5794#define HW_LOCK_RESOURCE_RECOVERY_LEADER_1 9
5793#define HW_LOCK_RESOURCE_SPIO 2 5795#define HW_LOCK_RESOURCE_RECOVERY_REG 11
5794#define HW_LOCK_RESOURCE_RESET 5 5796#define HW_LOCK_RESOURCE_RESET 5
5797#define HW_LOCK_RESOURCE_SPIO 2
5795#define AEU_INPUTS_ATTN_BITS_ATC_HW_INTERRUPT (0x1<<4) 5798#define AEU_INPUTS_ATTN_BITS_ATC_HW_INTERRUPT (0x1<<4)
5796#define AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR (0x1<<5) 5799#define AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR (0x1<<5)
5797#define AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR (0x1<<18) 5800#define AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR (0x1<<18)
@@ -6023,7 +6026,8 @@
6023#define PCICFG_MSI_CONTROL_64_BIT_ADDR_CAP (0x1<<23) 6026#define PCICFG_MSI_CONTROL_64_BIT_ADDR_CAP (0x1<<23)
6024#define PCICFG_MSI_CONTROL_MSI_PVMASK_CAPABLE (0x1<<24) 6027#define PCICFG_MSI_CONTROL_MSI_PVMASK_CAPABLE (0x1<<24)
6025#define PCICFG_GRC_ADDRESS 0x78 6028#define PCICFG_GRC_ADDRESS 0x78
6026#define PCICFG_GRC_DATA 0x80 6029#define PCICFG_GRC_DATA 0x80
6030#define PCICFG_ME_REGISTER 0x98
6027#define PCICFG_MSIX_CAP_ID_OFFSET 0xa0 6031#define PCICFG_MSIX_CAP_ID_OFFSET 0xa0
6028#define PCICFG_MSIX_CONTROL_TABLE_SIZE (0x7ff<<16) 6032#define PCICFG_MSIX_CONTROL_TABLE_SIZE (0x7ff<<16)
6029#define PCICFG_MSIX_CONTROL_RESERVED (0x7<<27) 6033#define PCICFG_MSIX_CONTROL_RESERVED (0x7<<27)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
index cb6339c35571..ac15f747f8da 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
@@ -1,6 +1,6 @@
1/* bnx2x_sp.c: Broadcom Everest network driver. 1/* bnx2x_sp.c: Broadcom Everest network driver.
2 * 2 *
3 * Copyright 2011 Broadcom Corporation 3 * Copyright (c) 2011-2012 Broadcom Corporation
4 * 4 *
5 * Unless you and Broadcom execute a separate written software license 5 * Unless you and Broadcom execute a separate written software license
6 * agreement governing use of this software, this software is licensed to you 6 * agreement governing use of this software, this software is licensed to you
@@ -1836,6 +1836,7 @@ static int bnx2x_vlan_mac_del_all(struct bnx2x *bp,
1836 rc = exeq->remove(bp, exeq->owner, exeq_pos); 1836 rc = exeq->remove(bp, exeq->owner, exeq_pos);
1837 if (rc) { 1837 if (rc) {
1838 BNX2X_ERR("Failed to remove command\n"); 1838 BNX2X_ERR("Failed to remove command\n");
1839 spin_unlock_bh(&exeq->lock);
1839 return rc; 1840 return rc;
1840 } 1841 }
1841 list_del(&exeq_pos->link); 1842 list_del(&exeq_pos->link);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
index 66da39f0c84a..71e039b618a7 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
@@ -1,6 +1,6 @@
1/* bnx2x_sp.h: Broadcom Everest network driver. 1/* bnx2x_sp.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright 2011 Broadcom Corporation 3 * Copyright (c) 2011-2012 Broadcom Corporation
4 * 4 *
5 * Unless you and Broadcom execute a separate written software license 5 * Unless you and Broadcom execute a separate written software license
6 * agreement governing use of this software, this software is licensed to you 6 * agreement governing use of this software, this software is licensed to you
@@ -803,10 +803,10 @@ enum bnx2x_q_type {
803}; 803};
804 804
805#define BNX2X_PRIMARY_CID_INDEX 0 805#define BNX2X_PRIMARY_CID_INDEX 0
806#define BNX2X_MULTI_TX_COS_E1X 1 806#define BNX2X_MULTI_TX_COS_E1X 3 /* QM only */
807#define BNX2X_MULTI_TX_COS_E2_E3A0 2 807#define BNX2X_MULTI_TX_COS_E2_E3A0 2
808#define BNX2X_MULTI_TX_COS_E3B0 3 808#define BNX2X_MULTI_TX_COS_E3B0 3
809#define BNX2X_MULTI_TX_COS BNX2X_MULTI_TX_COS_E3B0 809#define BNX2X_MULTI_TX_COS 3 /* Maximum possible */
810 810
811 811
812struct bnx2x_queue_init_params { 812struct bnx2x_queue_init_params {
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
index bc0121ac291e..7b9b304b9107 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
@@ -1,6 +1,6 @@
1/* bnx2x_stats.c: Broadcom Everest network driver. 1/* bnx2x_stats.c: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007-2011 Broadcom Corporation 3 * Copyright (c) 2007-2012 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h
index 683deb053109..7e979686cd68 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h
@@ -1,6 +1,6 @@
1/* bnx2x_stats.h: Broadcom Everest network driver. 1/* bnx2x_stats.h: Broadcom Everest network driver.
2 * 2 *
3 * Copyright (c) 2007-2011 Broadcom Corporation 3 * Copyright (c) 2007-2012 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -199,6 +199,10 @@ struct bnx2x_eth_stats {
199 u32 pfc_frames_received_lo; 199 u32 pfc_frames_received_lo;
200 u32 pfc_frames_sent_hi; 200 u32 pfc_frames_sent_hi;
201 u32 pfc_frames_sent_lo; 201 u32 pfc_frames_sent_lo;
202
203 /* Recovery */
204 u32 recoverable_error;
205 u32 unrecoverable_error;
202}; 206};
203 207
204 208
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index dd3a0a232ea0..df429959abdd 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -1,6 +1,6 @@
1/* cnic.c: Broadcom CNIC core network driver. 1/* cnic.c: Broadcom CNIC core network driver.
2 * 2 *
3 * Copyright (c) 2006-2011 Broadcom Corporation 3 * Copyright (c) 2006-2012 Broadcom Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -380,6 +380,8 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type,
380 if (cnic_in_use(csk) && 380 if (cnic_in_use(csk) &&
381 test_bit(SK_F_CONNECT_START, &csk->flags)) { 381 test_bit(SK_F_CONNECT_START, &csk->flags)) {
382 382
383 csk->vlan_id = path_resp->vlan_id;
384
383 memcpy(csk->ha, path_resp->mac_addr, 6); 385 memcpy(csk->ha, path_resp->mac_addr, 6);
384 if (test_bit(SK_F_IPV6, &csk->flags)) 386 if (test_bit(SK_F_IPV6, &csk->flags))
385 memcpy(&csk->src_ip[0], &path_resp->src.v6_addr, 387 memcpy(&csk->src_ip[0], &path_resp->src.v6_addr,
@@ -2521,12 +2523,35 @@ static void cnic_bnx2x_kwqe_err(struct cnic_dev *dev, struct kwqe *kwqe)
2521 u32 cid; 2523 u32 cid;
2522 u32 opcode = KWQE_OPCODE(kwqe->kwqe_op_flag); 2524 u32 opcode = KWQE_OPCODE(kwqe->kwqe_op_flag);
2523 u32 layer_code = kwqe->kwqe_op_flag & KWQE_LAYER_MASK; 2525 u32 layer_code = kwqe->kwqe_op_flag & KWQE_LAYER_MASK;
2526 u32 kcqe_op;
2524 int ulp_type; 2527 int ulp_type;
2525 2528
2526 cid = kwqe->kwqe_info0; 2529 cid = kwqe->kwqe_info0;
2527 memset(&kcqe, 0, sizeof(kcqe)); 2530 memset(&kcqe, 0, sizeof(kcqe));
2528 2531
2529 if (layer_code == KWQE_FLAGS_LAYER_MASK_L5_ISCSI) { 2532 if (layer_code == KWQE_FLAGS_LAYER_MASK_L5_FCOE) {
2533 u32 l5_cid = 0;
2534
2535 ulp_type = CNIC_ULP_FCOE;
2536 if (opcode == FCOE_KWQE_OPCODE_DISABLE_CONN) {
2537 struct fcoe_kwqe_conn_enable_disable *req;
2538
2539 req = (struct fcoe_kwqe_conn_enable_disable *) kwqe;
2540 kcqe_op = FCOE_KCQE_OPCODE_DISABLE_CONN;
2541 cid = req->context_id;
2542 l5_cid = req->conn_id;
2543 } else if (opcode == FCOE_KWQE_OPCODE_DESTROY) {
2544 kcqe_op = FCOE_KCQE_OPCODE_DESTROY_FUNC;
2545 } else {
2546 return;
2547 }
2548 kcqe.kcqe_op_flag = kcqe_op << KCQE_FLAGS_OPCODE_SHIFT;
2549 kcqe.kcqe_op_flag |= KCQE_FLAGS_LAYER_MASK_L5_FCOE;
2550 kcqe.kcqe_info1 = FCOE_KCQE_COMPLETION_STATUS_NIC_ERROR;
2551 kcqe.kcqe_info2 = cid;
2552 kcqe.kcqe_info0 = l5_cid;
2553
2554 } else if (layer_code == KWQE_FLAGS_LAYER_MASK_L5_ISCSI) {
2530 ulp_type = CNIC_ULP_ISCSI; 2555 ulp_type = CNIC_ULP_ISCSI;
2531 if (opcode == ISCSI_KWQE_OPCODE_UPDATE_CONN) 2556 if (opcode == ISCSI_KWQE_OPCODE_UPDATE_CONN)
2532 cid = kwqe->kwqe_info1; 2557 cid = kwqe->kwqe_info1;
@@ -2539,7 +2564,6 @@ static void cnic_bnx2x_kwqe_err(struct cnic_dev *dev, struct kwqe *kwqe)
2539 2564
2540 } else if (layer_code == KWQE_FLAGS_LAYER_MASK_L4) { 2565 } else if (layer_code == KWQE_FLAGS_LAYER_MASK_L4) {
2541 struct l4_kcq *l4kcqe = (struct l4_kcq *) &kcqe; 2566 struct l4_kcq *l4kcqe = (struct l4_kcq *) &kcqe;
2542 u32 kcqe_op;
2543 2567
2544 ulp_type = CNIC_ULP_L4; 2568 ulp_type = CNIC_ULP_L4;
2545 if (opcode == L4_KWQE_OPCODE_VALUE_CONNECT1) 2569 if (opcode == L4_KWQE_OPCODE_VALUE_CONNECT1)
@@ -2686,9 +2710,17 @@ static int cnic_submit_bnx2x_fcoe_kwqes(struct cnic_dev *dev,
2686 opcode); 2710 opcode);
2687 break; 2711 break;
2688 } 2712 }
2689 if (ret < 0) 2713 if (ret < 0) {
2690 netdev_err(dev->netdev, "KWQE(0x%x) failed\n", 2714 netdev_err(dev->netdev, "KWQE(0x%x) failed\n",
2691 opcode); 2715 opcode);
2716
2717 /* Possibly bnx2x parity error, send completion
2718 * to ulp drivers with error code to speed up
2719 * cleanup and reset recovery.
2720 */
2721 if (ret == -EIO || ret == -EAGAIN)
2722 cnic_bnx2x_kwqe_err(dev, kwqe);
2723 }
2692 i += work; 2724 i += work;
2693 } 2725 }
2694 return 0; 2726 return 0;
@@ -3897,6 +3929,8 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe)
3897 case L4_KCQE_OPCODE_VALUE_CONNECT_COMPLETE: 3929 case L4_KCQE_OPCODE_VALUE_CONNECT_COMPLETE:
3898 if (l4kcqe->status == 0) 3930 if (l4kcqe->status == 0)
3899 set_bit(SK_F_OFFLD_COMPLETE, &csk->flags); 3931 set_bit(SK_F_OFFLD_COMPLETE, &csk->flags);
3932 else if (l4kcqe->status == L4_KCQE_COMPLETION_STATUS_NIC_ERROR)
3933 set_bit(SK_F_HW_ERR, &csk->flags);
3900 3934
3901 smp_mb__before_clear_bit(); 3935 smp_mb__before_clear_bit();
3902 clear_bit(SK_F_OFFLD_SCHED, &csk->flags); 3936 clear_bit(SK_F_OFFLD_SCHED, &csk->flags);
diff --git a/drivers/net/ethernet/broadcom/cnic_defs.h b/drivers/net/ethernet/broadcom/cnic_defs.h
index 86936f6b6dbc..7271f14bda3b 100644
--- a/drivers/net/ethernet/broadcom/cnic_defs.h
+++ b/drivers/net/ethernet/broadcom/cnic_defs.h
@@ -1,7 +1,7 @@
1 1
2/* cnic.c: Broadcom CNIC core network driver. 2/* cnic.c: Broadcom CNIC core network driver.
3 * 3 *
4 * Copyright (c) 2006-2009 Broadcom Corporation 4 * Copyright (c) 2006-2012 Broadcom Corporation
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -69,6 +69,7 @@
69 69
70#define FCOE_KCQE_COMPLETION_STATUS_ERROR (0x1) 70#define FCOE_KCQE_COMPLETION_STATUS_ERROR (0x1)
71#define FCOE_KCQE_COMPLETION_STATUS_CTX_ALLOC_FAILURE (0x3) 71#define FCOE_KCQE_COMPLETION_STATUS_CTX_ALLOC_FAILURE (0x3)
72#define FCOE_KCQE_COMPLETION_STATUS_NIC_ERROR (0x5)
72 73
73/* KCQ (kernel completion queue) response op codes */ 74/* KCQ (kernel completion queue) response op codes */
74#define L4_KCQE_OPCODE_VALUE_CLOSE_COMP (53) 75#define L4_KCQE_OPCODE_VALUE_CLOSE_COMP (53)
diff --git a/drivers/net/ethernet/broadcom/cnic_if.h b/drivers/net/ethernet/broadcom/cnic_if.h
index 1517763d4e55..60deb84d36bd 100644
--- a/drivers/net/ethernet/broadcom/cnic_if.h
+++ b/drivers/net/ethernet/broadcom/cnic_if.h
@@ -12,8 +12,8 @@
12#ifndef CNIC_IF_H 12#ifndef CNIC_IF_H
13#define CNIC_IF_H 13#define CNIC_IF_H
14 14
15#define CNIC_MODULE_VERSION "2.5.8" 15#define CNIC_MODULE_VERSION "2.5.9"
16#define CNIC_MODULE_RELDATE "Jan 3, 2012" 16#define CNIC_MODULE_RELDATE "Feb 8, 2012"
17 17
18#define CNIC_ULP_RDMA 0 18#define CNIC_ULP_RDMA 0
19#define CNIC_ULP_ISCSI 1 19#define CNIC_ULP_ISCSI 1
diff --git a/drivers/net/ethernet/broadcom/sb1250-mac.c b/drivers/net/ethernet/broadcom/sb1250-mac.c
index 084904ceaa30..49e7a258da8a 100644
--- a/drivers/net/ethernet/broadcom/sb1250-mac.c
+++ b/drivers/net/ethernet/broadcom/sb1250-mac.c
@@ -2623,8 +2623,6 @@ static int __devinit sbmac_probe(struct platform_device *pldev)
2623 */ 2623 */
2624 dev = alloc_etherdev(sizeof(struct sbmac_softc)); 2624 dev = alloc_etherdev(sizeof(struct sbmac_softc));
2625 if (!dev) { 2625 if (!dev) {
2626 printk(KERN_ERR "%s: unable to allocate etherdev\n",
2627 dev_name(&pldev->dev));
2628 err = -ENOMEM; 2626 err = -ENOMEM;
2629 goto out_unmap; 2627 goto out_unmap;
2630 } 2628 }
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index a1f2e0fed78b..3bf3adca3695 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -15471,7 +15471,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
15471 15471
15472 dev = alloc_etherdev_mq(sizeof(*tp), TG3_IRQ_MAX_VECS); 15472 dev = alloc_etherdev_mq(sizeof(*tp), TG3_IRQ_MAX_VECS);
15473 if (!dev) { 15473 if (!dev) {
15474 dev_err(&pdev->dev, "Etherdev alloc failed, aborting\n");
15475 err = -ENOMEM; 15474 err = -ENOMEM;
15476 goto err_out_power_down; 15475 goto err_out_power_down;
15477 } 15476 }
diff --git a/drivers/net/ethernet/brocade/bna/bfa_defs.h b/drivers/net/ethernet/brocade/bna/bfa_defs.h
index 871c6309334c..48f877337390 100644
--- a/drivers/net/ethernet/brocade/bna/bfa_defs.h
+++ b/drivers/net/ethernet/brocade/bna/bfa_defs.h
@@ -297,6 +297,7 @@ enum bfa_mode {
297#define BFA_FLASH_PART_ENTRY_SIZE 32 /* partition entry size */ 297#define BFA_FLASH_PART_ENTRY_SIZE 32 /* partition entry size */
298#define BFA_FLASH_PART_MAX 32 /* maximal # of partitions */ 298#define BFA_FLASH_PART_MAX 32 /* maximal # of partitions */
299#define BFA_TOTAL_FLASH_SIZE 0x400000 299#define BFA_TOTAL_FLASH_SIZE 0x400000
300#define BFA_FLASH_PART_FWIMG 2
300#define BFA_FLASH_PART_MFG 7 301#define BFA_FLASH_PART_MFG 7
301 302
302/* 303/*
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c
index be7d91e4b785..ff78f770dec9 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -3284,7 +3284,6 @@ bnad_pci_probe(struct pci_dev *pdev,
3284 */ 3284 */
3285 netdev = alloc_etherdev(sizeof(struct bnad)); 3285 netdev = alloc_etherdev(sizeof(struct bnad));
3286 if (!netdev) { 3286 if (!netdev) {
3287 dev_err(&pdev->dev, "netdev allocation failed\n");
3288 err = -ENOMEM; 3287 err = -ENOMEM;
3289 return err; 3288 return err;
3290 } 3289 }
diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
index 592ad3929f53..c9fdceb135f3 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
@@ -62,8 +62,6 @@ bnad_debugfs_open_fwtrc(struct inode *inode, struct file *file)
62 if (!fw_debug->debug_buffer) { 62 if (!fw_debug->debug_buffer) {
63 kfree(fw_debug); 63 kfree(fw_debug);
64 fw_debug = NULL; 64 fw_debug = NULL;
65 pr_warn("bna %s: Failed to allocate fwtrc buffer\n",
66 pci_name(bnad->pcidev));
67 return -ENOMEM; 65 return -ENOMEM;
68 } 66 }
69 67
@@ -105,8 +103,6 @@ bnad_debugfs_open_fwsave(struct inode *inode, struct file *file)
105 if (!fw_debug->debug_buffer) { 103 if (!fw_debug->debug_buffer) {
106 kfree(fw_debug); 104 kfree(fw_debug);
107 fw_debug = NULL; 105 fw_debug = NULL;
108 pr_warn("bna %s: Failed to allocate fwsave buffer\n",
109 pci_name(bnad->pcidev));
110 return -ENOMEM; 106 return -ENOMEM;
111 } 107 }
112 108
@@ -208,8 +204,6 @@ bnad_debugfs_open_drvinfo(struct inode *inode, struct file *file)
208 if (!drv_info->debug_buffer) { 204 if (!drv_info->debug_buffer) {
209 kfree(drv_info); 205 kfree(drv_info);
210 drv_info = NULL; 206 drv_info = NULL;
211 pr_warn("bna %s: Failed to allocate drv info buffer\n",
212 pci_name(bnad->pcidev));
213 return -ENOMEM; 207 return -ENOMEM;
214 } 208 }
215 209
@@ -348,11 +342,8 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *buf,
348 342
349 /* Allocate memory to store the user space buf */ 343 /* Allocate memory to store the user space buf */
350 kern_buf = kzalloc(nbytes, GFP_KERNEL); 344 kern_buf = kzalloc(nbytes, GFP_KERNEL);
351 if (!kern_buf) { 345 if (!kern_buf)
352 pr_warn("bna %s: Failed to allocate user buffer\n",
353 pci_name(bnad->pcidev));
354 return -ENOMEM; 346 return -ENOMEM;
355 }
356 347
357 if (copy_from_user(kern_buf, (void __user *)buf, nbytes)) { 348 if (copy_from_user(kern_buf, (void __user *)buf, nbytes)) {
358 kfree(kern_buf); 349 kfree(kern_buf);
@@ -373,11 +364,8 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *buf,
373 bnad->reglen = 0; 364 bnad->reglen = 0;
374 365
375 bnad->regdata = kzalloc(len << 2, GFP_KERNEL); 366 bnad->regdata = kzalloc(len << 2, GFP_KERNEL);
376 if (!bnad->regdata) { 367 if (!bnad->regdata)
377 pr_warn("bna %s: Failed to allocate regrd buffer\n",
378 pci_name(bnad->pcidev));
379 return -ENOMEM; 368 return -ENOMEM;
380 }
381 369
382 bnad->reglen = len << 2; 370 bnad->reglen = len << 2;
383 rb = bfa_ioc_bar0(ioc); 371 rb = bfa_ioc_bar0(ioc);
@@ -421,11 +409,8 @@ bnad_debugfs_write_regwr(struct file *file, const char __user *buf,
421 409
422 /* Allocate memory to store the user space buf */ 410 /* Allocate memory to store the user space buf */
423 kern_buf = kzalloc(nbytes, GFP_KERNEL); 411 kern_buf = kzalloc(nbytes, GFP_KERNEL);
424 if (!kern_buf) { 412 if (!kern_buf)
425 pr_warn("bna %s: Failed to allocate user buffer\n",
426 pci_name(bnad->pcidev));
427 return -ENOMEM; 413 return -ENOMEM;
428 }
429 414
430 if (copy_from_user(kern_buf, (void __user *)buf, nbytes)) { 415 if (copy_from_user(kern_buf, (void __user *)buf, nbytes)) {
431 kfree(kern_buf); 416 kfree(kern_buf);
diff --git a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
index 803ea32aa99d..ab753d7334a6 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
@@ -1070,6 +1070,47 @@ done:
1070 return ret; 1070 return ret;
1071} 1071}
1072 1072
1073static int
1074bnad_flash_device(struct net_device *netdev, struct ethtool_flash *eflash)
1075{
1076 struct bnad *bnad = netdev_priv(netdev);
1077 struct bnad_iocmd_comp fcomp;
1078 const struct firmware *fw;
1079 int ret = 0;
1080
1081 ret = request_firmware(&fw, eflash->data, &bnad->pcidev->dev);
1082 if (ret) {
1083 pr_err("BNA: Can't locate firmware %s\n", eflash->data);
1084 goto out;
1085 }
1086
1087 fcomp.bnad = bnad;
1088 fcomp.comp_status = 0;
1089
1090 init_completion(&fcomp.comp);
1091 spin_lock_irq(&bnad->bna_lock);
1092 ret = bfa_nw_flash_update_part(&bnad->bna.flash, BFA_FLASH_PART_FWIMG,
1093 bnad->id, (u8 *)fw->data, fw->size, 0,
1094 bnad_cb_completion, &fcomp);
1095 if (ret != BFA_STATUS_OK) {
1096 pr_warn("BNA: Flash update failed with err: %d\n", ret);
1097 ret = -EIO;
1098 spin_unlock_irq(&bnad->bna_lock);
1099 goto out;
1100 }
1101
1102 spin_unlock_irq(&bnad->bna_lock);
1103 wait_for_completion(&fcomp.comp);
1104 if (fcomp.comp_status != BFA_STATUS_OK) {
1105 ret = -EIO;
1106 pr_warn("BNA: Firmware image update to flash failed with: %d\n",
1107 fcomp.comp_status);
1108 }
1109out:
1110 release_firmware(fw);
1111 return ret;
1112}
1113
1073static const struct ethtool_ops bnad_ethtool_ops = { 1114static const struct ethtool_ops bnad_ethtool_ops = {
1074 .get_settings = bnad_get_settings, 1115 .get_settings = bnad_get_settings,
1075 .set_settings = bnad_set_settings, 1116 .set_settings = bnad_set_settings,
@@ -1088,6 +1129,7 @@ static const struct ethtool_ops bnad_ethtool_ops = {
1088 .get_eeprom_len = bnad_get_eeprom_len, 1129 .get_eeprom_len = bnad_get_eeprom_len,
1089 .get_eeprom = bnad_get_eeprom, 1130 .get_eeprom = bnad_get_eeprom,
1090 .set_eeprom = bnad_set_eeprom, 1131 .set_eeprom = bnad_set_eeprom,
1132 .flash_device = bnad_flash_device,
1091}; 1133};
1092 1134
1093void 1135void
diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
index 1a5b6efa0120..906117016fc4 100644
--- a/drivers/net/ethernet/cadence/at91_ether.c
+++ b/drivers/net/ethernet/cadence/at91_ether.c
@@ -886,7 +886,7 @@ static void at91ether_rx(struct net_device *dev)
886 while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) { 886 while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) {
887 p_recv = dlist->recv_buf[lp->rxBuffIndex]; 887 p_recv = dlist->recv_buf[lp->rxBuffIndex];
888 pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */ 888 pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */
889 skb = dev_alloc_skb(pktlen + 2); 889 skb = netdev_alloc_skb(dev, pktlen + 2);
890 if (skb != NULL) { 890 if (skb != NULL) {
891 skb_reserve(skb, 2); 891 skb_reserve(skb, 2);
892 memcpy(skb_put(skb, pktlen), p_recv, pktlen); 892 memcpy(skb_put(skb, pktlen), p_recv, pktlen);
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 23200680d4c1..85e044567f68 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -397,7 +397,7 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
397 netdev_dbg(bp->dev, "macb_rx_frame frags %u - %u (len %u)\n", 397 netdev_dbg(bp->dev, "macb_rx_frame frags %u - %u (len %u)\n",
398 first_frag, last_frag, len); 398 first_frag, last_frag, len);
399 399
400 skb = dev_alloc_skb(len + RX_OFFSET); 400 skb = netdev_alloc_skb(bp->dev, len + RX_OFFSET);
401 if (!skb) { 401 if (!skb) {
402 bp->stats.rx_dropped++; 402 bp->stats.rx_dropped++;
403 for (frag = first_frag; ; frag = NEXT_RX(frag)) { 403 for (frag = first_frag; ; frag = NEXT_RX(frag)) {
@@ -1308,10 +1308,8 @@ static int __init macb_probe(struct platform_device *pdev)
1308 1308
1309 err = -ENOMEM; 1309 err = -ENOMEM;
1310 dev = alloc_etherdev(sizeof(*bp)); 1310 dev = alloc_etherdev(sizeof(*bp));
1311 if (!dev) { 1311 if (!dev)
1312 dev_err(&pdev->dev, "etherdev alloc failed, aborting.\n");
1313 goto err_out; 1312 goto err_out;
1314 }
1315 1313
1316 SET_NETDEV_DEV(dev, &pdev->dev); 1314 SET_NETDEV_DEV(dev, &pdev->dev);
1317 1315
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index e53365a71484..9045a451d4a9 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -2596,8 +2596,6 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev,
2596 netdev = alloc_etherdev_mq(sizeof(struct port_info), 2596 netdev = alloc_etherdev_mq(sizeof(struct port_info),
2597 MAX_PORT_QSETS); 2597 MAX_PORT_QSETS);
2598 if (netdev == NULL) { 2598 if (netdev == NULL) {
2599 dev_err(&pdev->dev, "cannot allocate netdev for"
2600 " port %d\n", port_id);
2601 t4vf_free_vi(adapter, viid); 2599 t4vf_free_vi(adapter, viid);
2602 err = -ENOMEM; 2600 err = -ENOMEM;
2603 goto err_free_dev; 2601 goto err_free_dev;
diff --git a/drivers/net/ethernet/cirrus/cs89x0.c b/drivers/net/ethernet/cirrus/cs89x0.c
index f328da24c8fa..d5ff93653e4c 100644
--- a/drivers/net/ethernet/cirrus/cs89x0.c
+++ b/drivers/net/ethernet/cirrus/cs89x0.c
@@ -911,7 +911,7 @@ dma_rx(struct net_device *dev)
911 } 911 }
912 912
913 /* Malloc up new buffer. */ 913 /* Malloc up new buffer. */
914 skb = dev_alloc_skb(length + 2); 914 skb = netdev_alloc_skb(dev, length + 2);
915 if (skb == NULL) { 915 if (skb == NULL) {
916 if (net_debug) /* I don't think we want to do this to a stressed system */ 916 if (net_debug) /* I don't think we want to do this to a stressed system */
917 printk("%s: Memory squeeze, dropping packet.\n", dev->name); 917 printk("%s: Memory squeeze, dropping packet.\n", dev->name);
@@ -1616,7 +1616,7 @@ net_rx(struct net_device *dev)
1616 } 1616 }
1617 1617
1618 /* Malloc up new buffer. */ 1618 /* Malloc up new buffer. */
1619 skb = dev_alloc_skb(length + 2); 1619 skb = netdev_alloc_skb(dev, length + 2);
1620 if (skb == NULL) { 1620 if (skb == NULL) {
1621#if 0 /* Again, this seems a cruel thing to do */ 1621#if 0 /* Again, this seems a cruel thing to do */
1622 printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name); 1622 printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name);
diff --git a/drivers/net/ethernet/cirrus/ep93xx_eth.c b/drivers/net/ethernet/cirrus/ep93xx_eth.c
index 4317af8d2f0a..c21e5ab8d1ef 100644
--- a/drivers/net/ethernet/cirrus/ep93xx_eth.c
+++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c
@@ -282,7 +282,7 @@ static int ep93xx_rx(struct net_device *dev, int processed, int budget)
282 if (rstat0 & RSTAT0_CRCI) 282 if (rstat0 & RSTAT0_CRCI)
283 length -= 4; 283 length -= 4;
284 284
285 skb = dev_alloc_skb(length + 2); 285 skb = netdev_alloc_skb(dev, length + 2);
286 if (likely(skb != NULL)) { 286 if (likely(skb != NULL)) {
287 struct ep93xx_rdesc *rxd = &ep->descs->rdesc[entry]; 287 struct ep93xx_rdesc *rxd = &ep->descs->rdesc[entry];
288 skb_reserve(skb, 2); 288 skb_reserve(skb, 2);
diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h
index ee93a2087fe6..54fd9c314b38 100644
--- a/drivers/net/ethernet/cisco/enic/enic.h
+++ b/drivers/net/ethernet/cisco/enic/enic.h
@@ -32,13 +32,13 @@
32 32
33#define DRV_NAME "enic" 33#define DRV_NAME "enic"
34#define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" 34#define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver"
35#define DRV_VERSION "2.1.1.31" 35#define DRV_VERSION "2.1.1.33"
36#define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc" 36#define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc"
37 37
38#define ENIC_BARS_MAX 6 38#define ENIC_BARS_MAX 6
39 39
40#define ENIC_WQ_MAX 1 40#define ENIC_WQ_MAX 1
41#define ENIC_RQ_MAX 1 41#define ENIC_RQ_MAX 8
42#define ENIC_CQ_MAX (ENIC_WQ_MAX + ENIC_RQ_MAX) 42#define ENIC_CQ_MAX (ENIC_WQ_MAX + ENIC_RQ_MAX)
43#define ENIC_INTR_MAX (ENIC_CQ_MAX + 2) 43#define ENIC_INTR_MAX (ENIC_CQ_MAX + 2)
44 44
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index ab3f67f980d8..2838891a94ee 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -2280,10 +2280,8 @@ static int __devinit enic_probe(struct pci_dev *pdev,
2280 */ 2280 */
2281 2281
2282 netdev = alloc_etherdev(sizeof(struct enic)); 2282 netdev = alloc_etherdev(sizeof(struct enic));
2283 if (!netdev) { 2283 if (!netdev)
2284 pr_err("Etherdev alloc failed, aborting\n");
2285 return -ENOMEM; 2284 return -ENOMEM;
2286 }
2287 2285
2288 pci_set_drvdata(pdev, netdev); 2286 pci_set_drvdata(pdev, netdev);
2289 2287
@@ -2388,7 +2386,6 @@ static int __devinit enic_probe(struct pci_dev *pdev,
2388 /* Allocate structure for port profiles */ 2386 /* Allocate structure for port profiles */
2389 enic->pp = kcalloc(num_pps, sizeof(*enic->pp), GFP_KERNEL); 2387 enic->pp = kcalloc(num_pps, sizeof(*enic->pp), GFP_KERNEL);
2390 if (!enic->pp) { 2388 if (!enic->pp) {
2391 pr_err("port profile alloc failed, aborting\n");
2392 err = -ENOMEM; 2389 err = -ENOMEM;
2393 goto err_out_disable_sriov_pp; 2390 goto err_out_disable_sriov_pp;
2394 } 2391 }
diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.c b/drivers/net/ethernet/cisco/enic/vnic_dev.c
index 31e7f9bc2067..298ad6f865be 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_dev.c
+++ b/drivers/net/ethernet/cisco/enic/vnic_dev.c
@@ -439,11 +439,12 @@ int vnic_dev_fw_info(struct vnic_dev *vdev,
439 a1 = sizeof(struct vnic_devcmd_fw_info); 439 a1 = sizeof(struct vnic_devcmd_fw_info);
440 440
441 /* only get fw_info once and cache it */ 441 /* only get fw_info once and cache it */
442 err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO, &a0, &a1, wait); 442 if (vnic_dev_capable(vdev, CMD_MCPU_FW_INFO))
443 if (err == ERR_ECMDUNKNOWN) { 443 err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO,
444 &a0, &a1, wait);
445 else
444 err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO_OLD, 446 err = vnic_dev_cmd(vdev, CMD_MCPU_FW_INFO_OLD,
445 &a0, &a1, wait); 447 &a0, &a1, wait);
446 }
447 } 448 }
448 449
449 *fw_info = vdev->fw_info; 450 *fw_info = vdev->fw_info;
@@ -504,13 +505,11 @@ int vnic_dev_enable_wait(struct vnic_dev *vdev)
504{ 505{
505 u64 a0 = 0, a1 = 0; 506 u64 a0 = 0, a1 = 0;
506 int wait = 1000; 507 int wait = 1000;
507 int err;
508 508
509 err = vnic_dev_cmd(vdev, CMD_ENABLE_WAIT, &a0, &a1, wait); 509 if (vnic_dev_capable(vdev, CMD_ENABLE_WAIT))
510 if (err == ERR_ECMDUNKNOWN) 510 return vnic_dev_cmd(vdev, CMD_ENABLE_WAIT, &a0, &a1, wait);
511 else
511 return vnic_dev_cmd(vdev, CMD_ENABLE, &a0, &a1, wait); 512 return vnic_dev_cmd(vdev, CMD_ENABLE, &a0, &a1, wait);
512
513 return err;
514} 513}
515 514
516int vnic_dev_disable(struct vnic_dev *vdev) 515int vnic_dev_disable(struct vnic_dev *vdev)
@@ -574,16 +573,15 @@ int vnic_dev_hang_reset(struct vnic_dev *vdev, int arg)
574 int wait = 1000; 573 int wait = 1000;
575 int err; 574 int err;
576 575
577 err = vnic_dev_cmd(vdev, CMD_HANG_RESET, &a0, &a1, wait); 576 if (vnic_dev_capable(vdev, CMD_HANG_RESET)) {
578 if (err == ERR_ECMDUNKNOWN) { 577 return vnic_dev_cmd(vdev, CMD_HANG_RESET,
578 &a0, &a1, wait);
579 } else {
579 err = vnic_dev_soft_reset(vdev, arg); 580 err = vnic_dev_soft_reset(vdev, arg);
580 if (err) 581 if (err)
581 return err; 582 return err;
582
583 return vnic_dev_init(vdev, 0); 583 return vnic_dev_init(vdev, 0);
584 } 584 }
585
586 return err;
587} 585}
588 586
589int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done) 587int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done)
@@ -594,11 +592,13 @@ int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done)
594 592
595 *done = 0; 593 *done = 0;
596 594
597 err = vnic_dev_cmd(vdev, CMD_HANG_RESET_STATUS, &a0, &a1, wait); 595 if (vnic_dev_capable(vdev, CMD_HANG_RESET_STATUS)) {
598 if (err) { 596 err = vnic_dev_cmd(vdev, CMD_HANG_RESET_STATUS,
599 if (err == ERR_ECMDUNKNOWN) 597 &a0, &a1, wait);
600 return vnic_dev_soft_reset_done(vdev, done); 598 if (err)
601 return err; 599 return err;
600 } else {
601 return vnic_dev_soft_reset_done(vdev, done);
602 } 602 }
603 603
604 *done = (a0 == 0); 604 *done = (a0 == 0);
@@ -691,13 +691,12 @@ int vnic_dev_set_ig_vlan_rewrite_mode(struct vnic_dev *vdev,
691{ 691{
692 u64 a0 = ig_vlan_rewrite_mode, a1 = 0; 692 u64 a0 = ig_vlan_rewrite_mode, a1 = 0;
693 int wait = 1000; 693 int wait = 1000;
694 int err;
695 694
696 err = vnic_dev_cmd(vdev, CMD_IG_VLAN_REWRITE_MODE, &a0, &a1, wait); 695 if (vnic_dev_capable(vdev, CMD_IG_VLAN_REWRITE_MODE))
697 if (err == ERR_ECMDUNKNOWN) 696 return vnic_dev_cmd(vdev, CMD_IG_VLAN_REWRITE_MODE,
697 &a0, &a1, wait);
698 else
698 return 0; 699 return 0;
699
700 return err;
701} 700}
702 701
703static int vnic_dev_notify_setcmd(struct vnic_dev *vdev, 702static int vnic_dev_notify_setcmd(struct vnic_dev *vdev,
@@ -835,7 +834,10 @@ int vnic_dev_intr_coal_timer_info(struct vnic_dev *vdev)
835 834
836 memset(vdev->args, 0, sizeof(vdev->args)); 835 memset(vdev->args, 0, sizeof(vdev->args));
837 836
838 err = _vnic_dev_cmd(vdev, CMD_INTR_COAL_CONVERT, wait); 837 if (vnic_dev_capable(vdev, CMD_INTR_COAL_CONVERT))
838 err = _vnic_dev_cmd(vdev, CMD_INTR_COAL_CONVERT, wait);
839 else
840 err = ERR_ECMDUNKNOWN;
839 841
840 /* Use defaults when firmware doesn't support the devcmd at all or 842 /* Use defaults when firmware doesn't support the devcmd at all or
841 * supports it for only specific hardware 843 * supports it for only specific hardware
@@ -848,9 +850,11 @@ int vnic_dev_intr_coal_timer_info(struct vnic_dev *vdev)
848 return 0; 850 return 0;
849 } 851 }
850 852
851 vdev->intr_coal_timer_info.mul = (u32) vdev->args[0]; 853 if (!err) {
852 vdev->intr_coal_timer_info.div = (u32) vdev->args[1]; 854 vdev->intr_coal_timer_info.mul = (u32) vdev->args[0];
853 vdev->intr_coal_timer_info.max_usec = (u32) vdev->args[2]; 855 vdev->intr_coal_timer_info.div = (u32) vdev->args[1];
856 vdev->intr_coal_timer_info.max_usec = (u32) vdev->args[2];
857 }
854 858
855 return err; 859 return err;
856} 860}
diff --git a/drivers/net/ethernet/cisco/enic/vnic_rq.c b/drivers/net/ethernet/cisco/enic/vnic_rq.c
index 34105e0951a5..7e1488fc8ab2 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_rq.c
+++ b/drivers/net/ethernet/cisco/enic/vnic_rq.c
@@ -38,10 +38,8 @@ static int vnic_rq_alloc_bufs(struct vnic_rq *rq)
38 38
39 for (i = 0; i < blks; i++) { 39 for (i = 0; i < blks; i++) {
40 rq->bufs[i] = kzalloc(VNIC_RQ_BUF_BLK_SZ(count), GFP_ATOMIC); 40 rq->bufs[i] = kzalloc(VNIC_RQ_BUF_BLK_SZ(count), GFP_ATOMIC);
41 if (!rq->bufs[i]) { 41 if (!rq->bufs[i])
42 pr_err("Failed to alloc rq_bufs\n");
43 return -ENOMEM; 42 return -ENOMEM;
44 }
45 } 43 }
46 44
47 for (i = 0; i < blks; i++) { 45 for (i = 0; i < blks; i++) {
diff --git a/drivers/net/ethernet/cisco/enic/vnic_wq.c b/drivers/net/ethernet/cisco/enic/vnic_wq.c
index df61bd932ea6..5e0d7a2be9bc 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_wq.c
+++ b/drivers/net/ethernet/cisco/enic/vnic_wq.c
@@ -38,10 +38,8 @@ static int vnic_wq_alloc_bufs(struct vnic_wq *wq)
38 38
39 for (i = 0; i < blks; i++) { 39 for (i = 0; i < blks; i++) {
40 wq->bufs[i] = kzalloc(VNIC_WQ_BUF_BLK_SZ(count), GFP_ATOMIC); 40 wq->bufs[i] = kzalloc(VNIC_WQ_BUF_BLK_SZ(count), GFP_ATOMIC);
41 if (!wq->bufs[i]) { 41 if (!wq->bufs[i])
42 pr_err("Failed to alloc wq_bufs\n");
43 return -ENOMEM; 42 return -ENOMEM;
44 }
45 } 43 }
46 44
47 for (i = 0; i < blks; i++) { 45 for (i = 0; i < blks; i++) {
diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index f801754c71a7..42383ab5227e 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -1028,7 +1028,7 @@ dm9000_rx(struct net_device *dev)
1028 1028
1029 /* Move data from DM9000 */ 1029 /* Move data from DM9000 */
1030 if (GoodPacket && 1030 if (GoodPacket &&
1031 ((skb = dev_alloc_skb(RxLen + 4)) != NULL)) { 1031 ((skb = netdev_alloc_skb(dev, RxLen + 4)) != NULL)) {
1032 skb_reserve(skb, 2); 1032 skb_reserve(skb, 2);
1033 rdptr = (u8 *) skb_put(skb, RxLen - 4); 1033 rdptr = (u8 *) skb_put(skb, RxLen - 4);
1034 1034
@@ -1373,10 +1373,8 @@ dm9000_probe(struct platform_device *pdev)
1373 1373
1374 /* Init network device */ 1374 /* Init network device */
1375 ndev = alloc_etherdev(sizeof(struct board_info)); 1375 ndev = alloc_etherdev(sizeof(struct board_info));
1376 if (!ndev) { 1376 if (!ndev)
1377 dev_err(&pdev->dev, "could not allocate device.\n");
1378 return -ENOMEM; 1377 return -ENOMEM;
1379 }
1380 1378
1381 SET_NETDEV_DEV(ndev, &pdev->dev); 1379 SET_NETDEV_DEV(ndev, &pdev->dev);
1382 1380
diff --git a/drivers/net/ethernet/dec/ewrk3.c b/drivers/net/ethernet/dec/ewrk3.c
index f9df5e4d0341..1879f84a25a3 100644
--- a/drivers/net/ethernet/dec/ewrk3.c
+++ b/drivers/net/ethernet/dec/ewrk3.c
@@ -986,8 +986,10 @@ static int ewrk3_rx(struct net_device *dev)
986 dev->stats.rx_fifo_errors++; 986 dev->stats.rx_fifo_errors++;
987 } else { 987 } else {
988 struct sk_buff *skb; 988 struct sk_buff *skb;
989 skb = netdev_alloc_skb(dev,
990 pkt_len + 2);
989 991
990 if ((skb = dev_alloc_skb(pkt_len + 2)) != NULL) { 992 if (skb != NULL) {
991 unsigned char *p; 993 unsigned char *p;
992 skb_reserve(skb, 2); /* Align to 16 bytes */ 994 skb_reserve(skb, 2); /* Align to 16 bytes */
993 p = skb_put(skb, pkt_len); 995 p = skb_put(skb, pkt_len);
diff --git a/drivers/net/ethernet/dec/tulip/21142.c b/drivers/net/ethernet/dec/tulip/21142.c
index 25b8deedbef8..369858272650 100644
--- a/drivers/net/ethernet/dec/tulip/21142.c
+++ b/drivers/net/ethernet/dec/tulip/21142.c
@@ -1,5 +1,5 @@
1/* 1/*
2 drivers/net/tulip/21142.c 2 drivers/net/ethernet/dec/tulip/21142.c
3 3
4 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
5 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c
index 1eb46a0bb488..68f1c39184df 100644
--- a/drivers/net/ethernet/dec/tulip/de2104x.c
+++ b/drivers/net/ethernet/dec/tulip/de2104x.c
@@ -439,7 +439,7 @@ static void de_rx (struct de_private *de)
439 rx_tail, status, len, copying_skb); 439 rx_tail, status, len, copying_skb);
440 440
441 buflen = copying_skb ? (len + RX_OFFSET) : de->rx_buf_sz; 441 buflen = copying_skb ? (len + RX_OFFSET) : de->rx_buf_sz;
442 copy_skb = dev_alloc_skb (buflen); 442 copy_skb = netdev_alloc_skb(de->dev, buflen);
443 if (unlikely(!copy_skb)) { 443 if (unlikely(!copy_skb)) {
444 de->net_stats.rx_dropped++; 444 de->net_stats.rx_dropped++;
445 drop = 1; 445 drop = 1;
@@ -1283,12 +1283,10 @@ static int de_refill_rx (struct de_private *de)
1283 for (i = 0; i < DE_RX_RING_SIZE; i++) { 1283 for (i = 0; i < DE_RX_RING_SIZE; i++) {
1284 struct sk_buff *skb; 1284 struct sk_buff *skb;
1285 1285
1286 skb = dev_alloc_skb(de->rx_buf_sz); 1286 skb = netdev_alloc_skb(de->dev, de->rx_buf_sz);
1287 if (!skb) 1287 if (!skb)
1288 goto err_out; 1288 goto err_out;
1289 1289
1290 skb->dev = de->dev;
1291
1292 de->rx_skb[i].mapping = pci_map_single(de->pdev, 1290 de->rx_skb[i].mapping = pci_map_single(de->pdev,
1293 skb->data, de->rx_buf_sz, PCI_DMA_FROMDEVICE); 1291 skb->data, de->rx_buf_sz, PCI_DMA_FROMDEVICE);
1294 de->rx_skb[i].skb = skb; 1292 de->rx_skb[i].skb = skb;
diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
index 4d71f5ae20c8..93583408a325 100644
--- a/drivers/net/ethernet/dec/tulip/de4x5.c
+++ b/drivers/net/ethernet/dec/tulip/de4x5.c
@@ -3598,7 +3598,7 @@ de4x5_alloc_rx_buff(struct net_device *dev, int index, int len)
3598 struct sk_buff *ret; 3598 struct sk_buff *ret;
3599 u_long i=0, tmp; 3599 u_long i=0, tmp;
3600 3600
3601 p = dev_alloc_skb(IEEE802_3_SZ + DE4X5_ALIGN + 2); 3601 p = netdev_alloc_skb(dev, IEEE802_3_SZ + DE4X5_ALIGN + 2);
3602 if (!p) return NULL; 3602 if (!p) return NULL;
3603 3603
3604 tmp = virt_to_bus(p->data); 3604 tmp = virt_to_bus(p->data);
@@ -3618,7 +3618,7 @@ de4x5_alloc_rx_buff(struct net_device *dev, int index, int len)
3618#else 3618#else
3619 if (lp->state != OPEN) return (struct sk_buff *)1; /* Fake out the open */ 3619 if (lp->state != OPEN) return (struct sk_buff *)1; /* Fake out the open */
3620 3620
3621 p = dev_alloc_skb(len + 2); 3621 p = netdev_alloc_skb(dev, len + 2);
3622 if (!p) return NULL; 3622 if (!p) return NULL;
3623 3623
3624 skb_reserve(p, 2); /* Align */ 3624 skb_reserve(p, 2); /* Align */
diff --git a/drivers/net/ethernet/dec/tulip/dmfe.c b/drivers/net/ethernet/dec/tulip/dmfe.c
index 51f7542eb451..1eccf4945485 100644
--- a/drivers/net/ethernet/dec/tulip/dmfe.c
+++ b/drivers/net/ethernet/dec/tulip/dmfe.c
@@ -325,8 +325,8 @@ static irqreturn_t dmfe_interrupt(int , void *);
325#ifdef CONFIG_NET_POLL_CONTROLLER 325#ifdef CONFIG_NET_POLL_CONTROLLER
326static void poll_dmfe (struct net_device *dev); 326static void poll_dmfe (struct net_device *dev);
327#endif 327#endif
328static void dmfe_descriptor_init(struct dmfe_board_info *, unsigned long); 328static void dmfe_descriptor_init(struct net_device *, unsigned long);
329static void allocate_rx_buffer(struct dmfe_board_info *); 329static void allocate_rx_buffer(struct net_device *);
330static void update_cr6(u32, unsigned long); 330static void update_cr6(u32, unsigned long);
331static void send_filter_frame(struct DEVICE *); 331static void send_filter_frame(struct DEVICE *);
332static void dm9132_id_table(struct DEVICE *); 332static void dm9132_id_table(struct DEVICE *);
@@ -649,7 +649,7 @@ static void dmfe_init_dm910x(struct DEVICE *dev)
649 db->op_mode = db->media_mode; /* Force Mode */ 649 db->op_mode = db->media_mode; /* Force Mode */
650 650
651 /* Initialize Transmit/Receive decriptor and CR3/4 */ 651 /* Initialize Transmit/Receive decriptor and CR3/4 */
652 dmfe_descriptor_init(db, ioaddr); 652 dmfe_descriptor_init(dev, ioaddr);
653 653
654 /* Init CR6 to program DM910x operation */ 654 /* Init CR6 to program DM910x operation */
655 update_cr6(db->cr6_data, ioaddr); 655 update_cr6(db->cr6_data, ioaddr);
@@ -828,7 +828,7 @@ static irqreturn_t dmfe_interrupt(int irq, void *dev_id)
828 828
829 /* reallocate rx descriptor buffer */ 829 /* reallocate rx descriptor buffer */
830 if (db->rx_avail_cnt<RX_DESC_CNT) 830 if (db->rx_avail_cnt<RX_DESC_CNT)
831 allocate_rx_buffer(db); 831 allocate_rx_buffer(dev);
832 832
833 /* Free the transmitted descriptor */ 833 /* Free the transmitted descriptor */
834 if ( db->cr5_data & 0x01) 834 if ( db->cr5_data & 0x01)
@@ -1008,7 +1008,7 @@ static void dmfe_rx_packet(struct DEVICE *dev, struct dmfe_board_info * db)
1008 /* Good packet, send to upper layer */ 1008 /* Good packet, send to upper layer */
1009 /* Shorst packet used new SKB */ 1009 /* Shorst packet used new SKB */
1010 if ((rxlen < RX_COPY_SIZE) && 1010 if ((rxlen < RX_COPY_SIZE) &&
1011 ((newskb = dev_alloc_skb(rxlen + 2)) 1011 ((newskb = netdev_alloc_skb(dev, rxlen + 2))
1012 != NULL)) { 1012 != NULL)) {
1013 1013
1014 skb = newskb; 1014 skb = newskb;
@@ -1364,8 +1364,9 @@ static void dmfe_reuse_skb(struct dmfe_board_info *db, struct sk_buff * skb)
1364 * Using Chain structure, and allocate Tx/Rx buffer 1364 * Using Chain structure, and allocate Tx/Rx buffer
1365 */ 1365 */
1366 1366
1367static void dmfe_descriptor_init(struct dmfe_board_info *db, unsigned long ioaddr) 1367static void dmfe_descriptor_init(struct net_device *dev, unsigned long ioaddr)
1368{ 1368{
1369 struct dmfe_board_info *db = netdev_priv(dev);
1369 struct tx_desc *tmp_tx; 1370 struct tx_desc *tmp_tx;
1370 struct rx_desc *tmp_rx; 1371 struct rx_desc *tmp_rx;
1371 unsigned char *tmp_buf; 1372 unsigned char *tmp_buf;
@@ -1421,7 +1422,7 @@ static void dmfe_descriptor_init(struct dmfe_board_info *db, unsigned long ioadd
1421 tmp_rx->next_rx_desc = db->first_rx_desc; 1422 tmp_rx->next_rx_desc = db->first_rx_desc;
1422 1423
1423 /* pre-allocate Rx buffer */ 1424 /* pre-allocate Rx buffer */
1424 allocate_rx_buffer(db); 1425 allocate_rx_buffer(dev);
1425} 1426}
1426 1427
1427 1428
@@ -1551,15 +1552,16 @@ static void send_filter_frame(struct DEVICE *dev)
1551 * As possible as allocate maxiumn Rx buffer 1552 * As possible as allocate maxiumn Rx buffer
1552 */ 1553 */
1553 1554
1554static void allocate_rx_buffer(struct dmfe_board_info *db) 1555static void allocate_rx_buffer(struct net_device *dev)
1555{ 1556{
1557 struct dmfe_board_info *db = netdev_priv(dev);
1556 struct rx_desc *rxptr; 1558 struct rx_desc *rxptr;
1557 struct sk_buff *skb; 1559 struct sk_buff *skb;
1558 1560
1559 rxptr = db->rx_insert_ptr; 1561 rxptr = db->rx_insert_ptr;
1560 1562
1561 while(db->rx_avail_cnt < RX_DESC_CNT) { 1563 while(db->rx_avail_cnt < RX_DESC_CNT) {
1562 if ( ( skb = dev_alloc_skb(RX_ALLOC_SIZE) ) == NULL ) 1564 if ( ( skb = netdev_alloc_skb(dev, RX_ALLOC_SIZE) ) == NULL )
1563 break; 1565 break;
1564 rxptr->rx_skb_ptr = skb; /* FIXME (?) */ 1566 rxptr->rx_skb_ptr = skb; /* FIXME (?) */
1565 rxptr->rdes2 = cpu_to_le32( pci_map_single(db->pdev, skb->data, 1567 rxptr->rdes2 = cpu_to_le32( pci_map_single(db->pdev, skb->data,
diff --git a/drivers/net/ethernet/dec/tulip/eeprom.c b/drivers/net/ethernet/dec/tulip/eeprom.c
index 14d5b611783d..ed7d1dcd9566 100644
--- a/drivers/net/ethernet/dec/tulip/eeprom.c
+++ b/drivers/net/ethernet/dec/tulip/eeprom.c
@@ -1,5 +1,5 @@
1/* 1/*
2 drivers/net/tulip/eeprom.c 2 drivers/net/ethernet/dec/tulip/eeprom.c
3 3
4 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
5 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
diff --git a/drivers/net/ethernet/dec/tulip/interrupt.c b/drivers/net/ethernet/dec/tulip/interrupt.c
index 4fb8c8c0a420..28a5e425fecf 100644
--- a/drivers/net/ethernet/dec/tulip/interrupt.c
+++ b/drivers/net/ethernet/dec/tulip/interrupt.c
@@ -1,5 +1,5 @@
1/* 1/*
2 drivers/net/tulip/interrupt.c 2 drivers/net/ethernet/dec/tulip/interrupt.c
3 3
4 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
5 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
@@ -69,7 +69,8 @@ int tulip_refill_rx(struct net_device *dev)
69 struct sk_buff *skb; 69 struct sk_buff *skb;
70 dma_addr_t mapping; 70 dma_addr_t mapping;
71 71
72 skb = tp->rx_buffers[entry].skb = dev_alloc_skb(PKT_BUF_SZ); 72 skb = tp->rx_buffers[entry].skb =
73 netdev_alloc_skb(dev, PKT_BUF_SZ);
73 if (skb == NULL) 74 if (skb == NULL)
74 break; 75 break;
75 76
@@ -77,7 +78,6 @@ int tulip_refill_rx(struct net_device *dev)
77 PCI_DMA_FROMDEVICE); 78 PCI_DMA_FROMDEVICE);
78 tp->rx_buffers[entry].mapping = mapping; 79 tp->rx_buffers[entry].mapping = mapping;
79 80
80 skb->dev = dev; /* Mark as being used by this device. */
81 tp->rx_ring[entry].buffer1 = cpu_to_le32(mapping); 81 tp->rx_ring[entry].buffer1 = cpu_to_le32(mapping);
82 refilled++; 82 refilled++;
83 } 83 }
@@ -202,7 +202,7 @@ int tulip_poll(struct napi_struct *napi, int budget)
202 /* Check if the packet is long enough to accept without copying 202 /* Check if the packet is long enough to accept without copying
203 to a minimally-sized skbuff. */ 203 to a minimally-sized skbuff. */
204 if (pkt_len < tulip_rx_copybreak && 204 if (pkt_len < tulip_rx_copybreak &&
205 (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { 205 (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) {
206 skb_reserve(skb, 2); /* 16 byte align the IP header */ 206 skb_reserve(skb, 2); /* 16 byte align the IP header */
207 pci_dma_sync_single_for_cpu(tp->pdev, 207 pci_dma_sync_single_for_cpu(tp->pdev,
208 tp->rx_buffers[entry].mapping, 208 tp->rx_buffers[entry].mapping,
@@ -428,7 +428,7 @@ static int tulip_rx(struct net_device *dev)
428 /* Check if the packet is long enough to accept without copying 428 /* Check if the packet is long enough to accept without copying
429 to a minimally-sized skbuff. */ 429 to a minimally-sized skbuff. */
430 if (pkt_len < tulip_rx_copybreak && 430 if (pkt_len < tulip_rx_copybreak &&
431 (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { 431 (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) {
432 skb_reserve(skb, 2); /* 16 byte align the IP header */ 432 skb_reserve(skb, 2); /* 16 byte align the IP header */
433 pci_dma_sync_single_for_cpu(tp->pdev, 433 pci_dma_sync_single_for_cpu(tp->pdev,
434 tp->rx_buffers[entry].mapping, 434 tp->rx_buffers[entry].mapping,
diff --git a/drivers/net/ethernet/dec/tulip/media.c b/drivers/net/ethernet/dec/tulip/media.c
index beeb17b52ad4..ae937c6749e7 100644
--- a/drivers/net/ethernet/dec/tulip/media.c
+++ b/drivers/net/ethernet/dec/tulip/media.c
@@ -1,5 +1,5 @@
1/* 1/*
2 drivers/net/tulip/media.c 2 drivers/net/ethernet/dec/tulip/media.c
3 3
4 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
5 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
diff --git a/drivers/net/ethernet/dec/tulip/pnic.c b/drivers/net/ethernet/dec/tulip/pnic.c
index 9c16e4ad02a6..5364563c4378 100644
--- a/drivers/net/ethernet/dec/tulip/pnic.c
+++ b/drivers/net/ethernet/dec/tulip/pnic.c
@@ -1,5 +1,5 @@
1/* 1/*
2 drivers/net/tulip/pnic.c 2 drivers/net/ethernet/dec/tulip/pnic.c
3 3
4 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
5 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
diff --git a/drivers/net/ethernet/dec/tulip/pnic2.c b/drivers/net/ethernet/dec/tulip/pnic2.c
index 04a7e477eaff..5895fc43f6e0 100644
--- a/drivers/net/ethernet/dec/tulip/pnic2.c
+++ b/drivers/net/ethernet/dec/tulip/pnic2.c
@@ -1,5 +1,5 @@
1/* 1/*
2 drivers/net/tulip/pnic2.c 2 drivers/net/ethernet/dec/tulip/pnic2.c
3 3
4 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
5 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
diff --git a/drivers/net/ethernet/dec/tulip/timer.c b/drivers/net/ethernet/dec/tulip/timer.c
index 19078d28ffb9..768379b8aee9 100644
--- a/drivers/net/ethernet/dec/tulip/timer.c
+++ b/drivers/net/ethernet/dec/tulip/timer.c
@@ -1,5 +1,5 @@
1/* 1/*
2 drivers/net/tulip/timer.c 2 drivers/net/ethernet/dec/tulip/timer.c
3 3
4 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
5 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
diff --git a/drivers/net/ethernet/dec/tulip/tulip.h b/drivers/net/ethernet/dec/tulip/tulip.h
index fb3887c18dc6..38431a155f09 100644
--- a/drivers/net/ethernet/dec/tulip/tulip.h
+++ b/drivers/net/ethernet/dec/tulip/tulip.h
@@ -1,5 +1,5 @@
1/* 1/*
2 drivers/net/tulip/tulip.h 2 drivers/net/ethernet/dec/tulip/tulip.h
3 3
4 Copyright 2000,2001 The Linux Kernel Team 4 Copyright 2000,2001 The Linux Kernel Team
5 Written/copyright 1994-2001 by Donald Becker. 5 Written/copyright 1994-2001 by Donald Becker.
diff --git a/drivers/net/ethernet/dec/tulip/tulip_core.c b/drivers/net/ethernet/dec/tulip/tulip_core.c
index 4eb0d76145c2..fea3641d9398 100644
--- a/drivers/net/ethernet/dec/tulip/tulip_core.c
+++ b/drivers/net/ethernet/dec/tulip/tulip_core.c
@@ -636,16 +636,15 @@ static void tulip_init_ring(struct net_device *dev)
636 dma_addr_t mapping; 636 dma_addr_t mapping;
637 637
638 /* Note the receive buffer must be longword aligned. 638 /* Note the receive buffer must be longword aligned.
639 dev_alloc_skb() provides 16 byte alignment. But do *not* 639 netdev_alloc_skb() provides 16 byte alignment. But do *not*
640 use skb_reserve() to align the IP header! */ 640 use skb_reserve() to align the IP header! */
641 struct sk_buff *skb = dev_alloc_skb(PKT_BUF_SZ); 641 struct sk_buff *skb = netdev_alloc_skb(dev, PKT_BUF_SZ);
642 tp->rx_buffers[i].skb = skb; 642 tp->rx_buffers[i].skb = skb;
643 if (skb == NULL) 643 if (skb == NULL)
644 break; 644 break;
645 mapping = pci_map_single(tp->pdev, skb->data, 645 mapping = pci_map_single(tp->pdev, skb->data,
646 PKT_BUF_SZ, PCI_DMA_FROMDEVICE); 646 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
647 tp->rx_buffers[i].mapping = mapping; 647 tp->rx_buffers[i].mapping = mapping;
648 skb->dev = dev; /* Mark as being used by this device. */
649 tp->rx_ring[i].status = cpu_to_le32(DescOwned); /* Owned by Tulip chip */ 648 tp->rx_ring[i].status = cpu_to_le32(DescOwned); /* Owned by Tulip chip */
650 tp->rx_ring[i].buffer1 = cpu_to_le32(mapping); 649 tp->rx_ring[i].buffer1 = cpu_to_le32(mapping);
651 } 650 }
@@ -1424,10 +1423,8 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1424 1423
1425 /* alloc_etherdev ensures aligned and zeroed private structures */ 1424 /* alloc_etherdev ensures aligned and zeroed private structures */
1426 dev = alloc_etherdev (sizeof (*tp)); 1425 dev = alloc_etherdev (sizeof (*tp));
1427 if (!dev) { 1426 if (!dev)
1428 pr_err("ether device alloc failed, aborting\n");
1429 return -ENOMEM; 1427 return -ENOMEM;
1430 }
1431 1428
1432 SET_NETDEV_DEV(dev, &pdev->dev); 1429 SET_NETDEV_DEV(dev, &pdev->dev);
1433 if (pci_resource_len (pdev, 0) < tulip_tbl[chip_idx].io_size) { 1430 if (pci_resource_len (pdev, 0) < tulip_tbl[chip_idx].io_size) {
diff --git a/drivers/net/ethernet/dec/tulip/uli526x.c b/drivers/net/ethernet/dec/tulip/uli526x.c
index 48b0b6566eef..fc4001f6a5e4 100644
--- a/drivers/net/ethernet/dec/tulip/uli526x.c
+++ b/drivers/net/ethernet/dec/tulip/uli526x.c
@@ -232,8 +232,8 @@ static irqreturn_t uli526x_interrupt(int, void *);
232#ifdef CONFIG_NET_POLL_CONTROLLER 232#ifdef CONFIG_NET_POLL_CONTROLLER
233static void uli526x_poll(struct net_device *dev); 233static void uli526x_poll(struct net_device *dev);
234#endif 234#endif
235static void uli526x_descriptor_init(struct uli526x_board_info *, unsigned long); 235static void uli526x_descriptor_init(struct net_device *, unsigned long);
236static void allocate_rx_buffer(struct uli526x_board_info *); 236static void allocate_rx_buffer(struct net_device *);
237static void update_cr6(u32, unsigned long); 237static void update_cr6(u32, unsigned long);
238static void send_filter_frame(struct net_device *, int); 238static void send_filter_frame(struct net_device *, int);
239static u16 phy_read(unsigned long, u8, u8, u32); 239static u16 phy_read(unsigned long, u8, u8, u32);
@@ -549,7 +549,7 @@ static void uli526x_init(struct net_device *dev)
549 db->op_mode = db->media_mode; /* Force Mode */ 549 db->op_mode = db->media_mode; /* Force Mode */
550 550
551 /* Initialize Transmit/Receive decriptor and CR3/4 */ 551 /* Initialize Transmit/Receive decriptor and CR3/4 */
552 uli526x_descriptor_init(db, ioaddr); 552 uli526x_descriptor_init(dev, ioaddr);
553 553
554 /* Init CR6 to program M526X operation */ 554 /* Init CR6 to program M526X operation */
555 update_cr6(db->cr6_data, ioaddr); 555 update_cr6(db->cr6_data, ioaddr);
@@ -711,7 +711,7 @@ static irqreturn_t uli526x_interrupt(int irq, void *dev_id)
711 711
712 /* reallocate rx descriptor buffer */ 712 /* reallocate rx descriptor buffer */
713 if (db->rx_avail_cnt<RX_DESC_CNT) 713 if (db->rx_avail_cnt<RX_DESC_CNT)
714 allocate_rx_buffer(db); 714 allocate_rx_buffer(dev);
715 715
716 /* Free the transmitted descriptor */ 716 /* Free the transmitted descriptor */
717 if ( db->cr5_data & 0x01) 717 if ( db->cr5_data & 0x01)
@@ -844,7 +844,7 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
844 /* Good packet, send to upper layer */ 844 /* Good packet, send to upper layer */
845 /* Shorst packet used new SKB */ 845 /* Shorst packet used new SKB */
846 if ((rxlen < RX_COPY_SIZE) && 846 if ((rxlen < RX_COPY_SIZE) &&
847 (((new_skb = dev_alloc_skb(rxlen + 2)) != NULL))) { 847 (((new_skb = netdev_alloc_skb(dev, rxlen + 2)) != NULL))) {
848 skb = new_skb; 848 skb = new_skb;
849 /* size less than COPY_SIZE, allocate a rxlen SKB */ 849 /* size less than COPY_SIZE, allocate a rxlen SKB */
850 skb_reserve(skb, 2); /* 16byte align */ 850 skb_reserve(skb, 2); /* 16byte align */
@@ -1289,8 +1289,9 @@ static void uli526x_reuse_skb(struct uli526x_board_info *db, struct sk_buff * sk
1289 * Using Chain structure, and allocate Tx/Rx buffer 1289 * Using Chain structure, and allocate Tx/Rx buffer
1290 */ 1290 */
1291 1291
1292static void uli526x_descriptor_init(struct uli526x_board_info *db, unsigned long ioaddr) 1292static void uli526x_descriptor_init(struct net_device *dev, unsigned long ioaddr)
1293{ 1293{
1294 struct uli526x_board_info *db = netdev_priv(dev);
1294 struct tx_desc *tmp_tx; 1295 struct tx_desc *tmp_tx;
1295 struct rx_desc *tmp_rx; 1296 struct rx_desc *tmp_rx;
1296 unsigned char *tmp_buf; 1297 unsigned char *tmp_buf;
@@ -1343,7 +1344,7 @@ static void uli526x_descriptor_init(struct uli526x_board_info *db, unsigned long
1343 tmp_rx->next_rx_desc = db->first_rx_desc; 1344 tmp_rx->next_rx_desc = db->first_rx_desc;
1344 1345
1345 /* pre-allocate Rx buffer */ 1346 /* pre-allocate Rx buffer */
1346 allocate_rx_buffer(db); 1347 allocate_rx_buffer(dev);
1347} 1348}
1348 1349
1349 1350
@@ -1433,15 +1434,17 @@ static void send_filter_frame(struct net_device *dev, int mc_cnt)
1433 * As possible as allocate maxiumn Rx buffer 1434 * As possible as allocate maxiumn Rx buffer
1434 */ 1435 */
1435 1436
1436static void allocate_rx_buffer(struct uli526x_board_info *db) 1437static void allocate_rx_buffer(struct net_device *dev)
1437{ 1438{
1439 struct uli526x_board_info *db = netdev_priv(dev);
1438 struct rx_desc *rxptr; 1440 struct rx_desc *rxptr;
1439 struct sk_buff *skb; 1441 struct sk_buff *skb;
1440 1442
1441 rxptr = db->rx_insert_ptr; 1443 rxptr = db->rx_insert_ptr;
1442 1444
1443 while(db->rx_avail_cnt < RX_DESC_CNT) { 1445 while(db->rx_avail_cnt < RX_DESC_CNT) {
1444 if ( ( skb = dev_alloc_skb(RX_ALLOC_SIZE) ) == NULL ) 1446 skb = netdev_alloc_skb(dev, RX_ALLOC_SIZE);
1447 if (skb == NULL)
1445 break; 1448 break;
1446 rxptr->rx_skb_ptr = skb; /* FIXME (?) */ 1449 rxptr->rx_skb_ptr = skb; /* FIXME (?) */
1447 rxptr->rdes2 = cpu_to_le32(pci_map_single(db->pdev, 1450 rxptr->rdes2 = cpu_to_le32(pci_map_single(db->pdev,
diff --git a/drivers/net/ethernet/dec/tulip/winbond-840.c b/drivers/net/ethernet/dec/tulip/winbond-840.c
index 52da7b2fe3b6..2ac6fff0363a 100644
--- a/drivers/net/ethernet/dec/tulip/winbond-840.c
+++ b/drivers/net/ethernet/dec/tulip/winbond-840.c
@@ -815,7 +815,7 @@ static void init_rxtx_rings(struct net_device *dev)
815 815
816 /* Fill in the Rx buffers. Handle allocation failure gracefully. */ 816 /* Fill in the Rx buffers. Handle allocation failure gracefully. */
817 for (i = 0; i < RX_RING_SIZE; i++) { 817 for (i = 0; i < RX_RING_SIZE; i++) {
818 struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz); 818 struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz);
819 np->rx_skbuff[i] = skb; 819 np->rx_skbuff[i] = skb;
820 if (skb == NULL) 820 if (skb == NULL)
821 break; 821 break;
@@ -1231,7 +1231,7 @@ static int netdev_rx(struct net_device *dev)
1231 /* Check if the packet is long enough to accept without copying 1231 /* Check if the packet is long enough to accept without copying
1232 to a minimally-sized skbuff. */ 1232 to a minimally-sized skbuff. */
1233 if (pkt_len < rx_copybreak && 1233 if (pkt_len < rx_copybreak &&
1234 (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { 1234 (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) {
1235 skb_reserve(skb, 2); /* 16 byte align the IP header */ 1235 skb_reserve(skb, 2); /* 16 byte align the IP header */
1236 pci_dma_sync_single_for_cpu(np->pci_dev,np->rx_addr[entry], 1236 pci_dma_sync_single_for_cpu(np->pci_dev,np->rx_addr[entry],
1237 np->rx_skbuff[entry]->len, 1237 np->rx_skbuff[entry]->len,
@@ -1270,7 +1270,7 @@ static int netdev_rx(struct net_device *dev)
1270 struct sk_buff *skb; 1270 struct sk_buff *skb;
1271 entry = np->dirty_rx % RX_RING_SIZE; 1271 entry = np->dirty_rx % RX_RING_SIZE;
1272 if (np->rx_skbuff[entry] == NULL) { 1272 if (np->rx_skbuff[entry] == NULL) {
1273 skb = dev_alloc_skb(np->rx_buf_sz); 1273 skb = netdev_alloc_skb(dev, np->rx_buf_sz);
1274 np->rx_skbuff[entry] = skb; 1274 np->rx_skbuff[entry] = skb;
1275 if (skb == NULL) 1275 if (skb == NULL)
1276 break; /* Better luck next round. */ 1276 break; /* Better luck next round. */
diff --git a/drivers/net/ethernet/dec/tulip/xircom_cb.c b/drivers/net/ethernet/dec/tulip/xircom_cb.c
index 988b8eb24d37..fdb329fe6e8e 100644
--- a/drivers/net/ethernet/dec/tulip/xircom_cb.c
+++ b/drivers/net/ethernet/dec/tulip/xircom_cb.c
@@ -222,10 +222,9 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
222 is available. 222 is available.
223 */ 223 */
224 dev = alloc_etherdev(sizeof(struct xircom_private)); 224 dev = alloc_etherdev(sizeof(struct xircom_private));
225 if (!dev) { 225 if (!dev)
226 pr_err("%s: failed to allocate etherdev\n", __func__);
227 goto device_fail; 226 goto device_fail;
228 } 227
229 private = netdev_priv(dev); 228 private = netdev_priv(dev);
230 229
231 /* Allocate the send/receive buffers */ 230 /* Allocate the send/receive buffers */
@@ -1085,7 +1084,7 @@ investigate_read_descriptor(struct net_device *dev, struct xircom_private *card,
1085 pkt_len = 1518; 1084 pkt_len = 1518;
1086 } 1085 }
1087 1086
1088 skb = dev_alloc_skb(pkt_len + 2); 1087 skb = netdev_alloc_skb(dev, pkt_len + 2);
1089 if (skb == NULL) { 1088 if (skb == NULL) {
1090 dev->stats.rx_dropped++; 1089 dev->stats.rx_dropped++;
1091 goto out; 1090 goto out;
diff --git a/drivers/net/ethernet/dlink/de600.c b/drivers/net/ethernet/dlink/de600.c
index c24fab1e9cbe..682750c052c8 100644
--- a/drivers/net/ethernet/dlink/de600.c
+++ b/drivers/net/ethernet/dlink/de600.c
@@ -335,7 +335,7 @@ static void de600_rx_intr(struct net_device *dev)
335 return; 335 return;
336 } 336 }
337 337
338 skb = dev_alloc_skb(size+2); 338 skb = netdev_alloc_skb(dev, size + 2);
339 if (skb == NULL) { 339 if (skb == NULL) {
340 printk("%s: Couldn't allocate a sk_buff of size %d.\n", dev->name, size); 340 printk("%s: Couldn't allocate a sk_buff of size %d.\n", dev->name, size);
341 return; 341 return;
diff --git a/drivers/net/ethernet/dlink/de620.c b/drivers/net/ethernet/dlink/de620.c
index 3b934ab784d3..afc5aaac6b60 100644
--- a/drivers/net/ethernet/dlink/de620.c
+++ b/drivers/net/ethernet/dlink/de620.c
@@ -650,7 +650,7 @@ static int de620_rx_intr(struct net_device *dev)
650 printk(KERN_WARNING "%s: Illegal packet size: %d!\n", dev->name, size); 650 printk(KERN_WARNING "%s: Illegal packet size: %d!\n", dev->name, size);
651 } 651 }
652 else { /* Good packet? */ 652 else { /* Good packet? */
653 skb = dev_alloc_skb(size+2); 653 skb = netdev_alloc_skb(dev, size + 2);
654 if (skb == NULL) { /* Yeah, but no place to put it... */ 654 if (skb == NULL) { /* Yeah, but no place to put it... */
655 printk(KERN_WARNING "%s: Couldn't allocate a sk_buff of size %d.\n", dev->name, size); 655 printk(KERN_WARNING "%s: Couldn't allocate a sk_buff of size %d.\n", dev->name, size);
656 dev->stats.rx_dropped++; 656 dev->stats.rx_dropped++;
diff --git a/drivers/net/ethernet/dlink/sundance.c b/drivers/net/ethernet/dlink/sundance.c
index 28a3a9b50b8b..7227f29ee2ee 100644
--- a/drivers/net/ethernet/dlink/sundance.c
+++ b/drivers/net/ethernet/dlink/sundance.c
@@ -1020,11 +1020,11 @@ static void init_ring(struct net_device *dev)
1020 1020
1021 /* Fill in the Rx buffers. Handle allocation failure gracefully. */ 1021 /* Fill in the Rx buffers. Handle allocation failure gracefully. */
1022 for (i = 0; i < RX_RING_SIZE; i++) { 1022 for (i = 0; i < RX_RING_SIZE; i++) {
1023 struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + 2); 1023 struct sk_buff *skb =
1024 netdev_alloc_skb(dev, np->rx_buf_sz + 2);
1024 np->rx_skbuff[i] = skb; 1025 np->rx_skbuff[i] = skb;
1025 if (skb == NULL) 1026 if (skb == NULL)
1026 break; 1027 break;
1027 skb->dev = dev; /* Mark as being used by this device. */
1028 skb_reserve(skb, 2); /* 16 byte align the IP header. */ 1028 skb_reserve(skb, 2); /* 16 byte align the IP header. */
1029 np->rx_ring[i].frag[0].addr = cpu_to_le32( 1029 np->rx_ring[i].frag[0].addr = cpu_to_le32(
1030 dma_map_single(&np->pci_dev->dev, skb->data, 1030 dma_map_single(&np->pci_dev->dev, skb->data,
@@ -1358,7 +1358,7 @@ static void rx_poll(unsigned long data)
1358 /* Check if the packet is long enough to accept without copying 1358 /* Check if the packet is long enough to accept without copying
1359 to a minimally-sized skbuff. */ 1359 to a minimally-sized skbuff. */
1360 if (pkt_len < rx_copybreak && 1360 if (pkt_len < rx_copybreak &&
1361 (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { 1361 (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) {
1362 skb_reserve(skb, 2); /* 16 byte align the IP header */ 1362 skb_reserve(skb, 2); /* 16 byte align the IP header */
1363 dma_sync_single_for_cpu(&np->pci_dev->dev, 1363 dma_sync_single_for_cpu(&np->pci_dev->dev,
1364 le32_to_cpu(desc->frag[0].addr), 1364 le32_to_cpu(desc->frag[0].addr),
@@ -1411,11 +1411,10 @@ static void refill_rx (struct net_device *dev)
1411 struct sk_buff *skb; 1411 struct sk_buff *skb;
1412 entry = np->dirty_rx % RX_RING_SIZE; 1412 entry = np->dirty_rx % RX_RING_SIZE;
1413 if (np->rx_skbuff[entry] == NULL) { 1413 if (np->rx_skbuff[entry] == NULL) {
1414 skb = dev_alloc_skb(np->rx_buf_sz + 2); 1414 skb = netdev_alloc_skb(dev, np->rx_buf_sz + 2);
1415 np->rx_skbuff[entry] = skb; 1415 np->rx_skbuff[entry] = skb;
1416 if (skb == NULL) 1416 if (skb == NULL)
1417 break; /* Better luck next round. */ 1417 break; /* Better luck next round. */
1418 skb->dev = dev; /* Mark as being used by this device. */
1419 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1418 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1420 np->rx_ring[entry].frag[0].addr = cpu_to_le32( 1419 np->rx_ring[entry].frag[0].addr = cpu_to_le32(
1421 dma_map_single(&np->pci_dev->dev, skb->data, 1420 dma_map_single(&np->pci_dev->dev, skb->data,
diff --git a/drivers/net/ethernet/dnet.c b/drivers/net/ethernet/dnet.c
index 925c9bafc9b9..8536e376555a 100644
--- a/drivers/net/ethernet/dnet.c
+++ b/drivers/net/ethernet/dnet.c
@@ -421,7 +421,7 @@ static int dnet_poll(struct napi_struct *napi, int budget)
421 printk(KERN_ERR "%s packet receive error %x\n", 421 printk(KERN_ERR "%s packet receive error %x\n",
422 __func__, cmd_word); 422 __func__, cmd_word);
423 423
424 skb = dev_alloc_skb(pkt_len + 5); 424 skb = netdev_alloc_skb(dev, pkt_len + 5);
425 if (skb != NULL) { 425 if (skb != NULL) {
426 /* Align IP on 16 byte boundaries */ 426 /* Align IP on 16 byte boundaries */
427 skb_reserve(skb, 2); 427 skb_reserve(skb, 2);
@@ -854,10 +854,8 @@ static int __devinit dnet_probe(struct platform_device *pdev)
854 854
855 err = -ENOMEM; 855 err = -ENOMEM;
856 dev = alloc_etherdev(sizeof(*bp)); 856 dev = alloc_etherdev(sizeof(*bp));
857 if (!dev) { 857 if (!dev)
858 dev_err(&pdev->dev, "etherdev alloc failed, aborting.\n");
859 goto err_out_release_mem; 858 goto err_out_release_mem;
860 }
861 859
862 /* TODO: Actually, we have some interesting features... */ 860 /* TODO: Actually, we have some interesting features... */
863 dev->features |= 0; 861 dev->features |= 0;
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index cbdec2536da6..74aa14811977 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -74,6 +74,9 @@ static inline char *nic_name(struct pci_dev *pdev)
74 74
75/* Number of bytes of an RX frame that are copied to skb->data */ 75/* Number of bytes of an RX frame that are copied to skb->data */
76#define BE_HDR_LEN ((u16) 64) 76#define BE_HDR_LEN ((u16) 64)
77/* allocate extra space to allow tunneling decapsulation without head reallocation */
78#define BE_RX_SKB_ALLOC_SIZE (BE_HDR_LEN + 64)
79
77#define BE_MAX_JUMBO_FRAME_SIZE 9018 80#define BE_MAX_JUMBO_FRAME_SIZE 9018
78#define BE_MIN_MTU 256 81#define BE_MIN_MTU 256
79 82
@@ -262,7 +265,6 @@ struct be_drv_stats {
262 u32 rx_drops_no_erx_descr; 265 u32 rx_drops_no_erx_descr;
263 u32 rx_drops_no_tpre_descr; 266 u32 rx_drops_no_tpre_descr;
264 u32 rx_drops_too_many_frags; 267 u32 rx_drops_too_many_frags;
265 u32 rx_drops_invalid_ring;
266 u32 forwarded_packets; 268 u32 forwarded_packets;
267 u32 rx_drops_mtu; 269 u32 rx_drops_mtu;
268 u32 rx_crc_errors; 270 u32 rx_crc_errors;
@@ -273,7 +275,7 @@ struct be_drv_stats {
273 u32 rx_in_range_errors; 275 u32 rx_in_range_errors;
274 u32 rx_out_range_errors; 276 u32 rx_out_range_errors;
275 u32 rx_frame_too_long; 277 u32 rx_frame_too_long;
276 u32 rx_address_match_errors; 278 u32 rx_address_mismatch_drops;
277 u32 rx_dropped_too_small; 279 u32 rx_dropped_too_small;
278 u32 rx_dropped_too_short; 280 u32 rx_dropped_too_short;
279 u32 rx_dropped_header_too_small; 281 u32 rx_dropped_header_too_small;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 0fcb45624796..29dff7de66b6 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -1257,11 +1257,13 @@ int be_cmd_link_status_query(struct be_adapter *adapter, u8 *mac_speed,
1257 } 1257 }
1258 req = embedded_payload(wrb); 1258 req = embedded_payload(wrb);
1259 1259
1260 be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
1261 OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req), wrb, NULL);
1262
1260 if (adapter->generation == BE_GEN3 || lancer_chip(adapter)) 1263 if (adapter->generation == BE_GEN3 || lancer_chip(adapter))
1261 req->hdr.version = 1; 1264 req->hdr.version = 1;
1262 1265
1263 be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, 1266 req->hdr.domain = dom;
1264 OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req), wrb, NULL);
1265 1267
1266 status = be_mcc_notify_wait(adapter); 1268 status = be_mcc_notify_wait(adapter);
1267 if (!status) { 1269 if (!status) {
@@ -2298,52 +2300,81 @@ err:
2298 2300
2299/* Uses synchronous MCCQ */ 2301/* Uses synchronous MCCQ */
2300int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain, 2302int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain,
2301 u32 *pmac_id) 2303 bool *pmac_id_active, u32 *pmac_id, u8 *mac)
2302{ 2304{
2303 struct be_mcc_wrb *wrb; 2305 struct be_mcc_wrb *wrb;
2304 struct be_cmd_req_get_mac_list *req; 2306 struct be_cmd_req_get_mac_list *req;
2305 int status; 2307 int status;
2306 int mac_count; 2308 int mac_count;
2309 struct be_dma_mem get_mac_list_cmd;
2310 int i;
2311
2312 memset(&get_mac_list_cmd, 0, sizeof(struct be_dma_mem));
2313 get_mac_list_cmd.size = sizeof(struct be_cmd_resp_get_mac_list);
2314 get_mac_list_cmd.va = pci_alloc_consistent(adapter->pdev,
2315 get_mac_list_cmd.size,
2316 &get_mac_list_cmd.dma);
2317
2318 if (!get_mac_list_cmd.va) {
2319 dev_err(&adapter->pdev->dev,
2320 "Memory allocation failure during GET_MAC_LIST\n");
2321 return -ENOMEM;
2322 }
2307 2323
2308 spin_lock_bh(&adapter->mcc_lock); 2324 spin_lock_bh(&adapter->mcc_lock);
2309 2325
2310 wrb = wrb_from_mccq(adapter); 2326 wrb = wrb_from_mccq(adapter);
2311 if (!wrb) { 2327 if (!wrb) {
2312 status = -EBUSY; 2328 status = -EBUSY;
2313 goto err; 2329 goto out;
2314 } 2330 }
2315 req = embedded_payload(wrb); 2331
2332 req = get_mac_list_cmd.va;
2316 2333
2317 be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, 2334 be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
2318 OPCODE_COMMON_GET_MAC_LIST, sizeof(*req), 2335 OPCODE_COMMON_GET_MAC_LIST, sizeof(*req),
2319 wrb, NULL); 2336 wrb, &get_mac_list_cmd);
2320 2337
2321 req->hdr.domain = domain; 2338 req->hdr.domain = domain;
2339 req->mac_type = MAC_ADDRESS_TYPE_NETWORK;
2340 req->perm_override = 1;
2322 2341
2323 status = be_mcc_notify_wait(adapter); 2342 status = be_mcc_notify_wait(adapter);
2324 if (!status) { 2343 if (!status) {
2325 struct be_cmd_resp_get_mac_list *resp = 2344 struct be_cmd_resp_get_mac_list *resp =
2326 embedded_payload(wrb); 2345 get_mac_list_cmd.va;
2327 int i; 2346 mac_count = resp->true_mac_count + resp->pseudo_mac_count;
2328 u8 *ctxt = &resp->context[0][0]; 2347 /* Mac list returned could contain one or more active mac_ids
2329 status = -EIO; 2348 * or one or more pseudo permanant mac addresses. If an active
2330 mac_count = resp->mac_count; 2349 * mac_id is present, return first active mac_id found
2331 be_dws_le_to_cpu(&resp->context, sizeof(resp->context)); 2350 */
2332 for (i = 0; i < mac_count; i++) { 2351 for (i = 0; i < mac_count; i++) {
2333 if (!AMAP_GET_BITS(struct amap_get_mac_list_context, 2352 struct get_list_macaddr *mac_entry;
2334 act, ctxt)) { 2353 u16 mac_addr_size;
2335 *pmac_id = AMAP_GET_BITS 2354 u32 mac_id;
2336 (struct amap_get_mac_list_context, 2355
2337 macid, ctxt); 2356 mac_entry = &resp->macaddr_list[i];
2338 status = 0; 2357 mac_addr_size = le16_to_cpu(mac_entry->mac_addr_size);
2339 break; 2358 /* mac_id is a 32 bit value and mac_addr size
2359 * is 6 bytes
2360 */
2361 if (mac_addr_size == sizeof(u32)) {
2362 *pmac_id_active = true;
2363 mac_id = mac_entry->mac_addr_id.s_mac_id.mac_id;
2364 *pmac_id = le32_to_cpu(mac_id);
2365 goto out;
2340 } 2366 }
2341 ctxt += sizeof(struct amap_get_mac_list_context) / 8;
2342 } 2367 }
2368 /* If no active mac_id found, return first pseudo mac addr */
2369 *pmac_id_active = false;
2370 memcpy(mac, resp->macaddr_list[0].mac_addr_id.macaddr,
2371 ETH_ALEN);
2343 } 2372 }
2344 2373
2345err: 2374out:
2346 spin_unlock_bh(&adapter->mcc_lock); 2375 spin_unlock_bh(&adapter->mcc_lock);
2376 pci_free_consistent(adapter->pdev, get_mac_list_cmd.size,
2377 get_mac_list_cmd.va, get_mac_list_cmd.dma);
2347 return status; 2378 return status;
2348} 2379}
2349 2380
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index dca89249088f..5bb66c80f05e 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -592,8 +592,8 @@ struct be_port_rxf_stats_v0 {
592 u32 rx_in_range_errors; /* dword 10*/ 592 u32 rx_in_range_errors; /* dword 10*/
593 u32 rx_out_range_errors; /* dword 11*/ 593 u32 rx_out_range_errors; /* dword 11*/
594 u32 rx_frame_too_long; /* dword 12*/ 594 u32 rx_frame_too_long; /* dword 12*/
595 u32 rx_address_match_errors; /* dword 13*/ 595 u32 rx_address_mismatch_drops; /* dword 13*/
596 u32 rx_vlan_mismatch; /* dword 14*/ 596 u32 rx_vlan_mismatch_drops; /* dword 14*/
597 u32 rx_dropped_too_small; /* dword 15*/ 597 u32 rx_dropped_too_small; /* dword 15*/
598 u32 rx_dropped_too_short; /* dword 16*/ 598 u32 rx_dropped_too_short; /* dword 16*/
599 u32 rx_dropped_header_too_small; /* dword 17*/ 599 u32 rx_dropped_header_too_small; /* dword 17*/
@@ -799,8 +799,8 @@ struct lancer_pport_stats {
799 u32 rx_control_frames_unknown_opcode_hi; 799 u32 rx_control_frames_unknown_opcode_hi;
800 u32 rx_in_range_errors; 800 u32 rx_in_range_errors;
801 u32 rx_out_of_range_errors; 801 u32 rx_out_of_range_errors;
802 u32 rx_address_match_errors; 802 u32 rx_address_mismatch_drops;
803 u32 rx_vlan_mismatch_errors; 803 u32 rx_vlan_mismatch_drops;
804 u32 rx_dropped_too_small; 804 u32 rx_dropped_too_small;
805 u32 rx_dropped_too_short; 805 u32 rx_dropped_too_short;
806 u32 rx_dropped_header_too_small; 806 u32 rx_dropped_header_too_small;
@@ -1346,22 +1346,36 @@ struct be_cmd_resp_set_func_cap {
1346 1346
1347/******************** GET/SET_MACLIST **************************/ 1347/******************** GET/SET_MACLIST **************************/
1348#define BE_MAX_MAC 64 1348#define BE_MAX_MAC 64
1349struct amap_get_mac_list_context {
1350 u8 macid[31];
1351 u8 act;
1352} __packed;
1353
1354struct be_cmd_req_get_mac_list { 1349struct be_cmd_req_get_mac_list {
1355 struct be_cmd_req_hdr hdr; 1350 struct be_cmd_req_hdr hdr;
1356 u32 rsvd; 1351 u8 mac_type;
1352 u8 perm_override;
1353 u16 iface_id;
1354 u32 mac_id;
1355 u32 rsvd[3];
1356} __packed;
1357
1358struct get_list_macaddr {
1359 u16 mac_addr_size;
1360 union {
1361 u8 macaddr[6];
1362 struct {
1363 u8 rsvd[2];
1364 u32 mac_id;
1365 } __packed s_mac_id;
1366 } __packed mac_addr_id;
1357} __packed; 1367} __packed;
1358 1368
1359struct be_cmd_resp_get_mac_list { 1369struct be_cmd_resp_get_mac_list {
1360 struct be_cmd_resp_hdr hdr; 1370 struct be_cmd_resp_hdr hdr;
1361 u8 mac_count; 1371 struct get_list_macaddr fd_macaddr; /* Factory default mac */
1362 u8 rsvd1; 1372 struct get_list_macaddr macid_macaddr; /* soft mac */
1363 u16 rsvd2; 1373 u8 true_mac_count;
1364 u8 context[sizeof(struct amap_get_mac_list_context) / 8][BE_MAX_MAC]; 1374 u8 pseudo_mac_count;
1375 u8 mac_list_size;
1376 u8 rsvd;
1377 /* perm override mac */
1378 struct get_list_macaddr macaddr_list[BE_MAX_MAC];
1365} __packed; 1379} __packed;
1366 1380
1367struct be_cmd_req_set_mac_list { 1381struct be_cmd_req_set_mac_list {
@@ -1384,7 +1398,7 @@ struct be_port_rxf_stats_v1 {
1384 u32 rx_in_range_errors; 1398 u32 rx_in_range_errors;
1385 u32 rx_out_range_errors; 1399 u32 rx_out_range_errors;
1386 u32 rx_frame_too_long; 1400 u32 rx_frame_too_long;
1387 u32 rx_address_match_errors; 1401 u32 rx_address_mismatch_drops;
1388 u32 rx_dropped_too_small; 1402 u32 rx_dropped_too_small;
1389 u32 rx_dropped_too_short; 1403 u32 rx_dropped_too_short;
1390 u32 rx_dropped_header_too_small; 1404 u32 rx_dropped_header_too_small;
@@ -1575,7 +1589,7 @@ extern int be_cmd_req_native_mode(struct be_adapter *adapter);
1575extern int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size); 1589extern int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size);
1576extern void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf); 1590extern void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf);
1577extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain, 1591extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u32 domain,
1578 u32 *pmac_id); 1592 bool *pmac_id_active, u32 *pmac_id, u8 *mac);
1579extern int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array, 1593extern int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array,
1580 u8 mac_count, u32 domain); 1594 u8 mac_count, u32 domain);
1581 1595
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c
index 802e5ddef8a8..dc1383c396c0 100644
--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
+++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
@@ -42,15 +42,42 @@ static const struct be_ethtool_stat et_stats[] = {
42 {DRVSTAT_INFO(rx_alignment_symbol_errors)}, 42 {DRVSTAT_INFO(rx_alignment_symbol_errors)},
43 {DRVSTAT_INFO(rx_pause_frames)}, 43 {DRVSTAT_INFO(rx_pause_frames)},
44 {DRVSTAT_INFO(rx_control_frames)}, 44 {DRVSTAT_INFO(rx_control_frames)},
45 /* Received packets dropped when the Ethernet length field
46 * is not equal to the actual Ethernet data length.
47 */
45 {DRVSTAT_INFO(rx_in_range_errors)}, 48 {DRVSTAT_INFO(rx_in_range_errors)},
49 /* Received packets dropped when their length field is >= 1501 bytes
50 * and <= 1535 bytes.
51 */
46 {DRVSTAT_INFO(rx_out_range_errors)}, 52 {DRVSTAT_INFO(rx_out_range_errors)},
53 /* Received packets dropped when they are longer than 9216 bytes */
47 {DRVSTAT_INFO(rx_frame_too_long)}, 54 {DRVSTAT_INFO(rx_frame_too_long)},
48 {DRVSTAT_INFO(rx_address_match_errors)}, 55 /* Received packets dropped when they don't pass the unicast or
56 * multicast address filtering.
57 */
58 {DRVSTAT_INFO(rx_address_mismatch_drops)},
59 /* Received packets dropped when IP packet length field is less than
60 * the IP header length field.
61 */
49 {DRVSTAT_INFO(rx_dropped_too_small)}, 62 {DRVSTAT_INFO(rx_dropped_too_small)},
63 /* Received packets dropped when IP length field is greater than
64 * the actual packet length.
65 */
50 {DRVSTAT_INFO(rx_dropped_too_short)}, 66 {DRVSTAT_INFO(rx_dropped_too_short)},
67 /* Received packets dropped when the IP header length field is less
68 * than 5.
69 */
51 {DRVSTAT_INFO(rx_dropped_header_too_small)}, 70 {DRVSTAT_INFO(rx_dropped_header_too_small)},
71 /* Received packets dropped when the TCP header length field is less
72 * than 5 or the TCP header length + IP header length is more
73 * than IP packet length.
74 */
52 {DRVSTAT_INFO(rx_dropped_tcp_length)}, 75 {DRVSTAT_INFO(rx_dropped_tcp_length)},
53 {DRVSTAT_INFO(rx_dropped_runt)}, 76 {DRVSTAT_INFO(rx_dropped_runt)},
77 /* Number of received packets dropped when a fifo for descriptors going
78 * into the packet demux block overflows. In normal operation, this
79 * fifo must never overflow.
80 */
54 {DRVSTAT_INFO(rxpp_fifo_overflow_drop)}, 81 {DRVSTAT_INFO(rxpp_fifo_overflow_drop)},
55 {DRVSTAT_INFO(rx_input_fifo_overflow_drop)}, 82 {DRVSTAT_INFO(rx_input_fifo_overflow_drop)},
56 {DRVSTAT_INFO(rx_ip_checksum_errs)}, 83 {DRVSTAT_INFO(rx_ip_checksum_errs)},
@@ -59,16 +86,35 @@ static const struct be_ethtool_stat et_stats[] = {
59 {DRVSTAT_INFO(tx_pauseframes)}, 86 {DRVSTAT_INFO(tx_pauseframes)},
60 {DRVSTAT_INFO(tx_controlframes)}, 87 {DRVSTAT_INFO(tx_controlframes)},
61 {DRVSTAT_INFO(rx_priority_pause_frames)}, 88 {DRVSTAT_INFO(rx_priority_pause_frames)},
89 /* Received packets dropped when an internal fifo going into
90 * main packet buffer tank (PMEM) overflows.
91 */
62 {DRVSTAT_INFO(pmem_fifo_overflow_drop)}, 92 {DRVSTAT_INFO(pmem_fifo_overflow_drop)},
63 {DRVSTAT_INFO(jabber_events)}, 93 {DRVSTAT_INFO(jabber_events)},
94 /* Received packets dropped due to lack of available HW packet buffers
95 * used to temporarily hold the received packets.
96 */
64 {DRVSTAT_INFO(rx_drops_no_pbuf)}, 97 {DRVSTAT_INFO(rx_drops_no_pbuf)},
65 {DRVSTAT_INFO(rx_drops_no_txpb)}, 98 /* Received packets dropped due to input receive buffer
99 * descriptor fifo overflowing.
100 */
66 {DRVSTAT_INFO(rx_drops_no_erx_descr)}, 101 {DRVSTAT_INFO(rx_drops_no_erx_descr)},
102 /* Packets dropped because the internal FIFO to the offloaded TCP
103 * receive processing block is full. This could happen only for
104 * offloaded iSCSI or FCoE trarffic.
105 */
67 {DRVSTAT_INFO(rx_drops_no_tpre_descr)}, 106 {DRVSTAT_INFO(rx_drops_no_tpre_descr)},
107 /* Received packets dropped when they need more than 8
108 * receive buffers. This cannot happen as the driver configures
109 * 2048 byte receive buffers.
110 */
68 {DRVSTAT_INFO(rx_drops_too_many_frags)}, 111 {DRVSTAT_INFO(rx_drops_too_many_frags)},
69 {DRVSTAT_INFO(rx_drops_invalid_ring)},
70 {DRVSTAT_INFO(forwarded_packets)}, 112 {DRVSTAT_INFO(forwarded_packets)},
113 /* Received packets dropped when the frame length
114 * is more than 9018 bytes
115 */
71 {DRVSTAT_INFO(rx_drops_mtu)}, 116 {DRVSTAT_INFO(rx_drops_mtu)},
117 /* Number of packets dropped due to random early drop function */
72 {DRVSTAT_INFO(eth_red_drops)}, 118 {DRVSTAT_INFO(eth_red_drops)},
73 {DRVSTAT_INFO(be_on_die_temperature)} 119 {DRVSTAT_INFO(be_on_die_temperature)}
74}; 120};
@@ -84,8 +130,15 @@ static const struct be_ethtool_stat et_rx_stats[] = {
84 {DRVSTAT_RX_INFO(rx_events)}, 130 {DRVSTAT_RX_INFO(rx_events)},
85 {DRVSTAT_RX_INFO(rx_compl)}, 131 {DRVSTAT_RX_INFO(rx_compl)},
86 {DRVSTAT_RX_INFO(rx_mcast_pkts)}, 132 {DRVSTAT_RX_INFO(rx_mcast_pkts)},
133 /* Number of page allocation failures while posting receive buffers
134 * to HW.
135 */
87 {DRVSTAT_RX_INFO(rx_post_fail)}, 136 {DRVSTAT_RX_INFO(rx_post_fail)},
137 /* Recevied packets dropped due to skb allocation failure */
88 {DRVSTAT_RX_INFO(rx_drops_no_skbs)}, 138 {DRVSTAT_RX_INFO(rx_drops_no_skbs)},
139 /* Received packets dropped due to lack of available fetched buffers
140 * posted by the driver.
141 */
89 {DRVSTAT_RX_INFO(rx_drops_no_frags)} 142 {DRVSTAT_RX_INFO(rx_drops_no_frags)}
90}; 143};
91#define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats)) 144#define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats))
@@ -97,9 +150,14 @@ static const struct be_ethtool_stat et_tx_stats[] = {
97 {DRVSTAT_TX_INFO(tx_compl)}, /* If moving this member see above note */ 150 {DRVSTAT_TX_INFO(tx_compl)}, /* If moving this member see above note */
98 {DRVSTAT_TX_INFO(tx_bytes)}, 151 {DRVSTAT_TX_INFO(tx_bytes)},
99 {DRVSTAT_TX_INFO(tx_pkts)}, 152 {DRVSTAT_TX_INFO(tx_pkts)},
153 /* Number of skbs queued for trasmission by the driver */
100 {DRVSTAT_TX_INFO(tx_reqs)}, 154 {DRVSTAT_TX_INFO(tx_reqs)},
155 /* Number of TX work request blocks DMAed to HW */
101 {DRVSTAT_TX_INFO(tx_wrbs)}, 156 {DRVSTAT_TX_INFO(tx_wrbs)},
102 {DRVSTAT_TX_INFO(tx_compl)}, 157 {DRVSTAT_TX_INFO(tx_compl)},
158 /* Number of times the TX queue was stopped due to lack
159 * of spaces in the TXQ.
160 */
103 {DRVSTAT_TX_INFO(tx_stops)} 161 {DRVSTAT_TX_INFO(tx_stops)}
104}; 162};
105#define ETHTOOL_TXSTATS_NUM (ARRAY_SIZE(et_tx_stats)) 163#define ETHTOOL_TXSTATS_NUM (ARRAY_SIZE(et_tx_stats))
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index e703d64434f8..780498784d8e 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -286,7 +286,9 @@ static void populate_be2_stats(struct be_adapter *adapter)
286 drvs->rx_input_fifo_overflow_drop = port_stats->rx_input_fifo_overflow; 286 drvs->rx_input_fifo_overflow_drop = port_stats->rx_input_fifo_overflow;
287 drvs->rx_dropped_header_too_small = 287 drvs->rx_dropped_header_too_small =
288 port_stats->rx_dropped_header_too_small; 288 port_stats->rx_dropped_header_too_small;
289 drvs->rx_address_match_errors = port_stats->rx_address_match_errors; 289 drvs->rx_address_mismatch_drops =
290 port_stats->rx_address_mismatch_drops +
291 port_stats->rx_vlan_mismatch_drops;
290 drvs->rx_alignment_symbol_errors = 292 drvs->rx_alignment_symbol_errors =
291 port_stats->rx_alignment_symbol_errors; 293 port_stats->rx_alignment_symbol_errors;
292 294
@@ -298,9 +300,7 @@ static void populate_be2_stats(struct be_adapter *adapter)
298 else 300 else
299 drvs->jabber_events = rxf_stats->port0_jabber_events; 301 drvs->jabber_events = rxf_stats->port0_jabber_events;
300 drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; 302 drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf;
301 drvs->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb;
302 drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; 303 drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr;
303 drvs->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring;
304 drvs->forwarded_packets = rxf_stats->forwarded_packets; 304 drvs->forwarded_packets = rxf_stats->forwarded_packets;
305 drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu; 305 drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu;
306 drvs->rx_drops_no_tpre_descr = rxf_stats->rx_drops_no_tpre_descr; 306 drvs->rx_drops_no_tpre_descr = rxf_stats->rx_drops_no_tpre_descr;
@@ -337,7 +337,7 @@ static void populate_be3_stats(struct be_adapter *adapter)
337 port_stats->rx_dropped_header_too_small; 337 port_stats->rx_dropped_header_too_small;
338 drvs->rx_input_fifo_overflow_drop = 338 drvs->rx_input_fifo_overflow_drop =
339 port_stats->rx_input_fifo_overflow_drop; 339 port_stats->rx_input_fifo_overflow_drop;
340 drvs->rx_address_match_errors = port_stats->rx_address_match_errors; 340 drvs->rx_address_mismatch_drops = port_stats->rx_address_mismatch_drops;
341 drvs->rx_alignment_symbol_errors = 341 drvs->rx_alignment_symbol_errors =
342 port_stats->rx_alignment_symbol_errors; 342 port_stats->rx_alignment_symbol_errors;
343 drvs->rxpp_fifo_overflow_drop = port_stats->rxpp_fifo_overflow_drop; 343 drvs->rxpp_fifo_overflow_drop = port_stats->rxpp_fifo_overflow_drop;
@@ -345,9 +345,7 @@ static void populate_be3_stats(struct be_adapter *adapter)
345 drvs->tx_controlframes = port_stats->tx_controlframes; 345 drvs->tx_controlframes = port_stats->tx_controlframes;
346 drvs->jabber_events = port_stats->jabber_events; 346 drvs->jabber_events = port_stats->jabber_events;
347 drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf; 347 drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf;
348 drvs->rx_drops_no_txpb = rxf_stats->rx_drops_no_txpb;
349 drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr; 348 drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr;
350 drvs->rx_drops_invalid_ring = rxf_stats->rx_drops_invalid_ring;
351 drvs->forwarded_packets = rxf_stats->forwarded_packets; 349 drvs->forwarded_packets = rxf_stats->forwarded_packets;
352 drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu; 350 drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu;
353 drvs->rx_drops_no_tpre_descr = rxf_stats->rx_drops_no_tpre_descr; 351 drvs->rx_drops_no_tpre_descr = rxf_stats->rx_drops_no_tpre_descr;
@@ -380,13 +378,14 @@ static void populate_lancer_stats(struct be_adapter *adapter)
380 drvs->rx_dropped_header_too_small = 378 drvs->rx_dropped_header_too_small =
381 pport_stats->rx_dropped_header_too_small; 379 pport_stats->rx_dropped_header_too_small;
382 drvs->rx_input_fifo_overflow_drop = pport_stats->rx_fifo_overflow; 380 drvs->rx_input_fifo_overflow_drop = pport_stats->rx_fifo_overflow;
383 drvs->rx_address_match_errors = pport_stats->rx_address_match_errors; 381 drvs->rx_address_mismatch_drops =
382 pport_stats->rx_address_mismatch_drops +
383 pport_stats->rx_vlan_mismatch_drops;
384 drvs->rx_alignment_symbol_errors = pport_stats->rx_symbol_errors_lo; 384 drvs->rx_alignment_symbol_errors = pport_stats->rx_symbol_errors_lo;
385 drvs->rxpp_fifo_overflow_drop = pport_stats->rx_fifo_overflow; 385 drvs->rxpp_fifo_overflow_drop = pport_stats->rx_fifo_overflow;
386 drvs->tx_pauseframes = pport_stats->tx_pause_frames_lo; 386 drvs->tx_pauseframes = pport_stats->tx_pause_frames_lo;
387 drvs->tx_controlframes = pport_stats->tx_control_frames_lo; 387 drvs->tx_controlframes = pport_stats->tx_control_frames_lo;
388 drvs->jabber_events = pport_stats->rx_jabbers; 388 drvs->jabber_events = pport_stats->rx_jabbers;
389 drvs->rx_drops_invalid_ring = pport_stats->rx_drops_invalid_queue;
390 drvs->forwarded_packets = pport_stats->num_forwards_lo; 389 drvs->forwarded_packets = pport_stats->num_forwards_lo;
391 drvs->rx_drops_mtu = pport_stats->rx_drops_mtu_lo; 390 drvs->rx_drops_mtu = pport_stats->rx_drops_mtu_lo;
392 drvs->rx_drops_too_many_frags = 391 drvs->rx_drops_too_many_frags =
@@ -1189,7 +1188,7 @@ static void be_rx_compl_process(struct be_adapter *adapter,
1189 struct net_device *netdev = adapter->netdev; 1188 struct net_device *netdev = adapter->netdev;
1190 struct sk_buff *skb; 1189 struct sk_buff *skb;
1191 1190
1192 skb = netdev_alloc_skb_ip_align(netdev, BE_HDR_LEN); 1191 skb = netdev_alloc_skb_ip_align(netdev, BE_RX_SKB_ALLOC_SIZE);
1193 if (unlikely(!skb)) { 1192 if (unlikely(!skb)) {
1194 rx_stats(rxo)->rx_drops_no_skbs++; 1193 rx_stats(rxo)->rx_drops_no_skbs++;
1195 be_rx_compl_discard(adapter, rxo, rxcp); 1194 be_rx_compl_discard(adapter, rxo, rxcp);
@@ -2609,19 +2608,28 @@ static void be_setup_init(struct be_adapter *adapter)
2609 adapter->eq_next_idx = 0; 2608 adapter->eq_next_idx = 0;
2610} 2609}
2611 2610
2612static int be_configure_mac_from_list(struct be_adapter *adapter, u8 *mac) 2611static int be_add_mac_from_list(struct be_adapter *adapter, u8 *mac)
2613{ 2612{
2614 u32 pmac_id; 2613 u32 pmac_id;
2615 int status = be_cmd_get_mac_from_list(adapter, 0, &pmac_id); 2614 int status;
2616 if (status != 0) 2615 bool pmac_id_active;
2617 goto do_none; 2616
2618 status = be_cmd_mac_addr_query(adapter, mac, 2617 status = be_cmd_get_mac_from_list(adapter, 0, &pmac_id_active,
2619 MAC_ADDRESS_TYPE_NETWORK, 2618 &pmac_id, mac);
2620 false, adapter->if_handle, pmac_id);
2621 if (status != 0) 2619 if (status != 0)
2622 goto do_none; 2620 goto do_none;
2623 status = be_cmd_pmac_add(adapter, mac, adapter->if_handle, 2621
2624 &adapter->pmac_id, 0); 2622 if (pmac_id_active) {
2623 status = be_cmd_mac_addr_query(adapter, mac,
2624 MAC_ADDRESS_TYPE_NETWORK,
2625 false, adapter->if_handle, pmac_id);
2626
2627 if (!status)
2628 adapter->pmac_id = pmac_id;
2629 } else {
2630 status = be_cmd_pmac_add(adapter, mac,
2631 adapter->if_handle, &adapter->pmac_id, 0);
2632 }
2625do_none: 2633do_none:
2626 return status; 2634 return status;
2627} 2635}
@@ -2686,7 +2694,7 @@ static int be_setup(struct be_adapter *adapter)
2686 */ 2694 */
2687 if (!be_physfn(adapter)) { 2695 if (!be_physfn(adapter)) {
2688 if (lancer_chip(adapter)) 2696 if (lancer_chip(adapter))
2689 status = be_configure_mac_from_list(adapter, mac); 2697 status = be_add_mac_from_list(adapter, mac);
2690 else 2698 else
2691 status = be_cmd_mac_addr_query(adapter, mac, 2699 status = be_cmd_mac_addr_query(adapter, mac,
2692 MAC_ADDRESS_TYPE_NETWORK, false, 2700 MAC_ADDRESS_TYPE_NETWORK, false,
diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 60f0e788cc25..0b723ff2294b 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/net/ethoc.c 2 * linux/drivers/net/ethernet/ethoc.c
3 * 3 *
4 * Copyright (C) 2007-2008 Avionic Design Development GmbH 4 * Copyright (C) 2007-2008 Avionic Design Development GmbH
5 * Copyright (C) 2008-2009 Avionic Design GmbH 5 * Copyright (C) 2008-2009 Avionic Design GmbH
@@ -913,7 +913,6 @@ static int __devinit ethoc_probe(struct platform_device *pdev)
913 /* allocate networking device */ 913 /* allocate networking device */
914 netdev = alloc_etherdev(sizeof(struct ethoc)); 914 netdev = alloc_etherdev(sizeof(struct ethoc));
915 if (!netdev) { 915 if (!netdev) {
916 dev_err(&pdev->dev, "cannot allocate network device\n");
917 ret = -ENOMEM; 916 ret = -ENOMEM;
918 goto out; 917 goto out;
919 } 918 }
diff --git a/drivers/net/ethernet/fealnx.c b/drivers/net/ethernet/fealnx.c
index c82d444b582d..1637b9862292 100644
--- a/drivers/net/ethernet/fealnx.c
+++ b/drivers/net/ethernet/fealnx.c
@@ -1070,14 +1070,13 @@ static void allocate_rx_buffers(struct net_device *dev)
1070 while (np->really_rx_count != RX_RING_SIZE) { 1070 while (np->really_rx_count != RX_RING_SIZE) {
1071 struct sk_buff *skb; 1071 struct sk_buff *skb;
1072 1072
1073 skb = dev_alloc_skb(np->rx_buf_sz); 1073 skb = netdev_alloc_skb(dev, np->rx_buf_sz);
1074 if (skb == NULL) 1074 if (skb == NULL)
1075 break; /* Better luck next round. */ 1075 break; /* Better luck next round. */
1076 1076
1077 while (np->lack_rxbuf->skbuff) 1077 while (np->lack_rxbuf->skbuff)
1078 np->lack_rxbuf = np->lack_rxbuf->next_desc_logical; 1078 np->lack_rxbuf = np->lack_rxbuf->next_desc_logical;
1079 1079
1080 skb->dev = dev; /* Mark as being used by this device. */
1081 np->lack_rxbuf->skbuff = skb; 1080 np->lack_rxbuf->skbuff = skb;
1082 np->lack_rxbuf->buffer = pci_map_single(np->pci_dev, skb->data, 1081 np->lack_rxbuf->buffer = pci_map_single(np->pci_dev, skb->data,
1083 np->rx_buf_sz, PCI_DMA_FROMDEVICE); 1082 np->rx_buf_sz, PCI_DMA_FROMDEVICE);
@@ -1265,7 +1264,7 @@ static void init_ring(struct net_device *dev)
1265 1264
1266 /* allocate skb for rx buffers */ 1265 /* allocate skb for rx buffers */
1267 for (i = 0; i < RX_RING_SIZE; i++) { 1266 for (i = 0; i < RX_RING_SIZE; i++) {
1268 struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz); 1267 struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz);
1269 1268
1270 if (skb == NULL) { 1269 if (skb == NULL) {
1271 np->lack_rxbuf = &np->rx_ring[i]; 1270 np->lack_rxbuf = &np->rx_ring[i];
@@ -1274,7 +1273,6 @@ static void init_ring(struct net_device *dev)
1274 1273
1275 ++np->really_rx_count; 1274 ++np->really_rx_count;
1276 np->rx_ring[i].skbuff = skb; 1275 np->rx_ring[i].skbuff = skb;
1277 skb->dev = dev; /* Mark as being used by this device. */
1278 np->rx_ring[i].buffer = pci_map_single(np->pci_dev, skb->data, 1276 np->rx_ring[i].buffer = pci_map_single(np->pci_dev, skb->data,
1279 np->rx_buf_sz, PCI_DMA_FROMDEVICE); 1277 np->rx_buf_sz, PCI_DMA_FROMDEVICE);
1280 np->rx_ring[i].status = RXOWN; 1278 np->rx_ring[i].status = RXOWN;
@@ -1704,7 +1702,7 @@ static int netdev_rx(struct net_device *dev)
1704 /* Check if the packet is long enough to accept without copying 1702 /* Check if the packet is long enough to accept without copying
1705 to a minimally-sized skbuff. */ 1703 to a minimally-sized skbuff. */
1706 if (pkt_len < rx_copybreak && 1704 if (pkt_len < rx_copybreak &&
1707 (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { 1705 (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) {
1708 skb_reserve(skb, 2); /* 16 byte align the IP header */ 1706 skb_reserve(skb, 2); /* 16 byte align the IP header */
1709 pci_dma_sync_single_for_cpu(np->pci_dev, 1707 pci_dma_sync_single_for_cpu(np->pci_dev,
1710 np->cur_rx->buffer, 1708 np->cur_rx->buffer,
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index 1c7aad8fa19c..0ee2ca7baaf3 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -711,7 +711,7 @@ fec_enet_rx(struct net_device *ndev)
711 * include that when passing upstream as it messes up 711 * include that when passing upstream as it messes up
712 * bridging applications. 712 * bridging applications.
713 */ 713 */
714 skb = dev_alloc_skb(pkt_len - 4 + NET_IP_ALIGN); 714 skb = netdev_alloc_skb(ndev, pkt_len - 4 + NET_IP_ALIGN);
715 715
716 if (unlikely(!skb)) { 716 if (unlikely(!skb)) {
717 printk("%s: Memory squeeze, dropping packet.\n", 717 printk("%s: Memory squeeze, dropping packet.\n",
@@ -1210,7 +1210,7 @@ static int fec_enet_alloc_buffers(struct net_device *ndev)
1210 1210
1211 bdp = fep->rx_bd_base; 1211 bdp = fep->rx_bd_base;
1212 for (i = 0; i < RX_RING_SIZE; i++) { 1212 for (i = 0; i < RX_RING_SIZE; i++) {
1213 skb = dev_alloc_skb(FEC_ENET_RX_FRSIZE); 1213 skb = netdev_alloc_skb(ndev, FEC_ENET_RX_FRSIZE);
1214 if (!skb) { 1214 if (!skb) {
1215 fec_enet_free_buffers(ndev); 1215 fec_enet_free_buffers(ndev);
1216 return -ENOMEM; 1216 return -ENOMEM;
@@ -1739,21 +1739,6 @@ static struct platform_driver fec_driver = {
1739 .remove = __devexit_p(fec_drv_remove), 1739 .remove = __devexit_p(fec_drv_remove),
1740}; 1740};
1741 1741
1742static int __init 1742module_platform_driver(fec_driver);
1743fec_enet_module_init(void)
1744{
1745 printk(KERN_INFO "FEC Ethernet Driver\n");
1746
1747 return platform_driver_register(&fec_driver);
1748}
1749
1750static void __exit
1751fec_enet_cleanup(void)
1752{
1753 platform_driver_unregister(&fec_driver);
1754}
1755
1756module_exit(fec_enet_cleanup);
1757module_init(fec_enet_module_init);
1758 1743
1759MODULE_LICENSE("GPL"); 1744MODULE_LICENSE("GPL");
diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx.c b/drivers/net/ethernet/freescale/fec_mpc52xx.c
index 30745b56fe5d..7b34d8c698da 100644
--- a/drivers/net/ethernet/freescale/fec_mpc52xx.c
+++ b/drivers/net/ethernet/freescale/fec_mpc52xx.c
@@ -160,7 +160,7 @@ static int mpc52xx_fec_alloc_rx_buffers(struct net_device *dev, struct bcom_task
160 struct sk_buff *skb; 160 struct sk_buff *skb;
161 161
162 while (!bcom_queue_full(rxtsk)) { 162 while (!bcom_queue_full(rxtsk)) {
163 skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE); 163 skb = netdev_alloc_skb(dev, FEC_RX_BUFFER_SIZE);
164 if (!skb) 164 if (!skb)
165 return -EAGAIN; 165 return -EAGAIN;
166 166
@@ -416,7 +416,7 @@ static irqreturn_t mpc52xx_fec_rx_interrupt(int irq, void *dev_id)
416 416
417 /* skbs are allocated on open, so now we allocate a new one, 417 /* skbs are allocated on open, so now we allocate a new one,
418 * and remove the old (with the packet) */ 418 * and remove the old (with the packet) */
419 skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE); 419 skb = netdev_alloc_skb(dev, FEC_RX_BUFFER_SIZE);
420 if (!skb) { 420 if (!skb) {
421 /* Can't get a new one : reuse the same & drop pkt */ 421 /* Can't get a new one : reuse the same & drop pkt */
422 dev_notice(&dev->dev, "Low memory - dropped packet.\n"); 422 dev_notice(&dev->dev, "Low memory - dropped packet.\n");
diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx.h b/drivers/net/ethernet/freescale/fec_mpc52xx.h
index 41d2dffde55b..10afa54dd062 100644
--- a/drivers/net/ethernet/freescale/fec_mpc52xx.h
+++ b/drivers/net/ethernet/freescale/fec_mpc52xx.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/drivers/net/fec_mpc52xx/fec.h 2 * drivers/net/ethernet/freescale/fec_mpc52xx.h
3 * 3 *
4 * Driver for the MPC5200 Fast Ethernet Controller 4 * Driver for the MPC5200 Fast Ethernet Controller
5 * 5 *
diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
index 910a8e18a9ae..999638a7c851 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -154,7 +154,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
154 154
155 if (pkt_len <= fpi->rx_copybreak) { 155 if (pkt_len <= fpi->rx_copybreak) {
156 /* +2 to make IP header L1 cache aligned */ 156 /* +2 to make IP header L1 cache aligned */
157 skbn = dev_alloc_skb(pkt_len + 2); 157 skbn = netdev_alloc_skb(dev, pkt_len + 2);
158 if (skbn != NULL) { 158 if (skbn != NULL) {
159 skb_reserve(skbn, 2); /* align IP header */ 159 skb_reserve(skbn, 2); /* align IP header */
160 skb_copy_from_linear_data(skb, 160 skb_copy_from_linear_data(skb,
@@ -165,7 +165,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
165 skbn = skbt; 165 skbn = skbt;
166 } 166 }
167 } else { 167 } else {
168 skbn = dev_alloc_skb(ENET_RX_FRSIZE); 168 skbn = netdev_alloc_skb(dev, ENET_RX_FRSIZE);
169 169
170 if (skbn) 170 if (skbn)
171 skb_align(skbn, ENET_RX_ALIGN); 171 skb_align(skbn, ENET_RX_ALIGN);
@@ -286,7 +286,7 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
286 286
287 if (pkt_len <= fpi->rx_copybreak) { 287 if (pkt_len <= fpi->rx_copybreak) {
288 /* +2 to make IP header L1 cache aligned */ 288 /* +2 to make IP header L1 cache aligned */
289 skbn = dev_alloc_skb(pkt_len + 2); 289 skbn = netdev_alloc_skb(dev, pkt_len + 2);
290 if (skbn != NULL) { 290 if (skbn != NULL) {
291 skb_reserve(skbn, 2); /* align IP header */ 291 skb_reserve(skbn, 2); /* align IP header */
292 skb_copy_from_linear_data(skb, 292 skb_copy_from_linear_data(skb,
@@ -297,7 +297,7 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
297 skbn = skbt; 297 skbn = skbt;
298 } 298 }
299 } else { 299 } else {
300 skbn = dev_alloc_skb(ENET_RX_FRSIZE); 300 skbn = netdev_alloc_skb(dev, ENET_RX_FRSIZE);
301 301
302 if (skbn) 302 if (skbn)
303 skb_align(skbn, ENET_RX_ALIGN); 303 skb_align(skbn, ENET_RX_ALIGN);
@@ -504,7 +504,7 @@ void fs_init_bds(struct net_device *dev)
504 * Initialize the receive buffer descriptors. 504 * Initialize the receive buffer descriptors.
505 */ 505 */
506 for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) { 506 for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) {
507 skb = dev_alloc_skb(ENET_RX_FRSIZE); 507 skb = netdev_alloc_skb(dev, ENET_RX_FRSIZE);
508 if (skb == NULL) { 508 if (skb == NULL) {
509 dev_warn(fep->dev, 509 dev_warn(fep->dev,
510 "Memory squeeze, unable to allocate skb\n"); 510 "Memory squeeze, unable to allocate skb\n");
@@ -592,7 +592,7 @@ static struct sk_buff *tx_skb_align_workaround(struct net_device *dev,
592 struct fs_enet_private *fep = netdev_priv(dev); 592 struct fs_enet_private *fep = netdev_priv(dev);
593 593
594 /* Alloc new skb */ 594 /* Alloc new skb */
595 new_skb = dev_alloc_skb(skb->len + 4); 595 new_skb = netdev_alloc_skb(dev, skb->len + 4);
596 if (!new_skb) { 596 if (!new_skb) {
597 if (net_ratelimit()) { 597 if (net_ratelimit()) {
598 dev_warn(fep->dev, 598 dev_warn(fep->dev,
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 39d160d353a4..adb0ae4e4195 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/gianfar.c 2 * drivers/net/ethernet/freescale/gianfar.c
3 * 3 *
4 * Gianfar Ethernet Driver 4 * Gianfar Ethernet Driver
5 * This driver is designed for the non-CPM ethernet controllers 5 * This driver is designed for the non-CPM ethernet controllers
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
index 40c33a7554c0..4fe0f342acec 100644
--- a/drivers/net/ethernet/freescale/gianfar.h
+++ b/drivers/net/ethernet/freescale/gianfar.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/gianfar.h 2 * drivers/net/ethernet/freescale/gianfar.h
3 * 3 *
4 * Gianfar Ethernet Driver 4 * Gianfar Ethernet Driver
5 * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560 5 * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 5a3b2e5b2880..5a78d55f46e7 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/gianfar_ethtool.c 2 * drivers/net/ethernet/freescale/gianfar_ethtool.c
3 * 3 *
4 * Gianfar Ethernet Driver 4 * Gianfar Ethernet Driver
5 * Ethtool support for Gianfar Enet 5 * Ethtool support for Gianfar Enet
diff --git a/drivers/net/ethernet/freescale/gianfar_sysfs.c b/drivers/net/ethernet/freescale/gianfar_sysfs.c
index 64f4094ac7f1..cd14a4d449c2 100644
--- a/drivers/net/ethernet/freescale/gianfar_sysfs.c
+++ b/drivers/net/ethernet/freescale/gianfar_sysfs.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/gianfar_sysfs.c 2 * drivers/net/ethernet/freescale/gianfar_sysfs.c
3 * 3 *
4 * Gianfar Ethernet Driver 4 * Gianfar Ethernet Driver
5 * This driver is designed for the non-CPM ethernet controllers 5 * This driver is designed for the non-CPM ethernet controllers
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index ba2dc083bfc0..ec0905461312 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -214,8 +214,9 @@ static struct sk_buff *get_new_skb(struct ucc_geth_private *ugeth,
214 214
215 skb = __skb_dequeue(&ugeth->rx_recycle); 215 skb = __skb_dequeue(&ugeth->rx_recycle);
216 if (!skb) 216 if (!skb)
217 skb = dev_alloc_skb(ugeth->ug_info->uf_info.max_rx_buf_length + 217 skb = netdev_alloc_skb(ugeth->ndev,
218 UCC_GETH_RX_DATA_BUF_ALIGNMENT); 218 ugeth->ug_info->uf_info.max_rx_buf_length +
219 UCC_GETH_RX_DATA_BUF_ALIGNMENT);
219 if (skb == NULL) 220 if (skb == NULL)
220 return NULL; 221 return NULL;
221 222
@@ -227,8 +228,6 @@ static struct sk_buff *get_new_skb(struct ucc_geth_private *ugeth,
227 (((unsigned)skb->data) & (UCC_GETH_RX_DATA_BUF_ALIGNMENT - 228 (((unsigned)skb->data) & (UCC_GETH_RX_DATA_BUF_ALIGNMENT -
228 1))); 229 1)));
229 230
230 skb->dev = ugeth->ndev;
231
232 out_be32(&((struct qe_bd __iomem *)bd)->buf, 231 out_be32(&((struct qe_bd __iomem *)bd)->buf,
233 dma_map_single(ugeth->dev, 232 dma_map_single(ugeth->dev,
234 skb->data, 233 skb->data,
diff --git a/drivers/net/ethernet/fujitsu/at1700.c b/drivers/net/ethernet/fujitsu/at1700.c
index 7c6c908bdf02..586b46fd4eed 100644
--- a/drivers/net/ethernet/fujitsu/at1700.c
+++ b/drivers/net/ethernet/fujitsu/at1700.c
@@ -757,7 +757,7 @@ net_rx(struct net_device *dev)
757 dev->stats.rx_errors++; 757 dev->stats.rx_errors++;
758 break; 758 break;
759 } 759 }
760 skb = dev_alloc_skb(pkt_len+3); 760 skb = netdev_alloc_skb(dev, pkt_len + 3);
761 if (skb == NULL) { 761 if (skb == NULL) {
762 printk("%s: Memory squeeze, dropping packet (len %d).\n", 762 printk("%s: Memory squeeze, dropping packet (len %d).\n",
763 dev->name, pkt_len); 763 dev->name, pkt_len);
diff --git a/drivers/net/ethernet/fujitsu/eth16i.c b/drivers/net/ethernet/fujitsu/eth16i.c
index b0e2313af3d1..c3f0178fb5cb 100644
--- a/drivers/net/ethernet/fujitsu/eth16i.c
+++ b/drivers/net/ethernet/fujitsu/eth16i.c
@@ -1164,7 +1164,7 @@ static void eth16i_rx(struct net_device *dev)
1164 else { /* Ok so now we should have a good packet */ 1164 else { /* Ok so now we should have a good packet */
1165 struct sk_buff *skb; 1165 struct sk_buff *skb;
1166 1166
1167 skb = dev_alloc_skb(pkt_len + 3); 1167 skb = netdev_alloc_skb(dev, pkt_len + 3);
1168 if( skb == NULL ) { 1168 if( skb == NULL ) {
1169 printk(KERN_WARNING "%s: Could'n allocate memory for packet (len %d)\n", 1169 printk(KERN_WARNING "%s: Could'n allocate memory for packet (len %d)\n",
1170 dev->name, pkt_len); 1170 dev->name, pkt_len);
diff --git a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
index ee84b472cee6..0230319ddb59 100644
--- a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
+++ b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
@@ -1002,7 +1002,7 @@ static void fjn_rx(struct net_device *dev)
1002 dev->stats.rx_errors++; 1002 dev->stats.rx_errors++;
1003 break; 1003 break;
1004 } 1004 }
1005 skb = dev_alloc_skb(pkt_len+2); 1005 skb = netdev_alloc_skb(dev, pkt_len + 2);
1006 if (skb == NULL) { 1006 if (skb == NULL) {
1007 netdev_notice(dev, "Memory squeeze, dropping packet (len %d)\n", 1007 netdev_notice(dev, "Memory squeeze, dropping packet (len %d)\n",
1008 pkt_len); 1008 pkt_len);
diff --git a/drivers/net/ethernet/hp/hp100.c b/drivers/net/ethernet/hp/hp100.c
index 6a5ee0776b28..d496673f0908 100644
--- a/drivers/net/ethernet/hp/hp100.c
+++ b/drivers/net/ethernet/hp/hp100.c
@@ -1274,7 +1274,7 @@ static int hp100_build_rx_pdl(hp100_ring_t * ringptr,
1274 /* Note: This depends on the alloc_skb functions allocating more 1274 /* Note: This depends on the alloc_skb functions allocating more
1275 * space than requested, i.e. aligning to 16bytes */ 1275 * space than requested, i.e. aligning to 16bytes */
1276 1276
1277 ringptr->skb = dev_alloc_skb(roundup(MAX_ETHER_SIZE + 2, 4)); 1277 ringptr->skb = netdev_alloc_skb(dev, roundup(MAX_ETHER_SIZE + 2, 4));
1278 1278
1279 if (NULL != ringptr->skb) { 1279 if (NULL != ringptr->skb) {
1280 /* 1280 /*
@@ -1284,7 +1284,6 @@ static int hp100_build_rx_pdl(hp100_ring_t * ringptr,
1284 */ 1284 */
1285 skb_reserve(ringptr->skb, 2); 1285 skb_reserve(ringptr->skb, 2);
1286 1286
1287 ringptr->skb->dev = dev;
1288 ringptr->skb->data = (u_char *) skb_put(ringptr->skb, MAX_ETHER_SIZE); 1287 ringptr->skb->data = (u_char *) skb_put(ringptr->skb, MAX_ETHER_SIZE);
1289 1288
1290 /* ringptr->pdl points to the beginning of the PDL, i.e. the PDH */ 1289 /* ringptr->pdl points to the beginning of the PDL, i.e. the PDH */
@@ -1817,7 +1816,7 @@ static void hp100_rx(struct net_device *dev)
1817#endif 1816#endif
1818 1817
1819 /* Now we allocate the skb and transfer the data into it. */ 1818 /* Now we allocate the skb and transfer the data into it. */
1820 skb = dev_alloc_skb(pkt_len+2); 1819 skb = netdev_alloc_skb(dev, pkt_len + 2);
1821 if (skb == NULL) { /* Not enough memory->drop packet */ 1820 if (skb == NULL) { /* Not enough memory->drop packet */
1822#ifdef HP100_DEBUG 1821#ifdef HP100_DEBUG
1823 printk("hp100: %s: rx: couldn't allocate a sk_buff of size %d\n", 1822 printk("hp100: %s: rx: couldn't allocate a sk_buff of size %d\n",
@@ -2992,7 +2991,6 @@ static int __init hp100_isa_init(void)
2992 for (i = 0; i < HP100_DEVICES && hp100_port[i] != -1; ++i) { 2991 for (i = 0; i < HP100_DEVICES && hp100_port[i] != -1; ++i) {
2993 dev = alloc_etherdev(sizeof(struct hp100_private)); 2992 dev = alloc_etherdev(sizeof(struct hp100_private));
2994 if (!dev) { 2993 if (!dev) {
2995 printk(KERN_WARNING "hp100: no memory for network device\n");
2996 while (cards > 0) 2994 while (cards > 0)
2997 cleanup_dev(hp100_devlist[--cards]); 2995 cleanup_dev(hp100_devlist[--cards]);
2998 2996
diff --git a/drivers/net/ethernet/i825xx/3c505.c b/drivers/net/ethernet/i825xx/3c505.c
index ba82a266051d..6a5c21b82c51 100644
--- a/drivers/net/ethernet/i825xx/3c505.c
+++ b/drivers/net/ethernet/i825xx/3c505.c
@@ -583,7 +583,7 @@ static void receive_packet(struct net_device *dev, int len)
583 unsigned long flags; 583 unsigned long flags;
584 584
585 rlen = (len + 1) & ~1; 585 rlen = (len + 1) & ~1;
586 skb = dev_alloc_skb(rlen + 2); 586 skb = netdev_alloc_skb(dev, rlen + 2);
587 587
588 if (!skb) { 588 if (!skb) {
589 pr_warning("%s: memory squeeze, dropping packet\n", dev->name); 589 pr_warning("%s: memory squeeze, dropping packet\n", dev->name);
diff --git a/drivers/net/ethernet/i825xx/3c507.c b/drivers/net/ethernet/i825xx/3c507.c
index 1e945551c144..ed6925f11479 100644
--- a/drivers/net/ethernet/i825xx/3c507.c
+++ b/drivers/net/ethernet/i825xx/3c507.c
@@ -851,7 +851,7 @@ static void el16_rx(struct net_device *dev)
851 struct sk_buff *skb; 851 struct sk_buff *skb;
852 852
853 pkt_len &= 0x3fff; 853 pkt_len &= 0x3fff;
854 skb = dev_alloc_skb(pkt_len+2); 854 skb = netdev_alloc_skb(dev, pkt_len + 2);
855 if (skb == NULL) { 855 if (skb == NULL) {
856 pr_err("%s: Memory squeeze, dropping packet.\n", 856 pr_err("%s: Memory squeeze, dropping packet.\n",
857 dev->name); 857 dev->name);
diff --git a/drivers/net/ethernet/i825xx/3c523.c b/drivers/net/ethernet/i825xx/3c523.c
index d70d3df4c985..8451ecd4c1ec 100644
--- a/drivers/net/ethernet/i825xx/3c523.c
+++ b/drivers/net/ethernet/i825xx/3c523.c
@@ -983,7 +983,7 @@ static void elmc_rcv_int(struct net_device *dev)
983 if ((totlen = rbd->status) & RBD_LAST) { /* the first and the last buffer? */ 983 if ((totlen = rbd->status) & RBD_LAST) { /* the first and the last buffer? */
984 totlen &= RBD_MASK; /* length of this frame */ 984 totlen &= RBD_MASK; /* length of this frame */
985 rbd->status = 0; 985 rbd->status = 0;
986 skb = (struct sk_buff *) dev_alloc_skb(totlen + 2); 986 skb = netdev_alloc_skb(dev, totlen + 2);
987 if (skb != NULL) { 987 if (skb != NULL) {
988 skb_reserve(skb, 2); /* 16 byte alignment */ 988 skb_reserve(skb, 2); /* 16 byte alignment */
989 skb_put(skb,totlen); 989 skb_put(skb,totlen);
diff --git a/drivers/net/ethernet/i825xx/3c527.c b/drivers/net/ethernet/i825xx/3c527.c
index 474b5e71a53a..ef43f3e951c5 100644
--- a/drivers/net/ethernet/i825xx/3c527.c
+++ b/drivers/net/ethernet/i825xx/3c527.c
@@ -1169,7 +1169,7 @@ static void mc32_rx_ring(struct net_device *dev)
1169 /* Try to save time by avoiding a copy on big frames */ 1169 /* Try to save time by avoiding a copy on big frames */
1170 1170
1171 if ((length > RX_COPYBREAK) && 1171 if ((length > RX_COPYBREAK) &&
1172 ((newskb=dev_alloc_skb(1532)) != NULL)) 1172 ((newskb = netdev_alloc_skb(dev, 1532)) != NULL))
1173 { 1173 {
1174 skb=lp->rx_ring[rx_ring_tail].skb; 1174 skb=lp->rx_ring[rx_ring_tail].skb;
1175 skb_put(skb, length); 1175 skb_put(skb, length);
@@ -1180,7 +1180,7 @@ static void mc32_rx_ring(struct net_device *dev)
1180 } 1180 }
1181 else 1181 else
1182 { 1182 {
1183 skb=dev_alloc_skb(length+2); 1183 skb = netdev_alloc_skb(dev, length + 2);
1184 1184
1185 if(skb==NULL) { 1185 if(skb==NULL) {
1186 dev->stats.rx_dropped++; 1186 dev->stats.rx_dropped++;
diff --git a/drivers/net/ethernet/i825xx/82596.c b/drivers/net/ethernet/i825xx/82596.c
index f2408a4d5d9c..6aa927af382c 100644
--- a/drivers/net/ethernet/i825xx/82596.c
+++ b/drivers/net/ethernet/i825xx/82596.c
@@ -549,14 +549,13 @@ static inline int init_rx_bufs(struct net_device *dev)
549 /* First build the Receive Buffer Descriptor List */ 549 /* First build the Receive Buffer Descriptor List */
550 550
551 for (i = 0, rbd = lp->rbds; i < rx_ring_size; i++, rbd++) { 551 for (i = 0, rbd = lp->rbds; i < rx_ring_size; i++, rbd++) {
552 struct sk_buff *skb = dev_alloc_skb(PKT_BUF_SZ); 552 struct sk_buff *skb = netdev_alloc_skb(dev, PKT_BUF_SZ);
553 553
554 if (skb == NULL) { 554 if (skb == NULL) {
555 remove_rx_bufs(dev); 555 remove_rx_bufs(dev);
556 return -ENOMEM; 556 return -ENOMEM;
557 } 557 }
558 558
559 skb->dev = dev;
560 rbd->v_next = rbd+1; 559 rbd->v_next = rbd+1;
561 rbd->b_next = WSWAPrbd(virt_to_bus(rbd+1)); 560 rbd->b_next = WSWAPrbd(virt_to_bus(rbd+1));
562 rbd->b_addr = WSWAPrbd(virt_to_bus(rbd)); 561 rbd->b_addr = WSWAPrbd(virt_to_bus(rbd));
@@ -810,7 +809,7 @@ static inline int i596_rx(struct net_device *dev)
810 struct sk_buff *newskb; 809 struct sk_buff *newskb;
811 810
812 /* Get fresh skbuff to replace filled one. */ 811 /* Get fresh skbuff to replace filled one. */
813 newskb = dev_alloc_skb(PKT_BUF_SZ); 812 newskb = netdev_alloc_skb(dev, PKT_BUF_SZ);
814 if (newskb == NULL) { 813 if (newskb == NULL) {
815 skb = NULL; /* drop pkt */ 814 skb = NULL; /* drop pkt */
816 goto memory_squeeze; 815 goto memory_squeeze;
@@ -819,7 +818,6 @@ static inline int i596_rx(struct net_device *dev)
819 skb_put(skb, pkt_len); 818 skb_put(skb, pkt_len);
820 rx_in_place = 1; 819 rx_in_place = 1;
821 rbd->skb = newskb; 820 rbd->skb = newskb;
822 newskb->dev = dev;
823 rbd->v_data = newskb->data; 821 rbd->v_data = newskb->data;
824 rbd->b_data = WSWAPchar(virt_to_bus(newskb->data)); 822 rbd->b_data = WSWAPchar(virt_to_bus(newskb->data));
825#ifdef __mc68000__ 823#ifdef __mc68000__
@@ -827,7 +825,7 @@ static inline int i596_rx(struct net_device *dev)
827#endif 825#endif
828 } 826 }
829 else 827 else
830 skb = dev_alloc_skb(pkt_len + 2); 828 skb = netdev_alloc_skb(dev, pkt_len + 2);
831memory_squeeze: 829memory_squeeze:
832 if (skb == NULL) { 830 if (skb == NULL) {
833 /* XXX tulip.c can defer packets here!! */ 831 /* XXX tulip.c can defer packets here!! */
diff --git a/drivers/net/ethernet/i825xx/eepro.c b/drivers/net/ethernet/i825xx/eepro.c
index 114cda7721fe..7a4ad4a07917 100644
--- a/drivers/net/ethernet/i825xx/eepro.c
+++ b/drivers/net/ethernet/i825xx/eepro.c
@@ -1563,7 +1563,7 @@ eepro_rx(struct net_device *dev)
1563 1563
1564 dev->stats.rx_bytes+=rcv_size; 1564 dev->stats.rx_bytes+=rcv_size;
1565 rcv_size &= 0x3fff; 1565 rcv_size &= 0x3fff;
1566 skb = dev_alloc_skb(rcv_size+5); 1566 skb = netdev_alloc_skb(dev, rcv_size + 5);
1567 if (skb == NULL) { 1567 if (skb == NULL) {
1568 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name); 1568 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
1569 dev->stats.rx_dropped++; 1569 dev->stats.rx_dropped++;
diff --git a/drivers/net/ethernet/i825xx/eexpress.c b/drivers/net/ethernet/i825xx/eexpress.c
index 3a9580f3d4dd..3fc649e54a32 100644
--- a/drivers/net/ethernet/i825xx/eexpress.c
+++ b/drivers/net/ethernet/i825xx/eexpress.c
@@ -955,7 +955,7 @@ static void eexp_hw_rx_pio(struct net_device *dev)
955 { 955 {
956 struct sk_buff *skb; 956 struct sk_buff *skb;
957 pkt_len &= 0x3fff; 957 pkt_len &= 0x3fff;
958 skb = dev_alloc_skb(pkt_len+16); 958 skb = netdev_alloc_skb(dev, pkt_len + 16);
959 if (skb == NULL) 959 if (skb == NULL)
960 { 960 {
961 printk(KERN_WARNING "%s: Memory squeeze, dropping packet\n",dev->name); 961 printk(KERN_WARNING "%s: Memory squeeze, dropping packet\n",dev->name);
diff --git a/drivers/net/ethernet/i825xx/ether1.c b/drivers/net/ethernet/i825xx/ether1.c
index 42e90a97c7a5..406a12b46404 100644
--- a/drivers/net/ethernet/i825xx/ether1.c
+++ b/drivers/net/ethernet/i825xx/ether1.c
@@ -867,7 +867,7 @@ ether1_recv_done (struct net_device *dev)
867 struct sk_buff *skb; 867 struct sk_buff *skb;
868 868
869 length = (length + 1) & ~1; 869 length = (length + 1) & ~1;
870 skb = dev_alloc_skb (length + 2); 870 skb = netdev_alloc_skb(dev, length + 2);
871 871
872 if (skb) { 872 if (skb) {
873 skb_reserve (skb, 2); 873 skb_reserve (skb, 2);
diff --git a/drivers/net/ethernet/i825xx/lp486e.c b/drivers/net/ethernet/i825xx/lp486e.c
index 414044b3cb11..6c2952c8ea15 100644
--- a/drivers/net/ethernet/i825xx/lp486e.c
+++ b/drivers/net/ethernet/i825xx/lp486e.c
@@ -454,8 +454,6 @@ init_rx_bufs(struct net_device *dev, int num) {
454 } 454 }
455 455
456 rfd->rbd = rbd; 456 rfd->rbd = rbd;
457 } else {
458 printk("Could not kmalloc rbd\n");
459 } 457 }
460 } 458 }
461 lp->rbd_tail->next = rfd->rbd; 459 lp->rbd_tail->next = rfd->rbd;
@@ -658,7 +656,7 @@ i596_rx_one(struct net_device *dev, struct i596_private *lp,
658 if (rfd->stat & RFD_STAT_OK) { 656 if (rfd->stat & RFD_STAT_OK) {
659 /* a good frame */ 657 /* a good frame */
660 int pkt_len = (rfd->count & 0x3fff); 658 int pkt_len = (rfd->count & 0x3fff);
661 struct sk_buff *skb = dev_alloc_skb(pkt_len); 659 struct sk_buff *skb = netdev_alloc_skb(dev, pkt_len);
662 660
663 (*frames)++; 661 (*frames)++;
664 662
diff --git a/drivers/net/ethernet/i825xx/ni52.c b/drivers/net/ethernet/i825xx/ni52.c
index c0893715ef47..272976e1bb0f 100644
--- a/drivers/net/ethernet/i825xx/ni52.c
+++ b/drivers/net/ethernet/i825xx/ni52.c
@@ -964,7 +964,7 @@ static void ni52_rcv_int(struct net_device *dev)
964 /* the first and the last buffer? */ 964 /* the first and the last buffer? */
965 totlen &= RBD_MASK; /* length of this frame */ 965 totlen &= RBD_MASK; /* length of this frame */
966 writew(0x00, &rbd->status); 966 writew(0x00, &rbd->status);
967 skb = (struct sk_buff *)dev_alloc_skb(totlen+2); 967 skb = netdev_alloc_skb(dev, totlen + 2);
968 if (skb != NULL) { 968 if (skb != NULL) {
969 skb_reserve(skb, 2); 969 skb_reserve(skb, 2);
970 skb_put(skb, totlen); 970 skb_put(skb, totlen);
diff --git a/drivers/net/ethernet/i825xx/sun3_82586.c b/drivers/net/ethernet/i825xx/sun3_82586.c
index 6ef5e11d1c84..cae17f4bc93e 100644
--- a/drivers/net/ethernet/i825xx/sun3_82586.c
+++ b/drivers/net/ethernet/i825xx/sun3_82586.c
@@ -28,7 +28,6 @@ static int automatic_resume = 0; /* experimental .. better should be zero */
28static int rfdadd = 0; /* rfdadd=1 may be better for 8K MEM cards */ 28static int rfdadd = 0; /* rfdadd=1 may be better for 8K MEM cards */
29static int fifo=0x8; /* don't change */ 29static int fifo=0x8; /* don't change */
30 30
31#include <linux/module.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
33#include <linux/string.h> 32#include <linux/string.h>
34#include <linux/errno.h> 33#include <linux/errno.h>
@@ -779,7 +778,7 @@ static void sun3_82586_rcv_int(struct net_device *dev)
779 { 778 {
780 totlen &= RBD_MASK; /* length of this frame */ 779 totlen &= RBD_MASK; /* length of this frame */
781 rbd->status = 0; 780 rbd->status = 0;
782 skb = (struct sk_buff *) dev_alloc_skb(totlen+2); 781 skb = netdev_alloc_skb(dev, totlen + 2);
783 if(skb != NULL) 782 if(skb != NULL)
784 { 783 {
785 skb_reserve(skb,2); 784 skb_reserve(skb,2);
@@ -1151,28 +1150,6 @@ static void set_multicast_list(struct net_device *dev)
1151 netif_wake_queue(dev); 1150 netif_wake_queue(dev);
1152} 1151}
1153 1152
1154#ifdef MODULE
1155#error This code is not currently supported as a module
1156static struct net_device *dev_sun3_82586;
1157
1158int init_module(void)
1159{
1160 dev_sun3_82586 = sun3_82586_probe(-1);
1161 if (IS_ERR(dev_sun3_82586))
1162 return PTR_ERR(dev_sun3_82586);
1163 return 0;
1164}
1165
1166void cleanup_module(void)
1167{
1168 unsigned long ioaddr = dev_sun3_82586->base_addr;
1169 unregister_netdev(dev_sun3_82586);
1170 release_region(ioaddr, SUN3_82586_TOTAL_SIZE);
1171 iounmap((void *)ioaddr);
1172 free_netdev(dev_sun3_82586);
1173}
1174#endif /* MODULE */
1175
1176#if 0 1153#if 0
1177/* 1154/*
1178 * DUMP .. we expect a not running CMD unit and enough space 1155 * DUMP .. we expect a not running CMD unit and enough space
@@ -1209,5 +1186,3 @@ void sun3_82586_dump(struct net_device *dev,void *ptr)
1209 printk("\n"); 1186 printk("\n");
1210} 1187}
1211#endif 1188#endif
1212
1213MODULE_LICENSE("GPL");
diff --git a/drivers/net/ethernet/i825xx/znet.c b/drivers/net/ethernet/i825xx/znet.c
index 962b4c421f3f..a43649735a04 100644
--- a/drivers/net/ethernet/i825xx/znet.c
+++ b/drivers/net/ethernet/i825xx/znet.c
@@ -762,7 +762,7 @@ static void znet_rx(struct net_device *dev)
762 /* Malloc up new buffer. */ 762 /* Malloc up new buffer. */
763 struct sk_buff *skb; 763 struct sk_buff *skb;
764 764
765 skb = dev_alloc_skb(pkt_len); 765 skb = netdev_alloc_skb(dev, pkt_len);
766 if (skb == NULL) { 766 if (skb == NULL) {
767 if (znet_debug) 767 if (znet_debug)
768 printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name); 768 printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name);
diff --git a/drivers/net/ethernet/ibm/ehea/ehea.h b/drivers/net/ethernet/ibm/ehea/ehea.h
index 6650068c996c..b8e46cc31e53 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea.h
+++ b/drivers/net/ethernet/ibm/ehea/ehea.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/net/ehea/ehea.h 2 * linux/drivers/net/ethernet/ibm/ehea/ehea.h
3 * 3 *
4 * eHEA ethernet device driver for IBM eServer System p 4 * eHEA ethernet device driver for IBM eServer System p
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_ethtool.c b/drivers/net/ethernet/ibm/ehea/ehea_ethtool.c
index 6bdd8e36e564..95837b99a464 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_ethtool.c
+++ b/drivers/net/ethernet/ibm/ehea/ehea_ethtool.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/net/ehea/ehea_ethtool.c 2 * linux/drivers/net/ethernet/ibm/ehea/ehea_ethtool.c
3 * 3 *
4 * eHEA ethernet device driver for IBM eServer System p 4 * eHEA ethernet device driver for IBM eServer System p
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_hw.h b/drivers/net/ethernet/ibm/ehea/ehea_hw.h
index 1a2fe4dc3eb3..180d4128a711 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_hw.h
+++ b/drivers/net/ethernet/ibm/ehea/ehea_hw.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/net/ehea/ehea_hw.h 2 * linux/drivers/net/ethernet/ibm/ehea/ehea_hw.h
3 * 3 *
4 * eHEA ethernet device driver for IBM eServer System p 4 * eHEA ethernet device driver for IBM eServer System p
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c
index 5d5fb2627184..8b73dd472475 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_main.c
+++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/net/ehea/ehea_main.c 2 * linux/drivers/net/ethernet/ibm/ehea/ehea_main.c
3 * 3 *
4 * eHEA ethernet device driver for IBM eServer System p 4 * eHEA ethernet device driver for IBM eServer System p
5 * 5 *
@@ -2980,7 +2980,6 @@ static struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter,
2980 dev = alloc_etherdev_mq(sizeof(struct ehea_port), EHEA_MAX_PORT_RES); 2980 dev = alloc_etherdev_mq(sizeof(struct ehea_port), EHEA_MAX_PORT_RES);
2981 2981
2982 if (!dev) { 2982 if (!dev) {
2983 pr_err("no mem for net_device\n");
2984 ret = -ENOMEM; 2983 ret = -ENOMEM;
2985 goto out_err; 2984 goto out_err;
2986 } 2985 }
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_phyp.c b/drivers/net/ethernet/ibm/ehea/ehea_phyp.c
index 0506967b9044..30f903332e92 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_phyp.c
+++ b/drivers/net/ethernet/ibm/ehea/ehea_phyp.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/net/ehea/ehea_phyp.c 2 * linux/drivers/net/ethernet/ibm/ehea/ehea_phyp.c
3 * 3 *
4 * eHEA ethernet device driver for IBM eServer System p 4 * eHEA ethernet device driver for IBM eServer System p
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_phyp.h b/drivers/net/ethernet/ibm/ehea/ehea_phyp.h
index 2f8174c248bc..52c456ec4d6c 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_phyp.h
+++ b/drivers/net/ethernet/ibm/ehea/ehea_phyp.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/net/ehea/ehea_phyp.h 2 * linux/drivers/net/ethernet/ibm/ehea/ehea_phyp.h
3 * 3 *
4 * eHEA ethernet device driver for IBM eServer System p 4 * eHEA ethernet device driver for IBM eServer System p
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_qmr.c b/drivers/net/ethernet/ibm/ehea/ehea_qmr.c
index c25b05b94daa..4fb47f14dbfe 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_qmr.c
+++ b/drivers/net/ethernet/ibm/ehea/ehea_qmr.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/net/ehea/ehea_qmr.c 2 * linux/drivers/net/ethernet/ibm/ehea/ehea_qmr.c
3 * 3 *
4 * eHEA ethernet device driver for IBM eServer System p 4 * eHEA ethernet device driver for IBM eServer System p
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_qmr.h b/drivers/net/ethernet/ibm/ehea/ehea_qmr.h
index 337a47ecf4aa..8e4a70c20ab7 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_qmr.h
+++ b/drivers/net/ethernet/ibm/ehea/ehea_qmr.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/net/ehea/ehea_qmr.h 2 * linux/drivers/net/ethernet/ibm/ehea/ehea_qmr.h
3 * 3 *
4 * eHEA ethernet device driver for IBM eServer System p 4 * eHEA ethernet device driver for IBM eServer System p
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index 2abce965c7bd..dac7ffb4eaf1 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/core.c 2 * drivers/net/ethernet/ibm/emac/core.c
3 * 3 *
4 * Driver for PowerPC 4xx on-chip ethernet controller. 4 * Driver for PowerPC 4xx on-chip ethernet controller.
5 * 5 *
@@ -2706,11 +2706,9 @@ static int __devinit emac_probe(struct platform_device *ofdev)
2706 /* Allocate our net_device structure */ 2706 /* Allocate our net_device structure */
2707 err = -ENOMEM; 2707 err = -ENOMEM;
2708 ndev = alloc_etherdev(sizeof(struct emac_instance)); 2708 ndev = alloc_etherdev(sizeof(struct emac_instance));
2709 if (!ndev) { 2709 if (!ndev)
2710 printk(KERN_ERR "%s: could not allocate ethernet device!\n",
2711 np->full_name);
2712 goto err_gone; 2710 goto err_gone;
2713 } 2711
2714 dev = netdev_priv(ndev); 2712 dev = netdev_priv(ndev);
2715 dev->ndev = ndev; 2713 dev->ndev = ndev;
2716 dev->ofdev = ofdev; 2714 dev->ofdev = ofdev;
diff --git a/drivers/net/ethernet/ibm/emac/core.h b/drivers/net/ethernet/ibm/emac/core.h
index fa3ec57935fa..bade29690c71 100644
--- a/drivers/net/ethernet/ibm/emac/core.h
+++ b/drivers/net/ethernet/ibm/emac/core.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/core.h 2 * drivers/net/ethernet/ibm/emac/core.h
3 * 3 *
4 * Driver for PowerPC 4xx on-chip ethernet controller. 4 * Driver for PowerPC 4xx on-chip ethernet controller.
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/emac/debug.c b/drivers/net/ethernet/ibm/emac/debug.c
index 8c6c1e2a8750..b16b4828b64d 100644
--- a/drivers/net/ethernet/ibm/emac/debug.c
+++ b/drivers/net/ethernet/ibm/emac/debug.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/debug.c 2 * drivers/net/ethernet/ibm/emac/debug.c
3 * 3 *
4 * Driver for PowerPC 4xx on-chip ethernet controller, debug print routines. 4 * Driver for PowerPC 4xx on-chip ethernet controller, debug print routines.
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/emac/debug.h b/drivers/net/ethernet/ibm/emac/debug.h
index 90477fe69d0c..59a92d5870b5 100644
--- a/drivers/net/ethernet/ibm/emac/debug.h
+++ b/drivers/net/ethernet/ibm/emac/debug.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/debug.h 2 * drivers/net/ethernet/ibm/emac/debug.h
3 * 3 *
4 * Driver for PowerPC 4xx on-chip ethernet controller, debug print routines. 4 * Driver for PowerPC 4xx on-chip ethernet controller, debug print routines.
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/emac/emac.h b/drivers/net/ethernet/ibm/emac/emac.h
index 1568278d759a..b44bd243fb58 100644
--- a/drivers/net/ethernet/ibm/emac/emac.h
+++ b/drivers/net/ethernet/ibm/emac/emac.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/emac.h 2 * drivers/net/ethernet/ibm/emac/emac.h
3 * 3 *
4 * Register definitions for PowerPC 4xx on-chip ethernet contoller 4 * Register definitions for PowerPC 4xx on-chip ethernet contoller
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/emac/mal.c b/drivers/net/ethernet/ibm/emac/mal.c
index f3c50b97ec61..479e43e2f1ef 100644
--- a/drivers/net/ethernet/ibm/emac/mal.c
+++ b/drivers/net/ethernet/ibm/emac/mal.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/mal.c 2 * drivers/net/ethernet/ibm/emac/mal.c
3 * 3 *
4 * Memory Access Layer (MAL) support 4 * Memory Access Layer (MAL) support
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/emac/mal.h b/drivers/net/ethernet/ibm/emac/mal.h
index d06f985bda32..e431a32e3d69 100644
--- a/drivers/net/ethernet/ibm/emac/mal.h
+++ b/drivers/net/ethernet/ibm/emac/mal.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/mal.h 2 * drivers/net/ethernet/ibm/emac/mal.h
3 * 3 *
4 * Memory Access Layer (MAL) support 4 * Memory Access Layer (MAL) support
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/emac/phy.c b/drivers/net/ethernet/ibm/emac/phy.c
index ab4e5969fe65..d3b9d103353e 100644
--- a/drivers/net/ethernet/ibm/emac/phy.c
+++ b/drivers/net/ethernet/ibm/emac/phy.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/phy.c 2 * drivers/net/ethernet/ibm/emac/phy.c
3 * 3 *
4 * Driver for PowerPC 4xx on-chip ethernet controller, PHY support. 4 * Driver for PowerPC 4xx on-chip ethernet controller, PHY support.
5 * Borrowed from sungem_phy.c, though I only kept the generic MII 5 * Borrowed from sungem_phy.c, though I only kept the generic MII
diff --git a/drivers/net/ethernet/ibm/emac/phy.h b/drivers/net/ethernet/ibm/emac/phy.h
index 5d2bf4cbe50b..d7e41ec37467 100644
--- a/drivers/net/ethernet/ibm/emac/phy.h
+++ b/drivers/net/ethernet/ibm/emac/phy.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/phy.h 2 * drivers/net/ethernet/ibm/emac/phy.h
3 * 3 *
4 * Driver for PowerPC 4xx on-chip ethernet controller, PHY support 4 * Driver for PowerPC 4xx on-chip ethernet controller, PHY support
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/emac/rgmii.c b/drivers/net/ethernet/ibm/emac/rgmii.c
index 4fa53f3def64..d3123282e18e 100644
--- a/drivers/net/ethernet/ibm/emac/rgmii.c
+++ b/drivers/net/ethernet/ibm/emac/rgmii.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/rgmii.c 2 * drivers/net/ethernet/ibm/emac/rgmii.c
3 * 3 *
4 * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support. 4 * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support.
5 * 5 *
@@ -237,11 +237,8 @@ static int __devinit rgmii_probe(struct platform_device *ofdev)
237 237
238 rc = -ENOMEM; 238 rc = -ENOMEM;
239 dev = kzalloc(sizeof(struct rgmii_instance), GFP_KERNEL); 239 dev = kzalloc(sizeof(struct rgmii_instance), GFP_KERNEL);
240 if (dev == NULL) { 240 if (dev == NULL)
241 printk(KERN_ERR "%s: could not allocate RGMII device!\n",
242 np->full_name);
243 goto err_gone; 241 goto err_gone;
244 }
245 242
246 mutex_init(&dev->lock); 243 mutex_init(&dev->lock);
247 dev->ofdev = ofdev; 244 dev->ofdev = ofdev;
diff --git a/drivers/net/ethernet/ibm/emac/rgmii.h b/drivers/net/ethernet/ibm/emac/rgmii.h
index 9296b6c5f920..668bceeff4a2 100644
--- a/drivers/net/ethernet/ibm/emac/rgmii.h
+++ b/drivers/net/ethernet/ibm/emac/rgmii.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/rgmii.h 2 * drivers/net/ethernet/ibm/emac/rgmii.h
3 * 3 *
4 * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support. 4 * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support.
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/emac/tah.c b/drivers/net/ethernet/ibm/emac/tah.c
index 5f51bf7c9dc5..872912ef518d 100644
--- a/drivers/net/ethernet/ibm/emac/tah.c
+++ b/drivers/net/ethernet/ibm/emac/tah.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/tah.c 2 * drivers/net/ethernet/ibm/emac/tah.c
3 * 3 *
4 * Driver for PowerPC 4xx on-chip ethernet controller, TAH support. 4 * Driver for PowerPC 4xx on-chip ethernet controller, TAH support.
5 * 5 *
@@ -96,11 +96,8 @@ static int __devinit tah_probe(struct platform_device *ofdev)
96 96
97 rc = -ENOMEM; 97 rc = -ENOMEM;
98 dev = kzalloc(sizeof(struct tah_instance), GFP_KERNEL); 98 dev = kzalloc(sizeof(struct tah_instance), GFP_KERNEL);
99 if (dev == NULL) { 99 if (dev == NULL)
100 printk(KERN_ERR "%s: could not allocate TAH device!\n",
101 np->full_name);
102 goto err_gone; 100 goto err_gone;
103 }
104 101
105 mutex_init(&dev->lock); 102 mutex_init(&dev->lock);
106 dev->ofdev = ofdev; 103 dev->ofdev = ofdev;
diff --git a/drivers/net/ethernet/ibm/emac/tah.h b/drivers/net/ethernet/ibm/emac/tah.h
index 3437ab4964c7..350b7096a041 100644
--- a/drivers/net/ethernet/ibm/emac/tah.h
+++ b/drivers/net/ethernet/ibm/emac/tah.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/tah.h 2 * drivers/net/ethernet/ibm/emac/tah.h
3 * 3 *
4 * Driver for PowerPC 4xx on-chip ethernet controller, TAH support. 4 * Driver for PowerPC 4xx on-chip ethernet controller, TAH support.
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/emac/zmii.c b/drivers/net/ethernet/ibm/emac/zmii.c
index 97449e786d61..415e9b4d5408 100644
--- a/drivers/net/ethernet/ibm/emac/zmii.c
+++ b/drivers/net/ethernet/ibm/emac/zmii.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/zmii.c 2 * drivers/net/ethernet/ibm/emac/zmii.c
3 * 3 *
4 * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support. 4 * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support.
5 * 5 *
@@ -240,11 +240,8 @@ static int __devinit zmii_probe(struct platform_device *ofdev)
240 240
241 rc = -ENOMEM; 241 rc = -ENOMEM;
242 dev = kzalloc(sizeof(struct zmii_instance), GFP_KERNEL); 242 dev = kzalloc(sizeof(struct zmii_instance), GFP_KERNEL);
243 if (dev == NULL) { 243 if (dev == NULL)
244 printk(KERN_ERR "%s: could not allocate ZMII device!\n",
245 np->full_name);
246 goto err_gone; 244 goto err_gone;
247 }
248 245
249 mutex_init(&dev->lock); 246 mutex_init(&dev->lock);
250 dev->ofdev = ofdev; 247 dev->ofdev = ofdev;
diff --git a/drivers/net/ethernet/ibm/emac/zmii.h b/drivers/net/ethernet/ibm/emac/zmii.h
index ceaed823a83c..455bfb085493 100644
--- a/drivers/net/ethernet/ibm/emac/zmii.h
+++ b/drivers/net/ethernet/ibm/emac/zmii.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/ibm_newemac/zmii.h 2 * drivers/net/ethernet/ibm/emac/zmii.h
3 * 3 *
4 * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support. 4 * Driver for PowerPC 4xx on-chip ethernet controller, ZMII bridge support.
5 * 5 *
diff --git a/drivers/net/ethernet/ibm/iseries_veth.c b/drivers/net/ethernet/ibm/iseries_veth.c
index acc31af6594a..1cafa6562a06 100644
--- a/drivers/net/ethernet/ibm/iseries_veth.c
+++ b/drivers/net/ethernet/ibm/iseries_veth.c
@@ -1032,10 +1032,8 @@ static struct net_device *veth_probe_one(int vlan,
1032 } 1032 }
1033 1033
1034 dev = alloc_etherdev(sizeof (struct veth_port)); 1034 dev = alloc_etherdev(sizeof (struct veth_port));
1035 if (! dev) { 1035 if (!dev)
1036 veth_error("Unable to allocate net_device structure!\n");
1037 return NULL; 1036 return NULL;
1038 }
1039 1037
1040 port = netdev_priv(dev); 1038 port = netdev_priv(dev);
1041 1039
diff --git a/drivers/net/ethernet/icplus/ipg.c b/drivers/net/ethernet/icplus/ipg.c
index 075451d0207d..1b563bb959c2 100644
--- a/drivers/net/ethernet/icplus/ipg.c
+++ b/drivers/net/ethernet/icplus/ipg.c
@@ -744,9 +744,6 @@ static int ipg_get_rxbuff(struct net_device *dev, int entry)
744 return -ENOMEM; 744 return -ENOMEM;
745 } 745 }
746 746
747 /* Associate the receive buffer with the IPG NIC. */
748 skb->dev = dev;
749
750 /* Save the address of the sk_buff structure. */ 747 /* Save the address of the sk_buff structure. */
751 sp->rx_buff[entry] = skb; 748 sp->rx_buff[entry] = skb;
752 749
@@ -2233,7 +2230,6 @@ static int __devinit ipg_probe(struct pci_dev *pdev,
2233 */ 2230 */
2234 dev = alloc_etherdev(sizeof(struct ipg_nic_private)); 2231 dev = alloc_etherdev(sizeof(struct ipg_nic_private));
2235 if (!dev) { 2232 if (!dev) {
2236 pr_err("%s: alloc_etherdev failed\n", pci_name(pdev));
2237 rc = -ENOMEM; 2233 rc = -ENOMEM;
2238 goto err_disable_0; 2234 goto err_disable_0;
2239 } 2235 }
diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index 9436397e5725..485ab8cdac48 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -2751,11 +2751,8 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2751 struct nic *nic; 2751 struct nic *nic;
2752 int err; 2752 int err;
2753 2753
2754 if (!(netdev = alloc_etherdev(sizeof(struct nic)))) { 2754 if (!(netdev = alloc_etherdev(sizeof(struct nic))))
2755 if (((1 << debug) - 1) & NETIF_MSG_PROBE)
2756 pr_err("Etherdev alloc failed, aborting\n");
2757 return -ENOMEM; 2755 return -ENOMEM;
2758 }
2759 2756
2760 netdev->netdev_ops = &e100_netdev_ops; 2757 netdev->netdev_ops = &e100_netdev_ops;
2761 SET_ETHTOOL_OPS(netdev, &e100_ethtool_ops); 2758 SET_ETHTOOL_OPS(netdev, &e100_ethtool_ops);
diff --git a/drivers/net/ethernet/intel/e1000/e1000.h b/drivers/net/ethernet/intel/e1000/e1000.h
index 1e1596990b5c..2b6cd02bfba0 100644
--- a/drivers/net/ethernet/intel/e1000/e1000.h
+++ b/drivers/net/ethernet/intel/e1000/e1000.h
@@ -254,6 +254,7 @@ struct e1000_adapter {
254 atomic_t tx_fifo_stall; 254 atomic_t tx_fifo_stall;
255 bool pcix_82544; 255 bool pcix_82544;
256 bool detect_tx_hung; 256 bool detect_tx_hung;
257 bool dump_buffers;
257 258
258 /* RX */ 259 /* RX */
259 bool (*clean_rx)(struct e1000_adapter *adapter, 260 bool (*clean_rx)(struct e1000_adapter *adapter,
diff --git a/drivers/net/ethernet/intel/e1000/e1000_hw.h b/drivers/net/ethernet/intel/e1000/e1000_hw.h
index f6c4d7e2560c..11578c8978db 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_hw.h
+++ b/drivers/net/ethernet/intel/e1000/e1000_hw.h
@@ -895,6 +895,11 @@ struct e1000_ffvt_entry {
895#define E1000_FCRTL 0x02160 /* Flow Control Receive Threshold Low - RW */ 895#define E1000_FCRTL 0x02160 /* Flow Control Receive Threshold Low - RW */
896#define E1000_FCRTH 0x02168 /* Flow Control Receive Threshold High - RW */ 896#define E1000_FCRTH 0x02168 /* Flow Control Receive Threshold High - RW */
897#define E1000_PSRCTL 0x02170 /* Packet Split Receive Control - RW */ 897#define E1000_PSRCTL 0x02170 /* Packet Split Receive Control - RW */
898#define E1000_RDFH 0x02410 /* RX Data FIFO Head - RW */
899#define E1000_RDFT 0x02418 /* RX Data FIFO Tail - RW */
900#define E1000_RDFHS 0x02420 /* RX Data FIFO Head Saved - RW */
901#define E1000_RDFTS 0x02428 /* RX Data FIFO Tail Saved - RW */
902#define E1000_RDFPC 0x02430 /* RX Data FIFO Packet Count - RW */
898#define E1000_RDBAL 0x02800 /* RX Descriptor Base Address Low - RW */ 903#define E1000_RDBAL 0x02800 /* RX Descriptor Base Address Low - RW */
899#define E1000_RDBAH 0x02804 /* RX Descriptor Base Address High - RW */ 904#define E1000_RDBAH 0x02804 /* RX Descriptor Base Address High - RW */
900#define E1000_RDLEN 0x02808 /* RX Descriptor Length - RW */ 905#define E1000_RDLEN 0x02808 /* RX Descriptor Length - RW */
@@ -1074,6 +1079,11 @@ struct e1000_ffvt_entry {
1074#define E1000_82542_IMC E1000_IMC 1079#define E1000_82542_IMC E1000_IMC
1075#define E1000_82542_RCTL E1000_RCTL 1080#define E1000_82542_RCTL E1000_RCTL
1076#define E1000_82542_RDTR 0x00108 1081#define E1000_82542_RDTR 0x00108
1082#define E1000_82542_RDFH E1000_RDFH
1083#define E1000_82542_RDFT E1000_RDFT
1084#define E1000_82542_RDFHS E1000_RDFHS
1085#define E1000_82542_RDFTS E1000_RDFTS
1086#define E1000_82542_RDFPC E1000_RDFPC
1077#define E1000_82542_RDBAL 0x00110 1087#define E1000_82542_RDBAL 0x00110
1078#define E1000_82542_RDBAH 0x00114 1088#define E1000_82542_RDBAH 0x00114
1079#define E1000_82542_RDLEN 0x00118 1089#define E1000_82542_RDLEN 0x00118
diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
index d94d64b5d695..e72dc8175955 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -730,10 +730,8 @@ static void e1000_dump_eeprom(struct e1000_adapter *adapter)
730 eeprom.offset = 0; 730 eeprom.offset = 0;
731 731
732 data = kmalloc(eeprom.len, GFP_KERNEL); 732 data = kmalloc(eeprom.len, GFP_KERNEL);
733 if (!data) { 733 if (!data)
734 pr_err("Unable to allocate memory to dump EEPROM data\n");
735 return; 734 return;
736 }
737 735
738 ops->get_eeprom(netdev, &eeprom, data); 736 ops->get_eeprom(netdev, &eeprom, data);
739 737
@@ -3241,6 +3239,228 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
3241 return NETDEV_TX_OK; 3239 return NETDEV_TX_OK;
3242} 3240}
3243 3241
3242#define NUM_REGS 38 /* 1 based count */
3243static void e1000_regdump(struct e1000_adapter *adapter)
3244{
3245 struct e1000_hw *hw = &adapter->hw;
3246 u32 regs[NUM_REGS];
3247 u32 *regs_buff = regs;
3248 int i = 0;
3249
3250 char *reg_name[] = {
3251 "CTRL", "STATUS",
3252 "RCTL", "RDLEN", "RDH", "RDT", "RDTR",
3253 "TCTL", "TDBAL", "TDBAH", "TDLEN", "TDH", "TDT",
3254 "TIDV", "TXDCTL", "TADV", "TARC0",
3255 "TDBAL1", "TDBAH1", "TDLEN1", "TDH1", "TDT1",
3256 "TXDCTL1", "TARC1",
3257 "CTRL_EXT", "ERT", "RDBAL", "RDBAH",
3258 "TDFH", "TDFT", "TDFHS", "TDFTS", "TDFPC",
3259 "RDFH", "RDFT", "RDFHS", "RDFTS", "RDFPC"
3260 };
3261
3262 regs_buff[0] = er32(CTRL);
3263 regs_buff[1] = er32(STATUS);
3264
3265 regs_buff[2] = er32(RCTL);
3266 regs_buff[3] = er32(RDLEN);
3267 regs_buff[4] = er32(RDH);
3268 regs_buff[5] = er32(RDT);
3269 regs_buff[6] = er32(RDTR);
3270
3271 regs_buff[7] = er32(TCTL);
3272 regs_buff[8] = er32(TDBAL);
3273 regs_buff[9] = er32(TDBAH);
3274 regs_buff[10] = er32(TDLEN);
3275 regs_buff[11] = er32(TDH);
3276 regs_buff[12] = er32(TDT);
3277 regs_buff[13] = er32(TIDV);
3278 regs_buff[14] = er32(TXDCTL);
3279 regs_buff[15] = er32(TADV);
3280 regs_buff[16] = er32(TARC0);
3281
3282 regs_buff[17] = er32(TDBAL1);
3283 regs_buff[18] = er32(TDBAH1);
3284 regs_buff[19] = er32(TDLEN1);
3285 regs_buff[20] = er32(TDH1);
3286 regs_buff[21] = er32(TDT1);
3287 regs_buff[22] = er32(TXDCTL1);
3288 regs_buff[23] = er32(TARC1);
3289 regs_buff[24] = er32(CTRL_EXT);
3290 regs_buff[25] = er32(ERT);
3291 regs_buff[26] = er32(RDBAL0);
3292 regs_buff[27] = er32(RDBAH0);
3293 regs_buff[28] = er32(TDFH);
3294 regs_buff[29] = er32(TDFT);
3295 regs_buff[30] = er32(TDFHS);
3296 regs_buff[31] = er32(TDFTS);
3297 regs_buff[32] = er32(TDFPC);
3298 regs_buff[33] = er32(RDFH);
3299 regs_buff[34] = er32(RDFT);
3300 regs_buff[35] = er32(RDFHS);
3301 regs_buff[36] = er32(RDFTS);
3302 regs_buff[37] = er32(RDFPC);
3303
3304 pr_info("Register dump\n");
3305 for (i = 0; i < NUM_REGS; i++) {
3306 printk(KERN_INFO "%-15s %08x\n",
3307 reg_name[i], regs_buff[i]);
3308 }
3309}
3310
3311/*
3312 * e1000_dump: Print registers, tx ring and rx ring
3313 */
3314static void e1000_dump(struct e1000_adapter *adapter)
3315{
3316 /* this code doesn't handle multiple rings */
3317 struct e1000_tx_ring *tx_ring = adapter->tx_ring;
3318 struct e1000_rx_ring *rx_ring = adapter->rx_ring;
3319 int i;
3320
3321 if (!netif_msg_hw(adapter))
3322 return;
3323
3324 /* Print Registers */
3325 e1000_regdump(adapter);
3326
3327 /*
3328 * transmit dump
3329 */
3330 pr_info("TX Desc ring0 dump\n");
3331
3332 /* Transmit Descriptor Formats - DEXT[29] is 0 (Legacy) or 1 (Extended)
3333 *
3334 * Legacy Transmit Descriptor
3335 * +--------------------------------------------------------------+
3336 * 0 | Buffer Address [63:0] (Reserved on Write Back) |
3337 * +--------------------------------------------------------------+
3338 * 8 | Special | CSS | Status | CMD | CSO | Length |
3339 * +--------------------------------------------------------------+
3340 * 63 48 47 36 35 32 31 24 23 16 15 0
3341 *
3342 * Extended Context Descriptor (DTYP=0x0) for TSO or checksum offload
3343 * 63 48 47 40 39 32 31 16 15 8 7 0
3344 * +----------------------------------------------------------------+
3345 * 0 | TUCSE | TUCS0 | TUCSS | IPCSE | IPCS0 | IPCSS |
3346 * +----------------------------------------------------------------+
3347 * 8 | MSS | HDRLEN | RSV | STA | TUCMD | DTYP | PAYLEN |
3348 * +----------------------------------------------------------------+
3349 * 63 48 47 40 39 36 35 32 31 24 23 20 19 0
3350 *
3351 * Extended Data Descriptor (DTYP=0x1)
3352 * +----------------------------------------------------------------+
3353 * 0 | Buffer Address [63:0] |
3354 * +----------------------------------------------------------------+
3355 * 8 | VLAN tag | POPTS | Rsvd | Status | Command | DTYP | DTALEN |
3356 * +----------------------------------------------------------------+
3357 * 63 48 47 40 39 36 35 32 31 24 23 20 19 0
3358 */
3359 printk(KERN_INFO "Tc[desc] [Ce CoCsIpceCoS] [MssHlRSCm0Plen] [bi->dma ]"
3360 " leng ntw timestmp bi->skb\n");
3361 printk(KERN_INFO "Td[desc] [address 63:0 ] [VlaPoRSCm1Dlen] [bi->dma ]"
3362 " leng ntw timestmp bi->skb\n");
3363
3364 if (!netif_msg_tx_done(adapter))
3365 goto rx_ring_summary;
3366
3367 for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) {
3368 struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*tx_ring, i);
3369 struct e1000_buffer *buffer_info = &tx_ring->buffer_info[i];
3370 struct my_u { u64 a; u64 b; };
3371 struct my_u *u = (struct my_u *)tx_desc;
3372 printk(KERN_INFO "T%c[0x%03X] %016llX %016llX %016llX %04X %3X "
3373 "%016llX %p",
3374 ((le64_to_cpu(u->b) & (1<<20)) ? 'd' : 'c'), i,
3375 le64_to_cpu(u->a), le64_to_cpu(u->b),
3376 (u64)buffer_info->dma, buffer_info->length,
3377 buffer_info->next_to_watch, (u64)buffer_info->time_stamp,
3378 buffer_info->skb);
3379 if (i == tx_ring->next_to_use && i == tx_ring->next_to_clean)
3380 printk(KERN_CONT" NTC/U\n");
3381 else if (i == tx_ring->next_to_use)
3382 printk(KERN_CONT " NTU\n");
3383 else if (i == tx_ring->next_to_clean)
3384 printk(KERN_CONT " NTC\n");
3385 else
3386 printk(KERN_CONT "\n");
3387
3388
3389 if (netif_msg_pktdata(adapter) && buffer_info->dma != 0)
3390 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS,
3391 16, 1, phys_to_virt(buffer_info->dma),
3392 buffer_info->length, true);
3393 }
3394
3395rx_ring_summary:
3396 /*
3397 * receive dump
3398 */
3399 pr_info("\nRX Desc ring dump\n");
3400
3401 /* Legacy Receive Descriptor Format
3402 *
3403 * +-----------------------------------------------------+
3404 * | Buffer Address [63:0] |
3405 * +-----------------------------------------------------+
3406 * | VLAN Tag | Errors | Status 0 | Packet csum | Length |
3407 * +-----------------------------------------------------+
3408 * 63 48 47 40 39 32 31 16 15 0
3409 */
3410 printk(KERN_INFO "R[desc] [address 63:0 ] [vl er S cks ln] "
3411 "[bi->dma ] [bi->skb]\n");
3412
3413 if (!netif_msg_rx_status(adapter))
3414 goto exit;
3415
3416 for (i = 0; rx_ring->desc && (i < rx_ring->count); i++) {
3417 struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rx_ring, i);
3418 struct e1000_buffer *buffer_info = &rx_ring->buffer_info[i];
3419 struct my_u { u64 a; u64 b; };
3420 struct my_u *u = (struct my_u *)rx_desc;
3421 printk(KERN_INFO "R[0x%03X] %016llX %016llX %016llX %p",
3422 i, le64_to_cpu(u->a), le64_to_cpu(u->b),
3423 (u64)buffer_info->dma, buffer_info->skb);
3424 if (i == rx_ring->next_to_use)
3425 printk(KERN_CONT " NTU\n");
3426 else if (i == rx_ring->next_to_clean)
3427 printk(KERN_CONT " NTC\n");
3428 else
3429 printk(KERN_CONT "\n");
3430
3431 if (netif_msg_pktdata(adapter))
3432 print_hex_dump(KERN_INFO, "",
3433 DUMP_PREFIX_ADDRESS, 16, 1,
3434 phys_to_virt(buffer_info->dma),
3435 buffer_info->length, true);
3436
3437 } /* for */
3438
3439 /* dump the descriptor caches */
3440 /* rx */
3441 printk(KERN_INFO "e1000: Rx descriptor cache in 64bit format\n");
3442 for (i = 0x6000; i <= 0x63FF ; i += 0x10) {
3443 printk(KERN_INFO "R%04X: %08X|%08X %08X|%08X\n",
3444 i,
3445 readl(adapter->hw.hw_addr + i+4),
3446 readl(adapter->hw.hw_addr + i),
3447 readl(adapter->hw.hw_addr + i+12),
3448 readl(adapter->hw.hw_addr + i+8));
3449 }
3450 /* tx */
3451 printk(KERN_INFO "e1000: Tx descriptor cache in 64bit format\n");
3452 for (i = 0x7000; i <= 0x73FF ; i += 0x10) {
3453 printk(KERN_INFO "T%04X: %08X|%08X %08X|%08X\n",
3454 i,
3455 readl(adapter->hw.hw_addr + i+4),
3456 readl(adapter->hw.hw_addr + i),
3457 readl(adapter->hw.hw_addr + i+12),
3458 readl(adapter->hw.hw_addr + i+8));
3459 }
3460exit:
3461 return;
3462}
3463
3244/** 3464/**
3245 * e1000_tx_timeout - Respond to a Tx Hang 3465 * e1000_tx_timeout - Respond to a Tx Hang
3246 * @netdev: network interface device structure 3466 * @netdev: network interface device structure
@@ -3262,6 +3482,7 @@ static void e1000_reset_task(struct work_struct *work)
3262 3482
3263 if (test_bit(__E1000_DOWN, &adapter->flags)) 3483 if (test_bit(__E1000_DOWN, &adapter->flags))
3264 return; 3484 return;
3485 e_err(drv, "Reset adapter\n");
3265 e1000_reinit_safe(adapter); 3486 e1000_reinit_safe(adapter);
3266} 3487}
3267 3488
@@ -3679,6 +3900,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
3679 eop, 3900 eop,
3680 jiffies, 3901 jiffies,
3681 eop_desc->upper.fields.status); 3902 eop_desc->upper.fields.status);
3903 e1000_dump(adapter);
3682 netif_stop_queue(netdev); 3904 netif_stop_queue(netdev);
3683 } 3905 }
3684 } 3906 }
diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
index e1159e54334a..cfb361e5f498 100644
--- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c
+++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2011 Intel Corporation. 4 Copyright(c) 1999 - 2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -201,19 +201,23 @@ static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw)
201 * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs. 201 * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs.
202 * @hw: pointer to the HW structure 202 * @hw: pointer to the HW structure
203 **/ 203 **/
204static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter) 204static s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw)
205{ 205{
206 struct e1000_hw *hw = &adapter->hw;
207 struct e1000_mac_info *mac = &hw->mac; 206 struct e1000_mac_info *mac = &hw->mac;
208 struct e1000_mac_operations *func = &mac->ops;
209 207
210 /* Set media type */ 208 /* Set media type and media-dependent function pointers */
211 switch (adapter->pdev->device) { 209 switch (hw->adapter->pdev->device) {
212 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT: 210 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
213 hw->phy.media_type = e1000_media_type_internal_serdes; 211 hw->phy.media_type = e1000_media_type_internal_serdes;
212 mac->ops.check_for_link = e1000e_check_for_serdes_link;
213 mac->ops.setup_physical_interface =
214 e1000e_setup_fiber_serdes_link;
214 break; 215 break;
215 default: 216 default:
216 hw->phy.media_type = e1000_media_type_copper; 217 hw->phy.media_type = e1000_media_type_copper;
218 mac->ops.check_for_link = e1000e_check_for_copper_link;
219 mac->ops.setup_physical_interface =
220 e1000_setup_copper_link_80003es2lan;
217 break; 221 break;
218 } 222 }
219 223
@@ -230,25 +234,6 @@ static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter)
230 /* Adaptive IFS not supported */ 234 /* Adaptive IFS not supported */
231 mac->adaptive_ifs = false; 235 mac->adaptive_ifs = false;
232 236
233 /* check for link */
234 switch (hw->phy.media_type) {
235 case e1000_media_type_copper:
236 func->setup_physical_interface = e1000_setup_copper_link_80003es2lan;
237 func->check_for_link = e1000e_check_for_copper_link;
238 break;
239 case e1000_media_type_fiber:
240 func->setup_physical_interface = e1000e_setup_fiber_serdes_link;
241 func->check_for_link = e1000e_check_for_fiber_link;
242 break;
243 case e1000_media_type_internal_serdes:
244 func->setup_physical_interface = e1000e_setup_fiber_serdes_link;
245 func->check_for_link = e1000e_check_for_serdes_link;
246 break;
247 default:
248 return -E1000_ERR_CONFIG;
249 break;
250 }
251
252 /* set lan id for port to determine which phy lock to use */ 237 /* set lan id for port to determine which phy lock to use */
253 hw->mac.ops.set_lan_id(hw); 238 hw->mac.ops.set_lan_id(hw);
254 239
@@ -260,7 +245,7 @@ static s32 e1000_get_variants_80003es2lan(struct e1000_adapter *adapter)
260 struct e1000_hw *hw = &adapter->hw; 245 struct e1000_hw *hw = &adapter->hw;
261 s32 rc; 246 s32 rc;
262 247
263 rc = e1000_init_mac_params_80003es2lan(adapter); 248 rc = e1000_init_mac_params_80003es2lan(hw);
264 if (rc) 249 if (rc)
265 return rc; 250 return rc;
266 251
@@ -667,8 +652,7 @@ static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)
667 udelay(1); 652 udelay(1);
668 653
669 if (hw->phy.autoneg_wait_to_complete) { 654 if (hw->phy.autoneg_wait_to_complete) {
670 e_dbg("Waiting for forced speed/duplex link " 655 e_dbg("Waiting for forced speed/duplex link on GG82563 phy.\n");
671 "on GG82563 phy.\n");
672 656
673 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT, 657 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
674 100000, &link); 658 100000, &link);
@@ -1502,8 +1486,7 @@ const struct e1000_info e1000_es2_info = {
1502 | FLAG_RX_NEEDS_RESTART /* errata */ 1486 | FLAG_RX_NEEDS_RESTART /* errata */
1503 | FLAG_TARC_SET_BIT_ZERO /* errata */ 1487 | FLAG_TARC_SET_BIT_ZERO /* errata */
1504 | FLAG_APME_CHECK_PORT_B 1488 | FLAG_APME_CHECK_PORT_B
1505 | FLAG_DISABLE_FC_PAUSE_TIME /* errata */ 1489 | FLAG_DISABLE_FC_PAUSE_TIME, /* errata */
1506 | FLAG_TIPG_MEDIUM_FOR_80003ESLAN,
1507 .flags2 = FLAG2_DMA_BURST, 1490 .flags2 = FLAG2_DMA_BURST,
1508 .pba = 38, 1491 .pba = 38,
1509 .max_hw_frame_size = DEFAULT_JUMBO, 1492 .max_hw_frame_size = DEFAULT_JUMBO,
diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c
index a3e65fd26e09..795c3d640615 100644
--- a/drivers/net/ethernet/intel/e1000e/82571.c
+++ b/drivers/net/ethernet/intel/e1000e/82571.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2011 Intel Corporation. 4 Copyright(c) 1999 - 2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -235,30 +235,42 @@ static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw)
235 * e1000_init_mac_params_82571 - Init MAC func ptrs. 235 * e1000_init_mac_params_82571 - Init MAC func ptrs.
236 * @hw: pointer to the HW structure 236 * @hw: pointer to the HW structure
237 **/ 237 **/
238static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter) 238static s32 e1000_init_mac_params_82571(struct e1000_hw *hw)
239{ 239{
240 struct e1000_hw *hw = &adapter->hw;
241 struct e1000_mac_info *mac = &hw->mac; 240 struct e1000_mac_info *mac = &hw->mac;
242 struct e1000_mac_operations *func = &mac->ops;
243 u32 swsm = 0; 241 u32 swsm = 0;
244 u32 swsm2 = 0; 242 u32 swsm2 = 0;
245 bool force_clear_smbi = false; 243 bool force_clear_smbi = false;
246 244
247 /* Set media type */ 245 /* Set media type and media-dependent function pointers */
248 switch (adapter->pdev->device) { 246 switch (hw->adapter->pdev->device) {
249 case E1000_DEV_ID_82571EB_FIBER: 247 case E1000_DEV_ID_82571EB_FIBER:
250 case E1000_DEV_ID_82572EI_FIBER: 248 case E1000_DEV_ID_82572EI_FIBER:
251 case E1000_DEV_ID_82571EB_QUAD_FIBER: 249 case E1000_DEV_ID_82571EB_QUAD_FIBER:
252 hw->phy.media_type = e1000_media_type_fiber; 250 hw->phy.media_type = e1000_media_type_fiber;
251 mac->ops.setup_physical_interface =
252 e1000_setup_fiber_serdes_link_82571;
253 mac->ops.check_for_link = e1000e_check_for_fiber_link;
254 mac->ops.get_link_up_info =
255 e1000e_get_speed_and_duplex_fiber_serdes;
253 break; 256 break;
254 case E1000_DEV_ID_82571EB_SERDES: 257 case E1000_DEV_ID_82571EB_SERDES:
255 case E1000_DEV_ID_82572EI_SERDES:
256 case E1000_DEV_ID_82571EB_SERDES_DUAL: 258 case E1000_DEV_ID_82571EB_SERDES_DUAL:
257 case E1000_DEV_ID_82571EB_SERDES_QUAD: 259 case E1000_DEV_ID_82571EB_SERDES_QUAD:
260 case E1000_DEV_ID_82572EI_SERDES:
258 hw->phy.media_type = e1000_media_type_internal_serdes; 261 hw->phy.media_type = e1000_media_type_internal_serdes;
262 mac->ops.setup_physical_interface =
263 e1000_setup_fiber_serdes_link_82571;
264 mac->ops.check_for_link = e1000_check_for_serdes_link_82571;
265 mac->ops.get_link_up_info =
266 e1000e_get_speed_and_duplex_fiber_serdes;
259 break; 267 break;
260 default: 268 default:
261 hw->phy.media_type = e1000_media_type_copper; 269 hw->phy.media_type = e1000_media_type_copper;
270 mac->ops.setup_physical_interface =
271 e1000_setup_copper_link_82571;
272 mac->ops.check_for_link = e1000e_check_for_copper_link;
273 mac->ops.get_link_up_info = e1000e_get_speed_and_duplex_copper;
262 break; 274 break;
263 } 275 }
264 276
@@ -269,38 +281,13 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
269 /* Adaptive IFS supported */ 281 /* Adaptive IFS supported */
270 mac->adaptive_ifs = true; 282 mac->adaptive_ifs = true;
271 283
272 /* check for link */ 284 /* MAC-specific function pointers */
273 switch (hw->phy.media_type) {
274 case e1000_media_type_copper:
275 func->setup_physical_interface = e1000_setup_copper_link_82571;
276 func->check_for_link = e1000e_check_for_copper_link;
277 func->get_link_up_info = e1000e_get_speed_and_duplex_copper;
278 break;
279 case e1000_media_type_fiber:
280 func->setup_physical_interface =
281 e1000_setup_fiber_serdes_link_82571;
282 func->check_for_link = e1000e_check_for_fiber_link;
283 func->get_link_up_info =
284 e1000e_get_speed_and_duplex_fiber_serdes;
285 break;
286 case e1000_media_type_internal_serdes:
287 func->setup_physical_interface =
288 e1000_setup_fiber_serdes_link_82571;
289 func->check_for_link = e1000_check_for_serdes_link_82571;
290 func->get_link_up_info =
291 e1000e_get_speed_and_duplex_fiber_serdes;
292 break;
293 default:
294 return -E1000_ERR_CONFIG;
295 break;
296 }
297
298 switch (hw->mac.type) { 285 switch (hw->mac.type) {
299 case e1000_82573: 286 case e1000_82573:
300 func->set_lan_id = e1000_set_lan_id_single_port; 287 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
301 func->check_mng_mode = e1000e_check_mng_mode_generic; 288 mac->ops.check_mng_mode = e1000e_check_mng_mode_generic;
302 func->led_on = e1000e_led_on_generic; 289 mac->ops.led_on = e1000e_led_on_generic;
303 func->blink_led = e1000e_blink_led_generic; 290 mac->ops.blink_led = e1000e_blink_led_generic;
304 291
305 /* FWSM register */ 292 /* FWSM register */
306 mac->has_fwsm = true; 293 mac->has_fwsm = true;
@@ -314,14 +301,14 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
314 break; 301 break;
315 case e1000_82574: 302 case e1000_82574:
316 case e1000_82583: 303 case e1000_82583:
317 func->set_lan_id = e1000_set_lan_id_single_port; 304 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
318 func->check_mng_mode = e1000_check_mng_mode_82574; 305 mac->ops.check_mng_mode = e1000_check_mng_mode_82574;
319 func->led_on = e1000_led_on_82574; 306 mac->ops.led_on = e1000_led_on_82574;
320 break; 307 break;
321 default: 308 default:
322 func->check_mng_mode = e1000e_check_mng_mode_generic; 309 mac->ops.check_mng_mode = e1000e_check_mng_mode_generic;
323 func->led_on = e1000e_led_on_generic; 310 mac->ops.led_on = e1000e_led_on_generic;
324 func->blink_led = e1000e_blink_led_generic; 311 mac->ops.blink_led = e1000e_blink_led_generic;
325 312
326 /* FWSM register */ 313 /* FWSM register */
327 mac->has_fwsm = true; 314 mac->has_fwsm = true;
@@ -342,11 +329,11 @@ static s32 e1000_init_mac_params_82571(struct e1000_adapter *adapter)
342 329
343 if (!(swsm2 & E1000_SWSM2_LOCK)) { 330 if (!(swsm2 & E1000_SWSM2_LOCK)) {
344 /* Only do this for the first interface on this card */ 331 /* Only do this for the first interface on this card */
345 ew32(SWSM2, 332 ew32(SWSM2, swsm2 | E1000_SWSM2_LOCK);
346 swsm2 | E1000_SWSM2_LOCK);
347 force_clear_smbi = true; 333 force_clear_smbi = true;
348 } else 334 } else {
349 force_clear_smbi = false; 335 force_clear_smbi = false;
336 }
350 break; 337 break;
351 default: 338 default:
352 force_clear_smbi = true; 339 force_clear_smbi = true;
@@ -383,7 +370,7 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
383 int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1; 370 int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1;
384 s32 rc; 371 s32 rc;
385 372
386 rc = e1000_init_mac_params_82571(adapter); 373 rc = e1000_init_mac_params_82571(hw);
387 if (rc) 374 if (rc)
388 return rc; 375 return rc;
389 376
@@ -1227,6 +1214,10 @@ static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw)
1227 case e1000_82572: 1214 case e1000_82572:
1228 reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26); 1215 reg |= (1 << 23) | (1 << 24) | (1 << 25) | (1 << 26);
1229 break; 1216 break;
1217 case e1000_82574:
1218 case e1000_82583:
1219 reg |= (1 << 26);
1220 break;
1230 default: 1221 default:
1231 break; 1222 break;
1232 } 1223 }
@@ -1873,7 +1864,7 @@ static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw)
1873 struct e1000_phy_info *phy = &hw->phy; 1864 struct e1000_phy_info *phy = &hw->phy;
1874 struct e1000_mac_info *mac = &hw->mac; 1865 struct e1000_mac_info *mac = &hw->mac;
1875 1866
1876 if (!(phy->ops.check_reset_block)) 1867 if (!phy->ops.check_reset_block)
1877 return; 1868 return;
1878 1869
1879 /* If the management interface is not enabled, then power down */ 1870 /* If the management interface is not enabled, then power down */
diff --git a/drivers/net/ethernet/intel/e1000e/Makefile b/drivers/net/ethernet/intel/e1000e/Makefile
index 948c05db5d68..591b71324505 100644
--- a/drivers/net/ethernet/intel/e1000e/Makefile
+++ b/drivers/net/ethernet/intel/e1000e/Makefile
@@ -1,7 +1,7 @@
1################################################################################ 1################################################################################
2# 2#
3# Intel PRO/1000 Linux driver 3# Intel PRO/1000 Linux driver
4# Copyright(c) 1999 - 2011 Intel Corporation. 4# Copyright(c) 1999 - 2012 Intel Corporation.
5# 5#
6# This program is free software; you can redistribute it and/or modify it 6# This program is free software; you can redistribute it and/or modify it
7# under the terms and conditions of the GNU General Public License, 7# under the terms and conditions of the GNU General Public License,
@@ -33,5 +33,6 @@
33obj-$(CONFIG_E1000E) += e1000e.o 33obj-$(CONFIG_E1000E) += e1000e.o
34 34
35e1000e-objs := 82571.o ich8lan.o 80003es2lan.o \ 35e1000e-objs := 82571.o ich8lan.o 80003es2lan.o \
36 lib.o phy.o param.o ethtool.o netdev.o 36 mac.o manage.o nvm.o phy.o \
37 param.o ethtool.o netdev.o
37 38
diff --git a/drivers/net/ethernet/intel/e1000e/defines.h b/drivers/net/ethernet/intel/e1000e/defines.h
index c516a7440bec..1af30b967a4f 100644
--- a/drivers/net/ethernet/intel/e1000e/defines.h
+++ b/drivers/net/ethernet/intel/e1000e/defines.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2011 Intel Corporation. 4 Copyright(c) 1999 - 2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -126,6 +126,13 @@
126 E1000_RXDEXT_STATERR_CXE | \ 126 E1000_RXDEXT_STATERR_CXE | \
127 E1000_RXDEXT_STATERR_RXE) 127 E1000_RXDEXT_STATERR_RXE)
128 128
129#define E1000_MRQC_RSS_FIELD_MASK 0xFFFF0000
130#define E1000_MRQC_RSS_FIELD_IPV4_TCP 0x00010000
131#define E1000_MRQC_RSS_FIELD_IPV4 0x00020000
132#define E1000_MRQC_RSS_FIELD_IPV6_TCP_EX 0x00040000
133#define E1000_MRQC_RSS_FIELD_IPV6 0x00100000
134#define E1000_MRQC_RSS_FIELD_IPV6_TCP 0x00200000
135
129#define E1000_RXDPS_HDRSTAT_HDRSP 0x00008000 136#define E1000_RXDPS_HDRSTAT_HDRSP 0x00008000
130 137
131/* Management Control */ 138/* Management Control */
@@ -326,6 +333,7 @@
326/* Receive Checksum Control */ 333/* Receive Checksum Control */
327#define E1000_RXCSUM_TUOFL 0x00000200 /* TCP / UDP checksum offload */ 334#define E1000_RXCSUM_TUOFL 0x00000200 /* TCP / UDP checksum offload */
328#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */ 335#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */
336#define E1000_RXCSUM_PCSD 0x00002000 /* packet checksum disabled */
329 337
330/* Header split receive */ 338/* Header split receive */
331#define E1000_RFCTL_NFSW_DIS 0x00000040 339#define E1000_RFCTL_NFSW_DIS 0x00000040
diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h
index f478a22ed577..45e5ae8a9fb7 100644
--- a/drivers/net/ethernet/intel/e1000e/e1000.h
+++ b/drivers/net/ethernet/intel/e1000e/e1000.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2011 Intel Corporation. 4 Copyright(c) 1999 - 2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -234,6 +234,7 @@ struct e1000_buffer {
234}; 234};
235 235
236struct e1000_ring { 236struct e1000_ring {
237 struct e1000_adapter *adapter; /* back pointer to adapter */
237 void *desc; /* pointer to ring memory */ 238 void *desc; /* pointer to ring memory */
238 dma_addr_t dma; /* phys address of ring */ 239 dma_addr_t dma; /* phys address of ring */
239 unsigned int size; /* length of ring in bytes */ 240 unsigned int size; /* length of ring in bytes */
@@ -242,8 +243,8 @@ struct e1000_ring {
242 u16 next_to_use; 243 u16 next_to_use;
243 u16 next_to_clean; 244 u16 next_to_clean;
244 245
245 u16 head; 246 void __iomem *head;
246 u16 tail; 247 void __iomem *tail;
247 248
248 /* array of buffer information structs */ 249 /* array of buffer information structs */
249 struct e1000_buffer *buffer_info; 250 struct e1000_buffer *buffer_info;
@@ -251,7 +252,7 @@ struct e1000_ring {
251 char name[IFNAMSIZ + 5]; 252 char name[IFNAMSIZ + 5];
252 u32 ims_val; 253 u32 ims_val;
253 u32 itr_val; 254 u32 itr_val;
254 u16 itr_register; 255 void __iomem *itr_register;
255 int set_itr; 256 int set_itr;
256 257
257 struct sk_buff *rx_skb_top; 258 struct sk_buff *rx_skb_top;
@@ -334,11 +335,10 @@ struct e1000_adapter {
334 /* 335 /*
335 * Rx 336 * Rx
336 */ 337 */
337 bool (*clean_rx) (struct e1000_adapter *adapter, 338 bool (*clean_rx) (struct e1000_ring *ring, int *work_done,
338 int *work_done, int work_to_do) 339 int work_to_do) ____cacheline_aligned_in_smp;
339 ____cacheline_aligned_in_smp; 340 void (*alloc_rx_buf) (struct e1000_ring *ring, int cleaned_count,
340 void (*alloc_rx_buf) (struct e1000_adapter *adapter, 341 gfp_t gfp);
341 int cleaned_count, gfp_t gfp);
342 struct e1000_ring *rx_ring; 342 struct e1000_ring *rx_ring;
343 343
344 u32 rx_int_delay; 344 u32 rx_int_delay;
@@ -398,6 +398,9 @@ struct e1000_adapter {
398 398
399 bool idle_check; 399 bool idle_check;
400 int phy_hang_count; 400 int phy_hang_count;
401
402 u16 tx_ring_count;
403 u16 rx_ring_count;
401}; 404};
402 405
403struct e1000_info { 406struct e1000_info {
@@ -417,7 +420,7 @@ struct e1000_info {
417#define FLAG_HAS_FLASH (1 << 1) 420#define FLAG_HAS_FLASH (1 << 1)
418#define FLAG_HAS_HW_VLAN_FILTER (1 << 2) 421#define FLAG_HAS_HW_VLAN_FILTER (1 << 2)
419#define FLAG_HAS_WOL (1 << 3) 422#define FLAG_HAS_WOL (1 << 3)
420#define FLAG_HAS_ERT (1 << 4) 423/* reserved bit4 */
421#define FLAG_HAS_CTRLEXT_ON_LOAD (1 << 5) 424#define FLAG_HAS_CTRLEXT_ON_LOAD (1 << 5)
422#define FLAG_HAS_SWSM_ON_LOAD (1 << 6) 425#define FLAG_HAS_SWSM_ON_LOAD (1 << 6)
423#define FLAG_HAS_JUMBO_FRAMES (1 << 7) 426#define FLAG_HAS_JUMBO_FRAMES (1 << 7)
@@ -427,7 +430,7 @@ struct e1000_info {
427#define FLAG_HAS_SMART_POWER_DOWN (1 << 11) 430#define FLAG_HAS_SMART_POWER_DOWN (1 << 11)
428#define FLAG_IS_QUAD_PORT_A (1 << 12) 431#define FLAG_IS_QUAD_PORT_A (1 << 12)
429#define FLAG_IS_QUAD_PORT (1 << 13) 432#define FLAG_IS_QUAD_PORT (1 << 13)
430#define FLAG_TIPG_MEDIUM_FOR_80003ESLAN (1 << 14) 433/* reserved bit14 */
431#define FLAG_APME_IN_WUC (1 << 15) 434#define FLAG_APME_IN_WUC (1 << 15)
432#define FLAG_APME_IN_CTRL3 (1 << 16) 435#define FLAG_APME_IN_CTRL3 (1 << 16)
433#define FLAG_APME_CHECK_PORT_B (1 << 17) 436#define FLAG_APME_CHECK_PORT_B (1 << 17)
@@ -492,10 +495,10 @@ extern void e1000e_down(struct e1000_adapter *adapter);
492extern void e1000e_reinit_locked(struct e1000_adapter *adapter); 495extern void e1000e_reinit_locked(struct e1000_adapter *adapter);
493extern void e1000e_reset(struct e1000_adapter *adapter); 496extern void e1000e_reset(struct e1000_adapter *adapter);
494extern void e1000e_power_up_phy(struct e1000_adapter *adapter); 497extern void e1000e_power_up_phy(struct e1000_adapter *adapter);
495extern int e1000e_setup_rx_resources(struct e1000_adapter *adapter); 498extern int e1000e_setup_rx_resources(struct e1000_ring *ring);
496extern int e1000e_setup_tx_resources(struct e1000_adapter *adapter); 499extern int e1000e_setup_tx_resources(struct e1000_ring *ring);
497extern void e1000e_free_rx_resources(struct e1000_adapter *adapter); 500extern void e1000e_free_rx_resources(struct e1000_ring *ring);
498extern void e1000e_free_tx_resources(struct e1000_adapter *adapter); 501extern void e1000e_free_tx_resources(struct e1000_ring *ring);
499extern struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev, 502extern struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
500 struct rtnl_link_stats64 503 struct rtnl_link_stats64
501 *stats); 504 *stats);
diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c
index fb2c28e799a2..b1f5d7491b57 100644
--- a/drivers/net/ethernet/intel/e1000e/ethtool.c
+++ b/drivers/net/ethernet/intel/e1000e/ethtool.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2011 Intel Corporation. 4 Copyright(c) 1999 - 2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -34,6 +34,7 @@
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/vmalloc.h>
37 38
38#include "e1000.h" 39#include "e1000.h"
39 40
@@ -536,7 +537,7 @@ static int e1000_set_eeprom(struct net_device *netdev,
536 ret_val = e1000_read_nvm(hw, first_word, 1, &eeprom_buff[0]); 537 ret_val = e1000_read_nvm(hw, first_word, 1, &eeprom_buff[0]);
537 ptr++; 538 ptr++;
538 } 539 }
539 if (((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) 540 if (((eeprom->offset + eeprom->len) & 1) && (!ret_val))
540 /* need read/modify/write of last changed EEPROM word */ 541 /* need read/modify/write of last changed EEPROM word */
541 /* only the first byte of the word is being modified */ 542 /* only the first byte of the word is being modified */
542 ret_val = e1000_read_nvm(hw, last_word, 1, 543 ret_val = e1000_read_nvm(hw, last_word, 1,
@@ -552,7 +553,7 @@ static int e1000_set_eeprom(struct net_device *netdev,
552 memcpy(ptr, bytes, eeprom->len); 553 memcpy(ptr, bytes, eeprom->len);
553 554
554 for (i = 0; i < last_word - first_word + 1; i++) 555 for (i = 0; i < last_word - first_word + 1; i++)
555 eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]); 556 cpu_to_le16s(&eeprom_buff[i]);
556 557
557 ret_val = e1000_write_nvm(hw, first_word, 558 ret_val = e1000_write_nvm(hw, first_word,
558 last_word - first_word + 1, eeprom_buff); 559 last_word - first_word + 1, eeprom_buff);
@@ -605,94 +606,112 @@ static void e1000_get_ringparam(struct net_device *netdev,
605 struct ethtool_ringparam *ring) 606 struct ethtool_ringparam *ring)
606{ 607{
607 struct e1000_adapter *adapter = netdev_priv(netdev); 608 struct e1000_adapter *adapter = netdev_priv(netdev);
608 struct e1000_ring *tx_ring = adapter->tx_ring;
609 struct e1000_ring *rx_ring = adapter->rx_ring;
610 609
611 ring->rx_max_pending = E1000_MAX_RXD; 610 ring->rx_max_pending = E1000_MAX_RXD;
612 ring->tx_max_pending = E1000_MAX_TXD; 611 ring->tx_max_pending = E1000_MAX_TXD;
613 ring->rx_pending = rx_ring->count; 612 ring->rx_pending = adapter->rx_ring_count;
614 ring->tx_pending = tx_ring->count; 613 ring->tx_pending = adapter->tx_ring_count;
615} 614}
616 615
617static int e1000_set_ringparam(struct net_device *netdev, 616static int e1000_set_ringparam(struct net_device *netdev,
618 struct ethtool_ringparam *ring) 617 struct ethtool_ringparam *ring)
619{ 618{
620 struct e1000_adapter *adapter = netdev_priv(netdev); 619 struct e1000_adapter *adapter = netdev_priv(netdev);
621 struct e1000_ring *tx_ring, *tx_old; 620 struct e1000_ring *temp_tx = NULL, *temp_rx = NULL;
622 struct e1000_ring *rx_ring, *rx_old; 621 int err = 0, size = sizeof(struct e1000_ring);
623 int err; 622 bool set_tx = false, set_rx = false;
623 u16 new_rx_count, new_tx_count;
624 624
625 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) 625 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
626 return -EINVAL; 626 return -EINVAL;
627 627
628 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 628 new_rx_count = clamp_t(u32, ring->rx_pending, E1000_MIN_RXD,
629 usleep_range(1000, 2000); 629 E1000_MAX_RXD);
630 new_rx_count = ALIGN(new_rx_count, REQ_RX_DESCRIPTOR_MULTIPLE);
630 631
631 if (netif_running(adapter->netdev)) 632 new_tx_count = clamp_t(u32, ring->tx_pending, E1000_MIN_TXD,
632 e1000e_down(adapter); 633 E1000_MAX_TXD);
634 new_tx_count = ALIGN(new_tx_count, REQ_TX_DESCRIPTOR_MULTIPLE);
633 635
634 tx_old = adapter->tx_ring; 636 if ((new_tx_count == adapter->tx_ring_count) &&
635 rx_old = adapter->rx_ring; 637 (new_rx_count == adapter->rx_ring_count))
638 /* nothing to do */
639 return 0;
636 640
637 err = -ENOMEM; 641 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
638 tx_ring = kmemdup(tx_old, sizeof(struct e1000_ring), GFP_KERNEL); 642 usleep_range(1000, 2000);
639 if (!tx_ring)
640 goto err_alloc_tx;
641 643
642 rx_ring = kmemdup(rx_old, sizeof(struct e1000_ring), GFP_KERNEL); 644 if (!netif_running(adapter->netdev)) {
643 if (!rx_ring) 645 /* Set counts now and allocate resources during open() */
644 goto err_alloc_rx; 646 adapter->tx_ring->count = new_tx_count;
647 adapter->rx_ring->count = new_rx_count;
648 adapter->tx_ring_count = new_tx_count;
649 adapter->rx_ring_count = new_rx_count;
650 goto clear_reset;
651 }
645 652
646 adapter->tx_ring = tx_ring; 653 set_tx = (new_tx_count != adapter->tx_ring_count);
647 adapter->rx_ring = rx_ring; 654 set_rx = (new_rx_count != adapter->rx_ring_count);
648 655
649 rx_ring->count = max(ring->rx_pending, (u32)E1000_MIN_RXD); 656 /* Allocate temporary storage for ring updates */
650 rx_ring->count = min(rx_ring->count, (u32)(E1000_MAX_RXD)); 657 if (set_tx) {
651 rx_ring->count = ALIGN(rx_ring->count, REQ_RX_DESCRIPTOR_MULTIPLE); 658 temp_tx = vmalloc(size);
659 if (!temp_tx) {
660 err = -ENOMEM;
661 goto free_temp;
662 }
663 }
664 if (set_rx) {
665 temp_rx = vmalloc(size);
666 if (!temp_rx) {
667 err = -ENOMEM;
668 goto free_temp;
669 }
670 }
652 671
653 tx_ring->count = max(ring->tx_pending, (u32)E1000_MIN_TXD); 672 e1000e_down(adapter);
654 tx_ring->count = min(tx_ring->count, (u32)(E1000_MAX_TXD));
655 tx_ring->count = ALIGN(tx_ring->count, REQ_TX_DESCRIPTOR_MULTIPLE);
656 673
657 if (netif_running(adapter->netdev)) { 674 /*
658 /* Try to get new resources before deleting old */ 675 * We can't just free everything and then setup again, because the
659 err = e1000e_setup_rx_resources(adapter); 676 * ISRs in MSI-X mode get passed pointers to the Tx and Rx ring
677 * structs. First, attempt to allocate new resources...
678 */
679 if (set_tx) {
680 memcpy(temp_tx, adapter->tx_ring, size);
681 temp_tx->count = new_tx_count;
682 err = e1000e_setup_tx_resources(temp_tx);
660 if (err) 683 if (err)
661 goto err_setup_rx; 684 goto err_setup;
662 err = e1000e_setup_tx_resources(adapter); 685 }
686 if (set_rx) {
687 memcpy(temp_rx, adapter->rx_ring, size);
688 temp_rx->count = new_rx_count;
689 err = e1000e_setup_rx_resources(temp_rx);
663 if (err) 690 if (err)
664 goto err_setup_tx; 691 goto err_setup_rx;
692 }
665 693
666 /* 694 /* ...then free the old resources and copy back any new ring data */
667 * restore the old in order to free it, 695 if (set_tx) {
668 * then add in the new 696 e1000e_free_tx_resources(adapter->tx_ring);
669 */ 697 memcpy(adapter->tx_ring, temp_tx, size);
670 adapter->rx_ring = rx_old; 698 adapter->tx_ring_count = new_tx_count;
671 adapter->tx_ring = tx_old; 699 }
672 e1000e_free_rx_resources(adapter); 700 if (set_rx) {
673 e1000e_free_tx_resources(adapter); 701 e1000e_free_rx_resources(adapter->rx_ring);
674 kfree(tx_old); 702 memcpy(adapter->rx_ring, temp_rx, size);
675 kfree(rx_old); 703 adapter->rx_ring_count = new_rx_count;
676 adapter->rx_ring = rx_ring;
677 adapter->tx_ring = tx_ring;
678 err = e1000e_up(adapter);
679 if (err)
680 goto err_setup;
681 } 704 }
682 705
683 clear_bit(__E1000_RESETTING, &adapter->state);
684 return 0;
685err_setup_tx:
686 e1000e_free_rx_resources(adapter);
687err_setup_rx: 706err_setup_rx:
688 adapter->rx_ring = rx_old; 707 if (err && set_tx)
689 adapter->tx_ring = tx_old; 708 e1000e_free_tx_resources(temp_tx);
690 kfree(rx_ring);
691err_alloc_rx:
692 kfree(tx_ring);
693err_alloc_tx:
694 e1000e_up(adapter);
695err_setup: 709err_setup:
710 e1000e_up(adapter);
711free_temp:
712 vfree(temp_tx);
713 vfree(temp_rx);
714clear_reset:
696 clear_bit(__E1000_RESETTING, &adapter->state); 715 clear_bit(__E1000_RESETTING, &adapter->state);
697 return err; 716 return err;
698} 717}
@@ -1069,7 +1088,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1069 tx_ring->buffer_info = kcalloc(tx_ring->count, 1088 tx_ring->buffer_info = kcalloc(tx_ring->count,
1070 sizeof(struct e1000_buffer), 1089 sizeof(struct e1000_buffer),
1071 GFP_KERNEL); 1090 GFP_KERNEL);
1072 if (!(tx_ring->buffer_info)) { 1091 if (!tx_ring->buffer_info) {
1073 ret_val = 1; 1092 ret_val = 1;
1074 goto err_nomem; 1093 goto err_nomem;
1075 } 1094 }
@@ -1131,7 +1150,7 @@ static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1131 rx_ring->buffer_info = kcalloc(rx_ring->count, 1150 rx_ring->buffer_info = kcalloc(rx_ring->count,
1132 sizeof(struct e1000_buffer), 1151 sizeof(struct e1000_buffer),
1133 GFP_KERNEL); 1152 GFP_KERNEL);
1134 if (!(rx_ring->buffer_info)) { 1153 if (!rx_ring->buffer_info) {
1135 ret_val = 5; 1154 ret_val = 5;
1136 goto err_nomem; 1155 goto err_nomem;
1137 } 1156 }
@@ -1837,11 +1856,11 @@ static int e1000_set_phys_id(struct net_device *netdev,
1837 break; 1856 break;
1838 1857
1839 case ETHTOOL_ID_ON: 1858 case ETHTOOL_ID_ON:
1840 adapter->hw.mac.ops.led_on(&adapter->hw); 1859 hw->mac.ops.led_on(hw);
1841 break; 1860 break;
1842 1861
1843 case ETHTOOL_ID_OFF: 1862 case ETHTOOL_ID_OFF:
1844 adapter->hw.mac.ops.led_off(&adapter->hw); 1863 hw->mac.ops.led_off(hw);
1845 break; 1864 break;
1846 } 1865 }
1847 return 0; 1866 return 0;
@@ -1955,6 +1974,53 @@ static void e1000_get_strings(struct net_device *netdev, u32 stringset,
1955 } 1974 }
1956} 1975}
1957 1976
1977static int e1000_get_rxnfc(struct net_device *netdev,
1978 struct ethtool_rxnfc *info, u32 *rule_locs)
1979{
1980 info->data = 0;
1981
1982 switch (info->cmd) {
1983 case ETHTOOL_GRXFH: {
1984 struct e1000_adapter *adapter = netdev_priv(netdev);
1985 struct e1000_hw *hw = &adapter->hw;
1986 u32 mrqc = er32(MRQC);
1987
1988 if (!(mrqc & E1000_MRQC_RSS_FIELD_MASK))
1989 return 0;
1990
1991 switch (info->flow_type) {
1992 case TCP_V4_FLOW:
1993 if (mrqc & E1000_MRQC_RSS_FIELD_IPV4_TCP)
1994 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1995 /* fall through */
1996 case UDP_V4_FLOW:
1997 case SCTP_V4_FLOW:
1998 case AH_ESP_V4_FLOW:
1999 case IPV4_FLOW:
2000 if (mrqc & E1000_MRQC_RSS_FIELD_IPV4)
2001 info->data |= RXH_IP_SRC | RXH_IP_DST;
2002 break;
2003 case TCP_V6_FLOW:
2004 if (mrqc & E1000_MRQC_RSS_FIELD_IPV6_TCP)
2005 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
2006 /* fall through */
2007 case UDP_V6_FLOW:
2008 case SCTP_V6_FLOW:
2009 case AH_ESP_V6_FLOW:
2010 case IPV6_FLOW:
2011 if (mrqc & E1000_MRQC_RSS_FIELD_IPV6)
2012 info->data |= RXH_IP_SRC | RXH_IP_DST;
2013 break;
2014 default:
2015 break;
2016 }
2017 return 0;
2018 }
2019 default:
2020 return -EOPNOTSUPP;
2021 }
2022}
2023
1958static const struct ethtool_ops e1000_ethtool_ops = { 2024static const struct ethtool_ops e1000_ethtool_ops = {
1959 .get_settings = e1000_get_settings, 2025 .get_settings = e1000_get_settings,
1960 .set_settings = e1000_set_settings, 2026 .set_settings = e1000_set_settings,
@@ -1981,6 +2047,7 @@ static const struct ethtool_ops e1000_ethtool_ops = {
1981 .get_sset_count = e1000e_get_sset_count, 2047 .get_sset_count = e1000e_get_sset_count,
1982 .get_coalesce = e1000_get_coalesce, 2048 .get_coalesce = e1000_get_coalesce,
1983 .set_coalesce = e1000_set_coalesce, 2049 .set_coalesce = e1000_set_coalesce,
2050 .get_rxnfc = e1000_get_rxnfc,
1984}; 2051};
1985 2052
1986void e1000e_set_ethtool_ops(struct net_device *netdev) 2053void e1000e_set_ethtool_ops(struct net_device *netdev)
diff --git a/drivers/net/ethernet/intel/e1000e/hw.h b/drivers/net/ethernet/intel/e1000e/hw.h
index 29670397079b..197059bb9abf 100644
--- a/drivers/net/ethernet/intel/e1000e/hw.h
+++ b/drivers/net/ethernet/intel/e1000e/hw.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2011 Intel Corporation. 4 Copyright(c) 1999 - 2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -204,6 +204,7 @@ enum e1e_registers {
204 E1000_WUC = 0x05800, /* Wakeup Control - RW */ 204 E1000_WUC = 0x05800, /* Wakeup Control - RW */
205 E1000_WUFC = 0x05808, /* Wakeup Filter Control - RW */ 205 E1000_WUFC = 0x05808, /* Wakeup Filter Control - RW */
206 E1000_WUS = 0x05810, /* Wakeup Status - RO */ 206 E1000_WUS = 0x05810, /* Wakeup Status - RO */
207 E1000_MRQC = 0x05818, /* Multiple Receive Control - RW */
207 E1000_MANC = 0x05820, /* Management Control - RW */ 208 E1000_MANC = 0x05820, /* Management Control - RW */
208 E1000_FFLT = 0x05F00, /* Flexible Filter Length Table - RW Array */ 209 E1000_FFLT = 0x05F00, /* Flexible Filter Length Table - RW Array */
209 E1000_HOST_IF = 0x08800, /* Host Interface */ 210 E1000_HOST_IF = 0x08800, /* Host Interface */
@@ -219,6 +220,10 @@ enum e1e_registers {
219 E1000_SWSM = 0x05B50, /* SW Semaphore */ 220 E1000_SWSM = 0x05B50, /* SW Semaphore */
220 E1000_FWSM = 0x05B54, /* FW Semaphore */ 221 E1000_FWSM = 0x05B54, /* FW Semaphore */
221 E1000_SWSM2 = 0x05B58, /* Driver-only SW semaphore */ 222 E1000_SWSM2 = 0x05B58, /* Driver-only SW semaphore */
223 E1000_RETA_BASE = 0x05C00, /* Redirection Table - RW */
224#define E1000_RETA(_n) (E1000_RETA_BASE + ((_n) * 4))
225 E1000_RSSRK_BASE = 0x05C80, /* RSS Random Key - RW */
226#define E1000_RSSRK(_n) (E1000_RSSRK_BASE + ((_n) * 4))
222 E1000_FFLT_DBG = 0x05F04, /* Debug Register */ 227 E1000_FFLT_DBG = 0x05F04, /* Debug Register */
223 E1000_PCH_RAICC_BASE = 0x05F50, /* Receive Address Initial CRC */ 228 E1000_PCH_RAICC_BASE = 0x05F50, /* Receive Address Initial CRC */
224#define E1000_PCH_RAICC(_n) (E1000_PCH_RAICC_BASE + ((_n) * 4)) 229#define E1000_PCH_RAICC(_n) (E1000_PCH_RAICC_BASE + ((_n) * 4))
@@ -964,8 +969,8 @@ struct e1000_dev_spec_ich8lan {
964struct e1000_hw { 969struct e1000_hw {
965 struct e1000_adapter *adapter; 970 struct e1000_adapter *adapter;
966 971
967 u8 __iomem *hw_addr; 972 void __iomem *hw_addr;
968 u8 __iomem *flash_address; 973 void __iomem *flash_address;
969 974
970 struct e1000_mac_info mac; 975 struct e1000_mac_info mac;
971 struct e1000_fc_info fc; 976 struct e1000_fc_info fc;
diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c
index e2a80a283fd3..112d55f76b79 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.c
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2011 Intel Corporation. 4 Copyright(c) 1999 - 2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -145,6 +145,8 @@
145#define I82579_EMI_ADDR 0x10 145#define I82579_EMI_ADDR 0x10
146#define I82579_EMI_DATA 0x11 146#define I82579_EMI_DATA 0x11
147#define I82579_LPI_UPDATE_TIMER 0x4805 /* in 40ns units + 40 ns base value */ 147#define I82579_LPI_UPDATE_TIMER 0x4805 /* in 40ns units + 40 ns base value */
148#define I82579_MSE_THRESHOLD 0x084F /* Mean Square Error Threshold */
149#define I82579_MSE_LINK_DOWN 0x2411 /* MSE count before dropping link */
148 150
149/* Strapping Option Register - RO */ 151/* Strapping Option Register - RO */
150#define E1000_STRAP 0x0000C 152#define E1000_STRAP 0x0000C
@@ -278,8 +280,8 @@ static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
278 280
279#define er16flash(reg) __er16flash(hw, (reg)) 281#define er16flash(reg) __er16flash(hw, (reg))
280#define er32flash(reg) __er32flash(hw, (reg)) 282#define er32flash(reg) __er32flash(hw, (reg))
281#define ew16flash(reg,val) __ew16flash(hw, (reg), (val)) 283#define ew16flash(reg, val) __ew16flash(hw, (reg), (val))
282#define ew32flash(reg,val) __ew32flash(hw, (reg), (val)) 284#define ew32flash(reg, val) __ew32flash(hw, (reg), (val))
283 285
284static void e1000_toggle_lanphypc_value_ich8lan(struct e1000_hw *hw) 286static void e1000_toggle_lanphypc_value_ich8lan(struct e1000_hw *hw)
285{ 287{
@@ -304,7 +306,6 @@ static void e1000_toggle_lanphypc_value_ich8lan(struct e1000_hw *hw)
304static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) 306static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
305{ 307{
306 struct e1000_phy_info *phy = &hw->phy; 308 struct e1000_phy_info *phy = &hw->phy;
307 u32 fwsm;
308 s32 ret_val = 0; 309 s32 ret_val = 0;
309 310
310 phy->addr = 1; 311 phy->addr = 1;
@@ -323,14 +324,14 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
323 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan; 324 phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
324 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; 325 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
325 326
326 /* 327 if (!e1000_check_reset_block(hw)) {
327 * The MAC-PHY interconnect may still be in SMBus mode 328 u32 fwsm = er32(FWSM);
328 * after Sx->S0. If the manageability engine (ME) is 329
329 * disabled, then toggle the LANPHYPC Value bit to force 330 /*
330 * the interconnect to PCIe mode. 331 * The MAC-PHY interconnect may still be in SMBus mode after
331 */ 332 * Sx->S0. If resetting the PHY is not blocked, toggle the
332 fwsm = er32(FWSM); 333 * LANPHYPC Value bit to force the interconnect to PCIe mode.
333 if (!(fwsm & E1000_ICH_FWSM_FW_VALID) && !e1000_check_reset_block(hw)) { 334 */
334 e1000_toggle_lanphypc_value_ich8lan(hw); 335 e1000_toggle_lanphypc_value_ich8lan(hw);
335 msleep(50); 336 msleep(50);
336 337
@@ -338,25 +339,26 @@ static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
338 * Gate automatic PHY configuration by hardware on 339 * Gate automatic PHY configuration by hardware on
339 * non-managed 82579 340 * non-managed 82579
340 */ 341 */
341 if (hw->mac.type == e1000_pch2lan) 342 if ((hw->mac.type == e1000_pch2lan) &&
343 !(fwsm & E1000_ICH_FWSM_FW_VALID))
342 e1000_gate_hw_phy_config_ich8lan(hw, true); 344 e1000_gate_hw_phy_config_ich8lan(hw, true);
343 }
344 345
345 /* 346 /*
346 * Reset the PHY before any access to it. Doing so, ensures that 347 * Reset the PHY before any access to it. Doing so, ensures
347 * the PHY is in a known good state before we read/write PHY registers. 348 * that the PHY is in a known good state before we read/write
348 * The generic reset is sufficient here, because we haven't determined 349 * PHY registers. The generic reset is sufficient here,
349 * the PHY type yet. 350 * because we haven't determined the PHY type yet.
350 */ 351 */
351 ret_val = e1000e_phy_hw_reset_generic(hw); 352 ret_val = e1000e_phy_hw_reset_generic(hw);
352 if (ret_val) 353 if (ret_val)
353 goto out; 354 goto out;
354 355
355 /* Ungate automatic PHY configuration on non-managed 82579 */ 356 /* Ungate automatic PHY configuration on non-managed 82579 */
356 if ((hw->mac.type == e1000_pch2lan) && 357 if ((hw->mac.type == e1000_pch2lan) &&
357 !(fwsm & E1000_ICH_FWSM_FW_VALID)) { 358 !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
358 usleep_range(10000, 20000); 359 usleep_range(10000, 20000);
359 e1000_gate_hw_phy_config_ich8lan(hw, false); 360 e1000_gate_hw_phy_config_ich8lan(hw, false);
361 }
360 } 362 }
361 363
362 phy->id = e1000_phy_unknown; 364 phy->id = e1000_phy_unknown;
@@ -551,9 +553,8 @@ static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
551 * Initialize family-specific MAC parameters and function 553 * Initialize family-specific MAC parameters and function
552 * pointers. 554 * pointers.
553 **/ 555 **/
554static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter) 556static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
555{ 557{
556 struct e1000_hw *hw = &adapter->hw;
557 struct e1000_mac_info *mac = &hw->mac; 558 struct e1000_mac_info *mac = &hw->mac;
558 559
559 /* Set media type function pointer */ 560 /* Set media type function pointer */
@@ -773,7 +774,7 @@ static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
773 struct e1000_hw *hw = &adapter->hw; 774 struct e1000_hw *hw = &adapter->hw;
774 s32 rc; 775 s32 rc;
775 776
776 rc = e1000_init_mac_params_ich8lan(adapter); 777 rc = e1000_init_mac_params_ich8lan(hw);
777 if (rc) 778 if (rc)
778 return rc; 779 return rc;
779 780
@@ -900,8 +901,7 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
900 } 901 }
901 902
902 if (!timeout) { 903 if (!timeout) {
903 e_dbg("Failed to acquire the semaphore, FW or HW has it: " 904 e_dbg("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n",
904 "FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n",
905 er32(FWSM), extcnf_ctrl); 905 er32(FWSM), extcnf_ctrl);
906 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 906 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
907 ew32(EXTCNF_CTRL, extcnf_ctrl); 907 ew32(EXTCNF_CTRL, extcnf_ctrl);
@@ -1669,6 +1669,26 @@ static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
1669 /* Set MDIO slow mode before any other MDIO access */ 1669 /* Set MDIO slow mode before any other MDIO access */
1670 ret_val = e1000_set_mdio_slow_mode_hv(hw); 1670 ret_val = e1000_set_mdio_slow_mode_hv(hw);
1671 1671
1672 ret_val = hw->phy.ops.acquire(hw);
1673 if (ret_val)
1674 goto out;
1675 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR,
1676 I82579_MSE_THRESHOLD);
1677 if (ret_val)
1678 goto release;
1679 /* set MSE higher to enable link to stay up when noise is high */
1680 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA, 0x0034);
1681 if (ret_val)
1682 goto release;
1683 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_ADDR,
1684 I82579_MSE_LINK_DOWN);
1685 if (ret_val)
1686 goto release;
1687 /* drop link after 5 times MSE threshold was reached */
1688 ret_val = hw->phy.ops.write_reg_locked(hw, I82579_EMI_DATA, 0x0005);
1689release:
1690 hw->phy.ops.release(hw);
1691
1672out: 1692out:
1673 return ret_val; 1693 return ret_val;
1674} 1694}
@@ -1741,7 +1761,6 @@ static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
1741 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG; 1761 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
1742 1762
1743 ew32(EXTCNF_CTRL, extcnf_ctrl); 1763 ew32(EXTCNF_CTRL, extcnf_ctrl);
1744 return;
1745} 1764}
1746 1765
1747/** 1766/**
@@ -1899,7 +1918,9 @@ static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
1899 else 1918 else
1900 oem_reg &= ~HV_OEM_BITS_LPLU; 1919 oem_reg &= ~HV_OEM_BITS_LPLU;
1901 1920
1902 oem_reg |= HV_OEM_BITS_RESTART_AN; 1921 if (!e1000_check_reset_block(hw))
1922 oem_reg |= HV_OEM_BITS_RESTART_AN;
1923
1903 ret_val = e1e_wphy(hw, HV_OEM_BITS, oem_reg); 1924 ret_val = e1e_wphy(hw, HV_OEM_BITS, oem_reg);
1904 1925
1905out: 1926out:
@@ -2108,8 +2129,7 @@ static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
2108 2129
2109 return 0; 2130 return 0;
2110 } 2131 }
2111 e_dbg("Unable to determine valid NVM bank via EEC - " 2132 e_dbg("Unable to determine valid NVM bank via EEC - reading flash signature\n");
2112 "reading flash signature\n");
2113 /* fall-thru */ 2133 /* fall-thru */
2114 default: 2134 default:
2115 /* set bank to 0 in case flash read fails */ 2135 /* set bank to 0 in case flash read fails */
@@ -2221,8 +2241,7 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
2221 2241
2222 /* Check if the flash descriptor is valid */ 2242 /* Check if the flash descriptor is valid */
2223 if (hsfsts.hsf_status.fldesvalid == 0) { 2243 if (hsfsts.hsf_status.fldesvalid == 0) {
2224 e_dbg("Flash descriptor invalid. " 2244 e_dbg("Flash descriptor invalid. SW Sequencing must be used.\n");
2225 "SW Sequencing must be used.\n");
2226 return -E1000_ERR_NVM; 2245 return -E1000_ERR_NVM;
2227 } 2246 }
2228 2247
@@ -2258,14 +2277,14 @@ static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
2258 * cycle has a chance to end before giving up. 2277 * cycle has a chance to end before giving up.
2259 */ 2278 */
2260 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) { 2279 for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
2261 hsfsts.regval = __er16flash(hw, ICH_FLASH_HSFSTS); 2280 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
2262 if (hsfsts.hsf_status.flcinprog == 0) { 2281 if (hsfsts.hsf_status.flcinprog == 0) {
2263 ret_val = 0; 2282 ret_val = 0;
2264 break; 2283 break;
2265 } 2284 }
2266 udelay(1); 2285 udelay(1);
2267 } 2286 }
2268 if (ret_val == 0) { 2287 if (!ret_val) {
2269 /* 2288 /*
2270 * Successful in waiting for previous cycle to timeout, 2289 * Successful in waiting for previous cycle to timeout,
2271 * now set the Flash Cycle Done. 2290 * now set the Flash Cycle Done.
@@ -2383,7 +2402,7 @@ static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2383 udelay(1); 2402 udelay(1);
2384 /* Steps */ 2403 /* Steps */
2385 ret_val = e1000_flash_cycle_init_ich8lan(hw); 2404 ret_val = e1000_flash_cycle_init_ich8lan(hw);
2386 if (ret_val != 0) 2405 if (ret_val)
2387 break; 2406 break;
2388 2407
2389 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); 2408 hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
@@ -2403,7 +2422,7 @@ static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2403 * read in (shift in) the Flash Data0, the order is 2422 * read in (shift in) the Flash Data0, the order is
2404 * least significant byte first msb to lsb 2423 * least significant byte first msb to lsb
2405 */ 2424 */
2406 if (ret_val == 0) { 2425 if (!ret_val) {
2407 flash_data = er32flash(ICH_FLASH_FDATA0); 2426 flash_data = er32flash(ICH_FLASH_FDATA0);
2408 if (size == 1) 2427 if (size == 1)
2409 *data = (u8)(flash_data & 0x000000FF); 2428 *data = (u8)(flash_data & 0x000000FF);
@@ -2422,8 +2441,7 @@ static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2422 /* Repeat for some time before giving up. */ 2441 /* Repeat for some time before giving up. */
2423 continue; 2442 continue;
2424 } else if (hsfsts.hsf_status.flcdone == 0) { 2443 } else if (hsfsts.hsf_status.flcdone == 0) {
2425 e_dbg("Timeout error - flash cycle " 2444 e_dbg("Timeout error - flash cycle did not complete.\n");
2426 "did not complete.\n");
2427 break; 2445 break;
2428 } 2446 }
2429 } 2447 }
@@ -2774,8 +2792,7 @@ static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
2774 /* Repeat for some time before giving up. */ 2792 /* Repeat for some time before giving up. */
2775 continue; 2793 continue;
2776 if (hsfsts.hsf_status.flcdone == 0) { 2794 if (hsfsts.hsf_status.flcdone == 0) {
2777 e_dbg("Timeout error - flash cycle " 2795 e_dbg("Timeout error - flash cycle did not complete.\n");
2778 "did not complete.");
2779 break; 2796 break;
2780 } 2797 }
2781 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT); 2798 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
@@ -2917,7 +2934,7 @@ static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
2917 2934
2918 ret_val = e1000_flash_cycle_ich8lan(hw, 2935 ret_val = e1000_flash_cycle_ich8lan(hw,
2919 ICH_FLASH_ERASE_COMMAND_TIMEOUT); 2936 ICH_FLASH_ERASE_COMMAND_TIMEOUT);
2920 if (ret_val == 0) 2937 if (!ret_val)
2921 break; 2938 break;
2922 2939
2923 /* 2940 /*
@@ -3676,9 +3693,10 @@ void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
3676 * 3693 *
3677 * During S0 to Sx transition, it is possible the link remains at gig 3694 * During S0 to Sx transition, it is possible the link remains at gig
3678 * instead of negotiating to a lower speed. Before going to Sx, set 3695 * instead of negotiating to a lower speed. Before going to Sx, set
3679 * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation 3696 * 'Gig Disable' to force link speed negotiation to a lower speed based on
3680 * to a lower speed. For PCH and newer parts, the OEM bits PHY register 3697 * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
3681 * (LED, GbE disable and LPLU configurations) also needs to be written. 3698 * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
3699 * needs to be written.
3682 **/ 3700 **/
3683void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw) 3701void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
3684{ 3702{
@@ -3686,7 +3704,7 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
3686 s32 ret_val; 3704 s32 ret_val;
3687 3705
3688 phy_ctrl = er32(PHY_CTRL); 3706 phy_ctrl = er32(PHY_CTRL);
3689 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU | E1000_PHY_CTRL_GBE_DISABLE; 3707 phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
3690 ew32(PHY_CTRL, phy_ctrl); 3708 ew32(PHY_CTRL, phy_ctrl);
3691 3709
3692 if (hw->mac.type == e1000_ich8lan) 3710 if (hw->mac.type == e1000_ich8lan)
@@ -3714,47 +3732,40 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
3714 **/ 3732 **/
3715void e1000_resume_workarounds_pchlan(struct e1000_hw *hw) 3733void e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
3716{ 3734{
3717 u32 fwsm; 3735 u16 phy_id1, phy_id2;
3736 s32 ret_val;
3718 3737
3719 if (hw->mac.type != e1000_pch2lan) 3738 if ((hw->mac.type != e1000_pch2lan) || e1000_check_reset_block(hw))
3720 return; 3739 return;
3721 3740
3722 fwsm = er32(FWSM); 3741 ret_val = hw->phy.ops.acquire(hw);
3723 if (!(fwsm & E1000_ICH_FWSM_FW_VALID) || !e1000_check_reset_block(hw)) { 3742 if (ret_val) {
3724 u16 phy_id1, phy_id2; 3743 e_dbg("Failed to acquire PHY semaphore in resume\n");
3725 s32 ret_val; 3744 return;
3726 3745 }
3727 ret_val = hw->phy.ops.acquire(hw);
3728 if (ret_val) {
3729 e_dbg("Failed to acquire PHY semaphore in resume\n");
3730 return;
3731 }
3732 3746
3733 /* Test access to the PHY registers by reading the ID regs */ 3747 /* Test access to the PHY registers by reading the ID regs */
3734 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID1, &phy_id1); 3748 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID1, &phy_id1);
3735 if (ret_val) 3749 if (ret_val)
3736 goto release; 3750 goto release;
3737 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID2, &phy_id2); 3751 ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID2, &phy_id2);
3738 if (ret_val) 3752 if (ret_val)
3739 goto release; 3753 goto release;
3740 3754
3741 if (hw->phy.id == ((u32)(phy_id1 << 16) | 3755 if (hw->phy.id == ((u32)(phy_id1 << 16) |
3742 (u32)(phy_id2 & PHY_REVISION_MASK))) 3756 (u32)(phy_id2 & PHY_REVISION_MASK)))
3743 goto release; 3757 goto release;
3744 3758
3745 e1000_toggle_lanphypc_value_ich8lan(hw); 3759 e1000_toggle_lanphypc_value_ich8lan(hw);
3746 3760
3747 hw->phy.ops.release(hw); 3761 hw->phy.ops.release(hw);
3748 msleep(50); 3762 msleep(50);
3749 e1000_phy_hw_reset(hw); 3763 e1000_phy_hw_reset(hw);
3750 msleep(50); 3764 msleep(50);
3751 return; 3765 return;
3752 }
3753 3766
3754release: 3767release:
3755 hw->phy.ops.release(hw); 3768 hw->phy.ops.release(hw);
3756
3757 return;
3758} 3769}
3759 3770
3760/** 3771/**
@@ -4088,10 +4099,9 @@ const struct e1000_info e1000_ich9_info = {
4088 | FLAG_HAS_WOL 4099 | FLAG_HAS_WOL
4089 | FLAG_HAS_CTRLEXT_ON_LOAD 4100 | FLAG_HAS_CTRLEXT_ON_LOAD
4090 | FLAG_HAS_AMT 4101 | FLAG_HAS_AMT
4091 | FLAG_HAS_ERT
4092 | FLAG_HAS_FLASH 4102 | FLAG_HAS_FLASH
4093 | FLAG_APME_IN_WUC, 4103 | FLAG_APME_IN_WUC,
4094 .pba = 10, 4104 .pba = 18,
4095 .max_hw_frame_size = DEFAULT_JUMBO, 4105 .max_hw_frame_size = DEFAULT_JUMBO,
4096 .get_variants = e1000_get_variants_ich8lan, 4106 .get_variants = e1000_get_variants_ich8lan,
4097 .mac_ops = &ich8_mac_ops, 4107 .mac_ops = &ich8_mac_ops,
@@ -4106,10 +4116,9 @@ const struct e1000_info e1000_ich10_info = {
4106 | FLAG_HAS_WOL 4116 | FLAG_HAS_WOL
4107 | FLAG_HAS_CTRLEXT_ON_LOAD 4117 | FLAG_HAS_CTRLEXT_ON_LOAD
4108 | FLAG_HAS_AMT 4118 | FLAG_HAS_AMT
4109 | FLAG_HAS_ERT
4110 | FLAG_HAS_FLASH 4119 | FLAG_HAS_FLASH
4111 | FLAG_APME_IN_WUC, 4120 | FLAG_APME_IN_WUC,
4112 .pba = 10, 4121 .pba = 18,
4113 .max_hw_frame_size = DEFAULT_JUMBO, 4122 .max_hw_frame_size = DEFAULT_JUMBO,
4114 .get_variants = e1000_get_variants_ich8lan, 4123 .get_variants = e1000_get_variants_ich8lan,
4115 .mac_ops = &ich8_mac_ops, 4124 .mac_ops = &ich8_mac_ops,
diff --git a/drivers/net/ethernet/intel/e1000e/lib.c b/drivers/net/ethernet/intel/e1000e/mac.c
index 0893ab107adf..83f93684dc2f 100644
--- a/drivers/net/ethernet/intel/e1000e/lib.c
+++ b/drivers/net/ethernet/intel/e1000e/mac.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2011 Intel Corporation. 4 Copyright(c) 1999 - 2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -28,19 +28,6 @@
28 28
29#include "e1000.h" 29#include "e1000.h"
30 30
31enum e1000_mng_mode {
32 e1000_mng_mode_none = 0,
33 e1000_mng_mode_asf,
34 e1000_mng_mode_pt,
35 e1000_mng_mode_ipmi,
36 e1000_mng_mode_host_if_only
37};
38
39#define E1000_FACTPS_MNGCG 0x20000000
40
41/* Intel(R) Active Management Technology signature */
42#define E1000_IAMT_SIGNATURE 0x544D4149
43
44/** 31/**
45 * e1000e_get_bus_info_pcie - Get PCIe bus information 32 * e1000e_get_bus_info_pcie - Get PCIe bus information
46 * @hw: pointer to the HW structure 33 * @hw: pointer to the HW structure
@@ -151,7 +138,7 @@ void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value)
151void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count) 138void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count)
152{ 139{
153 u32 i; 140 u32 i;
154 u8 mac_addr[ETH_ALEN] = {0}; 141 u8 mac_addr[ETH_ALEN] = { 0 };
155 142
156 /* Setup the receive address */ 143 /* Setup the receive address */
157 e_dbg("Programming MAC Address into RAR[0]\n"); 144 e_dbg("Programming MAC Address into RAR[0]\n");
@@ -159,7 +146,7 @@ void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count)
159 e1000e_rar_set(hw, hw->mac.addr, 0); 146 e1000e_rar_set(hw, hw->mac.addr, 0);
160 147
161 /* Zero out the other (rar_entry_count - 1) receive addresses */ 148 /* Zero out the other (rar_entry_count - 1) receive addresses */
162 e_dbg("Clearing RAR[1-%u]\n", rar_count-1); 149 e_dbg("Clearing RAR[1-%u]\n", rar_count - 1);
163 for (i = 1; i < rar_count; i++) 150 for (i = 1; i < rar_count; i++)
164 e1000e_rar_set(hw, mac_addr, i); 151 e1000e_rar_set(hw, mac_addr, i);
165} 152}
@@ -187,15 +174,12 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)
187 if (ret_val) 174 if (ret_val)
188 goto out; 175 goto out;
189 176
190 /* Check for LOM (vs. NIC) or one of two valid mezzanine cards */ 177 /* not supported on 82573 */
191 if (!((nvm_data & NVM_COMPAT_LOM) || 178 if (hw->mac.type == e1000_82573)
192 (hw->adapter->pdev->device == E1000_DEV_ID_82571EB_SERDES_DUAL) ||
193 (hw->adapter->pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD) ||
194 (hw->adapter->pdev->device == E1000_DEV_ID_82571EB_SERDES)))
195 goto out; 179 goto out;
196 180
197 ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1, 181 ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1,
198 &nvm_alt_mac_addr_offset); 182 &nvm_alt_mac_addr_offset);
199 if (ret_val) { 183 if (ret_val) {
200 e_dbg("NVM Read Error\n"); 184 e_dbg("NVM Read Error\n");
201 goto out; 185 goto out;
@@ -254,11 +238,10 @@ void e1000e_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
254 * HW expects these in little endian so we reverse the byte order 238 * HW expects these in little endian so we reverse the byte order
255 * from network order (big endian) to little endian 239 * from network order (big endian) to little endian
256 */ 240 */
257 rar_low = ((u32) addr[0] | 241 rar_low = ((u32)addr[0] | ((u32)addr[1] << 8) |
258 ((u32) addr[1] << 8) | 242 ((u32)addr[2] << 16) | ((u32)addr[3] << 24));
259 ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
260 243
261 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8)); 244 rar_high = ((u32)addr[4] | ((u32)addr[5] << 8));
262 245
263 /* If MAC address zero, no need to set the AV bit */ 246 /* If MAC address zero, no need to set the AV bit */
264 if (rar_low || rar_high) 247 if (rar_low || rar_high)
@@ -318,7 +301,7 @@ static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
318 * values resulting from each mc_filter_type... 301 * values resulting from each mc_filter_type...
319 * [0] [1] [2] [3] [4] [5] 302 * [0] [1] [2] [3] [4] [5]
320 * 01 AA 00 12 34 56 303 * 01 AA 00 12 34 56
321 * LSB MSB 304 * LSB MSB
322 * 305 *
323 * case 0: hash_value = ((0x34 >> 4) | (0x56 << 4)) & 0xFFF = 0x563 306 * case 0: hash_value = ((0x34 >> 4) | (0x56 << 4)) & 0xFFF = 0x563
324 * case 1: hash_value = ((0x34 >> 3) | (0x56 << 5)) & 0xFFF = 0xAC6 307 * case 1: hash_value = ((0x34 >> 3) | (0x56 << 5)) & 0xFFF = 0xAC6
@@ -341,7 +324,7 @@ static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
341 } 324 }
342 325
343 hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) | 326 hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |
344 (((u16) mc_addr[5]) << bit_shift))); 327 (((u16)mc_addr[5]) << bit_shift)));
345 328
346 return hash_value; 329 return hash_value;
347} 330}
@@ -365,7 +348,7 @@ void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw,
365 memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow)); 348 memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow));
366 349
367 /* update mta_shadow from mc_addr_list */ 350 /* update mta_shadow from mc_addr_list */
368 for (i = 0; (u32) i < mc_addr_count; i++) { 351 for (i = 0; (u32)i < mc_addr_count; i++) {
369 hash_value = e1000_hash_mc_addr(hw, mc_addr_list); 352 hash_value = e1000_hash_mc_addr(hw, mc_addr_list);
370 353
371 hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1); 354 hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1);
@@ -461,7 +444,7 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
461 return ret_val; 444 return ret_val;
462 445
463 if (!link) 446 if (!link)
464 return ret_val; /* No link detected */ 447 return ret_val; /* No link detected */
465 448
466 mac->get_link_status = false; 449 mac->get_link_status = false;
467 450
@@ -528,10 +511,10 @@ s32 e1000e_check_for_fiber_link(struct e1000_hw *hw)
528 * was just plugged in. The autoneg_failed flag does this. 511 * was just plugged in. The autoneg_failed flag does this.
529 */ 512 */
530 /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */ 513 /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */
531 if ((ctrl & E1000_CTRL_SWDPIN1) && (!(status & E1000_STATUS_LU)) && 514 if ((ctrl & E1000_CTRL_SWDPIN1) && !(status & E1000_STATUS_LU) &&
532 (!(rxcw & E1000_RXCW_C))) { 515 !(rxcw & E1000_RXCW_C)) {
533 if (mac->autoneg_failed == 0) { 516 if (!mac->autoneg_failed) {
534 mac->autoneg_failed = 1; 517 mac->autoneg_failed = true;
535 return 0; 518 return 0;
536 } 519 }
537 e_dbg("NOT Rx'ing /C/, disable AutoNeg and force link.\n"); 520 e_dbg("NOT Rx'ing /C/, disable AutoNeg and force link.\n");
@@ -594,9 +577,9 @@ s32 e1000e_check_for_serdes_link(struct e1000_hw *hw)
594 * time to complete. 577 * time to complete.
595 */ 578 */
596 /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */ 579 /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */
597 if ((!(status & E1000_STATUS_LU)) && (!(rxcw & E1000_RXCW_C))) { 580 if (!(status & E1000_STATUS_LU) && !(rxcw & E1000_RXCW_C)) {
598 if (mac->autoneg_failed == 0) { 581 if (!mac->autoneg_failed) {
599 mac->autoneg_failed = 1; 582 mac->autoneg_failed = true;
600 return 0; 583 return 0;
601 } 584 }
602 e_dbg("NOT Rx'ing /C/, disable AutoNeg and force link.\n"); 585 e_dbg("NOT Rx'ing /C/, disable AutoNeg and force link.\n");
@@ -656,12 +639,10 @@ s32 e1000e_check_for_serdes_link(struct e1000_hw *hw)
656 if (rxcw & E1000_RXCW_SYNCH) { 639 if (rxcw & E1000_RXCW_SYNCH) {
657 if (!(rxcw & E1000_RXCW_IV)) { 640 if (!(rxcw & E1000_RXCW_IV)) {
658 mac->serdes_has_link = true; 641 mac->serdes_has_link = true;
659 e_dbg("SERDES: Link up - autoneg " 642 e_dbg("SERDES: Link up - autoneg completed successfully.\n");
660 "completed successfully.\n");
661 } else { 643 } else {
662 mac->serdes_has_link = false; 644 mac->serdes_has_link = false;
663 e_dbg("SERDES: Link down - invalid" 645 e_dbg("SERDES: Link down - invalid codewords detected in autoneg.\n");
664 "codewords detected in autoneg.\n");
665 } 646 }
666 } else { 647 } else {
667 mac->serdes_has_link = false; 648 mac->serdes_has_link = false;
@@ -706,8 +687,7 @@ static s32 e1000_set_default_fc_generic(struct e1000_hw *hw)
706 687
707 if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 0) 688 if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 0)
708 hw->fc.requested_mode = e1000_fc_none; 689 hw->fc.requested_mode = e1000_fc_none;
709 else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 690 else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == NVM_WORD0F_ASM_DIR)
710 NVM_WORD0F_ASM_DIR)
711 hw->fc.requested_mode = e1000_fc_tx_pause; 691 hw->fc.requested_mode = e1000_fc_tx_pause;
712 else 692 else
713 hw->fc.requested_mode = e1000_fc_full; 693 hw->fc.requested_mode = e1000_fc_full;
@@ -753,8 +733,7 @@ s32 e1000e_setup_link(struct e1000_hw *hw)
753 */ 733 */
754 hw->fc.current_mode = hw->fc.requested_mode; 734 hw->fc.current_mode = hw->fc.requested_mode;
755 735
756 e_dbg("After fix-ups FlowControl is now = %x\n", 736 e_dbg("After fix-ups FlowControl is now = %x\n", hw->fc.current_mode);
757 hw->fc.current_mode);
758 737
759 /* Call the necessary media_type subroutine to configure the link. */ 738 /* Call the necessary media_type subroutine to configure the link. */
760 ret_val = mac->ops.setup_physical_interface(hw); 739 ret_val = mac->ops.setup_physical_interface(hw);
@@ -876,7 +855,7 @@ static s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw)
876 } 855 }
877 if (i == FIBER_LINK_UP_LIMIT) { 856 if (i == FIBER_LINK_UP_LIMIT) {
878 e_dbg("Never got a valid link from auto-neg!!!\n"); 857 e_dbg("Never got a valid link from auto-neg!!!\n");
879 mac->autoneg_failed = 1; 858 mac->autoneg_failed = true;
880 /* 859 /*
881 * AutoNeg failed to achieve a link, so we'll call 860 * AutoNeg failed to achieve a link, so we'll call
882 * mac->check_for_link. This routine will force the 861 * mac->check_for_link. This routine will force the
@@ -888,9 +867,9 @@ static s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw)
888 e_dbg("Error while checking for link\n"); 867 e_dbg("Error while checking for link\n");
889 return ret_val; 868 return ret_val;
890 } 869 }
891 mac->autoneg_failed = 0; 870 mac->autoneg_failed = false;
892 } else { 871 } else {
893 mac->autoneg_failed = 0; 872 mac->autoneg_failed = false;
894 e_dbg("Valid Link Found\n"); 873 e_dbg("Valid Link Found\n");
895 } 874 }
896 875
@@ -1121,8 +1100,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
1121 return ret_val; 1100 return ret_val;
1122 1101
1123 if (!(mii_status_reg & MII_SR_AUTONEG_COMPLETE)) { 1102 if (!(mii_status_reg & MII_SR_AUTONEG_COMPLETE)) {
1124 e_dbg("Copper PHY and Auto Neg " 1103 e_dbg("Copper PHY and Auto Neg has not completed.\n");
1125 "has not completed.\n");
1126 return ret_val; 1104 return ret_val;
1127 } 1105 }
1128 1106
@@ -1186,11 +1164,10 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
1186 */ 1164 */
1187 if (hw->fc.requested_mode == e1000_fc_full) { 1165 if (hw->fc.requested_mode == e1000_fc_full) {
1188 hw->fc.current_mode = e1000_fc_full; 1166 hw->fc.current_mode = e1000_fc_full;
1189 e_dbg("Flow Control = FULL.\r\n"); 1167 e_dbg("Flow Control = FULL.\n");
1190 } else { 1168 } else {
1191 hw->fc.current_mode = e1000_fc_rx_pause; 1169 hw->fc.current_mode = e1000_fc_rx_pause;
1192 e_dbg("Flow Control = " 1170 e_dbg("Flow Control = Rx PAUSE frames only.\n");
1193 "Rx PAUSE frames only.\r\n");
1194 } 1171 }
1195 } 1172 }
1196 /* 1173 /*
@@ -1202,11 +1179,11 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
1202 * 0 | 1 | 1 | 1 | e1000_fc_tx_pause 1179 * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
1203 */ 1180 */
1204 else if (!(mii_nway_adv_reg & NWAY_AR_PAUSE) && 1181 else if (!(mii_nway_adv_reg & NWAY_AR_PAUSE) &&
1205 (mii_nway_adv_reg & NWAY_AR_ASM_DIR) && 1182 (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
1206 (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && 1183 (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
1207 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { 1184 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
1208 hw->fc.current_mode = e1000_fc_tx_pause; 1185 hw->fc.current_mode = e1000_fc_tx_pause;
1209 e_dbg("Flow Control = Tx PAUSE frames only.\r\n"); 1186 e_dbg("Flow Control = Tx PAUSE frames only.\n");
1210 } 1187 }
1211 /* 1188 /*
1212 * For transmitting PAUSE frames ONLY. 1189 * For transmitting PAUSE frames ONLY.
@@ -1221,14 +1198,14 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
1221 !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && 1198 !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
1222 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { 1199 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
1223 hw->fc.current_mode = e1000_fc_rx_pause; 1200 hw->fc.current_mode = e1000_fc_rx_pause;
1224 e_dbg("Flow Control = Rx PAUSE frames only.\r\n"); 1201 e_dbg("Flow Control = Rx PAUSE frames only.\n");
1225 } else { 1202 } else {
1226 /* 1203 /*
1227 * Per the IEEE spec, at this point flow control 1204 * Per the IEEE spec, at this point flow control
1228 * should be disabled. 1205 * should be disabled.
1229 */ 1206 */
1230 hw->fc.current_mode = e1000_fc_none; 1207 hw->fc.current_mode = e1000_fc_none;
1231 e_dbg("Flow Control = NONE.\r\n"); 1208 e_dbg("Flow Control = NONE.\n");
1232 } 1209 }
1233 1210
1234 /* 1211 /*
@@ -1268,7 +1245,8 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
1268 * Read the status register for the current speed/duplex and store the current 1245 * Read the status register for the current speed/duplex and store the current
1269 * speed and duplex for copper connections. 1246 * speed and duplex for copper connections.
1270 **/ 1247 **/
1271s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *duplex) 1248s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed,
1249 u16 *duplex)
1272{ 1250{
1273 u32 status; 1251 u32 status;
1274 1252
@@ -1301,7 +1279,8 @@ s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *dup
1301 * Sets the speed and duplex to gigabit full duplex (the only possible option) 1279 * Sets the speed and duplex to gigabit full duplex (the only possible option)
1302 * for fiber/serdes links. 1280 * for fiber/serdes links.
1303 **/ 1281 **/
1304s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 *duplex) 1282s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed,
1283 u16 *duplex)
1305{ 1284{
1306 *speed = SPEED_1000; 1285 *speed = SPEED_1000;
1307 *duplex = FULL_DUPLEX; 1286 *duplex = FULL_DUPLEX;
@@ -1504,11 +1483,10 @@ s32 e1000e_setup_led_generic(struct e1000_hw *hw)
1504 ledctl = er32(LEDCTL); 1483 ledctl = er32(LEDCTL);
1505 hw->mac.ledctl_default = ledctl; 1484 hw->mac.ledctl_default = ledctl;
1506 /* Turn off LED0 */ 1485 /* Turn off LED0 */
1507 ledctl &= ~(E1000_LEDCTL_LED0_IVRT | 1486 ledctl &= ~(E1000_LEDCTL_LED0_IVRT | E1000_LEDCTL_LED0_BLINK |
1508 E1000_LEDCTL_LED0_BLINK | 1487 E1000_LEDCTL_LED0_MODE_MASK);
1509 E1000_LEDCTL_LED0_MODE_MASK);
1510 ledctl |= (E1000_LEDCTL_MODE_LED_OFF << 1488 ledctl |= (E1000_LEDCTL_MODE_LED_OFF <<
1511 E1000_LEDCTL_LED0_MODE_SHIFT); 1489 E1000_LEDCTL_LED0_MODE_SHIFT);
1512 ew32(LEDCTL, ledctl); 1490 ew32(LEDCTL, ledctl);
1513 } else if (hw->phy.media_type == e1000_media_type_copper) { 1491 } else if (hw->phy.media_type == e1000_media_type_copper) {
1514 ew32(LEDCTL, hw->mac.ledctl_mode1); 1492 ew32(LEDCTL, hw->mac.ledctl_mode1);
@@ -1544,7 +1522,7 @@ s32 e1000e_blink_led_generic(struct e1000_hw *hw)
1544 if (hw->phy.media_type == e1000_media_type_fiber) { 1522 if (hw->phy.media_type == e1000_media_type_fiber) {
1545 /* always blink LED0 for PCI-E fiber */ 1523 /* always blink LED0 for PCI-E fiber */
1546 ledctl_blink = E1000_LEDCTL_LED0_BLINK | 1524 ledctl_blink = E1000_LEDCTL_LED0_BLINK |
1547 (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT); 1525 (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT);
1548 } else { 1526 } else {
1549 /* 1527 /*
1550 * set the blink bit for each LED that's "on" (0x0E) 1528 * set the blink bit for each LED that's "on" (0x0E)
@@ -1657,8 +1635,7 @@ s32 e1000e_disable_pcie_master(struct e1000_hw *hw)
1657 ew32(CTRL, ctrl); 1635 ew32(CTRL, ctrl);
1658 1636
1659 while (timeout) { 1637 while (timeout) {
1660 if (!(er32(STATUS) & 1638 if (!(er32(STATUS) & E1000_STATUS_GIO_MASTER_ENABLE))
1661 E1000_STATUS_GIO_MASTER_ENABLE))
1662 break; 1639 break;
1663 udelay(100); 1640 udelay(100);
1664 timeout--; 1641 timeout--;
@@ -1684,7 +1661,7 @@ void e1000e_reset_adaptive(struct e1000_hw *hw)
1684 1661
1685 if (!mac->adaptive_ifs) { 1662 if (!mac->adaptive_ifs) {
1686 e_dbg("Not in Adaptive IFS mode!\n"); 1663 e_dbg("Not in Adaptive IFS mode!\n");
1687 goto out; 1664 return;
1688 } 1665 }
1689 1666
1690 mac->current_ifs_val = 0; 1667 mac->current_ifs_val = 0;
@@ -1695,8 +1672,6 @@ void e1000e_reset_adaptive(struct e1000_hw *hw)
1695 1672
1696 mac->in_ifs_mode = false; 1673 mac->in_ifs_mode = false;
1697 ew32(AIT, 0); 1674 ew32(AIT, 0);
1698out:
1699 return;
1700} 1675}
1701 1676
1702/** 1677/**
@@ -1712,7 +1687,7 @@ void e1000e_update_adaptive(struct e1000_hw *hw)
1712 1687
1713 if (!mac->adaptive_ifs) { 1688 if (!mac->adaptive_ifs) {
1714 e_dbg("Not in Adaptive IFS mode!\n"); 1689 e_dbg("Not in Adaptive IFS mode!\n");
1715 goto out; 1690 return;
1716 } 1691 }
1717 1692
1718 if ((mac->collision_delta * mac->ifs_ratio) > mac->tx_packet_delta) { 1693 if ((mac->collision_delta * mac->ifs_ratio) > mac->tx_packet_delta) {
@@ -1723,7 +1698,7 @@ void e1000e_update_adaptive(struct e1000_hw *hw)
1723 mac->current_ifs_val = mac->ifs_min_val; 1698 mac->current_ifs_val = mac->ifs_min_val;
1724 else 1699 else
1725 mac->current_ifs_val += 1700 mac->current_ifs_val +=
1726 mac->ifs_step_size; 1701 mac->ifs_step_size;
1727 ew32(AIT, mac->current_ifs_val); 1702 ew32(AIT, mac->current_ifs_val);
1728 } 1703 }
1729 } 1704 }
@@ -1735,959 +1710,4 @@ void e1000e_update_adaptive(struct e1000_hw *hw)
1735 ew32(AIT, 0); 1710 ew32(AIT, 0);
1736 } 1711 }
1737 } 1712 }
1738out:
1739 return;
1740}
1741
1742/**
1743 * e1000_raise_eec_clk - Raise EEPROM clock
1744 * @hw: pointer to the HW structure
1745 * @eecd: pointer to the EEPROM
1746 *
1747 * Enable/Raise the EEPROM clock bit.
1748 **/
1749static void e1000_raise_eec_clk(struct e1000_hw *hw, u32 *eecd)
1750{
1751 *eecd = *eecd | E1000_EECD_SK;
1752 ew32(EECD, *eecd);
1753 e1e_flush();
1754 udelay(hw->nvm.delay_usec);
1755}
1756
1757/**
1758 * e1000_lower_eec_clk - Lower EEPROM clock
1759 * @hw: pointer to the HW structure
1760 * @eecd: pointer to the EEPROM
1761 *
1762 * Clear/Lower the EEPROM clock bit.
1763 **/
1764static void e1000_lower_eec_clk(struct e1000_hw *hw, u32 *eecd)
1765{
1766 *eecd = *eecd & ~E1000_EECD_SK;
1767 ew32(EECD, *eecd);
1768 e1e_flush();
1769 udelay(hw->nvm.delay_usec);
1770}
1771
1772/**
1773 * e1000_shift_out_eec_bits - Shift data bits our to the EEPROM
1774 * @hw: pointer to the HW structure
1775 * @data: data to send to the EEPROM
1776 * @count: number of bits to shift out
1777 *
1778 * We need to shift 'count' bits out to the EEPROM. So, the value in the
1779 * "data" parameter will be shifted out to the EEPROM one bit at a time.
1780 * In order to do this, "data" must be broken down into bits.
1781 **/
1782static void e1000_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count)
1783{
1784 struct e1000_nvm_info *nvm = &hw->nvm;
1785 u32 eecd = er32(EECD);
1786 u32 mask;
1787
1788 mask = 0x01 << (count - 1);
1789 if (nvm->type == e1000_nvm_eeprom_spi)
1790 eecd |= E1000_EECD_DO;
1791
1792 do {
1793 eecd &= ~E1000_EECD_DI;
1794
1795 if (data & mask)
1796 eecd |= E1000_EECD_DI;
1797
1798 ew32(EECD, eecd);
1799 e1e_flush();
1800
1801 udelay(nvm->delay_usec);
1802
1803 e1000_raise_eec_clk(hw, &eecd);
1804 e1000_lower_eec_clk(hw, &eecd);
1805
1806 mask >>= 1;
1807 } while (mask);
1808
1809 eecd &= ~E1000_EECD_DI;
1810 ew32(EECD, eecd);
1811}
1812
1813/**
1814 * e1000_shift_in_eec_bits - Shift data bits in from the EEPROM
1815 * @hw: pointer to the HW structure
1816 * @count: number of bits to shift in
1817 *
1818 * In order to read a register from the EEPROM, we need to shift 'count' bits
1819 * in from the EEPROM. Bits are "shifted in" by raising the clock input to
1820 * the EEPROM (setting the SK bit), and then reading the value of the data out
1821 * "DO" bit. During this "shifting in" process the data in "DI" bit should
1822 * always be clear.
1823 **/
1824static u16 e1000_shift_in_eec_bits(struct e1000_hw *hw, u16 count)
1825{
1826 u32 eecd;
1827 u32 i;
1828 u16 data;
1829
1830 eecd = er32(EECD);
1831
1832 eecd &= ~(E1000_EECD_DO | E1000_EECD_DI);
1833 data = 0;
1834
1835 for (i = 0; i < count; i++) {
1836 data <<= 1;
1837 e1000_raise_eec_clk(hw, &eecd);
1838
1839 eecd = er32(EECD);
1840
1841 eecd &= ~E1000_EECD_DI;
1842 if (eecd & E1000_EECD_DO)
1843 data |= 1;
1844
1845 e1000_lower_eec_clk(hw, &eecd);
1846 }
1847
1848 return data;
1849}
1850
1851/**
1852 * e1000e_poll_eerd_eewr_done - Poll for EEPROM read/write completion
1853 * @hw: pointer to the HW structure
1854 * @ee_reg: EEPROM flag for polling
1855 *
1856 * Polls the EEPROM status bit for either read or write completion based
1857 * upon the value of 'ee_reg'.
1858 **/
1859s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg)
1860{
1861 u32 attempts = 100000;
1862 u32 i, reg = 0;
1863
1864 for (i = 0; i < attempts; i++) {
1865 if (ee_reg == E1000_NVM_POLL_READ)
1866 reg = er32(EERD);
1867 else
1868 reg = er32(EEWR);
1869
1870 if (reg & E1000_NVM_RW_REG_DONE)
1871 return 0;
1872
1873 udelay(5);
1874 }
1875
1876 return -E1000_ERR_NVM;
1877}
1878
1879/**
1880 * e1000e_acquire_nvm - Generic request for access to EEPROM
1881 * @hw: pointer to the HW structure
1882 *
1883 * Set the EEPROM access request bit and wait for EEPROM access grant bit.
1884 * Return successful if access grant bit set, else clear the request for
1885 * EEPROM access and return -E1000_ERR_NVM (-1).
1886 **/
1887s32 e1000e_acquire_nvm(struct e1000_hw *hw)
1888{
1889 u32 eecd = er32(EECD);
1890 s32 timeout = E1000_NVM_GRANT_ATTEMPTS;
1891
1892 ew32(EECD, eecd | E1000_EECD_REQ);
1893 eecd = er32(EECD);
1894
1895 while (timeout) {
1896 if (eecd & E1000_EECD_GNT)
1897 break;
1898 udelay(5);
1899 eecd = er32(EECD);
1900 timeout--;
1901 }
1902
1903 if (!timeout) {
1904 eecd &= ~E1000_EECD_REQ;
1905 ew32(EECD, eecd);
1906 e_dbg("Could not acquire NVM grant\n");
1907 return -E1000_ERR_NVM;
1908 }
1909
1910 return 0;
1911}
1912
1913/**
1914 * e1000_standby_nvm - Return EEPROM to standby state
1915 * @hw: pointer to the HW structure
1916 *
1917 * Return the EEPROM to a standby state.
1918 **/
1919static void e1000_standby_nvm(struct e1000_hw *hw)
1920{
1921 struct e1000_nvm_info *nvm = &hw->nvm;
1922 u32 eecd = er32(EECD);
1923
1924 if (nvm->type == e1000_nvm_eeprom_spi) {
1925 /* Toggle CS to flush commands */
1926 eecd |= E1000_EECD_CS;
1927 ew32(EECD, eecd);
1928 e1e_flush();
1929 udelay(nvm->delay_usec);
1930 eecd &= ~E1000_EECD_CS;
1931 ew32(EECD, eecd);
1932 e1e_flush();
1933 udelay(nvm->delay_usec);
1934 }
1935}
1936
1937/**
1938 * e1000_stop_nvm - Terminate EEPROM command
1939 * @hw: pointer to the HW structure
1940 *
1941 * Terminates the current command by inverting the EEPROM's chip select pin.
1942 **/
1943static void e1000_stop_nvm(struct e1000_hw *hw)
1944{
1945 u32 eecd;
1946
1947 eecd = er32(EECD);
1948 if (hw->nvm.type == e1000_nvm_eeprom_spi) {
1949 /* Pull CS high */
1950 eecd |= E1000_EECD_CS;
1951 e1000_lower_eec_clk(hw, &eecd);
1952 }
1953}
1954
1955/**
1956 * e1000e_release_nvm - Release exclusive access to EEPROM
1957 * @hw: pointer to the HW structure
1958 *
1959 * Stop any current commands to the EEPROM and clear the EEPROM request bit.
1960 **/
1961void e1000e_release_nvm(struct e1000_hw *hw)
1962{
1963 u32 eecd;
1964
1965 e1000_stop_nvm(hw);
1966
1967 eecd = er32(EECD);
1968 eecd &= ~E1000_EECD_REQ;
1969 ew32(EECD, eecd);
1970}
1971
1972/**
1973 * e1000_ready_nvm_eeprom - Prepares EEPROM for read/write
1974 * @hw: pointer to the HW structure
1975 *
1976 * Setups the EEPROM for reading and writing.
1977 **/
1978static s32 e1000_ready_nvm_eeprom(struct e1000_hw *hw)
1979{
1980 struct e1000_nvm_info *nvm = &hw->nvm;
1981 u32 eecd = er32(EECD);
1982 u8 spi_stat_reg;
1983
1984 if (nvm->type == e1000_nvm_eeprom_spi) {
1985 u16 timeout = NVM_MAX_RETRY_SPI;
1986
1987 /* Clear SK and CS */
1988 eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
1989 ew32(EECD, eecd);
1990 e1e_flush();
1991 udelay(1);
1992
1993 /*
1994 * Read "Status Register" repeatedly until the LSB is cleared.
1995 * The EEPROM will signal that the command has been completed
1996 * by clearing bit 0 of the internal status register. If it's
1997 * not cleared within 'timeout', then error out.
1998 */
1999 while (timeout) {
2000 e1000_shift_out_eec_bits(hw, NVM_RDSR_OPCODE_SPI,
2001 hw->nvm.opcode_bits);
2002 spi_stat_reg = (u8)e1000_shift_in_eec_bits(hw, 8);
2003 if (!(spi_stat_reg & NVM_STATUS_RDY_SPI))
2004 break;
2005
2006 udelay(5);
2007 e1000_standby_nvm(hw);
2008 timeout--;
2009 }
2010
2011 if (!timeout) {
2012 e_dbg("SPI NVM Status error\n");
2013 return -E1000_ERR_NVM;
2014 }
2015 }
2016
2017 return 0;
2018}
2019
2020/**
2021 * e1000e_read_nvm_eerd - Reads EEPROM using EERD register
2022 * @hw: pointer to the HW structure
2023 * @offset: offset of word in the EEPROM to read
2024 * @words: number of words to read
2025 * @data: word read from the EEPROM
2026 *
2027 * Reads a 16 bit word from the EEPROM using the EERD register.
2028 **/
2029s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
2030{
2031 struct e1000_nvm_info *nvm = &hw->nvm;
2032 u32 i, eerd = 0;
2033 s32 ret_val = 0;
2034
2035 /*
2036 * A check for invalid values: offset too large, too many words,
2037 * too many words for the offset, and not enough words.
2038 */
2039 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
2040 (words == 0)) {
2041 e_dbg("nvm parameter(s) out of bounds\n");
2042 return -E1000_ERR_NVM;
2043 }
2044
2045 for (i = 0; i < words; i++) {
2046 eerd = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) +
2047 E1000_NVM_RW_REG_START;
2048
2049 ew32(EERD, eerd);
2050 ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ);
2051 if (ret_val)
2052 break;
2053
2054 data[i] = (er32(EERD) >> E1000_NVM_RW_REG_DATA);
2055 }
2056
2057 return ret_val;
2058}
2059
2060/**
2061 * e1000e_write_nvm_spi - Write to EEPROM using SPI
2062 * @hw: pointer to the HW structure
2063 * @offset: offset within the EEPROM to be written to
2064 * @words: number of words to write
2065 * @data: 16 bit word(s) to be written to the EEPROM
2066 *
2067 * Writes data to EEPROM at offset using SPI interface.
2068 *
2069 * If e1000e_update_nvm_checksum is not called after this function , the
2070 * EEPROM will most likely contain an invalid checksum.
2071 **/
2072s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
2073{
2074 struct e1000_nvm_info *nvm = &hw->nvm;
2075 s32 ret_val;
2076 u16 widx = 0;
2077
2078 /*
2079 * A check for invalid values: offset too large, too many words,
2080 * and not enough words.
2081 */
2082 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
2083 (words == 0)) {
2084 e_dbg("nvm parameter(s) out of bounds\n");
2085 return -E1000_ERR_NVM;
2086 }
2087
2088 ret_val = nvm->ops.acquire(hw);
2089 if (ret_val)
2090 return ret_val;
2091
2092 while (widx < words) {
2093 u8 write_opcode = NVM_WRITE_OPCODE_SPI;
2094
2095 ret_val = e1000_ready_nvm_eeprom(hw);
2096 if (ret_val) {
2097 nvm->ops.release(hw);
2098 return ret_val;
2099 }
2100
2101 e1000_standby_nvm(hw);
2102
2103 /* Send the WRITE ENABLE command (8 bit opcode) */
2104 e1000_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI,
2105 nvm->opcode_bits);
2106
2107 e1000_standby_nvm(hw);
2108
2109 /*
2110 * Some SPI eeproms use the 8th address bit embedded in the
2111 * opcode
2112 */
2113 if ((nvm->address_bits == 8) && (offset >= 128))
2114 write_opcode |= NVM_A8_OPCODE_SPI;
2115
2116 /* Send the Write command (8-bit opcode + addr) */
2117 e1000_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits);
2118 e1000_shift_out_eec_bits(hw, (u16)((offset + widx) * 2),
2119 nvm->address_bits);
2120
2121 /* Loop to allow for up to whole page write of eeprom */
2122 while (widx < words) {
2123 u16 word_out = data[widx];
2124 word_out = (word_out >> 8) | (word_out << 8);
2125 e1000_shift_out_eec_bits(hw, word_out, 16);
2126 widx++;
2127
2128 if ((((offset + widx) * 2) % nvm->page_size) == 0) {
2129 e1000_standby_nvm(hw);
2130 break;
2131 }
2132 }
2133 }
2134
2135 usleep_range(10000, 20000);
2136 nvm->ops.release(hw);
2137 return 0;
2138}
2139
2140/**
2141 * e1000_read_pba_string_generic - Read device part number
2142 * @hw: pointer to the HW structure
2143 * @pba_num: pointer to device part number
2144 * @pba_num_size: size of part number buffer
2145 *
2146 * Reads the product board assembly (PBA) number from the EEPROM and stores
2147 * the value in pba_num.
2148 **/
2149s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num,
2150 u32 pba_num_size)
2151{
2152 s32 ret_val;
2153 u16 nvm_data;
2154 u16 pba_ptr;
2155 u16 offset;
2156 u16 length;
2157
2158 if (pba_num == NULL) {
2159 e_dbg("PBA string buffer was null\n");
2160 ret_val = E1000_ERR_INVALID_ARGUMENT;
2161 goto out;
2162 }
2163
2164 ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
2165 if (ret_val) {
2166 e_dbg("NVM Read Error\n");
2167 goto out;
2168 }
2169
2170 ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &pba_ptr);
2171 if (ret_val) {
2172 e_dbg("NVM Read Error\n");
2173 goto out;
2174 }
2175
2176 /*
2177 * if nvm_data is not ptr guard the PBA must be in legacy format which
2178 * means pba_ptr is actually our second data word for the PBA number
2179 * and we can decode it into an ascii string
2180 */
2181 if (nvm_data != NVM_PBA_PTR_GUARD) {
2182 e_dbg("NVM PBA number is not stored as string\n");
2183
2184 /* we will need 11 characters to store the PBA */
2185 if (pba_num_size < 11) {
2186 e_dbg("PBA string buffer too small\n");
2187 return E1000_ERR_NO_SPACE;
2188 }
2189
2190 /* extract hex string from data and pba_ptr */
2191 pba_num[0] = (nvm_data >> 12) & 0xF;
2192 pba_num[1] = (nvm_data >> 8) & 0xF;
2193 pba_num[2] = (nvm_data >> 4) & 0xF;
2194 pba_num[3] = nvm_data & 0xF;
2195 pba_num[4] = (pba_ptr >> 12) & 0xF;
2196 pba_num[5] = (pba_ptr >> 8) & 0xF;
2197 pba_num[6] = '-';
2198 pba_num[7] = 0;
2199 pba_num[8] = (pba_ptr >> 4) & 0xF;
2200 pba_num[9] = pba_ptr & 0xF;
2201
2202 /* put a null character on the end of our string */
2203 pba_num[10] = '\0';
2204
2205 /* switch all the data but the '-' to hex char */
2206 for (offset = 0; offset < 10; offset++) {
2207 if (pba_num[offset] < 0xA)
2208 pba_num[offset] += '0';
2209 else if (pba_num[offset] < 0x10)
2210 pba_num[offset] += 'A' - 0xA;
2211 }
2212
2213 goto out;
2214 }
2215
2216 ret_val = e1000_read_nvm(hw, pba_ptr, 1, &length);
2217 if (ret_val) {
2218 e_dbg("NVM Read Error\n");
2219 goto out;
2220 }
2221
2222 if (length == 0xFFFF || length == 0) {
2223 e_dbg("NVM PBA number section invalid length\n");
2224 ret_val = E1000_ERR_NVM_PBA_SECTION;
2225 goto out;
2226 }
2227 /* check if pba_num buffer is big enough */
2228 if (pba_num_size < (((u32)length * 2) - 1)) {
2229 e_dbg("PBA string buffer too small\n");
2230 ret_val = E1000_ERR_NO_SPACE;
2231 goto out;
2232 }
2233
2234 /* trim pba length from start of string */
2235 pba_ptr++;
2236 length--;
2237
2238 for (offset = 0; offset < length; offset++) {
2239 ret_val = e1000_read_nvm(hw, pba_ptr + offset, 1, &nvm_data);
2240 if (ret_val) {
2241 e_dbg("NVM Read Error\n");
2242 goto out;
2243 }
2244 pba_num[offset * 2] = (u8)(nvm_data >> 8);
2245 pba_num[(offset * 2) + 1] = (u8)(nvm_data & 0xFF);
2246 }
2247 pba_num[offset * 2] = '\0';
2248
2249out:
2250 return ret_val;
2251}
2252
2253/**
2254 * e1000_read_mac_addr_generic - Read device MAC address
2255 * @hw: pointer to the HW structure
2256 *
2257 * Reads the device MAC address from the EEPROM and stores the value.
2258 * Since devices with two ports use the same EEPROM, we increment the
2259 * last bit in the MAC address for the second port.
2260 **/
2261s32 e1000_read_mac_addr_generic(struct e1000_hw *hw)
2262{
2263 u32 rar_high;
2264 u32 rar_low;
2265 u16 i;
2266
2267 rar_high = er32(RAH(0));
2268 rar_low = er32(RAL(0));
2269
2270 for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++)
2271 hw->mac.perm_addr[i] = (u8)(rar_low >> (i*8));
2272
2273 for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++)
2274 hw->mac.perm_addr[i+4] = (u8)(rar_high >> (i*8));
2275
2276 for (i = 0; i < ETH_ALEN; i++)
2277 hw->mac.addr[i] = hw->mac.perm_addr[i];
2278
2279 return 0;
2280}
2281
2282/**
2283 * e1000e_validate_nvm_checksum_generic - Validate EEPROM checksum
2284 * @hw: pointer to the HW structure
2285 *
2286 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
2287 * and then verifies that the sum of the EEPROM is equal to 0xBABA.
2288 **/
2289s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw)
2290{
2291 s32 ret_val;
2292 u16 checksum = 0;
2293 u16 i, nvm_data;
2294
2295 for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
2296 ret_val = e1000_read_nvm(hw, i, 1, &nvm_data);
2297 if (ret_val) {
2298 e_dbg("NVM Read Error\n");
2299 return ret_val;
2300 }
2301 checksum += nvm_data;
2302 }
2303
2304 if (checksum != (u16) NVM_SUM) {
2305 e_dbg("NVM Checksum Invalid\n");
2306 return -E1000_ERR_NVM;
2307 }
2308
2309 return 0;
2310}
2311
2312/**
2313 * e1000e_update_nvm_checksum_generic - Update EEPROM checksum
2314 * @hw: pointer to the HW structure
2315 *
2316 * Updates the EEPROM checksum by reading/adding each word of the EEPROM
2317 * up to the checksum. Then calculates the EEPROM checksum and writes the
2318 * value to the EEPROM.
2319 **/
2320s32 e1000e_update_nvm_checksum_generic(struct e1000_hw *hw)
2321{
2322 s32 ret_val;
2323 u16 checksum = 0;
2324 u16 i, nvm_data;
2325
2326 for (i = 0; i < NVM_CHECKSUM_REG; i++) {
2327 ret_val = e1000_read_nvm(hw, i, 1, &nvm_data);
2328 if (ret_val) {
2329 e_dbg("NVM Read Error while updating checksum.\n");
2330 return ret_val;
2331 }
2332 checksum += nvm_data;
2333 }
2334 checksum = (u16) NVM_SUM - checksum;
2335 ret_val = e1000_write_nvm(hw, NVM_CHECKSUM_REG, 1, &checksum);
2336 if (ret_val)
2337 e_dbg("NVM Write Error while updating checksum.\n");
2338
2339 return ret_val;
2340}
2341
2342/**
2343 * e1000e_reload_nvm - Reloads EEPROM
2344 * @hw: pointer to the HW structure
2345 *
2346 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
2347 * extended control register.
2348 **/
2349void e1000e_reload_nvm(struct e1000_hw *hw)
2350{
2351 u32 ctrl_ext;
2352
2353 udelay(10);
2354 ctrl_ext = er32(CTRL_EXT);
2355 ctrl_ext |= E1000_CTRL_EXT_EE_RST;
2356 ew32(CTRL_EXT, ctrl_ext);
2357 e1e_flush();
2358}
2359
2360/**
2361 * e1000_calculate_checksum - Calculate checksum for buffer
2362 * @buffer: pointer to EEPROM
2363 * @length: size of EEPROM to calculate a checksum for
2364 *
2365 * Calculates the checksum for some buffer on a specified length. The
2366 * checksum calculated is returned.
2367 **/
2368static u8 e1000_calculate_checksum(u8 *buffer, u32 length)
2369{
2370 u32 i;
2371 u8 sum = 0;
2372
2373 if (!buffer)
2374 return 0;
2375
2376 for (i = 0; i < length; i++)
2377 sum += buffer[i];
2378
2379 return (u8) (0 - sum);
2380}
2381
2382/**
2383 * e1000_mng_enable_host_if - Checks host interface is enabled
2384 * @hw: pointer to the HW structure
2385 *
2386 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
2387 *
2388 * This function checks whether the HOST IF is enabled for command operation
2389 * and also checks whether the previous command is completed. It busy waits
2390 * in case of previous command is not completed.
2391 **/
2392static s32 e1000_mng_enable_host_if(struct e1000_hw *hw)
2393{
2394 u32 hicr;
2395 u8 i;
2396
2397 if (!(hw->mac.arc_subsystem_valid)) {
2398 e_dbg("ARC subsystem not valid.\n");
2399 return -E1000_ERR_HOST_INTERFACE_COMMAND;
2400 }
2401
2402 /* Check that the host interface is enabled. */
2403 hicr = er32(HICR);
2404 if ((hicr & E1000_HICR_EN) == 0) {
2405 e_dbg("E1000_HOST_EN bit disabled.\n");
2406 return -E1000_ERR_HOST_INTERFACE_COMMAND;
2407 }
2408 /* check the previous command is completed */
2409 for (i = 0; i < E1000_MNG_DHCP_COMMAND_TIMEOUT; i++) {
2410 hicr = er32(HICR);
2411 if (!(hicr & E1000_HICR_C))
2412 break;
2413 mdelay(1);
2414 }
2415
2416 if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) {
2417 e_dbg("Previous command timeout failed .\n");
2418 return -E1000_ERR_HOST_INTERFACE_COMMAND;
2419 }
2420
2421 return 0;
2422}
2423
2424/**
2425 * e1000e_check_mng_mode_generic - check management mode
2426 * @hw: pointer to the HW structure
2427 *
2428 * Reads the firmware semaphore register and returns true (>0) if
2429 * manageability is enabled, else false (0).
2430 **/
2431bool e1000e_check_mng_mode_generic(struct e1000_hw *hw)
2432{
2433 u32 fwsm = er32(FWSM);
2434
2435 return (fwsm & E1000_FWSM_MODE_MASK) ==
2436 (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT);
2437}
2438
2439/**
2440 * e1000e_enable_tx_pkt_filtering - Enable packet filtering on Tx
2441 * @hw: pointer to the HW structure
2442 *
2443 * Enables packet filtering on transmit packets if manageability is enabled
2444 * and host interface is enabled.
2445 **/
2446bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw)
2447{
2448 struct e1000_host_mng_dhcp_cookie *hdr = &hw->mng_cookie;
2449 u32 *buffer = (u32 *)&hw->mng_cookie;
2450 u32 offset;
2451 s32 ret_val, hdr_csum, csum;
2452 u8 i, len;
2453
2454 hw->mac.tx_pkt_filtering = true;
2455
2456 /* No manageability, no filtering */
2457 if (!e1000e_check_mng_mode(hw)) {
2458 hw->mac.tx_pkt_filtering = false;
2459 goto out;
2460 }
2461
2462 /*
2463 * If we can't read from the host interface for whatever
2464 * reason, disable filtering.
2465 */
2466 ret_val = e1000_mng_enable_host_if(hw);
2467 if (ret_val) {
2468 hw->mac.tx_pkt_filtering = false;
2469 goto out;
2470 }
2471
2472 /* Read in the header. Length and offset are in dwords. */
2473 len = E1000_MNG_DHCP_COOKIE_LENGTH >> 2;
2474 offset = E1000_MNG_DHCP_COOKIE_OFFSET >> 2;
2475 for (i = 0; i < len; i++)
2476 *(buffer + i) = E1000_READ_REG_ARRAY(hw, E1000_HOST_IF, offset + i);
2477 hdr_csum = hdr->checksum;
2478 hdr->checksum = 0;
2479 csum = e1000_calculate_checksum((u8 *)hdr,
2480 E1000_MNG_DHCP_COOKIE_LENGTH);
2481 /*
2482 * If either the checksums or signature don't match, then
2483 * the cookie area isn't considered valid, in which case we
2484 * take the safe route of assuming Tx filtering is enabled.
2485 */
2486 if ((hdr_csum != csum) || (hdr->signature != E1000_IAMT_SIGNATURE)) {
2487 hw->mac.tx_pkt_filtering = true;
2488 goto out;
2489 }
2490
2491 /* Cookie area is valid, make the final check for filtering. */
2492 if (!(hdr->status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING)) {
2493 hw->mac.tx_pkt_filtering = false;
2494 goto out;
2495 }
2496
2497out:
2498 return hw->mac.tx_pkt_filtering;
2499}
2500
2501/**
2502 * e1000_mng_write_cmd_header - Writes manageability command header
2503 * @hw: pointer to the HW structure
2504 * @hdr: pointer to the host interface command header
2505 *
2506 * Writes the command header after does the checksum calculation.
2507 **/
2508static s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
2509 struct e1000_host_mng_command_header *hdr)
2510{
2511 u16 i, length = sizeof(struct e1000_host_mng_command_header);
2512
2513 /* Write the whole command header structure with new checksum. */
2514
2515 hdr->checksum = e1000_calculate_checksum((u8 *)hdr, length);
2516
2517 length >>= 2;
2518 /* Write the relevant command block into the ram area. */
2519 for (i = 0; i < length; i++) {
2520 E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, i,
2521 *((u32 *) hdr + i));
2522 e1e_flush();
2523 }
2524
2525 return 0;
2526}
2527
2528/**
2529 * e1000_mng_host_if_write - Write to the manageability host interface
2530 * @hw: pointer to the HW structure
2531 * @buffer: pointer to the host interface buffer
2532 * @length: size of the buffer
2533 * @offset: location in the buffer to write to
2534 * @sum: sum of the data (not checksum)
2535 *
2536 * This function writes the buffer content at the offset given on the host if.
2537 * It also does alignment considerations to do the writes in most efficient
2538 * way. Also fills up the sum of the buffer in *buffer parameter.
2539 **/
2540static s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer,
2541 u16 length, u16 offset, u8 *sum)
2542{
2543 u8 *tmp;
2544 u8 *bufptr = buffer;
2545 u32 data = 0;
2546 u16 remaining, i, j, prev_bytes;
2547
2548 /* sum = only sum of the data and it is not checksum */
2549
2550 if (length == 0 || offset + length > E1000_HI_MAX_MNG_DATA_LENGTH)
2551 return -E1000_ERR_PARAM;
2552
2553 tmp = (u8 *)&data;
2554 prev_bytes = offset & 0x3;
2555 offset >>= 2;
2556
2557 if (prev_bytes) {
2558 data = E1000_READ_REG_ARRAY(hw, E1000_HOST_IF, offset);
2559 for (j = prev_bytes; j < sizeof(u32); j++) {
2560 *(tmp + j) = *bufptr++;
2561 *sum += *(tmp + j);
2562 }
2563 E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset, data);
2564 length -= j - prev_bytes;
2565 offset++;
2566 }
2567
2568 remaining = length & 0x3;
2569 length -= remaining;
2570
2571 /* Calculate length in DWORDs */
2572 length >>= 2;
2573
2574 /*
2575 * The device driver writes the relevant command block into the
2576 * ram area.
2577 */
2578 for (i = 0; i < length; i++) {
2579 for (j = 0; j < sizeof(u32); j++) {
2580 *(tmp + j) = *bufptr++;
2581 *sum += *(tmp + j);
2582 }
2583
2584 E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset + i, data);
2585 }
2586 if (remaining) {
2587 for (j = 0; j < sizeof(u32); j++) {
2588 if (j < remaining)
2589 *(tmp + j) = *bufptr++;
2590 else
2591 *(tmp + j) = 0;
2592
2593 *sum += *(tmp + j);
2594 }
2595 E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset + i, data);
2596 }
2597
2598 return 0;
2599}
2600
2601/**
2602 * e1000e_mng_write_dhcp_info - Writes DHCP info to host interface
2603 * @hw: pointer to the HW structure
2604 * @buffer: pointer to the host interface
2605 * @length: size of the buffer
2606 *
2607 * Writes the DHCP information to the host interface.
2608 **/
2609s32 e1000e_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
2610{
2611 struct e1000_host_mng_command_header hdr;
2612 s32 ret_val;
2613 u32 hicr;
2614
2615 hdr.command_id = E1000_MNG_DHCP_TX_PAYLOAD_CMD;
2616 hdr.command_length = length;
2617 hdr.reserved1 = 0;
2618 hdr.reserved2 = 0;
2619 hdr.checksum = 0;
2620
2621 /* Enable the host interface */
2622 ret_val = e1000_mng_enable_host_if(hw);
2623 if (ret_val)
2624 return ret_val;
2625
2626 /* Populate the host interface with the contents of "buffer". */
2627 ret_val = e1000_mng_host_if_write(hw, buffer, length,
2628 sizeof(hdr), &(hdr.checksum));
2629 if (ret_val)
2630 return ret_val;
2631
2632 /* Write the manageability command header */
2633 ret_val = e1000_mng_write_cmd_header(hw, &hdr);
2634 if (ret_val)
2635 return ret_val;
2636
2637 /* Tell the ARC a new command is pending. */
2638 hicr = er32(HICR);
2639 ew32(HICR, hicr | E1000_HICR_C);
2640
2641 return 0;
2642}
2643
2644/**
2645 * e1000e_enable_mng_pass_thru - Check if management passthrough is needed
2646 * @hw: pointer to the HW structure
2647 *
2648 * Verifies the hardware needs to leave interface enabled so that frames can
2649 * be directed to and from the management interface.
2650 **/
2651bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw)
2652{
2653 u32 manc;
2654 u32 fwsm, factps;
2655 bool ret_val = false;
2656
2657 manc = er32(MANC);
2658
2659 if (!(manc & E1000_MANC_RCV_TCO_EN))
2660 goto out;
2661
2662 if (hw->mac.has_fwsm) {
2663 fwsm = er32(FWSM);
2664 factps = er32(FACTPS);
2665
2666 if (!(factps & E1000_FACTPS_MNGCG) &&
2667 ((fwsm & E1000_FWSM_MODE_MASK) ==
2668 (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT))) {
2669 ret_val = true;
2670 goto out;
2671 }
2672 } else if ((hw->mac.type == e1000_82574) ||
2673 (hw->mac.type == e1000_82583)) {
2674 u16 data;
2675
2676 factps = er32(FACTPS);
2677 e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data);
2678
2679 if (!(factps & E1000_FACTPS_MNGCG) &&
2680 ((data & E1000_NVM_INIT_CTRL2_MNGM) ==
2681 (e1000_mng_mode_pt << 13))) {
2682 ret_val = true;
2683 goto out;
2684 }
2685 } else if ((manc & E1000_MANC_SMBUS_EN) &&
2686 !(manc & E1000_MANC_ASF_EN)) {
2687 ret_val = true;
2688 goto out;
2689 }
2690
2691out:
2692 return ret_val;
2693} 1713}
diff --git a/drivers/net/ethernet/intel/e1000e/manage.c b/drivers/net/ethernet/intel/e1000e/manage.c
new file mode 100644
index 000000000000..c54caf6e5801
--- /dev/null
+++ b/drivers/net/ethernet/intel/e1000e/manage.c
@@ -0,0 +1,377 @@
1/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2012 Intel Corporation.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
9
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
14
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28
29#include "e1000.h"
30
31enum e1000_mng_mode {
32 e1000_mng_mode_none = 0,
33 e1000_mng_mode_asf,
34 e1000_mng_mode_pt,
35 e1000_mng_mode_ipmi,
36 e1000_mng_mode_host_if_only
37};
38
39#define E1000_FACTPS_MNGCG 0x20000000
40
41/* Intel(R) Active Management Technology signature */
42#define E1000_IAMT_SIGNATURE 0x544D4149
43
44/**
45 * e1000_calculate_checksum - Calculate checksum for buffer
46 * @buffer: pointer to EEPROM
47 * @length: size of EEPROM to calculate a checksum for
48 *
49 * Calculates the checksum for some buffer on a specified length. The
50 * checksum calculated is returned.
51 **/
52static u8 e1000_calculate_checksum(u8 *buffer, u32 length)
53{
54 u32 i;
55 u8 sum = 0;
56
57 if (!buffer)
58 return 0;
59
60 for (i = 0; i < length; i++)
61 sum += buffer[i];
62
63 return (u8)(0 - sum);
64}
65
66/**
67 * e1000_mng_enable_host_if - Checks host interface is enabled
68 * @hw: pointer to the HW structure
69 *
70 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
71 *
72 * This function checks whether the HOST IF is enabled for command operation
73 * and also checks whether the previous command is completed. It busy waits
74 * in case of previous command is not completed.
75 **/
76static s32 e1000_mng_enable_host_if(struct e1000_hw *hw)
77{
78 u32 hicr;
79 u8 i;
80
81 if (!hw->mac.arc_subsystem_valid) {
82 e_dbg("ARC subsystem not valid.\n");
83 return -E1000_ERR_HOST_INTERFACE_COMMAND;
84 }
85
86 /* Check that the host interface is enabled. */
87 hicr = er32(HICR);
88 if ((hicr & E1000_HICR_EN) == 0) {
89 e_dbg("E1000_HOST_EN bit disabled.\n");
90 return -E1000_ERR_HOST_INTERFACE_COMMAND;
91 }
92 /* check the previous command is completed */
93 for (i = 0; i < E1000_MNG_DHCP_COMMAND_TIMEOUT; i++) {
94 hicr = er32(HICR);
95 if (!(hicr & E1000_HICR_C))
96 break;
97 mdelay(1);
98 }
99
100 if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) {
101 e_dbg("Previous command timeout failed .\n");
102 return -E1000_ERR_HOST_INTERFACE_COMMAND;
103 }
104
105 return 0;
106}
107
108/**
109 * e1000e_check_mng_mode_generic - check management mode
110 * @hw: pointer to the HW structure
111 *
112 * Reads the firmware semaphore register and returns true (>0) if
113 * manageability is enabled, else false (0).
114 **/
115bool e1000e_check_mng_mode_generic(struct e1000_hw *hw)
116{
117 u32 fwsm = er32(FWSM);
118
119 return (fwsm & E1000_FWSM_MODE_MASK) ==
120 (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT);
121}
122
123/**
124 * e1000e_enable_tx_pkt_filtering - Enable packet filtering on Tx
125 * @hw: pointer to the HW structure
126 *
127 * Enables packet filtering on transmit packets if manageability is enabled
128 * and host interface is enabled.
129 **/
130bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw)
131{
132 struct e1000_host_mng_dhcp_cookie *hdr = &hw->mng_cookie;
133 u32 *buffer = (u32 *)&hw->mng_cookie;
134 u32 offset;
135 s32 ret_val, hdr_csum, csum;
136 u8 i, len;
137
138 hw->mac.tx_pkt_filtering = true;
139
140 /* No manageability, no filtering */
141 if (!e1000e_check_mng_mode(hw)) {
142 hw->mac.tx_pkt_filtering = false;
143 goto out;
144 }
145
146 /*
147 * If we can't read from the host interface for whatever
148 * reason, disable filtering.
149 */
150 ret_val = e1000_mng_enable_host_if(hw);
151 if (ret_val) {
152 hw->mac.tx_pkt_filtering = false;
153 goto out;
154 }
155
156 /* Read in the header. Length and offset are in dwords. */
157 len = E1000_MNG_DHCP_COOKIE_LENGTH >> 2;
158 offset = E1000_MNG_DHCP_COOKIE_OFFSET >> 2;
159 for (i = 0; i < len; i++)
160 *(buffer + i) = E1000_READ_REG_ARRAY(hw, E1000_HOST_IF,
161 offset + i);
162 hdr_csum = hdr->checksum;
163 hdr->checksum = 0;
164 csum = e1000_calculate_checksum((u8 *)hdr,
165 E1000_MNG_DHCP_COOKIE_LENGTH);
166 /*
167 * If either the checksums or signature don't match, then
168 * the cookie area isn't considered valid, in which case we
169 * take the safe route of assuming Tx filtering is enabled.
170 */
171 if ((hdr_csum != csum) || (hdr->signature != E1000_IAMT_SIGNATURE)) {
172 hw->mac.tx_pkt_filtering = true;
173 goto out;
174 }
175
176 /* Cookie area is valid, make the final check for filtering. */
177 if (!(hdr->status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING)) {
178 hw->mac.tx_pkt_filtering = false;
179 goto out;
180 }
181
182out:
183 return hw->mac.tx_pkt_filtering;
184}
185
186/**
187 * e1000_mng_write_cmd_header - Writes manageability command header
188 * @hw: pointer to the HW structure
189 * @hdr: pointer to the host interface command header
190 *
191 * Writes the command header after does the checksum calculation.
192 **/
193static s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
194 struct e1000_host_mng_command_header *hdr)
195{
196 u16 i, length = sizeof(struct e1000_host_mng_command_header);
197
198 /* Write the whole command header structure with new checksum. */
199
200 hdr->checksum = e1000_calculate_checksum((u8 *)hdr, length);
201
202 length >>= 2;
203 /* Write the relevant command block into the ram area. */
204 for (i = 0; i < length; i++) {
205 E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, i, *((u32 *)hdr + i));
206 e1e_flush();
207 }
208
209 return 0;
210}
211
212/**
213 * e1000_mng_host_if_write - Write to the manageability host interface
214 * @hw: pointer to the HW structure
215 * @buffer: pointer to the host interface buffer
216 * @length: size of the buffer
217 * @offset: location in the buffer to write to
218 * @sum: sum of the data (not checksum)
219 *
220 * This function writes the buffer content at the offset given on the host if.
221 * It also does alignment considerations to do the writes in most efficient
222 * way. Also fills up the sum of the buffer in *buffer parameter.
223 **/
224static s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer,
225 u16 length, u16 offset, u8 *sum)
226{
227 u8 *tmp;
228 u8 *bufptr = buffer;
229 u32 data = 0;
230 u16 remaining, i, j, prev_bytes;
231
232 /* sum = only sum of the data and it is not checksum */
233
234 if (length == 0 || offset + length > E1000_HI_MAX_MNG_DATA_LENGTH)
235 return -E1000_ERR_PARAM;
236
237 tmp = (u8 *)&data;
238 prev_bytes = offset & 0x3;
239 offset >>= 2;
240
241 if (prev_bytes) {
242 data = E1000_READ_REG_ARRAY(hw, E1000_HOST_IF, offset);
243 for (j = prev_bytes; j < sizeof(u32); j++) {
244 *(tmp + j) = *bufptr++;
245 *sum += *(tmp + j);
246 }
247 E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset, data);
248 length -= j - prev_bytes;
249 offset++;
250 }
251
252 remaining = length & 0x3;
253 length -= remaining;
254
255 /* Calculate length in DWORDs */
256 length >>= 2;
257
258 /*
259 * The device driver writes the relevant command block into the
260 * ram area.
261 */
262 for (i = 0; i < length; i++) {
263 for (j = 0; j < sizeof(u32); j++) {
264 *(tmp + j) = *bufptr++;
265 *sum += *(tmp + j);
266 }
267
268 E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset + i, data);
269 }
270 if (remaining) {
271 for (j = 0; j < sizeof(u32); j++) {
272 if (j < remaining)
273 *(tmp + j) = *bufptr++;
274 else
275 *(tmp + j) = 0;
276
277 *sum += *(tmp + j);
278 }
279 E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset + i, data);
280 }
281
282 return 0;
283}
284
285/**
286 * e1000e_mng_write_dhcp_info - Writes DHCP info to host interface
287 * @hw: pointer to the HW structure
288 * @buffer: pointer to the host interface
289 * @length: size of the buffer
290 *
291 * Writes the DHCP information to the host interface.
292 **/
293s32 e1000e_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
294{
295 struct e1000_host_mng_command_header hdr;
296 s32 ret_val;
297 u32 hicr;
298
299 hdr.command_id = E1000_MNG_DHCP_TX_PAYLOAD_CMD;
300 hdr.command_length = length;
301 hdr.reserved1 = 0;
302 hdr.reserved2 = 0;
303 hdr.checksum = 0;
304
305 /* Enable the host interface */
306 ret_val = e1000_mng_enable_host_if(hw);
307 if (ret_val)
308 return ret_val;
309
310 /* Populate the host interface with the contents of "buffer". */
311 ret_val = e1000_mng_host_if_write(hw, buffer, length,
312 sizeof(hdr), &(hdr.checksum));
313 if (ret_val)
314 return ret_val;
315
316 /* Write the manageability command header */
317 ret_val = e1000_mng_write_cmd_header(hw, &hdr);
318 if (ret_val)
319 return ret_val;
320
321 /* Tell the ARC a new command is pending. */
322 hicr = er32(HICR);
323 ew32(HICR, hicr | E1000_HICR_C);
324
325 return 0;
326}
327
328/**
329 * e1000e_enable_mng_pass_thru - Check if management passthrough is needed
330 * @hw: pointer to the HW structure
331 *
332 * Verifies the hardware needs to leave interface enabled so that frames can
333 * be directed to and from the management interface.
334 **/
335bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw)
336{
337 u32 manc;
338 u32 fwsm, factps;
339 bool ret_val = false;
340
341 manc = er32(MANC);
342
343 if (!(manc & E1000_MANC_RCV_TCO_EN))
344 goto out;
345
346 if (hw->mac.has_fwsm) {
347 fwsm = er32(FWSM);
348 factps = er32(FACTPS);
349
350 if (!(factps & E1000_FACTPS_MNGCG) &&
351 ((fwsm & E1000_FWSM_MODE_MASK) ==
352 (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT))) {
353 ret_val = true;
354 goto out;
355 }
356 } else if ((hw->mac.type == e1000_82574) ||
357 (hw->mac.type == e1000_82583)) {
358 u16 data;
359
360 factps = er32(FACTPS);
361 e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data);
362
363 if (!(factps & E1000_FACTPS_MNGCG) &&
364 ((data & E1000_NVM_INIT_CTRL2_MNGM) ==
365 (e1000_mng_mode_pt << 13))) {
366 ret_val = true;
367 goto out;
368 }
369 } else if ((manc & E1000_MANC_SMBUS_EN) &&
370 !(manc & E1000_MANC_ASF_EN)) {
371 ret_val = true;
372 goto out;
373 }
374
375out:
376 return ret_val;
377}
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 3911401ed65d..f868fb822a30 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2011 Intel Corporation. 4 Copyright(c) 1999 - 2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -56,7 +56,7 @@
56 56
57#define DRV_EXTRAVERSION "-k" 57#define DRV_EXTRAVERSION "-k"
58 58
59#define DRV_VERSION "1.5.1" DRV_EXTRAVERSION 59#define DRV_VERSION "1.9.5" DRV_EXTRAVERSION
60char e1000e_driver_name[] = "e1000e"; 60char e1000e_driver_name[] = "e1000e";
61const char e1000e_driver_version[] = DRV_VERSION; 61const char e1000e_driver_version[] = DRV_VERSION;
62 62
@@ -137,7 +137,7 @@ static const struct e1000_reg_info e1000_reg_info_tbl[] = {
137 {E1000_TDFPC, "TDFPC"}, 137 {E1000_TDFPC, "TDFPC"},
138 138
139 /* List Terminator */ 139 /* List Terminator */
140 {} 140 {0, NULL}
141}; 141};
142 142
143/* 143/*
@@ -183,18 +183,18 @@ static void e1000e_dump(struct e1000_adapter *adapter)
183 struct e1000_ring *tx_ring = adapter->tx_ring; 183 struct e1000_ring *tx_ring = adapter->tx_ring;
184 struct e1000_tx_desc *tx_desc; 184 struct e1000_tx_desc *tx_desc;
185 struct my_u0 { 185 struct my_u0 {
186 u64 a; 186 __le64 a;
187 u64 b; 187 __le64 b;
188 } *u0; 188 } *u0;
189 struct e1000_buffer *buffer_info; 189 struct e1000_buffer *buffer_info;
190 struct e1000_ring *rx_ring = adapter->rx_ring; 190 struct e1000_ring *rx_ring = adapter->rx_ring;
191 union e1000_rx_desc_packet_split *rx_desc_ps; 191 union e1000_rx_desc_packet_split *rx_desc_ps;
192 union e1000_rx_desc_extended *rx_desc; 192 union e1000_rx_desc_extended *rx_desc;
193 struct my_u1 { 193 struct my_u1 {
194 u64 a; 194 __le64 a;
195 u64 b; 195 __le64 b;
196 u64 c; 196 __le64 c;
197 u64 d; 197 __le64 d;
198 } *u1; 198 } *u1;
199 u32 staterr; 199 u32 staterr;
200 int i = 0; 200 int i = 0;
@@ -221,7 +221,7 @@ static void e1000e_dump(struct e1000_adapter *adapter)
221 221
222 /* Print Tx Ring Summary */ 222 /* Print Tx Ring Summary */
223 if (!netdev || !netif_running(netdev)) 223 if (!netdev || !netif_running(netdev))
224 goto exit; 224 return;
225 225
226 dev_info(&adapter->pdev->dev, "Tx Ring Summary\n"); 226 dev_info(&adapter->pdev->dev, "Tx Ring Summary\n");
227 pr_info("Queue [NTU] [NTC] [bi(ntc)->dma ] leng ntw timestamp\n"); 227 pr_info("Queue [NTU] [NTC] [bi(ntc)->dma ] leng ntw timestamp\n");
@@ -308,7 +308,7 @@ rx_ring_summary:
308 308
309 /* Print Rx Ring */ 309 /* Print Rx Ring */
310 if (!netif_msg_rx_status(adapter)) 310 if (!netif_msg_rx_status(adapter))
311 goto exit; 311 return;
312 312
313 dev_info(&adapter->pdev->dev, "Rx Ring Dump\n"); 313 dev_info(&adapter->pdev->dev, "Rx Ring Dump\n");
314 switch (adapter->rx_ps_pages) { 314 switch (adapter->rx_ps_pages) {
@@ -449,9 +449,6 @@ rx_ring_summary:
449 } 449 }
450 } 450 }
451 } 451 }
452
453exit:
454 return;
455} 452}
456 453
457/** 454/**
@@ -487,22 +484,27 @@ static void e1000_receive_skb(struct e1000_adapter *adapter,
487 484
488/** 485/**
489 * e1000_rx_checksum - Receive Checksum Offload 486 * e1000_rx_checksum - Receive Checksum Offload
490 * @adapter: board private structure 487 * @adapter: board private structure
491 * @status_err: receive descriptor status and error fields 488 * @status_err: receive descriptor status and error fields
492 * @csum: receive descriptor csum field 489 * @csum: receive descriptor csum field
493 * @sk_buff: socket buffer with received data 490 * @sk_buff: socket buffer with received data
494 **/ 491 **/
495static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err, 492static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
496 u32 csum, struct sk_buff *skb) 493 __le16 csum, struct sk_buff *skb)
497{ 494{
498 u16 status = (u16)status_err; 495 u16 status = (u16)status_err;
499 u8 errors = (u8)(status_err >> 24); 496 u8 errors = (u8)(status_err >> 24);
500 497
501 skb_checksum_none_assert(skb); 498 skb_checksum_none_assert(skb);
502 499
500 /* Rx checksum disabled */
501 if (!(adapter->netdev->features & NETIF_F_RXCSUM))
502 return;
503
503 /* Ignore Checksum bit is set */ 504 /* Ignore Checksum bit is set */
504 if (status & E1000_RXD_STAT_IXSM) 505 if (status & E1000_RXD_STAT_IXSM)
505 return; 506 return;
507
506 /* TCP/UDP checksum error bit is set */ 508 /* TCP/UDP checksum error bit is set */
507 if (errors & E1000_RXD_ERR_TCPE) { 509 if (errors & E1000_RXD_ERR_TCPE) {
508 /* let the stack verify checksum errors */ 510 /* let the stack verify checksum errors */
@@ -524,7 +526,7 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
524 * Hardware complements the payload checksum, so we undo it 526 * Hardware complements the payload checksum, so we undo it
525 * and then put the value in host order for further stack use. 527 * and then put the value in host order for further stack use.
526 */ 528 */
527 __sum16 sum = (__force __sum16)htons(csum); 529 __sum16 sum = (__force __sum16)swab16((__force u16)csum);
528 skb->csum = csum_unfold(~sum); 530 skb->csum = csum_unfold(~sum);
529 skb->ip_summed = CHECKSUM_COMPLETE; 531 skb->ip_summed = CHECKSUM_COMPLETE;
530 } 532 }
@@ -545,7 +547,7 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
545 * which has bit 24 set while ME is accessing Host CSR registers, wait 547 * which has bit 24 set while ME is accessing Host CSR registers, wait
546 * if it is set and try again a number of times. 548 * if it is set and try again a number of times.
547 **/ 549 **/
548static inline s32 e1000e_update_tail_wa(struct e1000_hw *hw, u8 __iomem * tail, 550static inline s32 e1000e_update_tail_wa(struct e1000_hw *hw, void __iomem *tail,
549 unsigned int i) 551 unsigned int i)
550{ 552{
551 unsigned int j = 0; 553 unsigned int j = 0;
@@ -562,12 +564,12 @@ static inline s32 e1000e_update_tail_wa(struct e1000_hw *hw, u8 __iomem * tail,
562 return 0; 564 return 0;
563} 565}
564 566
565static void e1000e_update_rdt_wa(struct e1000_adapter *adapter, unsigned int i) 567static void e1000e_update_rdt_wa(struct e1000_ring *rx_ring, unsigned int i)
566{ 568{
567 u8 __iomem *tail = (adapter->hw.hw_addr + adapter->rx_ring->tail); 569 struct e1000_adapter *adapter = rx_ring->adapter;
568 struct e1000_hw *hw = &adapter->hw; 570 struct e1000_hw *hw = &adapter->hw;
569 571
570 if (e1000e_update_tail_wa(hw, tail, i)) { 572 if (e1000e_update_tail_wa(hw, rx_ring->tail, i)) {
571 u32 rctl = er32(RCTL); 573 u32 rctl = er32(RCTL);
572 ew32(RCTL, rctl & ~E1000_RCTL_EN); 574 ew32(RCTL, rctl & ~E1000_RCTL_EN);
573 e_err("ME firmware caused invalid RDT - resetting\n"); 575 e_err("ME firmware caused invalid RDT - resetting\n");
@@ -575,12 +577,12 @@ static void e1000e_update_rdt_wa(struct e1000_adapter *adapter, unsigned int i)
575 } 577 }
576} 578}
577 579
578static void e1000e_update_tdt_wa(struct e1000_adapter *adapter, unsigned int i) 580static void e1000e_update_tdt_wa(struct e1000_ring *tx_ring, unsigned int i)
579{ 581{
580 u8 __iomem *tail = (adapter->hw.hw_addr + adapter->tx_ring->tail); 582 struct e1000_adapter *adapter = tx_ring->adapter;
581 struct e1000_hw *hw = &adapter->hw; 583 struct e1000_hw *hw = &adapter->hw;
582 584
583 if (e1000e_update_tail_wa(hw, tail, i)) { 585 if (e1000e_update_tail_wa(hw, tx_ring->tail, i)) {
584 u32 tctl = er32(TCTL); 586 u32 tctl = er32(TCTL);
585 ew32(TCTL, tctl & ~E1000_TCTL_EN); 587 ew32(TCTL, tctl & ~E1000_TCTL_EN);
586 e_err("ME firmware caused invalid TDT - resetting\n"); 588 e_err("ME firmware caused invalid TDT - resetting\n");
@@ -590,14 +592,14 @@ static void e1000e_update_tdt_wa(struct e1000_adapter *adapter, unsigned int i)
590 592
591/** 593/**
592 * e1000_alloc_rx_buffers - Replace used receive buffers 594 * e1000_alloc_rx_buffers - Replace used receive buffers
593 * @adapter: address of board private structure 595 * @rx_ring: Rx descriptor ring
594 **/ 596 **/
595static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, 597static void e1000_alloc_rx_buffers(struct e1000_ring *rx_ring,
596 int cleaned_count, gfp_t gfp) 598 int cleaned_count, gfp_t gfp)
597{ 599{
600 struct e1000_adapter *adapter = rx_ring->adapter;
598 struct net_device *netdev = adapter->netdev; 601 struct net_device *netdev = adapter->netdev;
599 struct pci_dev *pdev = adapter->pdev; 602 struct pci_dev *pdev = adapter->pdev;
600 struct e1000_ring *rx_ring = adapter->rx_ring;
601 union e1000_rx_desc_extended *rx_desc; 603 union e1000_rx_desc_extended *rx_desc;
602 struct e1000_buffer *buffer_info; 604 struct e1000_buffer *buffer_info;
603 struct sk_buff *skb; 605 struct sk_buff *skb;
@@ -644,9 +646,9 @@ map_skb:
644 */ 646 */
645 wmb(); 647 wmb();
646 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) 648 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
647 e1000e_update_rdt_wa(adapter, i); 649 e1000e_update_rdt_wa(rx_ring, i);
648 else 650 else
649 writel(i, adapter->hw.hw_addr + rx_ring->tail); 651 writel(i, rx_ring->tail);
650 } 652 }
651 i++; 653 i++;
652 if (i == rx_ring->count) 654 if (i == rx_ring->count)
@@ -659,15 +661,15 @@ map_skb:
659 661
660/** 662/**
661 * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split 663 * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split
662 * @adapter: address of board private structure 664 * @rx_ring: Rx descriptor ring
663 **/ 665 **/
664static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, 666static void e1000_alloc_rx_buffers_ps(struct e1000_ring *rx_ring,
665 int cleaned_count, gfp_t gfp) 667 int cleaned_count, gfp_t gfp)
666{ 668{
669 struct e1000_adapter *adapter = rx_ring->adapter;
667 struct net_device *netdev = adapter->netdev; 670 struct net_device *netdev = adapter->netdev;
668 struct pci_dev *pdev = adapter->pdev; 671 struct pci_dev *pdev = adapter->pdev;
669 union e1000_rx_desc_packet_split *rx_desc; 672 union e1000_rx_desc_packet_split *rx_desc;
670 struct e1000_ring *rx_ring = adapter->rx_ring;
671 struct e1000_buffer *buffer_info; 673 struct e1000_buffer *buffer_info;
672 struct e1000_ps_page *ps_page; 674 struct e1000_ps_page *ps_page;
673 struct sk_buff *skb; 675 struct sk_buff *skb;
@@ -747,10 +749,9 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
747 */ 749 */
748 wmb(); 750 wmb();
749 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) 751 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
750 e1000e_update_rdt_wa(adapter, i << 1); 752 e1000e_update_rdt_wa(rx_ring, i << 1);
751 else 753 else
752 writel(i << 1, 754 writel(i << 1, rx_ring->tail);
753 adapter->hw.hw_addr + rx_ring->tail);
754 } 755 }
755 756
756 i++; 757 i++;
@@ -765,17 +766,17 @@ no_buffers:
765 766
766/** 767/**
767 * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers 768 * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers
768 * @adapter: address of board private structure 769 * @rx_ring: Rx descriptor ring
769 * @cleaned_count: number of buffers to allocate this pass 770 * @cleaned_count: number of buffers to allocate this pass
770 **/ 771 **/
771 772
772static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, 773static void e1000_alloc_jumbo_rx_buffers(struct e1000_ring *rx_ring,
773 int cleaned_count, gfp_t gfp) 774 int cleaned_count, gfp_t gfp)
774{ 775{
776 struct e1000_adapter *adapter = rx_ring->adapter;
775 struct net_device *netdev = adapter->netdev; 777 struct net_device *netdev = adapter->netdev;
776 struct pci_dev *pdev = adapter->pdev; 778 struct pci_dev *pdev = adapter->pdev;
777 union e1000_rx_desc_extended *rx_desc; 779 union e1000_rx_desc_extended *rx_desc;
778 struct e1000_ring *rx_ring = adapter->rx_ring;
779 struct e1000_buffer *buffer_info; 780 struct e1000_buffer *buffer_info;
780 struct sk_buff *skb; 781 struct sk_buff *skb;
781 unsigned int i; 782 unsigned int i;
@@ -834,26 +835,33 @@ check_page:
834 * such as IA-64). */ 835 * such as IA-64). */
835 wmb(); 836 wmb();
836 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) 837 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
837 e1000e_update_rdt_wa(adapter, i); 838 e1000e_update_rdt_wa(rx_ring, i);
838 else 839 else
839 writel(i, adapter->hw.hw_addr + rx_ring->tail); 840 writel(i, rx_ring->tail);
840 } 841 }
841} 842}
842 843
844static inline void e1000_rx_hash(struct net_device *netdev, __le32 rss,
845 struct sk_buff *skb)
846{
847 if (netdev->features & NETIF_F_RXHASH)
848 skb->rxhash = le32_to_cpu(rss);
849}
850
843/** 851/**
844 * e1000_clean_rx_irq - Send received data up the network stack; legacy 852 * e1000_clean_rx_irq - Send received data up the network stack
845 * @adapter: board private structure 853 * @rx_ring: Rx descriptor ring
846 * 854 *
847 * the return value indicates whether actual cleaning was done, there 855 * the return value indicates whether actual cleaning was done, there
848 * is no guarantee that everything was cleaned 856 * is no guarantee that everything was cleaned
849 **/ 857 **/
850static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, 858static bool e1000_clean_rx_irq(struct e1000_ring *rx_ring, int *work_done,
851 int *work_done, int work_to_do) 859 int work_to_do)
852{ 860{
861 struct e1000_adapter *adapter = rx_ring->adapter;
853 struct net_device *netdev = adapter->netdev; 862 struct net_device *netdev = adapter->netdev;
854 struct pci_dev *pdev = adapter->pdev; 863 struct pci_dev *pdev = adapter->pdev;
855 struct e1000_hw *hw = &adapter->hw; 864 struct e1000_hw *hw = &adapter->hw;
856 struct e1000_ring *rx_ring = adapter->rx_ring;
857 union e1000_rx_desc_extended *rx_desc, *next_rxd; 865 union e1000_rx_desc_extended *rx_desc, *next_rxd;
858 struct e1000_buffer *buffer_info, *next_buffer; 866 struct e1000_buffer *buffer_info, *next_buffer;
859 u32 length, staterr; 867 u32 length, staterr;
@@ -957,8 +965,9 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
957 965
958 /* Receive Checksum Offload */ 966 /* Receive Checksum Offload */
959 e1000_rx_checksum(adapter, staterr, 967 e1000_rx_checksum(adapter, staterr,
960 le16_to_cpu(rx_desc->wb.lower.hi_dword. 968 rx_desc->wb.lower.hi_dword.csum_ip.csum, skb);
961 csum_ip.csum), skb); 969
970 e1000_rx_hash(netdev, rx_desc->wb.lower.hi_dword.rss, skb);
962 971
963 e1000_receive_skb(adapter, netdev, skb, staterr, 972 e1000_receive_skb(adapter, netdev, skb, staterr,
964 rx_desc->wb.upper.vlan); 973 rx_desc->wb.upper.vlan);
@@ -968,7 +977,7 @@ next_desc:
968 977
969 /* return some buffers to hardware, one at a time is too slow */ 978 /* return some buffers to hardware, one at a time is too slow */
970 if (cleaned_count >= E1000_RX_BUFFER_WRITE) { 979 if (cleaned_count >= E1000_RX_BUFFER_WRITE) {
971 adapter->alloc_rx_buf(adapter, cleaned_count, 980 adapter->alloc_rx_buf(rx_ring, cleaned_count,
972 GFP_ATOMIC); 981 GFP_ATOMIC);
973 cleaned_count = 0; 982 cleaned_count = 0;
974 } 983 }
@@ -983,16 +992,18 @@ next_desc:
983 992
984 cleaned_count = e1000_desc_unused(rx_ring); 993 cleaned_count = e1000_desc_unused(rx_ring);
985 if (cleaned_count) 994 if (cleaned_count)
986 adapter->alloc_rx_buf(adapter, cleaned_count, GFP_ATOMIC); 995 adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC);
987 996
988 adapter->total_rx_bytes += total_rx_bytes; 997 adapter->total_rx_bytes += total_rx_bytes;
989 adapter->total_rx_packets += total_rx_packets; 998 adapter->total_rx_packets += total_rx_packets;
990 return cleaned; 999 return cleaned;
991} 1000}
992 1001
993static void e1000_put_txbuf(struct e1000_adapter *adapter, 1002static void e1000_put_txbuf(struct e1000_ring *tx_ring,
994 struct e1000_buffer *buffer_info) 1003 struct e1000_buffer *buffer_info)
995{ 1004{
1005 struct e1000_adapter *adapter = tx_ring->adapter;
1006
996 if (buffer_info->dma) { 1007 if (buffer_info->dma) {
997 if (buffer_info->mapped_as_page) 1008 if (buffer_info->mapped_as_page)
998 dma_unmap_page(&adapter->pdev->dev, buffer_info->dma, 1009 dma_unmap_page(&adapter->pdev->dev, buffer_info->dma,
@@ -1063,8 +1074,8 @@ static void e1000_print_hw_hang(struct work_struct *work)
1063 "PHY 1000BASE-T Status <%x>\n" 1074 "PHY 1000BASE-T Status <%x>\n"
1064 "PHY Extended Status <%x>\n" 1075 "PHY Extended Status <%x>\n"
1065 "PCI Status <%x>\n", 1076 "PCI Status <%x>\n",
1066 readl(adapter->hw.hw_addr + tx_ring->head), 1077 readl(tx_ring->head),
1067 readl(adapter->hw.hw_addr + tx_ring->tail), 1078 readl(tx_ring->tail),
1068 tx_ring->next_to_use, 1079 tx_ring->next_to_use,
1069 tx_ring->next_to_clean, 1080 tx_ring->next_to_clean,
1070 tx_ring->buffer_info[eop].time_stamp, 1081 tx_ring->buffer_info[eop].time_stamp,
@@ -1080,16 +1091,16 @@ static void e1000_print_hw_hang(struct work_struct *work)
1080 1091
1081/** 1092/**
1082 * e1000_clean_tx_irq - Reclaim resources after transmit completes 1093 * e1000_clean_tx_irq - Reclaim resources after transmit completes
1083 * @adapter: board private structure 1094 * @tx_ring: Tx descriptor ring
1084 * 1095 *
1085 * the return value indicates whether actual cleaning was done, there 1096 * the return value indicates whether actual cleaning was done, there
1086 * is no guarantee that everything was cleaned 1097 * is no guarantee that everything was cleaned
1087 **/ 1098 **/
1088static bool e1000_clean_tx_irq(struct e1000_adapter *adapter) 1099static bool e1000_clean_tx_irq(struct e1000_ring *tx_ring)
1089{ 1100{
1101 struct e1000_adapter *adapter = tx_ring->adapter;
1090 struct net_device *netdev = adapter->netdev; 1102 struct net_device *netdev = adapter->netdev;
1091 struct e1000_hw *hw = &adapter->hw; 1103 struct e1000_hw *hw = &adapter->hw;
1092 struct e1000_ring *tx_ring = adapter->tx_ring;
1093 struct e1000_tx_desc *tx_desc, *eop_desc; 1104 struct e1000_tx_desc *tx_desc, *eop_desc;
1094 struct e1000_buffer *buffer_info; 1105 struct e1000_buffer *buffer_info;
1095 unsigned int i, eop; 1106 unsigned int i, eop;
@@ -1119,7 +1130,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
1119 } 1130 }
1120 } 1131 }
1121 1132
1122 e1000_put_txbuf(adapter, buffer_info); 1133 e1000_put_txbuf(tx_ring, buffer_info);
1123 tx_desc->upper.data = 0; 1134 tx_desc->upper.data = 0;
1124 1135
1125 i++; 1136 i++;
@@ -1173,19 +1184,19 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
1173 1184
1174/** 1185/**
1175 * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split 1186 * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split
1176 * @adapter: board private structure 1187 * @rx_ring: Rx descriptor ring
1177 * 1188 *
1178 * the return value indicates whether actual cleaning was done, there 1189 * the return value indicates whether actual cleaning was done, there
1179 * is no guarantee that everything was cleaned 1190 * is no guarantee that everything was cleaned
1180 **/ 1191 **/
1181static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, 1192static bool e1000_clean_rx_irq_ps(struct e1000_ring *rx_ring, int *work_done,
1182 int *work_done, int work_to_do) 1193 int work_to_do)
1183{ 1194{
1195 struct e1000_adapter *adapter = rx_ring->adapter;
1184 struct e1000_hw *hw = &adapter->hw; 1196 struct e1000_hw *hw = &adapter->hw;
1185 union e1000_rx_desc_packet_split *rx_desc, *next_rxd; 1197 union e1000_rx_desc_packet_split *rx_desc, *next_rxd;
1186 struct net_device *netdev = adapter->netdev; 1198 struct net_device *netdev = adapter->netdev;
1187 struct pci_dev *pdev = adapter->pdev; 1199 struct pci_dev *pdev = adapter->pdev;
1188 struct e1000_ring *rx_ring = adapter->rx_ring;
1189 struct e1000_buffer *buffer_info, *next_buffer; 1200 struct e1000_buffer *buffer_info, *next_buffer;
1190 struct e1000_ps_page *ps_page; 1201 struct e1000_ps_page *ps_page;
1191 struct sk_buff *skb; 1202 struct sk_buff *skb;
@@ -1253,43 +1264,49 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
1253 skb_put(skb, length); 1264 skb_put(skb, length);
1254 1265
1255 { 1266 {
1256 /* 1267 /*
1257 * this looks ugly, but it seems compiler issues make it 1268 * this looks ugly, but it seems compiler issues make
1258 * more efficient than reusing j 1269 * it more efficient than reusing j
1259 */ 1270 */
1260 int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]); 1271 int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]);
1261
1262 /*
1263 * page alloc/put takes too long and effects small packet
1264 * throughput, so unsplit small packets and save the alloc/put
1265 * only valid in softirq (napi) context to call kmap_*
1266 */
1267 if (l1 && (l1 <= copybreak) &&
1268 ((length + l1) <= adapter->rx_ps_bsize0)) {
1269 u8 *vaddr;
1270
1271 ps_page = &buffer_info->ps_pages[0];
1272 1272
1273 /* 1273 /*
1274 * there is no documentation about how to call 1274 * page alloc/put takes too long and effects small
1275 * kmap_atomic, so we can't hold the mapping 1275 * packet throughput, so unsplit small packets and
1276 * very long 1276 * save the alloc/put only valid in softirq (napi)
1277 * context to call kmap_*
1277 */ 1278 */
1278 dma_sync_single_for_cpu(&pdev->dev, ps_page->dma, 1279 if (l1 && (l1 <= copybreak) &&
1279 PAGE_SIZE, DMA_FROM_DEVICE); 1280 ((length + l1) <= adapter->rx_ps_bsize0)) {
1280 vaddr = kmap_atomic(ps_page->page, KM_SKB_DATA_SOFTIRQ); 1281 u8 *vaddr;
1281 memcpy(skb_tail_pointer(skb), vaddr, l1); 1282
1282 kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ); 1283 ps_page = &buffer_info->ps_pages[0];
1283 dma_sync_single_for_device(&pdev->dev, ps_page->dma, 1284
1284 PAGE_SIZE, DMA_FROM_DEVICE); 1285 /*
1285 1286 * there is no documentation about how to call
1286 /* remove the CRC */ 1287 * kmap_atomic, so we can't hold the mapping
1287 if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) 1288 * very long
1288 l1 -= 4; 1289 */
1289 1290 dma_sync_single_for_cpu(&pdev->dev,
1290 skb_put(skb, l1); 1291 ps_page->dma,
1291 goto copydone; 1292 PAGE_SIZE,
1292 } /* if */ 1293 DMA_FROM_DEVICE);
1294 vaddr = kmap_atomic(ps_page->page,
1295 KM_SKB_DATA_SOFTIRQ);
1296 memcpy(skb_tail_pointer(skb), vaddr, l1);
1297 kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
1298 dma_sync_single_for_device(&pdev->dev,
1299 ps_page->dma,
1300 PAGE_SIZE,
1301 DMA_FROM_DEVICE);
1302
1303 /* remove the CRC */
1304 if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
1305 l1 -= 4;
1306
1307 skb_put(skb, l1);
1308 goto copydone;
1309 } /* if */
1293 } 1310 }
1294 1311
1295 for (j = 0; j < PS_PAGE_BUFFERS; j++) { 1312 for (j = 0; j < PS_PAGE_BUFFERS; j++) {
@@ -1318,8 +1335,10 @@ copydone:
1318 total_rx_bytes += skb->len; 1335 total_rx_bytes += skb->len;
1319 total_rx_packets++; 1336 total_rx_packets++;
1320 1337
1321 e1000_rx_checksum(adapter, staterr, le16_to_cpu( 1338 e1000_rx_checksum(adapter, staterr,
1322 rx_desc->wb.lower.hi_dword.csum_ip.csum), skb); 1339 rx_desc->wb.lower.hi_dword.csum_ip.csum, skb);
1340
1341 e1000_rx_hash(netdev, rx_desc->wb.lower.hi_dword.rss, skb);
1323 1342
1324 if (rx_desc->wb.upper.header_status & 1343 if (rx_desc->wb.upper.header_status &
1325 cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)) 1344 cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP))
@@ -1334,7 +1353,7 @@ next_desc:
1334 1353
1335 /* return some buffers to hardware, one at a time is too slow */ 1354 /* return some buffers to hardware, one at a time is too slow */
1336 if (cleaned_count >= E1000_RX_BUFFER_WRITE) { 1355 if (cleaned_count >= E1000_RX_BUFFER_WRITE) {
1337 adapter->alloc_rx_buf(adapter, cleaned_count, 1356 adapter->alloc_rx_buf(rx_ring, cleaned_count,
1338 GFP_ATOMIC); 1357 GFP_ATOMIC);
1339 cleaned_count = 0; 1358 cleaned_count = 0;
1340 } 1359 }
@@ -1349,7 +1368,7 @@ next_desc:
1349 1368
1350 cleaned_count = e1000_desc_unused(rx_ring); 1369 cleaned_count = e1000_desc_unused(rx_ring);
1351 if (cleaned_count) 1370 if (cleaned_count)
1352 adapter->alloc_rx_buf(adapter, cleaned_count, GFP_ATOMIC); 1371 adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC);
1353 1372
1354 adapter->total_rx_bytes += total_rx_bytes; 1373 adapter->total_rx_bytes += total_rx_bytes;
1355 adapter->total_rx_packets += total_rx_packets; 1374 adapter->total_rx_packets += total_rx_packets;
@@ -1375,13 +1394,12 @@ static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb,
1375 * the return value indicates whether actual cleaning was done, there 1394 * the return value indicates whether actual cleaning was done, there
1376 * is no guarantee that everything was cleaned 1395 * is no guarantee that everything was cleaned
1377 **/ 1396 **/
1378 1397static bool e1000_clean_jumbo_rx_irq(struct e1000_ring *rx_ring, int *work_done,
1379static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, 1398 int work_to_do)
1380 int *work_done, int work_to_do)
1381{ 1399{
1400 struct e1000_adapter *adapter = rx_ring->adapter;
1382 struct net_device *netdev = adapter->netdev; 1401 struct net_device *netdev = adapter->netdev;
1383 struct pci_dev *pdev = adapter->pdev; 1402 struct pci_dev *pdev = adapter->pdev;
1384 struct e1000_ring *rx_ring = adapter->rx_ring;
1385 union e1000_rx_desc_extended *rx_desc, *next_rxd; 1403 union e1000_rx_desc_extended *rx_desc, *next_rxd;
1386 struct e1000_buffer *buffer_info, *next_buffer; 1404 struct e1000_buffer *buffer_info, *next_buffer;
1387 u32 length, staterr; 1405 u32 length, staterr;
@@ -1491,8 +1509,9 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
1491 1509
1492 /* Receive Checksum Offload XXX recompute due to CRC strip? */ 1510 /* Receive Checksum Offload XXX recompute due to CRC strip? */
1493 e1000_rx_checksum(adapter, staterr, 1511 e1000_rx_checksum(adapter, staterr,
1494 le16_to_cpu(rx_desc->wb.lower.hi_dword. 1512 rx_desc->wb.lower.hi_dword.csum_ip.csum, skb);
1495 csum_ip.csum), skb); 1513
1514 e1000_rx_hash(netdev, rx_desc->wb.lower.hi_dword.rss, skb);
1496 1515
1497 /* probably a little skewed due to removing CRC */ 1516 /* probably a little skewed due to removing CRC */
1498 total_rx_bytes += skb->len; 1517 total_rx_bytes += skb->len;
@@ -1513,7 +1532,7 @@ next_desc:
1513 1532
1514 /* return some buffers to hardware, one at a time is too slow */ 1533 /* return some buffers to hardware, one at a time is too slow */
1515 if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) { 1534 if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
1516 adapter->alloc_rx_buf(adapter, cleaned_count, 1535 adapter->alloc_rx_buf(rx_ring, cleaned_count,
1517 GFP_ATOMIC); 1536 GFP_ATOMIC);
1518 cleaned_count = 0; 1537 cleaned_count = 0;
1519 } 1538 }
@@ -1528,7 +1547,7 @@ next_desc:
1528 1547
1529 cleaned_count = e1000_desc_unused(rx_ring); 1548 cleaned_count = e1000_desc_unused(rx_ring);
1530 if (cleaned_count) 1549 if (cleaned_count)
1531 adapter->alloc_rx_buf(adapter, cleaned_count, GFP_ATOMIC); 1550 adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC);
1532 1551
1533 adapter->total_rx_bytes += total_rx_bytes; 1552 adapter->total_rx_bytes += total_rx_bytes;
1534 adapter->total_rx_packets += total_rx_packets; 1553 adapter->total_rx_packets += total_rx_packets;
@@ -1537,11 +1556,11 @@ next_desc:
1537 1556
1538/** 1557/**
1539 * e1000_clean_rx_ring - Free Rx Buffers per Queue 1558 * e1000_clean_rx_ring - Free Rx Buffers per Queue
1540 * @adapter: board private structure 1559 * @rx_ring: Rx descriptor ring
1541 **/ 1560 **/
1542static void e1000_clean_rx_ring(struct e1000_adapter *adapter) 1561static void e1000_clean_rx_ring(struct e1000_ring *rx_ring)
1543{ 1562{
1544 struct e1000_ring *rx_ring = adapter->rx_ring; 1563 struct e1000_adapter *adapter = rx_ring->adapter;
1545 struct e1000_buffer *buffer_info; 1564 struct e1000_buffer *buffer_info;
1546 struct e1000_ps_page *ps_page; 1565 struct e1000_ps_page *ps_page;
1547 struct pci_dev *pdev = adapter->pdev; 1566 struct pci_dev *pdev = adapter->pdev;
@@ -1601,8 +1620,8 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter)
1601 rx_ring->next_to_use = 0; 1620 rx_ring->next_to_use = 0;
1602 adapter->flags2 &= ~FLAG2_IS_DISCARDING; 1621 adapter->flags2 &= ~FLAG2_IS_DISCARDING;
1603 1622
1604 writel(0, adapter->hw.hw_addr + rx_ring->head); 1623 writel(0, rx_ring->head);
1605 writel(0, adapter->hw.hw_addr + rx_ring->tail); 1624 writel(0, rx_ring->tail);
1606} 1625}
1607 1626
1608static void e1000e_downshift_workaround(struct work_struct *work) 1627static void e1000e_downshift_workaround(struct work_struct *work)
@@ -1633,7 +1652,7 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
1633 */ 1652 */
1634 1653
1635 if (icr & E1000_ICR_LSC) { 1654 if (icr & E1000_ICR_LSC) {
1636 hw->mac.get_link_status = 1; 1655 hw->mac.get_link_status = true;
1637 /* 1656 /*
1638 * ICH8 workaround-- Call gig speed drop workaround on cable 1657 * ICH8 workaround-- Call gig speed drop workaround on cable
1639 * disconnect (LSC) before accessing any PHY registers 1658 * disconnect (LSC) before accessing any PHY registers
@@ -1699,7 +1718,7 @@ static irqreturn_t e1000_intr(int irq, void *data)
1699 */ 1718 */
1700 1719
1701 if (icr & E1000_ICR_LSC) { 1720 if (icr & E1000_ICR_LSC) {
1702 hw->mac.get_link_status = 1; 1721 hw->mac.get_link_status = true;
1703 /* 1722 /*
1704 * ICH8 workaround-- Call gig speed drop workaround on cable 1723 * ICH8 workaround-- Call gig speed drop workaround on cable
1705 * disconnect (LSC) before accessing any PHY registers 1724 * disconnect (LSC) before accessing any PHY registers
@@ -1756,7 +1775,7 @@ static irqreturn_t e1000_msix_other(int irq, void *data)
1756 if (icr & E1000_ICR_OTHER) { 1775 if (icr & E1000_ICR_OTHER) {
1757 if (!(icr & E1000_ICR_LSC)) 1776 if (!(icr & E1000_ICR_LSC))
1758 goto no_link_interrupt; 1777 goto no_link_interrupt;
1759 hw->mac.get_link_status = 1; 1778 hw->mac.get_link_status = true;
1760 /* guard against interrupt when we're going down */ 1779 /* guard against interrupt when we're going down */
1761 if (!test_bit(__E1000_DOWN, &adapter->state)) 1780 if (!test_bit(__E1000_DOWN, &adapter->state))
1762 mod_timer(&adapter->watchdog_timer, jiffies + 1); 1781 mod_timer(&adapter->watchdog_timer, jiffies + 1);
@@ -1781,7 +1800,7 @@ static irqreturn_t e1000_intr_msix_tx(int irq, void *data)
1781 adapter->total_tx_bytes = 0; 1800 adapter->total_tx_bytes = 0;
1782 adapter->total_tx_packets = 0; 1801 adapter->total_tx_packets = 0;
1783 1802
1784 if (!e1000_clean_tx_irq(adapter)) 1803 if (!e1000_clean_tx_irq(tx_ring))
1785 /* Ring was not completely cleaned, so fire another interrupt */ 1804 /* Ring was not completely cleaned, so fire another interrupt */
1786 ew32(ICS, tx_ring->ims_val); 1805 ew32(ICS, tx_ring->ims_val);
1787 1806
@@ -1792,14 +1811,15 @@ static irqreturn_t e1000_intr_msix_rx(int irq, void *data)
1792{ 1811{
1793 struct net_device *netdev = data; 1812 struct net_device *netdev = data;
1794 struct e1000_adapter *adapter = netdev_priv(netdev); 1813 struct e1000_adapter *adapter = netdev_priv(netdev);
1814 struct e1000_ring *rx_ring = adapter->rx_ring;
1795 1815
1796 /* Write the ITR value calculated at the end of the 1816 /* Write the ITR value calculated at the end of the
1797 * previous interrupt. 1817 * previous interrupt.
1798 */ 1818 */
1799 if (adapter->rx_ring->set_itr) { 1819 if (rx_ring->set_itr) {
1800 writel(1000000000 / (adapter->rx_ring->itr_val * 256), 1820 writel(1000000000 / (rx_ring->itr_val * 256),
1801 adapter->hw.hw_addr + adapter->rx_ring->itr_register); 1821 rx_ring->itr_register);
1802 adapter->rx_ring->set_itr = 0; 1822 rx_ring->set_itr = 0;
1803 } 1823 }
1804 1824
1805 if (napi_schedule_prep(&adapter->napi)) { 1825 if (napi_schedule_prep(&adapter->napi)) {
@@ -1839,9 +1859,9 @@ static void e1000_configure_msix(struct e1000_adapter *adapter)
1839 adapter->eiac_mask |= rx_ring->ims_val; 1859 adapter->eiac_mask |= rx_ring->ims_val;
1840 if (rx_ring->itr_val) 1860 if (rx_ring->itr_val)
1841 writel(1000000000 / (rx_ring->itr_val * 256), 1861 writel(1000000000 / (rx_ring->itr_val * 256),
1842 hw->hw_addr + rx_ring->itr_register); 1862 rx_ring->itr_register);
1843 else 1863 else
1844 writel(1, hw->hw_addr + rx_ring->itr_register); 1864 writel(1, rx_ring->itr_register);
1845 ivar = E1000_IVAR_INT_ALLOC_VALID | vector; 1865 ivar = E1000_IVAR_INT_ALLOC_VALID | vector;
1846 1866
1847 /* Configure Tx vector */ 1867 /* Configure Tx vector */
@@ -1849,9 +1869,9 @@ static void e1000_configure_msix(struct e1000_adapter *adapter)
1849 vector++; 1869 vector++;
1850 if (tx_ring->itr_val) 1870 if (tx_ring->itr_val)
1851 writel(1000000000 / (tx_ring->itr_val * 256), 1871 writel(1000000000 / (tx_ring->itr_val * 256),
1852 hw->hw_addr + tx_ring->itr_register); 1872 tx_ring->itr_register);
1853 else 1873 else
1854 writel(1, hw->hw_addr + tx_ring->itr_register); 1874 writel(1, tx_ring->itr_register);
1855 adapter->eiac_mask |= tx_ring->ims_val; 1875 adapter->eiac_mask |= tx_ring->ims_val;
1856 ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 8); 1876 ivar |= ((E1000_IVAR_INT_ALLOC_VALID | vector) << 8);
1857 1877
@@ -1966,7 +1986,8 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
1966 netdev); 1986 netdev);
1967 if (err) 1987 if (err)
1968 goto out; 1988 goto out;
1969 adapter->rx_ring->itr_register = E1000_EITR_82574(vector); 1989 adapter->rx_ring->itr_register = adapter->hw.hw_addr +
1990 E1000_EITR_82574(vector);
1970 adapter->rx_ring->itr_val = adapter->itr; 1991 adapter->rx_ring->itr_val = adapter->itr;
1971 vector++; 1992 vector++;
1972 1993
@@ -1981,7 +2002,8 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
1981 netdev); 2002 netdev);
1982 if (err) 2003 if (err)
1983 goto out; 2004 goto out;
1984 adapter->tx_ring->itr_register = E1000_EITR_82574(vector); 2005 adapter->tx_ring->itr_register = adapter->hw.hw_addr +
2006 E1000_EITR_82574(vector);
1985 adapter->tx_ring->itr_val = adapter->itr; 2007 adapter->tx_ring->itr_val = adapter->itr;
1986 vector++; 2008 vector++;
1987 2009
@@ -2162,13 +2184,13 @@ static int e1000_alloc_ring_dma(struct e1000_adapter *adapter,
2162 2184
2163/** 2185/**
2164 * e1000e_setup_tx_resources - allocate Tx resources (Descriptors) 2186 * e1000e_setup_tx_resources - allocate Tx resources (Descriptors)
2165 * @adapter: board private structure 2187 * @tx_ring: Tx descriptor ring
2166 * 2188 *
2167 * Return 0 on success, negative on failure 2189 * Return 0 on success, negative on failure
2168 **/ 2190 **/
2169int e1000e_setup_tx_resources(struct e1000_adapter *adapter) 2191int e1000e_setup_tx_resources(struct e1000_ring *tx_ring)
2170{ 2192{
2171 struct e1000_ring *tx_ring = adapter->tx_ring; 2193 struct e1000_adapter *adapter = tx_ring->adapter;
2172 int err = -ENOMEM, size; 2194 int err = -ENOMEM, size;
2173 2195
2174 size = sizeof(struct e1000_buffer) * tx_ring->count; 2196 size = sizeof(struct e1000_buffer) * tx_ring->count;
@@ -2196,13 +2218,13 @@ err:
2196 2218
2197/** 2219/**
2198 * e1000e_setup_rx_resources - allocate Rx resources (Descriptors) 2220 * e1000e_setup_rx_resources - allocate Rx resources (Descriptors)
2199 * @adapter: board private structure 2221 * @rx_ring: Rx descriptor ring
2200 * 2222 *
2201 * Returns 0 on success, negative on failure 2223 * Returns 0 on success, negative on failure
2202 **/ 2224 **/
2203int e1000e_setup_rx_resources(struct e1000_adapter *adapter) 2225int e1000e_setup_rx_resources(struct e1000_ring *rx_ring)
2204{ 2226{
2205 struct e1000_ring *rx_ring = adapter->rx_ring; 2227 struct e1000_adapter *adapter = rx_ring->adapter;
2206 struct e1000_buffer *buffer_info; 2228 struct e1000_buffer *buffer_info;
2207 int i, size, desc_len, err = -ENOMEM; 2229 int i, size, desc_len, err = -ENOMEM;
2208 2230
@@ -2249,18 +2271,18 @@ err:
2249 2271
2250/** 2272/**
2251 * e1000_clean_tx_ring - Free Tx Buffers 2273 * e1000_clean_tx_ring - Free Tx Buffers
2252 * @adapter: board private structure 2274 * @tx_ring: Tx descriptor ring
2253 **/ 2275 **/
2254static void e1000_clean_tx_ring(struct e1000_adapter *adapter) 2276static void e1000_clean_tx_ring(struct e1000_ring *tx_ring)
2255{ 2277{
2256 struct e1000_ring *tx_ring = adapter->tx_ring; 2278 struct e1000_adapter *adapter = tx_ring->adapter;
2257 struct e1000_buffer *buffer_info; 2279 struct e1000_buffer *buffer_info;
2258 unsigned long size; 2280 unsigned long size;
2259 unsigned int i; 2281 unsigned int i;
2260 2282
2261 for (i = 0; i < tx_ring->count; i++) { 2283 for (i = 0; i < tx_ring->count; i++) {
2262 buffer_info = &tx_ring->buffer_info[i]; 2284 buffer_info = &tx_ring->buffer_info[i];
2263 e1000_put_txbuf(adapter, buffer_info); 2285 e1000_put_txbuf(tx_ring, buffer_info);
2264 } 2286 }
2265 2287
2266 netdev_reset_queue(adapter->netdev); 2288 netdev_reset_queue(adapter->netdev);
@@ -2272,22 +2294,22 @@ static void e1000_clean_tx_ring(struct e1000_adapter *adapter)
2272 tx_ring->next_to_use = 0; 2294 tx_ring->next_to_use = 0;
2273 tx_ring->next_to_clean = 0; 2295 tx_ring->next_to_clean = 0;
2274 2296
2275 writel(0, adapter->hw.hw_addr + tx_ring->head); 2297 writel(0, tx_ring->head);
2276 writel(0, adapter->hw.hw_addr + tx_ring->tail); 2298 writel(0, tx_ring->tail);
2277} 2299}
2278 2300
2279/** 2301/**
2280 * e1000e_free_tx_resources - Free Tx Resources per Queue 2302 * e1000e_free_tx_resources - Free Tx Resources per Queue
2281 * @adapter: board private structure 2303 * @tx_ring: Tx descriptor ring
2282 * 2304 *
2283 * Free all transmit software resources 2305 * Free all transmit software resources
2284 **/ 2306 **/
2285void e1000e_free_tx_resources(struct e1000_adapter *adapter) 2307void e1000e_free_tx_resources(struct e1000_ring *tx_ring)
2286{ 2308{
2309 struct e1000_adapter *adapter = tx_ring->adapter;
2287 struct pci_dev *pdev = adapter->pdev; 2310 struct pci_dev *pdev = adapter->pdev;
2288 struct e1000_ring *tx_ring = adapter->tx_ring;
2289 2311
2290 e1000_clean_tx_ring(adapter); 2312 e1000_clean_tx_ring(tx_ring);
2291 2313
2292 vfree(tx_ring->buffer_info); 2314 vfree(tx_ring->buffer_info);
2293 tx_ring->buffer_info = NULL; 2315 tx_ring->buffer_info = NULL;
@@ -2299,18 +2321,17 @@ void e1000e_free_tx_resources(struct e1000_adapter *adapter)
2299 2321
2300/** 2322/**
2301 * e1000e_free_rx_resources - Free Rx Resources 2323 * e1000e_free_rx_resources - Free Rx Resources
2302 * @adapter: board private structure 2324 * @rx_ring: Rx descriptor ring
2303 * 2325 *
2304 * Free all receive software resources 2326 * Free all receive software resources
2305 **/ 2327 **/
2306 2328void e1000e_free_rx_resources(struct e1000_ring *rx_ring)
2307void e1000e_free_rx_resources(struct e1000_adapter *adapter)
2308{ 2329{
2330 struct e1000_adapter *adapter = rx_ring->adapter;
2309 struct pci_dev *pdev = adapter->pdev; 2331 struct pci_dev *pdev = adapter->pdev;
2310 struct e1000_ring *rx_ring = adapter->rx_ring;
2311 int i; 2332 int i;
2312 2333
2313 e1000_clean_rx_ring(adapter); 2334 e1000_clean_rx_ring(rx_ring);
2314 2335
2315 for (i = 0; i < rx_ring->count; i++) 2336 for (i = 0; i < rx_ring->count; i++)
2316 kfree(rx_ring->buffer_info[i].ps_pages); 2337 kfree(rx_ring->buffer_info[i].ps_pages);
@@ -2464,13 +2485,19 @@ set_itr_now:
2464 **/ 2485 **/
2465static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter) 2486static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
2466{ 2487{
2467 adapter->tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL); 2488 int size = sizeof(struct e1000_ring);
2489
2490 adapter->tx_ring = kzalloc(size, GFP_KERNEL);
2468 if (!adapter->tx_ring) 2491 if (!adapter->tx_ring)
2469 goto err; 2492 goto err;
2493 adapter->tx_ring->count = adapter->tx_ring_count;
2494 adapter->tx_ring->adapter = adapter;
2470 2495
2471 adapter->rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL); 2496 adapter->rx_ring = kzalloc(size, GFP_KERNEL);
2472 if (!adapter->rx_ring) 2497 if (!adapter->rx_ring)
2473 goto err; 2498 goto err;
2499 adapter->rx_ring->count = adapter->rx_ring_count;
2500 adapter->rx_ring->adapter = adapter;
2474 2501
2475 return 0; 2502 return 0;
2476err: 2503err:
@@ -2498,10 +2525,10 @@ static int e1000_clean(struct napi_struct *napi, int budget)
2498 !(adapter->rx_ring->ims_val & adapter->tx_ring->ims_val)) 2525 !(adapter->rx_ring->ims_val & adapter->tx_ring->ims_val))
2499 goto clean_rx; 2526 goto clean_rx;
2500 2527
2501 tx_cleaned = e1000_clean_tx_irq(adapter); 2528 tx_cleaned = e1000_clean_tx_irq(adapter->tx_ring);
2502 2529
2503clean_rx: 2530clean_rx:
2504 adapter->clean_rx(adapter, &work_done, budget); 2531 adapter->clean_rx(adapter->rx_ring, &work_done, budget);
2505 2532
2506 if (!tx_cleaned) 2533 if (!tx_cleaned)
2507 work_done = budget; 2534 work_done = budget;
@@ -2746,8 +2773,7 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
2746 struct e1000_hw *hw = &adapter->hw; 2773 struct e1000_hw *hw = &adapter->hw;
2747 struct e1000_ring *tx_ring = adapter->tx_ring; 2774 struct e1000_ring *tx_ring = adapter->tx_ring;
2748 u64 tdba; 2775 u64 tdba;
2749 u32 tdlen, tctl, tipg, tarc; 2776 u32 tdlen, tarc;
2750 u32 ipgr1, ipgr2;
2751 2777
2752 /* Setup the HW Tx Head and Tail descriptor pointers */ 2778 /* Setup the HW Tx Head and Tail descriptor pointers */
2753 tdba = tx_ring->dma; 2779 tdba = tx_ring->dma;
@@ -2757,20 +2783,8 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
2757 ew32(TDLEN, tdlen); 2783 ew32(TDLEN, tdlen);
2758 ew32(TDH, 0); 2784 ew32(TDH, 0);
2759 ew32(TDT, 0); 2785 ew32(TDT, 0);
2760 tx_ring->head = E1000_TDH; 2786 tx_ring->head = adapter->hw.hw_addr + E1000_TDH;
2761 tx_ring->tail = E1000_TDT; 2787 tx_ring->tail = adapter->hw.hw_addr + E1000_TDT;
2762
2763 /* Set the default values for the Tx Inter Packet Gap timer */
2764 tipg = DEFAULT_82543_TIPG_IPGT_COPPER; /* 8 */
2765 ipgr1 = DEFAULT_82543_TIPG_IPGR1; /* 8 */
2766 ipgr2 = DEFAULT_82543_TIPG_IPGR2; /* 6 */
2767
2768 if (adapter->flags & FLAG_TIPG_MEDIUM_FOR_80003ESLAN)
2769 ipgr2 = DEFAULT_80003ES2LAN_TIPG_IPGR2; /* 7 */
2770
2771 tipg |= ipgr1 << E1000_TIPG_IPGR1_SHIFT;
2772 tipg |= ipgr2 << E1000_TIPG_IPGR2_SHIFT;
2773 ew32(TIPG, tipg);
2774 2788
2775 /* Set the Tx Interrupt Delay register */ 2789 /* Set the Tx Interrupt Delay register */
2776 ew32(TIDV, adapter->tx_int_delay); 2790 ew32(TIDV, adapter->tx_int_delay);
@@ -2793,15 +2807,9 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
2793 */ 2807 */
2794 txdctl |= E1000_TXDCTL_DMA_BURST_ENABLE; 2808 txdctl |= E1000_TXDCTL_DMA_BURST_ENABLE;
2795 ew32(TXDCTL(0), txdctl); 2809 ew32(TXDCTL(0), txdctl);
2796 /* erratum work around: set txdctl the same for both queues */
2797 ew32(TXDCTL(1), txdctl);
2798 } 2810 }
2799 2811 /* erratum work around: set txdctl the same for both queues */
2800 /* Program the Transmit Control Register */ 2812 ew32(TXDCTL(1), er32(TXDCTL(0)));
2801 tctl = er32(TCTL);
2802 tctl &= ~E1000_TCTL_CT;
2803 tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
2804 (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
2805 2813
2806 if (adapter->flags & FLAG_TARC_SPEED_MODE_BIT) { 2814 if (adapter->flags & FLAG_TARC_SPEED_MODE_BIT) {
2807 tarc = er32(TARC(0)); 2815 tarc = er32(TARC(0));
@@ -2834,8 +2842,6 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
2834 /* enable Report Status bit */ 2842 /* enable Report Status bit */
2835 adapter->txd_cmd |= E1000_TXD_CMD_RS; 2843 adapter->txd_cmd |= E1000_TXD_CMD_RS;
2836 2844
2837 ew32(TCTL, tctl);
2838
2839 e1000e_config_collision_dist(hw); 2845 e1000e_config_collision_dist(hw);
2840} 2846}
2841 2847
@@ -2944,8 +2950,7 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
2944 * per packet. 2950 * per packet.
2945 */ 2951 */
2946 pages = PAGE_USE_COUNT(adapter->netdev->mtu); 2952 pages = PAGE_USE_COUNT(adapter->netdev->mtu);
2947 if (!(adapter->flags & FLAG_HAS_ERT) && (pages <= 3) && 2953 if ((pages <= 3) && (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE))
2948 (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE))
2949 adapter->rx_ps_pages = pages; 2954 adapter->rx_ps_pages = pages;
2950 else 2955 else
2951 adapter->rx_ps_pages = 0; 2956 adapter->rx_ps_pages = 0;
@@ -3072,8 +3077,8 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
3072 ew32(RDLEN, rdlen); 3077 ew32(RDLEN, rdlen);
3073 ew32(RDH, 0); 3078 ew32(RDH, 0);
3074 ew32(RDT, 0); 3079 ew32(RDT, 0);
3075 rx_ring->head = E1000_RDH; 3080 rx_ring->head = adapter->hw.hw_addr + E1000_RDH;
3076 rx_ring->tail = E1000_RDT; 3081 rx_ring->tail = adapter->hw.hw_addr + E1000_RDT;
3077 3082
3078 /* Enable Receive Checksum Offload for TCP and UDP */ 3083 /* Enable Receive Checksum Offload for TCP and UDP */
3079 rxcsum = er32(RXCSUM); 3084 rxcsum = er32(RXCSUM);
@@ -3092,23 +3097,14 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
3092 } 3097 }
3093 ew32(RXCSUM, rxcsum); 3098 ew32(RXCSUM, rxcsum);
3094 3099
3095 /* 3100 if (adapter->hw.mac.type == e1000_pch2lan) {
3096 * Enable early receives on supported devices, only takes effect when 3101 /*
3097 * packet size is equal or larger than the specified value (in 8 byte 3102 * With jumbo frames, excessive C-state transition
3098 * units), e.g. using jumbo frames when setting to E1000_ERT_2048 3103 * latencies result in dropped transactions.
3099 */ 3104 */
3100 if ((adapter->flags & FLAG_HAS_ERT) ||
3101 (adapter->hw.mac.type == e1000_pch2lan)) {
3102 if (adapter->netdev->mtu > ETH_DATA_LEN) { 3105 if (adapter->netdev->mtu > ETH_DATA_LEN) {
3103 u32 rxdctl = er32(RXDCTL(0)); 3106 u32 rxdctl = er32(RXDCTL(0));
3104 ew32(RXDCTL(0), rxdctl | 0x3); 3107 ew32(RXDCTL(0), rxdctl | 0x3);
3105 if (adapter->flags & FLAG_HAS_ERT)
3106 ew32(ERT, E1000_ERT_2048 | (1 << 13));
3107 /*
3108 * With jumbo frames and early-receive enabled,
3109 * excessive C-state transition latencies result in
3110 * dropped transactions.
3111 */
3112 pm_qos_update_request(&adapter->netdev->pm_qos_req, 55); 3108 pm_qos_update_request(&adapter->netdev->pm_qos_req, 55);
3113 } else { 3109 } else {
3114 pm_qos_update_request(&adapter->netdev->pm_qos_req, 3110 pm_qos_update_request(&adapter->netdev->pm_qos_req,
@@ -3268,22 +3264,62 @@ static void e1000e_set_rx_mode(struct net_device *netdev)
3268 e1000e_vlan_strip_disable(adapter); 3264 e1000e_vlan_strip_disable(adapter);
3269} 3265}
3270 3266
3267static void e1000e_setup_rss_hash(struct e1000_adapter *adapter)
3268{
3269 struct e1000_hw *hw = &adapter->hw;
3270 u32 mrqc, rxcsum;
3271 int i;
3272 static const u32 rsskey[10] = {
3273 0xda565a6d, 0xc20e5b25, 0x3d256741, 0xb08fa343, 0xcb2bcad0,
3274 0xb4307bae, 0xa32dcb77, 0x0cf23080, 0x3bb7426a, 0xfa01acbe
3275 };
3276
3277 /* Fill out hash function seed */
3278 for (i = 0; i < 10; i++)
3279 ew32(RSSRK(i), rsskey[i]);
3280
3281 /* Direct all traffic to queue 0 */
3282 for (i = 0; i < 32; i++)
3283 ew32(RETA(i), 0);
3284
3285 /*
3286 * Disable raw packet checksumming so that RSS hash is placed in
3287 * descriptor on writeback.
3288 */
3289 rxcsum = er32(RXCSUM);
3290 rxcsum |= E1000_RXCSUM_PCSD;
3291
3292 ew32(RXCSUM, rxcsum);
3293
3294 mrqc = (E1000_MRQC_RSS_FIELD_IPV4 |
3295 E1000_MRQC_RSS_FIELD_IPV4_TCP |
3296 E1000_MRQC_RSS_FIELD_IPV6 |
3297 E1000_MRQC_RSS_FIELD_IPV6_TCP |
3298 E1000_MRQC_RSS_FIELD_IPV6_TCP_EX);
3299
3300 ew32(MRQC, mrqc);
3301}
3302
3271/** 3303/**
3272 * e1000_configure - configure the hardware for Rx and Tx 3304 * e1000_configure - configure the hardware for Rx and Tx
3273 * @adapter: private board structure 3305 * @adapter: private board structure
3274 **/ 3306 **/
3275static void e1000_configure(struct e1000_adapter *adapter) 3307static void e1000_configure(struct e1000_adapter *adapter)
3276{ 3308{
3309 struct e1000_ring *rx_ring = adapter->rx_ring;
3310
3277 e1000e_set_rx_mode(adapter->netdev); 3311 e1000e_set_rx_mode(adapter->netdev);
3278 3312
3279 e1000_restore_vlan(adapter); 3313 e1000_restore_vlan(adapter);
3280 e1000_init_manageability_pt(adapter); 3314 e1000_init_manageability_pt(adapter);
3281 3315
3282 e1000_configure_tx(adapter); 3316 e1000_configure_tx(adapter);
3317
3318 if (adapter->netdev->features & NETIF_F_RXHASH)
3319 e1000e_setup_rss_hash(adapter);
3283 e1000_setup_rctl(adapter); 3320 e1000_setup_rctl(adapter);
3284 e1000_configure_rx(adapter); 3321 e1000_configure_rx(adapter);
3285 adapter->alloc_rx_buf(adapter, e1000_desc_unused(adapter->rx_ring), 3322 adapter->alloc_rx_buf(rx_ring, e1000_desc_unused(rx_ring), GFP_KERNEL);
3286 GFP_KERNEL);
3287} 3323}
3288 3324
3289/** 3325/**
@@ -3379,9 +3415,7 @@ void e1000e_reset(struct e1000_adapter *adapter)
3379 * if short on Rx space, Rx wins and must trump Tx 3415 * if short on Rx space, Rx wins and must trump Tx
3380 * adjustment or use Early Receive if available 3416 * adjustment or use Early Receive if available
3381 */ 3417 */
3382 if ((pba < min_rx_space) && 3418 if (pba < min_rx_space)
3383 (!(adapter->flags & FLAG_HAS_ERT)))
3384 /* ERT enabled in e1000_configure_rx */
3385 pba = min_rx_space; 3419 pba = min_rx_space;
3386 } 3420 }
3387 3421
@@ -3395,8 +3429,6 @@ void e1000e_reset(struct e1000_adapter *adapter)
3395 * (or the size used for early receive) above it in the Rx FIFO. 3429 * (or the size used for early receive) above it in the Rx FIFO.
3396 * Set it to the lower of: 3430 * Set it to the lower of:
3397 * - 90% of the Rx FIFO size, and 3431 * - 90% of the Rx FIFO size, and
3398 * - the full Rx FIFO size minus the early receive size (for parts
3399 * with ERT support assuming ERT set to E1000_ERT_2048), or
3400 * - the full Rx FIFO size minus one full frame 3432 * - the full Rx FIFO size minus one full frame
3401 */ 3433 */
3402 if (adapter->flags & FLAG_DISABLE_FC_PAUSE_TIME) 3434 if (adapter->flags & FLAG_DISABLE_FC_PAUSE_TIME)
@@ -3407,14 +3439,19 @@ void e1000e_reset(struct e1000_adapter *adapter)
3407 fc->current_mode = fc->requested_mode; 3439 fc->current_mode = fc->requested_mode;
3408 3440
3409 switch (hw->mac.type) { 3441 switch (hw->mac.type) {
3442 case e1000_ich9lan:
3443 case e1000_ich10lan:
3444 if (adapter->netdev->mtu > ETH_DATA_LEN) {
3445 pba = 14;
3446 ew32(PBA, pba);
3447 fc->high_water = 0x2800;
3448 fc->low_water = fc->high_water - 8;
3449 break;
3450 }
3451 /* fall-through */
3410 default: 3452 default:
3411 if ((adapter->flags & FLAG_HAS_ERT) && 3453 hwm = min(((pba << 10) * 9 / 10),
3412 (adapter->netdev->mtu > ETH_DATA_LEN)) 3454 ((pba << 10) - adapter->max_frame_size));
3413 hwm = min(((pba << 10) * 9 / 10),
3414 ((pba << 10) - (E1000_ERT_2048 << 3)));
3415 else
3416 hwm = min(((pba << 10) * 9 / 10),
3417 ((pba << 10) - adapter->max_frame_size));
3418 3455
3419 fc->high_water = hwm & E1000_FCRTH_RTH; /* 8-byte granularity */ 3456 fc->high_water = hwm & E1000_FCRTH_RTH; /* 8-byte granularity */
3420 fc->low_water = fc->high_water - 8; 3457 fc->low_water = fc->high_water - 8;
@@ -3447,11 +3484,10 @@ void e1000e_reset(struct e1000_adapter *adapter)
3447 3484
3448 /* 3485 /*
3449 * Disable Adaptive Interrupt Moderation if 2 full packets cannot 3486 * Disable Adaptive Interrupt Moderation if 2 full packets cannot
3450 * fit in receive buffer and early-receive not supported. 3487 * fit in receive buffer.
3451 */ 3488 */
3452 if (adapter->itr_setting & 0x3) { 3489 if (adapter->itr_setting & 0x3) {
3453 if (((adapter->max_frame_size * 2) > (pba << 10)) && 3490 if ((adapter->max_frame_size * 2) > (pba << 10)) {
3454 !(adapter->flags & FLAG_HAS_ERT)) {
3455 if (!(adapter->flags2 & FLAG2_DISABLE_AIM)) { 3491 if (!(adapter->flags2 & FLAG2_DISABLE_AIM)) {
3456 dev_info(&adapter->pdev->dev, 3492 dev_info(&adapter->pdev->dev,
3457 "Interrupt Throttle Rate turned off\n"); 3493 "Interrupt Throttle Rate turned off\n");
@@ -3593,8 +3629,8 @@ void e1000e_down(struct e1000_adapter *adapter)
3593 spin_unlock(&adapter->stats64_lock); 3629 spin_unlock(&adapter->stats64_lock);
3594 3630
3595 e1000e_flush_descriptors(adapter); 3631 e1000e_flush_descriptors(adapter);
3596 e1000_clean_tx_ring(adapter); 3632 e1000_clean_tx_ring(adapter->tx_ring);
3597 e1000_clean_rx_ring(adapter); 3633 e1000_clean_rx_ring(adapter->rx_ring);
3598 3634
3599 adapter->link_speed = 0; 3635 adapter->link_speed = 0;
3600 adapter->link_duplex = 0; 3636 adapter->link_duplex = 0;
@@ -3634,6 +3670,8 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
3634 adapter->rx_ps_bsize0 = 128; 3670 adapter->rx_ps_bsize0 = 128;
3635 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; 3671 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
3636 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; 3672 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
3673 adapter->tx_ring_count = E1000_DEFAULT_TXD;
3674 adapter->rx_ring_count = E1000_DEFAULT_RXD;
3637 3675
3638 spin_lock_init(&adapter->stats64_lock); 3676 spin_lock_init(&adapter->stats64_lock);
3639 3677
@@ -3721,8 +3759,9 @@ static int e1000_test_msi_interrupt(struct e1000_adapter *adapter)
3721 if (adapter->flags & FLAG_MSI_TEST_FAILED) { 3759 if (adapter->flags & FLAG_MSI_TEST_FAILED) {
3722 adapter->int_mode = E1000E_INT_MODE_LEGACY; 3760 adapter->int_mode = E1000E_INT_MODE_LEGACY;
3723 e_info("MSI interrupt test failed, using legacy interrupt.\n"); 3761 e_info("MSI interrupt test failed, using legacy interrupt.\n");
3724 } else 3762 } else {
3725 e_dbg("MSI interrupt test succeeded!\n"); 3763 e_dbg("MSI interrupt test succeeded!\n");
3764 }
3726 3765
3727 free_irq(adapter->pdev->irq, netdev); 3766 free_irq(adapter->pdev->irq, netdev);
3728 pci_disable_msi(adapter->pdev); 3767 pci_disable_msi(adapter->pdev);
@@ -3792,12 +3831,12 @@ static int e1000_open(struct net_device *netdev)
3792 netif_carrier_off(netdev); 3831 netif_carrier_off(netdev);
3793 3832
3794 /* allocate transmit descriptors */ 3833 /* allocate transmit descriptors */
3795 err = e1000e_setup_tx_resources(adapter); 3834 err = e1000e_setup_tx_resources(adapter->tx_ring);
3796 if (err) 3835 if (err)
3797 goto err_setup_tx; 3836 goto err_setup_tx;
3798 3837
3799 /* allocate receive descriptors */ 3838 /* allocate receive descriptors */
3800 err = e1000e_setup_rx_resources(adapter); 3839 err = e1000e_setup_rx_resources(adapter->rx_ring);
3801 if (err) 3840 if (err)
3802 goto err_setup_rx; 3841 goto err_setup_rx;
3803 3842
@@ -3817,9 +3856,8 @@ static int e1000_open(struct net_device *netdev)
3817 E1000_MNG_DHCP_COOKIE_STATUS_VLAN)) 3856 E1000_MNG_DHCP_COOKIE_STATUS_VLAN))
3818 e1000_update_mng_vlan(adapter); 3857 e1000_update_mng_vlan(adapter);
3819 3858
3820 /* DMA latency requirement to workaround early-receive/jumbo issue */ 3859 /* DMA latency requirement to workaround jumbo issue */
3821 if ((adapter->flags & FLAG_HAS_ERT) || 3860 if (adapter->hw.mac.type == e1000_pch2lan)
3822 (adapter->hw.mac.type == e1000_pch2lan))
3823 pm_qos_add_request(&adapter->netdev->pm_qos_req, 3861 pm_qos_add_request(&adapter->netdev->pm_qos_req,
3824 PM_QOS_CPU_DMA_LATENCY, 3862 PM_QOS_CPU_DMA_LATENCY,
3825 PM_QOS_DEFAULT_VALUE); 3863 PM_QOS_DEFAULT_VALUE);
@@ -3873,9 +3911,9 @@ static int e1000_open(struct net_device *netdev)
3873err_req_irq: 3911err_req_irq:
3874 e1000e_release_hw_control(adapter); 3912 e1000e_release_hw_control(adapter);
3875 e1000_power_down_phy(adapter); 3913 e1000_power_down_phy(adapter);
3876 e1000e_free_rx_resources(adapter); 3914 e1000e_free_rx_resources(adapter->rx_ring);
3877err_setup_rx: 3915err_setup_rx:
3878 e1000e_free_tx_resources(adapter); 3916 e1000e_free_tx_resources(adapter->tx_ring);
3879err_setup_tx: 3917err_setup_tx:
3880 e1000e_reset(adapter); 3918 e1000e_reset(adapter);
3881 pm_runtime_put_sync(&pdev->dev); 3919 pm_runtime_put_sync(&pdev->dev);
@@ -3911,8 +3949,8 @@ static int e1000_close(struct net_device *netdev)
3911 } 3949 }
3912 e1000_power_down_phy(adapter); 3950 e1000_power_down_phy(adapter);
3913 3951
3914 e1000e_free_tx_resources(adapter); 3952 e1000e_free_tx_resources(adapter->tx_ring);
3915 e1000e_free_rx_resources(adapter); 3953 e1000e_free_rx_resources(adapter->rx_ring);
3916 3954
3917 /* 3955 /*
3918 * kill manageability vlan ID if supported, but not if a vlan with 3956 * kill manageability vlan ID if supported, but not if a vlan with
@@ -3930,8 +3968,7 @@ static int e1000_close(struct net_device *netdev)
3930 !test_bit(__E1000_TESTING, &adapter->state)) 3968 !test_bit(__E1000_TESTING, &adapter->state))
3931 e1000e_release_hw_control(adapter); 3969 e1000e_release_hw_control(adapter);
3932 3970
3933 if ((adapter->flags & FLAG_HAS_ERT) || 3971 if (adapter->hw.mac.type == e1000_pch2lan)
3934 (adapter->hw.mac.type == e1000_pch2lan))
3935 pm_qos_remove_request(&adapter->netdev->pm_qos_req); 3972 pm_qos_remove_request(&adapter->netdev->pm_qos_req);
3936 3973
3937 pm_runtime_put_sync(&pdev->dev); 3974 pm_runtime_put_sync(&pdev->dev);
@@ -4569,10 +4606,8 @@ link_up:
4569#define E1000_TX_FLAGS_VLAN_MASK 0xffff0000 4606#define E1000_TX_FLAGS_VLAN_MASK 0xffff0000
4570#define E1000_TX_FLAGS_VLAN_SHIFT 16 4607#define E1000_TX_FLAGS_VLAN_SHIFT 16
4571 4608
4572static int e1000_tso(struct e1000_adapter *adapter, 4609static int e1000_tso(struct e1000_ring *tx_ring, struct sk_buff *skb)
4573 struct sk_buff *skb)
4574{ 4610{
4575 struct e1000_ring *tx_ring = adapter->tx_ring;
4576 struct e1000_context_desc *context_desc; 4611 struct e1000_context_desc *context_desc;
4577 struct e1000_buffer *buffer_info; 4612 struct e1000_buffer *buffer_info;
4578 unsigned int i; 4613 unsigned int i;
@@ -4641,9 +4676,9 @@ static int e1000_tso(struct e1000_adapter *adapter,
4641 return 1; 4676 return 1;
4642} 4677}
4643 4678
4644static bool e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb) 4679static bool e1000_tx_csum(struct e1000_ring *tx_ring, struct sk_buff *skb)
4645{ 4680{
4646 struct e1000_ring *tx_ring = adapter->tx_ring; 4681 struct e1000_adapter *adapter = tx_ring->adapter;
4647 struct e1000_context_desc *context_desc; 4682 struct e1000_context_desc *context_desc;
4648 struct e1000_buffer *buffer_info; 4683 struct e1000_buffer *buffer_info;
4649 unsigned int i; 4684 unsigned int i;
@@ -4704,12 +4739,11 @@ static bool e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb)
4704#define E1000_MAX_PER_TXD 8192 4739#define E1000_MAX_PER_TXD 8192
4705#define E1000_MAX_TXD_PWR 12 4740#define E1000_MAX_TXD_PWR 12
4706 4741
4707static int e1000_tx_map(struct e1000_adapter *adapter, 4742static int e1000_tx_map(struct e1000_ring *tx_ring, struct sk_buff *skb,
4708 struct sk_buff *skb, unsigned int first, 4743 unsigned int first, unsigned int max_per_txd,
4709 unsigned int max_per_txd, unsigned int nr_frags, 4744 unsigned int nr_frags, unsigned int mss)
4710 unsigned int mss)
4711{ 4745{
4712 struct e1000_ring *tx_ring = adapter->tx_ring; 4746 struct e1000_adapter *adapter = tx_ring->adapter;
4713 struct pci_dev *pdev = adapter->pdev; 4747 struct pci_dev *pdev = adapter->pdev;
4714 struct e1000_buffer *buffer_info; 4748 struct e1000_buffer *buffer_info;
4715 unsigned int len = skb_headlen(skb); 4749 unsigned int len = skb_headlen(skb);
@@ -4795,16 +4829,15 @@ dma_error:
4795 i += tx_ring->count; 4829 i += tx_ring->count;
4796 i--; 4830 i--;
4797 buffer_info = &tx_ring->buffer_info[i]; 4831 buffer_info = &tx_ring->buffer_info[i];
4798 e1000_put_txbuf(adapter, buffer_info); 4832 e1000_put_txbuf(tx_ring, buffer_info);
4799 } 4833 }
4800 4834
4801 return 0; 4835 return 0;
4802} 4836}
4803 4837
4804static void e1000_tx_queue(struct e1000_adapter *adapter, 4838static void e1000_tx_queue(struct e1000_ring *tx_ring, int tx_flags, int count)
4805 int tx_flags, int count)
4806{ 4839{
4807 struct e1000_ring *tx_ring = adapter->tx_ring; 4840 struct e1000_adapter *adapter = tx_ring->adapter;
4808 struct e1000_tx_desc *tx_desc = NULL; 4841 struct e1000_tx_desc *tx_desc = NULL;
4809 struct e1000_buffer *buffer_info; 4842 struct e1000_buffer *buffer_info;
4810 u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS; 4843 u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
@@ -4857,9 +4890,9 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
4857 tx_ring->next_to_use = i; 4890 tx_ring->next_to_use = i;
4858 4891
4859 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) 4892 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
4860 e1000e_update_tdt_wa(adapter, i); 4893 e1000e_update_tdt_wa(tx_ring, i);
4861 else 4894 else
4862 writel(i, adapter->hw.hw_addr + tx_ring->tail); 4895 writel(i, tx_ring->tail);
4863 4896
4864 /* 4897 /*
4865 * we need this if more than one processor can write to our tail 4898 * we need this if more than one processor can write to our tail
@@ -4907,11 +4940,11 @@ static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,
4907 return 0; 4940 return 0;
4908} 4941}
4909 4942
4910static int __e1000_maybe_stop_tx(struct net_device *netdev, int size) 4943static int __e1000_maybe_stop_tx(struct e1000_ring *tx_ring, int size)
4911{ 4944{
4912 struct e1000_adapter *adapter = netdev_priv(netdev); 4945 struct e1000_adapter *adapter = tx_ring->adapter;
4913 4946
4914 netif_stop_queue(netdev); 4947 netif_stop_queue(adapter->netdev);
4915 /* 4948 /*
4916 * Herbert's original patch had: 4949 * Herbert's original patch had:
4917 * smp_mb__after_netif_stop_queue(); 4950 * smp_mb__after_netif_stop_queue();
@@ -4923,25 +4956,23 @@ static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)
4923 * We need to check again in a case another CPU has just 4956 * We need to check again in a case another CPU has just
4924 * made room available. 4957 * made room available.
4925 */ 4958 */
4926 if (e1000_desc_unused(adapter->tx_ring) < size) 4959 if (e1000_desc_unused(tx_ring) < size)
4927 return -EBUSY; 4960 return -EBUSY;
4928 4961
4929 /* A reprieve! */ 4962 /* A reprieve! */
4930 netif_start_queue(netdev); 4963 netif_start_queue(adapter->netdev);
4931 ++adapter->restart_queue; 4964 ++adapter->restart_queue;
4932 return 0; 4965 return 0;
4933} 4966}
4934 4967
4935static int e1000_maybe_stop_tx(struct net_device *netdev, int size) 4968static int e1000_maybe_stop_tx(struct e1000_ring *tx_ring, int size)
4936{ 4969{
4937 struct e1000_adapter *adapter = netdev_priv(netdev); 4970 if (e1000_desc_unused(tx_ring) >= size)
4938
4939 if (e1000_desc_unused(adapter->tx_ring) >= size)
4940 return 0; 4971 return 0;
4941 return __e1000_maybe_stop_tx(netdev, size); 4972 return __e1000_maybe_stop_tx(tx_ring, size);
4942} 4973}
4943 4974
4944#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 ) 4975#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1)
4945static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, 4976static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
4946 struct net_device *netdev) 4977 struct net_device *netdev)
4947{ 4978{
@@ -4995,7 +5026,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
4995 if (skb->data_len && (hdr_len == len)) { 5026 if (skb->data_len && (hdr_len == len)) {
4996 unsigned int pull_size; 5027 unsigned int pull_size;
4997 5028
4998 pull_size = min((unsigned int)4, skb->data_len); 5029 pull_size = min_t(unsigned int, 4, skb->data_len);
4999 if (!__pskb_pull_tail(skb, pull_size)) { 5030 if (!__pskb_pull_tail(skb, pull_size)) {
5000 e_err("__pskb_pull_tail failed.\n"); 5031 e_err("__pskb_pull_tail failed.\n");
5001 dev_kfree_skb_any(skb); 5032 dev_kfree_skb_any(skb);
@@ -5024,7 +5055,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
5024 * need: count + 2 desc gap to keep tail from touching 5055 * need: count + 2 desc gap to keep tail from touching
5025 * head, otherwise try next time 5056 * head, otherwise try next time
5026 */ 5057 */
5027 if (e1000_maybe_stop_tx(netdev, count + 2)) 5058 if (e1000_maybe_stop_tx(tx_ring, count + 2))
5028 return NETDEV_TX_BUSY; 5059 return NETDEV_TX_BUSY;
5029 5060
5030 if (vlan_tx_tag_present(skb)) { 5061 if (vlan_tx_tag_present(skb)) {
@@ -5034,7 +5065,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
5034 5065
5035 first = tx_ring->next_to_use; 5066 first = tx_ring->next_to_use;
5036 5067
5037 tso = e1000_tso(adapter, skb); 5068 tso = e1000_tso(tx_ring, skb);
5038 if (tso < 0) { 5069 if (tso < 0) {
5039 dev_kfree_skb_any(skb); 5070 dev_kfree_skb_any(skb);
5040 return NETDEV_TX_OK; 5071 return NETDEV_TX_OK;
@@ -5042,7 +5073,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
5042 5073
5043 if (tso) 5074 if (tso)
5044 tx_flags |= E1000_TX_FLAGS_TSO; 5075 tx_flags |= E1000_TX_FLAGS_TSO;
5045 else if (e1000_tx_csum(adapter, skb)) 5076 else if (e1000_tx_csum(tx_ring, skb))
5046 tx_flags |= E1000_TX_FLAGS_CSUM; 5077 tx_flags |= E1000_TX_FLAGS_CSUM;
5047 5078
5048 /* 5079 /*
@@ -5054,12 +5085,12 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
5054 tx_flags |= E1000_TX_FLAGS_IPV4; 5085 tx_flags |= E1000_TX_FLAGS_IPV4;
5055 5086
5056 /* if count is 0 then mapping error has occurred */ 5087 /* if count is 0 then mapping error has occurred */
5057 count = e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss); 5088 count = e1000_tx_map(tx_ring, skb, first, max_per_txd, nr_frags, mss);
5058 if (count) { 5089 if (count) {
5059 netdev_sent_queue(netdev, skb->len); 5090 netdev_sent_queue(netdev, skb->len);
5060 e1000_tx_queue(adapter, tx_flags, count); 5091 e1000_tx_queue(tx_ring, tx_flags, count);
5061 /* Make sure there is space in the ring for the next send. */ 5092 /* Make sure there is space in the ring for the next send. */
5062 e1000_maybe_stop_tx(netdev, MAX_SKB_FRAGS + 2); 5093 e1000_maybe_stop_tx(tx_ring, MAX_SKB_FRAGS + 2);
5063 5094
5064 } else { 5095 } else {
5065 dev_kfree_skb_any(skb); 5096 dev_kfree_skb_any(skb);
@@ -5165,10 +5196,22 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
5165 int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN; 5196 int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
5166 5197
5167 /* Jumbo frame support */ 5198 /* Jumbo frame support */
5168 if ((max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) && 5199 if (max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) {
5169 !(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) { 5200 if (!(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) {
5170 e_err("Jumbo Frames not supported.\n"); 5201 e_err("Jumbo Frames not supported.\n");
5171 return -EINVAL; 5202 return -EINVAL;
5203 }
5204
5205 /*
5206 * IP payload checksum (enabled with jumbos/packet-split when
5207 * Rx checksum is enabled) and generation of RSS hash is
5208 * mutually exclusive in the hardware.
5209 */
5210 if ((netdev->features & NETIF_F_RXCSUM) &&
5211 (netdev->features & NETIF_F_RXHASH)) {
5212 e_err("Jumbo frames cannot be enabled when both receive checksum offload and receive hashing are enabled. Disable one of the receive offload features before enabling jumbos.\n");
5213 return -EINVAL;
5214 }
5172 } 5215 }
5173 5216
5174 /* Supported frame sizes */ 5217 /* Supported frame sizes */
@@ -5908,7 +5951,7 @@ static void e1000_print_device_info(struct e1000_adapter *adapter)
5908 ret_val = e1000_read_pba_string_generic(hw, pba_str, 5951 ret_val = e1000_read_pba_string_generic(hw, pba_str,
5909 E1000_PBANUM_LENGTH); 5952 E1000_PBANUM_LENGTH);
5910 if (ret_val) 5953 if (ret_val)
5911 strncpy((char *)pba_str, "Unknown", sizeof(pba_str) - 1); 5954 strlcpy((char *)pba_str, "Unknown", sizeof(pba_str));
5912 e_info("MAC: %d, PHY: %d, PBA No: %s\n", 5955 e_info("MAC: %d, PHY: %d, PBA No: %s\n",
5913 hw->mac.type, hw->phy.type, pba_str); 5956 hw->mac.type, hw->phy.type, pba_str);
5914} 5957}
@@ -5923,7 +5966,8 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter)
5923 return; 5966 return;
5924 5967
5925 ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &buf); 5968 ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &buf);
5926 if (!ret_val && (!(le16_to_cpu(buf) & (1 << 0)))) { 5969 le16_to_cpus(&buf);
5970 if (!ret_val && (!(buf & (1 << 0)))) {
5927 /* Deep Smart Power Down (DSPD) */ 5971 /* Deep Smart Power Down (DSPD) */
5928 dev_warn(&adapter->pdev->dev, 5972 dev_warn(&adapter->pdev->dev,
5929 "Warning: detected DSPD enabled in EEPROM\n"); 5973 "Warning: detected DSPD enabled in EEPROM\n");
@@ -5931,7 +5975,7 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter)
5931} 5975}
5932 5976
5933static int e1000_set_features(struct net_device *netdev, 5977static int e1000_set_features(struct net_device *netdev,
5934 netdev_features_t features) 5978 netdev_features_t features)
5935{ 5979{
5936 struct e1000_adapter *adapter = netdev_priv(netdev); 5980 struct e1000_adapter *adapter = netdev_priv(netdev);
5937 netdev_features_t changed = features ^ netdev->features; 5981 netdev_features_t changed = features ^ netdev->features;
@@ -5940,9 +5984,22 @@ static int e1000_set_features(struct net_device *netdev,
5940 adapter->flags |= FLAG_TSO_FORCE; 5984 adapter->flags |= FLAG_TSO_FORCE;
5941 5985
5942 if (!(changed & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX | 5986 if (!(changed & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX |
5943 NETIF_F_RXCSUM))) 5987 NETIF_F_RXCSUM | NETIF_F_RXHASH)))
5944 return 0; 5988 return 0;
5945 5989
5990 /*
5991 * IP payload checksum (enabled with jumbos/packet-split when Rx
5992 * checksum is enabled) and generation of RSS hash is mutually
5993 * exclusive in the hardware.
5994 */
5995 if (adapter->rx_ps_pages &&
5996 (features & NETIF_F_RXCSUM) && (features & NETIF_F_RXHASH)) {
5997 e_err("Enabling both receive checksum offload and receive hashing is not possible with jumbo frames. Disable jumbos or enable only one of the receive offload features.\n");
5998 return -EINVAL;
5999 }
6000
6001 netdev->features = features;
6002
5946 if (netif_running(netdev)) 6003 if (netif_running(netdev))
5947 e1000e_reinit_locked(adapter); 6004 e1000e_reinit_locked(adapter);
5948 else 6005 else
@@ -6087,7 +6144,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
6087 e1000e_set_ethtool_ops(netdev); 6144 e1000e_set_ethtool_ops(netdev);
6088 netdev->watchdog_timeo = 5 * HZ; 6145 netdev->watchdog_timeo = 5 * HZ;
6089 netif_napi_add(netdev, &adapter->napi, e1000_clean, 64); 6146 netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
6090 strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1); 6147 strlcpy(netdev->name, pci_name(pdev), sizeof(netdev->name));
6091 6148
6092 netdev->mem_start = mmio_start; 6149 netdev->mem_start = mmio_start;
6093 netdev->mem_end = mmio_start + mmio_len; 6150 netdev->mem_end = mmio_start + mmio_len;
@@ -6133,6 +6190,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
6133 NETIF_F_HW_VLAN_TX | 6190 NETIF_F_HW_VLAN_TX |
6134 NETIF_F_TSO | 6191 NETIF_F_TSO |
6135 NETIF_F_TSO6 | 6192 NETIF_F_TSO6 |
6193 NETIF_F_RXHASH |
6136 NETIF_F_RXCSUM | 6194 NETIF_F_RXCSUM |
6137 NETIF_F_HW_CSUM); 6195 NETIF_F_HW_CSUM);
6138 6196
@@ -6268,7 +6326,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
6268 if (!(adapter->flags & FLAG_HAS_AMT)) 6326 if (!(adapter->flags & FLAG_HAS_AMT))
6269 e1000e_get_hw_control(adapter); 6327 e1000e_get_hw_control(adapter);
6270 6328
6271 strncpy(netdev->name, "eth%d", sizeof(netdev->name) - 1); 6329 strlcpy(netdev->name, "eth%d", sizeof(netdev->name));
6272 err = register_netdev(netdev); 6330 err = register_netdev(netdev);
6273 if (err) 6331 if (err)
6274 goto err_register; 6332 goto err_register;
@@ -6449,7 +6507,7 @@ static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = {
6449 { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH2_LV_LM), board_pch2lan }, 6507 { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH2_LV_LM), board_pch2lan },
6450 { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH2_LV_V), board_pch2lan }, 6508 { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH2_LV_V), board_pch2lan },
6451 6509
6452 { } /* terminate list */ 6510 { 0, 0, 0, 0, 0, 0, 0 } /* terminate list */
6453}; 6511};
6454MODULE_DEVICE_TABLE(pci, e1000_pci_tbl); 6512MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
6455 6513
@@ -6468,7 +6526,9 @@ static struct pci_driver e1000_driver = {
6468 .probe = e1000_probe, 6526 .probe = e1000_probe,
6469 .remove = __devexit_p(e1000_remove), 6527 .remove = __devexit_p(e1000_remove),
6470#ifdef CONFIG_PM 6528#ifdef CONFIG_PM
6471 .driver.pm = &e1000_pm_ops, 6529 .driver = {
6530 .pm = &e1000_pm_ops,
6531 },
6472#endif 6532#endif
6473 .shutdown = e1000_shutdown, 6533 .shutdown = e1000_shutdown,
6474 .err_handler = &e1000_err_handler 6534 .err_handler = &e1000_err_handler
@@ -6485,7 +6545,7 @@ static int __init e1000_init_module(void)
6485 int ret; 6545 int ret;
6486 pr_info("Intel(R) PRO/1000 Network Driver - %s\n", 6546 pr_info("Intel(R) PRO/1000 Network Driver - %s\n",
6487 e1000e_driver_version); 6547 e1000e_driver_version);
6488 pr_info("Copyright(c) 1999 - 2011 Intel Corporation.\n"); 6548 pr_info("Copyright(c) 1999 - 2012 Intel Corporation.\n");
6489 ret = pci_register_driver(&e1000_driver); 6549 ret = pci_register_driver(&e1000_driver);
6490 6550
6491 return ret; 6551 return ret;
diff --git a/drivers/net/ethernet/intel/e1000e/nvm.c b/drivers/net/ethernet/intel/e1000e/nvm.c
new file mode 100644
index 000000000000..f6fb7a768ba5
--- /dev/null
+++ b/drivers/net/ethernet/intel/e1000e/nvm.c
@@ -0,0 +1,647 @@
1/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2012 Intel Corporation.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
9
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
14
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28
29#include "e1000.h"
30
31/**
32 * e1000_raise_eec_clk - Raise EEPROM clock
33 * @hw: pointer to the HW structure
34 * @eecd: pointer to the EEPROM
35 *
36 * Enable/Raise the EEPROM clock bit.
37 **/
38static void e1000_raise_eec_clk(struct e1000_hw *hw, u32 *eecd)
39{
40 *eecd = *eecd | E1000_EECD_SK;
41 ew32(EECD, *eecd);
42 e1e_flush();
43 udelay(hw->nvm.delay_usec);
44}
45
46/**
47 * e1000_lower_eec_clk - Lower EEPROM clock
48 * @hw: pointer to the HW structure
49 * @eecd: pointer to the EEPROM
50 *
51 * Clear/Lower the EEPROM clock bit.
52 **/
53static void e1000_lower_eec_clk(struct e1000_hw *hw, u32 *eecd)
54{
55 *eecd = *eecd & ~E1000_EECD_SK;
56 ew32(EECD, *eecd);
57 e1e_flush();
58 udelay(hw->nvm.delay_usec);
59}
60
61/**
62 * e1000_shift_out_eec_bits - Shift data bits our to the EEPROM
63 * @hw: pointer to the HW structure
64 * @data: data to send to the EEPROM
65 * @count: number of bits to shift out
66 *
67 * We need to shift 'count' bits out to the EEPROM. So, the value in the
68 * "data" parameter will be shifted out to the EEPROM one bit at a time.
69 * In order to do this, "data" must be broken down into bits.
70 **/
71static void e1000_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count)
72{
73 struct e1000_nvm_info *nvm = &hw->nvm;
74 u32 eecd = er32(EECD);
75 u32 mask;
76
77 mask = 0x01 << (count - 1);
78 if (nvm->type == e1000_nvm_eeprom_spi)
79 eecd |= E1000_EECD_DO;
80
81 do {
82 eecd &= ~E1000_EECD_DI;
83
84 if (data & mask)
85 eecd |= E1000_EECD_DI;
86
87 ew32(EECD, eecd);
88 e1e_flush();
89
90 udelay(nvm->delay_usec);
91
92 e1000_raise_eec_clk(hw, &eecd);
93 e1000_lower_eec_clk(hw, &eecd);
94
95 mask >>= 1;
96 } while (mask);
97
98 eecd &= ~E1000_EECD_DI;
99 ew32(EECD, eecd);
100}
101
102/**
103 * e1000_shift_in_eec_bits - Shift data bits in from the EEPROM
104 * @hw: pointer to the HW structure
105 * @count: number of bits to shift in
106 *
107 * In order to read a register from the EEPROM, we need to shift 'count' bits
108 * in from the EEPROM. Bits are "shifted in" by raising the clock input to
109 * the EEPROM (setting the SK bit), and then reading the value of the data out
110 * "DO" bit. During this "shifting in" process the data in "DI" bit should
111 * always be clear.
112 **/
113static u16 e1000_shift_in_eec_bits(struct e1000_hw *hw, u16 count)
114{
115 u32 eecd;
116 u32 i;
117 u16 data;
118
119 eecd = er32(EECD);
120
121 eecd &= ~(E1000_EECD_DO | E1000_EECD_DI);
122 data = 0;
123
124 for (i = 0; i < count; i++) {
125 data <<= 1;
126 e1000_raise_eec_clk(hw, &eecd);
127
128 eecd = er32(EECD);
129
130 eecd &= ~E1000_EECD_DI;
131 if (eecd & E1000_EECD_DO)
132 data |= 1;
133
134 e1000_lower_eec_clk(hw, &eecd);
135 }
136
137 return data;
138}
139
140/**
141 * e1000e_poll_eerd_eewr_done - Poll for EEPROM read/write completion
142 * @hw: pointer to the HW structure
143 * @ee_reg: EEPROM flag for polling
144 *
145 * Polls the EEPROM status bit for either read or write completion based
146 * upon the value of 'ee_reg'.
147 **/
148s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg)
149{
150 u32 attempts = 100000;
151 u32 i, reg = 0;
152
153 for (i = 0; i < attempts; i++) {
154 if (ee_reg == E1000_NVM_POLL_READ)
155 reg = er32(EERD);
156 else
157 reg = er32(EEWR);
158
159 if (reg & E1000_NVM_RW_REG_DONE)
160 return 0;
161
162 udelay(5);
163 }
164
165 return -E1000_ERR_NVM;
166}
167
168/**
169 * e1000e_acquire_nvm - Generic request for access to EEPROM
170 * @hw: pointer to the HW structure
171 *
172 * Set the EEPROM access request bit and wait for EEPROM access grant bit.
173 * Return successful if access grant bit set, else clear the request for
174 * EEPROM access and return -E1000_ERR_NVM (-1).
175 **/
176s32 e1000e_acquire_nvm(struct e1000_hw *hw)
177{
178 u32 eecd = er32(EECD);
179 s32 timeout = E1000_NVM_GRANT_ATTEMPTS;
180
181 ew32(EECD, eecd | E1000_EECD_REQ);
182 eecd = er32(EECD);
183
184 while (timeout) {
185 if (eecd & E1000_EECD_GNT)
186 break;
187 udelay(5);
188 eecd = er32(EECD);
189 timeout--;
190 }
191
192 if (!timeout) {
193 eecd &= ~E1000_EECD_REQ;
194 ew32(EECD, eecd);
195 e_dbg("Could not acquire NVM grant\n");
196 return -E1000_ERR_NVM;
197 }
198
199 return 0;
200}
201
202/**
203 * e1000_standby_nvm - Return EEPROM to standby state
204 * @hw: pointer to the HW structure
205 *
206 * Return the EEPROM to a standby state.
207 **/
208static void e1000_standby_nvm(struct e1000_hw *hw)
209{
210 struct e1000_nvm_info *nvm = &hw->nvm;
211 u32 eecd = er32(EECD);
212
213 if (nvm->type == e1000_nvm_eeprom_spi) {
214 /* Toggle CS to flush commands */
215 eecd |= E1000_EECD_CS;
216 ew32(EECD, eecd);
217 e1e_flush();
218 udelay(nvm->delay_usec);
219 eecd &= ~E1000_EECD_CS;
220 ew32(EECD, eecd);
221 e1e_flush();
222 udelay(nvm->delay_usec);
223 }
224}
225
226/**
227 * e1000_stop_nvm - Terminate EEPROM command
228 * @hw: pointer to the HW structure
229 *
230 * Terminates the current command by inverting the EEPROM's chip select pin.
231 **/
232static void e1000_stop_nvm(struct e1000_hw *hw)
233{
234 u32 eecd;
235
236 eecd = er32(EECD);
237 if (hw->nvm.type == e1000_nvm_eeprom_spi) {
238 /* Pull CS high */
239 eecd |= E1000_EECD_CS;
240 e1000_lower_eec_clk(hw, &eecd);
241 }
242}
243
244/**
245 * e1000e_release_nvm - Release exclusive access to EEPROM
246 * @hw: pointer to the HW structure
247 *
248 * Stop any current commands to the EEPROM and clear the EEPROM request bit.
249 **/
250void e1000e_release_nvm(struct e1000_hw *hw)
251{
252 u32 eecd;
253
254 e1000_stop_nvm(hw);
255
256 eecd = er32(EECD);
257 eecd &= ~E1000_EECD_REQ;
258 ew32(EECD, eecd);
259}
260
261/**
262 * e1000_ready_nvm_eeprom - Prepares EEPROM for read/write
263 * @hw: pointer to the HW structure
264 *
265 * Setups the EEPROM for reading and writing.
266 **/
267static s32 e1000_ready_nvm_eeprom(struct e1000_hw *hw)
268{
269 struct e1000_nvm_info *nvm = &hw->nvm;
270 u32 eecd = er32(EECD);
271 u8 spi_stat_reg;
272
273 if (nvm->type == e1000_nvm_eeprom_spi) {
274 u16 timeout = NVM_MAX_RETRY_SPI;
275
276 /* Clear SK and CS */
277 eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
278 ew32(EECD, eecd);
279 e1e_flush();
280 udelay(1);
281
282 /*
283 * Read "Status Register" repeatedly until the LSB is cleared.
284 * The EEPROM will signal that the command has been completed
285 * by clearing bit 0 of the internal status register. If it's
286 * not cleared within 'timeout', then error out.
287 */
288 while (timeout) {
289 e1000_shift_out_eec_bits(hw, NVM_RDSR_OPCODE_SPI,
290 hw->nvm.opcode_bits);
291 spi_stat_reg = (u8)e1000_shift_in_eec_bits(hw, 8);
292 if (!(spi_stat_reg & NVM_STATUS_RDY_SPI))
293 break;
294
295 udelay(5);
296 e1000_standby_nvm(hw);
297 timeout--;
298 }
299
300 if (!timeout) {
301 e_dbg("SPI NVM Status error\n");
302 return -E1000_ERR_NVM;
303 }
304 }
305
306 return 0;
307}
308
309/**
310 * e1000e_read_nvm_eerd - Reads EEPROM using EERD register
311 * @hw: pointer to the HW structure
312 * @offset: offset of word in the EEPROM to read
313 * @words: number of words to read
314 * @data: word read from the EEPROM
315 *
316 * Reads a 16 bit word from the EEPROM using the EERD register.
317 **/
318s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
319{
320 struct e1000_nvm_info *nvm = &hw->nvm;
321 u32 i, eerd = 0;
322 s32 ret_val = 0;
323
324 /*
325 * A check for invalid values: offset too large, too many words,
326 * too many words for the offset, and not enough words.
327 */
328 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
329 (words == 0)) {
330 e_dbg("nvm parameter(s) out of bounds\n");
331 return -E1000_ERR_NVM;
332 }
333
334 for (i = 0; i < words; i++) {
335 eerd = ((offset + i) << E1000_NVM_RW_ADDR_SHIFT) +
336 E1000_NVM_RW_REG_START;
337
338 ew32(EERD, eerd);
339 ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ);
340 if (ret_val)
341 break;
342
343 data[i] = (er32(EERD) >> E1000_NVM_RW_REG_DATA);
344 }
345
346 return ret_val;
347}
348
349/**
350 * e1000e_write_nvm_spi - Write to EEPROM using SPI
351 * @hw: pointer to the HW structure
352 * @offset: offset within the EEPROM to be written to
353 * @words: number of words to write
354 * @data: 16 bit word(s) to be written to the EEPROM
355 *
356 * Writes data to EEPROM at offset using SPI interface.
357 *
358 * If e1000e_update_nvm_checksum is not called after this function , the
359 * EEPROM will most likely contain an invalid checksum.
360 **/
361s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
362{
363 struct e1000_nvm_info *nvm = &hw->nvm;
364 s32 ret_val;
365 u16 widx = 0;
366
367 /*
368 * A check for invalid values: offset too large, too many words,
369 * and not enough words.
370 */
371 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
372 (words == 0)) {
373 e_dbg("nvm parameter(s) out of bounds\n");
374 return -E1000_ERR_NVM;
375 }
376
377 ret_val = nvm->ops.acquire(hw);
378 if (ret_val)
379 return ret_val;
380
381 while (widx < words) {
382 u8 write_opcode = NVM_WRITE_OPCODE_SPI;
383
384 ret_val = e1000_ready_nvm_eeprom(hw);
385 if (ret_val) {
386 nvm->ops.release(hw);
387 return ret_val;
388 }
389
390 e1000_standby_nvm(hw);
391
392 /* Send the WRITE ENABLE command (8 bit opcode) */
393 e1000_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI,
394 nvm->opcode_bits);
395
396 e1000_standby_nvm(hw);
397
398 /*
399 * Some SPI eeproms use the 8th address bit embedded in the
400 * opcode
401 */
402 if ((nvm->address_bits == 8) && (offset >= 128))
403 write_opcode |= NVM_A8_OPCODE_SPI;
404
405 /* Send the Write command (8-bit opcode + addr) */
406 e1000_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits);
407 e1000_shift_out_eec_bits(hw, (u16)((offset + widx) * 2),
408 nvm->address_bits);
409
410 /* Loop to allow for up to whole page write of eeprom */
411 while (widx < words) {
412 u16 word_out = data[widx];
413 word_out = (word_out >> 8) | (word_out << 8);
414 e1000_shift_out_eec_bits(hw, word_out, 16);
415 widx++;
416
417 if ((((offset + widx) * 2) % nvm->page_size) == 0) {
418 e1000_standby_nvm(hw);
419 break;
420 }
421 }
422 }
423
424 usleep_range(10000, 20000);
425 nvm->ops.release(hw);
426 return 0;
427}
428
429/**
430 * e1000_read_pba_string_generic - Read device part number
431 * @hw: pointer to the HW structure
432 * @pba_num: pointer to device part number
433 * @pba_num_size: size of part number buffer
434 *
435 * Reads the product board assembly (PBA) number from the EEPROM and stores
436 * the value in pba_num.
437 **/
438s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num,
439 u32 pba_num_size)
440{
441 s32 ret_val;
442 u16 nvm_data;
443 u16 pba_ptr;
444 u16 offset;
445 u16 length;
446
447 if (pba_num == NULL) {
448 e_dbg("PBA string buffer was null\n");
449 ret_val = E1000_ERR_INVALID_ARGUMENT;
450 goto out;
451 }
452
453 ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
454 if (ret_val) {
455 e_dbg("NVM Read Error\n");
456 goto out;
457 }
458
459 ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &pba_ptr);
460 if (ret_val) {
461 e_dbg("NVM Read Error\n");
462 goto out;
463 }
464
465 /*
466 * if nvm_data is not ptr guard the PBA must be in legacy format which
467 * means pba_ptr is actually our second data word for the PBA number
468 * and we can decode it into an ascii string
469 */
470 if (nvm_data != NVM_PBA_PTR_GUARD) {
471 e_dbg("NVM PBA number is not stored as string\n");
472
473 /* we will need 11 characters to store the PBA */
474 if (pba_num_size < 11) {
475 e_dbg("PBA string buffer too small\n");
476 return E1000_ERR_NO_SPACE;
477 }
478
479 /* extract hex string from data and pba_ptr */
480 pba_num[0] = (nvm_data >> 12) & 0xF;
481 pba_num[1] = (nvm_data >> 8) & 0xF;
482 pba_num[2] = (nvm_data >> 4) & 0xF;
483 pba_num[3] = nvm_data & 0xF;
484 pba_num[4] = (pba_ptr >> 12) & 0xF;
485 pba_num[5] = (pba_ptr >> 8) & 0xF;
486 pba_num[6] = '-';
487 pba_num[7] = 0;
488 pba_num[8] = (pba_ptr >> 4) & 0xF;
489 pba_num[9] = pba_ptr & 0xF;
490
491 /* put a null character on the end of our string */
492 pba_num[10] = '\0';
493
494 /* switch all the data but the '-' to hex char */
495 for (offset = 0; offset < 10; offset++) {
496 if (pba_num[offset] < 0xA)
497 pba_num[offset] += '0';
498 else if (pba_num[offset] < 0x10)
499 pba_num[offset] += 'A' - 0xA;
500 }
501
502 goto out;
503 }
504
505 ret_val = e1000_read_nvm(hw, pba_ptr, 1, &length);
506 if (ret_val) {
507 e_dbg("NVM Read Error\n");
508 goto out;
509 }
510
511 if (length == 0xFFFF || length == 0) {
512 e_dbg("NVM PBA number section invalid length\n");
513 ret_val = E1000_ERR_NVM_PBA_SECTION;
514 goto out;
515 }
516 /* check if pba_num buffer is big enough */
517 if (pba_num_size < (((u32)length * 2) - 1)) {
518 e_dbg("PBA string buffer too small\n");
519 ret_val = E1000_ERR_NO_SPACE;
520 goto out;
521 }
522
523 /* trim pba length from start of string */
524 pba_ptr++;
525 length--;
526
527 for (offset = 0; offset < length; offset++) {
528 ret_val = e1000_read_nvm(hw, pba_ptr + offset, 1, &nvm_data);
529 if (ret_val) {
530 e_dbg("NVM Read Error\n");
531 goto out;
532 }
533 pba_num[offset * 2] = (u8)(nvm_data >> 8);
534 pba_num[(offset * 2) + 1] = (u8)(nvm_data & 0xFF);
535 }
536 pba_num[offset * 2] = '\0';
537
538out:
539 return ret_val;
540}
541
542/**
543 * e1000_read_mac_addr_generic - Read device MAC address
544 * @hw: pointer to the HW structure
545 *
546 * Reads the device MAC address from the EEPROM and stores the value.
547 * Since devices with two ports use the same EEPROM, we increment the
548 * last bit in the MAC address for the second port.
549 **/
550s32 e1000_read_mac_addr_generic(struct e1000_hw *hw)
551{
552 u32 rar_high;
553 u32 rar_low;
554 u16 i;
555
556 rar_high = er32(RAH(0));
557 rar_low = er32(RAL(0));
558
559 for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++)
560 hw->mac.perm_addr[i] = (u8)(rar_low >> (i * 8));
561
562 for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++)
563 hw->mac.perm_addr[i + 4] = (u8)(rar_high >> (i * 8));
564
565 for (i = 0; i < ETH_ALEN; i++)
566 hw->mac.addr[i] = hw->mac.perm_addr[i];
567
568 return 0;
569}
570
571/**
572 * e1000e_validate_nvm_checksum_generic - Validate EEPROM checksum
573 * @hw: pointer to the HW structure
574 *
575 * Calculates the EEPROM checksum by reading/adding each word of the EEPROM
576 * and then verifies that the sum of the EEPROM is equal to 0xBABA.
577 **/
578s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw)
579{
580 s32 ret_val;
581 u16 checksum = 0;
582 u16 i, nvm_data;
583
584 for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
585 ret_val = e1000_read_nvm(hw, i, 1, &nvm_data);
586 if (ret_val) {
587 e_dbg("NVM Read Error\n");
588 return ret_val;
589 }
590 checksum += nvm_data;
591 }
592
593 if (checksum != (u16)NVM_SUM) {
594 e_dbg("NVM Checksum Invalid\n");
595 return -E1000_ERR_NVM;
596 }
597
598 return 0;
599}
600
601/**
602 * e1000e_update_nvm_checksum_generic - Update EEPROM checksum
603 * @hw: pointer to the HW structure
604 *
605 * Updates the EEPROM checksum by reading/adding each word of the EEPROM
606 * up to the checksum. Then calculates the EEPROM checksum and writes the
607 * value to the EEPROM.
608 **/
609s32 e1000e_update_nvm_checksum_generic(struct e1000_hw *hw)
610{
611 s32 ret_val;
612 u16 checksum = 0;
613 u16 i, nvm_data;
614
615 for (i = 0; i < NVM_CHECKSUM_REG; i++) {
616 ret_val = e1000_read_nvm(hw, i, 1, &nvm_data);
617 if (ret_val) {
618 e_dbg("NVM Read Error while updating checksum.\n");
619 return ret_val;
620 }
621 checksum += nvm_data;
622 }
623 checksum = (u16)NVM_SUM - checksum;
624 ret_val = e1000_write_nvm(hw, NVM_CHECKSUM_REG, 1, &checksum);
625 if (ret_val)
626 e_dbg("NVM Write Error while updating checksum.\n");
627
628 return ret_val;
629}
630
631/**
632 * e1000e_reload_nvm - Reloads EEPROM
633 * @hw: pointer to the HW structure
634 *
635 * Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
636 * extended control register.
637 **/
638void e1000e_reload_nvm(struct e1000_hw *hw)
639{
640 u32 ctrl_ext;
641
642 udelay(10);
643 ctrl_ext = er32(CTRL_EXT);
644 ctrl_ext |= E1000_CTRL_EXT_EE_RST;
645 ew32(CTRL_EXT, ctrl_ext);
646 e1e_flush();
647}
diff --git a/drivers/net/ethernet/intel/e1000e/param.c b/drivers/net/ethernet/intel/e1000e/param.c
index 20e93b08e7f3..9c6a56d804a4 100644
--- a/drivers/net/ethernet/intel/e1000e/param.c
+++ b/drivers/net/ethernet/intel/e1000e/param.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2011 Intel Corporation. 4 Copyright(c) 1999 - 2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -113,11 +113,20 @@ E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
113#define MAX_ITR 100000 113#define MAX_ITR 100000
114#define MIN_ITR 100 114#define MIN_ITR 100
115 115
116/* IntMode (Interrupt Mode) 116/*
117 * IntMode (Interrupt Mode)
118 *
119 * Valid Range: varies depending on kernel configuration & hardware support
120 *
121 * legacy=0, MSI=1, MSI-X=2
117 * 122 *
118 * Valid Range: 0 - 2 123 * When MSI/MSI-X support is enabled in kernel-
124 * Default Value: 2 (MSI-X) when supported by hardware, 1 (MSI) otherwise
125 * When MSI/MSI-X support is not enabled in kernel-
126 * Default Value: 0 (legacy)
119 * 127 *
120 * Default Value: 2 (MSI-X) 128 * When a mode is specified that is not allowed/supported, it will be
129 * demoted to the most advanced interrupt mode available.
121 */ 130 */
122E1000_PARAM(IntMode, "Interrupt Mode"); 131E1000_PARAM(IntMode, "Interrupt Mode");
123#define MAX_INTMODE 2 132#define MAX_INTMODE 2
@@ -388,12 +397,33 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
388 static struct e1000_option opt = { 397 static struct e1000_option opt = {
389 .type = range_option, 398 .type = range_option,
390 .name = "Interrupt Mode", 399 .name = "Interrupt Mode",
391 .err = "defaulting to 2 (MSI-X)", 400#ifndef CONFIG_PCI_MSI
392 .def = E1000E_INT_MODE_MSIX, 401 .err = "defaulting to 0 (legacy)",
393 .arg = { .r = { .min = MIN_INTMODE, 402 .def = E1000E_INT_MODE_LEGACY,
394 .max = MAX_INTMODE } } 403 .arg = { .r = { .min = 0,
404 .max = 0 } }
405#endif
395 }; 406 };
396 407
408#ifdef CONFIG_PCI_MSI
409 if (adapter->flags & FLAG_HAS_MSIX) {
410 opt.err = kstrdup("defaulting to 2 (MSI-X)",
411 GFP_KERNEL);
412 opt.def = E1000E_INT_MODE_MSIX;
413 opt.arg.r.max = E1000E_INT_MODE_MSIX;
414 } else {
415 opt.err = kstrdup("defaulting to 1 (MSI)", GFP_KERNEL);
416 opt.def = E1000E_INT_MODE_MSI;
417 opt.arg.r.max = E1000E_INT_MODE_MSI;
418 }
419
420 if (!opt.err) {
421 dev_err(&adapter->pdev->dev,
422 "Failed to allocate memory\n");
423 return;
424 }
425#endif
426
397 if (num_IntMode > bd) { 427 if (num_IntMode > bd) {
398 unsigned int int_mode = IntMode[bd]; 428 unsigned int int_mode = IntMode[bd];
399 e1000_validate_option(&int_mode, &opt, adapter); 429 e1000_validate_option(&int_mode, &opt, adapter);
@@ -401,6 +431,10 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
401 } else { 431 } else {
402 adapter->int_mode = opt.def; 432 adapter->int_mode = opt.def;
403 } 433 }
434
435#ifdef CONFIG_PCI_MSI
436 kfree(opt.err);
437#endif
404 } 438 }
405 { /* Smart Power Down */ 439 { /* Smart Power Down */
406 static const struct e1000_option opt = { 440 static const struct e1000_option opt = {
diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c
index 8666476cb9be..6f44c3fb80b6 100644
--- a/drivers/net/ethernet/intel/e1000e/phy.c
+++ b/drivers/net/ethernet/intel/e1000e/phy.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2011 Intel Corporation. 4 Copyright(c) 1999 - 2012 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -132,7 +132,7 @@ s32 e1000e_get_phy_id(struct e1000_hw *hw)
132 u16 phy_id; 132 u16 phy_id;
133 u16 retry_count = 0; 133 u16 retry_count = 0;
134 134
135 if (!(phy->ops.read_reg)) 135 if (!phy->ops.read_reg)
136 goto out; 136 goto out;
137 137
138 while (retry_count < 2) { 138 while (retry_count < 2) {
@@ -382,7 +382,7 @@ static s32 __e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data,
382 s32 ret_val = 0; 382 s32 ret_val = 0;
383 383
384 if (!locked) { 384 if (!locked) {
385 if (!(hw->phy.ops.acquire)) 385 if (!hw->phy.ops.acquire)
386 goto out; 386 goto out;
387 387
388 ret_val = hw->phy.ops.acquire(hw); 388 ret_val = hw->phy.ops.acquire(hw);
@@ -453,7 +453,7 @@ static s32 __e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data,
453 s32 ret_val = 0; 453 s32 ret_val = 0;
454 454
455 if (!locked) { 455 if (!locked) {
456 if (!(hw->phy.ops.acquire)) 456 if (!hw->phy.ops.acquire)
457 goto out; 457 goto out;
458 458
459 ret_val = hw->phy.ops.acquire(hw); 459 ret_val = hw->phy.ops.acquire(hw);
@@ -526,7 +526,7 @@ static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data,
526 s32 ret_val = 0; 526 s32 ret_val = 0;
527 527
528 if (!locked) { 528 if (!locked) {
529 if (!(hw->phy.ops.acquire)) 529 if (!hw->phy.ops.acquire)
530 goto out; 530 goto out;
531 531
532 ret_val = hw->phy.ops.acquire(hw); 532 ret_val = hw->phy.ops.acquire(hw);
@@ -599,7 +599,7 @@ static s32 __e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data,
599 s32 ret_val = 0; 599 s32 ret_val = 0;
600 600
601 if (!locked) { 601 if (!locked) {
602 if (!(hw->phy.ops.acquire)) 602 if (!hw->phy.ops.acquire)
603 goto out; 603 goto out;
604 604
605 ret_val = hw->phy.ops.acquire(hw); 605 ret_val = hw->phy.ops.acquire(hw);
@@ -1136,13 +1136,12 @@ static s32 e1000_copper_link_autoneg(struct e1000_hw *hw)
1136 if (phy->autoneg_wait_to_complete) { 1136 if (phy->autoneg_wait_to_complete) {
1137 ret_val = e1000_wait_autoneg(hw); 1137 ret_val = e1000_wait_autoneg(hw);
1138 if (ret_val) { 1138 if (ret_val) {
1139 e_dbg("Error while waiting for " 1139 e_dbg("Error while waiting for autoneg to complete\n");
1140 "autoneg to complete\n");
1141 return ret_val; 1140 return ret_val;
1142 } 1141 }
1143 } 1142 }
1144 1143
1145 hw->mac.get_link_status = 1; 1144 hw->mac.get_link_status = true;
1146 1145
1147 return ret_val; 1146 return ret_val;
1148} 1147}
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 94be6c32fa7d..fda824735e18 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -173,7 +173,9 @@ static int igb_check_vf_assignment(struct igb_adapter *adapter);
173#endif 173#endif
174 174
175#ifdef CONFIG_PM 175#ifdef CONFIG_PM
176#ifdef CONFIG_PM_SLEEP
176static int igb_suspend(struct device *); 177static int igb_suspend(struct device *);
178#endif
177static int igb_resume(struct device *); 179static int igb_resume(struct device *);
178#ifdef CONFIG_PM_RUNTIME 180#ifdef CONFIG_PM_RUNTIME
179static int igb_runtime_suspend(struct device *dev); 181static int igb_runtime_suspend(struct device *dev);
@@ -6710,6 +6712,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
6710} 6712}
6711 6713
6712#ifdef CONFIG_PM 6714#ifdef CONFIG_PM
6715#ifdef CONFIG_PM_SLEEP
6713static int igb_suspend(struct device *dev) 6716static int igb_suspend(struct device *dev)
6714{ 6717{
6715 int retval; 6718 int retval;
@@ -6729,6 +6732,7 @@ static int igb_suspend(struct device *dev)
6729 6732
6730 return 0; 6733 return 0;
6731} 6734}
6735#endif /* CONFIG_PM_SLEEP */
6732 6736
6733static int igb_resume(struct device *dev) 6737static int igb_resume(struct device *dev)
6734{ 6738{
diff --git a/drivers/net/ethernet/intel/igbvf/ethtool.c b/drivers/net/ethernet/intel/igbvf/ethtool.c
index db7dce2351c2..8ce67064b9c5 100644
--- a/drivers/net/ethernet/intel/igbvf/ethtool.c
+++ b/drivers/net/ethernet/intel/igbvf/ethtool.c
@@ -343,10 +343,10 @@ static int igbvf_get_coalesce(struct net_device *netdev,
343{ 343{
344 struct igbvf_adapter *adapter = netdev_priv(netdev); 344 struct igbvf_adapter *adapter = netdev_priv(netdev);
345 345
346 if (adapter->itr_setting <= 3) 346 if (adapter->requested_itr <= 3)
347 ec->rx_coalesce_usecs = adapter->itr_setting; 347 ec->rx_coalesce_usecs = adapter->requested_itr;
348 else 348 else
349 ec->rx_coalesce_usecs = adapter->itr_setting >> 2; 349 ec->rx_coalesce_usecs = adapter->current_itr >> 2;
350 350
351 return 0; 351 return 0;
352} 352}
@@ -365,15 +365,16 @@ static int igbvf_set_coalesce(struct net_device *netdev,
365 365
366 /* convert to rate of irq's per second */ 366 /* convert to rate of irq's per second */
367 if (ec->rx_coalesce_usecs && ec->rx_coalesce_usecs <= 3) { 367 if (ec->rx_coalesce_usecs && ec->rx_coalesce_usecs <= 3) {
368 adapter->itr = IGBVF_START_ITR; 368 adapter->current_itr = IGBVF_START_ITR;
369 adapter->itr_setting = ec->rx_coalesce_usecs; 369 adapter->requested_itr = ec->rx_coalesce_usecs;
370 } else { 370 } else {
371 adapter->itr = ec->rx_coalesce_usecs << 2; 371 adapter->current_itr = ec->rx_coalesce_usecs << 2;
372 adapter->itr_setting = adapter->itr; 372 adapter->requested_itr = 1000000000 /
373 (adapter->current_itr * 256);
373 } 374 }
374 375
375 writel(adapter->itr, 376 writel(adapter->current_itr,
376 hw->hw_addr + adapter->rx_ring[0].itr_register); 377 hw->hw_addr + adapter->rx_ring->itr_register);
377 378
378 return 0; 379 return 0;
379} 380}
diff --git a/drivers/net/ethernet/intel/igbvf/igbvf.h b/drivers/net/ethernet/intel/igbvf/igbvf.h
index 2c6d87e4d3d9..a895e2f7b34d 100644
--- a/drivers/net/ethernet/intel/igbvf/igbvf.h
+++ b/drivers/net/ethernet/intel/igbvf/igbvf.h
@@ -43,7 +43,18 @@ struct igbvf_info;
43struct igbvf_adapter; 43struct igbvf_adapter;
44 44
45/* Interrupt defines */ 45/* Interrupt defines */
46#define IGBVF_START_ITR 648 /* ~6000 ints/sec */ 46#define IGBVF_START_ITR 488 /* ~8000 ints/sec */
47#define IGBVF_4K_ITR 980
48#define IGBVF_20K_ITR 196
49#define IGBVF_70K_ITR 56
50
51enum latency_range {
52 lowest_latency = 0,
53 low_latency = 1,
54 bulk_latency = 2,
55 latency_invalid = 255
56};
57
47 58
48/* Interrupt modes, as used by the IntMode parameter */ 59/* Interrupt modes, as used by the IntMode parameter */
49#define IGBVF_INT_MODE_LEGACY 0 60#define IGBVF_INT_MODE_LEGACY 0
@@ -155,6 +166,7 @@ struct igbvf_ring {
155 char name[IFNAMSIZ + 5]; 166 char name[IFNAMSIZ + 5];
156 u32 eims_value; 167 u32 eims_value;
157 u32 itr_val; 168 u32 itr_val;
169 enum latency_range itr_range;
158 u16 itr_register; 170 u16 itr_register;
159 int set_itr; 171 int set_itr;
160 172
@@ -187,10 +199,8 @@ struct igbvf_adapter {
187 unsigned long state; 199 unsigned long state;
188 200
189 /* Interrupt Throttle Rate */ 201 /* Interrupt Throttle Rate */
190 u32 itr; 202 u32 requested_itr; /* ints/sec or adaptive */
191 u32 itr_setting; 203 u32 current_itr; /* Actual ITR register value, not ints/sec */
192 u16 tx_itr;
193 u16 rx_itr;
194 204
195 /* 205 /*
196 * Tx 206 * Tx
@@ -299,13 +309,6 @@ enum igbvf_state_t {
299 __IGBVF_DOWN 309 __IGBVF_DOWN
300}; 310};
301 311
302enum latency_range {
303 lowest_latency = 0,
304 low_latency = 1,
305 bulk_latency = 2,
306 latency_invalid = 255
307};
308
309extern char igbvf_driver_name[]; 312extern char igbvf_driver_name[];
310extern const char igbvf_driver_version[]; 313extern const char igbvf_driver_version[];
311 314
diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
index 4e9141cfe81d..446297ff0104 100644
--- a/drivers/net/ethernet/intel/igbvf/netdev.c
+++ b/drivers/net/ethernet/intel/igbvf/netdev.c
@@ -632,14 +632,13 @@ void igbvf_free_rx_resources(struct igbvf_ring *rx_ring)
632 * traffic pattern. Constants in this function were computed 632 * traffic pattern. Constants in this function were computed
633 * based on theoretical maximum wire speed and thresholds were set based 633 * based on theoretical maximum wire speed and thresholds were set based
634 * on testing data as well as attempting to minimize response time 634 * on testing data as well as attempting to minimize response time
635 * while increasing bulk throughput. This functionality is controlled 635 * while increasing bulk throughput.
636 * by the InterruptThrottleRate module parameter.
637 **/ 636 **/
638static unsigned int igbvf_update_itr(struct igbvf_adapter *adapter, 637static enum latency_range igbvf_update_itr(struct igbvf_adapter *adapter,
639 u16 itr_setting, int packets, 638 enum latency_range itr_setting,
640 int bytes) 639 int packets, int bytes)
641{ 640{
642 unsigned int retval = itr_setting; 641 enum latency_range retval = itr_setting;
643 642
644 if (packets == 0) 643 if (packets == 0)
645 goto update_itr_done; 644 goto update_itr_done;
@@ -675,65 +674,87 @@ static unsigned int igbvf_update_itr(struct igbvf_adapter *adapter,
675 retval = low_latency; 674 retval = low_latency;
676 } 675 }
677 break; 676 break;
677 default:
678 break;
678 } 679 }
679 680
680update_itr_done: 681update_itr_done:
681 return retval; 682 return retval;
682} 683}
683 684
684static void igbvf_set_itr(struct igbvf_adapter *adapter) 685static int igbvf_range_to_itr(enum latency_range current_range)
685{ 686{
686 struct e1000_hw *hw = &adapter->hw; 687 int new_itr;
687 u16 current_itr;
688 u32 new_itr = adapter->itr;
689
690 adapter->tx_itr = igbvf_update_itr(adapter, adapter->tx_itr,
691 adapter->total_tx_packets,
692 adapter->total_tx_bytes);
693 /* conservative mode (itr 3) eliminates the lowest_latency setting */
694 if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)
695 adapter->tx_itr = low_latency;
696
697 adapter->rx_itr = igbvf_update_itr(adapter, adapter->rx_itr,
698 adapter->total_rx_packets,
699 adapter->total_rx_bytes);
700 /* conservative mode (itr 3) eliminates the lowest_latency setting */
701 if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)
702 adapter->rx_itr = low_latency;
703 688
704 current_itr = max(adapter->rx_itr, adapter->tx_itr); 689 switch (current_range) {
705
706 switch (current_itr) {
707 /* counts and packets in update_itr are dependent on these numbers */ 690 /* counts and packets in update_itr are dependent on these numbers */
708 case lowest_latency: 691 case lowest_latency:
709 new_itr = 70000; 692 new_itr = IGBVF_70K_ITR;
710 break; 693 break;
711 case low_latency: 694 case low_latency:
712 new_itr = 20000; /* aka hwitr = ~200 */ 695 new_itr = IGBVF_20K_ITR;
713 break; 696 break;
714 case bulk_latency: 697 case bulk_latency:
715 new_itr = 4000; 698 new_itr = IGBVF_4K_ITR;
716 break; 699 break;
717 default: 700 default:
701 new_itr = IGBVF_START_ITR;
718 break; 702 break;
719 } 703 }
704 return new_itr;
705}
706
707static void igbvf_set_itr(struct igbvf_adapter *adapter)
708{
709 u32 new_itr;
710
711 adapter->tx_ring->itr_range =
712 igbvf_update_itr(adapter,
713 adapter->tx_ring->itr_val,
714 adapter->total_tx_packets,
715 adapter->total_tx_bytes);
716
717 /* conservative mode (itr 3) eliminates the lowest_latency setting */
718 if (adapter->requested_itr == 3 &&
719 adapter->tx_ring->itr_range == lowest_latency)
720 adapter->tx_ring->itr_range = low_latency;
720 721
721 if (new_itr != adapter->itr) { 722 new_itr = igbvf_range_to_itr(adapter->tx_ring->itr_range);
723
724
725 if (new_itr != adapter->tx_ring->itr_val) {
726 u32 current_itr = adapter->tx_ring->itr_val;
722 /* 727 /*
723 * this attempts to bias the interrupt rate towards Bulk 728 * this attempts to bias the interrupt rate towards Bulk
724 * by adding intermediate steps when interrupt rate is 729 * by adding intermediate steps when interrupt rate is
725 * increasing 730 * increasing
726 */ 731 */
727 new_itr = new_itr > adapter->itr ? 732 new_itr = new_itr > current_itr ?
728 min(adapter->itr + (new_itr >> 2), new_itr) : 733 min(current_itr + (new_itr >> 2), new_itr) :
729 new_itr; 734 new_itr;
730 adapter->itr = new_itr; 735 adapter->tx_ring->itr_val = new_itr;
731 adapter->rx_ring->itr_val = 1952; 736
732 737 adapter->tx_ring->set_itr = 1;
733 if (adapter->msix_entries) 738 }
734 adapter->rx_ring->set_itr = 1; 739
735 else 740 adapter->rx_ring->itr_range =
736 ew32(ITR, 1952); 741 igbvf_update_itr(adapter, adapter->rx_ring->itr_val,
742 adapter->total_rx_packets,
743 adapter->total_rx_bytes);
744 if (adapter->requested_itr == 3 &&
745 adapter->rx_ring->itr_range == lowest_latency)
746 adapter->rx_ring->itr_range = low_latency;
747
748 new_itr = igbvf_range_to_itr(adapter->rx_ring->itr_range);
749
750 if (new_itr != adapter->rx_ring->itr_val) {
751 u32 current_itr = adapter->rx_ring->itr_val;
752 new_itr = new_itr > current_itr ?
753 min(current_itr + (new_itr >> 2), new_itr) :
754 new_itr;
755 adapter->rx_ring->itr_val = new_itr;
756
757 adapter->rx_ring->set_itr = 1;
737 } 758 }
738} 759}
739 760
@@ -835,6 +856,11 @@ static irqreturn_t igbvf_intr_msix_tx(int irq, void *data)
835 struct e1000_hw *hw = &adapter->hw; 856 struct e1000_hw *hw = &adapter->hw;
836 struct igbvf_ring *tx_ring = adapter->tx_ring; 857 struct igbvf_ring *tx_ring = adapter->tx_ring;
837 858
859 if (tx_ring->set_itr) {
860 writel(tx_ring->itr_val,
861 adapter->hw.hw_addr + tx_ring->itr_register);
862 adapter->tx_ring->set_itr = 0;
863 }
838 864
839 adapter->total_tx_bytes = 0; 865 adapter->total_tx_bytes = 0;
840 adapter->total_tx_packets = 0; 866 adapter->total_tx_packets = 0;
@@ -937,19 +963,10 @@ static void igbvf_configure_msix(struct igbvf_adapter *adapter)
937 963
938 igbvf_assign_vector(adapter, IGBVF_NO_QUEUE, 0, vector++); 964 igbvf_assign_vector(adapter, IGBVF_NO_QUEUE, 0, vector++);
939 adapter->eims_enable_mask |= tx_ring->eims_value; 965 adapter->eims_enable_mask |= tx_ring->eims_value;
940 if (tx_ring->itr_val) 966 writel(tx_ring->itr_val, hw->hw_addr + tx_ring->itr_register);
941 writel(tx_ring->itr_val,
942 hw->hw_addr + tx_ring->itr_register);
943 else
944 writel(1952, hw->hw_addr + tx_ring->itr_register);
945
946 igbvf_assign_vector(adapter, 0, IGBVF_NO_QUEUE, vector++); 967 igbvf_assign_vector(adapter, 0, IGBVF_NO_QUEUE, vector++);
947 adapter->eims_enable_mask |= rx_ring->eims_value; 968 adapter->eims_enable_mask |= rx_ring->eims_value;
948 if (rx_ring->itr_val) 969 writel(rx_ring->itr_val, hw->hw_addr + rx_ring->itr_register);
949 writel(rx_ring->itr_val,
950 hw->hw_addr + rx_ring->itr_register);
951 else
952 writel(1952, hw->hw_addr + rx_ring->itr_register);
953 970
954 /* set vector for other causes, i.e. link changes */ 971 /* set vector for other causes, i.e. link changes */
955 972
@@ -1027,7 +1044,7 @@ static int igbvf_request_msix(struct igbvf_adapter *adapter)
1027 goto out; 1044 goto out;
1028 1045
1029 adapter->tx_ring->itr_register = E1000_EITR(vector); 1046 adapter->tx_ring->itr_register = E1000_EITR(vector);
1030 adapter->tx_ring->itr_val = 1952; 1047 adapter->tx_ring->itr_val = adapter->current_itr;
1031 vector++; 1048 vector++;
1032 1049
1033 err = request_irq(adapter->msix_entries[vector].vector, 1050 err = request_irq(adapter->msix_entries[vector].vector,
@@ -1037,7 +1054,7 @@ static int igbvf_request_msix(struct igbvf_adapter *adapter)
1037 goto out; 1054 goto out;
1038 1055
1039 adapter->rx_ring->itr_register = E1000_EITR(vector); 1056 adapter->rx_ring->itr_register = E1000_EITR(vector);
1040 adapter->rx_ring->itr_val = 1952; 1057 adapter->rx_ring->itr_val = adapter->current_itr;
1041 vector++; 1058 vector++;
1042 1059
1043 err = request_irq(adapter->msix_entries[vector].vector, 1060 err = request_irq(adapter->msix_entries[vector].vector,
@@ -1151,7 +1168,7 @@ static int igbvf_poll(struct napi_struct *napi, int budget)
1151 if (work_done < budget) { 1168 if (work_done < budget) {
1152 napi_complete(napi); 1169 napi_complete(napi);
1153 1170
1154 if (adapter->itr_setting & 3) 1171 if (adapter->requested_itr & 3)
1155 igbvf_set_itr(adapter); 1172 igbvf_set_itr(adapter);
1156 1173
1157 if (!test_bit(__IGBVF_DOWN, &adapter->state)) 1174 if (!test_bit(__IGBVF_DOWN, &adapter->state))
@@ -1521,8 +1538,8 @@ static int __devinit igbvf_sw_init(struct igbvf_adapter *adapter)
1521 adapter->tx_abs_int_delay = 32; 1538 adapter->tx_abs_int_delay = 32;
1522 adapter->rx_int_delay = 0; 1539 adapter->rx_int_delay = 0;
1523 adapter->rx_abs_int_delay = 8; 1540 adapter->rx_abs_int_delay = 8;
1524 adapter->itr_setting = 3; 1541 adapter->requested_itr = 3;
1525 adapter->itr = 20000; 1542 adapter->current_itr = IGBVF_START_ITR;
1526 1543
1527 /* Set various function pointers */ 1544 /* Set various function pointers */
1528 adapter->ei->init_ops(&adapter->hw); 1545 adapter->ei->init_ops(&adapter->hw);
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
index 9bd5faf64a85..002478801a1b 100644
--- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c
+++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
@@ -1136,10 +1136,8 @@ ixgb_set_multi(struct net_device *netdev)
1136 u8 *mta = kmalloc(IXGB_MAX_NUM_MULTICAST_ADDRESSES * 1136 u8 *mta = kmalloc(IXGB_MAX_NUM_MULTICAST_ADDRESSES *
1137 ETH_ALEN, GFP_ATOMIC); 1137 ETH_ALEN, GFP_ATOMIC);
1138 u8 *addr; 1138 u8 *addr;
1139 if (!mta) { 1139 if (!mta)
1140 pr_err("allocation of multicast memory failed\n");
1141 goto alloc_failed; 1140 goto alloc_failed;
1142 }
1143 1141
1144 IXGB_WRITE_REG(hw, RCTL, rctl); 1142 IXGB_WRITE_REG(hw, RCTL, rctl);
1145 1143
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 3dc6cef58107..6441acc34c23 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -131,6 +131,11 @@ MODULE_PARM_DESC(max_vfs,
131 "Maximum number of virtual functions to allocate per physical function"); 131 "Maximum number of virtual functions to allocate per physical function");
132#endif /* CONFIG_PCI_IOV */ 132#endif /* CONFIG_PCI_IOV */
133 133
134static unsigned int allow_unsupported_sfp;
135module_param(allow_unsupported_sfp, uint, 0);
136MODULE_PARM_DESC(allow_unsupported_sfp,
137 "Allow unsupported and untested SFP+ modules on 82599-based adapters");
138
134MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>"); 139MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
135MODULE_DESCRIPTION("Intel(R) 10 Gigabit PCI Express Network Driver"); 140MODULE_DESCRIPTION("Intel(R) 10 Gigabit PCI Express Network Driver");
136MODULE_LICENSE("GPL"); 141MODULE_LICENSE("GPL");
@@ -7493,6 +7498,9 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
7493 e_crit(probe, "Fan has stopped, replace the adapter\n"); 7498 e_crit(probe, "Fan has stopped, replace the adapter\n");
7494 } 7499 }
7495 7500
7501 if (allow_unsupported_sfp)
7502 hw->allow_unsupported_sfp = allow_unsupported_sfp;
7503
7496 /* reset_hw fills in the perm_addr as well */ 7504 /* reset_hw fills in the perm_addr as well */
7497 hw->phy.reset_if_overtemp = true; 7505 hw->phy.reset_if_overtemp = true;
7498 err = hw->mac.ops.reset_hw(hw); 7506 err = hw->mac.ops.reset_hw(hw);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
index b91773551a38..bf9f82f4b1ae 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
@@ -834,6 +834,7 @@ out:
834 **/ 834 **/
835s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) 835s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
836{ 836{
837 struct ixgbe_adapter *adapter = hw->back;
837 s32 status = IXGBE_ERR_PHY_ADDR_INVALID; 838 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
838 u32 vendor_oui = 0; 839 u32 vendor_oui = 0;
839 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type; 840 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
@@ -1068,9 +1069,16 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
1068 if (hw->phy.type == ixgbe_phy_sfp_intel) { 1069 if (hw->phy.type == ixgbe_phy_sfp_intel) {
1069 status = 0; 1070 status = 0;
1070 } else { 1071 } else {
1071 hw_dbg(hw, "SFP+ module not supported\n"); 1072 if (hw->allow_unsupported_sfp) {
1072 hw->phy.type = ixgbe_phy_sfp_unsupported; 1073 e_warn(drv, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.");
1073 status = IXGBE_ERR_SFP_NOT_SUPPORTED; 1074 status = 0;
1075 } else {
1076 hw_dbg(hw,
1077 "SFP+ module not supported\n");
1078 hw->phy.type =
1079 ixgbe_phy_sfp_unsupported;
1080 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1081 }
1074 } 1082 }
1075 } else { 1083 } else {
1076 status = 0; 1084 status = 0;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 9b95bef60970..4c060292395f 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -2892,6 +2892,7 @@ struct ixgbe_hw {
2892 u8 revision_id; 2892 u8 revision_id;
2893 bool adapter_stopped; 2893 bool adapter_stopped;
2894 bool force_full_reset; 2894 bool force_full_reset;
2895 bool allow_unsupported_sfp;
2895}; 2896};
2896 2897
2897struct ixgbe_info { 2898struct ixgbe_info {
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index e51d552410ae..58c04b69ce70 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -2521,12 +2521,8 @@ int ixgbevf_setup_rx_resources(struct ixgbevf_adapter *adapter,
2521 2521
2522 size = sizeof(struct ixgbevf_rx_buffer) * rx_ring->count; 2522 size = sizeof(struct ixgbevf_rx_buffer) * rx_ring->count;
2523 rx_ring->rx_buffer_info = vzalloc(size); 2523 rx_ring->rx_buffer_info = vzalloc(size);
2524 if (!rx_ring->rx_buffer_info) { 2524 if (!rx_ring->rx_buffer_info)
2525 hw_dbg(&adapter->hw,
2526 "Unable to vmalloc buffer memory for "
2527 "the receive descriptor ring\n");
2528 goto alloc_failed; 2525 goto alloc_failed;
2529 }
2530 2526
2531 /* Round up to nearest 4K */ 2527 /* Round up to nearest 4K */
2532 rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc); 2528 rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc);
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c
index 27d651a80f3f..1b86d0b45f3c 100644
--- a/drivers/net/ethernet/jme.c
+++ b/drivers/net/ethernet/jme.c
@@ -2999,7 +2999,6 @@ jme_init_one(struct pci_dev *pdev,
2999 */ 2999 */
3000 netdev = alloc_etherdev(sizeof(*jme)); 3000 netdev = alloc_etherdev(sizeof(*jme));
3001 if (!netdev) { 3001 if (!netdev) {
3002 pr_err("Cannot allocate netdev structure\n");
3003 rc = -ENOMEM; 3002 rc = -ENOMEM;
3004 goto err_out_release_regions; 3003 goto err_out_release_regions;
3005 } 3004 }
diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c
index 6ad094f176f8..f30db1c46600 100644
--- a/drivers/net/ethernet/korina.c
+++ b/drivers/net/ethernet/korina.c
@@ -1108,10 +1108,9 @@ static int korina_probe(struct platform_device *pdev)
1108 int rc; 1108 int rc;
1109 1109
1110 dev = alloc_etherdev(sizeof(struct korina_private)); 1110 dev = alloc_etherdev(sizeof(struct korina_private));
1111 if (!dev) { 1111 if (!dev)
1112 printk(KERN_ERR DRV_NAME ": alloc_etherdev failed\n");
1113 return -ENOMEM; 1112 return -ENOMEM;
1114 } 1113
1115 SET_NETDEV_DEV(dev, &pdev->dev); 1114 SET_NETDEV_DEV(dev, &pdev->dev);
1116 lp = netdev_priv(dev); 1115 lp = netdev_priv(dev);
1117 1116
@@ -1150,7 +1149,6 @@ static int korina_probe(struct platform_device *pdev)
1150 1149
1151 lp->td_ring = kmalloc(TD_RING_SIZE + RD_RING_SIZE, GFP_KERNEL); 1150 lp->td_ring = kmalloc(TD_RING_SIZE + RD_RING_SIZE, GFP_KERNEL);
1152 if (!lp->td_ring) { 1151 if (!lp->td_ring) {
1153 printk(KERN_ERR DRV_NAME ": cannot allocate descriptors\n");
1154 rc = -ENXIO; 1152 rc = -ENXIO;
1155 goto probe_err_td_ring; 1153 goto probe_err_td_ring;
1156 } 1154 }
diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index 85e2c6cd9708..3369b7db777d 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -114,7 +114,7 @@ struct ltq_etop_priv {
114static int 114static int
115ltq_etop_alloc_skb(struct ltq_etop_chan *ch) 115ltq_etop_alloc_skb(struct ltq_etop_chan *ch)
116{ 116{
117 ch->skb[ch->dma.desc] = dev_alloc_skb(MAX_DMA_DATA_LEN); 117 ch->skb[ch->dma.desc] = netdev_alloc_skb(ch->netdev, MAX_DMA_DATA_LEN);
118 if (!ch->skb[ch->dma.desc]) 118 if (!ch->skb[ch->dma.desc])
119 return -ENOMEM; 119 return -ENOMEM;
120 ch->dma.desc_base[ch->dma.desc].addr = dma_map_single(NULL, 120 ch->dma.desc_base[ch->dma.desc].addr = dma_map_single(NULL,
@@ -731,6 +731,10 @@ ltq_etop_probe(struct platform_device *pdev)
731 } 731 }
732 732
733 dev = alloc_etherdev_mq(sizeof(struct ltq_etop_priv), 4); 733 dev = alloc_etherdev_mq(sizeof(struct ltq_etop_priv), 4);
734 if (!dev) {
735 err = -ENOMEM;
736 goto err_out;
737 }
734 strcpy(dev->name, "eth%d"); 738 strcpy(dev->name, "eth%d");
735 dev->netdev_ops = &ltq_eth_netdev_ops; 739 dev->netdev_ops = &ltq_eth_netdev_ops;
736 dev->ethtool_ops = &ltq_etop_ethtool_ops; 740 dev->ethtool_ops = &ltq_etop_ethtool_ops;
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 9edecfa1f0f4..f702d0dc18c7 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -667,7 +667,7 @@ static int rxq_refill(struct rx_queue *rxq, int budget)
667 667
668 skb = __skb_dequeue(&mp->rx_recycle); 668 skb = __skb_dequeue(&mp->rx_recycle);
669 if (skb == NULL) 669 if (skb == NULL)
670 skb = dev_alloc_skb(mp->skb_size); 670 skb = netdev_alloc_skb(mp->dev, mp->skb_size);
671 671
672 if (skb == NULL) { 672 if (skb == NULL) {
673 mp->oom = 1; 673 mp->oom = 1;
diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c
index 953ba5851f7b..75df2091bd2e 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -350,7 +350,7 @@ static void rxq_refill(struct net_device *dev)
350 while (pep->rx_desc_count < pep->rx_ring_size) { 350 while (pep->rx_desc_count < pep->rx_ring_size) {
351 int size; 351 int size;
352 352
353 skb = dev_alloc_skb(pep->skb_size); 353 skb = netdev_alloc_skb(dev, pep->skb_size);
354 if (!skb) 354 if (!skb)
355 break; 355 break;
356 if (SKB_DMA_REALIGN) 356 if (SKB_DMA_REALIGN)
@@ -1017,10 +1017,9 @@ static int rxq_init(struct net_device *dev)
1017 /* Allocate RX skb rings */ 1017 /* Allocate RX skb rings */
1018 pep->rx_skb = kmalloc(sizeof(*pep->rx_skb) * pep->rx_ring_size, 1018 pep->rx_skb = kmalloc(sizeof(*pep->rx_skb) * pep->rx_ring_size,
1019 GFP_KERNEL); 1019 GFP_KERNEL);
1020 if (!pep->rx_skb) { 1020 if (!pep->rx_skb)
1021 printk(KERN_ERR "%s: Cannot alloc RX skb ring\n", dev->name);
1022 return -ENOMEM; 1021 return -ENOMEM;
1023 } 1022
1024 /* Allocate RX ring */ 1023 /* Allocate RX ring */
1025 pep->rx_desc_count = 0; 1024 pep->rx_desc_count = 0;
1026 size = pep->rx_ring_size * sizeof(struct rx_desc); 1025 size = pep->rx_ring_size * sizeof(struct rx_desc);
@@ -1081,10 +1080,9 @@ static int txq_init(struct net_device *dev)
1081 1080
1082 pep->tx_skb = kmalloc(sizeof(*pep->tx_skb) * pep->tx_ring_size, 1081 pep->tx_skb = kmalloc(sizeof(*pep->tx_skb) * pep->tx_ring_size,
1083 GFP_KERNEL); 1082 GFP_KERNEL);
1084 if (!pep->tx_skb) { 1083 if (!pep->tx_skb)
1085 printk(KERN_ERR "%s: Cannot alloc TX skb ring\n", dev->name);
1086 return -ENOMEM; 1084 return -ENOMEM;
1087 } 1085
1088 /* Allocate TX ring */ 1086 /* Allocate TX ring */
1089 pep->tx_desc_count = 0; 1087 pep->tx_desc_count = 0;
1090 size = pep->tx_ring_size * sizeof(struct tx_desc); 1088 size = pep->tx_ring_size * sizeof(struct tx_desc);
diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index 33947ac595c0..5a30bf823099 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -3807,10 +3807,8 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
3807 struct skge_port *skge; 3807 struct skge_port *skge;
3808 struct net_device *dev = alloc_etherdev(sizeof(*skge)); 3808 struct net_device *dev = alloc_etherdev(sizeof(*skge));
3809 3809
3810 if (!dev) { 3810 if (!dev)
3811 dev_err(&hw->pdev->dev, "etherdev alloc failed\n");
3812 return NULL; 3811 return NULL;
3813 }
3814 3812
3815 SET_NETDEV_DEV(dev, &hw->pdev->dev); 3813 SET_NETDEV_DEV(dev, &hw->pdev->dev);
3816 dev->netdev_ops = &skge_netdev_ops; 3814 dev->netdev_ops = &skge_netdev_ops;
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index 760c2b17dfd3..82c2c86a1951 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -4700,10 +4700,8 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
4700 struct sky2_port *sky2; 4700 struct sky2_port *sky2;
4701 struct net_device *dev = alloc_etherdev(sizeof(*sky2)); 4701 struct net_device *dev = alloc_etherdev(sizeof(*sky2));
4702 4702
4703 if (!dev) { 4703 if (!dev)
4704 dev_err(&hw->pdev->dev, "etherdev alloc failed\n");
4705 return NULL; 4704 return NULL;
4706 }
4707 4705
4708 SET_NETDEV_DEV(dev, &hw->pdev->dev); 4706 SET_NETDEV_DEV(dev, &hw->pdev->dev);
4709 dev->irq = hw->pdev->irq; 4707 dev->irq = hw->pdev->irq;
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index eaf09d4f02d0..48d5c48d7ce8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -1314,7 +1314,7 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd,
1314 down(&priv->cmd.slave_sem); 1314 down(&priv->cmd.slave_sem);
1315 if (mlx4_master_process_vhcr(dev, slave, NULL)) { 1315 if (mlx4_master_process_vhcr(dev, slave, NULL)) {
1316 mlx4_err(dev, "Failed processing vhcr for slave:%d," 1316 mlx4_err(dev, "Failed processing vhcr for slave:%d,"
1317 " reseting slave.\n", slave); 1317 " resetting slave.\n", slave);
1318 up(&priv->cmd.slave_sem); 1318 up(&priv->cmd.slave_sem);
1319 goto reset_slave; 1319 goto reset_slave;
1320 } 1320 }
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 149e60da0a32..9fe4f94c6da7 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -1048,10 +1048,8 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
1048 1048
1049 dev = alloc_etherdev_mqs(sizeof(struct mlx4_en_priv), 1049 dev = alloc_etherdev_mqs(sizeof(struct mlx4_en_priv),
1050 prof->tx_ring_num, prof->rx_ring_num); 1050 prof->tx_ring_num, prof->rx_ring_num);
1051 if (dev == NULL) { 1051 if (dev == NULL)
1052 mlx4_err(mdev, "Net device allocation failed\n");
1053 return -ENOMEM; 1052 return -ENOMEM;
1054 }
1055 1053
1056 SET_NETDEV_DEV(dev, &mdev->dev->pdev->dev); 1054 SET_NETDEV_DEV(dev, &mdev->dev->pdev->dev);
1057 dev->dev_id = port - 1; 1055 dev->dev_id = port - 1;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index d4ad8c226b51..d703ef2c9c91 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -285,10 +285,9 @@ int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv,
285 tmp = size * roundup_pow_of_two(MLX4_EN_MAX_RX_FRAGS * 285 tmp = size * roundup_pow_of_two(MLX4_EN_MAX_RX_FRAGS *
286 sizeof(struct skb_frag_struct)); 286 sizeof(struct skb_frag_struct));
287 ring->rx_info = vmalloc(tmp); 287 ring->rx_info = vmalloc(tmp);
288 if (!ring->rx_info) { 288 if (!ring->rx_info)
289 en_err(priv, "Failed allocating rx_info ring\n");
290 return -ENOMEM; 289 return -ENOMEM;
291 } 290
292 en_dbg(DRV, priv, "Allocated rx_info ring at addr:%p size:%d\n", 291 en_dbg(DRV, priv, "Allocated rx_info ring at addr:%p size:%d\n",
293 ring->rx_info, tmp); 292 ring->rx_info, tmp);
294 293
@@ -468,12 +467,11 @@ static struct sk_buff *mlx4_en_rx_skb(struct mlx4_en_priv *priv,
468 int used_frags; 467 int used_frags;
469 dma_addr_t dma; 468 dma_addr_t dma;
470 469
471 skb = dev_alloc_skb(SMALL_PACKET_SIZE + NET_IP_ALIGN); 470 skb = netdev_alloc_skb(priv->dev, SMALL_PACKET_SIZE + NET_IP_ALIGN);
472 if (!skb) { 471 if (!skb) {
473 en_dbg(RX_ERR, priv, "Failed allocating skb\n"); 472 en_dbg(RX_ERR, priv, "Failed allocating skb\n");
474 return NULL; 473 return NULL;
475 } 474 }
476 skb->dev = priv->dev;
477 skb_reserve(skb, NET_IP_ALIGN); 475 skb_reserve(skb, NET_IP_ALIGN);
478 skb->len = length; 476 skb->len = length;
479 477
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 9ef9038d0629..ff3250586584 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -71,16 +71,14 @@ int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv,
71 71
72 tmp = size * sizeof(struct mlx4_en_tx_info); 72 tmp = size * sizeof(struct mlx4_en_tx_info);
73 ring->tx_info = vmalloc(tmp); 73 ring->tx_info = vmalloc(tmp);
74 if (!ring->tx_info) { 74 if (!ring->tx_info)
75 en_err(priv, "Failed allocating tx_info ring\n");
76 return -ENOMEM; 75 return -ENOMEM;
77 } 76
78 en_dbg(DRV, priv, "Allocated tx_info ring at addr:%p size:%d\n", 77 en_dbg(DRV, priv, "Allocated tx_info ring at addr:%p size:%d\n",
79 ring->tx_info, tmp); 78 ring->tx_info, tmp);
80 79
81 ring->bounce_buf = kmalloc(MAX_DESC_SIZE, GFP_KERNEL); 80 ring->bounce_buf = kmalloc(MAX_DESC_SIZE, GFP_KERNEL);
82 if (!ring->bounce_buf) { 81 if (!ring->bounce_buf) {
83 en_err(priv, "Failed allocating bounce buffer\n");
84 err = -ENOMEM; 82 err = -ENOMEM;
85 goto err_tx; 83 goto err_tx;
86 } 84 }
diff --git a/drivers/net/ethernet/micrel/ks8695net.c b/drivers/net/ethernet/micrel/ks8695net.c
index ab81c0dc96e2..dccae1d1743a 100644
--- a/drivers/net/ethernet/micrel/ks8695net.c
+++ b/drivers/net/ethernet/micrel/ks8695net.c
@@ -278,7 +278,8 @@ ks8695_refill_rxbuffers(struct ks8695_priv *ksp)
278 278
279 for (buff_n = 0; buff_n < MAX_RX_DESC; ++buff_n) { 279 for (buff_n = 0; buff_n < MAX_RX_DESC; ++buff_n) {
280 if (!ksp->rx_buffers[buff_n].skb) { 280 if (!ksp->rx_buffers[buff_n].skb) {
281 struct sk_buff *skb = dev_alloc_skb(MAX_RXBUF_SIZE); 281 struct sk_buff *skb =
282 netdev_alloc_skb(ksp->ndev, MAX_RXBUF_SIZE);
282 dma_addr_t mapping; 283 dma_addr_t mapping;
283 284
284 ksp->rx_buffers[buff_n].skb = skb; 285 ksp->rx_buffers[buff_n].skb = skb;
@@ -299,7 +300,6 @@ ks8695_refill_rxbuffers(struct ks8695_priv *ksp)
299 break; 300 break;
300 } 301 }
301 ksp->rx_buffers[buff_n].dma_ptr = mapping; 302 ksp->rx_buffers[buff_n].dma_ptr = mapping;
302 skb->dev = ksp->ndev;
303 ksp->rx_buffers[buff_n].length = MAX_RXBUF_SIZE; 303 ksp->rx_buffers[buff_n].length = MAX_RXBUF_SIZE;
304 304
305 /* Record this into the DMA ring */ 305 /* Record this into the DMA ring */
@@ -1362,10 +1362,8 @@ ks8695_probe(struct platform_device *pdev)
1362 1362
1363 /* Initialise a net_device */ 1363 /* Initialise a net_device */
1364 ndev = alloc_etherdev(sizeof(struct ks8695_priv)); 1364 ndev = alloc_etherdev(sizeof(struct ks8695_priv));
1365 if (!ndev) { 1365 if (!ndev)
1366 dev_err(&pdev->dev, "could not allocate device.\n");
1367 return -ENOMEM; 1366 return -ENOMEM;
1368 }
1369 1367
1370 SET_NETDEV_DEV(ndev, &pdev->dev); 1368 SET_NETDEV_DEV(ndev, &pdev->dev);
1371 1369
diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c
index 6b35e7da9a9c..4b551feae4c5 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -1,4 +1,4 @@
1/* drivers/net/ks8851.c 1/* drivers/net/ethernet/micrel/ks8851.c
2 * 2 *
3 * Copyright 2009 Simtec Electronics 3 * Copyright 2009 Simtec Electronics
4 * http://www.simtec.co.uk/ 4 * http://www.simtec.co.uk/
@@ -1419,10 +1419,8 @@ static int __devinit ks8851_probe(struct spi_device *spi)
1419 int ret; 1419 int ret;
1420 1420
1421 ndev = alloc_etherdev(sizeof(struct ks8851_net)); 1421 ndev = alloc_etherdev(sizeof(struct ks8851_net));
1422 if (!ndev) { 1422 if (!ndev)
1423 dev_err(&spi->dev, "failed to alloc ethernet device\n");
1424 return -ENOMEM; 1423 return -ENOMEM;
1425 }
1426 1424
1427 spi->bits_per_word = 8; 1425 spi->bits_per_word = 8;
1428 1426
diff --git a/drivers/net/ethernet/micrel/ks8851.h b/drivers/net/ethernet/micrel/ks8851.h
index b0fae86aacad..852256ef1f22 100644
--- a/drivers/net/ethernet/micrel/ks8851.h
+++ b/drivers/net/ethernet/micrel/ks8851.h
@@ -1,4 +1,4 @@
1/* drivers/net/ks8851.h 1/* drivers/net/ethernet/micrel/ks8851.h
2 * 2 *
3 * Copyright 2009 Simtec Electronics 3 * Copyright 2009 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk> 4 * Ben Dooks <ben@simtec.co.uk>
diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
index e58e78e5c930..61a2f61a31f6 100644
--- a/drivers/net/ethernet/micrel/ks8851_mll.c
+++ b/drivers/net/ethernet/micrel/ks8851_mll.c
@@ -1,5 +1,5 @@
1/** 1/**
2 * drivers/net/ks8851_mll.c 2 * drivers/net/ethernet/micrel/ks8851_mll.c
3 * Copyright (c) 2009 Micrel Inc. 3 * Copyright (c) 2009 Micrel Inc.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
@@ -796,7 +796,7 @@ static void ks_rcv(struct ks_net *ks, struct net_device *netdev)
796 796
797 frame_hdr = ks->frame_head_info; 797 frame_hdr = ks->frame_head_info;
798 while (ks->frame_cnt--) { 798 while (ks->frame_cnt--) {
799 skb = dev_alloc_skb(frame_hdr->len + 16); 799 skb = netdev_alloc_skb(netdev, frame_hdr->len + 16);
800 if (likely(skb && (frame_hdr->sts & RXFSHR_RXFV) && 800 if (likely(skb && (frame_hdr->sts & RXFSHR_RXFV) &&
801 (frame_hdr->len < RX_BUF_SIZE) && frame_hdr->len)) { 801 (frame_hdr->len < RX_BUF_SIZE) && frame_hdr->len)) {
802 skb_reserve(skb, 2); 802 skb_reserve(skb, 2);
@@ -1501,10 +1501,8 @@ static int ks_hw_init(struct ks_net *ks)
1501 ks->mcast_lst_size = 0; 1501 ks->mcast_lst_size = 0;
1502 1502
1503 ks->frame_head_info = kmalloc(MHEADER_SIZE, GFP_KERNEL); 1503 ks->frame_head_info = kmalloc(MHEADER_SIZE, GFP_KERNEL);
1504 if (!ks->frame_head_info) { 1504 if (!ks->frame_head_info)
1505 pr_err("Error: Fail to allocate frame memory\n");
1506 return false; 1505 return false;
1507 }
1508 1506
1509 ks_set_mac(ks, KS_DEFAULT_MAC_ADDRESS); 1507 ks_set_mac(ks, KS_DEFAULT_MAC_ADDRESS);
1510 return true; 1508 return true;
diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
index e52cd310ae76..ef723b185d85 100644
--- a/drivers/net/ethernet/micrel/ksz884x.c
+++ b/drivers/net/ethernet/micrel/ksz884x.c
@@ -1,5 +1,5 @@
1/** 1/**
2 * drivers/net/ksx884x.c - Micrel KSZ8841/2 PCI Ethernet driver 2 * drivers/net/ethernet/micrel/ksx884x.c - Micrel KSZ8841/2 PCI Ethernet driver
3 * 3 *
4 * Copyright (c) 2009-2010 Micrel, Inc. 4 * Copyright (c) 2009-2010 Micrel, Inc.
5 * Tristram Ha <Tristram.Ha@micrel.com> 5 * Tristram Ha <Tristram.Ha@micrel.com>
@@ -4863,7 +4863,7 @@ static netdev_tx_t netdev_tx(struct sk_buff *skb, struct net_device *dev)
4863 memset(&skb->data[skb->len], 0, 50 - skb->len); 4863 memset(&skb->data[skb->len], 0, 50 - skb->len);
4864 skb->len = 50; 4864 skb->len = 50;
4865 } else { 4865 } else {
4866 skb = dev_alloc_skb(50); 4866 skb = netdev_alloc_skb(dev, 50);
4867 if (!skb) 4867 if (!skb)
4868 return NETDEV_TX_BUSY; 4868 return NETDEV_TX_BUSY;
4869 memcpy(skb->data, org_skb->data, org_skb->len); 4869 memcpy(skb->data, org_skb->data, org_skb->len);
@@ -4885,7 +4885,7 @@ static netdev_tx_t netdev_tx(struct sk_buff *skb, struct net_device *dev)
4885 (ETH_P_IPV6 == htons(skb->protocol)))) { 4885 (ETH_P_IPV6 == htons(skb->protocol)))) {
4886 struct sk_buff *org_skb = skb; 4886 struct sk_buff *org_skb = skb;
4887 4887
4888 skb = dev_alloc_skb(org_skb->len); 4888 skb = netdev_alloc_skb(dev, org_skb->len);
4889 if (!skb) { 4889 if (!skb) {
4890 rc = NETDEV_TX_BUSY; 4890 rc = NETDEV_TX_BUSY;
4891 goto unlock; 4891 goto unlock;
@@ -5019,7 +5019,7 @@ static inline int rx_proc(struct net_device *dev, struct ksz_hw* hw,
5019 5019
5020 do { 5020 do {
5021 /* skb->data != skb->head */ 5021 /* skb->data != skb->head */
5022 skb = dev_alloc_skb(packet_len + 2); 5022 skb = netdev_alloc_skb(dev, packet_len + 2);
5023 if (!skb) { 5023 if (!skb) {
5024 dev->stats.rx_dropped++; 5024 dev->stats.rx_dropped++;
5025 return -ENOMEM; 5025 return -ENOMEM;
diff --git a/drivers/net/ethernet/microchip/enc28j60.c b/drivers/net/ethernet/microchip/enc28j60.c
index 50055e0282ed..1d6b7ce3e1ee 100644
--- a/drivers/net/ethernet/microchip/enc28j60.c
+++ b/drivers/net/ethernet/microchip/enc28j60.c
@@ -954,14 +954,13 @@ static void enc28j60_hw_rx(struct net_device *ndev)
954 if (len > MAX_FRAMELEN) 954 if (len > MAX_FRAMELEN)
955 ndev->stats.rx_over_errors++; 955 ndev->stats.rx_over_errors++;
956 } else { 956 } else {
957 skb = dev_alloc_skb(len + NET_IP_ALIGN); 957 skb = netdev_alloc_skb(ndev, len + NET_IP_ALIGN);
958 if (!skb) { 958 if (!skb) {
959 if (netif_msg_rx_err(priv)) 959 if (netif_msg_rx_err(priv))
960 dev_err(&ndev->dev, 960 dev_err(&ndev->dev,
961 "out of memory for Rx'd frame\n"); 961 "out of memory for Rx'd frame\n");
962 ndev->stats.rx_dropped++; 962 ndev->stats.rx_dropped++;
963 } else { 963 } else {
964 skb->dev = ndev;
965 skb_reserve(skb, NET_IP_ALIGN); 964 skb_reserve(skb, NET_IP_ALIGN);
966 /* copy the packet from the receive buffer */ 965 /* copy the packet from the receive buffer */
967 enc28j60_mem_read(priv, 966 enc28j60_mem_read(priv,
@@ -1553,9 +1552,6 @@ static int __devinit enc28j60_probe(struct spi_device *spi)
1553 1552
1554 dev = alloc_etherdev(sizeof(struct enc28j60_net)); 1553 dev = alloc_etherdev(sizeof(struct enc28j60_net));
1555 if (!dev) { 1554 if (!dev) {
1556 if (netif_msg_drv(&debug))
1557 dev_err(&spi->dev, DRV_NAME
1558 ": unable to alloc new ethernet\n");
1559 ret = -ENOMEM; 1555 ret = -ENOMEM;
1560 goto error_alloc; 1556 goto error_alloc;
1561 } 1557 }
diff --git a/drivers/net/ethernet/mipsnet.c b/drivers/net/ethernet/mipsnet.c
index d05b0c9e1e9c..dbc666a3d523 100644
--- a/drivers/net/ethernet/mipsnet.c
+++ b/drivers/net/ethernet/mipsnet.c
@@ -152,7 +152,7 @@ static inline ssize_t mipsnet_get_fromdev(struct net_device *dev, size_t len)
152 if (!len) 152 if (!len)
153 return len; 153 return len;
154 154
155 skb = dev_alloc_skb(len + NET_IP_ALIGN); 155 skb = netdev_alloc_skb(dev, len + NET_IP_ALIGN);
156 if (!skb) { 156 if (!skb) {
157 dev->stats.rx_dropped++; 157 dev->stats.rx_dropped++;
158 return -ENOMEM; 158 return -ENOMEM;
diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
index 20b72ecb020a..27273ae1a6e6 100644
--- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
+++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
@@ -3910,10 +3910,8 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3910 static int board_number; 3910 static int board_number;
3911 3911
3912 netdev = alloc_etherdev_mq(sizeof(*mgp), MYRI10GE_MAX_SLICES); 3912 netdev = alloc_etherdev_mq(sizeof(*mgp), MYRI10GE_MAX_SLICES);
3913 if (netdev == NULL) { 3913 if (netdev == NULL)
3914 dev_err(dev, "Could not allocate ethernet device\n");
3915 return -ENOMEM; 3914 return -ENOMEM;
3916 }
3917 3915
3918 SET_NETDEV_DEV(netdev, &pdev->dev); 3916 SET_NETDEV_DEV(netdev, &pdev->dev);
3919 3917
diff --git a/drivers/net/ethernet/natsemi/ibmlana.c b/drivers/net/ethernet/natsemi/ibmlana.c
index 999407f7ebdf..3f94ddbf4dc0 100644
--- a/drivers/net/ethernet/natsemi/ibmlana.c
+++ b/drivers/net/ethernet/natsemi/ibmlana.c
@@ -589,7 +589,7 @@ static void irqrx_handler(struct net_device *dev)
589 589
590 /* fetch buffer */ 590 /* fetch buffer */
591 591
592 skb = dev_alloc_skb(rda.length + 2); 592 skb = netdev_alloc_skb(dev, rda.length + 2);
593 if (skb == NULL) 593 if (skb == NULL)
594 dev->stats.rx_dropped++; 594 dev->stats.rx_dropped++;
595 else { 595 else {
diff --git a/drivers/net/ethernet/natsemi/natsemi.c b/drivers/net/ethernet/natsemi/natsemi.c
index ac7b16b6e7af..d38e48d4f430 100644
--- a/drivers/net/ethernet/natsemi/natsemi.c
+++ b/drivers/net/ethernet/natsemi/natsemi.c
@@ -1934,11 +1934,10 @@ static void refill_rx(struct net_device *dev)
1934 int entry = np->dirty_rx % RX_RING_SIZE; 1934 int entry = np->dirty_rx % RX_RING_SIZE;
1935 if (np->rx_skbuff[entry] == NULL) { 1935 if (np->rx_skbuff[entry] == NULL) {
1936 unsigned int buflen = np->rx_buf_sz+NATSEMI_PADDING; 1936 unsigned int buflen = np->rx_buf_sz+NATSEMI_PADDING;
1937 skb = dev_alloc_skb(buflen); 1937 skb = netdev_alloc_skb(dev, buflen);
1938 np->rx_skbuff[entry] = skb; 1938 np->rx_skbuff[entry] = skb;
1939 if (skb == NULL) 1939 if (skb == NULL)
1940 break; /* Better luck next round. */ 1940 break; /* Better luck next round. */
1941 skb->dev = dev; /* Mark as being used by this device. */
1942 np->rx_dma[entry] = pci_map_single(np->pci_dev, 1941 np->rx_dma[entry] = pci_map_single(np->pci_dev,
1943 skb->data, buflen, PCI_DMA_FROMDEVICE); 1942 skb->data, buflen, PCI_DMA_FROMDEVICE);
1944 np->rx_ring[entry].addr = cpu_to_le32(np->rx_dma[entry]); 1943 np->rx_ring[entry].addr = cpu_to_le32(np->rx_dma[entry]);
@@ -2344,7 +2343,7 @@ static void netdev_rx(struct net_device *dev, int *work_done, int work_to_do)
2344 /* Check if the packet is long enough to accept 2343 /* Check if the packet is long enough to accept
2345 * without copying to a minimally-sized skbuff. */ 2344 * without copying to a minimally-sized skbuff. */
2346 if (pkt_len < rx_copybreak && 2345 if (pkt_len < rx_copybreak &&
2347 (skb = dev_alloc_skb(pkt_len + RX_OFFSET)) != NULL) { 2346 (skb = netdev_alloc_skb(dev, pkt_len + RX_OFFSET)) != NULL) {
2348 /* 16 byte align the IP header */ 2347 /* 16 byte align the IP header */
2349 skb_reserve(skb, RX_OFFSET); 2348 skb_reserve(skb, RX_OFFSET);
2350 pci_dma_sync_single_for_cpu(np->pci_dev, 2349 pci_dma_sync_single_for_cpu(np->pci_dev,
diff --git a/drivers/net/ethernet/natsemi/sonic.c b/drivers/net/ethernet/natsemi/sonic.c
index 26e25d7f5829..46795e403467 100644
--- a/drivers/net/ethernet/natsemi/sonic.c
+++ b/drivers/net/ethernet/natsemi/sonic.c
@@ -51,7 +51,7 @@ static int sonic_open(struct net_device *dev)
51 printk("sonic_open: initializing sonic driver.\n"); 51 printk("sonic_open: initializing sonic driver.\n");
52 52
53 for (i = 0; i < SONIC_NUM_RRS; i++) { 53 for (i = 0; i < SONIC_NUM_RRS; i++) {
54 struct sk_buff *skb = dev_alloc_skb(SONIC_RBSIZE + 2); 54 struct sk_buff *skb = netdev_alloc_skb(dev, SONIC_RBSIZE + 2);
55 if (skb == NULL) { 55 if (skb == NULL) {
56 while(i > 0) { /* free any that were allocated successfully */ 56 while(i > 0) { /* free any that were allocated successfully */
57 i--; 57 i--;
@@ -422,7 +422,7 @@ static void sonic_rx(struct net_device *dev)
422 status = sonic_rda_get(dev, entry, SONIC_RD_STATUS); 422 status = sonic_rda_get(dev, entry, SONIC_RD_STATUS);
423 if (status & SONIC_RCR_PRX) { 423 if (status & SONIC_RCR_PRX) {
424 /* Malloc up new buffer. */ 424 /* Malloc up new buffer. */
425 new_skb = dev_alloc_skb(SONIC_RBSIZE + 2); 425 new_skb = netdev_alloc_skb(dev, SONIC_RBSIZE + 2);
426 if (new_skb == NULL) { 426 if (new_skb == NULL) {
427 printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n", dev->name); 427 printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n", dev->name);
428 lp->stats.rx_dropped++; 428 lp->stats.rx_dropped++;
diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c
index 97f63e12d86e..44a6065794c3 100644
--- a/drivers/net/ethernet/neterion/s2io.c
+++ b/drivers/net/ethernet/neterion/s2io.c
@@ -2524,7 +2524,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, struct ring_info *ring,
2524 size = ring->mtu + ALIGN_SIZE + BUF0_LEN + 4; 2524 size = ring->mtu + ALIGN_SIZE + BUF0_LEN + 4;
2525 2525
2526 /* allocate skb */ 2526 /* allocate skb */
2527 skb = dev_alloc_skb(size); 2527 skb = netdev_alloc_skb(nic->dev, size);
2528 if (!skb) { 2528 if (!skb) {
2529 DBG_PRINT(INFO_DBG, "%s: Could not allocate skb\n", 2529 DBG_PRINT(INFO_DBG, "%s: Could not allocate skb\n",
2530 ring->dev->name); 2530 ring->dev->name);
@@ -6820,7 +6820,7 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6820 */ 6820 */
6821 rxdp1->Buffer0_ptr = *temp0; 6821 rxdp1->Buffer0_ptr = *temp0;
6822 } else { 6822 } else {
6823 *skb = dev_alloc_skb(size); 6823 *skb = netdev_alloc_skb(dev, size);
6824 if (!(*skb)) { 6824 if (!(*skb)) {
6825 DBG_PRINT(INFO_DBG, 6825 DBG_PRINT(INFO_DBG,
6826 "%s: Out of memory to allocate %s\n", 6826 "%s: Out of memory to allocate %s\n",
@@ -6849,7 +6849,7 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6849 rxdp3->Buffer0_ptr = *temp0; 6849 rxdp3->Buffer0_ptr = *temp0;
6850 rxdp3->Buffer1_ptr = *temp1; 6850 rxdp3->Buffer1_ptr = *temp1;
6851 } else { 6851 } else {
6852 *skb = dev_alloc_skb(size); 6852 *skb = netdev_alloc_skb(dev, size);
6853 if (!(*skb)) { 6853 if (!(*skb)) {
6854 DBG_PRINT(INFO_DBG, 6854 DBG_PRINT(INFO_DBG,
6855 "%s: Out of memory to allocate %s\n", 6855 "%s: Out of memory to allocate %s\n",
@@ -7760,7 +7760,6 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7760 else 7760 else
7761 dev = alloc_etherdev(sizeof(struct s2io_nic)); 7761 dev = alloc_etherdev(sizeof(struct s2io_nic));
7762 if (dev == NULL) { 7762 if (dev == NULL) {
7763 DBG_PRINT(ERR_DBG, "Device allocation failed\n");
7764 pci_disable_device(pdev); 7763 pci_disable_device(pdev);
7765 pci_release_regions(pdev); 7764 pci_release_regions(pdev);
7766 return -ENODEV; 7765 return -ENODEV;
diff --git a/drivers/net/ethernet/netx-eth.c b/drivers/net/ethernet/netx-eth.c
index 8d288af16fc9..9d11ab7521bc 100644
--- a/drivers/net/ethernet/netx-eth.c
+++ b/drivers/net/ethernet/netx-eth.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * drivers/net/netx-eth.c 2 * drivers/net/ethernet/netx-eth.c
3 * 3 *
4 * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix 4 * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
5 * 5 *
@@ -150,7 +150,7 @@ static void netx_eth_receive(struct net_device *ndev)
150 seg = (val & FIFO_PTR_SEGMENT_MASK) >> FIFO_PTR_SEGMENT_SHIFT; 150 seg = (val & FIFO_PTR_SEGMENT_MASK) >> FIFO_PTR_SEGMENT_SHIFT;
151 len = (val & FIFO_PTR_FRAMELEN_MASK) >> FIFO_PTR_FRAMELEN_SHIFT; 151 len = (val & FIFO_PTR_FRAMELEN_MASK) >> FIFO_PTR_FRAMELEN_SHIFT;
152 152
153 skb = dev_alloc_skb(len); 153 skb = netdev_alloc_skb(ndev, len);
154 if (unlikely(skb == NULL)) { 154 if (unlikely(skb == NULL)) {
155 printk(KERN_NOTICE "%s: Low memory, packet dropped.\n", 155 printk(KERN_NOTICE "%s: Low memory, packet dropped.\n",
156 ndev->name); 156 ndev->name);
@@ -383,7 +383,6 @@ static int netx_eth_drv_probe(struct platform_device *pdev)
383 383
384 ndev = alloc_etherdev(sizeof (struct netx_eth_priv)); 384 ndev = alloc_etherdev(sizeof (struct netx_eth_priv));
385 if (!ndev) { 385 if (!ndev) {
386 printk("%s: could not allocate device.\n", CARDNAME);
387 ret = -ENOMEM; 386 ret = -ENOMEM;
388 goto exit; 387 goto exit;
389 } 388 }
diff --git a/drivers/net/ethernet/nuvoton/w90p910_ether.c b/drivers/net/ethernet/nuvoton/w90p910_ether.c
index b75a0497d58d..6893a65ae55f 100644
--- a/drivers/net/ethernet/nuvoton/w90p910_ether.c
+++ b/drivers/net/ethernet/nuvoton/w90p910_ether.c
@@ -735,7 +735,7 @@ static void netdev_rx(struct net_device *dev)
735 735
736 if (status & RXDS_RXGD) { 736 if (status & RXDS_RXGD) {
737 data = ether->rdesc->recv_buf[ether->cur_rx]; 737 data = ether->rdesc->recv_buf[ether->cur_rx];
738 skb = dev_alloc_skb(length+2); 738 skb = netdev_alloc_skb(dev, length + 2);
739 if (!skb) { 739 if (!skb) {
740 dev_err(&pdev->dev, "get skb buffer error\n"); 740 dev_err(&pdev->dev, "get skb buffer error\n");
741 ether->stats.rx_dropped++; 741 ether->stats.rx_dropped++;
diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
index 4c4e7f458383..5eeb92f87380 100644
--- a/drivers/net/ethernet/nvidia/forcedeth.c
+++ b/drivers/net/ethernet/nvidia/forcedeth.c
@@ -1815,7 +1815,7 @@ static int nv_alloc_rx(struct net_device *dev)
1815 less_rx = np->last_rx.orig; 1815 less_rx = np->last_rx.orig;
1816 1816
1817 while (np->put_rx.orig != less_rx) { 1817 while (np->put_rx.orig != less_rx) {
1818 struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD); 1818 struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz + NV_RX_ALLOC_PAD);
1819 if (skb) { 1819 if (skb) {
1820 np->put_rx_ctx->skb = skb; 1820 np->put_rx_ctx->skb = skb;
1821 np->put_rx_ctx->dma = pci_map_single(np->pci_dev, 1821 np->put_rx_ctx->dma = pci_map_single(np->pci_dev,
@@ -1850,7 +1850,7 @@ static int nv_alloc_rx_optimized(struct net_device *dev)
1850 less_rx = np->last_rx.ex; 1850 less_rx = np->last_rx.ex;
1851 1851
1852 while (np->put_rx.ex != less_rx) { 1852 while (np->put_rx.ex != less_rx) {
1853 struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD); 1853 struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz + NV_RX_ALLOC_PAD);
1854 if (skb) { 1854 if (skb) {
1855 np->put_rx_ctx->skb = skb; 1855 np->put_rx_ctx->skb = skb;
1856 np->put_rx_ctx->dma = pci_map_single(np->pci_dev, 1856 np->put_rx_ctx->dma = pci_map_single(np->pci_dev,
@@ -4993,9 +4993,9 @@ static int nv_loopback_test(struct net_device *dev)
4993 4993
4994 /* setup packet for tx */ 4994 /* setup packet for tx */
4995 pkt_len = ETH_DATA_LEN; 4995 pkt_len = ETH_DATA_LEN;
4996 tx_skb = dev_alloc_skb(pkt_len); 4996 tx_skb = netdev_alloc_skb(dev, pkt_len);
4997 if (!tx_skb) { 4997 if (!tx_skb) {
4998 netdev_err(dev, "dev_alloc_skb() failed during loopback test\n"); 4998 netdev_err(dev, "netdev_alloc_skb() failed during loopback test\n");
4999 ret = 0; 4999 ret = 0;
5000 goto out; 5000 goto out;
5001 } 5001 }
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 3ead111111e1..bdbec7e04a4c 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -1587,10 +1587,8 @@ int pch_gbe_setup_tx_resources(struct pch_gbe_adapter *adapter,
1587 1587
1588 size = (int)sizeof(struct pch_gbe_buffer) * tx_ring->count; 1588 size = (int)sizeof(struct pch_gbe_buffer) * tx_ring->count;
1589 tx_ring->buffer_info = vzalloc(size); 1589 tx_ring->buffer_info = vzalloc(size);
1590 if (!tx_ring->buffer_info) { 1590 if (!tx_ring->buffer_info)
1591 pr_err("Unable to allocate memory for the buffer information\n");
1592 return -ENOMEM; 1591 return -ENOMEM;
1593 }
1594 1592
1595 tx_ring->size = tx_ring->count * (int)sizeof(struct pch_gbe_tx_desc); 1593 tx_ring->size = tx_ring->count * (int)sizeof(struct pch_gbe_tx_desc);
1596 1594
@@ -1636,10 +1634,9 @@ int pch_gbe_setup_rx_resources(struct pch_gbe_adapter *adapter,
1636 1634
1637 size = (int)sizeof(struct pch_gbe_buffer) * rx_ring->count; 1635 size = (int)sizeof(struct pch_gbe_buffer) * rx_ring->count;
1638 rx_ring->buffer_info = vzalloc(size); 1636 rx_ring->buffer_info = vzalloc(size);
1639 if (!rx_ring->buffer_info) { 1637 if (!rx_ring->buffer_info)
1640 pr_err("Unable to allocate memory for the receive descriptor ring\n");
1641 return -ENOMEM; 1638 return -ENOMEM;
1642 } 1639
1643 rx_ring->size = rx_ring->count * (int)sizeof(struct pch_gbe_rx_desc); 1640 rx_ring->size = rx_ring->count * (int)sizeof(struct pch_gbe_rx_desc);
1644 rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size, 1641 rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size,
1645 &rx_ring->dma, GFP_KERNEL); 1642 &rx_ring->dma, GFP_KERNEL);
@@ -2422,8 +2419,6 @@ static int pch_gbe_probe(struct pci_dev *pdev,
2422 netdev = alloc_etherdev((int)sizeof(struct pch_gbe_adapter)); 2419 netdev = alloc_etherdev((int)sizeof(struct pch_gbe_adapter));
2423 if (!netdev) { 2420 if (!netdev) {
2424 ret = -ENOMEM; 2421 ret = -ENOMEM;
2425 dev_err(&pdev->dev,
2426 "ERR: Can't allocate and set up an Ethernet device\n");
2427 goto err_release_pci; 2422 goto err_release_pci;
2428 } 2423 }
2429 SET_NETDEV_DEV(netdev, &pdev->dev); 2424 SET_NETDEV_DEV(netdev, &pdev->dev);
diff --git a/drivers/net/ethernet/packetengines/hamachi.c b/drivers/net/ethernet/packetengines/hamachi.c
index 3458df3780b8..0d29f5f4b8e4 100644
--- a/drivers/net/ethernet/packetengines/hamachi.c
+++ b/drivers/net/ethernet/packetengines/hamachi.c
@@ -1188,11 +1188,10 @@ static void hamachi_init_ring(struct net_device *dev)
1188 } 1188 }
1189 /* Fill in the Rx buffers. Handle allocation failure gracefully. */ 1189 /* Fill in the Rx buffers. Handle allocation failure gracefully. */
1190 for (i = 0; i < RX_RING_SIZE; i++) { 1190 for (i = 0; i < RX_RING_SIZE; i++) {
1191 struct sk_buff *skb = dev_alloc_skb(hmp->rx_buf_sz + 2); 1191 struct sk_buff *skb = netdev_alloc_skb(dev, hmp->rx_buf_sz + 2);
1192 hmp->rx_skbuff[i] = skb; 1192 hmp->rx_skbuff[i] = skb;
1193 if (skb == NULL) 1193 if (skb == NULL)
1194 break; 1194 break;
1195 skb->dev = dev; /* Mark as being used by this device. */
1196 skb_reserve(skb, 2); /* 16 byte align the IP header. */ 1195 skb_reserve(skb, 2); /* 16 byte align the IP header. */
1197 hmp->rx_ring[i].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev, 1196 hmp->rx_ring[i].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev,
1198 skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE)); 1197 skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE));
@@ -1488,7 +1487,7 @@ static int hamachi_rx(struct net_device *dev)
1488 /* Check if the packet is long enough to accept without copying 1487 /* Check if the packet is long enough to accept without copying
1489 to a minimally-sized skbuff. */ 1488 to a minimally-sized skbuff. */
1490 if (pkt_len < rx_copybreak && 1489 if (pkt_len < rx_copybreak &&
1491 (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { 1490 (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) {
1492#ifdef RX_CHECKSUM 1491#ifdef RX_CHECKSUM
1493 printk(KERN_ERR "%s: rx_copybreak non-zero " 1492 printk(KERN_ERR "%s: rx_copybreak non-zero "
1494 "not good with RX_CHECKSUM\n", dev->name); 1493 "not good with RX_CHECKSUM\n", dev->name);
@@ -1591,12 +1590,11 @@ static int hamachi_rx(struct net_device *dev)
1591 entry = hmp->dirty_rx % RX_RING_SIZE; 1590 entry = hmp->dirty_rx % RX_RING_SIZE;
1592 desc = &(hmp->rx_ring[entry]); 1591 desc = &(hmp->rx_ring[entry]);
1593 if (hmp->rx_skbuff[entry] == NULL) { 1592 if (hmp->rx_skbuff[entry] == NULL) {
1594 struct sk_buff *skb = dev_alloc_skb(hmp->rx_buf_sz + 2); 1593 struct sk_buff *skb = netdev_alloc_skb(dev, hmp->rx_buf_sz + 2);
1595 1594
1596 hmp->rx_skbuff[entry] = skb; 1595 hmp->rx_skbuff[entry] = skb;
1597 if (skb == NULL) 1596 if (skb == NULL)
1598 break; /* Better luck next round. */ 1597 break; /* Better luck next round. */
1599 skb->dev = dev; /* Mark as being used by this device. */
1600 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1598 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1601 desc->addr = cpu_to_leXX(pci_map_single(hmp->pci_dev, 1599 desc->addr = cpu_to_leXX(pci_map_single(hmp->pci_dev,
1602 skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE)); 1600 skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE));
diff --git a/drivers/net/ethernet/packetengines/yellowfin.c b/drivers/net/ethernet/packetengines/yellowfin.c
index db44e9af03c3..7757b80ef924 100644
--- a/drivers/net/ethernet/packetengines/yellowfin.c
+++ b/drivers/net/ethernet/packetengines/yellowfin.c
@@ -397,10 +397,9 @@ static int __devinit yellowfin_init_one(struct pci_dev *pdev,
397 if (i) return i; 397 if (i) return i;
398 398
399 dev = alloc_etherdev(sizeof(*np)); 399 dev = alloc_etherdev(sizeof(*np));
400 if (!dev) { 400 if (!dev)
401 pr_err("cannot allocate ethernet device\n");
402 return -ENOMEM; 401 return -ENOMEM;
403 } 402
404 SET_NETDEV_DEV(dev, &pdev->dev); 403 SET_NETDEV_DEV(dev, &pdev->dev);
405 404
406 np = netdev_priv(dev); 405 np = netdev_priv(dev);
@@ -744,11 +743,10 @@ static int yellowfin_init_ring(struct net_device *dev)
744 } 743 }
745 744
746 for (i = 0; i < RX_RING_SIZE; i++) { 745 for (i = 0; i < RX_RING_SIZE; i++) {
747 struct sk_buff *skb = dev_alloc_skb(yp->rx_buf_sz + 2); 746 struct sk_buff *skb = netdev_alloc_skb(dev, yp->rx_buf_sz + 2);
748 yp->rx_skbuff[i] = skb; 747 yp->rx_skbuff[i] = skb;
749 if (skb == NULL) 748 if (skb == NULL)
750 break; 749 break;
751 skb->dev = dev; /* Mark as being used by this device. */
752 skb_reserve(skb, 2); /* 16 byte align the IP header. */ 750 skb_reserve(skb, 2); /* 16 byte align the IP header. */
753 yp->rx_ring[i].addr = cpu_to_le32(pci_map_single(yp->pci_dev, 751 yp->rx_ring[i].addr = cpu_to_le32(pci_map_single(yp->pci_dev,
754 skb->data, yp->rx_buf_sz, PCI_DMA_FROMDEVICE)); 752 skb->data, yp->rx_buf_sz, PCI_DMA_FROMDEVICE));
@@ -1134,7 +1132,7 @@ static int yellowfin_rx(struct net_device *dev)
1134 PCI_DMA_FROMDEVICE); 1132 PCI_DMA_FROMDEVICE);
1135 yp->rx_skbuff[entry] = NULL; 1133 yp->rx_skbuff[entry] = NULL;
1136 } else { 1134 } else {
1137 skb = dev_alloc_skb(pkt_len + 2); 1135 skb = netdev_alloc_skb(dev, pkt_len + 2);
1138 if (skb == NULL) 1136 if (skb == NULL)
1139 break; 1137 break;
1140 skb_reserve(skb, 2); /* 16 byte align the IP header */ 1138 skb_reserve(skb, 2); /* 16 byte align the IP header */
@@ -1157,11 +1155,10 @@ static int yellowfin_rx(struct net_device *dev)
1157 for (; yp->cur_rx - yp->dirty_rx > 0; yp->dirty_rx++) { 1155 for (; yp->cur_rx - yp->dirty_rx > 0; yp->dirty_rx++) {
1158 entry = yp->dirty_rx % RX_RING_SIZE; 1156 entry = yp->dirty_rx % RX_RING_SIZE;
1159 if (yp->rx_skbuff[entry] == NULL) { 1157 if (yp->rx_skbuff[entry] == NULL) {
1160 struct sk_buff *skb = dev_alloc_skb(yp->rx_buf_sz + 2); 1158 struct sk_buff *skb = netdev_alloc_skb(dev, yp->rx_buf_sz + 2);
1161 if (skb == NULL) 1159 if (skb == NULL)
1162 break; /* Better luck next round. */ 1160 break; /* Better luck next round. */
1163 yp->rx_skbuff[entry] = skb; 1161 yp->rx_skbuff[entry] = skb;
1164 skb->dev = dev; /* Mark as being used by this device. */
1165 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1162 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1166 yp->rx_ring[entry].addr = cpu_to_le32(pci_map_single(yp->pci_dev, 1163 yp->rx_ring[entry].addr = cpu_to_le32(pci_map_single(yp->pci_dev,
1167 skb->data, yp->rx_buf_sz, PCI_DMA_FROMDEVICE)); 1164 skb->data, yp->rx_buf_sz, PCI_DMA_FROMDEVICE));
diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c
index 49b549ff2c78..667498ea4603 100644
--- a/drivers/net/ethernet/pasemi/pasemi_mac.c
+++ b/drivers/net/ethernet/pasemi/pasemi_mac.c
@@ -643,7 +643,7 @@ static void pasemi_mac_replenish_rx_ring(const struct net_device *dev,
643 /* Entry in use? */ 643 /* Entry in use? */
644 WARN_ON(*buff); 644 WARN_ON(*buff);
645 645
646 skb = dev_alloc_skb(mac->bufsz); 646 skb = netdev_alloc_skb(dev, mac->bufsz);
647 skb_reserve(skb, LOCAL_SKB_ALIGN); 647 skb_reserve(skb, LOCAL_SKB_ALIGN);
648 648
649 if (unlikely(!skb)) 649 if (unlikely(!skb))
@@ -1740,8 +1740,6 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1740 1740
1741 dev = alloc_etherdev(sizeof(struct pasemi_mac)); 1741 dev = alloc_etherdev(sizeof(struct pasemi_mac));
1742 if (dev == NULL) { 1742 if (dev == NULL) {
1743 dev_err(&pdev->dev,
1744 "pasemi_mac: Could not allocate ethernet device.\n");
1745 err = -ENOMEM; 1743 err = -ENOMEM;
1746 goto out_disable_device; 1744 goto out_disable_device;
1747 } 1745 }
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h
index a876dffd7101..2eeac32f7fdd 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h
@@ -53,8 +53,8 @@
53 53
54#define _NETXEN_NIC_LINUX_MAJOR 4 54#define _NETXEN_NIC_LINUX_MAJOR 4
55#define _NETXEN_NIC_LINUX_MINOR 0 55#define _NETXEN_NIC_LINUX_MINOR 0
56#define _NETXEN_NIC_LINUX_SUBVERSION 77 56#define _NETXEN_NIC_LINUX_SUBVERSION 78
57#define NETXEN_NIC_LINUX_VERSIONID "4.0.77" 57#define NETXEN_NIC_LINUX_VERSIONID "4.0.78"
58 58
59#define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c)) 59#define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c))
60#define _major(v) (((v) >> 24) & 0xff) 60#define _major(v) (((v) >> 24) & 0xff)
@@ -686,6 +686,18 @@ struct netxen_recv_context {
686 dma_addr_t phys_addr; 686 dma_addr_t phys_addr;
687}; 687};
688 688
689struct _cdrp_cmd {
690 u32 cmd;
691 u32 arg1;
692 u32 arg2;
693 u32 arg3;
694};
695
696struct netxen_cmd_args {
697 struct _cdrp_cmd req;
698 struct _cdrp_cmd rsp;
699};
700
689/* New HW context creation */ 701/* New HW context creation */
690 702
691#define NX_OS_CRB_RETRY_COUNT 4000 703#define NX_OS_CRB_RETRY_COUNT 4000
@@ -1142,6 +1154,7 @@ typedef struct {
1142#define NETXEN_NIC_LRO_DISABLED 0x00 1154#define NETXEN_NIC_LRO_DISABLED 0x00
1143#define NETXEN_NIC_BRIDGE_ENABLED 0X10 1155#define NETXEN_NIC_BRIDGE_ENABLED 0X10
1144#define NETXEN_NIC_DIAG_ENABLED 0x20 1156#define NETXEN_NIC_DIAG_ENABLED 0x20
1157#define NETXEN_FW_RESET_OWNER 0x40
1145#define NETXEN_IS_MSI_FAMILY(adapter) \ 1158#define NETXEN_IS_MSI_FAMILY(adapter) \
1146 ((adapter)->flags & (NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED)) 1159 ((adapter)->flags & (NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED))
1147 1160
@@ -1159,6 +1172,419 @@ typedef struct {
1159#define __NX_DEV_UP 1 1172#define __NX_DEV_UP 1
1160#define __NX_RESETTING 2 1173#define __NX_RESETTING 2
1161 1174
1175/* Mini Coredump FW supported version */
1176#define NX_MD_SUPPORT_MAJOR 4
1177#define NX_MD_SUPPORT_MINOR 0
1178#define NX_MD_SUPPORT_SUBVERSION 579
1179
1180#define LSW(x) ((uint16_t)(x))
1181#define LSD(x) ((uint32_t)((uint64_t)(x)))
1182#define MSD(x) ((uint32_t)((((uint64_t)(x)) >> 16) >> 16))
1183
1184/* Mini Coredump mask level */
1185#define NX_DUMP_MASK_MIN 0x03
1186#define NX_DUMP_MASK_DEF 0x1f
1187#define NX_DUMP_MASK_MAX 0xff
1188
1189/* Mini Coredump CDRP commands */
1190#define NX_CDRP_CMD_TEMP_SIZE 0x0000002f
1191#define NX_CDRP_CMD_GET_TEMP_HDR 0x00000030
1192
1193
1194#define NX_DUMP_STATE_ARRAY_LEN 16
1195#define NX_DUMP_CAP_SIZE_ARRAY_LEN 8
1196
1197/* Mini Coredump sysfs entries flags*/
1198#define NX_FORCE_FW_DUMP_KEY 0xdeadfeed
1199#define NX_ENABLE_FW_DUMP 0xaddfeed
1200#define NX_DISABLE_FW_DUMP 0xbadfeed
1201#define NX_FORCE_FW_RESET 0xdeaddead
1202
1203
1204/* Flash read/write address */
1205#define NX_FW_DUMP_REG1 0x00130060
1206#define NX_FW_DUMP_REG2 0x001e0000
1207#define NX_FLASH_SEM2_LK 0x0013C010
1208#define NX_FLASH_SEM2_ULK 0x0013C014
1209#define NX_FLASH_LOCK_ID 0x001B2100
1210#define FLASH_ROM_WINDOW 0x42110030
1211#define FLASH_ROM_DATA 0x42150000
1212
1213/* Mini Coredump register read/write routine */
1214#define NX_RD_DUMP_REG(addr, bar0, data) do { \
1215 writel((addr & 0xFFFF0000), (void __iomem *) (bar0 + \
1216 NX_FW_DUMP_REG1)); \
1217 readl((void __iomem *) (bar0 + NX_FW_DUMP_REG1)); \
1218 *data = readl((void __iomem *) (bar0 + NX_FW_DUMP_REG2 + \
1219 LSW(addr))); \
1220} while (0)
1221
1222#define NX_WR_DUMP_REG(addr, bar0, data) do { \
1223 writel((addr & 0xFFFF0000), (void __iomem *) (bar0 + \
1224 NX_FW_DUMP_REG1)); \
1225 readl((void __iomem *) (bar0 + NX_FW_DUMP_REG1)); \
1226 writel(data, (void __iomem *) (bar0 + NX_FW_DUMP_REG2 + LSW(addr)));\
1227 readl((void __iomem *) (bar0 + NX_FW_DUMP_REG2 + LSW(addr))); \
1228} while (0)
1229
1230
1231/*
1232Entry Type Defines
1233*/
1234
1235#define RDNOP 0
1236#define RDCRB 1
1237#define RDMUX 2
1238#define QUEUE 3
1239#define BOARD 4
1240#define RDSRE 5
1241#define RDOCM 6
1242#define PREGS 7
1243#define L1DTG 8
1244#define L1ITG 9
1245#define CACHE 10
1246
1247#define L1DAT 11
1248#define L1INS 12
1249#define RDSTK 13
1250#define RDCON 14
1251
1252#define L2DTG 21
1253#define L2ITG 22
1254#define L2DAT 23
1255#define L2INS 24
1256#define RDOC3 25
1257
1258#define MEMBK 32
1259
1260#define RDROM 71
1261#define RDMEM 72
1262#define RDMN 73
1263
1264#define INFOR 81
1265#define CNTRL 98
1266
1267#define TLHDR 99
1268#define RDEND 255
1269
1270#define PRIMQ 103
1271#define SQG2Q 104
1272#define SQG3Q 105
1273
1274/*
1275* Opcodes for Control Entries.
1276* These Flags are bit fields.
1277*/
1278#define NX_DUMP_WCRB 0x01
1279#define NX_DUMP_RWCRB 0x02
1280#define NX_DUMP_ANDCRB 0x04
1281#define NX_DUMP_ORCRB 0x08
1282#define NX_DUMP_POLLCRB 0x10
1283#define NX_DUMP_RD_SAVE 0x20
1284#define NX_DUMP_WRT_SAVED 0x40
1285#define NX_DUMP_MOD_SAVE_ST 0x80
1286
1287/* Driver Flags */
1288#define NX_DUMP_SKIP 0x80 /* driver skipped this entry */
1289#define NX_DUMP_SIZE_ERR 0x40 /*entry size vs capture size mismatch*/
1290
1291#define NX_PCI_READ_32(ADDR) readl((ADDR))
1292#define NX_PCI_WRITE_32(DATA, ADDR) writel(DATA, (ADDR))
1293
1294
1295
1296struct netxen_minidump {
1297 u32 pos; /* position in the dump buffer */
1298 u8 fw_supports_md; /* FW supports Mini cordump */
1299 u8 has_valid_dump; /* indicates valid dump */
1300 u8 md_capture_mask; /* driver capture mask */
1301 u8 md_enabled; /* Turn Mini Coredump on/off */
1302 u32 md_dump_size; /* Total FW Mini Coredump size */
1303 u32 md_capture_size; /* FW dump capture size */
1304 u32 md_template_size; /* FW template size */
1305 u32 md_template_ver; /* FW template version */
1306 u64 md_timestamp; /* FW Mini dump timestamp */
1307 void *md_template; /* FW template will be stored */
1308 void *md_capture_buff; /* FW dump will be stored */
1309};
1310
1311
1312
1313struct netxen_minidump_template_hdr {
1314 u32 entry_type;
1315 u32 first_entry_offset;
1316 u32 size_of_template;
1317 u32 capture_mask;
1318 u32 num_of_entries;
1319 u32 version;
1320 u32 driver_timestamp;
1321 u32 checksum;
1322 u32 driver_capture_mask;
1323 u32 driver_info_word2;
1324 u32 driver_info_word3;
1325 u32 driver_info_word4;
1326 u32 saved_state_array[NX_DUMP_STATE_ARRAY_LEN];
1327 u32 capture_size_array[NX_DUMP_CAP_SIZE_ARRAY_LEN];
1328 u32 rsvd[0];
1329};
1330
1331/* Common Entry Header: Common to All Entry Types */
1332/*
1333 * Driver Code is for driver to write some info about the entry.
1334 * Currently not used.
1335 */
1336
1337struct netxen_common_entry_hdr {
1338 u32 entry_type;
1339 u32 entry_size;
1340 u32 entry_capture_size;
1341 union {
1342 struct {
1343 u8 entry_capture_mask;
1344 u8 entry_code;
1345 u8 driver_code;
1346 u8 driver_flags;
1347 };
1348 u32 entry_ctrl_word;
1349 };
1350};
1351
1352
1353/* Generic Entry Including Header */
1354struct netxen_minidump_entry {
1355 struct netxen_common_entry_hdr hdr;
1356 u32 entry_data00;
1357 u32 entry_data01;
1358 u32 entry_data02;
1359 u32 entry_data03;
1360 u32 entry_data04;
1361 u32 entry_data05;
1362 u32 entry_data06;
1363 u32 entry_data07;
1364};
1365
1366/* Read ROM Header */
1367struct netxen_minidump_entry_rdrom {
1368 struct netxen_common_entry_hdr h;
1369 union {
1370 struct {
1371 u32 select_addr_reg;
1372 };
1373 u32 rsvd_0;
1374 };
1375 union {
1376 struct {
1377 u8 addr_stride;
1378 u8 addr_cnt;
1379 u16 data_size;
1380 };
1381 u32 rsvd_1;
1382 };
1383 union {
1384 struct {
1385 u32 op_count;
1386 };
1387 u32 rsvd_2;
1388 };
1389 union {
1390 struct {
1391 u32 read_addr_reg;
1392 };
1393 u32 rsvd_3;
1394 };
1395 union {
1396 struct {
1397 u32 write_mask;
1398 };
1399 u32 rsvd_4;
1400 };
1401 union {
1402 struct {
1403 u32 read_mask;
1404 };
1405 u32 rsvd_5;
1406 };
1407 u32 read_addr;
1408 u32 read_data_size;
1409};
1410
1411
1412/* Read CRB and Control Entry Header */
1413struct netxen_minidump_entry_crb {
1414 struct netxen_common_entry_hdr h;
1415 u32 addr;
1416 union {
1417 struct {
1418 u8 addr_stride;
1419 u8 state_index_a;
1420 u16 poll_timeout;
1421 };
1422 u32 addr_cntrl;
1423 };
1424 u32 data_size;
1425 u32 op_count;
1426 union {
1427 struct {
1428 u8 opcode;
1429 u8 state_index_v;
1430 u8 shl;
1431 u8 shr;
1432 };
1433 u32 control_value;
1434 };
1435 u32 value_1;
1436 u32 value_2;
1437 u32 value_3;
1438};
1439
1440/* Read Memory and MN Header */
1441struct netxen_minidump_entry_rdmem {
1442 struct netxen_common_entry_hdr h;
1443 union {
1444 struct {
1445 u32 select_addr_reg;
1446 };
1447 u32 rsvd_0;
1448 };
1449 union {
1450 struct {
1451 u8 addr_stride;
1452 u8 addr_cnt;
1453 u16 data_size;
1454 };
1455 u32 rsvd_1;
1456 };
1457 union {
1458 struct {
1459 u32 op_count;
1460 };
1461 u32 rsvd_2;
1462 };
1463 union {
1464 struct {
1465 u32 read_addr_reg;
1466 };
1467 u32 rsvd_3;
1468 };
1469 union {
1470 struct {
1471 u32 cntrl_addr_reg;
1472 };
1473 u32 rsvd_4;
1474 };
1475 union {
1476 struct {
1477 u8 wr_byte0;
1478 u8 wr_byte1;
1479 u8 poll_mask;
1480 u8 poll_cnt;
1481 };
1482 u32 rsvd_5;
1483 };
1484 u32 read_addr;
1485 u32 read_data_size;
1486};
1487
1488/* Read Cache L1 and L2 Header */
1489struct netxen_minidump_entry_cache {
1490 struct netxen_common_entry_hdr h;
1491 u32 tag_reg_addr;
1492 union {
1493 struct {
1494 u16 tag_value_stride;
1495 u16 init_tag_value;
1496 };
1497 u32 select_addr_cntrl;
1498 };
1499 u32 data_size;
1500 u32 op_count;
1501 u32 control_addr;
1502 union {
1503 struct {
1504 u16 write_value;
1505 u8 poll_mask;
1506 u8 poll_wait;
1507 };
1508 u32 control_value;
1509 };
1510 u32 read_addr;
1511 union {
1512 struct {
1513 u8 read_addr_stride;
1514 u8 read_addr_cnt;
1515 u16 rsvd_1;
1516 };
1517 u32 read_addr_cntrl;
1518 };
1519};
1520
1521/* Read OCM Header */
1522struct netxen_minidump_entry_rdocm {
1523 struct netxen_common_entry_hdr h;
1524 u32 rsvd_0;
1525 union {
1526 struct {
1527 u32 rsvd_1;
1528 };
1529 u32 select_addr_cntrl;
1530 };
1531 u32 data_size;
1532 u32 op_count;
1533 u32 rsvd_2;
1534 u32 rsvd_3;
1535 u32 read_addr;
1536 union {
1537 struct {
1538 u32 read_addr_stride;
1539 };
1540 u32 read_addr_cntrl;
1541 };
1542};
1543
1544/* Read MUX Header */
1545struct netxen_minidump_entry_mux {
1546 struct netxen_common_entry_hdr h;
1547 u32 select_addr;
1548 union {
1549 struct {
1550 u32 rsvd_0;
1551 };
1552 u32 select_addr_cntrl;
1553 };
1554 u32 data_size;
1555 u32 op_count;
1556 u32 select_value;
1557 u32 select_value_stride;
1558 u32 read_addr;
1559 u32 rsvd_1;
1560};
1561
1562/* Read Queue Header */
1563struct netxen_minidump_entry_queue {
1564 struct netxen_common_entry_hdr h;
1565 u32 select_addr;
1566 union {
1567 struct {
1568 u16 queue_id_stride;
1569 u16 rsvd_0;
1570 };
1571 u32 select_addr_cntrl;
1572 };
1573 u32 data_size;
1574 u32 op_count;
1575 u32 rsvd_1;
1576 u32 rsvd_2;
1577 u32 read_addr;
1578 union {
1579 struct {
1580 u8 read_addr_stride;
1581 u8 read_addr_cnt;
1582 u16 rsvd_3;
1583 };
1584 u32 read_addr_cntrl;
1585 };
1586};
1587
1162struct netxen_dummy_dma { 1588struct netxen_dummy_dma {
1163 void *addr; 1589 void *addr;
1164 dma_addr_t phys_addr; 1590 dma_addr_t phys_addr;
@@ -1263,6 +1689,8 @@ struct netxen_adapter {
1263 __le32 file_prd_off; /*File fw product offset*/ 1689 __le32 file_prd_off; /*File fw product offset*/
1264 u32 fw_version; 1690 u32 fw_version;
1265 const struct firmware *fw; 1691 const struct firmware *fw;
1692 struct netxen_minidump mdump; /* mdump ptr */
1693 int fw_mdump_rdy; /* for mdump ready */
1266}; 1694};
1267 1695
1268int nx_fw_cmd_query_phy(struct netxen_adapter *adapter, u32 reg, u32 *val); 1696int nx_fw_cmd_query_phy(struct netxen_adapter *adapter, u32 reg, u32 *val);
@@ -1365,13 +1793,16 @@ int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
1365int netxen_config_hw_lro(struct netxen_adapter *adapter, int enable); 1793int netxen_config_hw_lro(struct netxen_adapter *adapter, int enable);
1366int netxen_config_bridged_mode(struct netxen_adapter *adapter, int enable); 1794int netxen_config_bridged_mode(struct netxen_adapter *adapter, int enable);
1367int netxen_send_lro_cleanup(struct netxen_adapter *adapter); 1795int netxen_send_lro_cleanup(struct netxen_adapter *adapter);
1368 1796int netxen_setup_minidump(struct netxen_adapter *adapter);
1797void netxen_dump_fw(struct netxen_adapter *adapter);
1369void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, 1798void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
1370 struct nx_host_tx_ring *tx_ring); 1799 struct nx_host_tx_ring *tx_ring);
1371 1800
1372/* Functions from netxen_nic_main.c */ 1801/* Functions from netxen_nic_main.c */
1373int netxen_nic_reset_context(struct netxen_adapter *); 1802int netxen_nic_reset_context(struct netxen_adapter *);
1374 1803
1804int nx_dev_request_reset(struct netxen_adapter *adapter);
1805
1375/* 1806/*
1376 * NetXen Board information 1807 * NetXen Board information
1377 */ 1808 */
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
index a925392abd6f..f3c0057a802b 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
@@ -48,28 +48,27 @@ netxen_poll_rsp(struct netxen_adapter *adapter)
48} 48}
49 49
50static u32 50static u32
51netxen_issue_cmd(struct netxen_adapter *adapter, 51netxen_issue_cmd(struct netxen_adapter *adapter, struct netxen_cmd_args *cmd)
52 u32 pci_fn, u32 version, u32 arg1, u32 arg2, u32 arg3, u32 cmd)
53{ 52{
54 u32 rsp; 53 u32 rsp;
55 u32 signature = 0; 54 u32 signature = 0;
56 u32 rcode = NX_RCODE_SUCCESS; 55 u32 rcode = NX_RCODE_SUCCESS;
57 56
58 signature = NX_CDRP_SIGNATURE_MAKE(pci_fn, version); 57 signature = NX_CDRP_SIGNATURE_MAKE(adapter->ahw.pci_func,
59 58 NXHAL_VERSION);
60 /* Acquire semaphore before accessing CRB */ 59 /* Acquire semaphore before accessing CRB */
61 if (netxen_api_lock(adapter)) 60 if (netxen_api_lock(adapter))
62 return NX_RCODE_TIMEOUT; 61 return NX_RCODE_TIMEOUT;
63 62
64 NXWR32(adapter, NX_SIGN_CRB_OFFSET, signature); 63 NXWR32(adapter, NX_SIGN_CRB_OFFSET, signature);
65 64
66 NXWR32(adapter, NX_ARG1_CRB_OFFSET, arg1); 65 NXWR32(adapter, NX_ARG1_CRB_OFFSET, cmd->req.arg1);
67 66
68 NXWR32(adapter, NX_ARG2_CRB_OFFSET, arg2); 67 NXWR32(adapter, NX_ARG2_CRB_OFFSET, cmd->req.arg2);
69 68
70 NXWR32(adapter, NX_ARG3_CRB_OFFSET, arg3); 69 NXWR32(adapter, NX_ARG3_CRB_OFFSET, cmd->req.arg3);
71 70
72 NXWR32(adapter, NX_CDRP_CRB_OFFSET, NX_CDRP_FORM_CMD(cmd)); 71 NXWR32(adapter, NX_CDRP_CRB_OFFSET, NX_CDRP_FORM_CMD(cmd->req.cmd));
73 72
74 rsp = netxen_poll_rsp(adapter); 73 rsp = netxen_poll_rsp(adapter);
75 74
@@ -83,28 +82,179 @@ netxen_issue_cmd(struct netxen_adapter *adapter,
83 82
84 printk(KERN_ERR "%s: failed card response code:0x%x\n", 83 printk(KERN_ERR "%s: failed card response code:0x%x\n",
85 netxen_nic_driver_name, rcode); 84 netxen_nic_driver_name, rcode);
85 } else if (rsp == NX_CDRP_RSP_OK) {
86 cmd->rsp.cmd = NX_RCODE_SUCCESS;
87 if (cmd->rsp.arg2)
88 cmd->rsp.arg2 = NXRD32(adapter, NX_ARG2_CRB_OFFSET);
89 if (cmd->rsp.arg3)
90 cmd->rsp.arg3 = NXRD32(adapter, NX_ARG3_CRB_OFFSET);
86 } 91 }
87 92
93 if (cmd->rsp.arg1)
94 cmd->rsp.arg1 = NXRD32(adapter, NX_ARG1_CRB_OFFSET);
88 /* Release semaphore */ 95 /* Release semaphore */
89 netxen_api_unlock(adapter); 96 netxen_api_unlock(adapter);
90 97
91 return rcode; 98 return rcode;
92} 99}
93 100
101static int
102netxen_get_minidump_template_size(struct netxen_adapter *adapter)
103{
104 struct netxen_cmd_args cmd;
105 memset(&cmd, 0, sizeof(cmd));
106 cmd.req.cmd = NX_CDRP_CMD_TEMP_SIZE;
107 memset(&cmd.rsp, 1, sizeof(struct _cdrp_cmd));
108 netxen_issue_cmd(adapter, &cmd);
109 if (cmd.rsp.cmd != NX_RCODE_SUCCESS) {
110 dev_info(&adapter->pdev->dev,
111 "Can't get template size %d\n", cmd.rsp.cmd);
112 return -EIO;
113 }
114 adapter->mdump.md_template_size = cmd.rsp.arg2;
115 adapter->mdump.md_template_ver = cmd.rsp.arg3;
116 return 0;
117}
118
119static int
120netxen_get_minidump_template(struct netxen_adapter *adapter)
121{
122 dma_addr_t md_template_addr;
123 void *addr;
124 u32 size;
125 struct netxen_cmd_args cmd;
126 size = adapter->mdump.md_template_size;
127
128 if (size == 0) {
129 dev_err(&adapter->pdev->dev, "Can not capture Minidump "
130 "template. Invalid template size.\n");
131 return NX_RCODE_INVALID_ARGS;
132 }
133
134 addr = pci_alloc_consistent(adapter->pdev, size, &md_template_addr);
135
136 if (!addr) {
137 dev_err(&adapter->pdev->dev, "Unable to allocate dmable memory for template.\n");
138 return -ENOMEM;
139 }
140
141 memset(addr, 0, size);
142 memset(&cmd, 0, sizeof(cmd));
143 memset(&cmd.rsp, 1, sizeof(struct _cdrp_cmd));
144 cmd.req.cmd = NX_CDRP_CMD_GET_TEMP_HDR;
145 cmd.req.arg1 = LSD(md_template_addr);
146 cmd.req.arg2 = MSD(md_template_addr);
147 cmd.req.arg3 |= size;
148 netxen_issue_cmd(adapter, &cmd);
149
150 if ((cmd.rsp.cmd == NX_RCODE_SUCCESS) && (size == cmd.rsp.arg2)) {
151 memcpy(adapter->mdump.md_template, addr, size);
152 } else {
153 dev_err(&adapter->pdev->dev, "Failed to get minidump template, "
154 "err_code : %d, requested_size : %d, actual_size : %d\n ",
155 cmd.rsp.cmd, size, cmd.rsp.arg2);
156 }
157 pci_free_consistent(adapter->pdev, size, addr, md_template_addr);
158 return 0;
159}
160
161static u32
162netxen_check_template_checksum(struct netxen_adapter *adapter)
163{
164 u64 sum = 0 ;
165 u32 *buff = adapter->mdump.md_template;
166 int count = adapter->mdump.md_template_size/sizeof(uint32_t) ;
167
168 while (count-- > 0)
169 sum += *buff++ ;
170 while (sum >> 32)
171 sum = (sum & 0xFFFFFFFF) + (sum >> 32) ;
172
173 return ~sum;
174}
175
176int
177netxen_setup_minidump(struct netxen_adapter *adapter)
178{
179 int err = 0, i;
180 u32 *template, *tmp_buf;
181 struct netxen_minidump_template_hdr *hdr;
182 err = netxen_get_minidump_template_size(adapter);
183 if (err) {
184 adapter->mdump.fw_supports_md = 0;
185 if ((err == NX_RCODE_CMD_INVALID) ||
186 (err == NX_RCODE_CMD_NOT_IMPL)) {
187 dev_info(&adapter->pdev->dev,
188 "Flashed firmware version does not support minidump, "
189 "minimum version required is [ %u.%u.%u ].\n ",
190 NX_MD_SUPPORT_MAJOR, NX_MD_SUPPORT_MINOR,
191 NX_MD_SUPPORT_SUBVERSION);
192 }
193 return err;
194 }
195
196 if (!adapter->mdump.md_template_size) {
197 dev_err(&adapter->pdev->dev, "Error : Invalid template size "
198 ",should be non-zero.\n");
199 return -EIO;
200 }
201 adapter->mdump.md_template =
202 kmalloc(adapter->mdump.md_template_size, GFP_KERNEL);
203
204 if (!adapter->mdump.md_template) {
205 dev_err(&adapter->pdev->dev, "Unable to allocate memory "
206 "for minidump template.\n");
207 return -ENOMEM;
208 }
209
210 err = netxen_get_minidump_template(adapter);
211 if (err) {
212 if (err == NX_RCODE_CMD_NOT_IMPL)
213 adapter->mdump.fw_supports_md = 0;
214 goto free_template;
215 }
216
217 if (netxen_check_template_checksum(adapter)) {
218 dev_err(&adapter->pdev->dev, "Minidump template checksum Error\n");
219 err = -EIO;
220 goto free_template;
221 }
222
223 adapter->mdump.md_capture_mask = NX_DUMP_MASK_DEF;
224 tmp_buf = (u32 *) adapter->mdump.md_template;
225 template = (u32 *) adapter->mdump.md_template;
226 for (i = 0; i < adapter->mdump.md_template_size/sizeof(u32); i++)
227 *template++ = __le32_to_cpu(*tmp_buf++);
228 hdr = (struct netxen_minidump_template_hdr *)
229 adapter->mdump.md_template;
230 adapter->mdump.md_capture_buff = NULL;
231 adapter->mdump.fw_supports_md = 1;
232 adapter->mdump.md_enabled = 1;
233
234 return err;
235
236free_template:
237 kfree(adapter->mdump.md_template);
238 adapter->mdump.md_template = NULL;
239 return err;
240}
241
242
94int 243int
95nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu) 244nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu)
96{ 245{
97 u32 rcode = NX_RCODE_SUCCESS; 246 u32 rcode = NX_RCODE_SUCCESS;
98 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; 247 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
248 struct netxen_cmd_args cmd;
249
250 memset(&cmd, 0, sizeof(cmd));
251 cmd.req.cmd = NX_CDRP_CMD_SET_MTU;
252 cmd.req.arg1 = recv_ctx->context_id;
253 cmd.req.arg2 = mtu;
254 cmd.req.arg3 = 0;
99 255
100 if (recv_ctx->state == NX_HOST_CTX_STATE_ACTIVE) 256 if (recv_ctx->state == NX_HOST_CTX_STATE_ACTIVE)
101 rcode = netxen_issue_cmd(adapter, 257 netxen_issue_cmd(adapter, &cmd);
102 adapter->ahw.pci_func,
103 NXHAL_VERSION,
104 recv_ctx->context_id,
105 mtu,
106 0,
107 NX_CDRP_CMD_SET_MTU);
108 258
109 if (rcode != NX_RCODE_SUCCESS) 259 if (rcode != NX_RCODE_SUCCESS)
110 return -EIO; 260 return -EIO;
@@ -116,15 +266,14 @@ int
116nx_fw_cmd_set_gbe_port(struct netxen_adapter *adapter, 266nx_fw_cmd_set_gbe_port(struct netxen_adapter *adapter,
117 u32 speed, u32 duplex, u32 autoneg) 267 u32 speed, u32 duplex, u32 autoneg)
118{ 268{
119 269 struct netxen_cmd_args cmd;
120 return netxen_issue_cmd(adapter, 270
121 adapter->ahw.pci_func, 271 memset(&cmd, 0, sizeof(cmd));
122 NXHAL_VERSION, 272 cmd.req.cmd = NX_CDRP_CMD_CONFIG_GBE_PORT;
123 speed, 273 cmd.req.arg1 = speed;
124 duplex, 274 cmd.req.arg2 = duplex;
125 autoneg, 275 cmd.req.arg3 = autoneg;
126 NX_CDRP_CMD_CONFIG_GBE_PORT); 276 return netxen_issue_cmd(adapter, &cmd);
127
128} 277}
129 278
130static int 279static int
@@ -139,6 +288,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
139 nx_cardrsp_sds_ring_t *prsp_sds; 288 nx_cardrsp_sds_ring_t *prsp_sds;
140 struct nx_host_rds_ring *rds_ring; 289 struct nx_host_rds_ring *rds_ring;
141 struct nx_host_sds_ring *sds_ring; 290 struct nx_host_sds_ring *sds_ring;
291 struct netxen_cmd_args cmd;
142 292
143 dma_addr_t hostrq_phys_addr, cardrsp_phys_addr; 293 dma_addr_t hostrq_phys_addr, cardrsp_phys_addr;
144 u64 phys_addr; 294 u64 phys_addr;
@@ -218,13 +368,12 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
218 } 368 }
219 369
220 phys_addr = hostrq_phys_addr; 370 phys_addr = hostrq_phys_addr;
221 err = netxen_issue_cmd(adapter, 371 memset(&cmd, 0, sizeof(cmd));
222 adapter->ahw.pci_func, 372 cmd.req.arg1 = (u32)(phys_addr >> 32);
223 NXHAL_VERSION, 373 cmd.req.arg2 = (u32)(phys_addr & 0xffffffff);
224 (u32)(phys_addr >> 32), 374 cmd.req.arg3 = rq_size;
225 (u32)(phys_addr & 0xffffffff), 375 cmd.req.cmd = NX_CDRP_CMD_CREATE_RX_CTX;
226 rq_size, 376 err = netxen_issue_cmd(adapter, &cmd);
227 NX_CDRP_CMD_CREATE_RX_CTX);
228 if (err) { 377 if (err) {
229 printk(KERN_WARNING 378 printk(KERN_WARNING
230 "Failed to create rx ctx in firmware%d\n", err); 379 "Failed to create rx ctx in firmware%d\n", err);
@@ -273,15 +422,15 @@ static void
273nx_fw_cmd_destroy_rx_ctx(struct netxen_adapter *adapter) 422nx_fw_cmd_destroy_rx_ctx(struct netxen_adapter *adapter)
274{ 423{
275 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; 424 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
425 struct netxen_cmd_args cmd;
276 426
277 if (netxen_issue_cmd(adapter, 427 memset(&cmd, 0, sizeof(cmd));
278 adapter->ahw.pci_func, 428 cmd.req.arg1 = recv_ctx->context_id;
279 NXHAL_VERSION, 429 cmd.req.arg2 = NX_DESTROY_CTX_RESET;
280 recv_ctx->context_id, 430 cmd.req.arg3 = 0;
281 NX_DESTROY_CTX_RESET, 431 cmd.req.cmd = NX_CDRP_CMD_DESTROY_RX_CTX;
282 0,
283 NX_CDRP_CMD_DESTROY_RX_CTX)) {
284 432
433 if (netxen_issue_cmd(adapter, &cmd)) {
285 printk(KERN_WARNING 434 printk(KERN_WARNING
286 "%s: Failed to destroy rx ctx in firmware\n", 435 "%s: Failed to destroy rx ctx in firmware\n",
287 netxen_nic_driver_name); 436 netxen_nic_driver_name);
@@ -302,6 +451,7 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
302 dma_addr_t rq_phys_addr, rsp_phys_addr; 451 dma_addr_t rq_phys_addr, rsp_phys_addr;
303 struct nx_host_tx_ring *tx_ring = adapter->tx_ring; 452 struct nx_host_tx_ring *tx_ring = adapter->tx_ring;
304 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; 453 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
454 struct netxen_cmd_args cmd;
305 455
306 rq_size = SIZEOF_HOSTRQ_TX(nx_hostrq_tx_ctx_t); 456 rq_size = SIZEOF_HOSTRQ_TX(nx_hostrq_tx_ctx_t);
307 rq_addr = pci_alloc_consistent(adapter->pdev, 457 rq_addr = pci_alloc_consistent(adapter->pdev,
@@ -345,13 +495,12 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
345 prq_cds->ring_size = cpu_to_le32(tx_ring->num_desc); 495 prq_cds->ring_size = cpu_to_le32(tx_ring->num_desc);
346 496
347 phys_addr = rq_phys_addr; 497 phys_addr = rq_phys_addr;
348 err = netxen_issue_cmd(adapter, 498 memset(&cmd, 0, sizeof(cmd));
349 adapter->ahw.pci_func, 499 cmd.req.arg1 = (u32)(phys_addr >> 32);
350 NXHAL_VERSION, 500 cmd.req.arg2 = ((u32)phys_addr & 0xffffffff);
351 (u32)(phys_addr >> 32), 501 cmd.req.arg3 = rq_size;
352 ((u32)phys_addr & 0xffffffff), 502 cmd.req.cmd = NX_CDRP_CMD_CREATE_TX_CTX;
353 rq_size, 503 err = netxen_issue_cmd(adapter, &cmd);
354 NX_CDRP_CMD_CREATE_TX_CTX);
355 504
356 if (err == NX_RCODE_SUCCESS) { 505 if (err == NX_RCODE_SUCCESS) {
357 temp = le32_to_cpu(prsp->cds_ring.host_producer_crb); 506 temp = le32_to_cpu(prsp->cds_ring.host_producer_crb);
@@ -380,14 +529,14 @@ out_free_rq:
380static void 529static void
381nx_fw_cmd_destroy_tx_ctx(struct netxen_adapter *adapter) 530nx_fw_cmd_destroy_tx_ctx(struct netxen_adapter *adapter)
382{ 531{
383 if (netxen_issue_cmd(adapter, 532 struct netxen_cmd_args cmd;
384 adapter->ahw.pci_func, 533
385 NXHAL_VERSION, 534 memset(&cmd, 0, sizeof(cmd));
386 adapter->tx_context_id, 535 cmd.req.arg1 = adapter->tx_context_id;
387 NX_DESTROY_CTX_RESET, 536 cmd.req.arg2 = NX_DESTROY_CTX_RESET;
388 0, 537 cmd.req.arg3 = 0;
389 NX_CDRP_CMD_DESTROY_TX_CTX)) { 538 cmd.req.cmd = NX_CDRP_CMD_DESTROY_TX_CTX;
390 539 if (netxen_issue_cmd(adapter, &cmd)) {
391 printk(KERN_WARNING 540 printk(KERN_WARNING
392 "%s: Failed to destroy tx ctx in firmware\n", 541 "%s: Failed to destroy tx ctx in firmware\n",
393 netxen_nic_driver_name); 542 netxen_nic_driver_name);
@@ -398,34 +547,37 @@ int
398nx_fw_cmd_query_phy(struct netxen_adapter *adapter, u32 reg, u32 *val) 547nx_fw_cmd_query_phy(struct netxen_adapter *adapter, u32 reg, u32 *val)
399{ 548{
400 u32 rcode; 549 u32 rcode;
401 550 struct netxen_cmd_args cmd;
402 rcode = netxen_issue_cmd(adapter, 551
403 adapter->ahw.pci_func, 552 memset(&cmd, 0, sizeof(cmd));
404 NXHAL_VERSION, 553 cmd.req.arg1 = reg;
405 reg, 554 cmd.req.arg2 = 0;
406 0, 555 cmd.req.arg3 = 0;
407 0, 556 cmd.req.cmd = NX_CDRP_CMD_READ_PHY;
408 NX_CDRP_CMD_READ_PHY); 557 cmd.rsp.arg1 = 1;
409 558 rcode = netxen_issue_cmd(adapter, &cmd);
410 if (rcode != NX_RCODE_SUCCESS) 559 if (rcode != NX_RCODE_SUCCESS)
411 return -EIO; 560 return -EIO;
412 561
413 return NXRD32(adapter, NX_ARG1_CRB_OFFSET); 562 if (val == NULL)
563 return -EIO;
564
565 *val = cmd.rsp.arg1;
566 return 0;
414} 567}
415 568
416int 569int
417nx_fw_cmd_set_phy(struct netxen_adapter *adapter, u32 reg, u32 val) 570nx_fw_cmd_set_phy(struct netxen_adapter *adapter, u32 reg, u32 val)
418{ 571{
419 u32 rcode; 572 u32 rcode;
420 573 struct netxen_cmd_args cmd;
421 rcode = netxen_issue_cmd(adapter, 574
422 adapter->ahw.pci_func, 575 memset(&cmd, 0, sizeof(cmd));
423 NXHAL_VERSION, 576 cmd.req.arg1 = reg;
424 reg, 577 cmd.req.arg2 = val;
425 val, 578 cmd.req.arg3 = 0;
426 0, 579 cmd.req.cmd = NX_CDRP_CMD_WRITE_PHY;
427 NX_CDRP_CMD_WRITE_PHY); 580 rcode = netxen_issue_cmd(adapter, &cmd);
428
429 if (rcode != NX_RCODE_SUCCESS) 581 if (rcode != NX_RCODE_SUCCESS)
430 return -EIO; 582 return -EIO;
431 583
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c
index 8a371985319f..8c39299331a2 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c
@@ -248,6 +248,11 @@ skip:
248 } 248 }
249 } 249 }
250 250
251 if (!netif_running(dev) || !adapter->ahw.linkup) {
252 ecmd->duplex = DUPLEX_UNKNOWN;
253 ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN);
254 }
255
251 return 0; 256 return 0;
252} 257}
253 258
@@ -812,6 +817,107 @@ static int netxen_get_intr_coalesce(struct net_device *netdev,
812 return 0; 817 return 0;
813} 818}
814 819
820static int
821netxen_get_dump_flag(struct net_device *netdev, struct ethtool_dump *dump)
822{
823 struct netxen_adapter *adapter = netdev_priv(netdev);
824 struct netxen_minidump *mdump = &adapter->mdump;
825 if (adapter->fw_mdump_rdy)
826 dump->len = mdump->md_dump_size;
827 else
828 dump->len = 0;
829 dump->flag = mdump->md_capture_mask;
830 dump->version = adapter->fw_version;
831 return 0;
832}
833
834static int
835netxen_set_dump(struct net_device *netdev, struct ethtool_dump *val)
836{
837 int ret = 0;
838 struct netxen_adapter *adapter = netdev_priv(netdev);
839 struct netxen_minidump *mdump = &adapter->mdump;
840
841 switch (val->flag) {
842 case NX_FORCE_FW_DUMP_KEY:
843 if (!mdump->md_enabled)
844 mdump->md_enabled = 1;
845 if (adapter->fw_mdump_rdy) {
846 netdev_info(netdev, "Previous dump not cleared, not forcing dump\n");
847 return ret;
848 }
849 netdev_info(netdev, "Forcing a fw dump\n");
850 nx_dev_request_reset(adapter);
851 break;
852 case NX_DISABLE_FW_DUMP:
853 if (mdump->md_enabled) {
854 netdev_info(netdev, "Disabling FW Dump\n");
855 mdump->md_enabled = 0;
856 }
857 break;
858 case NX_ENABLE_FW_DUMP:
859 if (!mdump->md_enabled) {
860 netdev_info(netdev, "Enabling FW dump\n");
861 mdump->md_enabled = 1;
862 }
863 break;
864 case NX_FORCE_FW_RESET:
865 netdev_info(netdev, "Forcing FW reset\n");
866 nx_dev_request_reset(adapter);
867 adapter->flags &= ~NETXEN_FW_RESET_OWNER;
868 break;
869 default:
870 if (val->flag <= NX_DUMP_MASK_MAX &&
871 val->flag >= NX_DUMP_MASK_MIN) {
872 mdump->md_capture_mask = val->flag & 0xff;
873 netdev_info(netdev, "Driver mask changed to: 0x%x\n",
874 mdump->md_capture_mask);
875 break;
876 }
877 netdev_info(netdev,
878 "Invalid dump level: 0x%x\n", val->flag);
879 return -EINVAL;
880 }
881
882 return ret;
883}
884
885static int
886netxen_get_dump_data(struct net_device *netdev, struct ethtool_dump *dump,
887 void *buffer)
888{
889 int i, copy_sz;
890 u32 *hdr_ptr, *data;
891 struct netxen_adapter *adapter = netdev_priv(netdev);
892 struct netxen_minidump *mdump = &adapter->mdump;
893
894
895 if (!adapter->fw_mdump_rdy) {
896 netdev_info(netdev, "Dump not available\n");
897 return -EINVAL;
898 }
899 /* Copy template header first */
900 copy_sz = mdump->md_template_size;
901 hdr_ptr = (u32 *) mdump->md_template;
902 data = buffer;
903 for (i = 0; i < copy_sz/sizeof(u32); i++)
904 *data++ = cpu_to_le32(*hdr_ptr++);
905
906 /* Copy captured dump data */
907 memcpy(buffer + copy_sz,
908 mdump->md_capture_buff + mdump->md_template_size,
909 mdump->md_capture_size);
910 dump->len = copy_sz + mdump->md_capture_size;
911 dump->flag = mdump->md_capture_mask;
912
913 /* Free dump area once data has been captured */
914 vfree(mdump->md_capture_buff);
915 mdump->md_capture_buff = NULL;
916 adapter->fw_mdump_rdy = 0;
917 netdev_info(netdev, "extracted the fw dump Successfully\n");
918 return 0;
919}
920
815const struct ethtool_ops netxen_nic_ethtool_ops = { 921const struct ethtool_ops netxen_nic_ethtool_ops = {
816 .get_settings = netxen_nic_get_settings, 922 .get_settings = netxen_nic_get_settings,
817 .set_settings = netxen_nic_set_settings, 923 .set_settings = netxen_nic_set_settings,
@@ -833,4 +939,7 @@ const struct ethtool_ops netxen_nic_ethtool_ops = {
833 .get_sset_count = netxen_get_sset_count, 939 .get_sset_count = netxen_get_sset_count,
834 .get_coalesce = netxen_get_intr_coalesce, 940 .get_coalesce = netxen_get_intr_coalesce,
835 .set_coalesce = netxen_set_intr_coalesce, 941 .set_coalesce = netxen_set_intr_coalesce,
942 .get_dump_flag = netxen_get_dump_flag,
943 .get_dump_data = netxen_get_dump_data,
944 .set_dump = netxen_set_dump,
836}; 945};
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h
index dc1967c1f312..b1a897cd9a8d 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h
@@ -969,6 +969,7 @@ enum {
969#define NX_RCODE_FATAL_ERROR 0x80000000 969#define NX_RCODE_FATAL_ERROR 0x80000000
970#define NX_FWERROR_PEGNUM(code) ((code) & 0xff) 970#define NX_FWERROR_PEGNUM(code) ((code) & 0xff)
971#define NX_FWERROR_CODE(code) ((code >> 8) & 0xfffff) 971#define NX_FWERROR_CODE(code) ((code >> 8) & 0xfffff)
972#define NX_FWERROR_PEGSTAT1(code) ((code >> 8) & 0x1fffff)
972 973
973#define FW_POLL_DELAY (2 * HZ) 974#define FW_POLL_DELAY (2 * HZ)
974#define FW_FAIL_THRESH 3 975#define FW_FAIL_THRESH 3
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
index 3f89e57cae50..6f37470750f3 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
@@ -46,7 +46,6 @@ static void netxen_nic_io_write_128M(struct netxen_adapter *adapter,
46 void __iomem *addr, u32 data); 46 void __iomem *addr, u32 data);
47static u32 netxen_nic_io_read_128M(struct netxen_adapter *adapter, 47static u32 netxen_nic_io_read_128M(struct netxen_adapter *adapter,
48 void __iomem *addr); 48 void __iomem *addr);
49
50#ifndef readq 49#ifndef readq
51static inline u64 readq(void __iomem *addr) 50static inline u64 readq(void __iomem *addr)
52{ 51{
@@ -1974,3 +1973,631 @@ netxen_nic_wol_supported(struct netxen_adapter *adapter)
1974 1973
1975 return 0; 1974 return 0;
1976} 1975}
1976
1977static u32 netxen_md_cntrl(struct netxen_adapter *adapter,
1978 struct netxen_minidump_template_hdr *template_hdr,
1979 struct netxen_minidump_entry_crb *crtEntry)
1980{
1981 int loop_cnt, i, rv = 0, timeout_flag;
1982 u32 op_count, stride;
1983 u32 opcode, read_value, addr;
1984 unsigned long timeout, timeout_jiffies;
1985 addr = crtEntry->addr;
1986 op_count = crtEntry->op_count;
1987 stride = crtEntry->addr_stride;
1988
1989 for (loop_cnt = 0; loop_cnt < op_count; loop_cnt++) {
1990 for (i = 0; i < sizeof(crtEntry->opcode) * 8; i++) {
1991 opcode = (crtEntry->opcode & (0x1 << i));
1992 if (opcode) {
1993 switch (opcode) {
1994 case NX_DUMP_WCRB:
1995 NX_WR_DUMP_REG(addr,
1996 adapter->ahw.pci_base0,
1997 crtEntry->value_1);
1998 break;
1999 case NX_DUMP_RWCRB:
2000 NX_RD_DUMP_REG(addr,
2001 adapter->ahw.pci_base0,
2002 &read_value);
2003 NX_WR_DUMP_REG(addr,
2004 adapter->ahw.pci_base0,
2005 read_value);
2006 break;
2007 case NX_DUMP_ANDCRB:
2008 NX_RD_DUMP_REG(addr,
2009 adapter->ahw.pci_base0,
2010 &read_value);
2011 read_value &= crtEntry->value_2;
2012 NX_WR_DUMP_REG(addr,
2013 adapter->ahw.pci_base0,
2014 read_value);
2015 break;
2016 case NX_DUMP_ORCRB:
2017 NX_RD_DUMP_REG(addr,
2018 adapter->ahw.pci_base0,
2019 &read_value);
2020 read_value |= crtEntry->value_3;
2021 NX_WR_DUMP_REG(addr,
2022 adapter->ahw.pci_base0,
2023 read_value);
2024 break;
2025 case NX_DUMP_POLLCRB:
2026 timeout = crtEntry->poll_timeout;
2027 NX_RD_DUMP_REG(addr,
2028 adapter->ahw.pci_base0,
2029 &read_value);
2030 timeout_jiffies =
2031 msecs_to_jiffies(timeout) + jiffies;
2032 for (timeout_flag = 0;
2033 !timeout_flag
2034 && ((read_value & crtEntry->value_2)
2035 != crtEntry->value_1);) {
2036 if (time_after(jiffies,
2037 timeout_jiffies))
2038 timeout_flag = 1;
2039 NX_RD_DUMP_REG(addr,
2040 adapter->ahw.pci_base0,
2041 &read_value);
2042 }
2043
2044 if (timeout_flag) {
2045 dev_err(&adapter->pdev->dev, "%s : "
2046 "Timeout in poll_crb control operation.\n"
2047 , __func__);
2048 return -1;
2049 }
2050 break;
2051 case NX_DUMP_RD_SAVE:
2052 /* Decide which address to use */
2053 if (crtEntry->state_index_a)
2054 addr =
2055 template_hdr->saved_state_array
2056 [crtEntry->state_index_a];
2057 NX_RD_DUMP_REG(addr,
2058 adapter->ahw.pci_base0,
2059 &read_value);
2060 template_hdr->saved_state_array
2061 [crtEntry->state_index_v]
2062 = read_value;
2063 break;
2064 case NX_DUMP_WRT_SAVED:
2065 /* Decide which value to use */
2066 if (crtEntry->state_index_v)
2067 read_value =
2068 template_hdr->saved_state_array
2069 [crtEntry->state_index_v];
2070 else
2071 read_value = crtEntry->value_1;
2072
2073 /* Decide which address to use */
2074 if (crtEntry->state_index_a)
2075 addr =
2076 template_hdr->saved_state_array
2077 [crtEntry->state_index_a];
2078
2079 NX_WR_DUMP_REG(addr,
2080 adapter->ahw.pci_base0,
2081 read_value);
2082 break;
2083 case NX_DUMP_MOD_SAVE_ST:
2084 read_value =
2085 template_hdr->saved_state_array
2086 [crtEntry->state_index_v];
2087 read_value <<= crtEntry->shl;
2088 read_value >>= crtEntry->shr;
2089 if (crtEntry->value_2)
2090 read_value &=
2091 crtEntry->value_2;
2092 read_value |= crtEntry->value_3;
2093 read_value += crtEntry->value_1;
2094 /* Write value back to state area.*/
2095 template_hdr->saved_state_array
2096 [crtEntry->state_index_v]
2097 = read_value;
2098 break;
2099 default:
2100 rv = 1;
2101 break;
2102 }
2103 }
2104 }
2105 addr = addr + stride;
2106 }
2107 return rv;
2108}
2109
2110/* Read memory or MN */
2111static u32
2112netxen_md_rdmem(struct netxen_adapter *adapter,
2113 struct netxen_minidump_entry_rdmem
2114 *memEntry, u64 *data_buff)
2115{
2116 u64 addr, value = 0;
2117 int i = 0, loop_cnt;
2118
2119 addr = (u64)memEntry->read_addr;
2120 loop_cnt = memEntry->read_data_size; /* This is size in bytes */
2121 loop_cnt /= sizeof(value);
2122
2123 for (i = 0; i < loop_cnt; i++) {
2124 if (netxen_nic_pci_mem_read_2M(adapter, addr, &value))
2125 goto out;
2126 *data_buff++ = value;
2127 addr += sizeof(value);
2128 }
2129out:
2130 return i * sizeof(value);
2131}
2132
2133/* Read CRB operation */
2134static u32 netxen_md_rd_crb(struct netxen_adapter *adapter,
2135 struct netxen_minidump_entry_crb
2136 *crbEntry, u32 *data_buff)
2137{
2138 int loop_cnt;
2139 u32 op_count, addr, stride, value;
2140
2141 addr = crbEntry->addr;
2142 op_count = crbEntry->op_count;
2143 stride = crbEntry->addr_stride;
2144
2145 for (loop_cnt = 0; loop_cnt < op_count; loop_cnt++) {
2146 NX_RD_DUMP_REG(addr, adapter->ahw.pci_base0, &value);
2147 *data_buff++ = addr;
2148 *data_buff++ = value;
2149 addr = addr + stride;
2150 }
2151 return loop_cnt * (2 * sizeof(u32));
2152}
2153
2154/* Read ROM */
2155static u32
2156netxen_md_rdrom(struct netxen_adapter *adapter,
2157 struct netxen_minidump_entry_rdrom
2158 *romEntry, u32 *data_buff)
2159{
2160 int i, count = 0;
2161 u32 size, lck_val;
2162 u32 val;
2163 u32 fl_addr, waddr, raddr;
2164 fl_addr = romEntry->read_addr;
2165 size = romEntry->read_data_size/4;
2166lock_try:
2167 lck_val = readl((void __iomem *)(adapter->ahw.pci_base0 +
2168 NX_FLASH_SEM2_LK));
2169 if (!lck_val && count < MAX_CTL_CHECK) {
2170 msleep(20);
2171 count++;
2172 goto lock_try;
2173 }
2174 writel(adapter->ahw.pci_func, (void __iomem *)(adapter->ahw.pci_base0 +
2175 NX_FLASH_LOCK_ID));
2176 for (i = 0; i < size; i++) {
2177 waddr = fl_addr & 0xFFFF0000;
2178 NX_WR_DUMP_REG(FLASH_ROM_WINDOW, adapter->ahw.pci_base0, waddr);
2179 raddr = FLASH_ROM_DATA + (fl_addr & 0x0000FFFF);
2180 NX_RD_DUMP_REG(raddr, adapter->ahw.pci_base0, &val);
2181 *data_buff++ = cpu_to_le32(val);
2182 fl_addr += sizeof(val);
2183 }
2184 readl((void __iomem *)(adapter->ahw.pci_base0 + NX_FLASH_SEM2_ULK));
2185 return romEntry->read_data_size;
2186}
2187
2188/* Handle L2 Cache */
2189static u32
2190netxen_md_L2Cache(struct netxen_adapter *adapter,
2191 struct netxen_minidump_entry_cache
2192 *cacheEntry, u32 *data_buff)
2193{
2194 int loop_cnt, i, k, timeout_flag = 0;
2195 u32 addr, read_addr, read_value, cntrl_addr, tag_reg_addr;
2196 u32 tag_value, read_cnt;
2197 u8 cntl_value_w, cntl_value_r;
2198 unsigned long timeout, timeout_jiffies;
2199
2200 loop_cnt = cacheEntry->op_count;
2201 read_addr = cacheEntry->read_addr;
2202 cntrl_addr = cacheEntry->control_addr;
2203 cntl_value_w = (u32) cacheEntry->write_value;
2204 tag_reg_addr = cacheEntry->tag_reg_addr;
2205 tag_value = cacheEntry->init_tag_value;
2206 read_cnt = cacheEntry->read_addr_cnt;
2207
2208 for (i = 0; i < loop_cnt; i++) {
2209 NX_WR_DUMP_REG(tag_reg_addr, adapter->ahw.pci_base0, tag_value);
2210 if (cntl_value_w)
2211 NX_WR_DUMP_REG(cntrl_addr, adapter->ahw.pci_base0,
2212 (u32)cntl_value_w);
2213 if (cacheEntry->poll_mask) {
2214 timeout = cacheEntry->poll_wait;
2215 NX_RD_DUMP_REG(cntrl_addr, adapter->ahw.pci_base0,
2216 &cntl_value_r);
2217 timeout_jiffies = msecs_to_jiffies(timeout) + jiffies;
2218 for (timeout_flag = 0; !timeout_flag &&
2219 ((cntl_value_r & cacheEntry->poll_mask) != 0);) {
2220 if (time_after(jiffies, timeout_jiffies))
2221 timeout_flag = 1;
2222 NX_RD_DUMP_REG(cntrl_addr,
2223 adapter->ahw.pci_base0,
2224 &cntl_value_r);
2225 }
2226 if (timeout_flag) {
2227 dev_err(&adapter->pdev->dev,
2228 "Timeout in processing L2 Tag poll.\n");
2229 return -1;
2230 }
2231 }
2232 addr = read_addr;
2233 for (k = 0; k < read_cnt; k++) {
2234 NX_RD_DUMP_REG(addr, adapter->ahw.pci_base0,
2235 &read_value);
2236 *data_buff++ = read_value;
2237 addr += cacheEntry->read_addr_stride;
2238 }
2239 tag_value += cacheEntry->tag_value_stride;
2240 }
2241 return read_cnt * loop_cnt * sizeof(read_value);
2242}
2243
2244
2245/* Handle L1 Cache */
2246static u32 netxen_md_L1Cache(struct netxen_adapter *adapter,
2247 struct netxen_minidump_entry_cache
2248 *cacheEntry, u32 *data_buff)
2249{
2250 int i, k, loop_cnt;
2251 u32 addr, read_addr, read_value, cntrl_addr, tag_reg_addr;
2252 u32 tag_value, read_cnt;
2253 u8 cntl_value_w;
2254
2255 loop_cnt = cacheEntry->op_count;
2256 read_addr = cacheEntry->read_addr;
2257 cntrl_addr = cacheEntry->control_addr;
2258 cntl_value_w = (u32) cacheEntry->write_value;
2259 tag_reg_addr = cacheEntry->tag_reg_addr;
2260 tag_value = cacheEntry->init_tag_value;
2261 read_cnt = cacheEntry->read_addr_cnt;
2262
2263 for (i = 0; i < loop_cnt; i++) {
2264 NX_WR_DUMP_REG(tag_reg_addr, adapter->ahw.pci_base0, tag_value);
2265 NX_WR_DUMP_REG(cntrl_addr, adapter->ahw.pci_base0,
2266 (u32) cntl_value_w);
2267 addr = read_addr;
2268 for (k = 0; k < read_cnt; k++) {
2269 NX_RD_DUMP_REG(addr,
2270 adapter->ahw.pci_base0,
2271 &read_value);
2272 *data_buff++ = read_value;
2273 addr += cacheEntry->read_addr_stride;
2274 }
2275 tag_value += cacheEntry->tag_value_stride;
2276 }
2277 return read_cnt * loop_cnt * sizeof(read_value);
2278}
2279
2280/* Reading OCM memory */
2281static u32
2282netxen_md_rdocm(struct netxen_adapter *adapter,
2283 struct netxen_minidump_entry_rdocm
2284 *ocmEntry, u32 *data_buff)
2285{
2286 int i, loop_cnt;
2287 u32 value;
2288 void __iomem *addr;
2289 addr = (ocmEntry->read_addr + adapter->ahw.pci_base0);
2290 loop_cnt = ocmEntry->op_count;
2291
2292 for (i = 0; i < loop_cnt; i++) {
2293 value = readl(addr);
2294 *data_buff++ = value;
2295 addr += ocmEntry->read_addr_stride;
2296 }
2297 return i * sizeof(u32);
2298}
2299
2300/* Read MUX data */
2301static u32
2302netxen_md_rdmux(struct netxen_adapter *adapter, struct netxen_minidump_entry_mux
2303 *muxEntry, u32 *data_buff)
2304{
2305 int loop_cnt = 0;
2306 u32 read_addr, read_value, select_addr, sel_value;
2307
2308 read_addr = muxEntry->read_addr;
2309 sel_value = muxEntry->select_value;
2310 select_addr = muxEntry->select_addr;
2311
2312 for (loop_cnt = 0; loop_cnt < muxEntry->op_count; loop_cnt++) {
2313 NX_WR_DUMP_REG(select_addr, adapter->ahw.pci_base0, sel_value);
2314 NX_RD_DUMP_REG(read_addr, adapter->ahw.pci_base0, &read_value);
2315 *data_buff++ = sel_value;
2316 *data_buff++ = read_value;
2317 sel_value += muxEntry->select_value_stride;
2318 }
2319 return loop_cnt * (2 * sizeof(u32));
2320}
2321
2322/* Handling Queue State Reads */
2323static u32
2324netxen_md_rdqueue(struct netxen_adapter *adapter,
2325 struct netxen_minidump_entry_queue
2326 *queueEntry, u32 *data_buff)
2327{
2328 int loop_cnt, k;
2329 u32 queue_id, read_addr, read_value, read_stride, select_addr, read_cnt;
2330
2331 read_cnt = queueEntry->read_addr_cnt;
2332 read_stride = queueEntry->read_addr_stride;
2333 select_addr = queueEntry->select_addr;
2334
2335 for (loop_cnt = 0, queue_id = 0; loop_cnt < queueEntry->op_count;
2336 loop_cnt++) {
2337 NX_WR_DUMP_REG(select_addr, adapter->ahw.pci_base0, queue_id);
2338 read_addr = queueEntry->read_addr;
2339 for (k = 0; k < read_cnt; k--) {
2340 NX_RD_DUMP_REG(read_addr, adapter->ahw.pci_base0,
2341 &read_value);
2342 *data_buff++ = read_value;
2343 read_addr += read_stride;
2344 }
2345 queue_id += queueEntry->queue_id_stride;
2346 }
2347 return loop_cnt * (read_cnt * sizeof(read_value));
2348}
2349
2350
2351/*
2352* We catch an error where driver does not read
2353* as much data as we expect from the entry.
2354*/
2355
2356static int netxen_md_entry_err_chk(struct netxen_adapter *adapter,
2357 struct netxen_minidump_entry *entry, int esize)
2358{
2359 if (esize < 0) {
2360 entry->hdr.driver_flags |= NX_DUMP_SKIP;
2361 return esize;
2362 }
2363 if (esize != entry->hdr.entry_capture_size) {
2364 entry->hdr.entry_capture_size = esize;
2365 entry->hdr.driver_flags |= NX_DUMP_SIZE_ERR;
2366 dev_info(&adapter->pdev->dev,
2367 "Invalidate dump, Type:%d\tMask:%d\tSize:%dCap_size:%d\n",
2368 entry->hdr.entry_type, entry->hdr.entry_capture_mask,
2369 esize, entry->hdr.entry_capture_size);
2370 dev_info(&adapter->pdev->dev, "Aborting further dump capture\n");
2371 }
2372 return 0;
2373}
2374
2375static int netxen_parse_md_template(struct netxen_adapter *adapter)
2376{
2377 int num_of_entries, buff_level, e_cnt, esize;
2378 int end_cnt = 0, rv = 0, sane_start = 0, sane_end = 0;
2379 char *dbuff;
2380 void *template_buff = adapter->mdump.md_template;
2381 char *dump_buff = adapter->mdump.md_capture_buff;
2382 int capture_mask = adapter->mdump.md_capture_mask;
2383 struct netxen_minidump_template_hdr *template_hdr;
2384 struct netxen_minidump_entry *entry;
2385
2386 if ((capture_mask & 0x3) != 0x3) {
2387 dev_err(&adapter->pdev->dev, "Capture mask %02x below minimum needed "
2388 "for valid firmware dump\n", capture_mask);
2389 return -EINVAL;
2390 }
2391 template_hdr = (struct netxen_minidump_template_hdr *) template_buff;
2392 num_of_entries = template_hdr->num_of_entries;
2393 entry = (struct netxen_minidump_entry *) ((char *) template_buff +
2394 template_hdr->first_entry_offset);
2395 memcpy(dump_buff, template_buff, adapter->mdump.md_template_size);
2396 dump_buff = dump_buff + adapter->mdump.md_template_size;
2397
2398 if (template_hdr->entry_type == TLHDR)
2399 sane_start = 1;
2400
2401 for (e_cnt = 0, buff_level = 0; e_cnt < num_of_entries; e_cnt++) {
2402 if (!(entry->hdr.entry_capture_mask & capture_mask)) {
2403 entry->hdr.driver_flags |= NX_DUMP_SKIP;
2404 entry = (struct netxen_minidump_entry *)
2405 ((char *) entry + entry->hdr.entry_size);
2406 continue;
2407 }
2408 switch (entry->hdr.entry_type) {
2409 case RDNOP:
2410 entry->hdr.driver_flags |= NX_DUMP_SKIP;
2411 break;
2412 case RDEND:
2413 entry->hdr.driver_flags |= NX_DUMP_SKIP;
2414 if (!sane_end)
2415 end_cnt = e_cnt;
2416 sane_end += 1;
2417 break;
2418 case CNTRL:
2419 rv = netxen_md_cntrl(adapter,
2420 template_hdr, (void *)entry);
2421 if (rv)
2422 entry->hdr.driver_flags |= NX_DUMP_SKIP;
2423 break;
2424 case RDCRB:
2425 dbuff = dump_buff + buff_level;
2426 esize = netxen_md_rd_crb(adapter,
2427 (void *) entry, (void *) dbuff);
2428 rv = netxen_md_entry_err_chk
2429 (adapter, entry, esize);
2430 if (rv < 0)
2431 break;
2432 buff_level += esize;
2433 break;
2434 case RDMN:
2435 case RDMEM:
2436 dbuff = dump_buff + buff_level;
2437 esize = netxen_md_rdmem(adapter,
2438 (void *) entry, (void *) dbuff);
2439 rv = netxen_md_entry_err_chk
2440 (adapter, entry, esize);
2441 if (rv < 0)
2442 break;
2443 buff_level += esize;
2444 break;
2445 case BOARD:
2446 case RDROM:
2447 dbuff = dump_buff + buff_level;
2448 esize = netxen_md_rdrom(adapter,
2449 (void *) entry, (void *) dbuff);
2450 rv = netxen_md_entry_err_chk
2451 (adapter, entry, esize);
2452 if (rv < 0)
2453 break;
2454 buff_level += esize;
2455 break;
2456 case L2ITG:
2457 case L2DTG:
2458 case L2DAT:
2459 case L2INS:
2460 dbuff = dump_buff + buff_level;
2461 esize = netxen_md_L2Cache(adapter,
2462 (void *) entry, (void *) dbuff);
2463 rv = netxen_md_entry_err_chk
2464 (adapter, entry, esize);
2465 if (rv < 0)
2466 break;
2467 buff_level += esize;
2468 break;
2469 case L1DAT:
2470 case L1INS:
2471 dbuff = dump_buff + buff_level;
2472 esize = netxen_md_L1Cache(adapter,
2473 (void *) entry, (void *) dbuff);
2474 rv = netxen_md_entry_err_chk
2475 (adapter, entry, esize);
2476 if (rv < 0)
2477 break;
2478 buff_level += esize;
2479 break;
2480 case RDOCM:
2481 dbuff = dump_buff + buff_level;
2482 esize = netxen_md_rdocm(adapter,
2483 (void *) entry, (void *) dbuff);
2484 rv = netxen_md_entry_err_chk
2485 (adapter, entry, esize);
2486 if (rv < 0)
2487 break;
2488 buff_level += esize;
2489 break;
2490 case RDMUX:
2491 dbuff = dump_buff + buff_level;
2492 esize = netxen_md_rdmux(adapter,
2493 (void *) entry, (void *) dbuff);
2494 rv = netxen_md_entry_err_chk
2495 (adapter, entry, esize);
2496 if (rv < 0)
2497 break;
2498 buff_level += esize;
2499 break;
2500 case QUEUE:
2501 dbuff = dump_buff + buff_level;
2502 esize = netxen_md_rdqueue(adapter,
2503 (void *) entry, (void *) dbuff);
2504 rv = netxen_md_entry_err_chk
2505 (adapter, entry, esize);
2506 if (rv < 0)
2507 break;
2508 buff_level += esize;
2509 break;
2510 default:
2511 entry->hdr.driver_flags |= NX_DUMP_SKIP;
2512 break;
2513 }
2514 /* Next entry in the template */
2515 entry = (struct netxen_minidump_entry *)
2516 ((char *) entry + entry->hdr.entry_size);
2517 }
2518 if (!sane_start || sane_end > 1) {
2519 dev_err(&adapter->pdev->dev,
2520 "Firmware minidump template configuration error.\n");
2521 }
2522 return 0;
2523}
2524
2525static int
2526netxen_collect_minidump(struct netxen_adapter *adapter)
2527{
2528 int ret = 0;
2529 struct netxen_minidump_template_hdr *hdr;
2530 struct timespec val;
2531 hdr = (struct netxen_minidump_template_hdr *)
2532 adapter->mdump.md_template;
2533 hdr->driver_capture_mask = adapter->mdump.md_capture_mask;
2534 jiffies_to_timespec(jiffies, &val);
2535 hdr->driver_timestamp = (u32) val.tv_sec;
2536 hdr->driver_info_word2 = adapter->fw_version;
2537 hdr->driver_info_word3 = NXRD32(adapter, CRB_DRIVER_VERSION);
2538 ret = netxen_parse_md_template(adapter);
2539 if (ret)
2540 return ret;
2541
2542 return ret;
2543}
2544
2545
2546void
2547netxen_dump_fw(struct netxen_adapter *adapter)
2548{
2549 struct netxen_minidump_template_hdr *hdr;
2550 int i, k, data_size = 0;
2551 u32 capture_mask;
2552 hdr = (struct netxen_minidump_template_hdr *)
2553 adapter->mdump.md_template;
2554 capture_mask = adapter->mdump.md_capture_mask;
2555
2556 for (i = 0x2, k = 1; (i & NX_DUMP_MASK_MAX); i <<= 1, k++) {
2557 if (i & capture_mask)
2558 data_size += hdr->capture_size_array[k];
2559 }
2560 if (!data_size) {
2561 dev_err(&adapter->pdev->dev,
2562 "Invalid cap sizes for capture_mask=0x%x\n",
2563 adapter->mdump.md_capture_mask);
2564 return;
2565 }
2566 adapter->mdump.md_capture_size = data_size;
2567 adapter->mdump.md_dump_size = adapter->mdump.md_template_size +
2568 adapter->mdump.md_capture_size;
2569 if (!adapter->mdump.md_capture_buff) {
2570 adapter->mdump.md_capture_buff =
2571 vmalloc(adapter->mdump.md_dump_size);
2572 if (!adapter->mdump.md_capture_buff) {
2573 dev_info(&adapter->pdev->dev,
2574 "Unable to allocate memory for minidump "
2575 "capture_buffer(%d bytes).\n",
2576 adapter->mdump.md_dump_size);
2577 return;
2578 }
2579 memset(adapter->mdump.md_capture_buff, 0,
2580 adapter->mdump.md_dump_size);
2581 if (netxen_collect_minidump(adapter)) {
2582 adapter->mdump.has_valid_dump = 0;
2583 adapter->mdump.md_dump_size = 0;
2584 vfree(adapter->mdump.md_capture_buff);
2585 adapter->mdump.md_capture_buff = NULL;
2586 dev_err(&adapter->pdev->dev,
2587 "Error in collecting firmware minidump.\n");
2588 } else {
2589 adapter->mdump.md_timestamp = jiffies;
2590 adapter->mdump.has_valid_dump = 1;
2591 adapter->fw_mdump_rdy = 1;
2592 dev_info(&adapter->pdev->dev, "%s Successfully "
2593 "collected fw dump.\n", adapter->netdev->name);
2594 }
2595
2596 } else {
2597 dev_info(&adapter->pdev->dev,
2598 "Cannot overwrite previously collected "
2599 "firmware minidump.\n");
2600 adapter->fw_mdump_rdy = 1;
2601 return;
2602 }
2603}
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
index a8259cc19a63..718b27440351 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
@@ -280,13 +280,10 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
280 280
281 } 281 }
282 rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring)); 282 rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring));
283 if (rds_ring->rx_buf_arr == NULL) { 283 if (rds_ring->rx_buf_arr == NULL)
284 printk(KERN_ERR "%s: Failed to allocate "
285 "rx buffer ring %d\n",
286 netdev->name, ring);
287 /* free whatever was already allocated */ 284 /* free whatever was already allocated */
288 goto err_out; 285 goto err_out;
289 } 286
290 INIT_LIST_HEAD(&rds_ring->free_list); 287 INIT_LIST_HEAD(&rds_ring->free_list);
291 /* 288 /*
292 * Now go through all of them, set reference handles 289 * Now go through all of them, set reference handles
@@ -449,7 +446,7 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter)
449 446
450 /* resetall */ 447 /* resetall */
451 netxen_rom_lock(adapter); 448 netxen_rom_lock(adapter);
452 NXWR32(adapter, NETXEN_ROMUSB_GLB_SW_RESET, 0xffffffff); 449 NXWR32(adapter, NETXEN_ROMUSB_GLB_SW_RESET, 0xfeffffff);
453 netxen_rom_unlock(adapter); 450 netxen_rom_unlock(adapter);
454 451
455 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { 452 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
@@ -480,11 +477,8 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter)
480 } 477 }
481 478
482 buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL); 479 buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
483 if (buf == NULL) { 480 if (buf == NULL)
484 printk("%s: netxen_pinit_from_rom: Unable to calloc memory.\n",
485 netxen_nic_driver_name);
486 return -ENOMEM; 481 return -ENOMEM;
487 }
488 482
489 for (i = 0; i < n; i++) { 483 for (i = 0; i < n; i++) {
490 if (netxen_rom_fast_read(adapter, 8*i + 4*offset, &val) != 0 || 484 if (netxen_rom_fast_read(adapter, 8*i + 4*offset, &val) != 0 ||
@@ -1353,7 +1347,6 @@ int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
1353 1347
1354 do { 1348 do {
1355 val = NXRD32(adapter, CRB_CMDPEG_STATE); 1349 val = NXRD32(adapter, CRB_CMDPEG_STATE);
1356
1357 switch (val) { 1350 switch (val) {
1358 case PHAN_INITIALIZE_COMPLETE: 1351 case PHAN_INITIALIZE_COMPLETE:
1359 case PHAN_INITIALIZE_ACK: 1352 case PHAN_INITIALIZE_ACK:
@@ -1494,7 +1487,7 @@ netxen_alloc_rx_skb(struct netxen_adapter *adapter,
1494 dma_addr_t dma; 1487 dma_addr_t dma;
1495 struct pci_dev *pdev = adapter->pdev; 1488 struct pci_dev *pdev = adapter->pdev;
1496 1489
1497 buffer->skb = dev_alloc_skb(rds_ring->skb_size); 1490 buffer->skb = netdev_alloc_skb(adapter->netdev, rds_ring->skb_size);
1498 if (!buffer->skb) 1491 if (!buffer->skb)
1499 return 1; 1492 return 1;
1500 1493
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
index 7dd9a4b107e6..8dc4a134dece 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
@@ -82,7 +82,6 @@ static void netxen_create_sysfs_entries(struct netxen_adapter *adapter);
82static void netxen_remove_sysfs_entries(struct netxen_adapter *adapter); 82static void netxen_remove_sysfs_entries(struct netxen_adapter *adapter);
83static void netxen_create_diag_entries(struct netxen_adapter *adapter); 83static void netxen_create_diag_entries(struct netxen_adapter *adapter);
84static void netxen_remove_diag_entries(struct netxen_adapter *adapter); 84static void netxen_remove_diag_entries(struct netxen_adapter *adapter);
85
86static int nx_dev_request_aer(struct netxen_adapter *adapter); 85static int nx_dev_request_aer(struct netxen_adapter *adapter);
87static int nx_decr_dev_ref_cnt(struct netxen_adapter *adapter); 86static int nx_decr_dev_ref_cnt(struct netxen_adapter *adapter);
88static int netxen_can_start_firmware(struct netxen_adapter *adapter); 87static int netxen_can_start_firmware(struct netxen_adapter *adapter);
@@ -802,10 +801,10 @@ err_out:
802static void 801static void
803netxen_check_options(struct netxen_adapter *adapter) 802netxen_check_options(struct netxen_adapter *adapter)
804{ 803{
805 u32 fw_major, fw_minor, fw_build; 804 u32 fw_major, fw_minor, fw_build, prev_fw_version;
806 char brd_name[NETXEN_MAX_SHORT_NAME]; 805 char brd_name[NETXEN_MAX_SHORT_NAME];
807 char serial_num[32]; 806 char serial_num[32];
808 int i, offset, val; 807 int i, offset, val, err;
809 int *ptr32; 808 int *ptr32;
810 struct pci_dev *pdev = adapter->pdev; 809 struct pci_dev *pdev = adapter->pdev;
811 810
@@ -826,9 +825,22 @@ netxen_check_options(struct netxen_adapter *adapter)
826 fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR); 825 fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR);
827 fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR); 826 fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR);
828 fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB); 827 fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB);
829 828 prev_fw_version = adapter->fw_version;
830 adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build); 829 adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build);
831 830
831 /* Get FW Mini Coredump template and store it */
832 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
833 if (adapter->mdump.md_template == NULL ||
834 adapter->fw_version > prev_fw_version) {
835 kfree(adapter->mdump.md_template);
836 adapter->mdump.md_template = NULL;
837 err = netxen_setup_minidump(adapter);
838 if (err)
839 dev_err(&adapter->pdev->dev,
840 "Failed to setup minidump rcode = %d\n", err);
841 }
842 }
843
832 if (adapter->portnum == 0) { 844 if (adapter->portnum == 0) {
833 get_brd_name_by_type(adapter->ahw.board_type, brd_name); 845 get_brd_name_by_type(adapter->ahw.board_type, brd_name);
834 846
@@ -909,7 +921,12 @@ netxen_start_firmware(struct netxen_adapter *adapter)
909 if (err) 921 if (err)
910 return err; 922 return err;
911 923
912 if (!netxen_can_start_firmware(adapter)) 924 err = netxen_can_start_firmware(adapter);
925
926 if (err < 0)
927 return err;
928
929 if (!err)
913 goto wait_init; 930 goto wait_init;
914 931
915 first_boot = NXRD32(adapter, NETXEN_CAM_RAM(0x1fc)); 932 first_boot = NXRD32(adapter, NETXEN_CAM_RAM(0x1fc));
@@ -1403,7 +1420,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1403 1420
1404 netdev = alloc_etherdev(sizeof(struct netxen_adapter)); 1421 netdev = alloc_etherdev(sizeof(struct netxen_adapter));
1405 if(!netdev) { 1422 if(!netdev) {
1406 dev_err(&pdev->dev, "failed to allocate net_device\n");
1407 err = -ENOMEM; 1423 err = -ENOMEM;
1408 goto err_out_free_res; 1424 goto err_out_free_res;
1409 } 1425 }
@@ -1529,6 +1545,18 @@ err_out_disable_pdev:
1529 return err; 1545 return err;
1530} 1546}
1531 1547
1548static
1549void netxen_cleanup_minidump(struct netxen_adapter *adapter)
1550{
1551 kfree(adapter->mdump.md_template);
1552 adapter->mdump.md_template = NULL;
1553
1554 if (adapter->mdump.md_capture_buff) {
1555 vfree(adapter->mdump.md_capture_buff);
1556 adapter->mdump.md_capture_buff = NULL;
1557 }
1558}
1559
1532static void __devexit netxen_nic_remove(struct pci_dev *pdev) 1560static void __devexit netxen_nic_remove(struct pci_dev *pdev)
1533{ 1561{
1534 struct netxen_adapter *adapter; 1562 struct netxen_adapter *adapter;
@@ -1564,8 +1592,10 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
1564 1592
1565 netxen_release_firmware(adapter); 1593 netxen_release_firmware(adapter);
1566 1594
1567 if (NX_IS_REVISION_P3(pdev->revision)) 1595 if (NX_IS_REVISION_P3(pdev->revision)) {
1596 netxen_cleanup_minidump(adapter);
1568 pci_disable_pcie_error_reporting(pdev); 1597 pci_disable_pcie_error_reporting(pdev);
1598 }
1569 1599
1570 pci_release_regions(pdev); 1600 pci_release_regions(pdev);
1571 pci_disable_device(pdev); 1601 pci_disable_device(pdev);
@@ -2317,7 +2347,7 @@ nx_incr_dev_ref_cnt(struct netxen_adapter *adapter)
2317static int 2347static int
2318nx_decr_dev_ref_cnt(struct netxen_adapter *adapter) 2348nx_decr_dev_ref_cnt(struct netxen_adapter *adapter)
2319{ 2349{
2320 int count; 2350 int count, state;
2321 if (netxen_api_lock(adapter)) 2351 if (netxen_api_lock(adapter))
2322 return -EIO; 2352 return -EIO;
2323 2353
@@ -2325,8 +2355,9 @@ nx_decr_dev_ref_cnt(struct netxen_adapter *adapter)
2325 WARN_ON(count == 0); 2355 WARN_ON(count == 0);
2326 2356
2327 NXWR32(adapter, NX_CRB_DEV_REF_COUNT, --count); 2357 NXWR32(adapter, NX_CRB_DEV_REF_COUNT, --count);
2358 state = NXRD32(adapter, NX_CRB_DEV_STATE);
2328 2359
2329 if (count == 0) 2360 if (count == 0 && state != NX_DEV_FAILED)
2330 NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_COLD); 2361 NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_COLD);
2331 2362
2332 netxen_api_unlock(adapter); 2363 netxen_api_unlock(adapter);
@@ -2355,7 +2386,7 @@ nx_dev_request_aer(struct netxen_adapter *adapter)
2355 return ret; 2386 return ret;
2356} 2387}
2357 2388
2358static int 2389int
2359nx_dev_request_reset(struct netxen_adapter *adapter) 2390nx_dev_request_reset(struct netxen_adapter *adapter)
2360{ 2391{
2361 u32 state; 2392 u32 state;
@@ -2366,10 +2397,11 @@ nx_dev_request_reset(struct netxen_adapter *adapter)
2366 2397
2367 state = NXRD32(adapter, NX_CRB_DEV_STATE); 2398 state = NXRD32(adapter, NX_CRB_DEV_STATE);
2368 2399
2369 if (state == NX_DEV_NEED_RESET) 2400 if (state == NX_DEV_NEED_RESET || state == NX_DEV_FAILED)
2370 ret = 0; 2401 ret = 0;
2371 else if (state != NX_DEV_INITALIZING && state != NX_DEV_NEED_AER) { 2402 else if (state != NX_DEV_INITALIZING && state != NX_DEV_NEED_AER) {
2372 NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_NEED_RESET); 2403 NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_NEED_RESET);
2404 adapter->flags |= NETXEN_FW_RESET_OWNER;
2373 ret = 0; 2405 ret = 0;
2374 } 2406 }
2375 2407
@@ -2384,8 +2416,10 @@ netxen_can_start_firmware(struct netxen_adapter *adapter)
2384 int count; 2416 int count;
2385 int can_start = 0; 2417 int can_start = 0;
2386 2418
2387 if (netxen_api_lock(adapter)) 2419 if (netxen_api_lock(adapter)) {
2388 return 0; 2420 nx_incr_dev_ref_cnt(adapter);
2421 return -1;
2422 }
2389 2423
2390 count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT); 2424 count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT);
2391 2425
@@ -2457,8 +2491,31 @@ netxen_fwinit_work(struct work_struct *work)
2457 struct netxen_adapter *adapter = container_of(work, 2491 struct netxen_adapter *adapter = container_of(work,
2458 struct netxen_adapter, fw_work.work); 2492 struct netxen_adapter, fw_work.work);
2459 int dev_state; 2493 int dev_state;
2460 2494 int count;
2461 dev_state = NXRD32(adapter, NX_CRB_DEV_STATE); 2495 dev_state = NXRD32(adapter, NX_CRB_DEV_STATE);
2496 if (adapter->flags & NETXEN_FW_RESET_OWNER) {
2497 count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT);
2498 WARN_ON(count == 0);
2499 if (count == 1) {
2500 if (adapter->mdump.md_enabled) {
2501 rtnl_lock();
2502 netxen_dump_fw(adapter);
2503 rtnl_unlock();
2504 }
2505 adapter->flags &= ~NETXEN_FW_RESET_OWNER;
2506 if (netxen_api_lock(adapter)) {
2507 clear_bit(__NX_RESETTING, &adapter->state);
2508 NXWR32(adapter, NX_CRB_DEV_STATE,
2509 NX_DEV_FAILED);
2510 return;
2511 }
2512 count = NXRD32(adapter, NX_CRB_DEV_REF_COUNT);
2513 NXWR32(adapter, NX_CRB_DEV_REF_COUNT, --count);
2514 NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_COLD);
2515 dev_state = NX_DEV_COLD;
2516 netxen_api_unlock(adapter);
2517 }
2518 }
2462 2519
2463 switch (dev_state) { 2520 switch (dev_state) {
2464 case NX_DEV_COLD: 2521 case NX_DEV_COLD:
@@ -2471,11 +2528,9 @@ netxen_fwinit_work(struct work_struct *work)
2471 2528
2472 case NX_DEV_NEED_RESET: 2529 case NX_DEV_NEED_RESET:
2473 case NX_DEV_INITALIZING: 2530 case NX_DEV_INITALIZING:
2474 if (++adapter->fw_wait_cnt < FW_POLL_THRESH) {
2475 netxen_schedule_work(adapter, 2531 netxen_schedule_work(adapter,
2476 netxen_fwinit_work, 2 * FW_POLL_DELAY); 2532 netxen_fwinit_work, 2 * FW_POLL_DELAY);
2477 return; 2533 return;
2478 }
2479 2534
2480 case NX_DEV_FAILED: 2535 case NX_DEV_FAILED:
2481 default: 2536 default:
@@ -2483,6 +2538,15 @@ netxen_fwinit_work(struct work_struct *work)
2483 break; 2538 break;
2484 } 2539 }
2485 2540
2541 if (netxen_api_lock(adapter)) {
2542 clear_bit(__NX_RESETTING, &adapter->state);
2543 return;
2544 }
2545 NXWR32(adapter, NX_CRB_DEV_STATE, NX_DEV_FAILED);
2546 netxen_api_unlock(adapter);
2547 dev_err(&adapter->pdev->dev, "%s: Device initialization Failed\n",
2548 adapter->netdev->name);
2549
2486 clear_bit(__NX_RESETTING, &adapter->state); 2550 clear_bit(__NX_RESETTING, &adapter->state);
2487} 2551}
2488 2552
@@ -2492,7 +2556,7 @@ netxen_detach_work(struct work_struct *work)
2492 struct netxen_adapter *adapter = container_of(work, 2556 struct netxen_adapter *adapter = container_of(work,
2493 struct netxen_adapter, fw_work.work); 2557 struct netxen_adapter, fw_work.work);
2494 struct net_device *netdev = adapter->netdev; 2558 struct net_device *netdev = adapter->netdev;
2495 int ref_cnt, delay; 2559 int ref_cnt = 0, delay;
2496 u32 status; 2560 u32 status;
2497 2561
2498 netif_device_detach(netdev); 2562 netif_device_detach(netdev);
@@ -2511,7 +2575,8 @@ netxen_detach_work(struct work_struct *work)
2511 if (adapter->temp == NX_TEMP_PANIC) 2575 if (adapter->temp == NX_TEMP_PANIC)
2512 goto err_ret; 2576 goto err_ret;
2513 2577
2514 ref_cnt = nx_decr_dev_ref_cnt(adapter); 2578 if (!(adapter->flags & NETXEN_FW_RESET_OWNER))
2579 ref_cnt = nx_decr_dev_ref_cnt(adapter);
2515 2580
2516 if (ref_cnt == -EIO) 2581 if (ref_cnt == -EIO)
2517 goto err_ret; 2582 goto err_ret;
@@ -2531,6 +2596,7 @@ static int
2531netxen_check_health(struct netxen_adapter *adapter) 2596netxen_check_health(struct netxen_adapter *adapter)
2532{ 2597{
2533 u32 state, heartbit; 2598 u32 state, heartbit;
2599 u32 peg_status;
2534 struct net_device *netdev = adapter->netdev; 2600 struct net_device *netdev = adapter->netdev;
2535 2601
2536 state = NXRD32(adapter, NX_CRB_DEV_STATE); 2602 state = NXRD32(adapter, NX_CRB_DEV_STATE);
@@ -2551,7 +2617,7 @@ netxen_check_health(struct netxen_adapter *adapter)
2551 * Send request to destroy context in case of tx timeout only 2617 * Send request to destroy context in case of tx timeout only
2552 * and doesn't required in case of Fw hang 2618 * and doesn't required in case of Fw hang
2553 */ 2619 */
2554 if (state == NX_DEV_NEED_RESET) { 2620 if (state == NX_DEV_NEED_RESET || state == NX_DEV_FAILED) {
2555 adapter->need_fw_reset = 1; 2621 adapter->need_fw_reset = 1;
2556 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) 2622 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
2557 goto detach; 2623 goto detach;
@@ -2577,8 +2643,24 @@ netxen_check_health(struct netxen_adapter *adapter)
2577 2643
2578 clear_bit(__NX_FW_ATTACHED, &adapter->state); 2644 clear_bit(__NX_FW_ATTACHED, &adapter->state);
2579 2645
2580 dev_info(&netdev->dev, "firmware hang detected\n"); 2646 dev_err(&netdev->dev, "firmware hang detected\n");
2581 2647 peg_status = NXRD32(adapter, NETXEN_PEG_HALT_STATUS1);
2648 dev_err(&adapter->pdev->dev, "Dumping hw/fw registers\n"
2649 "PEG_HALT_STATUS1: 0x%x, PEG_HALT_STATUS2: 0x%x,\n"
2650 "PEG_NET_0_PC: 0x%x, PEG_NET_1_PC: 0x%x,\n"
2651 "PEG_NET_2_PC: 0x%x, PEG_NET_3_PC: 0x%x,\n"
2652 "PEG_NET_4_PC: 0x%x\n",
2653 peg_status,
2654 NXRD32(adapter, NETXEN_PEG_HALT_STATUS2),
2655 NXRD32(adapter, NETXEN_CRB_PEG_NET_0 + 0x3c),
2656 NXRD32(adapter, NETXEN_CRB_PEG_NET_1 + 0x3c),
2657 NXRD32(adapter, NETXEN_CRB_PEG_NET_2 + 0x3c),
2658 NXRD32(adapter, NETXEN_CRB_PEG_NET_3 + 0x3c),
2659 NXRD32(adapter, NETXEN_CRB_PEG_NET_4 + 0x3c));
2660 if (NX_FWERROR_PEGSTAT1(peg_status) == 0x67)
2661 dev_err(&adapter->pdev->dev,
2662 "Firmware aborted with error code 0x00006700. "
2663 "Device is being reset.\n");
2582detach: 2664detach:
2583 if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) && 2665 if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) &&
2584 !test_and_set_bit(__NX_RESETTING, &adapter->state)) 2666 !test_and_set_bit(__NX_RESETTING, &adapter->state))
@@ -2848,13 +2930,12 @@ static struct bin_attribute bin_attr_mem = {
2848static void 2930static void
2849netxen_create_sysfs_entries(struct netxen_adapter *adapter) 2931netxen_create_sysfs_entries(struct netxen_adapter *adapter)
2850{ 2932{
2851 struct net_device *netdev = adapter->netdev; 2933 struct device *dev = &adapter->pdev->dev;
2852 struct device *dev = &netdev->dev;
2853 2934
2854 if (adapter->capabilities & NX_FW_CAPABILITY_BDG) { 2935 if (adapter->capabilities & NX_FW_CAPABILITY_BDG) {
2855 /* bridged_mode control */ 2936 /* bridged_mode control */
2856 if (device_create_file(dev, &dev_attr_bridged_mode)) { 2937 if (device_create_file(dev, &dev_attr_bridged_mode)) {
2857 dev_warn(&netdev->dev, 2938 dev_warn(dev,
2858 "failed to create bridged_mode sysfs entry\n"); 2939 "failed to create bridged_mode sysfs entry\n");
2859 } 2940 }
2860 } 2941 }
@@ -2863,8 +2944,7 @@ netxen_create_sysfs_entries(struct netxen_adapter *adapter)
2863static void 2944static void
2864netxen_remove_sysfs_entries(struct netxen_adapter *adapter) 2945netxen_remove_sysfs_entries(struct netxen_adapter *adapter)
2865{ 2946{
2866 struct net_device *netdev = adapter->netdev; 2947 struct device *dev = &adapter->pdev->dev;
2867 struct device *dev = &netdev->dev;
2868 2948
2869 if (adapter->capabilities & NX_FW_CAPABILITY_BDG) 2949 if (adapter->capabilities & NX_FW_CAPABILITY_BDG)
2870 device_remove_file(dev, &dev_attr_bridged_mode); 2950 device_remove_file(dev, &dev_attr_bridged_mode);
diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c
index 7931531c3a40..d49f6dac51fd 100644
--- a/drivers/net/ethernet/qlogic/qla3xxx.c
+++ b/drivers/net/ethernet/qlogic/qla3xxx.c
@@ -3805,7 +3805,6 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev,
3805 3805
3806 ndev = alloc_etherdev(sizeof(struct ql3_adapter)); 3806 ndev = alloc_etherdev(sizeof(struct ql3_adapter));
3807 if (!ndev) { 3807 if (!ndev) {
3808 pr_err("%s could not alloc etherdev\n", pci_name(pdev));
3809 err = -ENOMEM; 3808 err = -ENOMEM;
3810 goto err_out_free_regions; 3809 goto err_out_free_regions;
3811 } 3810 }
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
index 60976fc4ccc6..2b5af22419a5 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
@@ -37,7 +37,7 @@
37#define _QLCNIC_LINUX_MAJOR 5 37#define _QLCNIC_LINUX_MAJOR 5
38#define _QLCNIC_LINUX_MINOR 0 38#define _QLCNIC_LINUX_MINOR 0
39#define _QLCNIC_LINUX_SUBVERSION 25 39#define _QLCNIC_LINUX_SUBVERSION 25
40#define QLCNIC_LINUX_VERSIONID "5.0.25" 40#define QLCNIC_LINUX_VERSIONID "5.0.26"
41#define QLCNIC_DRV_IDC_VER 0x01 41#define QLCNIC_DRV_IDC_VER 0x01
42#define QLCNIC_DRIVER_VERSION ((_QLCNIC_LINUX_MAJOR << 16) |\ 42#define QLCNIC_DRIVER_VERSION ((_QLCNIC_LINUX_MAJOR << 16) |\
43 (_QLCNIC_LINUX_MINOR << 8) | (_QLCNIC_LINUX_SUBVERSION)) 43 (_QLCNIC_LINUX_MINOR << 8) | (_QLCNIC_LINUX_SUBVERSION))
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
index cc228cf3d84b..89ddf7f7d7df 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
@@ -155,7 +155,6 @@ qlcnic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
155{ 155{
156 struct qlcnic_adapter *adapter = netdev_priv(dev); 156 struct qlcnic_adapter *adapter = netdev_priv(dev);
157 int check_sfp_module = 0; 157 int check_sfp_module = 0;
158 u16 pcifn = adapter->ahw->pci_func;
159 158
160 /* read which mode */ 159 /* read which mode */
161 if (adapter->ahw->port_type == QLCNIC_GBE) { 160 if (adapter->ahw->port_type == QLCNIC_GBE) {
@@ -194,10 +193,8 @@ qlcnic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
194 goto skip; 193 goto skip;
195 } 194 }
196 195
197 val = QLCRD32(adapter, P3P_LINK_SPEED_REG(pcifn)); 196 ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN);
198 ethtool_cmd_speed_set(ecmd, P3P_LINK_SPEED_MHZ * 197 ecmd->duplex = DUPLEX_UNKNOWN;
199 P3P_LINK_SPEED_VAL(pcifn, val));
200 ecmd->duplex = DUPLEX_FULL;
201 ecmd->autoneg = AUTONEG_DISABLE; 198 ecmd->autoneg = AUTONEG_DISABLE;
202 } else 199 } else
203 return -EIO; 200 return -EIO;
@@ -722,7 +719,7 @@ static int qlcnic_do_lb_test(struct qlcnic_adapter *adapter, u8 mode)
722 int i, loop, cnt = 0; 719 int i, loop, cnt = 0;
723 720
724 for (i = 0; i < QLCNIC_NUM_ILB_PKT; i++) { 721 for (i = 0; i < QLCNIC_NUM_ILB_PKT; i++) {
725 skb = dev_alloc_skb(QLCNIC_ILB_PKT_SIZE); 722 skb = netdev_alloc_skb(adapter->netdev, QLCNIC_ILB_PKT_SIZE);
726 qlcnic_create_loopback_buff(skb->data, adapter->mac_addr); 723 qlcnic_create_loopback_buff(skb->data, adapter->mac_addr);
727 skb_put(skb, QLCNIC_ILB_PKT_SIZE); 724 skb_put(skb, QLCNIC_ILB_PKT_SIZE);
728 725
@@ -1155,7 +1152,6 @@ qlcnic_get_dump_data(struct net_device *netdev, struct ethtool_dump *dump,
1155 1152
1156 if (!fw_dump->clr) { 1153 if (!fw_dump->clr) {
1157 netdev_info(netdev, "Dump not available\n"); 1154 netdev_info(netdev, "Dump not available\n");
1158 qlcnic_api_unlock(adapter);
1159 return -EINVAL; 1155 return -EINVAL;
1160 } 1156 }
1161 /* Copy template header first */ 1157 /* Copy template header first */
@@ -1174,7 +1170,7 @@ qlcnic_get_dump_data(struct net_device *netdev, struct ethtool_dump *dump,
1174 vfree(fw_dump->data); 1170 vfree(fw_dump->data);
1175 fw_dump->data = NULL; 1171 fw_dump->data = NULL;
1176 fw_dump->clr = 0; 1172 fw_dump->clr = 0;
1177 1173 netdev_info(netdev, "extracted the FW dump Successfully\n");
1178 return 0; 1174 return 0;
1179} 1175}
1180 1176
@@ -1192,7 +1188,7 @@ qlcnic_set_dump(struct net_device *netdev, struct ethtool_dump *val)
1192 return ret; 1188 return ret;
1193 } 1189 }
1194 if (fw_dump->clr) { 1190 if (fw_dump->clr) {
1195 dev_info(&adapter->pdev->dev, 1191 netdev_info(netdev,
1196 "Previous dump not cleared, not forcing dump\n"); 1192 "Previous dump not cleared, not forcing dump\n");
1197 return ret; 1193 return ret;
1198 } 1194 }
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
index 38669583840c..d32cf0ddf1b9 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
@@ -1369,7 +1369,13 @@ qlcnic_handle_linkevent(struct qlcnic_adapter *adapter,
1369 1369
1370 adapter->module_type = module; 1370 adapter->module_type = module;
1371 adapter->link_autoneg = autoneg; 1371 adapter->link_autoneg = autoneg;
1372 adapter->link_speed = link_speed; 1372
1373 if (link_status) {
1374 adapter->link_speed = link_speed;
1375 } else {
1376 adapter->link_speed = SPEED_UNKNOWN;
1377 adapter->link_duplex = DUPLEX_UNKNOWN;
1378 }
1373} 1379}
1374 1380
1375static void 1381static void
@@ -1434,7 +1440,7 @@ qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter,
1434 dma_addr_t dma; 1440 dma_addr_t dma;
1435 struct pci_dev *pdev = adapter->pdev; 1441 struct pci_dev *pdev = adapter->pdev;
1436 1442
1437 skb = dev_alloc_skb(rds_ring->skb_size); 1443 skb = netdev_alloc_skb(adapter->netdev, rds_ring->skb_size);
1438 if (!skb) { 1444 if (!skb) {
1439 adapter->stats.skb_alloc_failure++; 1445 adapter->stats.skb_alloc_failure++;
1440 return -ENOMEM; 1446 return -ENOMEM;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 69b8e4ef14d9..dba95311a462 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -1576,7 +1576,6 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1576 1576
1577 netdev = alloc_etherdev(sizeof(struct qlcnic_adapter)); 1577 netdev = alloc_etherdev(sizeof(struct qlcnic_adapter));
1578 if (!netdev) { 1578 if (!netdev) {
1579 dev_err(&pdev->dev, "failed to allocate net_device\n");
1580 err = -ENOMEM; 1579 err = -ENOMEM;
1581 goto err_out_free_res; 1580 goto err_out_free_res;
1582 } 1581 }
@@ -3000,8 +2999,18 @@ qlcnic_set_npar_non_operational(struct qlcnic_adapter *adapter)
3000void 2999void
3001qlcnic_dev_request_reset(struct qlcnic_adapter *adapter) 3000qlcnic_dev_request_reset(struct qlcnic_adapter *adapter)
3002{ 3001{
3003 u32 state; 3002 u32 state, xg_val = 0, gb_val = 0;
3004 3003
3004 qlcnic_xg_set_xg0_mask(xg_val);
3005 qlcnic_xg_set_xg1_mask(xg_val);
3006 QLCWR32(adapter, QLCNIC_NIU_XG_PAUSE_CTL, xg_val);
3007 qlcnic_gb_set_gb0_mask(gb_val);
3008 qlcnic_gb_set_gb1_mask(gb_val);
3009 qlcnic_gb_set_gb2_mask(gb_val);
3010 qlcnic_gb_set_gb3_mask(gb_val);
3011 QLCWR32(adapter, QLCNIC_NIU_GB_PAUSE_CTL, gb_val);
3012 dev_info(&adapter->pdev->dev, "Pause control frames disabled"
3013 " on all ports\n");
3005 adapter->need_fw_reset = 1; 3014 adapter->need_fw_reset = 1;
3006 if (qlcnic_api_lock(adapter)) 3015 if (qlcnic_api_lock(adapter))
3007 return; 3016 return;
@@ -3150,7 +3159,7 @@ qlcnic_check_health(struct qlcnic_adapter *adapter)
3150 QLCRD32(adapter, QLCNIC_CRB_PEG_NET_3 + 0x3c), 3159 QLCRD32(adapter, QLCNIC_CRB_PEG_NET_3 + 0x3c),
3151 QLCRD32(adapter, QLCNIC_CRB_PEG_NET_4 + 0x3c)); 3160 QLCRD32(adapter, QLCNIC_CRB_PEG_NET_4 + 0x3c));
3152 peg_status = QLCRD32(adapter, QLCNIC_PEG_HALT_STATUS1); 3161 peg_status = QLCRD32(adapter, QLCNIC_PEG_HALT_STATUS1);
3153 if (LSW(MSB(peg_status)) == 0x67) 3162 if (QLCNIC_FWERROR_CODE(peg_status) == 0x67)
3154 dev_err(&adapter->pdev->dev, 3163 dev_err(&adapter->pdev->dev,
3155 "Firmware aborted with error code 0x00006700. " 3164 "Firmware aborted with error code 0x00006700. "
3156 "Device is being reset.\n"); 3165 "Device is being reset.\n");
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge.h b/drivers/net/ethernet/qlogic/qlge/qlge.h
index b8478aab050e..5a639df33f18 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge.h
+++ b/drivers/net/ethernet/qlogic/qlge/qlge.h
@@ -18,7 +18,7 @@
18 */ 18 */
19#define DRV_NAME "qlge" 19#define DRV_NAME "qlge"
20#define DRV_STRING "QLogic 10 Gigabit PCI-E Ethernet Driver " 20#define DRV_STRING "QLogic 10 Gigabit PCI-E Ethernet Driver "
21#define DRV_VERSION "v1.00.00.29.00.00-01" 21#define DRV_VERSION "v1.00.00.30.00.00-01"
22 22
23#define WQ_ADDR_ALIGN 0x3 /* 4 byte alignment */ 23#define WQ_ADDR_ALIGN 0x3 /* 4 byte alignment */
24 24
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c b/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c
index fca804f36d61..58185b604b72 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c
+++ b/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c
@@ -1824,10 +1824,8 @@ void ql_dump_hw_cb(struct ql_adapter *qdev, int size, u32 bit, u16 q_id)
1824 pr_err("%s: Enter\n", __func__); 1824 pr_err("%s: Enter\n", __func__);
1825 1825
1826 ptr = kmalloc(size, GFP_ATOMIC); 1826 ptr = kmalloc(size, GFP_ATOMIC);
1827 if (ptr == NULL) { 1827 if (ptr == NULL)
1828 pr_err("%s: Couldn't allocate a buffer\n", __func__);
1829 return; 1828 return;
1830 }
1831 1829
1832 if (ql_write_cfg(qdev, ptr, size, bit, q_id)) { 1830 if (ql_write_cfg(qdev, ptr, size, bit, q_id)) {
1833 pr_err("%s: Failed to upload control block!\n", __func__); 1831 pr_err("%s: Failed to upload control block!\n", __func__);
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
index b54898737284..49343ec21c82 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c
+++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
@@ -375,13 +375,6 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type,
375 u32 lower = 375 u32 lower =
376 (addr[2] << 24) | (addr[3] << 16) | (addr[4] << 8) | 376 (addr[2] << 24) | (addr[3] << 16) | (addr[4] << 8) |
377 (addr[5]); 377 (addr[5]);
378
379 netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev,
380 "Adding %s address %pM at index %d in the CAM.\n",
381 type == MAC_ADDR_TYPE_MULTI_MAC ?
382 "MULTICAST" : "UNICAST",
383 addr, index);
384
385 status = 378 status =
386 ql_wait_reg_rdy(qdev, 379 ql_wait_reg_rdy(qdev,
387 MAC_ADDR_IDX, MAC_ADDR_MW, 0); 380 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
@@ -430,12 +423,6 @@ static int ql_set_mac_addr_reg(struct ql_adapter *qdev, u8 *addr, u32 type,
430 * addressing. It's either MAC_ADDR_E on or off. 423 * addressing. It's either MAC_ADDR_E on or off.
431 * That's bit-27 we're talking about. 424 * That's bit-27 we're talking about.
432 */ 425 */
433 netif_info(qdev, ifup, qdev->ndev,
434 "%s VLAN ID %d %s the CAM.\n",
435 enable_bit ? "Adding" : "Removing",
436 index,
437 enable_bit ? "to" : "from");
438
439 status = 426 status =
440 ql_wait_reg_rdy(qdev, 427 ql_wait_reg_rdy(qdev,
441 MAC_ADDR_IDX, MAC_ADDR_MW, 0); 428 MAC_ADDR_IDX, MAC_ADDR_MW, 0);
@@ -535,28 +522,6 @@ static int ql_set_routing_reg(struct ql_adapter *qdev, u32 index, u32 mask,
535 int status = -EINVAL; /* Return error if no mask match. */ 522 int status = -EINVAL; /* Return error if no mask match. */
536 u32 value = 0; 523 u32 value = 0;
537 524
538 netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev,
539 "%s %s mask %s the routing reg.\n",
540 enable ? "Adding" : "Removing",
541 index == RT_IDX_ALL_ERR_SLOT ? "MAC ERROR/ALL ERROR" :
542 index == RT_IDX_IP_CSUM_ERR_SLOT ? "IP CSUM ERROR" :
543 index == RT_IDX_TCP_UDP_CSUM_ERR_SLOT ? "TCP/UDP CSUM ERROR" :
544 index == RT_IDX_BCAST_SLOT ? "BROADCAST" :
545 index == RT_IDX_MCAST_MATCH_SLOT ? "MULTICAST MATCH" :
546 index == RT_IDX_ALLMULTI_SLOT ? "ALL MULTICAST MATCH" :
547 index == RT_IDX_UNUSED6_SLOT ? "UNUSED6" :
548 index == RT_IDX_UNUSED7_SLOT ? "UNUSED7" :
549 index == RT_IDX_RSS_MATCH_SLOT ? "RSS ALL/IPV4 MATCH" :
550 index == RT_IDX_RSS_IPV6_SLOT ? "RSS IPV6" :
551 index == RT_IDX_RSS_TCP4_SLOT ? "RSS TCP4" :
552 index == RT_IDX_RSS_TCP6_SLOT ? "RSS TCP6" :
553 index == RT_IDX_CAM_HIT_SLOT ? "CAM HIT" :
554 index == RT_IDX_UNUSED013 ? "UNUSED13" :
555 index == RT_IDX_UNUSED014 ? "UNUSED14" :
556 index == RT_IDX_PROMISCUOUS_SLOT ? "PROMISCUOUS" :
557 "(Bad index != RT_IDX)",
558 enable ? "to" : "from");
559
560 switch (mask) { 525 switch (mask) {
561 case RT_IDX_CAM_HIT: 526 case RT_IDX_CAM_HIT:
562 { 527 {
@@ -1178,14 +1143,16 @@ static void ql_update_lbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
1178 int i; 1143 int i;
1179 1144
1180 while (rx_ring->lbq_free_cnt > 32) { 1145 while (rx_ring->lbq_free_cnt > 32) {
1181 for (i = 0; i < 16; i++) { 1146 for (i = (rx_ring->lbq_clean_idx % 16); i < 16; i++) {
1182 netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, 1147 netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev,
1183 "lbq: try cleaning clean_idx = %d.\n", 1148 "lbq: try cleaning clean_idx = %d.\n",
1184 clean_idx); 1149 clean_idx);
1185 lbq_desc = &rx_ring->lbq[clean_idx]; 1150 lbq_desc = &rx_ring->lbq[clean_idx];
1186 if (ql_get_next_chunk(qdev, rx_ring, lbq_desc)) { 1151 if (ql_get_next_chunk(qdev, rx_ring, lbq_desc)) {
1152 rx_ring->lbq_clean_idx = clean_idx;
1187 netif_err(qdev, ifup, qdev->ndev, 1153 netif_err(qdev, ifup, qdev->ndev,
1188 "Could not get a page chunk.\n"); 1154 "Could not get a page chunk, i=%d, clean_idx =%d .\n",
1155 i, clean_idx);
1189 return; 1156 return;
1190 } 1157 }
1191 1158
@@ -1230,7 +1197,7 @@ static void ql_update_sbq(struct ql_adapter *qdev, struct rx_ring *rx_ring)
1230 int i; 1197 int i;
1231 1198
1232 while (rx_ring->sbq_free_cnt > 16) { 1199 while (rx_ring->sbq_free_cnt > 16) {
1233 for (i = 0; i < 16; i++) { 1200 for (i = (rx_ring->sbq_clean_idx % 16); i < 16; i++) {
1234 sbq_desc = &rx_ring->sbq[clean_idx]; 1201 sbq_desc = &rx_ring->sbq[clean_idx];
1235 netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, 1202 netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev,
1236 "sbq: try cleaning clean_idx = %d.\n", 1203 "sbq: try cleaning clean_idx = %d.\n",
@@ -1576,13 +1543,14 @@ static void ql_process_mac_rx_page(struct ql_adapter *qdev,
1576 } else if ((ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_U) && 1543 } else if ((ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_U) &&
1577 (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_V4)) { 1544 (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_V4)) {
1578 /* Unfragmented ipv4 UDP frame. */ 1545 /* Unfragmented ipv4 UDP frame. */
1579 struct iphdr *iph = (struct iphdr *) skb->data; 1546 struct iphdr *iph =
1547 (struct iphdr *) ((u8 *)addr + ETH_HLEN);
1580 if (!(iph->frag_off & 1548 if (!(iph->frag_off &
1581 cpu_to_be16(IP_MF|IP_OFFSET))) { 1549 cpu_to_be16(IP_MF|IP_OFFSET))) {
1582 skb->ip_summed = CHECKSUM_UNNECESSARY; 1550 skb->ip_summed = CHECKSUM_UNNECESSARY;
1583 netif_printk(qdev, rx_status, KERN_DEBUG, 1551 netif_printk(qdev, rx_status, KERN_DEBUG,
1584 qdev->ndev, 1552 qdev->ndev,
1585 "TCP checksum done!\n"); 1553 "UDP checksum done!\n");
1586 } 1554 }
1587 } 1555 }
1588 } 1556 }
@@ -1690,7 +1658,7 @@ static void ql_process_mac_rx_skb(struct ql_adapter *qdev,
1690 skb->ip_summed = CHECKSUM_UNNECESSARY; 1658 skb->ip_summed = CHECKSUM_UNNECESSARY;
1691 netif_printk(qdev, rx_status, KERN_DEBUG, 1659 netif_printk(qdev, rx_status, KERN_DEBUG,
1692 qdev->ndev, 1660 qdev->ndev,
1693 "TCP checksum done!\n"); 1661 "UDP checksum done!\n");
1694 } 1662 }
1695 } 1663 }
1696 } 1664 }
@@ -2312,13 +2280,9 @@ static void qlge_vlan_mode(struct net_device *ndev, netdev_features_t features)
2312 struct ql_adapter *qdev = netdev_priv(ndev); 2280 struct ql_adapter *qdev = netdev_priv(ndev);
2313 2281
2314 if (features & NETIF_F_HW_VLAN_RX) { 2282 if (features & NETIF_F_HW_VLAN_RX) {
2315 netif_printk(qdev, ifup, KERN_DEBUG, ndev,
2316 "Turning on VLAN in NIC_RCV_CFG.\n");
2317 ql_write32(qdev, NIC_RCV_CFG, NIC_RCV_CFG_VLAN_MASK | 2283 ql_write32(qdev, NIC_RCV_CFG, NIC_RCV_CFG_VLAN_MASK |
2318 NIC_RCV_CFG_VLAN_MATCH_AND_NON); 2284 NIC_RCV_CFG_VLAN_MATCH_AND_NON);
2319 } else { 2285 } else {
2320 netif_printk(qdev, ifup, KERN_DEBUG, ndev,
2321 "Turning off VLAN in NIC_RCV_CFG.\n");
2322 ql_write32(qdev, NIC_RCV_CFG, NIC_RCV_CFG_VLAN_MASK); 2286 ql_write32(qdev, NIC_RCV_CFG, NIC_RCV_CFG_VLAN_MASK);
2323 } 2287 }
2324} 2288}
@@ -3183,8 +3147,6 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
3183 netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, 3147 netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev,
3184 "Invalid rx_ring->type = %d.\n", rx_ring->type); 3148 "Invalid rx_ring->type = %d.\n", rx_ring->type);
3185 } 3149 }
3186 netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev,
3187 "Initializing rx work queue.\n");
3188 err = ql_write_cfg(qdev, cqicb, sizeof(struct cqicb), 3150 err = ql_write_cfg(qdev, cqicb, sizeof(struct cqicb),
3189 CFG_LCQ, rx_ring->cq_id); 3151 CFG_LCQ, rx_ring->cq_id);
3190 if (err) { 3152 if (err) {
@@ -3237,8 +3199,6 @@ static int ql_start_tx_ring(struct ql_adapter *qdev, struct tx_ring *tx_ring)
3237 netif_err(qdev, ifup, qdev->ndev, "Failed to load tx_ring.\n"); 3199 netif_err(qdev, ifup, qdev->ndev, "Failed to load tx_ring.\n");
3238 return err; 3200 return err;
3239 } 3201 }
3240 netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev,
3241 "Successfully loaded WQICB.\n");
3242 return err; 3202 return err;
3243} 3203}
3244 3204
@@ -3488,12 +3448,8 @@ static void ql_free_irq(struct ql_adapter *qdev)
3488 if (test_bit(QL_MSIX_ENABLED, &qdev->flags)) { 3448 if (test_bit(QL_MSIX_ENABLED, &qdev->flags)) {
3489 free_irq(qdev->msi_x_entry[i].vector, 3449 free_irq(qdev->msi_x_entry[i].vector,
3490 &qdev->rx_ring[i]); 3450 &qdev->rx_ring[i]);
3491 netif_printk(qdev, ifdown, KERN_DEBUG, qdev->ndev,
3492 "freeing msix interrupt %d.\n", i);
3493 } else { 3451 } else {
3494 free_irq(qdev->pdev->irq, &qdev->rx_ring[0]); 3452 free_irq(qdev->pdev->irq, &qdev->rx_ring[0]);
3495 netif_printk(qdev, ifdown, KERN_DEBUG, qdev->ndev,
3496 "freeing msi interrupt %d.\n", i);
3497 } 3453 }
3498 } 3454 }
3499 } 3455 }
@@ -3522,17 +3478,6 @@ static int ql_request_irq(struct ql_adapter *qdev)
3522 "Failed request for MSIX interrupt %d.\n", 3478 "Failed request for MSIX interrupt %d.\n",
3523 i); 3479 i);
3524 goto err_irq; 3480 goto err_irq;
3525 } else {
3526 netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev,
3527 "Hooked intr %d, queue type %s, with name %s.\n",
3528 i,
3529 qdev->rx_ring[i].type == DEFAULT_Q ?
3530 "DEFAULT_Q" :
3531 qdev->rx_ring[i].type == TX_Q ?
3532 "TX_Q" :
3533 qdev->rx_ring[i].type == RX_Q ?
3534 "RX_Q" : "",
3535 intr_context->name);
3536 } 3481 }
3537 } else { 3482 } else {
3538 netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, 3483 netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev,
@@ -3602,15 +3547,11 @@ static int ql_start_rss(struct ql_adapter *qdev)
3602 memcpy((void *)&ricb->ipv6_hash_key[0], init_hash_seed, 40); 3547 memcpy((void *)&ricb->ipv6_hash_key[0], init_hash_seed, 40);
3603 memcpy((void *)&ricb->ipv4_hash_key[0], init_hash_seed, 16); 3548 memcpy((void *)&ricb->ipv4_hash_key[0], init_hash_seed, 16);
3604 3549
3605 netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, "Initializing RSS.\n");
3606
3607 status = ql_write_cfg(qdev, ricb, sizeof(*ricb), CFG_LR, 0); 3550 status = ql_write_cfg(qdev, ricb, sizeof(*ricb), CFG_LR, 0);
3608 if (status) { 3551 if (status) {
3609 netif_err(qdev, ifup, qdev->ndev, "Failed to load RICB.\n"); 3552 netif_err(qdev, ifup, qdev->ndev, "Failed to load RICB.\n");
3610 return status; 3553 return status;
3611 } 3554 }
3612 netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev,
3613 "Successfully loaded RICB.\n");
3614 return status; 3555 return status;
3615} 3556}
3616 3557
@@ -3817,11 +3758,8 @@ static int ql_adapter_initialize(struct ql_adapter *qdev)
3817 } 3758 }
3818 3759
3819 /* Start NAPI for the RSS queues. */ 3760 /* Start NAPI for the RSS queues. */
3820 for (i = 0; i < qdev->rss_ring_count; i++) { 3761 for (i = 0; i < qdev->rss_ring_count; i++)
3821 netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev,
3822 "Enabling NAPI for rx_ring[%d].\n", i);
3823 napi_enable(&qdev->rx_ring[i].napi); 3762 napi_enable(&qdev->rx_ring[i].napi);
3824 }
3825 3763
3826 return status; 3764 return status;
3827} 3765}
@@ -4121,10 +4059,6 @@ static int ql_configure_rings(struct ql_adapter *qdev)
4121 rx_ring->lbq_size = 4059 rx_ring->lbq_size =
4122 rx_ring->lbq_len * sizeof(__le64); 4060 rx_ring->lbq_len * sizeof(__le64);
4123 rx_ring->lbq_buf_size = (u16)lbq_buf_len; 4061 rx_ring->lbq_buf_size = (u16)lbq_buf_len;
4124 netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev,
4125 "lbq_buf_size %d, order = %d\n",
4126 rx_ring->lbq_buf_size,
4127 qdev->lbq_buf_order);
4128 rx_ring->sbq_len = NUM_SMALL_BUFFERS; 4062 rx_ring->sbq_len = NUM_SMALL_BUFFERS;
4129 rx_ring->sbq_size = 4063 rx_ring->sbq_size =
4130 rx_ring->sbq_len * sizeof(__le64); 4064 rx_ring->sbq_len * sizeof(__le64);
diff --git a/drivers/net/ethernet/racal/ni5010.c b/drivers/net/ethernet/racal/ni5010.c
index 072810da9a37..807982220050 100644
--- a/drivers/net/ethernet/racal/ni5010.c
+++ b/drivers/net/ethernet/racal/ni5010.c
@@ -552,7 +552,7 @@ static void ni5010_rx(struct net_device *dev)
552 } 552 }
553 553
554 /* Malloc up new buffer. */ 554 /* Malloc up new buffer. */
555 skb = dev_alloc_skb(i_pkt_size + 3); 555 skb = netdev_alloc_skb(dev, i_pkt_size + 3);
556 if (skb == NULL) { 556 if (skb == NULL) {
557 printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name); 557 printk(KERN_WARNING "%s: Memory squeeze, dropping packet.\n", dev->name);
558 dev->stats.rx_dropped++; 558 dev->stats.rx_dropped++;
diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c
index cb0eca807852..76cab284876b 100644
--- a/drivers/net/ethernet/rdc/r6040.c
+++ b/drivers/net/ethernet/rdc/r6040.c
@@ -1107,7 +1107,6 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
1107 1107
1108 dev = alloc_etherdev(sizeof(struct r6040_private)); 1108 dev = alloc_etherdev(sizeof(struct r6040_private));
1109 if (!dev) { 1109 if (!dev) {
1110 dev_err(&pdev->dev, "Failed to allocate etherdev\n");
1111 err = -ENOMEM; 1110 err = -ENOMEM;
1112 goto err_out; 1111 goto err_out;
1113 } 1112 }
diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c
index a8779bedb3d9..1c3feb0116b5 100644
--- a/drivers/net/ethernet/realtek/8139too.c
+++ b/drivers/net/ethernet/realtek/8139too.c
@@ -754,10 +754,9 @@ static __devinit struct net_device * rtl8139_init_board (struct pci_dev *pdev)
754 754
755 /* dev and priv zeroed in alloc_etherdev */ 755 /* dev and priv zeroed in alloc_etherdev */
756 dev = alloc_etherdev (sizeof (*tp)); 756 dev = alloc_etherdev (sizeof (*tp));
757 if (dev == NULL) { 757 if (dev == NULL)
758 dev_err(&pdev->dev, "Unable to alloc new net device\n");
759 return ERR_PTR(-ENOMEM); 758 return ERR_PTR(-ENOMEM);
760 } 759
761 SET_NETDEV_DEV(dev, &pdev->dev); 760 SET_NETDEV_DEV(dev, &pdev->dev);
762 761
763 tp = netdev_priv(dev); 762 tp = netdev_priv(dev);
diff --git a/drivers/net/ethernet/realtek/Kconfig b/drivers/net/ethernet/realtek/Kconfig
index 0578859a3c73..5821966f9f28 100644
--- a/drivers/net/ethernet/realtek/Kconfig
+++ b/drivers/net/ethernet/realtek/Kconfig
@@ -24,11 +24,11 @@ config ATP
24 select CRC32 24 select CRC32
25 ---help--- 25 ---help---
26 This is a network (Ethernet) device which attaches to your parallel 26 This is a network (Ethernet) device which attaches to your parallel
27 port. Read <file:drivers/net/atp.c> as well as the Ethernet-HOWTO, 27 port. Read <file:drivers/net/ethernet/realtek/atp.c> as well as the
28 available from <http://www.tldp.org/docs.html#howto>, if you 28 Ethernet-HOWTO, available from <http://www.tldp.org/docs.html#howto>,
29 want to use this. If you intend to use this driver, you should have 29 if you want to use this. If you intend to use this driver, you
30 said N to the "Parallel printer support", because the two drivers 30 should have said N to the "Parallel printer support", because the two
31 don't like each other. 31 drivers don't like each other.
32 32
33 To compile this driver as a module, choose M here: the module 33 To compile this driver as a module, choose M here: the module
34 will be called atp. 34 will be called atp.
diff --git a/drivers/net/ethernet/realtek/atp.c b/drivers/net/ethernet/realtek/atp.c
index e3f57fdbf0ea..46c1932048cb 100644
--- a/drivers/net/ethernet/realtek/atp.c
+++ b/drivers/net/ethernet/realtek/atp.c
@@ -783,7 +783,7 @@ static void net_rx(struct net_device *dev)
783 int pkt_len = (rx_head.rx_count & 0x7ff) - 4; 783 int pkt_len = (rx_head.rx_count & 0x7ff) - 4;
784 struct sk_buff *skb; 784 struct sk_buff *skb;
785 785
786 skb = dev_alloc_skb(pkt_len + 2); 786 skb = netdev_alloc_skb(dev, pkt_len + 2);
787 if (skb == NULL) { 787 if (skb == NULL) {
788 printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n", 788 printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n",
789 dev->name); 789 dev->name);
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 7a0c800b50ad..5eb6858ed0a7 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -667,12 +667,19 @@ struct rtl8169_counters {
667 __le16 tx_underun; 667 __le16 tx_underun;
668}; 668};
669 669
670enum rtl_flag {
671 RTL_FLAG_TASK_ENABLED,
672 RTL_FLAG_TASK_SLOW_PENDING,
673 RTL_FLAG_TASK_RESET_PENDING,
674 RTL_FLAG_TASK_PHY_PENDING,
675 RTL_FLAG_MAX
676};
677
670struct rtl8169_private { 678struct rtl8169_private {
671 void __iomem *mmio_addr; /* memory map physical address */ 679 void __iomem *mmio_addr; /* memory map physical address */
672 struct pci_dev *pci_dev; 680 struct pci_dev *pci_dev;
673 struct net_device *dev; 681 struct net_device *dev;
674 struct napi_struct napi; 682 struct napi_struct napi;
675 spinlock_t lock;
676 u32 msg_enable; 683 u32 msg_enable;
677 u16 txd_version; 684 u16 txd_version;
678 u16 mac_version; 685 u16 mac_version;
@@ -688,9 +695,8 @@ struct rtl8169_private {
688 struct ring_info tx_skb[NUM_TX_DESC]; /* Tx data buffers */ 695 struct ring_info tx_skb[NUM_TX_DESC]; /* Tx data buffers */
689 struct timer_list timer; 696 struct timer_list timer;
690 u16 cp_cmd; 697 u16 cp_cmd;
691 u16 intr_event; 698
692 u16 napi_event; 699 u16 event_slow;
693 u16 intr_mask;
694 700
695 struct mdio_ops { 701 struct mdio_ops {
696 void (*write)(void __iomem *, int, int); 702 void (*write)(void __iomem *, int, int);
@@ -714,7 +720,13 @@ struct rtl8169_private {
714 unsigned int (*phy_reset_pending)(struct rtl8169_private *tp); 720 unsigned int (*phy_reset_pending)(struct rtl8169_private *tp);
715 unsigned int (*link_ok)(void __iomem *); 721 unsigned int (*link_ok)(void __iomem *);
716 int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd); 722 int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd);
717 struct delayed_work task; 723
724 struct {
725 DECLARE_BITMAP(flags, RTL_FLAG_MAX);
726 struct mutex mutex;
727 struct work_struct work;
728 } wk;
729
718 unsigned features; 730 unsigned features;
719 731
720 struct mii_if_info mii; 732 struct mii_if_info mii;
@@ -764,13 +776,20 @@ static int rtl8169_close(struct net_device *dev);
764static void rtl_set_rx_mode(struct net_device *dev); 776static void rtl_set_rx_mode(struct net_device *dev);
765static void rtl8169_tx_timeout(struct net_device *dev); 777static void rtl8169_tx_timeout(struct net_device *dev);
766static struct net_device_stats *rtl8169_get_stats(struct net_device *dev); 778static struct net_device_stats *rtl8169_get_stats(struct net_device *dev);
767static int rtl8169_rx_interrupt(struct net_device *, struct rtl8169_private *,
768 void __iomem *, u32 budget);
769static int rtl8169_change_mtu(struct net_device *dev, int new_mtu); 779static int rtl8169_change_mtu(struct net_device *dev, int new_mtu);
770static void rtl8169_down(struct net_device *dev);
771static void rtl8169_rx_clear(struct rtl8169_private *tp); 780static void rtl8169_rx_clear(struct rtl8169_private *tp);
772static int rtl8169_poll(struct napi_struct *napi, int budget); 781static int rtl8169_poll(struct napi_struct *napi, int budget);
773 782
783static void rtl_lock_work(struct rtl8169_private *tp)
784{
785 mutex_lock(&tp->wk.mutex);
786}
787
788static void rtl_unlock_work(struct rtl8169_private *tp)
789{
790 mutex_unlock(&tp->wk.mutex);
791}
792
774static void rtl_tx_performance_tweak(struct pci_dev *pdev, u16 force) 793static void rtl_tx_performance_tweak(struct pci_dev *pdev, u16 force)
775{ 794{
776 int cap = pci_pcie_cap(pdev); 795 int cap = pci_pcie_cap(pdev);
@@ -1180,12 +1199,51 @@ static u8 rtl8168d_efuse_read(void __iomem *ioaddr, int reg_addr)
1180 return value; 1199 return value;
1181} 1200}
1182 1201
1202static u16 rtl_get_events(struct rtl8169_private *tp)
1203{
1204 void __iomem *ioaddr = tp->mmio_addr;
1205
1206 return RTL_R16(IntrStatus);
1207}
1208
1209static void rtl_ack_events(struct rtl8169_private *tp, u16 bits)
1210{
1211 void __iomem *ioaddr = tp->mmio_addr;
1212
1213 RTL_W16(IntrStatus, bits);
1214 mmiowb();
1215}
1216
1217static void rtl_irq_disable(struct rtl8169_private *tp)
1218{
1219 void __iomem *ioaddr = tp->mmio_addr;
1220
1221 RTL_W16(IntrMask, 0);
1222 mmiowb();
1223}
1224
1225static void rtl_irq_enable(struct rtl8169_private *tp, u16 bits)
1226{
1227 void __iomem *ioaddr = tp->mmio_addr;
1228
1229 RTL_W16(IntrMask, bits);
1230}
1231
1232#define RTL_EVENT_NAPI_RX (RxOK | RxErr)
1233#define RTL_EVENT_NAPI_TX (TxOK | TxErr)
1234#define RTL_EVENT_NAPI (RTL_EVENT_NAPI_RX | RTL_EVENT_NAPI_TX)
1235
1236static void rtl_irq_enable_all(struct rtl8169_private *tp)
1237{
1238 rtl_irq_enable(tp, RTL_EVENT_NAPI | tp->event_slow);
1239}
1240
1183static void rtl8169_irq_mask_and_ack(struct rtl8169_private *tp) 1241static void rtl8169_irq_mask_and_ack(struct rtl8169_private *tp)
1184{ 1242{
1185 void __iomem *ioaddr = tp->mmio_addr; 1243 void __iomem *ioaddr = tp->mmio_addr;
1186 1244
1187 RTL_W16(IntrMask, 0x0000); 1245 rtl_irq_disable(tp);
1188 RTL_W16(IntrStatus, tp->intr_event); 1246 rtl_ack_events(tp, RTL_EVENT_NAPI | tp->event_slow);
1189 RTL_R8(ChipCmd); 1247 RTL_R8(ChipCmd);
1190} 1248}
1191 1249
@@ -1276,9 +1334,6 @@ static void __rtl8169_check_link_status(struct net_device *dev,
1276 struct rtl8169_private *tp, 1334 struct rtl8169_private *tp,
1277 void __iomem *ioaddr, bool pm) 1335 void __iomem *ioaddr, bool pm)
1278{ 1336{
1279 unsigned long flags;
1280
1281 spin_lock_irqsave(&tp->lock, flags);
1282 if (tp->link_ok(ioaddr)) { 1337 if (tp->link_ok(ioaddr)) {
1283 rtl_link_chg_patch(tp); 1338 rtl_link_chg_patch(tp);
1284 /* This is to cancel a scheduled suspend if there's one. */ 1339 /* This is to cancel a scheduled suspend if there's one. */
@@ -1293,7 +1348,6 @@ static void __rtl8169_check_link_status(struct net_device *dev,
1293 if (pm) 1348 if (pm)
1294 pm_schedule_suspend(&tp->pci_dev->dev, 5000); 1349 pm_schedule_suspend(&tp->pci_dev->dev, 5000);
1295 } 1350 }
1296 spin_unlock_irqrestore(&tp->lock, flags);
1297} 1351}
1298 1352
1299static void rtl8169_check_link_status(struct net_device *dev, 1353static void rtl8169_check_link_status(struct net_device *dev,
@@ -1336,12 +1390,12 @@ static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
1336{ 1390{
1337 struct rtl8169_private *tp = netdev_priv(dev); 1391 struct rtl8169_private *tp = netdev_priv(dev);
1338 1392
1339 spin_lock_irq(&tp->lock); 1393 rtl_lock_work(tp);
1340 1394
1341 wol->supported = WAKE_ANY; 1395 wol->supported = WAKE_ANY;
1342 wol->wolopts = __rtl8169_get_wol(tp); 1396 wol->wolopts = __rtl8169_get_wol(tp);
1343 1397
1344 spin_unlock_irq(&tp->lock); 1398 rtl_unlock_work(tp);
1345} 1399}
1346 1400
1347static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts) 1401static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
@@ -1378,14 +1432,15 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
1378{ 1432{
1379 struct rtl8169_private *tp = netdev_priv(dev); 1433 struct rtl8169_private *tp = netdev_priv(dev);
1380 1434
1381 spin_lock_irq(&tp->lock); 1435 rtl_lock_work(tp);
1382 1436
1383 if (wol->wolopts) 1437 if (wol->wolopts)
1384 tp->features |= RTL_FEATURE_WOL; 1438 tp->features |= RTL_FEATURE_WOL;
1385 else 1439 else
1386 tp->features &= ~RTL_FEATURE_WOL; 1440 tp->features &= ~RTL_FEATURE_WOL;
1387 __rtl8169_set_wol(tp, wol->wolopts); 1441 __rtl8169_set_wol(tp, wol->wolopts);
1388 spin_unlock_irq(&tp->lock); 1442
1443 rtl_unlock_work(tp);
1389 1444
1390 device_set_wakeup_enable(&tp->pci_dev->dev, wol->wolopts); 1445 device_set_wakeup_enable(&tp->pci_dev->dev, wol->wolopts);
1391 1446
@@ -1540,15 +1595,14 @@ out:
1540static int rtl8169_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 1595static int rtl8169_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1541{ 1596{
1542 struct rtl8169_private *tp = netdev_priv(dev); 1597 struct rtl8169_private *tp = netdev_priv(dev);
1543 unsigned long flags;
1544 int ret; 1598 int ret;
1545 1599
1546 del_timer_sync(&tp->timer); 1600 del_timer_sync(&tp->timer);
1547 1601
1548 spin_lock_irqsave(&tp->lock, flags); 1602 rtl_lock_work(tp);
1549 ret = rtl8169_set_speed(dev, cmd->autoneg, ethtool_cmd_speed(cmd), 1603 ret = rtl8169_set_speed(dev, cmd->autoneg, ethtool_cmd_speed(cmd),
1550 cmd->duplex, cmd->advertising); 1604 cmd->duplex, cmd->advertising);
1551 spin_unlock_irqrestore(&tp->lock, flags); 1605 rtl_unlock_work(tp);
1552 1606
1553 return ret; 1607 return ret;
1554} 1608}
@@ -1568,14 +1622,12 @@ static netdev_features_t rtl8169_fix_features(struct net_device *dev,
1568 return features; 1622 return features;
1569} 1623}
1570 1624
1571static int rtl8169_set_features(struct net_device *dev, 1625static void __rtl8169_set_features(struct net_device *dev,
1572 netdev_features_t features) 1626 netdev_features_t features)
1573{ 1627{
1574 struct rtl8169_private *tp = netdev_priv(dev); 1628 struct rtl8169_private *tp = netdev_priv(dev);
1575 void __iomem *ioaddr = tp->mmio_addr;
1576 unsigned long flags;
1577 1629
1578 spin_lock_irqsave(&tp->lock, flags); 1630 void __iomem *ioaddr = tp->mmio_addr;
1579 1631
1580 if (features & NETIF_F_RXCSUM) 1632 if (features & NETIF_F_RXCSUM)
1581 tp->cp_cmd |= RxChkSum; 1633 tp->cp_cmd |= RxChkSum;
@@ -1589,12 +1641,21 @@ static int rtl8169_set_features(struct net_device *dev,
1589 1641
1590 RTL_W16(CPlusCmd, tp->cp_cmd); 1642 RTL_W16(CPlusCmd, tp->cp_cmd);
1591 RTL_R16(CPlusCmd); 1643 RTL_R16(CPlusCmd);
1644}
1645
1646static int rtl8169_set_features(struct net_device *dev,
1647 netdev_features_t features)
1648{
1649 struct rtl8169_private *tp = netdev_priv(dev);
1592 1650
1593 spin_unlock_irqrestore(&tp->lock, flags); 1651 rtl_lock_work(tp);
1652 __rtl8169_set_features(dev, features);
1653 rtl_unlock_work(tp);
1594 1654
1595 return 0; 1655 return 0;
1596} 1656}
1597 1657
1658
1598static inline u32 rtl8169_tx_vlan_tag(struct rtl8169_private *tp, 1659static inline u32 rtl8169_tx_vlan_tag(struct rtl8169_private *tp,
1599 struct sk_buff *skb) 1660 struct sk_buff *skb)
1600{ 1661{
@@ -1643,14 +1704,12 @@ static int rtl8169_gset_xmii(struct net_device *dev, struct ethtool_cmd *cmd)
1643static int rtl8169_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 1704static int rtl8169_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1644{ 1705{
1645 struct rtl8169_private *tp = netdev_priv(dev); 1706 struct rtl8169_private *tp = netdev_priv(dev);
1646 unsigned long flags;
1647 int rc; 1707 int rc;
1648 1708
1649 spin_lock_irqsave(&tp->lock, flags); 1709 rtl_lock_work(tp);
1650
1651 rc = tp->get_settings(dev, cmd); 1710 rc = tp->get_settings(dev, cmd);
1711 rtl_unlock_work(tp);
1652 1712
1653 spin_unlock_irqrestore(&tp->lock, flags);
1654 return rc; 1713 return rc;
1655} 1714}
1656 1715
@@ -1658,14 +1717,13 @@ static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs,
1658 void *p) 1717 void *p)
1659{ 1718{
1660 struct rtl8169_private *tp = netdev_priv(dev); 1719 struct rtl8169_private *tp = netdev_priv(dev);
1661 unsigned long flags;
1662 1720
1663 if (regs->len > R8169_REGS_SIZE) 1721 if (regs->len > R8169_REGS_SIZE)
1664 regs->len = R8169_REGS_SIZE; 1722 regs->len = R8169_REGS_SIZE;
1665 1723
1666 spin_lock_irqsave(&tp->lock, flags); 1724 rtl_lock_work(tp);
1667 memcpy_fromio(p, tp->mmio_addr, regs->len); 1725 memcpy_fromio(p, tp->mmio_addr, regs->len);
1668 spin_unlock_irqrestore(&tp->lock, flags); 1726 rtl_unlock_work(tp);
1669} 1727}
1670 1728
1671static u32 rtl8169_get_msglevel(struct net_device *dev) 1729static u32 rtl8169_get_msglevel(struct net_device *dev)
@@ -3182,18 +3240,14 @@ static void rtl_hw_phy_config(struct net_device *dev)
3182 } 3240 }
3183} 3241}
3184 3242
3185static void rtl8169_phy_timer(unsigned long __opaque) 3243static void rtl_phy_work(struct rtl8169_private *tp)
3186{ 3244{
3187 struct net_device *dev = (struct net_device *)__opaque;
3188 struct rtl8169_private *tp = netdev_priv(dev);
3189 struct timer_list *timer = &tp->timer; 3245 struct timer_list *timer = &tp->timer;
3190 void __iomem *ioaddr = tp->mmio_addr; 3246 void __iomem *ioaddr = tp->mmio_addr;
3191 unsigned long timeout = RTL8169_PHY_TIMEOUT; 3247 unsigned long timeout = RTL8169_PHY_TIMEOUT;
3192 3248
3193 assert(tp->mac_version > RTL_GIGA_MAC_VER_01); 3249 assert(tp->mac_version > RTL_GIGA_MAC_VER_01);
3194 3250
3195 spin_lock_irq(&tp->lock);
3196
3197 if (tp->phy_reset_pending(tp)) { 3251 if (tp->phy_reset_pending(tp)) {
3198 /* 3252 /*
3199 * A busy loop could burn quite a few cycles on nowadays CPU. 3253 * A busy loop could burn quite a few cycles on nowadays CPU.
@@ -3204,32 +3258,36 @@ static void rtl8169_phy_timer(unsigned long __opaque)
3204 } 3258 }
3205 3259
3206 if (tp->link_ok(ioaddr)) 3260 if (tp->link_ok(ioaddr))
3207 goto out_unlock; 3261 return;
3208 3262
3209 netif_warn(tp, link, dev, "PHY reset until link up\n"); 3263 netif_warn(tp, link, tp->dev, "PHY reset until link up\n");
3210 3264
3211 tp->phy_reset_enable(tp); 3265 tp->phy_reset_enable(tp);
3212 3266
3213out_mod_timer: 3267out_mod_timer:
3214 mod_timer(timer, jiffies + timeout); 3268 mod_timer(timer, jiffies + timeout);
3215out_unlock: 3269}
3216 spin_unlock_irq(&tp->lock); 3270
3271static void rtl_schedule_task(struct rtl8169_private *tp, enum rtl_flag flag)
3272{
3273 if (!test_and_set_bit(flag, tp->wk.flags))
3274 schedule_work(&tp->wk.work);
3275}
3276
3277static void rtl8169_phy_timer(unsigned long __opaque)
3278{
3279 struct net_device *dev = (struct net_device *)__opaque;
3280 struct rtl8169_private *tp = netdev_priv(dev);
3281
3282 rtl_schedule_task(tp, RTL_FLAG_TASK_PHY_PENDING);
3217} 3283}
3218 3284
3219#ifdef CONFIG_NET_POLL_CONTROLLER 3285#ifdef CONFIG_NET_POLL_CONTROLLER
3220/*
3221 * Polling 'interrupt' - used by things like netconsole to send skbs
3222 * without having to re-enable interrupts. It's not called while
3223 * the interrupt routine is executing.
3224 */
3225static void rtl8169_netpoll(struct net_device *dev) 3286static void rtl8169_netpoll(struct net_device *dev)
3226{ 3287{
3227 struct rtl8169_private *tp = netdev_priv(dev); 3288 struct rtl8169_private *tp = netdev_priv(dev);
3228 struct pci_dev *pdev = tp->pci_dev;
3229 3289
3230 disable_irq(pdev->irq); 3290 rtl8169_interrupt(tp->pci_dev->irq, dev);
3231 rtl8169_interrupt(pdev->irq, dev);
3232 enable_irq(pdev->irq);
3233} 3291}
3234#endif 3292#endif
3235 3293
@@ -3310,7 +3368,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
3310 low = addr[0] | (addr[1] << 8) | (addr[2] << 16) | (addr[3] << 24); 3368 low = addr[0] | (addr[1] << 8) | (addr[2] << 16) | (addr[3] << 24);
3311 high = addr[4] | (addr[5] << 8); 3369 high = addr[4] | (addr[5] << 8);
3312 3370
3313 spin_lock_irq(&tp->lock); 3371 rtl_lock_work(tp);
3314 3372
3315 RTL_W8(Cfg9346, Cfg9346_Unlock); 3373 RTL_W8(Cfg9346, Cfg9346_Unlock);
3316 3374
@@ -3334,7 +3392,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
3334 3392
3335 RTL_W8(Cfg9346, Cfg9346_Lock); 3393 RTL_W8(Cfg9346, Cfg9346_Lock);
3336 3394
3337 spin_unlock_irq(&tp->lock); 3395 rtl_unlock_work(tp);
3338} 3396}
3339 3397
3340static int rtl_set_mac_address(struct net_device *dev, void *p) 3398static int rtl_set_mac_address(struct net_device *dev, void *p)
@@ -3388,8 +3446,7 @@ static const struct rtl_cfg_info {
3388 void (*hw_start)(struct net_device *); 3446 void (*hw_start)(struct net_device *);
3389 unsigned int region; 3447 unsigned int region;
3390 unsigned int align; 3448 unsigned int align;
3391 u16 intr_event; 3449 u16 event_slow;
3392 u16 napi_event;
3393 unsigned features; 3450 unsigned features;
3394 u8 default_ver; 3451 u8 default_ver;
3395} rtl_cfg_infos [] = { 3452} rtl_cfg_infos [] = {
@@ -3397,9 +3454,7 @@ static const struct rtl_cfg_info {
3397 .hw_start = rtl_hw_start_8169, 3454 .hw_start = rtl_hw_start_8169,
3398 .region = 1, 3455 .region = 1,
3399 .align = 0, 3456 .align = 0,
3400 .intr_event = SYSErr | LinkChg | RxOverflow | 3457 .event_slow = SYSErr | LinkChg | RxOverflow | RxFIFOOver,
3401 RxFIFOOver | TxErr | TxOK | RxOK | RxErr,
3402 .napi_event = RxFIFOOver | TxErr | TxOK | RxOK | RxOverflow,
3403 .features = RTL_FEATURE_GMII, 3458 .features = RTL_FEATURE_GMII,
3404 .default_ver = RTL_GIGA_MAC_VER_01, 3459 .default_ver = RTL_GIGA_MAC_VER_01,
3405 }, 3460 },
@@ -3407,9 +3462,7 @@ static const struct rtl_cfg_info {
3407 .hw_start = rtl_hw_start_8168, 3462 .hw_start = rtl_hw_start_8168,
3408 .region = 2, 3463 .region = 2,
3409 .align = 8, 3464 .align = 8,
3410 .intr_event = SYSErr | LinkChg | RxOverflow | 3465 .event_slow = SYSErr | LinkChg | RxOverflow,
3411 TxErr | TxOK | RxOK | RxErr,
3412 .napi_event = TxErr | TxOK | RxOK | RxOverflow,
3413 .features = RTL_FEATURE_GMII | RTL_FEATURE_MSI, 3466 .features = RTL_FEATURE_GMII | RTL_FEATURE_MSI,
3414 .default_ver = RTL_GIGA_MAC_VER_11, 3467 .default_ver = RTL_GIGA_MAC_VER_11,
3415 }, 3468 },
@@ -3417,9 +3470,8 @@ static const struct rtl_cfg_info {
3417 .hw_start = rtl_hw_start_8101, 3470 .hw_start = rtl_hw_start_8101,
3418 .region = 2, 3471 .region = 2,
3419 .align = 8, 3472 .align = 8,
3420 .intr_event = SYSErr | LinkChg | RxOverflow | PCSTimeout | 3473 .event_slow = SYSErr | LinkChg | RxOverflow | RxFIFOOver |
3421 RxFIFOOver | TxErr | TxOK | RxOK | RxErr, 3474 PCSTimeout,
3422 .napi_event = RxFIFOOver | TxErr | TxOK | RxOK | RxOverflow,
3423 .features = RTL_FEATURE_MSI, 3475 .features = RTL_FEATURE_MSI,
3424 .default_ver = RTL_GIGA_MAC_VER_13, 3476 .default_ver = RTL_GIGA_MAC_VER_13,
3425 } 3477 }
@@ -3824,23 +3876,21 @@ static void r8168dp_hw_jumbo_disable(struct rtl8169_private *tp)
3824static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp) 3876static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp)
3825{ 3877{
3826 void __iomem *ioaddr = tp->mmio_addr; 3878 void __iomem *ioaddr = tp->mmio_addr;
3827 struct pci_dev *pdev = tp->pci_dev;
3828 3879
3829 RTL_W8(MaxTxPacketSize, 0x3f); 3880 RTL_W8(MaxTxPacketSize, 0x3f);
3830 RTL_W8(Config3, RTL_R8(Config3) | Jumbo_En0); 3881 RTL_W8(Config3, RTL_R8(Config3) | Jumbo_En0);
3831 RTL_W8(Config4, RTL_R8(Config4) | 0x01); 3882 RTL_W8(Config4, RTL_R8(Config4) | 0x01);
3832 pci_write_config_byte(pdev, 0x79, 0x20); 3883 rtl_tx_performance_tweak(tp->pci_dev, 0x2 << MAX_READ_REQUEST_SHIFT);
3833} 3884}
3834 3885
3835static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp) 3886static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp)
3836{ 3887{
3837 void __iomem *ioaddr = tp->mmio_addr; 3888 void __iomem *ioaddr = tp->mmio_addr;
3838 struct pci_dev *pdev = tp->pci_dev;
3839 3889
3840 RTL_W8(MaxTxPacketSize, 0x0c); 3890 RTL_W8(MaxTxPacketSize, 0x0c);
3841 RTL_W8(Config3, RTL_R8(Config3) & ~Jumbo_En0); 3891 RTL_W8(Config3, RTL_R8(Config3) & ~Jumbo_En0);
3842 RTL_W8(Config4, RTL_R8(Config4) & ~0x01); 3892 RTL_W8(Config4, RTL_R8(Config4) & ~0x01);
3843 pci_write_config_byte(pdev, 0x79, 0x50); 3893 rtl_tx_performance_tweak(tp->pci_dev, 0x5 << MAX_READ_REQUEST_SHIFT);
3844} 3894}
3845 3895
3846static void r8168b_0_hw_jumbo_enable(struct rtl8169_private *tp) 3896static void r8168b_0_hw_jumbo_enable(struct rtl8169_private *tp)
@@ -3958,8 +4008,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3958 4008
3959 dev = alloc_etherdev(sizeof (*tp)); 4009 dev = alloc_etherdev(sizeof (*tp));
3960 if (!dev) { 4010 if (!dev) {
3961 if (netif_msg_drv(&debug))
3962 dev_err(&pdev->dev, "unable to alloc new ethernet\n");
3963 rc = -ENOMEM; 4011 rc = -ENOMEM;
3964 goto out; 4012 goto out;
3965 } 4013 }
@@ -4048,11 +4096,11 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
4048 4096
4049 rtl_init_rxcfg(tp); 4097 rtl_init_rxcfg(tp);
4050 4098
4051 RTL_W16(IntrMask, 0x0000); 4099 rtl_irq_disable(tp);
4052 4100
4053 rtl_hw_reset(tp); 4101 rtl_hw_reset(tp);
4054 4102
4055 RTL_W16(IntrStatus, 0xffff); 4103 rtl_ack_events(tp, 0xffff);
4056 4104
4057 pci_set_master(pdev); 4105 pci_set_master(pdev);
4058 4106
@@ -4098,7 +4146,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
4098 tp->do_ioctl = rtl_xmii_ioctl; 4146 tp->do_ioctl = rtl_xmii_ioctl;
4099 } 4147 }
4100 4148
4101 spin_lock_init(&tp->lock); 4149 mutex_init(&tp->wk.mutex);
4102 4150
4103 /* Get MAC address */ 4151 /* Get MAC address */
4104 for (i = 0; i < ETH_ALEN; i++) 4152 for (i = 0; i < ETH_ALEN; i++)
@@ -4126,10 +4174,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
4126 /* 8110SCd requires hardware Rx VLAN - disallow toggling */ 4174 /* 8110SCd requires hardware Rx VLAN - disallow toggling */
4127 dev->hw_features &= ~NETIF_F_HW_VLAN_RX; 4175 dev->hw_features &= ~NETIF_F_HW_VLAN_RX;
4128 4176
4129 tp->intr_mask = 0xffff;
4130 tp->hw_start = cfg->hw_start; 4177 tp->hw_start = cfg->hw_start;
4131 tp->intr_event = cfg->intr_event; 4178 tp->event_slow = cfg->event_slow;
4132 tp->napi_event = cfg->napi_event;
4133 4179
4134 tp->opts1_mask = (tp->mac_version != RTL_GIGA_MAC_VER_01) ? 4180 tp->opts1_mask = (tp->mac_version != RTL_GIGA_MAC_VER_01) ?
4135 ~(RxBOVF | RxFOVF) : ~0; 4181 ~(RxBOVF | RxFOVF) : ~0;
@@ -4196,7 +4242,7 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
4196 rtl8168_driver_stop(tp); 4242 rtl8168_driver_stop(tp);
4197 } 4243 }
4198 4244
4199 cancel_delayed_work_sync(&tp->task); 4245 cancel_work_sync(&tp->wk.work);
4200 4246
4201 unregister_netdev(dev); 4247 unregister_netdev(dev);
4202 4248
@@ -4257,6 +4303,8 @@ static void rtl_request_firmware(struct rtl8169_private *tp)
4257 rtl_request_uncached_firmware(tp); 4303 rtl_request_uncached_firmware(tp);
4258} 4304}
4259 4305
4306static void rtl_task(struct work_struct *);
4307
4260static int rtl8169_open(struct net_device *dev) 4308static int rtl8169_open(struct net_device *dev)
4261{ 4309{
4262 struct rtl8169_private *tp = netdev_priv(dev); 4310 struct rtl8169_private *tp = netdev_priv(dev);
@@ -4284,7 +4332,7 @@ static int rtl8169_open(struct net_device *dev)
4284 if (retval < 0) 4332 if (retval < 0)
4285 goto err_free_rx_1; 4333 goto err_free_rx_1;
4286 4334
4287 INIT_DELAYED_WORK(&tp->task, NULL); 4335 INIT_WORK(&tp->wk.work, rtl_task);
4288 4336
4289 smp_mb(); 4337 smp_mb();
4290 4338
@@ -4296,16 +4344,24 @@ static int rtl8169_open(struct net_device *dev)
4296 if (retval < 0) 4344 if (retval < 0)
4297 goto err_release_fw_2; 4345 goto err_release_fw_2;
4298 4346
4347 rtl_lock_work(tp);
4348
4349 set_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
4350
4299 napi_enable(&tp->napi); 4351 napi_enable(&tp->napi);
4300 4352
4301 rtl8169_init_phy(dev, tp); 4353 rtl8169_init_phy(dev, tp);
4302 4354
4303 rtl8169_set_features(dev, dev->features); 4355 __rtl8169_set_features(dev, dev->features);
4304 4356
4305 rtl_pll_power_up(tp); 4357 rtl_pll_power_up(tp);
4306 4358
4307 rtl_hw_start(dev); 4359 rtl_hw_start(dev);
4308 4360
4361 netif_start_queue(dev);
4362
4363 rtl_unlock_work(tp);
4364
4309 tp->saved_wolopts = 0; 4365 tp->saved_wolopts = 0;
4310 pm_runtime_put_noidle(&pdev->dev); 4366 pm_runtime_put_noidle(&pdev->dev);
4311 4367
@@ -4379,7 +4435,7 @@ static void rtl_hw_start(struct net_device *dev)
4379 4435
4380 tp->hw_start(dev); 4436 tp->hw_start(dev);
4381 4437
4382 netif_start_queue(dev); 4438 rtl_irq_enable_all(tp);
4383} 4439}
4384 4440
4385static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp, 4441static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp,
@@ -4506,9 +4562,6 @@ static void rtl_hw_start_8169(struct net_device *dev)
4506 4562
4507 /* no early-rx interrupts */ 4563 /* no early-rx interrupts */
4508 RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000); 4564 RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000);
4509
4510 /* Enable all known interrupts by setting the interrupt mask. */
4511 RTL_W16(IntrMask, tp->intr_event);
4512} 4565}
4513 4566
4514static void rtl_csi_access_enable(void __iomem *ioaddr, u32 bits) 4567static void rtl_csi_access_enable(void __iomem *ioaddr, u32 bits)
@@ -4888,8 +4941,8 @@ static void rtl_hw_start_8168(struct net_device *dev)
4888 4941
4889 /* Work around for RxFIFO overflow. */ 4942 /* Work around for RxFIFO overflow. */
4890 if (tp->mac_version == RTL_GIGA_MAC_VER_11) { 4943 if (tp->mac_version == RTL_GIGA_MAC_VER_11) {
4891 tp->intr_event |= RxFIFOOver | PCSTimeout; 4944 tp->event_slow |= RxFIFOOver | PCSTimeout;
4892 tp->intr_event &= ~RxOverflow; 4945 tp->event_slow &= ~RxOverflow;
4893 } 4946 }
4894 4947
4895 rtl_set_rx_tx_desc_registers(tp, ioaddr); 4948 rtl_set_rx_tx_desc_registers(tp, ioaddr);
@@ -4977,8 +5030,6 @@ static void rtl_hw_start_8168(struct net_device *dev)
4977 RTL_W8(Cfg9346, Cfg9346_Lock); 5030 RTL_W8(Cfg9346, Cfg9346_Lock);
4978 5031
4979 RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000); 5032 RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000);
4980
4981 RTL_W16(IntrMask, tp->intr_event);
4982} 5033}
4983 5034
4984#define R810X_CPCMD_QUIRK_MASK (\ 5035#define R810X_CPCMD_QUIRK_MASK (\
@@ -5077,10 +5128,8 @@ static void rtl_hw_start_8101(struct net_device *dev)
5077 void __iomem *ioaddr = tp->mmio_addr; 5128 void __iomem *ioaddr = tp->mmio_addr;
5078 struct pci_dev *pdev = tp->pci_dev; 5129 struct pci_dev *pdev = tp->pci_dev;
5079 5130
5080 if (tp->mac_version >= RTL_GIGA_MAC_VER_30) { 5131 if (tp->mac_version >= RTL_GIGA_MAC_VER_30)
5081 tp->intr_event &= ~RxFIFOOver; 5132 tp->event_slow &= ~RxFIFOOver;
5082 tp->napi_event &= ~RxFIFOOver;
5083 }
5084 5133
5085 if (tp->mac_version == RTL_GIGA_MAC_VER_13 || 5134 if (tp->mac_version == RTL_GIGA_MAC_VER_13 ||
5086 tp->mac_version == RTL_GIGA_MAC_VER_16) { 5135 tp->mac_version == RTL_GIGA_MAC_VER_16) {
@@ -5136,8 +5185,6 @@ static void rtl_hw_start_8101(struct net_device *dev)
5136 rtl_set_rx_mode(dev); 5185 rtl_set_rx_mode(dev);
5137 5186
5138 RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xf000); 5187 RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xf000);
5139
5140 RTL_W16(IntrMask, tp->intr_event);
5141} 5188}
5142 5189
5143static int rtl8169_change_mtu(struct net_device *dev, int new_mtu) 5190static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
@@ -5330,92 +5377,34 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp)
5330 tp->cur_tx = tp->dirty_tx = 0; 5377 tp->cur_tx = tp->dirty_tx = 0;
5331} 5378}
5332 5379
5333static void rtl8169_schedule_work(struct net_device *dev, work_func_t task) 5380static void rtl_reset_work(struct rtl8169_private *tp)
5334{
5335 struct rtl8169_private *tp = netdev_priv(dev);
5336
5337 PREPARE_DELAYED_WORK(&tp->task, task);
5338 schedule_delayed_work(&tp->task, 4);
5339}
5340
5341static void rtl8169_wait_for_quiescence(struct net_device *dev)
5342{
5343 struct rtl8169_private *tp = netdev_priv(dev);
5344 void __iomem *ioaddr = tp->mmio_addr;
5345
5346 synchronize_irq(dev->irq);
5347
5348 /* Wait for any pending NAPI task to complete */
5349 napi_disable(&tp->napi);
5350
5351 rtl8169_irq_mask_and_ack(tp);
5352
5353 tp->intr_mask = 0xffff;
5354 RTL_W16(IntrMask, tp->intr_event);
5355 napi_enable(&tp->napi);
5356}
5357
5358static void rtl8169_reinit_task(struct work_struct *work)
5359{ 5381{
5360 struct rtl8169_private *tp =
5361 container_of(work, struct rtl8169_private, task.work);
5362 struct net_device *dev = tp->dev;
5363 int ret;
5364
5365 rtnl_lock();
5366
5367 if (!netif_running(dev))
5368 goto out_unlock;
5369
5370 rtl8169_wait_for_quiescence(dev);
5371 rtl8169_close(dev);
5372
5373 ret = rtl8169_open(dev);
5374 if (unlikely(ret < 0)) {
5375 if (net_ratelimit())
5376 netif_err(tp, drv, dev,
5377 "reinit failure (status = %d). Rescheduling\n",
5378 ret);
5379 rtl8169_schedule_work(dev, rtl8169_reinit_task);
5380 }
5381
5382out_unlock:
5383 rtnl_unlock();
5384}
5385
5386static void rtl8169_reset_task(struct work_struct *work)
5387{
5388 struct rtl8169_private *tp =
5389 container_of(work, struct rtl8169_private, task.work);
5390 struct net_device *dev = tp->dev; 5382 struct net_device *dev = tp->dev;
5391 int i; 5383 int i;
5392 5384
5393 rtnl_lock(); 5385 napi_disable(&tp->napi);
5394 5386 netif_stop_queue(dev);
5395 if (!netif_running(dev)) 5387 synchronize_sched();
5396 goto out_unlock;
5397 5388
5398 rtl8169_hw_reset(tp); 5389 rtl8169_hw_reset(tp);
5399 5390
5400 rtl8169_wait_for_quiescence(dev);
5401
5402 for (i = 0; i < NUM_RX_DESC; i++) 5391 for (i = 0; i < NUM_RX_DESC; i++)
5403 rtl8169_mark_to_asic(tp->RxDescArray + i, rx_buf_sz); 5392 rtl8169_mark_to_asic(tp->RxDescArray + i, rx_buf_sz);
5404 5393
5405 rtl8169_tx_clear(tp); 5394 rtl8169_tx_clear(tp);
5406 rtl8169_init_ring_indexes(tp); 5395 rtl8169_init_ring_indexes(tp);
5407 5396
5397 napi_enable(&tp->napi);
5408 rtl_hw_start(dev); 5398 rtl_hw_start(dev);
5409 netif_wake_queue(dev); 5399 netif_wake_queue(dev);
5410 rtl8169_check_link_status(dev, tp, tp->mmio_addr); 5400 rtl8169_check_link_status(dev, tp, tp->mmio_addr);
5411
5412out_unlock:
5413 rtnl_unlock();
5414} 5401}
5415 5402
5416static void rtl8169_tx_timeout(struct net_device *dev) 5403static void rtl8169_tx_timeout(struct net_device *dev)
5417{ 5404{
5418 rtl8169_schedule_work(dev, rtl8169_reset_task); 5405 struct rtl8169_private *tp = netdev_priv(dev);
5406
5407 rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
5419} 5408}
5420 5409
5421static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb, 5410static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb,
@@ -5552,9 +5541,22 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
5552 5541
5553 RTL_W8(TxPoll, NPQ); 5542 RTL_W8(TxPoll, NPQ);
5554 5543
5544 mmiowb();
5545
5555 if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) { 5546 if (TX_BUFFS_AVAIL(tp) < MAX_SKB_FRAGS) {
5547 /* Avoid wrongly optimistic queue wake-up: rtl_tx thread must
5548 * not miss a ring update when it notices a stopped queue.
5549 */
5550 smp_wmb();
5556 netif_stop_queue(dev); 5551 netif_stop_queue(dev);
5557 smp_rmb(); 5552 /* Sync with rtl_tx:
5553 * - publish queue status and cur_tx ring index (write barrier)
5554 * - refresh dirty_tx ring index (read barrier).
5555 * May the current thread have a pessimistic view of the ring
5556 * status and forget to wake up queue, a racing rtl_tx thread
5557 * can't.
5558 */
5559 smp_mb();
5558 if (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS) 5560 if (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS)
5559 netif_wake_queue(dev); 5561 netif_wake_queue(dev);
5560 } 5562 }
@@ -5618,12 +5620,10 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
5618 5620
5619 rtl8169_hw_reset(tp); 5621 rtl8169_hw_reset(tp);
5620 5622
5621 rtl8169_schedule_work(dev, rtl8169_reinit_task); 5623 rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
5622} 5624}
5623 5625
5624static void rtl8169_tx_interrupt(struct net_device *dev, 5626static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
5625 struct rtl8169_private *tp,
5626 void __iomem *ioaddr)
5627{ 5627{
5628 unsigned int dirty_tx, tx_left; 5628 unsigned int dirty_tx, tx_left;
5629 5629
@@ -5655,7 +5655,14 @@ static void rtl8169_tx_interrupt(struct net_device *dev,
5655 5655
5656 if (tp->dirty_tx != dirty_tx) { 5656 if (tp->dirty_tx != dirty_tx) {
5657 tp->dirty_tx = dirty_tx; 5657 tp->dirty_tx = dirty_tx;
5658 smp_wmb(); 5658 /* Sync with rtl8169_start_xmit:
5659 * - publish dirty_tx ring index (write barrier)
5660 * - refresh cur_tx ring index and queue status (read barrier)
5661 * May the current thread miss the stopped queue condition,
5662 * a racing xmit thread can only have a right view of the
5663 * ring status.
5664 */
5665 smp_mb();
5659 if (netif_queue_stopped(dev) && 5666 if (netif_queue_stopped(dev) &&
5660 (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS)) { 5667 (TX_BUFFS_AVAIL(tp) >= MAX_SKB_FRAGS)) {
5661 netif_wake_queue(dev); 5668 netif_wake_queue(dev);
@@ -5666,9 +5673,11 @@ static void rtl8169_tx_interrupt(struct net_device *dev,
5666 * of start_xmit activity is detected (if it is not detected, 5673 * of start_xmit activity is detected (if it is not detected,
5667 * it is slow enough). -- FR 5674 * it is slow enough). -- FR
5668 */ 5675 */
5669 smp_rmb(); 5676 if (tp->cur_tx != dirty_tx) {
5670 if (tp->cur_tx != dirty_tx) 5677 void __iomem *ioaddr = tp->mmio_addr;
5678
5671 RTL_W8(TxPoll, NPQ); 5679 RTL_W8(TxPoll, NPQ);
5680 }
5672 } 5681 }
5673} 5682}
5674 5683
@@ -5707,9 +5716,7 @@ static struct sk_buff *rtl8169_try_rx_copy(void *data,
5707 return skb; 5716 return skb;
5708} 5717}
5709 5718
5710static int rtl8169_rx_interrupt(struct net_device *dev, 5719static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget)
5711 struct rtl8169_private *tp,
5712 void __iomem *ioaddr, u32 budget)
5713{ 5720{
5714 unsigned int cur_rx, rx_left; 5721 unsigned int cur_rx, rx_left;
5715 unsigned int count; 5722 unsigned int count;
@@ -5737,7 +5744,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev,
5737 if (status & RxCRC) 5744 if (status & RxCRC)
5738 dev->stats.rx_crc_errors++; 5745 dev->stats.rx_crc_errors++;
5739 if (status & RxFOVF) { 5746 if (status & RxFOVF) {
5740 rtl8169_schedule_work(dev, rtl8169_reset_task); 5747 rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
5741 dev->stats.rx_fifo_errors++; 5748 dev->stats.rx_fifo_errors++;
5742 } 5749 }
5743 rtl8169_mark_to_asic(desc, rx_buf_sz); 5750 rtl8169_mark_to_asic(desc, rx_buf_sz);
@@ -5798,101 +5805,120 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
5798{ 5805{
5799 struct net_device *dev = dev_instance; 5806 struct net_device *dev = dev_instance;
5800 struct rtl8169_private *tp = netdev_priv(dev); 5807 struct rtl8169_private *tp = netdev_priv(dev);
5801 void __iomem *ioaddr = tp->mmio_addr;
5802 int handled = 0; 5808 int handled = 0;
5803 int status; 5809 u16 status;
5804 5810
5805 /* loop handling interrupts until we have no new ones or 5811 status = rtl_get_events(tp);
5806 * we hit a invalid/hotplug case. 5812 if (status && status != 0xffff) {
5807 */ 5813 status &= RTL_EVENT_NAPI | tp->event_slow;
5808 status = RTL_R16(IntrStatus); 5814 if (status) {
5809 while (status && status != 0xffff) { 5815 handled = 1;
5810 status &= tp->intr_event;
5811 if (!status)
5812 break;
5813 5816
5814 handled = 1; 5817 rtl_irq_disable(tp);
5818 napi_schedule(&tp->napi);
5819 }
5820 }
5821 return IRQ_RETVAL(handled);
5822}
5815 5823
5816 /* Handle all of the error cases first. These will reset 5824/*
5817 * the chip, so just exit the loop. 5825 * Workqueue context.
5818 */ 5826 */
5819 if (unlikely(!netif_running(dev))) { 5827static void rtl_slow_event_work(struct rtl8169_private *tp)
5820 rtl8169_hw_reset(tp); 5828{
5829 struct net_device *dev = tp->dev;
5830 u16 status;
5831
5832 status = rtl_get_events(tp) & tp->event_slow;
5833 rtl_ack_events(tp, status);
5834
5835 if (unlikely(status & RxFIFOOver)) {
5836 switch (tp->mac_version) {
5837 /* Work around for rx fifo overflow */
5838 case RTL_GIGA_MAC_VER_11:
5839 netif_stop_queue(dev);
5840 /* XXX - Hack alert. See rtl_task(). */
5841 set_bit(RTL_FLAG_TASK_RESET_PENDING, tp->wk.flags);
5842 default:
5821 break; 5843 break;
5822 } 5844 }
5845 }
5823 5846
5824 if (unlikely(status & RxFIFOOver)) { 5847 if (unlikely(status & SYSErr))
5825 switch (tp->mac_version) { 5848 rtl8169_pcierr_interrupt(dev);
5826 /* Work around for rx fifo overflow */
5827 case RTL_GIGA_MAC_VER_11:
5828 netif_stop_queue(dev);
5829 rtl8169_tx_timeout(dev);
5830 goto done;
5831 default:
5832 break;
5833 }
5834 }
5835 5849
5836 if (unlikely(status & SYSErr)) { 5850 if (status & LinkChg)
5837 rtl8169_pcierr_interrupt(dev); 5851 __rtl8169_check_link_status(dev, tp, tp->mmio_addr, true);
5838 break;
5839 }
5840 5852
5841 if (status & LinkChg) 5853 napi_disable(&tp->napi);
5842 __rtl8169_check_link_status(dev, tp, ioaddr, true); 5854 rtl_irq_disable(tp);
5843 5855
5844 /* We need to see the lastest version of tp->intr_mask to 5856 napi_enable(&tp->napi);
5845 * avoid ignoring an MSI interrupt and having to wait for 5857 napi_schedule(&tp->napi);
5846 * another event which may never come. 5858}
5847 */
5848 smp_rmb();
5849 if (status & tp->intr_mask & tp->napi_event) {
5850 RTL_W16(IntrMask, tp->intr_event & ~tp->napi_event);
5851 tp->intr_mask = ~tp->napi_event;
5852
5853 if (likely(napi_schedule_prep(&tp->napi)))
5854 __napi_schedule(&tp->napi);
5855 else
5856 netif_info(tp, intr, dev,
5857 "interrupt %04x in poll\n", status);
5858 }
5859 5859
5860 /* We only get a new MSI interrupt when all active irq 5860static void rtl_task(struct work_struct *work)
5861 * sources on the chip have been acknowledged. So, ack 5861{
5862 * everything we've seen and check if new sources have become 5862 static const struct {
5863 * active to avoid blocking all interrupts from the chip. 5863 int bitnr;
5864 */ 5864 void (*action)(struct rtl8169_private *);
5865 RTL_W16(IntrStatus, 5865 } rtl_work[] = {
5866 (status & RxFIFOOver) ? (status | RxOverflow) : status); 5866 /* XXX - keep rtl_slow_event_work() as first element. */
5867 status = RTL_R16(IntrStatus); 5867 { RTL_FLAG_TASK_SLOW_PENDING, rtl_slow_event_work },
5868 { RTL_FLAG_TASK_RESET_PENDING, rtl_reset_work },
5869 { RTL_FLAG_TASK_PHY_PENDING, rtl_phy_work }
5870 };
5871 struct rtl8169_private *tp =
5872 container_of(work, struct rtl8169_private, wk.work);
5873 struct net_device *dev = tp->dev;
5874 int i;
5875
5876 rtl_lock_work(tp);
5877
5878 if (!netif_running(dev) ||
5879 !test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags))
5880 goto out_unlock;
5881
5882 for (i = 0; i < ARRAY_SIZE(rtl_work); i++) {
5883 bool pending;
5884
5885 pending = test_and_clear_bit(rtl_work[i].bitnr, tp->wk.flags);
5886 if (pending)
5887 rtl_work[i].action(tp);
5868 } 5888 }
5869done: 5889
5870 return IRQ_RETVAL(handled); 5890out_unlock:
5891 rtl_unlock_work(tp);
5871} 5892}
5872 5893
5873static int rtl8169_poll(struct napi_struct *napi, int budget) 5894static int rtl8169_poll(struct napi_struct *napi, int budget)
5874{ 5895{
5875 struct rtl8169_private *tp = container_of(napi, struct rtl8169_private, napi); 5896 struct rtl8169_private *tp = container_of(napi, struct rtl8169_private, napi);
5876 struct net_device *dev = tp->dev; 5897 struct net_device *dev = tp->dev;
5877 void __iomem *ioaddr = tp->mmio_addr; 5898 u16 enable_mask = RTL_EVENT_NAPI | tp->event_slow;
5878 int work_done; 5899 int work_done= 0;
5900 u16 status;
5901
5902 status = rtl_get_events(tp);
5903 rtl_ack_events(tp, status & ~tp->event_slow);
5879 5904
5880 work_done = rtl8169_rx_interrupt(dev, tp, ioaddr, (u32) budget); 5905 if (status & RTL_EVENT_NAPI_RX)
5881 rtl8169_tx_interrupt(dev, tp, ioaddr); 5906 work_done = rtl_rx(dev, tp, (u32) budget);
5907
5908 if (status & RTL_EVENT_NAPI_TX)
5909 rtl_tx(dev, tp);
5910
5911 if (status & tp->event_slow) {
5912 enable_mask &= ~tp->event_slow;
5913
5914 rtl_schedule_task(tp, RTL_FLAG_TASK_SLOW_PENDING);
5915 }
5882 5916
5883 if (work_done < budget) { 5917 if (work_done < budget) {
5884 napi_complete(napi); 5918 napi_complete(napi);
5885 5919
5886 /* We need for force the visibility of tp->intr_mask 5920 rtl_irq_enable(tp, enable_mask);
5887 * for other CPUs, as we can loose an MSI interrupt 5921 mmiowb();
5888 * and potentially wait for a retransmit timeout if we don't.
5889 * The posted write to IntrMask is safe, as it will
5890 * eventually make it to the chip and we won't loose anything
5891 * until it does.
5892 */
5893 tp->intr_mask = 0xffff;
5894 wmb();
5895 RTL_W16(IntrMask, tp->intr_event);
5896 } 5922 }
5897 5923
5898 return work_done; 5924 return work_done;
@@ -5916,26 +5942,19 @@ static void rtl8169_down(struct net_device *dev)
5916 5942
5917 del_timer_sync(&tp->timer); 5943 del_timer_sync(&tp->timer);
5918 5944
5919 netif_stop_queue(dev);
5920
5921 napi_disable(&tp->napi); 5945 napi_disable(&tp->napi);
5922 5946 netif_stop_queue(dev);
5923 spin_lock_irq(&tp->lock);
5924 5947
5925 rtl8169_hw_reset(tp); 5948 rtl8169_hw_reset(tp);
5926 /* 5949 /*
5927 * At this point device interrupts can not be enabled in any function, 5950 * At this point device interrupts can not be enabled in any function,
5928 * as netif_running is not true (rtl8169_interrupt, rtl8169_reset_task, 5951 * as netif_running is not true (rtl8169_interrupt, rtl8169_reset_task)
5929 * rtl8169_reinit_task) and napi is disabled (rtl8169_poll). 5952 * and napi is disabled (rtl8169_poll).
5930 */ 5953 */
5931 rtl8169_rx_missed(dev, ioaddr); 5954 rtl8169_rx_missed(dev, ioaddr);
5932 5955
5933 spin_unlock_irq(&tp->lock);
5934
5935 synchronize_irq(dev->irq);
5936
5937 /* Give a racing hard_start_xmit a few cycles to complete. */ 5956 /* Give a racing hard_start_xmit a few cycles to complete. */
5938 synchronize_sched(); /* FIXME: should this be synchronize_irq()? */ 5957 synchronize_sched();
5939 5958
5940 rtl8169_tx_clear(tp); 5959 rtl8169_tx_clear(tp);
5941 5960
@@ -5954,7 +5973,11 @@ static int rtl8169_close(struct net_device *dev)
5954 /* Update counters before going down */ 5973 /* Update counters before going down */
5955 rtl8169_update_counters(dev); 5974 rtl8169_update_counters(dev);
5956 5975
5976 rtl_lock_work(tp);
5977 clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
5978
5957 rtl8169_down(dev); 5979 rtl8169_down(dev);
5980 rtl_unlock_work(tp);
5958 5981
5959 free_irq(dev->irq, dev); 5982 free_irq(dev->irq, dev);
5960 5983
@@ -5974,7 +5997,6 @@ static void rtl_set_rx_mode(struct net_device *dev)
5974{ 5997{
5975 struct rtl8169_private *tp = netdev_priv(dev); 5998 struct rtl8169_private *tp = netdev_priv(dev);
5976 void __iomem *ioaddr = tp->mmio_addr; 5999 void __iomem *ioaddr = tp->mmio_addr;
5977 unsigned long flags;
5978 u32 mc_filter[2]; /* Multicast hash filter */ 6000 u32 mc_filter[2]; /* Multicast hash filter */
5979 int rx_mode; 6001 int rx_mode;
5980 u32 tmp = 0; 6002 u32 tmp = 0;
@@ -6003,8 +6025,6 @@ static void rtl_set_rx_mode(struct net_device *dev)
6003 } 6025 }
6004 } 6026 }
6005 6027
6006 spin_lock_irqsave(&tp->lock, flags);
6007
6008 tmp = (RTL_R32(RxConfig) & ~RX_CONFIG_ACCEPT_MASK) | rx_mode; 6028 tmp = (RTL_R32(RxConfig) & ~RX_CONFIG_ACCEPT_MASK) | rx_mode;
6009 6029
6010 if (tp->mac_version > RTL_GIGA_MAC_VER_06) { 6030 if (tp->mac_version > RTL_GIGA_MAC_VER_06) {
@@ -6018,8 +6038,6 @@ static void rtl_set_rx_mode(struct net_device *dev)
6018 RTL_W32(MAR0 + 0, mc_filter[0]); 6038 RTL_W32(MAR0 + 0, mc_filter[0]);
6019 6039
6020 RTL_W32(RxConfig, tmp); 6040 RTL_W32(RxConfig, tmp);
6021
6022 spin_unlock_irqrestore(&tp->lock, flags);
6023} 6041}
6024 6042
6025/** 6043/**
@@ -6032,13 +6050,9 @@ static struct net_device_stats *rtl8169_get_stats(struct net_device *dev)
6032{ 6050{
6033 struct rtl8169_private *tp = netdev_priv(dev); 6051 struct rtl8169_private *tp = netdev_priv(dev);
6034 void __iomem *ioaddr = tp->mmio_addr; 6052 void __iomem *ioaddr = tp->mmio_addr;
6035 unsigned long flags;
6036 6053
6037 if (netif_running(dev)) { 6054 if (netif_running(dev))
6038 spin_lock_irqsave(&tp->lock, flags);
6039 rtl8169_rx_missed(dev, ioaddr); 6055 rtl8169_rx_missed(dev, ioaddr);
6040 spin_unlock_irqrestore(&tp->lock, flags);
6041 }
6042 6056
6043 return &dev->stats; 6057 return &dev->stats;
6044} 6058}
@@ -6050,10 +6064,15 @@ static void rtl8169_net_suspend(struct net_device *dev)
6050 if (!netif_running(dev)) 6064 if (!netif_running(dev))
6051 return; 6065 return;
6052 6066
6053 rtl_pll_power_down(tp);
6054
6055 netif_device_detach(dev); 6067 netif_device_detach(dev);
6056 netif_stop_queue(dev); 6068 netif_stop_queue(dev);
6069
6070 rtl_lock_work(tp);
6071 napi_disable(&tp->napi);
6072 clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
6073 rtl_unlock_work(tp);
6074
6075 rtl_pll_power_down(tp);
6057} 6076}
6058 6077
6059#ifdef CONFIG_PM 6078#ifdef CONFIG_PM
@@ -6076,7 +6095,9 @@ static void __rtl8169_resume(struct net_device *dev)
6076 6095
6077 rtl_pll_power_up(tp); 6096 rtl_pll_power_up(tp);
6078 6097
6079 rtl8169_schedule_work(dev, rtl8169_reset_task); 6098 set_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
6099
6100 rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
6080} 6101}
6081 6102
6082static int rtl8169_resume(struct device *device) 6103static int rtl8169_resume(struct device *device)
@@ -6102,10 +6123,10 @@ static int rtl8169_runtime_suspend(struct device *device)
6102 if (!tp->TxDescArray) 6123 if (!tp->TxDescArray)
6103 return 0; 6124 return 0;
6104 6125
6105 spin_lock_irq(&tp->lock); 6126 rtl_lock_work(tp);
6106 tp->saved_wolopts = __rtl8169_get_wol(tp); 6127 tp->saved_wolopts = __rtl8169_get_wol(tp);
6107 __rtl8169_set_wol(tp, WAKE_ANY); 6128 __rtl8169_set_wol(tp, WAKE_ANY);
6108 spin_unlock_irq(&tp->lock); 6129 rtl_unlock_work(tp);
6109 6130
6110 rtl8169_net_suspend(dev); 6131 rtl8169_net_suspend(dev);
6111 6132
@@ -6121,10 +6142,10 @@ static int rtl8169_runtime_resume(struct device *device)
6121 if (!tp->TxDescArray) 6142 if (!tp->TxDescArray)
6122 return 0; 6143 return 0;
6123 6144
6124 spin_lock_irq(&tp->lock); 6145 rtl_lock_work(tp);
6125 __rtl8169_set_wol(tp, tp->saved_wolopts); 6146 __rtl8169_set_wol(tp, tp->saved_wolopts);
6126 tp->saved_wolopts = 0; 6147 tp->saved_wolopts = 0;
6127 spin_unlock_irq(&tp->lock); 6148 rtl_unlock_work(tp);
6128 6149
6129 rtl8169_init_phy(dev, tp); 6150 rtl8169_init_phy(dev, tp);
6130 6151
@@ -6192,12 +6213,8 @@ static void rtl_shutdown(struct pci_dev *pdev)
6192 /* Restore original MAC address */ 6213 /* Restore original MAC address */
6193 rtl_rar_set(tp, dev->perm_addr); 6214 rtl_rar_set(tp, dev->perm_addr);
6194 6215
6195 spin_lock_irq(&tp->lock);
6196
6197 rtl8169_hw_reset(tp); 6216 rtl8169_hw_reset(tp);
6198 6217
6199 spin_unlock_irq(&tp->lock);
6200
6201 if (system_state == SYSTEM_POWER_OFF) { 6218 if (system_state == SYSTEM_POWER_OFF) {
6202 if (__rtl8169_get_wol(tp) & WAKE_ANY) { 6219 if (__rtl8169_get_wol(tp) & WAKE_ANY) {
6203 rtl_wol_suspend_quirk(tp); 6220 rtl_wol_suspend_quirk(tp);
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 87b650131774..cfad09107054 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -654,13 +654,12 @@ static void sh_eth_ring_format(struct net_device *ndev)
654 for (i = 0; i < RX_RING_SIZE; i++) { 654 for (i = 0; i < RX_RING_SIZE; i++) {
655 /* skb */ 655 /* skb */
656 mdp->rx_skbuff[i] = NULL; 656 mdp->rx_skbuff[i] = NULL;
657 skb = dev_alloc_skb(mdp->rx_buf_sz); 657 skb = netdev_alloc_skb(ndev, mdp->rx_buf_sz);
658 mdp->rx_skbuff[i] = skb; 658 mdp->rx_skbuff[i] = skb;
659 if (skb == NULL) 659 if (skb == NULL)
660 break; 660 break;
661 dma_map_single(&ndev->dev, skb->tail, mdp->rx_buf_sz, 661 dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz,
662 DMA_FROM_DEVICE); 662 DMA_FROM_DEVICE);
663 skb->dev = ndev; /* Mark as being used by this device. */
664 sh_eth_set_receive_align(skb); 663 sh_eth_set_receive_align(skb);
665 664
666 /* RX descriptor */ 665 /* RX descriptor */
@@ -883,8 +882,8 @@ static int sh_eth_txfree(struct net_device *ndev)
883 if (entry >= TX_RING_SIZE - 1) 882 if (entry >= TX_RING_SIZE - 1)
884 txdesc->status |= cpu_to_edmac(mdp, TD_TDLE); 883 txdesc->status |= cpu_to_edmac(mdp, TD_TDLE);
885 884
886 mdp->stats.tx_packets++; 885 ndev->stats.tx_packets++;
887 mdp->stats.tx_bytes += txdesc->buffer_length; 886 ndev->stats.tx_bytes += txdesc->buffer_length;
888 } 887 }
889 return freeNum; 888 return freeNum;
890} 889}
@@ -910,23 +909,23 @@ static int sh_eth_rx(struct net_device *ndev)
910 break; 909 break;
911 910
912 if (!(desc_status & RDFEND)) 911 if (!(desc_status & RDFEND))
913 mdp->stats.rx_length_errors++; 912 ndev->stats.rx_length_errors++;
914 913
915 if (desc_status & (RD_RFS1 | RD_RFS2 | RD_RFS3 | RD_RFS4 | 914 if (desc_status & (RD_RFS1 | RD_RFS2 | RD_RFS3 | RD_RFS4 |
916 RD_RFS5 | RD_RFS6 | RD_RFS10)) { 915 RD_RFS5 | RD_RFS6 | RD_RFS10)) {
917 mdp->stats.rx_errors++; 916 ndev->stats.rx_errors++;
918 if (desc_status & RD_RFS1) 917 if (desc_status & RD_RFS1)
919 mdp->stats.rx_crc_errors++; 918 ndev->stats.rx_crc_errors++;
920 if (desc_status & RD_RFS2) 919 if (desc_status & RD_RFS2)
921 mdp->stats.rx_frame_errors++; 920 ndev->stats.rx_frame_errors++;
922 if (desc_status & RD_RFS3) 921 if (desc_status & RD_RFS3)
923 mdp->stats.rx_length_errors++; 922 ndev->stats.rx_length_errors++;
924 if (desc_status & RD_RFS4) 923 if (desc_status & RD_RFS4)
925 mdp->stats.rx_length_errors++; 924 ndev->stats.rx_length_errors++;
926 if (desc_status & RD_RFS6) 925 if (desc_status & RD_RFS6)
927 mdp->stats.rx_missed_errors++; 926 ndev->stats.rx_missed_errors++;
928 if (desc_status & RD_RFS10) 927 if (desc_status & RD_RFS10)
929 mdp->stats.rx_over_errors++; 928 ndev->stats.rx_over_errors++;
930 } else { 929 } else {
931 if (!mdp->cd->hw_swap) 930 if (!mdp->cd->hw_swap)
932 sh_eth_soft_swap( 931 sh_eth_soft_swap(
@@ -939,8 +938,8 @@ static int sh_eth_rx(struct net_device *ndev)
939 skb_put(skb, pkt_len); 938 skb_put(skb, pkt_len);
940 skb->protocol = eth_type_trans(skb, ndev); 939 skb->protocol = eth_type_trans(skb, ndev);
941 netif_rx(skb); 940 netif_rx(skb);
942 mdp->stats.rx_packets++; 941 ndev->stats.rx_packets++;
943 mdp->stats.rx_bytes += pkt_len; 942 ndev->stats.rx_bytes += pkt_len;
944 } 943 }
945 rxdesc->status |= cpu_to_edmac(mdp, RD_RACT); 944 rxdesc->status |= cpu_to_edmac(mdp, RD_RACT);
946 entry = (++mdp->cur_rx) % RX_RING_SIZE; 945 entry = (++mdp->cur_rx) % RX_RING_SIZE;
@@ -955,13 +954,12 @@ static int sh_eth_rx(struct net_device *ndev)
955 rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16); 954 rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 16);
956 955
957 if (mdp->rx_skbuff[entry] == NULL) { 956 if (mdp->rx_skbuff[entry] == NULL) {
958 skb = dev_alloc_skb(mdp->rx_buf_sz); 957 skb = netdev_alloc_skb(ndev, mdp->rx_buf_sz);
959 mdp->rx_skbuff[entry] = skb; 958 mdp->rx_skbuff[entry] = skb;
960 if (skb == NULL) 959 if (skb == NULL)
961 break; /* Better luck next round. */ 960 break; /* Better luck next round. */
962 dma_map_single(&ndev->dev, skb->tail, mdp->rx_buf_sz, 961 dma_map_single(&ndev->dev, skb->data, mdp->rx_buf_sz,
963 DMA_FROM_DEVICE); 962 DMA_FROM_DEVICE);
964 skb->dev = ndev;
965 sh_eth_set_receive_align(skb); 963 sh_eth_set_receive_align(skb);
966 964
967 skb_checksum_none_assert(skb); 965 skb_checksum_none_assert(skb);
@@ -1009,7 +1007,7 @@ static void sh_eth_error(struct net_device *ndev, int intr_status)
1009 felic_stat = sh_eth_read(ndev, ECSR); 1007 felic_stat = sh_eth_read(ndev, ECSR);
1010 sh_eth_write(ndev, felic_stat, ECSR); /* clear int */ 1008 sh_eth_write(ndev, felic_stat, ECSR); /* clear int */
1011 if (felic_stat & ECSR_ICD) 1009 if (felic_stat & ECSR_ICD)
1012 mdp->stats.tx_carrier_errors++; 1010 ndev->stats.tx_carrier_errors++;
1013 if (felic_stat & ECSR_LCHNG) { 1011 if (felic_stat & ECSR_LCHNG) {
1014 /* Link Changed */ 1012 /* Link Changed */
1015 if (mdp->cd->no_psr || mdp->no_ether_link) { 1013 if (mdp->cd->no_psr || mdp->no_ether_link) {
@@ -1042,7 +1040,7 @@ static void sh_eth_error(struct net_device *ndev, int intr_status)
1042 if (intr_status & EESR_TWB) { 1040 if (intr_status & EESR_TWB) {
1043 /* Write buck end. unused write back interrupt */ 1041 /* Write buck end. unused write back interrupt */
1044 if (intr_status & EESR_TABT) /* Transmit Abort int */ 1042 if (intr_status & EESR_TABT) /* Transmit Abort int */
1045 mdp->stats.tx_aborted_errors++; 1043 ndev->stats.tx_aborted_errors++;
1046 if (netif_msg_tx_err(mdp)) 1044 if (netif_msg_tx_err(mdp))
1047 dev_err(&ndev->dev, "Transmit Abort\n"); 1045 dev_err(&ndev->dev, "Transmit Abort\n");
1048 } 1046 }
@@ -1051,7 +1049,7 @@ static void sh_eth_error(struct net_device *ndev, int intr_status)
1051 /* Receive Abort int */ 1049 /* Receive Abort int */
1052 if (intr_status & EESR_RFRMER) { 1050 if (intr_status & EESR_RFRMER) {
1053 /* Receive Frame Overflow int */ 1051 /* Receive Frame Overflow int */
1054 mdp->stats.rx_frame_errors++; 1052 ndev->stats.rx_frame_errors++;
1055 if (netif_msg_rx_err(mdp)) 1053 if (netif_msg_rx_err(mdp))
1056 dev_err(&ndev->dev, "Receive Abort\n"); 1054 dev_err(&ndev->dev, "Receive Abort\n");
1057 } 1055 }
@@ -1059,21 +1057,21 @@ static void sh_eth_error(struct net_device *ndev, int intr_status)
1059 1057
1060 if (intr_status & EESR_TDE) { 1058 if (intr_status & EESR_TDE) {
1061 /* Transmit Descriptor Empty int */ 1059 /* Transmit Descriptor Empty int */
1062 mdp->stats.tx_fifo_errors++; 1060 ndev->stats.tx_fifo_errors++;
1063 if (netif_msg_tx_err(mdp)) 1061 if (netif_msg_tx_err(mdp))
1064 dev_err(&ndev->dev, "Transmit Descriptor Empty\n"); 1062 dev_err(&ndev->dev, "Transmit Descriptor Empty\n");
1065 } 1063 }
1066 1064
1067 if (intr_status & EESR_TFE) { 1065 if (intr_status & EESR_TFE) {
1068 /* FIFO under flow */ 1066 /* FIFO under flow */
1069 mdp->stats.tx_fifo_errors++; 1067 ndev->stats.tx_fifo_errors++;
1070 if (netif_msg_tx_err(mdp)) 1068 if (netif_msg_tx_err(mdp))
1071 dev_err(&ndev->dev, "Transmit FIFO Under flow\n"); 1069 dev_err(&ndev->dev, "Transmit FIFO Under flow\n");
1072 } 1070 }
1073 1071
1074 if (intr_status & EESR_RDE) { 1072 if (intr_status & EESR_RDE) {
1075 /* Receive Descriptor Empty int */ 1073 /* Receive Descriptor Empty int */
1076 mdp->stats.rx_over_errors++; 1074 ndev->stats.rx_over_errors++;
1077 1075
1078 if (sh_eth_read(ndev, EDRRR) ^ EDRRR_R) 1076 if (sh_eth_read(ndev, EDRRR) ^ EDRRR_R)
1079 sh_eth_write(ndev, EDRRR_R, EDRRR); 1077 sh_eth_write(ndev, EDRRR_R, EDRRR);
@@ -1083,14 +1081,14 @@ static void sh_eth_error(struct net_device *ndev, int intr_status)
1083 1081
1084 if (intr_status & EESR_RFE) { 1082 if (intr_status & EESR_RFE) {
1085 /* Receive FIFO Overflow int */ 1083 /* Receive FIFO Overflow int */
1086 mdp->stats.rx_fifo_errors++; 1084 ndev->stats.rx_fifo_errors++;
1087 if (netif_msg_rx_err(mdp)) 1085 if (netif_msg_rx_err(mdp))
1088 dev_err(&ndev->dev, "Receive FIFO Overflow\n"); 1086 dev_err(&ndev->dev, "Receive FIFO Overflow\n");
1089 } 1087 }
1090 1088
1091 if (!mdp->cd->no_ade && (intr_status & EESR_ADE)) { 1089 if (!mdp->cd->no_ade && (intr_status & EESR_ADE)) {
1092 /* Address Error */ 1090 /* Address Error */
1093 mdp->stats.tx_fifo_errors++; 1091 ndev->stats.tx_fifo_errors++;
1094 if (netif_msg_tx_err(mdp)) 1092 if (netif_msg_tx_err(mdp))
1095 dev_err(&ndev->dev, "Address Error\n"); 1093 dev_err(&ndev->dev, "Address Error\n");
1096 } 1094 }
@@ -1447,7 +1445,7 @@ static void sh_eth_tx_timeout(struct net_device *ndev)
1447 " resetting...\n", ndev->name, (int)sh_eth_read(ndev, EESR)); 1445 " resetting...\n", ndev->name, (int)sh_eth_read(ndev, EESR));
1448 1446
1449 /* tx_errors count up */ 1447 /* tx_errors count up */
1450 mdp->stats.tx_errors++; 1448 ndev->stats.tx_errors++;
1451 1449
1452 /* timer off */ 1450 /* timer off */
1453 del_timer_sync(&mdp->timer); 1451 del_timer_sync(&mdp->timer);
@@ -1569,27 +1567,27 @@ static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev)
1569 1567
1570 pm_runtime_get_sync(&mdp->pdev->dev); 1568 pm_runtime_get_sync(&mdp->pdev->dev);
1571 1569
1572 mdp->stats.tx_dropped += sh_eth_read(ndev, TROCR); 1570 ndev->stats.tx_dropped += sh_eth_read(ndev, TROCR);
1573 sh_eth_write(ndev, 0, TROCR); /* (write clear) */ 1571 sh_eth_write(ndev, 0, TROCR); /* (write clear) */
1574 mdp->stats.collisions += sh_eth_read(ndev, CDCR); 1572 ndev->stats.collisions += sh_eth_read(ndev, CDCR);
1575 sh_eth_write(ndev, 0, CDCR); /* (write clear) */ 1573 sh_eth_write(ndev, 0, CDCR); /* (write clear) */
1576 mdp->stats.tx_carrier_errors += sh_eth_read(ndev, LCCR); 1574 ndev->stats.tx_carrier_errors += sh_eth_read(ndev, LCCR);
1577 sh_eth_write(ndev, 0, LCCR); /* (write clear) */ 1575 sh_eth_write(ndev, 0, LCCR); /* (write clear) */
1578 if (sh_eth_is_gether(mdp)) { 1576 if (sh_eth_is_gether(mdp)) {
1579 mdp->stats.tx_carrier_errors += sh_eth_read(ndev, CERCR); 1577 ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CERCR);
1580 sh_eth_write(ndev, 0, CERCR); /* (write clear) */ 1578 sh_eth_write(ndev, 0, CERCR); /* (write clear) */
1581 mdp->stats.tx_carrier_errors += sh_eth_read(ndev, CEECR); 1579 ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CEECR);
1582 sh_eth_write(ndev, 0, CEECR); /* (write clear) */ 1580 sh_eth_write(ndev, 0, CEECR); /* (write clear) */
1583 } else { 1581 } else {
1584 mdp->stats.tx_carrier_errors += sh_eth_read(ndev, CNDCR); 1582 ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CNDCR);
1585 sh_eth_write(ndev, 0, CNDCR); /* (write clear) */ 1583 sh_eth_write(ndev, 0, CNDCR); /* (write clear) */
1586 } 1584 }
1587 pm_runtime_put_sync(&mdp->pdev->dev); 1585 pm_runtime_put_sync(&mdp->pdev->dev);
1588 1586
1589 return &mdp->stats; 1587 return &ndev->stats;
1590} 1588}
1591 1589
1592/* ioctl to device funciotn*/ 1590/* ioctl to device function */
1593static int sh_eth_do_ioctl(struct net_device *ndev, struct ifreq *rq, 1591static int sh_eth_do_ioctl(struct net_device *ndev, struct ifreq *rq,
1594 int cmd) 1592 int cmd)
1595{ 1593{
@@ -1794,7 +1792,6 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
1794 1792
1795 ndev = alloc_etherdev(sizeof(struct sh_eth_private)); 1793 ndev = alloc_etherdev(sizeof(struct sh_eth_private));
1796 if (!ndev) { 1794 if (!ndev) {
1797 dev_err(&pdev->dev, "Could not allocate device.\n");
1798 ret = -ENOMEM; 1795 ret = -ENOMEM;
1799 goto out; 1796 goto out;
1800 } 1797 }
diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h
index cdbd844662a7..cb07add8638f 100644
--- a/drivers/net/ethernet/renesas/sh_eth.h
+++ b/drivers/net/ethernet/renesas/sh_eth.h
@@ -759,7 +759,6 @@ struct sh_eth_private {
759 struct sh_eth_txdesc *tx_ring; 759 struct sh_eth_txdesc *tx_ring;
760 struct sk_buff **rx_skbuff; 760 struct sk_buff **rx_skbuff;
761 struct sk_buff **tx_skbuff; 761 struct sk_buff **tx_skbuff;
762 struct net_device_stats stats;
763 struct timer_list timer; 762 struct timer_list timer;
764 spinlock_t lock; 763 spinlock_t lock;
765 u32 cur_rx, dirty_rx; /* Producer/consumer ring indices */ 764 u32 cur_rx, dirty_rx; /* Producer/consumer ring indices */
diff --git a/drivers/net/ethernet/s6gmac.c b/drivers/net/ethernet/s6gmac.c
index 22e9c0181ce8..1895605abb35 100644
--- a/drivers/net/ethernet/s6gmac.c
+++ b/drivers/net/ethernet/s6gmac.c
@@ -370,12 +370,13 @@ struct s6gmac {
370 } link; 370 } link;
371}; 371};
372 372
373static void s6gmac_rx_fillfifo(struct s6gmac *pd) 373static void s6gmac_rx_fillfifo(struct net_device *dev)
374{ 374{
375 struct s6gmac *pd = netdev_priv(dev);
375 struct sk_buff *skb; 376 struct sk_buff *skb;
376 while ((((u8)(pd->rx_skb_i - pd->rx_skb_o)) < S6_NUM_RX_SKB) && 377 while ((((u8)(pd->rx_skb_i - pd->rx_skb_o)) < S6_NUM_RX_SKB) &&
377 (!s6dmac_fifo_full(pd->rx_dma, pd->rx_chan)) && 378 (!s6dmac_fifo_full(pd->rx_dma, pd->rx_chan)) &&
378 (skb = dev_alloc_skb(S6_MAX_FRLEN + 2))) { 379 (skb = netdev_alloc_skb(dev, S6_MAX_FRLEN + 2))) {
379 pd->rx_skb[(pd->rx_skb_i++) % S6_NUM_RX_SKB] = skb; 380 pd->rx_skb[(pd->rx_skb_i++) % S6_NUM_RX_SKB] = skb;
380 s6dmac_put_fifo_cache(pd->rx_dma, pd->rx_chan, 381 s6dmac_put_fifo_cache(pd->rx_dma, pd->rx_chan,
381 pd->io, (u32)skb->data, S6_MAX_FRLEN); 382 pd->io, (u32)skb->data, S6_MAX_FRLEN);
@@ -514,7 +515,7 @@ static irqreturn_t s6gmac_interrupt(int irq, void *dev_id)
514 spin_lock(&pd->lock); 515 spin_lock(&pd->lock);
515 if (s6dmac_termcnt_irq(pd->rx_dma, pd->rx_chan)) 516 if (s6dmac_termcnt_irq(pd->rx_dma, pd->rx_chan))
516 s6gmac_rx_interrupt(dev); 517 s6gmac_rx_interrupt(dev);
517 s6gmac_rx_fillfifo(pd); 518 s6gmac_rx_fillfifo(dev);
518 if (s6dmac_termcnt_irq(pd->tx_dma, pd->tx_chan)) 519 if (s6dmac_termcnt_irq(pd->tx_dma, pd->tx_chan))
519 s6gmac_tx_interrupt(dev); 520 s6gmac_tx_interrupt(dev);
520 s6gmac_stats_interrupt(pd, 0); 521 s6gmac_stats_interrupt(pd, 0);
@@ -894,7 +895,7 @@ static int s6gmac_open(struct net_device *dev)
894 s6gmac_init_device(dev); 895 s6gmac_init_device(dev);
895 s6gmac_init_stats(dev); 896 s6gmac_init_stats(dev);
896 s6gmac_init_dmac(dev); 897 s6gmac_init_dmac(dev);
897 s6gmac_rx_fillfifo(pd); 898 s6gmac_rx_fillfifo(dev);
898 s6dmac_enable_chan(pd->rx_dma, pd->rx_chan, 899 s6dmac_enable_chan(pd->rx_dma, pd->rx_chan,
899 2, 1, 0, 1, 0, 0, 0, 7, -1, 2, 0, 1); 900 2, 1, 0, 1, 0, 0, 0, 7, -1, 2, 0, 1);
900 s6dmac_enable_chan(pd->tx_dma, pd->tx_chan, 901 s6dmac_enable_chan(pd->tx_dma, pd->tx_chan,
@@ -960,11 +961,11 @@ static int __devinit s6gmac_probe(struct platform_device *pdev)
960 int res; 961 int res;
961 unsigned long i; 962 unsigned long i;
962 struct mii_bus *mb; 963 struct mii_bus *mb;
964
963 dev = alloc_etherdev(sizeof(*pd)); 965 dev = alloc_etherdev(sizeof(*pd));
964 if (!dev) { 966 if (!dev)
965 printk(KERN_ERR DRV_PRMT "etherdev alloc failed, aborting.\n");
966 return -ENOMEM; 967 return -ENOMEM;
967 } 968
968 dev->open = s6gmac_open; 969 dev->open = s6gmac_open;
969 dev->stop = s6gmac_stop; 970 dev->stop = s6gmac_stop;
970 dev->hard_start_xmit = s6gmac_tx; 971 dev->hard_start_xmit = s6gmac_tx;
diff --git a/drivers/net/ethernet/seeq/ether3.c b/drivers/net/ethernet/seeq/ether3.c
index 893c880dadf0..7b819bd8c416 100644
--- a/drivers/net/ethernet/seeq/ether3.c
+++ b/drivers/net/ethernet/seeq/ether3.c
@@ -643,7 +643,7 @@ if (next_ptr < RX_START || next_ptr >= RX_END) {
643 if (next_ptr <= this_ptr) 643 if (next_ptr <= this_ptr)
644 length += RX_END - RX_START; 644 length += RX_END - RX_START;
645 645
646 skb = dev_alloc_skb(length + 2); 646 skb = netdev_alloc_skb(dev, length + 2);
647 if (skb) { 647 if (skb) {
648 unsigned char *buf; 648 unsigned char *buf;
649 649
diff --git a/drivers/net/ethernet/seeq/seeq8005.c b/drivers/net/ethernet/seeq/seeq8005.c
index 60561451789b..798990774446 100644
--- a/drivers/net/ethernet/seeq/seeq8005.c
+++ b/drivers/net/ethernet/seeq/seeq8005.c
@@ -548,7 +548,7 @@ static void seeq8005_rx(struct net_device *dev)
548 struct sk_buff *skb; 548 struct sk_buff *skb;
549 unsigned char *buf; 549 unsigned char *buf;
550 550
551 skb = dev_alloc_skb(pkt_len); 551 skb = netdev_alloc_skb(dev, pkt_len);
552 if (skb == NULL) { 552 if (skb == NULL) {
553 printk("%s: Memory squeeze, dropping packet.\n", dev->name); 553 printk("%s: Memory squeeze, dropping packet.\n", dev->name);
554 dev->stats.rx_dropped++; 554 dev->stats.rx_dropped++;
diff --git a/drivers/net/ethernet/seeq/sgiseeq.c b/drivers/net/ethernet/seeq/sgiseeq.c
index f955a19eb22f..bb8c8222122b 100644
--- a/drivers/net/ethernet/seeq/sgiseeq.c
+++ b/drivers/net/ethernet/seeq/sgiseeq.c
@@ -733,7 +733,6 @@ static int __devinit sgiseeq_probe(struct platform_device *pdev)
733 733
734 dev = alloc_etherdev(sizeof (struct sgiseeq_private)); 734 dev = alloc_etherdev(sizeof (struct sgiseeq_private));
735 if (!dev) { 735 if (!dev) {
736 printk(KERN_ERR "Sgiseeq: Etherdev alloc failed, aborting.\n");
737 err = -ENOMEM; 736 err = -ENOMEM;
738 goto err_out; 737 goto err_out;
739 } 738 }
diff --git a/drivers/net/ethernet/sfc/Kconfig b/drivers/net/ethernet/sfc/Kconfig
index 5d18841f0f3d..8d423544a7e6 100644
--- a/drivers/net/ethernet/sfc/Kconfig
+++ b/drivers/net/ethernet/sfc/Kconfig
@@ -16,6 +16,13 @@ config SFC_MTD
16 depends on SFC && MTD && !(SFC=y && MTD=m) 16 depends on SFC && MTD && !(SFC=y && MTD=m)
17 default y 17 default y
18 ---help--- 18 ---help---
19 This exposes the on-board flash memory as MTD devices (e.g. 19 This exposes the on-board flash and/or EEPROM as MTD devices
20 /dev/mtd1). This makes it possible to upload new firmware 20 (e.g. /dev/mtd1). This is required to update the firmware or
21 to the NIC. 21 the boot configuration under Linux.
22config SFC_MCDI_MON
23 bool "Solarflare SFC9000-family hwmon support"
24 depends on SFC && HWMON && !(SFC=y && HWMON=m)
25 default y
26 ----help---
27 This exposes the on-board firmware-managed sensors as a
28 hardware monitor device.
diff --git a/drivers/net/ethernet/sfc/Makefile b/drivers/net/ethernet/sfc/Makefile
index ab31c7124db1..3fa2e25ccc45 100644
--- a/drivers/net/ethernet/sfc/Makefile
+++ b/drivers/net/ethernet/sfc/Makefile
@@ -2,7 +2,7 @@ sfc-y += efx.o nic.o falcon.o siena.o tx.o rx.o filter.o \
2 falcon_xmac.o mcdi_mac.o \ 2 falcon_xmac.o mcdi_mac.o \
3 selftest.o ethtool.o qt202x_phy.o mdio_10g.o \ 3 selftest.o ethtool.o qt202x_phy.o mdio_10g.o \
4 tenxpress.o txc43128_phy.o falcon_boards.o \ 4 tenxpress.o txc43128_phy.o falcon_boards.o \
5 mcdi.o mcdi_phy.o 5 mcdi.o mcdi_phy.o mcdi_mon.o
6sfc-$(CONFIG_SFC_MTD) += mtd.o 6sfc-$(CONFIG_SFC_MTD) += mtd.o
7 7
8obj-$(CONFIG_SFC) += sfc.o 8obj-$(CONFIG_SFC) += sfc.o
diff --git a/drivers/net/ethernet/sfc/bitfield.h b/drivers/net/ethernet/sfc/bitfield.h
index 098ac2ad757d..a2a9f40b90cf 100644
--- a/drivers/net/ethernet/sfc/bitfield.h
+++ b/drivers/net/ethernet/sfc/bitfield.h
@@ -448,40 +448,40 @@ typedef union efx_oword {
448 EFX_INSERT32(min, max, low, high, EFX_MASK32(high + 1 - low)) 448 EFX_INSERT32(min, max, low, high, EFX_MASK32(high + 1 - low))
449 449
450#define EFX_SET_OWORD64(oword, low, high, value) do { \ 450#define EFX_SET_OWORD64(oword, low, high, value) do { \
451 (oword).u64[0] = (((oword).u64[0] \ 451 (oword).u64[0] = (((oword).u64[0] \
452 & ~EFX_INPLACE_MASK64(0, 63, low, high)) \ 452 & ~EFX_INPLACE_MASK64(0, 63, low, high)) \
453 | EFX_INSERT64(0, 63, low, high, value)); \ 453 | EFX_INSERT64(0, 63, low, high, value)); \
454 (oword).u64[1] = (((oword).u64[1] \ 454 (oword).u64[1] = (((oword).u64[1] \
455 & ~EFX_INPLACE_MASK64(64, 127, low, high)) \ 455 & ~EFX_INPLACE_MASK64(64, 127, low, high)) \
456 | EFX_INSERT64(64, 127, low, high, value)); \ 456 | EFX_INSERT64(64, 127, low, high, value)); \
457 } while (0) 457 } while (0)
458 458
459#define EFX_SET_QWORD64(qword, low, high, value) do { \ 459#define EFX_SET_QWORD64(qword, low, high, value) do { \
460 (qword).u64[0] = (((qword).u64[0] \ 460 (qword).u64[0] = (((qword).u64[0] \
461 & ~EFX_INPLACE_MASK64(0, 63, low, high)) \ 461 & ~EFX_INPLACE_MASK64(0, 63, low, high)) \
462 | EFX_INSERT64(0, 63, low, high, value)); \ 462 | EFX_INSERT64(0, 63, low, high, value)); \
463 } while (0) 463 } while (0)
464 464
465#define EFX_SET_OWORD32(oword, low, high, value) do { \ 465#define EFX_SET_OWORD32(oword, low, high, value) do { \
466 (oword).u32[0] = (((oword).u32[0] \ 466 (oword).u32[0] = (((oword).u32[0] \
467 & ~EFX_INPLACE_MASK32(0, 31, low, high)) \ 467 & ~EFX_INPLACE_MASK32(0, 31, low, high)) \
468 | EFX_INSERT32(0, 31, low, high, value)); \ 468 | EFX_INSERT32(0, 31, low, high, value)); \
469 (oword).u32[1] = (((oword).u32[1] \ 469 (oword).u32[1] = (((oword).u32[1] \
470 & ~EFX_INPLACE_MASK32(32, 63, low, high)) \ 470 & ~EFX_INPLACE_MASK32(32, 63, low, high)) \
471 | EFX_INSERT32(32, 63, low, high, value)); \ 471 | EFX_INSERT32(32, 63, low, high, value)); \
472 (oword).u32[2] = (((oword).u32[2] \ 472 (oword).u32[2] = (((oword).u32[2] \
473 & ~EFX_INPLACE_MASK32(64, 95, low, high)) \ 473 & ~EFX_INPLACE_MASK32(64, 95, low, high)) \
474 | EFX_INSERT32(64, 95, low, high, value)); \ 474 | EFX_INSERT32(64, 95, low, high, value)); \
475 (oword).u32[3] = (((oword).u32[3] \ 475 (oword).u32[3] = (((oword).u32[3] \
476 & ~EFX_INPLACE_MASK32(96, 127, low, high)) \ 476 & ~EFX_INPLACE_MASK32(96, 127, low, high)) \
477 | EFX_INSERT32(96, 127, low, high, value)); \ 477 | EFX_INSERT32(96, 127, low, high, value)); \
478 } while (0) 478 } while (0)
479 479
480#define EFX_SET_QWORD32(qword, low, high, value) do { \ 480#define EFX_SET_QWORD32(qword, low, high, value) do { \
481 (qword).u32[0] = (((qword).u32[0] \ 481 (qword).u32[0] = (((qword).u32[0] \
482 & ~EFX_INPLACE_MASK32(0, 31, low, high)) \ 482 & ~EFX_INPLACE_MASK32(0, 31, low, high)) \
483 | EFX_INSERT32(0, 31, low, high, value)); \ 483 | EFX_INSERT32(0, 31, low, high, value)); \
484 (qword).u32[1] = (((qword).u32[1] \ 484 (qword).u32[1] = (((qword).u32[1] \
485 & ~EFX_INPLACE_MASK32(32, 63, low, high)) \ 485 & ~EFX_INPLACE_MASK32(32, 63, low, high)) \
486 | EFX_INSERT32(32, 63, low, high, value)); \ 486 | EFX_INSERT32(32, 63, low, high, value)); \
487 } while (0) 487 } while (0)
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
index e43702f33b62..952d0bf7695a 100644
--- a/drivers/net/ethernet/sfc/efx.c
+++ b/drivers/net/ethernet/sfc/efx.c
@@ -38,15 +38,15 @@
38 38
39/* Loopback mode names (see LOOPBACK_MODE()) */ 39/* Loopback mode names (see LOOPBACK_MODE()) */
40const unsigned int efx_loopback_mode_max = LOOPBACK_MAX; 40const unsigned int efx_loopback_mode_max = LOOPBACK_MAX;
41const char *efx_loopback_mode_names[] = { 41const char *const efx_loopback_mode_names[] = {
42 [LOOPBACK_NONE] = "NONE", 42 [LOOPBACK_NONE] = "NONE",
43 [LOOPBACK_DATA] = "DATAPATH", 43 [LOOPBACK_DATA] = "DATAPATH",
44 [LOOPBACK_GMAC] = "GMAC", 44 [LOOPBACK_GMAC] = "GMAC",
45 [LOOPBACK_XGMII] = "XGMII", 45 [LOOPBACK_XGMII] = "XGMII",
46 [LOOPBACK_XGXS] = "XGXS", 46 [LOOPBACK_XGXS] = "XGXS",
47 [LOOPBACK_XAUI] = "XAUI", 47 [LOOPBACK_XAUI] = "XAUI",
48 [LOOPBACK_GMII] = "GMII", 48 [LOOPBACK_GMII] = "GMII",
49 [LOOPBACK_SGMII] = "SGMII", 49 [LOOPBACK_SGMII] = "SGMII",
50 [LOOPBACK_XGBR] = "XGBR", 50 [LOOPBACK_XGBR] = "XGBR",
51 [LOOPBACK_XFI] = "XFI", 51 [LOOPBACK_XFI] = "XFI",
52 [LOOPBACK_XAUI_FAR] = "XAUI_FAR", 52 [LOOPBACK_XAUI_FAR] = "XAUI_FAR",
@@ -55,21 +55,21 @@ const char *efx_loopback_mode_names[] = {
55 [LOOPBACK_XFI_FAR] = "XFI_FAR", 55 [LOOPBACK_XFI_FAR] = "XFI_FAR",
56 [LOOPBACK_GPHY] = "GPHY", 56 [LOOPBACK_GPHY] = "GPHY",
57 [LOOPBACK_PHYXS] = "PHYXS", 57 [LOOPBACK_PHYXS] = "PHYXS",
58 [LOOPBACK_PCS] = "PCS", 58 [LOOPBACK_PCS] = "PCS",
59 [LOOPBACK_PMAPMD] = "PMA/PMD", 59 [LOOPBACK_PMAPMD] = "PMA/PMD",
60 [LOOPBACK_XPORT] = "XPORT", 60 [LOOPBACK_XPORT] = "XPORT",
61 [LOOPBACK_XGMII_WS] = "XGMII_WS", 61 [LOOPBACK_XGMII_WS] = "XGMII_WS",
62 [LOOPBACK_XAUI_WS] = "XAUI_WS", 62 [LOOPBACK_XAUI_WS] = "XAUI_WS",
63 [LOOPBACK_XAUI_WS_FAR] = "XAUI_WS_FAR", 63 [LOOPBACK_XAUI_WS_FAR] = "XAUI_WS_FAR",
64 [LOOPBACK_XAUI_WS_NEAR] = "XAUI_WS_NEAR", 64 [LOOPBACK_XAUI_WS_NEAR] = "XAUI_WS_NEAR",
65 [LOOPBACK_GMII_WS] = "GMII_WS", 65 [LOOPBACK_GMII_WS] = "GMII_WS",
66 [LOOPBACK_XFI_WS] = "XFI_WS", 66 [LOOPBACK_XFI_WS] = "XFI_WS",
67 [LOOPBACK_XFI_WS_FAR] = "XFI_WS_FAR", 67 [LOOPBACK_XFI_WS_FAR] = "XFI_WS_FAR",
68 [LOOPBACK_PHYXS_WS] = "PHYXS_WS", 68 [LOOPBACK_PHYXS_WS] = "PHYXS_WS",
69}; 69};
70 70
71const unsigned int efx_reset_type_max = RESET_TYPE_MAX; 71const unsigned int efx_reset_type_max = RESET_TYPE_MAX;
72const char *efx_reset_type_names[] = { 72const char *const efx_reset_type_names[] = {
73 [RESET_TYPE_INVISIBLE] = "INVISIBLE", 73 [RESET_TYPE_INVISIBLE] = "INVISIBLE",
74 [RESET_TYPE_ALL] = "ALL", 74 [RESET_TYPE_ALL] = "ALL",
75 [RESET_TYPE_WORLD] = "WORLD", 75 [RESET_TYPE_WORLD] = "WORLD",
@@ -122,15 +122,6 @@ static int napi_weight = 64;
122 */ 122 */
123static unsigned int efx_monitor_interval = 1 * HZ; 123static unsigned int efx_monitor_interval = 1 * HZ;
124 124
125/* This controls whether or not the driver will initialise devices
126 * with invalid MAC addresses stored in the EEPROM or flash. If true,
127 * such devices will be initialised with a random locally-generated
128 * MAC address. This allows for loading the sfc_mtd driver to
129 * reprogram the flash, even if the flash contents (including the MAC
130 * address) have previously been erased.
131 */
132static unsigned int allow_bad_hwaddr;
133
134/* Initial interrupt moderation settings. They can be modified after 125/* Initial interrupt moderation settings. They can be modified after
135 * module load with ethtool. 126 * module load with ethtool.
136 * 127 *
@@ -162,7 +153,7 @@ static unsigned int interrupt_mode;
162 * interrupt handling. 153 * interrupt handling.
163 * 154 *
164 * Cards without MSI-X will only target one CPU via legacy or MSI interrupt. 155 * Cards without MSI-X will only target one CPU via legacy or MSI interrupt.
165 * The default (0) means to assign an interrupt to each package (level II cache) 156 * The default (0) means to assign an interrupt to each core.
166 */ 157 */
167static unsigned int rss_cpus; 158static unsigned int rss_cpus;
168module_param(rss_cpus, uint, 0444); 159module_param(rss_cpus, uint, 0444);
@@ -238,8 +229,7 @@ static int efx_process_channel(struct efx_channel *channel, int budget)
238 229
239 /* Deliver last RX packet. */ 230 /* Deliver last RX packet. */
240 if (channel->rx_pkt) { 231 if (channel->rx_pkt) {
241 __efx_rx_packet(channel, channel->rx_pkt, 232 __efx_rx_packet(channel, channel->rx_pkt);
242 channel->rx_pkt_csummed);
243 channel->rx_pkt = NULL; 233 channel->rx_pkt = NULL;
244 } 234 }
245 235
@@ -373,7 +363,7 @@ static int efx_probe_eventq(struct efx_channel *channel)
373 struct efx_nic *efx = channel->efx; 363 struct efx_nic *efx = channel->efx;
374 unsigned long entries; 364 unsigned long entries;
375 365
376 netif_dbg(channel->efx, probe, channel->efx->net_dev, 366 netif_dbg(efx, probe, efx->net_dev,
377 "chan %d create event queue\n", channel->channel); 367 "chan %d create event queue\n", channel->channel);
378 368
379 /* Build an event queue with room for one event per tx and rx buffer, 369 /* Build an event queue with room for one event per tx and rx buffer,
@@ -807,16 +797,14 @@ void efx_link_status_changed(struct efx_nic *efx)
807 } 797 }
808 798
809 /* Status message for kernel log */ 799 /* Status message for kernel log */
810 if (link_state->up) { 800 if (link_state->up)
811 netif_info(efx, link, efx->net_dev, 801 netif_info(efx, link, efx->net_dev,
812 "link up at %uMbps %s-duplex (MTU %d)%s\n", 802 "link up at %uMbps %s-duplex (MTU %d)%s\n",
813 link_state->speed, link_state->fd ? "full" : "half", 803 link_state->speed, link_state->fd ? "full" : "half",
814 efx->net_dev->mtu, 804 efx->net_dev->mtu,
815 (efx->promiscuous ? " [PROMISC]" : "")); 805 (efx->promiscuous ? " [PROMISC]" : ""));
816 } else { 806 else
817 netif_info(efx, link, efx->net_dev, "link down\n"); 807 netif_info(efx, link, efx->net_dev, "link down\n");
818 }
819
820} 808}
821 809
822void efx_link_set_advertising(struct efx_nic *efx, u32 advertising) 810void efx_link_set_advertising(struct efx_nic *efx, u32 advertising)
@@ -863,11 +851,9 @@ int __efx_reconfigure_port(struct efx_nic *efx)
863 851
864 WARN_ON(!mutex_is_locked(&efx->mac_lock)); 852 WARN_ON(!mutex_is_locked(&efx->mac_lock));
865 853
866 /* Serialise the promiscuous flag with efx_set_multicast_list. */ 854 /* Serialise the promiscuous flag with efx_set_rx_mode. */
867 if (efx_dev_registered(efx)) { 855 netif_addr_lock_bh(efx->net_dev);
868 netif_addr_lock_bh(efx->net_dev); 856 netif_addr_unlock_bh(efx->net_dev);
869 netif_addr_unlock_bh(efx->net_dev);
870 }
871 857
872 /* Disable PHY transmit in mac level loopbacks */ 858 /* Disable PHY transmit in mac level loopbacks */
873 phy_mode = efx->phy_mode; 859 phy_mode = efx->phy_mode;
@@ -907,16 +893,13 @@ static void efx_mac_work(struct work_struct *data)
907 struct efx_nic *efx = container_of(data, struct efx_nic, mac_work); 893 struct efx_nic *efx = container_of(data, struct efx_nic, mac_work);
908 894
909 mutex_lock(&efx->mac_lock); 895 mutex_lock(&efx->mac_lock);
910 if (efx->port_enabled) { 896 if (efx->port_enabled)
911 efx->type->push_multicast_hash(efx); 897 efx->type->reconfigure_mac(efx);
912 efx->mac_op->reconfigure(efx);
913 }
914 mutex_unlock(&efx->mac_lock); 898 mutex_unlock(&efx->mac_lock);
915} 899}
916 900
917static int efx_probe_port(struct efx_nic *efx) 901static int efx_probe_port(struct efx_nic *efx)
918{ 902{
919 unsigned char *perm_addr;
920 int rc; 903 int rc;
921 904
922 netif_dbg(efx, probe, efx->net_dev, "create port\n"); 905 netif_dbg(efx, probe, efx->net_dev, "create port\n");
@@ -929,28 +912,10 @@ static int efx_probe_port(struct efx_nic *efx)
929 if (rc) 912 if (rc)
930 return rc; 913 return rc;
931 914
932 /* Sanity check MAC address */ 915 /* Initialise MAC address to permanent address */
933 perm_addr = efx->net_dev->perm_addr; 916 memcpy(efx->net_dev->dev_addr, efx->net_dev->perm_addr, ETH_ALEN);
934 if (is_valid_ether_addr(perm_addr)) {
935 memcpy(efx->net_dev->dev_addr, perm_addr, ETH_ALEN);
936 } else {
937 netif_err(efx, probe, efx->net_dev, "invalid MAC address %pM\n",
938 perm_addr);
939 if (!allow_bad_hwaddr) {
940 rc = -EINVAL;
941 goto err;
942 }
943 random_ether_addr(efx->net_dev->dev_addr);
944 netif_info(efx, probe, efx->net_dev,
945 "using locally-generated MAC %pM\n",
946 efx->net_dev->dev_addr);
947 }
948 917
949 return 0; 918 return 0;
950
951 err:
952 efx->type->remove_port(efx);
953 return rc;
954} 919}
955 920
956static int efx_init_port(struct efx_nic *efx) 921static int efx_init_port(struct efx_nic *efx)
@@ -969,7 +934,7 @@ static int efx_init_port(struct efx_nic *efx)
969 934
970 /* Reconfigure the MAC before creating dma queues (required for 935 /* Reconfigure the MAC before creating dma queues (required for
971 * Falcon/A1 where RX_INGR_EN/TX_DRAIN_EN isn't supported) */ 936 * Falcon/A1 where RX_INGR_EN/TX_DRAIN_EN isn't supported) */
972 efx->mac_op->reconfigure(efx); 937 efx->type->reconfigure_mac(efx);
973 938
974 /* Ensure the PHY advertises the correct flow control settings */ 939 /* Ensure the PHY advertises the correct flow control settings */
975 rc = efx->phy_op->reconfigure(efx); 940 rc = efx->phy_op->reconfigure(efx);
@@ -996,8 +961,7 @@ static void efx_start_port(struct efx_nic *efx)
996 961
997 /* efx_mac_work() might have been scheduled after efx_stop_port(), 962 /* efx_mac_work() might have been scheduled after efx_stop_port(),
998 * and then cancelled by efx_flush_all() */ 963 * and then cancelled by efx_flush_all() */
999 efx->type->push_multicast_hash(efx); 964 efx->type->reconfigure_mac(efx);
1000 efx->mac_op->reconfigure(efx);
1001 965
1002 mutex_unlock(&efx->mac_lock); 966 mutex_unlock(&efx->mac_lock);
1003} 967}
@@ -1012,10 +976,8 @@ static void efx_stop_port(struct efx_nic *efx)
1012 mutex_unlock(&efx->mac_lock); 976 mutex_unlock(&efx->mac_lock);
1013 977
1014 /* Serialise against efx_set_multicast_list() */ 978 /* Serialise against efx_set_multicast_list() */
1015 if (efx_dev_registered(efx)) { 979 netif_addr_lock_bh(efx->net_dev);
1016 netif_addr_lock_bh(efx->net_dev); 980 netif_addr_unlock_bh(efx->net_dev);
1017 netif_addr_unlock_bh(efx->net_dev);
1018 }
1019} 981}
1020 982
1021static void efx_fini_port(struct efx_nic *efx) 983static void efx_fini_port(struct efx_nic *efx)
@@ -1069,9 +1031,11 @@ static int efx_init_io(struct efx_nic *efx)
1069 * masks event though they reject 46 bit masks. 1031 * masks event though they reject 46 bit masks.
1070 */ 1032 */
1071 while (dma_mask > 0x7fffffffUL) { 1033 while (dma_mask > 0x7fffffffUL) {
1072 if (pci_dma_supported(pci_dev, dma_mask) && 1034 if (pci_dma_supported(pci_dev, dma_mask)) {
1073 ((rc = pci_set_dma_mask(pci_dev, dma_mask)) == 0)) 1035 rc = pci_set_dma_mask(pci_dev, dma_mask);
1074 break; 1036 if (rc == 0)
1037 break;
1038 }
1075 dma_mask >>= 1; 1039 dma_mask >>= 1;
1076 } 1040 }
1077 if (rc) { 1041 if (rc) {
@@ -1144,18 +1108,16 @@ static void efx_fini_io(struct efx_nic *efx)
1144 pci_disable_device(efx->pci_dev); 1108 pci_disable_device(efx->pci_dev);
1145} 1109}
1146 1110
1147/* Get number of channels wanted. Each channel will have its own IRQ, 1111static int efx_wanted_parallelism(void)
1148 * 1 RX queue and/or 2 TX queues. */
1149static int efx_wanted_channels(void)
1150{ 1112{
1151 cpumask_var_t core_mask; 1113 cpumask_var_t thread_mask;
1152 int count; 1114 int count;
1153 int cpu; 1115 int cpu;
1154 1116
1155 if (rss_cpus) 1117 if (rss_cpus)
1156 return rss_cpus; 1118 return rss_cpus;
1157 1119
1158 if (unlikely(!zalloc_cpumask_var(&core_mask, GFP_KERNEL))) { 1120 if (unlikely(!zalloc_cpumask_var(&thread_mask, GFP_KERNEL))) {
1159 printk(KERN_WARNING 1121 printk(KERN_WARNING
1160 "sfc: RSS disabled due to allocation failure\n"); 1122 "sfc: RSS disabled due to allocation failure\n");
1161 return 1; 1123 return 1;
@@ -1163,14 +1125,14 @@ static int efx_wanted_channels(void)
1163 1125
1164 count = 0; 1126 count = 0;
1165 for_each_online_cpu(cpu) { 1127 for_each_online_cpu(cpu) {
1166 if (!cpumask_test_cpu(cpu, core_mask)) { 1128 if (!cpumask_test_cpu(cpu, thread_mask)) {
1167 ++count; 1129 ++count;
1168 cpumask_or(core_mask, core_mask, 1130 cpumask_or(thread_mask, thread_mask,
1169 topology_core_cpumask(cpu)); 1131 topology_thread_cpumask(cpu));
1170 } 1132 }
1171 } 1133 }
1172 1134
1173 free_cpumask_var(core_mask); 1135 free_cpumask_var(thread_mask);
1174 return count; 1136 return count;
1175} 1137}
1176 1138
@@ -1209,7 +1171,7 @@ static int efx_probe_interrupts(struct efx_nic *efx)
1209 struct msix_entry xentries[EFX_MAX_CHANNELS]; 1171 struct msix_entry xentries[EFX_MAX_CHANNELS];
1210 int n_channels; 1172 int n_channels;
1211 1173
1212 n_channels = efx_wanted_channels(); 1174 n_channels = efx_wanted_parallelism();
1213 if (separate_tx_channels) 1175 if (separate_tx_channels)
1214 n_channels *= 2; 1176 n_channels *= 2;
1215 n_channels = min(n_channels, max_channels); 1177 n_channels = min(n_channels, max_channels);
@@ -1425,14 +1387,14 @@ static void efx_start_all(struct efx_nic *efx)
1425 return; 1387 return;
1426 if ((efx->state != STATE_RUNNING) && (efx->state != STATE_INIT)) 1388 if ((efx->state != STATE_RUNNING) && (efx->state != STATE_INIT))
1427 return; 1389 return;
1428 if (efx_dev_registered(efx) && !netif_running(efx->net_dev)) 1390 if (!netif_running(efx->net_dev))
1429 return; 1391 return;
1430 1392
1431 /* Mark the port as enabled so port reconfigurations can start, then 1393 /* Mark the port as enabled so port reconfigurations can start, then
1432 * restart the transmit interface early so the watchdog timer stops */ 1394 * restart the transmit interface early so the watchdog timer stops */
1433 efx_start_port(efx); 1395 efx_start_port(efx);
1434 1396
1435 if (efx_dev_registered(efx) && netif_device_present(efx->net_dev)) 1397 if (netif_device_present(efx->net_dev))
1436 netif_tx_wake_all_queues(efx->net_dev); 1398 netif_tx_wake_all_queues(efx->net_dev);
1437 1399
1438 efx_for_each_channel(channel, efx) 1400 efx_for_each_channel(channel, efx)
@@ -1523,11 +1485,9 @@ static void efx_stop_all(struct efx_nic *efx)
1523 1485
1524 /* Stop the kernel transmit interface late, so the watchdog 1486 /* Stop the kernel transmit interface late, so the watchdog
1525 * timer isn't ticking over the flush */ 1487 * timer isn't ticking over the flush */
1526 if (efx_dev_registered(efx)) { 1488 netif_tx_stop_all_queues(efx->net_dev);
1527 netif_tx_stop_all_queues(efx->net_dev); 1489 netif_tx_lock_bh(efx->net_dev);
1528 netif_tx_lock_bh(efx->net_dev); 1490 netif_tx_unlock_bh(efx->net_dev);
1529 netif_tx_unlock_bh(efx->net_dev);
1530 }
1531} 1491}
1532 1492
1533static void efx_remove_all(struct efx_nic *efx) 1493static void efx_remove_all(struct efx_nic *efx)
@@ -1544,13 +1504,13 @@ static void efx_remove_all(struct efx_nic *efx)
1544 * 1504 *
1545 **************************************************************************/ 1505 **************************************************************************/
1546 1506
1547static unsigned int irq_mod_ticks(unsigned int usecs, unsigned int resolution) 1507static unsigned int irq_mod_ticks(unsigned int usecs, unsigned int quantum_ns)
1548{ 1508{
1549 if (usecs == 0) 1509 if (usecs == 0)
1550 return 0; 1510 return 0;
1551 if (usecs < resolution) 1511 if (usecs * 1000 < quantum_ns)
1552 return 1; /* never round down to 0 */ 1512 return 1; /* never round down to 0 */
1553 return usecs / resolution; 1513 return usecs * 1000 / quantum_ns;
1554} 1514}
1555 1515
1556/* Set interrupt moderation parameters */ 1516/* Set interrupt moderation parameters */
@@ -1559,14 +1519,20 @@ int efx_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs,
1559 bool rx_may_override_tx) 1519 bool rx_may_override_tx)
1560{ 1520{
1561 struct efx_channel *channel; 1521 struct efx_channel *channel;
1562 unsigned tx_ticks = irq_mod_ticks(tx_usecs, EFX_IRQ_MOD_RESOLUTION); 1522 unsigned int irq_mod_max = DIV_ROUND_UP(efx->type->timer_period_max *
1563 unsigned rx_ticks = irq_mod_ticks(rx_usecs, EFX_IRQ_MOD_RESOLUTION); 1523 efx->timer_quantum_ns,
1524 1000);
1525 unsigned int tx_ticks;
1526 unsigned int rx_ticks;
1564 1527
1565 EFX_ASSERT_RESET_SERIALISED(efx); 1528 EFX_ASSERT_RESET_SERIALISED(efx);
1566 1529
1567 if (tx_ticks > EFX_IRQ_MOD_MAX || rx_ticks > EFX_IRQ_MOD_MAX) 1530 if (tx_usecs > irq_mod_max || rx_usecs > irq_mod_max)
1568 return -EINVAL; 1531 return -EINVAL;
1569 1532
1533 tx_ticks = irq_mod_ticks(tx_usecs, efx->timer_quantum_ns);
1534 rx_ticks = irq_mod_ticks(rx_usecs, efx->timer_quantum_ns);
1535
1570 if (tx_ticks != rx_ticks && efx->tx_channel_offset == 0 && 1536 if (tx_ticks != rx_ticks && efx->tx_channel_offset == 0 &&
1571 !rx_may_override_tx) { 1537 !rx_may_override_tx) {
1572 netif_err(efx, drv, efx->net_dev, "Channels are shared. " 1538 netif_err(efx, drv, efx->net_dev, "Channels are shared. "
@@ -1589,8 +1555,14 @@ int efx_init_irq_moderation(struct efx_nic *efx, unsigned int tx_usecs,
1589void efx_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs, 1555void efx_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs,
1590 unsigned int *rx_usecs, bool *rx_adaptive) 1556 unsigned int *rx_usecs, bool *rx_adaptive)
1591{ 1557{
1558 /* We must round up when converting ticks to microseconds
1559 * because we round down when converting the other way.
1560 */
1561
1592 *rx_adaptive = efx->irq_rx_adaptive; 1562 *rx_adaptive = efx->irq_rx_adaptive;
1593 *rx_usecs = efx->irq_rx_moderation * EFX_IRQ_MOD_RESOLUTION; 1563 *rx_usecs = DIV_ROUND_UP(efx->irq_rx_moderation *
1564 efx->timer_quantum_ns,
1565 1000);
1594 1566
1595 /* If channels are shared between RX and TX, so is IRQ 1567 /* If channels are shared between RX and TX, so is IRQ
1596 * moderation. Otherwise, IRQ moderation is the same for all 1568 * moderation. Otherwise, IRQ moderation is the same for all
@@ -1599,9 +1571,10 @@ void efx_get_irq_moderation(struct efx_nic *efx, unsigned int *tx_usecs,
1599 if (efx->tx_channel_offset == 0) 1571 if (efx->tx_channel_offset == 0)
1600 *tx_usecs = *rx_usecs; 1572 *tx_usecs = *rx_usecs;
1601 else 1573 else
1602 *tx_usecs = 1574 *tx_usecs = DIV_ROUND_UP(
1603 efx->channel[efx->tx_channel_offset]->irq_moderation * 1575 efx->channel[efx->tx_channel_offset]->irq_moderation *
1604 EFX_IRQ_MOD_RESOLUTION; 1576 efx->timer_quantum_ns,
1577 1000);
1605} 1578}
1606 1579
1607/************************************************************************** 1580/**************************************************************************
@@ -1765,14 +1738,15 @@ static int efx_net_stop(struct net_device *net_dev)
1765} 1738}
1766 1739
1767/* Context: process, dev_base_lock or RTNL held, non-blocking. */ 1740/* Context: process, dev_base_lock or RTNL held, non-blocking. */
1768static struct rtnl_link_stats64 *efx_net_stats(struct net_device *net_dev, struct rtnl_link_stats64 *stats) 1741static struct rtnl_link_stats64 *efx_net_stats(struct net_device *net_dev,
1742 struct rtnl_link_stats64 *stats)
1769{ 1743{
1770 struct efx_nic *efx = netdev_priv(net_dev); 1744 struct efx_nic *efx = netdev_priv(net_dev);
1771 struct efx_mac_stats *mac_stats = &efx->mac_stats; 1745 struct efx_mac_stats *mac_stats = &efx->mac_stats;
1772 1746
1773 spin_lock_bh(&efx->stats_lock); 1747 spin_lock_bh(&efx->stats_lock);
1748
1774 efx->type->update_stats(efx); 1749 efx->type->update_stats(efx);
1775 spin_unlock_bh(&efx->stats_lock);
1776 1750
1777 stats->rx_packets = mac_stats->rx_packets; 1751 stats->rx_packets = mac_stats->rx_packets;
1778 stats->tx_packets = mac_stats->tx_packets; 1752 stats->tx_packets = mac_stats->tx_packets;
@@ -1796,6 +1770,8 @@ static struct rtnl_link_stats64 *efx_net_stats(struct net_device *net_dev, struc
1796 stats->tx_errors = (stats->tx_window_errors + 1770 stats->tx_errors = (stats->tx_window_errors +
1797 mac_stats->tx_bad); 1771 mac_stats->tx_bad);
1798 1772
1773 spin_unlock_bh(&efx->stats_lock);
1774
1799 return stats; 1775 return stats;
1800} 1776}
1801 1777
@@ -1816,7 +1792,6 @@ static void efx_watchdog(struct net_device *net_dev)
1816static int efx_change_mtu(struct net_device *net_dev, int new_mtu) 1792static int efx_change_mtu(struct net_device *net_dev, int new_mtu)
1817{ 1793{
1818 struct efx_nic *efx = netdev_priv(net_dev); 1794 struct efx_nic *efx = netdev_priv(net_dev);
1819 int rc = 0;
1820 1795
1821 EFX_ASSERT_RESET_SERIALISED(efx); 1796 EFX_ASSERT_RESET_SERIALISED(efx);
1822 1797
@@ -1833,13 +1808,13 @@ static int efx_change_mtu(struct net_device *net_dev, int new_mtu)
1833 /* Reconfigure the MAC before enabling the dma queues so that 1808 /* Reconfigure the MAC before enabling the dma queues so that
1834 * the RX buffers don't overflow */ 1809 * the RX buffers don't overflow */
1835 net_dev->mtu = new_mtu; 1810 net_dev->mtu = new_mtu;
1836 efx->mac_op->reconfigure(efx); 1811 efx->type->reconfigure_mac(efx);
1837 mutex_unlock(&efx->mac_lock); 1812 mutex_unlock(&efx->mac_lock);
1838 1813
1839 efx_init_channels(efx); 1814 efx_init_channels(efx);
1840 1815
1841 efx_start_all(efx); 1816 efx_start_all(efx);
1842 return rc; 1817 return 0;
1843} 1818}
1844 1819
1845static int efx_set_mac_address(struct net_device *net_dev, void *data) 1820static int efx_set_mac_address(struct net_device *net_dev, void *data)
@@ -1861,14 +1836,14 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data)
1861 1836
1862 /* Reconfigure the MAC */ 1837 /* Reconfigure the MAC */
1863 mutex_lock(&efx->mac_lock); 1838 mutex_lock(&efx->mac_lock);
1864 efx->mac_op->reconfigure(efx); 1839 efx->type->reconfigure_mac(efx);
1865 mutex_unlock(&efx->mac_lock); 1840 mutex_unlock(&efx->mac_lock);
1866 1841
1867 return 0; 1842 return 0;
1868} 1843}
1869 1844
1870/* Context: netif_addr_lock held, BHs disabled. */ 1845/* Context: netif_addr_lock held, BHs disabled. */
1871static void efx_set_multicast_list(struct net_device *net_dev) 1846static void efx_set_rx_mode(struct net_device *net_dev)
1872{ 1847{
1873 struct efx_nic *efx = netdev_priv(net_dev); 1848 struct efx_nic *efx = netdev_priv(net_dev);
1874 struct netdev_hw_addr *ha; 1849 struct netdev_hw_addr *ha;
@@ -1922,7 +1897,7 @@ static const struct net_device_ops efx_netdev_ops = {
1922 .ndo_do_ioctl = efx_ioctl, 1897 .ndo_do_ioctl = efx_ioctl,
1923 .ndo_change_mtu = efx_change_mtu, 1898 .ndo_change_mtu = efx_change_mtu,
1924 .ndo_set_mac_address = efx_set_mac_address, 1899 .ndo_set_mac_address = efx_set_mac_address,
1925 .ndo_set_rx_mode = efx_set_multicast_list, 1900 .ndo_set_rx_mode = efx_set_rx_mode,
1926 .ndo_set_features = efx_set_features, 1901 .ndo_set_features = efx_set_features,
1927#ifdef CONFIG_NET_POLL_CONTROLLER 1902#ifdef CONFIG_NET_POLL_CONTROLLER
1928 .ndo_poll_controller = efx_netpoll, 1903 .ndo_poll_controller = efx_netpoll,
@@ -1975,10 +1950,6 @@ static int efx_register_netdev(struct efx_nic *efx)
1975 net_dev->netdev_ops = &efx_netdev_ops; 1950 net_dev->netdev_ops = &efx_netdev_ops;
1976 SET_ETHTOOL_OPS(net_dev, &efx_ethtool_ops); 1951 SET_ETHTOOL_OPS(net_dev, &efx_ethtool_ops);
1977 1952
1978 /* Clear MAC statistics */
1979 efx->mac_op->update_stats(efx);
1980 memset(&efx->mac_stats, 0, sizeof(efx->mac_stats));
1981
1982 rtnl_lock(); 1953 rtnl_lock();
1983 1954
1984 rc = dev_alloc_name(net_dev, net_dev->name); 1955 rc = dev_alloc_name(net_dev, net_dev->name);
@@ -1997,7 +1968,7 @@ static int efx_register_netdev(struct efx_nic *efx)
1997 } 1968 }
1998 1969
1999 /* Always start with carrier off; PHY events will detect the link */ 1970 /* Always start with carrier off; PHY events will detect the link */
2000 netif_carrier_off(efx->net_dev); 1971 netif_carrier_off(net_dev);
2001 1972
2002 rtnl_unlock(); 1973 rtnl_unlock();
2003 1974
@@ -2038,11 +2009,9 @@ static void efx_unregister_netdev(struct efx_nic *efx)
2038 efx_release_tx_buffers(tx_queue); 2009 efx_release_tx_buffers(tx_queue);
2039 } 2010 }
2040 2011
2041 if (efx_dev_registered(efx)) { 2012 strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name));
2042 strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name)); 2013 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type);
2043 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_type); 2014 unregister_netdev(efx->net_dev);
2044 unregister_netdev(efx->net_dev);
2045 }
2046} 2015}
2047 2016
2048/************************************************************************** 2017/**************************************************************************
@@ -2095,7 +2064,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok)
2095 "could not restore PHY settings\n"); 2064 "could not restore PHY settings\n");
2096 } 2065 }
2097 2066
2098 efx->mac_op->reconfigure(efx); 2067 efx->type->reconfigure_mac(efx);
2099 2068
2100 efx_init_channels(efx); 2069 efx_init_channels(efx);
2101 efx_restore_filters(efx); 2070 efx_restore_filters(efx);
@@ -2300,7 +2269,6 @@ static int efx_init_struct(struct efx_nic *efx, const struct efx_nic_type *type,
2300 efx->net_dev = net_dev; 2269 efx->net_dev = net_dev;
2301 spin_lock_init(&efx->stats_lock); 2270 spin_lock_init(&efx->stats_lock);
2302 mutex_init(&efx->mac_lock); 2271 mutex_init(&efx->mac_lock);
2303 efx->mac_op = type->default_mac_ops;
2304 efx->phy_op = &efx_dummy_phy_operations; 2272 efx->phy_op = &efx_dummy_phy_operations;
2305 efx->mdio.dev = net_dev; 2273 efx->mdio.dev = net_dev;
2306 INIT_WORK(&efx->mac_work, efx_mac_work); 2274 INIT_WORK(&efx->mac_work, efx_mac_work);
@@ -2459,7 +2427,7 @@ static int efx_pci_probe_main(struct efx_nic *efx)
2459/* NIC initialisation 2427/* NIC initialisation
2460 * 2428 *
2461 * This is called at module load (or hotplug insertion, 2429 * This is called at module load (or hotplug insertion,
2462 * theoretically). It sets up PCI mappings, tests and resets the NIC, 2430 * theoretically). It sets up PCI mappings, resets the NIC,
2463 * sets up and registers the network devices with the kernel and hooks 2431 * sets up and registers the network devices with the kernel and hooks
2464 * the interrupt service routine. It does not prepare the device for 2432 * the interrupt service routine. It does not prepare the device for
2465 * transmission; this is left to the first time one of the network 2433 * transmission; this is left to the first time one of the network
@@ -2658,7 +2626,7 @@ static int efx_pm_suspend(struct device *dev)
2658 return rc; 2626 return rc;
2659} 2627}
2660 2628
2661static struct dev_pm_ops efx_pm_ops = { 2629static const struct dev_pm_ops efx_pm_ops = {
2662 .suspend = efx_pm_suspend, 2630 .suspend = efx_pm_suspend,
2663 .resume = efx_pm_resume, 2631 .resume = efx_pm_resume,
2664 .freeze = efx_pm_freeze, 2632 .freeze = efx_pm_freeze,
diff --git a/drivers/net/ethernet/sfc/efx.h b/drivers/net/ethernet/sfc/efx.h
index a3541ac6ea01..7f546e2c39e2 100644
--- a/drivers/net/ethernet/sfc/efx.h
+++ b/drivers/net/ethernet/sfc/efx.h
@@ -40,9 +40,9 @@ extern void efx_rx_strategy(struct efx_channel *channel);
40extern void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue); 40extern void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue);
41extern void efx_rx_slow_fill(unsigned long context); 41extern void efx_rx_slow_fill(unsigned long context);
42extern void __efx_rx_packet(struct efx_channel *channel, 42extern void __efx_rx_packet(struct efx_channel *channel,
43 struct efx_rx_buffer *rx_buf, bool checksummed); 43 struct efx_rx_buffer *rx_buf);
44extern void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index, 44extern void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index,
45 unsigned int len, bool checksummed, bool discard); 45 unsigned int len, u16 flags);
46extern void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue); 46extern void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue);
47 47
48#define EFX_MAX_DMAQ_SIZE 4096UL 48#define EFX_MAX_DMAQ_SIZE 4096UL
@@ -145,6 +145,12 @@ static inline void efx_schedule_channel(struct efx_channel *channel)
145 napi_schedule(&channel->napi_str); 145 napi_schedule(&channel->napi_str);
146} 146}
147 147
148static inline void efx_schedule_channel_irq(struct efx_channel *channel)
149{
150 channel->last_irq_cpu = raw_smp_processor_id();
151 efx_schedule_channel(channel);
152}
153
148extern void efx_link_status_changed(struct efx_nic *efx); 154extern void efx_link_status_changed(struct efx_nic *efx);
149extern void efx_link_set_advertising(struct efx_nic *efx, u32); 155extern void efx_link_set_advertising(struct efx_nic *efx, u32);
150extern void efx_link_set_wanted_fc(struct efx_nic *efx, u8); 156extern void efx_link_set_wanted_fc(struct efx_nic *efx, u8);
diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c
index 29b2ebfef19f..f887f65e4189 100644
--- a/drivers/net/ethernet/sfc/ethtool.c
+++ b/drivers/net/ethernet/sfc/ethtool.c
@@ -52,11 +52,6 @@ static u64 efx_get_uint_stat(void *field)
52 return *(unsigned int *)field; 52 return *(unsigned int *)field;
53} 53}
54 54
55static u64 efx_get_ulong_stat(void *field)
56{
57 return *(unsigned long *)field;
58}
59
60static u64 efx_get_u64_stat(void *field) 55static u64 efx_get_u64_stat(void *field)
61{ 56{
62 return *(u64 *) field; 57 return *(u64 *) field;
@@ -67,12 +62,8 @@ static u64 efx_get_atomic_stat(void *field)
67 return atomic_read((atomic_t *) field); 62 return atomic_read((atomic_t *) field);
68} 63}
69 64
70#define EFX_ETHTOOL_ULONG_MAC_STAT(field) \
71 EFX_ETHTOOL_STAT(field, mac_stats, field, \
72 unsigned long, efx_get_ulong_stat)
73
74#define EFX_ETHTOOL_U64_MAC_STAT(field) \ 65#define EFX_ETHTOOL_U64_MAC_STAT(field) \
75 EFX_ETHTOOL_STAT(field, mac_stats, field, \ 66 EFX_ETHTOOL_STAT(field, mac_stats, field, \
76 u64, efx_get_u64_stat) 67 u64, efx_get_u64_stat)
77 68
78#define EFX_ETHTOOL_UINT_NIC_STAT(name) \ 69#define EFX_ETHTOOL_UINT_NIC_STAT(name) \
@@ -91,36 +82,36 @@ static u64 efx_get_atomic_stat(void *field)
91 EFX_ETHTOOL_STAT(tx_##field, tx_queue, field, \ 82 EFX_ETHTOOL_STAT(tx_##field, tx_queue, field, \
92 unsigned int, efx_get_uint_stat) 83 unsigned int, efx_get_uint_stat)
93 84
94static struct efx_ethtool_stat efx_ethtool_stats[] = { 85static const struct efx_ethtool_stat efx_ethtool_stats[] = {
95 EFX_ETHTOOL_U64_MAC_STAT(tx_bytes), 86 EFX_ETHTOOL_U64_MAC_STAT(tx_bytes),
96 EFX_ETHTOOL_U64_MAC_STAT(tx_good_bytes), 87 EFX_ETHTOOL_U64_MAC_STAT(tx_good_bytes),
97 EFX_ETHTOOL_U64_MAC_STAT(tx_bad_bytes), 88 EFX_ETHTOOL_U64_MAC_STAT(tx_bad_bytes),
98 EFX_ETHTOOL_ULONG_MAC_STAT(tx_packets), 89 EFX_ETHTOOL_U64_MAC_STAT(tx_packets),
99 EFX_ETHTOOL_ULONG_MAC_STAT(tx_bad), 90 EFX_ETHTOOL_U64_MAC_STAT(tx_bad),
100 EFX_ETHTOOL_ULONG_MAC_STAT(tx_pause), 91 EFX_ETHTOOL_U64_MAC_STAT(tx_pause),
101 EFX_ETHTOOL_ULONG_MAC_STAT(tx_control), 92 EFX_ETHTOOL_U64_MAC_STAT(tx_control),
102 EFX_ETHTOOL_ULONG_MAC_STAT(tx_unicast), 93 EFX_ETHTOOL_U64_MAC_STAT(tx_unicast),
103 EFX_ETHTOOL_ULONG_MAC_STAT(tx_multicast), 94 EFX_ETHTOOL_U64_MAC_STAT(tx_multicast),
104 EFX_ETHTOOL_ULONG_MAC_STAT(tx_broadcast), 95 EFX_ETHTOOL_U64_MAC_STAT(tx_broadcast),
105 EFX_ETHTOOL_ULONG_MAC_STAT(tx_lt64), 96 EFX_ETHTOOL_U64_MAC_STAT(tx_lt64),
106 EFX_ETHTOOL_ULONG_MAC_STAT(tx_64), 97 EFX_ETHTOOL_U64_MAC_STAT(tx_64),
107 EFX_ETHTOOL_ULONG_MAC_STAT(tx_65_to_127), 98 EFX_ETHTOOL_U64_MAC_STAT(tx_65_to_127),
108 EFX_ETHTOOL_ULONG_MAC_STAT(tx_128_to_255), 99 EFX_ETHTOOL_U64_MAC_STAT(tx_128_to_255),
109 EFX_ETHTOOL_ULONG_MAC_STAT(tx_256_to_511), 100 EFX_ETHTOOL_U64_MAC_STAT(tx_256_to_511),
110 EFX_ETHTOOL_ULONG_MAC_STAT(tx_512_to_1023), 101 EFX_ETHTOOL_U64_MAC_STAT(tx_512_to_1023),
111 EFX_ETHTOOL_ULONG_MAC_STAT(tx_1024_to_15xx), 102 EFX_ETHTOOL_U64_MAC_STAT(tx_1024_to_15xx),
112 EFX_ETHTOOL_ULONG_MAC_STAT(tx_15xx_to_jumbo), 103 EFX_ETHTOOL_U64_MAC_STAT(tx_15xx_to_jumbo),
113 EFX_ETHTOOL_ULONG_MAC_STAT(tx_gtjumbo), 104 EFX_ETHTOOL_U64_MAC_STAT(tx_gtjumbo),
114 EFX_ETHTOOL_ULONG_MAC_STAT(tx_collision), 105 EFX_ETHTOOL_U64_MAC_STAT(tx_collision),
115 EFX_ETHTOOL_ULONG_MAC_STAT(tx_single_collision), 106 EFX_ETHTOOL_U64_MAC_STAT(tx_single_collision),
116 EFX_ETHTOOL_ULONG_MAC_STAT(tx_multiple_collision), 107 EFX_ETHTOOL_U64_MAC_STAT(tx_multiple_collision),
117 EFX_ETHTOOL_ULONG_MAC_STAT(tx_excessive_collision), 108 EFX_ETHTOOL_U64_MAC_STAT(tx_excessive_collision),
118 EFX_ETHTOOL_ULONG_MAC_STAT(tx_deferred), 109 EFX_ETHTOOL_U64_MAC_STAT(tx_deferred),
119 EFX_ETHTOOL_ULONG_MAC_STAT(tx_late_collision), 110 EFX_ETHTOOL_U64_MAC_STAT(tx_late_collision),
120 EFX_ETHTOOL_ULONG_MAC_STAT(tx_excessive_deferred), 111 EFX_ETHTOOL_U64_MAC_STAT(tx_excessive_deferred),
121 EFX_ETHTOOL_ULONG_MAC_STAT(tx_non_tcpudp), 112 EFX_ETHTOOL_U64_MAC_STAT(tx_non_tcpudp),
122 EFX_ETHTOOL_ULONG_MAC_STAT(tx_mac_src_error), 113 EFX_ETHTOOL_U64_MAC_STAT(tx_mac_src_error),
123 EFX_ETHTOOL_ULONG_MAC_STAT(tx_ip_src_error), 114 EFX_ETHTOOL_U64_MAC_STAT(tx_ip_src_error),
124 EFX_ETHTOOL_UINT_TXQ_STAT(tso_bursts), 115 EFX_ETHTOOL_UINT_TXQ_STAT(tso_bursts),
125 EFX_ETHTOOL_UINT_TXQ_STAT(tso_long_headers), 116 EFX_ETHTOOL_UINT_TXQ_STAT(tso_long_headers),
126 EFX_ETHTOOL_UINT_TXQ_STAT(tso_packets), 117 EFX_ETHTOOL_UINT_TXQ_STAT(tso_packets),
@@ -128,34 +119,34 @@ static struct efx_ethtool_stat efx_ethtool_stats[] = {
128 EFX_ETHTOOL_U64_MAC_STAT(rx_bytes), 119 EFX_ETHTOOL_U64_MAC_STAT(rx_bytes),
129 EFX_ETHTOOL_U64_MAC_STAT(rx_good_bytes), 120 EFX_ETHTOOL_U64_MAC_STAT(rx_good_bytes),
130 EFX_ETHTOOL_U64_MAC_STAT(rx_bad_bytes), 121 EFX_ETHTOOL_U64_MAC_STAT(rx_bad_bytes),
131 EFX_ETHTOOL_ULONG_MAC_STAT(rx_packets), 122 EFX_ETHTOOL_U64_MAC_STAT(rx_packets),
132 EFX_ETHTOOL_ULONG_MAC_STAT(rx_good), 123 EFX_ETHTOOL_U64_MAC_STAT(rx_good),
133 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad), 124 EFX_ETHTOOL_U64_MAC_STAT(rx_bad),
134 EFX_ETHTOOL_ULONG_MAC_STAT(rx_pause), 125 EFX_ETHTOOL_U64_MAC_STAT(rx_pause),
135 EFX_ETHTOOL_ULONG_MAC_STAT(rx_control), 126 EFX_ETHTOOL_U64_MAC_STAT(rx_control),
136 EFX_ETHTOOL_ULONG_MAC_STAT(rx_unicast), 127 EFX_ETHTOOL_U64_MAC_STAT(rx_unicast),
137 EFX_ETHTOOL_ULONG_MAC_STAT(rx_multicast), 128 EFX_ETHTOOL_U64_MAC_STAT(rx_multicast),
138 EFX_ETHTOOL_ULONG_MAC_STAT(rx_broadcast), 129 EFX_ETHTOOL_U64_MAC_STAT(rx_broadcast),
139 EFX_ETHTOOL_ULONG_MAC_STAT(rx_lt64), 130 EFX_ETHTOOL_U64_MAC_STAT(rx_lt64),
140 EFX_ETHTOOL_ULONG_MAC_STAT(rx_64), 131 EFX_ETHTOOL_U64_MAC_STAT(rx_64),
141 EFX_ETHTOOL_ULONG_MAC_STAT(rx_65_to_127), 132 EFX_ETHTOOL_U64_MAC_STAT(rx_65_to_127),
142 EFX_ETHTOOL_ULONG_MAC_STAT(rx_128_to_255), 133 EFX_ETHTOOL_U64_MAC_STAT(rx_128_to_255),
143 EFX_ETHTOOL_ULONG_MAC_STAT(rx_256_to_511), 134 EFX_ETHTOOL_U64_MAC_STAT(rx_256_to_511),
144 EFX_ETHTOOL_ULONG_MAC_STAT(rx_512_to_1023), 135 EFX_ETHTOOL_U64_MAC_STAT(rx_512_to_1023),
145 EFX_ETHTOOL_ULONG_MAC_STAT(rx_1024_to_15xx), 136 EFX_ETHTOOL_U64_MAC_STAT(rx_1024_to_15xx),
146 EFX_ETHTOOL_ULONG_MAC_STAT(rx_15xx_to_jumbo), 137 EFX_ETHTOOL_U64_MAC_STAT(rx_15xx_to_jumbo),
147 EFX_ETHTOOL_ULONG_MAC_STAT(rx_gtjumbo), 138 EFX_ETHTOOL_U64_MAC_STAT(rx_gtjumbo),
148 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_lt64), 139 EFX_ETHTOOL_U64_MAC_STAT(rx_bad_lt64),
149 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_64_to_15xx), 140 EFX_ETHTOOL_U64_MAC_STAT(rx_bad_64_to_15xx),
150 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_15xx_to_jumbo), 141 EFX_ETHTOOL_U64_MAC_STAT(rx_bad_15xx_to_jumbo),
151 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_gtjumbo), 142 EFX_ETHTOOL_U64_MAC_STAT(rx_bad_gtjumbo),
152 EFX_ETHTOOL_ULONG_MAC_STAT(rx_overflow), 143 EFX_ETHTOOL_U64_MAC_STAT(rx_overflow),
153 EFX_ETHTOOL_ULONG_MAC_STAT(rx_missed), 144 EFX_ETHTOOL_U64_MAC_STAT(rx_missed),
154 EFX_ETHTOOL_ULONG_MAC_STAT(rx_false_carrier), 145 EFX_ETHTOOL_U64_MAC_STAT(rx_false_carrier),
155 EFX_ETHTOOL_ULONG_MAC_STAT(rx_symbol_error), 146 EFX_ETHTOOL_U64_MAC_STAT(rx_symbol_error),
156 EFX_ETHTOOL_ULONG_MAC_STAT(rx_align_error), 147 EFX_ETHTOOL_U64_MAC_STAT(rx_align_error),
157 EFX_ETHTOOL_ULONG_MAC_STAT(rx_length_error), 148 EFX_ETHTOOL_U64_MAC_STAT(rx_length_error),
158 EFX_ETHTOOL_ULONG_MAC_STAT(rx_internal_error), 149 EFX_ETHTOOL_U64_MAC_STAT(rx_internal_error),
159 EFX_ETHTOOL_UINT_NIC_STAT(rx_nodesc_drop_cnt), 150 EFX_ETHTOOL_UINT_NIC_STAT(rx_nodesc_drop_cnt),
160 EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset), 151 EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset),
161 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc), 152 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc),
@@ -404,10 +395,6 @@ static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
404 &tests->eventq_int[channel->channel], 395 &tests->eventq_int[channel->channel],
405 EFX_CHANNEL_NAME(channel), 396 EFX_CHANNEL_NAME(channel),
406 "eventq.int", NULL); 397 "eventq.int", NULL);
407 efx_fill_test(n++, strings, data,
408 &tests->eventq_poll[channel->channel],
409 EFX_CHANNEL_NAME(channel),
410 "eventq.poll", NULL);
411 } 398 }
412 399
413 efx_fill_test(n++, strings, data, &tests->registers, 400 efx_fill_test(n++, strings, data, &tests->registers,
@@ -486,16 +473,17 @@ static void efx_ethtool_get_stats(struct net_device *net_dev,
486{ 473{
487 struct efx_nic *efx = netdev_priv(net_dev); 474 struct efx_nic *efx = netdev_priv(net_dev);
488 struct efx_mac_stats *mac_stats = &efx->mac_stats; 475 struct efx_mac_stats *mac_stats = &efx->mac_stats;
489 struct efx_ethtool_stat *stat; 476 const struct efx_ethtool_stat *stat;
490 struct efx_channel *channel; 477 struct efx_channel *channel;
491 struct efx_tx_queue *tx_queue; 478 struct efx_tx_queue *tx_queue;
492 struct rtnl_link_stats64 temp;
493 int i; 479 int i;
494 480
495 EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS); 481 EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS);
496 482
483 spin_lock_bh(&efx->stats_lock);
484
497 /* Update MAC and NIC statistics */ 485 /* Update MAC and NIC statistics */
498 dev_get_stats(net_dev, &temp); 486 efx->type->update_stats(efx);
499 487
500 /* Fill detailed statistics buffer */ 488 /* Fill detailed statistics buffer */
501 for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) { 489 for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) {
@@ -525,6 +513,8 @@ static void efx_ethtool_get_stats(struct net_device *net_dev,
525 break; 513 break;
526 } 514 }
527 } 515 }
516
517 spin_unlock_bh(&efx->stats_lock);
528} 518}
529 519
530static void efx_ethtool_self_test(struct net_device *net_dev, 520static void efx_ethtool_self_test(struct net_device *net_dev,
@@ -747,7 +737,7 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
747 /* Recover by resetting the EM block */ 737 /* Recover by resetting the EM block */
748 falcon_stop_nic_stats(efx); 738 falcon_stop_nic_stats(efx);
749 falcon_drain_tx_fifo(efx); 739 falcon_drain_tx_fifo(efx);
750 efx->mac_op->reconfigure(efx); 740 falcon_reconfigure_xmac(efx);
751 falcon_start_nic_stats(efx); 741 falcon_start_nic_stats(efx);
752 } else { 742 } else {
753 /* Schedule a reset to recover */ 743 /* Schedule a reset to recover */
@@ -772,7 +762,7 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
772 /* Reconfigure the MAC. The PHY *may* generate a link state change event 762 /* Reconfigure the MAC. The PHY *may* generate a link state change event
773 * if the user just changed the advertised capabilities, but there's no 763 * if the user just changed the advertised capabilities, but there's no
774 * harm doing this twice */ 764 * harm doing this twice */
775 efx->mac_op->reconfigure(efx); 765 efx->type->reconfigure_mac(efx);
776 766
777out: 767out:
778 mutex_unlock(&efx->mac_lock); 768 mutex_unlock(&efx->mac_lock);
diff --git a/drivers/net/ethernet/sfc/falcon.c b/drivers/net/ethernet/sfc/falcon.c
index 8ae1ebd35397..98285115df10 100644
--- a/drivers/net/ethernet/sfc/falcon.c
+++ b/drivers/net/ethernet/sfc/falcon.c
@@ -19,7 +19,6 @@
19#include "net_driver.h" 19#include "net_driver.h"
20#include "bitfield.h" 20#include "bitfield.h"
21#include "efx.h" 21#include "efx.h"
22#include "mac.h"
23#include "spi.h" 22#include "spi.h"
24#include "nic.h" 23#include "nic.h"
25#include "regs.h" 24#include "regs.h"
@@ -89,7 +88,7 @@ static int falcon_getscl(void *data)
89 return EFX_OWORD_FIELD(reg, FRF_AB_GPIO0_IN); 88 return EFX_OWORD_FIELD(reg, FRF_AB_GPIO0_IN);
90} 89}
91 90
92static struct i2c_algo_bit_data falcon_i2c_bit_operations = { 91static const struct i2c_algo_bit_data falcon_i2c_bit_operations = {
93 .setsda = falcon_setsda, 92 .setsda = falcon_setsda,
94 .setscl = falcon_setscl, 93 .setscl = falcon_setscl,
95 .getsda = falcon_getsda, 94 .getsda = falcon_getsda,
@@ -104,8 +103,6 @@ static void falcon_push_irq_moderation(struct efx_channel *channel)
104 efx_dword_t timer_cmd; 103 efx_dword_t timer_cmd;
105 struct efx_nic *efx = channel->efx; 104 struct efx_nic *efx = channel->efx;
106 105
107 BUILD_BUG_ON(EFX_IRQ_MOD_MAX > (1 << FRF_AB_TC_TIMER_VAL_WIDTH));
108
109 /* Set timer register */ 106 /* Set timer register */
110 if (channel->irq_moderation) { 107 if (channel->irq_moderation) {
111 EFX_POPULATE_DWORD_2(timer_cmd, 108 EFX_POPULATE_DWORD_2(timer_cmd,
@@ -177,27 +174,24 @@ irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id)
177 "IRQ %d on CPU %d status " EFX_OWORD_FMT "\n", 174 "IRQ %d on CPU %d status " EFX_OWORD_FMT "\n",
178 irq, raw_smp_processor_id(), EFX_OWORD_VAL(*int_ker)); 175 irq, raw_smp_processor_id(), EFX_OWORD_VAL(*int_ker));
179 176
177 /* Check to see if we have a serious error condition */
178 syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT);
179 if (unlikely(syserr))
180 return efx_nic_fatal_interrupt(efx);
181
180 /* Determine interrupting queues, clear interrupt status 182 /* Determine interrupting queues, clear interrupt status
181 * register and acknowledge the device interrupt. 183 * register and acknowledge the device interrupt.
182 */ 184 */
183 BUILD_BUG_ON(FSF_AZ_NET_IVEC_INT_Q_WIDTH > EFX_MAX_CHANNELS); 185 BUILD_BUG_ON(FSF_AZ_NET_IVEC_INT_Q_WIDTH > EFX_MAX_CHANNELS);
184 queues = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_INT_Q); 186 queues = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_INT_Q);
185
186 /* Check to see if we have a serious error condition */
187 if (queues & (1U << efx->fatal_irq_level)) {
188 syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT);
189 if (unlikely(syserr))
190 return efx_nic_fatal_interrupt(efx);
191 }
192
193 EFX_ZERO_OWORD(*int_ker); 187 EFX_ZERO_OWORD(*int_ker);
194 wmb(); /* Ensure the vector is cleared before interrupt ack */ 188 wmb(); /* Ensure the vector is cleared before interrupt ack */
195 falcon_irq_ack_a1(efx); 189 falcon_irq_ack_a1(efx);
196 190
197 if (queues & 1) 191 if (queues & 1)
198 efx_schedule_channel(efx_get_channel(efx, 0)); 192 efx_schedule_channel_irq(efx_get_channel(efx, 0));
199 if (queues & 2) 193 if (queues & 2)
200 efx_schedule_channel(efx_get_channel(efx, 1)); 194 efx_schedule_channel_irq(efx_get_channel(efx, 1));
201 return IRQ_HANDLED; 195 return IRQ_HANDLED;
202} 196}
203/************************************************************************** 197/**************************************************************************
@@ -613,7 +607,7 @@ static void falcon_stats_complete(struct efx_nic *efx)
613 nic_data->stats_pending = false; 607 nic_data->stats_pending = false;
614 if (*nic_data->stats_dma_done == FALCON_STATS_DONE) { 608 if (*nic_data->stats_dma_done == FALCON_STATS_DONE) {
615 rmb(); /* read the done flag before the stats */ 609 rmb(); /* read the done flag before the stats */
616 efx->mac_op->update_stats(efx); 610 falcon_update_stats_xmac(efx);
617 } else { 611 } else {
618 netif_err(efx, hw, efx->net_dev, 612 netif_err(efx, hw, efx->net_dev,
619 "timed out waiting for statistics\n"); 613 "timed out waiting for statistics\n");
@@ -670,7 +664,7 @@ static int falcon_reconfigure_port(struct efx_nic *efx)
670 falcon_reset_macs(efx); 664 falcon_reset_macs(efx);
671 665
672 efx->phy_op->reconfigure(efx); 666 efx->phy_op->reconfigure(efx);
673 rc = efx->mac_op->reconfigure(efx); 667 rc = falcon_reconfigure_xmac(efx);
674 BUG_ON(rc); 668 BUG_ON(rc);
675 669
676 falcon_start_nic_stats(efx); 670 falcon_start_nic_stats(efx);
@@ -1218,7 +1212,7 @@ static void falcon_monitor(struct efx_nic *efx)
1218 falcon_deconfigure_mac_wrapper(efx); 1212 falcon_deconfigure_mac_wrapper(efx);
1219 1213
1220 falcon_reset_macs(efx); 1214 falcon_reset_macs(efx);
1221 rc = efx->mac_op->reconfigure(efx); 1215 rc = falcon_reconfigure_xmac(efx);
1222 BUG_ON(rc); 1216 BUG_ON(rc);
1223 1217
1224 falcon_start_nic_stats(efx); 1218 falcon_start_nic_stats(efx);
@@ -1472,6 +1466,8 @@ static int falcon_probe_nic(struct efx_nic *efx)
1472 goto fail5; 1466 goto fail5;
1473 } 1467 }
1474 1468
1469 efx->timer_quantum_ns = 4968; /* 621 cycles */
1470
1475 /* Initialise I2C adapter */ 1471 /* Initialise I2C adapter */
1476 board = falcon_board(efx); 1472 board = falcon_board(efx);
1477 board->i2c_adap.owner = THIS_MODULE; 1473 board->i2c_adap.owner = THIS_MODULE;
@@ -1676,7 +1672,7 @@ static void falcon_update_nic_stats(struct efx_nic *efx)
1676 *nic_data->stats_dma_done == FALCON_STATS_DONE) { 1672 *nic_data->stats_dma_done == FALCON_STATS_DONE) {
1677 nic_data->stats_pending = false; 1673 nic_data->stats_pending = false;
1678 rmb(); /* read the done flag before the stats */ 1674 rmb(); /* read the done flag before the stats */
1679 efx->mac_op->update_stats(efx); 1675 falcon_update_stats_xmac(efx);
1680 } 1676 }
1681} 1677}
1682 1678
@@ -1767,13 +1763,13 @@ const struct efx_nic_type falcon_a1_nic_type = {
1767 .stop_stats = falcon_stop_nic_stats, 1763 .stop_stats = falcon_stop_nic_stats,
1768 .set_id_led = falcon_set_id_led, 1764 .set_id_led = falcon_set_id_led,
1769 .push_irq_moderation = falcon_push_irq_moderation, 1765 .push_irq_moderation = falcon_push_irq_moderation,
1770 .push_multicast_hash = falcon_push_multicast_hash,
1771 .reconfigure_port = falcon_reconfigure_port, 1766 .reconfigure_port = falcon_reconfigure_port,
1767 .reconfigure_mac = falcon_reconfigure_xmac,
1768 .check_mac_fault = falcon_xmac_check_fault,
1772 .get_wol = falcon_get_wol, 1769 .get_wol = falcon_get_wol,
1773 .set_wol = falcon_set_wol, 1770 .set_wol = falcon_set_wol,
1774 .resume_wol = efx_port_dummy_op_void, 1771 .resume_wol = efx_port_dummy_op_void,
1775 .test_nvram = falcon_test_nvram, 1772 .test_nvram = falcon_test_nvram,
1776 .default_mac_ops = &falcon_xmac_operations,
1777 1773
1778 .revision = EFX_REV_FALCON_A1, 1774 .revision = EFX_REV_FALCON_A1,
1779 .mem_map_size = 0x20000, 1775 .mem_map_size = 0x20000,
@@ -1786,6 +1782,7 @@ const struct efx_nic_type falcon_a1_nic_type = {
1786 .rx_buffer_padding = 0x24, 1782 .rx_buffer_padding = 0x24,
1787 .max_interrupt_mode = EFX_INT_MODE_MSI, 1783 .max_interrupt_mode = EFX_INT_MODE_MSI,
1788 .phys_addr_channels = 4, 1784 .phys_addr_channels = 4,
1785 .timer_period_max = 1 << FRF_AB_TC_TIMER_VAL_WIDTH,
1789 .tx_dc_base = 0x130000, 1786 .tx_dc_base = 0x130000,
1790 .rx_dc_base = 0x100000, 1787 .rx_dc_base = 0x100000,
1791 .offload_features = NETIF_F_IP_CSUM, 1788 .offload_features = NETIF_F_IP_CSUM,
@@ -1809,14 +1806,14 @@ const struct efx_nic_type falcon_b0_nic_type = {
1809 .stop_stats = falcon_stop_nic_stats, 1806 .stop_stats = falcon_stop_nic_stats,
1810 .set_id_led = falcon_set_id_led, 1807 .set_id_led = falcon_set_id_led,
1811 .push_irq_moderation = falcon_push_irq_moderation, 1808 .push_irq_moderation = falcon_push_irq_moderation,
1812 .push_multicast_hash = falcon_push_multicast_hash,
1813 .reconfigure_port = falcon_reconfigure_port, 1809 .reconfigure_port = falcon_reconfigure_port,
1810 .reconfigure_mac = falcon_reconfigure_xmac,
1811 .check_mac_fault = falcon_xmac_check_fault,
1814 .get_wol = falcon_get_wol, 1812 .get_wol = falcon_get_wol,
1815 .set_wol = falcon_set_wol, 1813 .set_wol = falcon_set_wol,
1816 .resume_wol = efx_port_dummy_op_void, 1814 .resume_wol = efx_port_dummy_op_void,
1817 .test_registers = falcon_b0_test_registers, 1815 .test_registers = falcon_b0_test_registers,
1818 .test_nvram = falcon_test_nvram, 1816 .test_nvram = falcon_test_nvram,
1819 .default_mac_ops = &falcon_xmac_operations,
1820 1817
1821 .revision = EFX_REV_FALCON_B0, 1818 .revision = EFX_REV_FALCON_B0,
1822 /* Map everything up to and including the RSS indirection 1819 /* Map everything up to and including the RSS indirection
@@ -1837,6 +1834,7 @@ const struct efx_nic_type falcon_b0_nic_type = {
1837 .phys_addr_channels = 32, /* Hardware limit is 64, but the legacy 1834 .phys_addr_channels = 32, /* Hardware limit is 64, but the legacy
1838 * interrupt handler only supports 32 1835 * interrupt handler only supports 32
1839 * channels */ 1836 * channels */
1837 .timer_period_max = 1 << FRF_AB_TC_TIMER_VAL_WIDTH,
1840 .tx_dc_base = 0x130000, 1838 .tx_dc_base = 0x130000,
1841 .rx_dc_base = 0x100000, 1839 .rx_dc_base = 0x100000,
1842 .offload_features = NETIF_F_IP_CSUM | NETIF_F_RXHASH | NETIF_F_NTUPLE, 1840 .offload_features = NETIF_F_IP_CSUM | NETIF_F_RXHASH | NETIF_F_NTUPLE,
diff --git a/drivers/net/ethernet/sfc/falcon_boards.c b/drivers/net/ethernet/sfc/falcon_boards.c
index 6cc16b8cc6f4..2084cc6ede52 100644
--- a/drivers/net/ethernet/sfc/falcon_boards.c
+++ b/drivers/net/ethernet/sfc/falcon_boards.c
@@ -87,7 +87,7 @@ static const u8 falcon_lm87_common_regs[] = {
87 0 87 0
88}; 88};
89 89
90static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info, 90static int efx_init_lm87(struct efx_nic *efx, const struct i2c_board_info *info,
91 const u8 *reg_values) 91 const u8 *reg_values)
92{ 92{
93 struct falcon_board *board = falcon_board(efx); 93 struct falcon_board *board = falcon_board(efx);
@@ -179,7 +179,7 @@ static int efx_check_lm87(struct efx_nic *efx, unsigned mask)
179#else /* !CONFIG_SENSORS_LM87 */ 179#else /* !CONFIG_SENSORS_LM87 */
180 180
181static inline int 181static inline int
182efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info, 182efx_init_lm87(struct efx_nic *efx, const struct i2c_board_info *info,
183 const u8 *reg_values) 183 const u8 *reg_values)
184{ 184{
185 return 0; 185 return 0;
@@ -442,7 +442,7 @@ static int sfe4001_check_hw(struct efx_nic *efx)
442 return (status < 0) ? -EIO : -ERANGE; 442 return (status < 0) ? -EIO : -ERANGE;
443} 443}
444 444
445static struct i2c_board_info sfe4001_hwmon_info = { 445static const struct i2c_board_info sfe4001_hwmon_info = {
446 I2C_BOARD_INFO("max6647", 0x4e), 446 I2C_BOARD_INFO("max6647", 0x4e),
447}; 447};
448 448
@@ -522,7 +522,7 @@ static const u8 sfe4002_lm87_regs[] = {
522 0 522 0
523}; 523};
524 524
525static struct i2c_board_info sfe4002_hwmon_info = { 525static const struct i2c_board_info sfe4002_hwmon_info = {
526 I2C_BOARD_INFO("lm87", 0x2e), 526 I2C_BOARD_INFO("lm87", 0x2e),
527 .platform_data = &sfe4002_lm87_channel, 527 .platform_data = &sfe4002_lm87_channel,
528}; 528};
@@ -591,7 +591,7 @@ static const u8 sfn4112f_lm87_regs[] = {
591 0 591 0
592}; 592};
593 593
594static struct i2c_board_info sfn4112f_hwmon_info = { 594static const struct i2c_board_info sfn4112f_hwmon_info = {
595 I2C_BOARD_INFO("lm87", 0x2e), 595 I2C_BOARD_INFO("lm87", 0x2e),
596 .platform_data = &sfn4112f_lm87_channel, 596 .platform_data = &sfn4112f_lm87_channel,
597}; 597};
@@ -653,7 +653,7 @@ static const u8 sfe4003_lm87_regs[] = {
653 0 653 0
654}; 654};
655 655
656static struct i2c_board_info sfe4003_hwmon_info = { 656static const struct i2c_board_info sfe4003_hwmon_info = {
657 I2C_BOARD_INFO("lm87", 0x2e), 657 I2C_BOARD_INFO("lm87", 0x2e),
658 .platform_data = &sfe4003_lm87_channel, 658 .platform_data = &sfe4003_lm87_channel,
659}; 659};
diff --git a/drivers/net/ethernet/sfc/falcon_xmac.c b/drivers/net/ethernet/sfc/falcon_xmac.c
index 9516452c079c..6106ef15dee3 100644
--- a/drivers/net/ethernet/sfc/falcon_xmac.c
+++ b/drivers/net/ethernet/sfc/falcon_xmac.c
@@ -14,7 +14,6 @@
14#include "nic.h" 14#include "nic.h"
15#include "regs.h" 15#include "regs.h"
16#include "io.h" 16#include "io.h"
17#include "mac.h"
18#include "mdio_10g.h" 17#include "mdio_10g.h"
19#include "workarounds.h" 18#include "workarounds.h"
20 19
@@ -139,7 +138,7 @@ static bool falcon_xmac_link_ok(struct efx_nic *efx)
139 return (efx->loopback_mode == LOOPBACK_XGMII || 138 return (efx->loopback_mode == LOOPBACK_XGMII ||
140 falcon_xgxs_link_ok(efx)) && 139 falcon_xgxs_link_ok(efx)) &&
141 (!(efx->mdio.mmds & (1 << MDIO_MMD_PHYXS)) || 140 (!(efx->mdio.mmds & (1 << MDIO_MMD_PHYXS)) ||
142 LOOPBACK_INTERNAL(efx) || 141 LOOPBACK_INTERNAL(efx) ||
143 efx_mdio_phyxgxs_lane_sync(efx)); 142 efx_mdio_phyxgxs_lane_sync(efx));
144} 143}
145 144
@@ -270,12 +269,12 @@ static bool falcon_xmac_link_ok_retry(struct efx_nic *efx, int tries)
270 return mac_up; 269 return mac_up;
271} 270}
272 271
273static bool falcon_xmac_check_fault(struct efx_nic *efx) 272bool falcon_xmac_check_fault(struct efx_nic *efx)
274{ 273{
275 return !falcon_xmac_link_ok_retry(efx, 5); 274 return !falcon_xmac_link_ok_retry(efx, 5);
276} 275}
277 276
278static int falcon_reconfigure_xmac(struct efx_nic *efx) 277int falcon_reconfigure_xmac(struct efx_nic *efx)
279{ 278{
280 struct falcon_nic_data *nic_data = efx->nic_data; 279 struct falcon_nic_data *nic_data = efx->nic_data;
281 280
@@ -290,7 +289,7 @@ static int falcon_reconfigure_xmac(struct efx_nic *efx)
290 return 0; 289 return 0;
291} 290}
292 291
293static void falcon_update_stats_xmac(struct efx_nic *efx) 292void falcon_update_stats_xmac(struct efx_nic *efx)
294{ 293{
295 struct efx_mac_stats *mac_stats = &efx->mac_stats; 294 struct efx_mac_stats *mac_stats = &efx->mac_stats;
296 295
@@ -361,9 +360,3 @@ void falcon_poll_xmac(struct efx_nic *efx)
361 nic_data->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 1); 360 nic_data->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 1);
362 falcon_ack_status_intr(efx); 361 falcon_ack_status_intr(efx);
363} 362}
364
365const struct efx_mac_operations falcon_xmac_operations = {
366 .reconfigure = falcon_reconfigure_xmac,
367 .update_stats = falcon_update_stats_xmac,
368 .check_fault = falcon_xmac_check_fault,
369};
diff --git a/drivers/net/ethernet/sfc/mac.h b/drivers/net/ethernet/sfc/mac.h
deleted file mode 100644
index d6a255d0856b..000000000000
--- a/drivers/net/ethernet/sfc/mac.h
+++ /dev/null
@@ -1,21 +0,0 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2009 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_MAC_H
12#define EFX_MAC_H
13
14#include "net_driver.h"
15
16extern const struct efx_mac_operations falcon_xmac_operations;
17extern const struct efx_mac_operations efx_mcdi_mac_operations;
18extern int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr,
19 u32 dma_len, int enable, int clear);
20
21#endif
diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c
index 81a425397468..619f63a66ce7 100644
--- a/drivers/net/ethernet/sfc/mcdi.c
+++ b/drivers/net/ethernet/sfc/mcdi.c
@@ -22,22 +22,22 @@
22 ************************************************************************** 22 **************************************************************************
23 */ 23 */
24 24
25/* Software-defined structure to the shared-memory */
26#define CMD_NOTIFY_PORT0 0
27#define CMD_NOTIFY_PORT1 4
28#define CMD_PDU_PORT0 0x008
29#define CMD_PDU_PORT1 0x108
30#define REBOOT_FLAG_PORT0 0x3f8
31#define REBOOT_FLAG_PORT1 0x3fc
32
33#define MCDI_RPC_TIMEOUT 10 /*seconds */ 25#define MCDI_RPC_TIMEOUT 10 /*seconds */
34 26
35#define MCDI_PDU(efx) \ 27#define MCDI_PDU(efx) \
36 (efx_port_num(efx) ? CMD_PDU_PORT1 : CMD_PDU_PORT0) 28 (efx_port_num(efx) ? MC_SMEM_P1_PDU_OFST : MC_SMEM_P0_PDU_OFST)
37#define MCDI_DOORBELL(efx) \ 29#define MCDI_DOORBELL(efx) \
38 (efx_port_num(efx) ? CMD_NOTIFY_PORT1 : CMD_NOTIFY_PORT0) 30 (efx_port_num(efx) ? MC_SMEM_P1_DOORBELL_OFST : MC_SMEM_P0_DOORBELL_OFST)
39#define MCDI_REBOOT_FLAG(efx) \ 31#define MCDI_STATUS(efx) \
40 (efx_port_num(efx) ? REBOOT_FLAG_PORT1 : REBOOT_FLAG_PORT0) 32 (efx_port_num(efx) ? MC_SMEM_P1_STATUS_OFST : MC_SMEM_P0_STATUS_OFST)
33
34/* A reboot/assertion causes the MCDI status word to be set after the
35 * command word is set or a REBOOT event is sent. If we notice a reboot
36 * via these mechanisms then wait 10ms for the status word to be set. */
37#define MCDI_STATUS_DELAY_US 100
38#define MCDI_STATUS_DELAY_COUNT 100
39#define MCDI_STATUS_SLEEP_MS \
40 (MCDI_STATUS_DELAY_US * MCDI_STATUS_DELAY_COUNT / 1000)
41 41
42#define SEQ_MASK \ 42#define SEQ_MASK \
43 EFX_MASK32(EFX_WIDTH(MCDI_HEADER_SEQ)) 43 EFX_MASK32(EFX_WIDTH(MCDI_HEADER_SEQ))
@@ -77,7 +77,7 @@ static void efx_mcdi_copyin(struct efx_nic *efx, unsigned cmd,
77 u32 xflags, seqno; 77 u32 xflags, seqno;
78 78
79 BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT); 79 BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT);
80 BUG_ON(inlen & 3 || inlen >= 0x100); 80 BUG_ON(inlen & 3 || inlen >= MC_SMEM_PDU_LEN);
81 81
82 seqno = mcdi->seqno & SEQ_MASK; 82 seqno = mcdi->seqno & SEQ_MASK;
83 xflags = 0; 83 xflags = 0;
@@ -111,7 +111,7 @@ static void efx_mcdi_copyout(struct efx_nic *efx, u8 *outbuf, size_t outlen)
111 int i; 111 int i;
112 112
113 BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT); 113 BUG_ON(atomic_read(&mcdi->state) == MCDI_STATE_QUIESCENT);
114 BUG_ON(outlen & 3 || outlen >= 0x100); 114 BUG_ON(outlen & 3 || outlen >= MC_SMEM_PDU_LEN);
115 115
116 for (i = 0; i < outlen; i += 4) 116 for (i = 0; i < outlen; i += 4)
117 *((__le32 *)(outbuf + i)) = _efx_readd(efx, pdu + 4 + i); 117 *((__le32 *)(outbuf + i)) = _efx_readd(efx, pdu + 4 + i);
@@ -210,7 +210,7 @@ out:
210/* Test and clear MC-rebooted flag for this port/function */ 210/* Test and clear MC-rebooted flag for this port/function */
211int efx_mcdi_poll_reboot(struct efx_nic *efx) 211int efx_mcdi_poll_reboot(struct efx_nic *efx)
212{ 212{
213 unsigned int addr = FR_CZ_MC_TREG_SMEM + MCDI_REBOOT_FLAG(efx); 213 unsigned int addr = FR_CZ_MC_TREG_SMEM + MCDI_STATUS(efx);
214 efx_dword_t reg; 214 efx_dword_t reg;
215 uint32_t value; 215 uint32_t value;
216 216
@@ -384,6 +384,11 @@ int efx_mcdi_rpc(struct efx_nic *efx, unsigned cmd,
384 netif_dbg(efx, hw, efx->net_dev, 384 netif_dbg(efx, hw, efx->net_dev,
385 "MC command 0x%x inlen %d failed rc=%d\n", 385 "MC command 0x%x inlen %d failed rc=%d\n",
386 cmd, (int)inlen, -rc); 386 cmd, (int)inlen, -rc);
387
388 if (rc == -EIO || rc == -EINTR) {
389 msleep(MCDI_STATUS_SLEEP_MS);
390 efx_mcdi_poll_reboot(efx);
391 }
387 } 392 }
388 393
389 efx_mcdi_release(mcdi); 394 efx_mcdi_release(mcdi);
@@ -465,10 +470,20 @@ static void efx_mcdi_ev_death(struct efx_nic *efx, int rc)
465 mcdi->resplen = 0; 470 mcdi->resplen = 0;
466 ++mcdi->credits; 471 ++mcdi->credits;
467 } 472 }
468 } else 473 } else {
474 int count;
475
469 /* Nobody was waiting for an MCDI request, so trigger a reset */ 476 /* Nobody was waiting for an MCDI request, so trigger a reset */
470 efx_schedule_reset(efx, RESET_TYPE_MC_FAILURE); 477 efx_schedule_reset(efx, RESET_TYPE_MC_FAILURE);
471 478
479 /* Consume the status word since efx_mcdi_rpc_finish() won't */
480 for (count = 0; count < MCDI_STATUS_DELAY_COUNT; ++count) {
481 if (efx_mcdi_poll_reboot(efx))
482 break;
483 udelay(MCDI_STATUS_DELAY_US);
484 }
485 }
486
472 spin_unlock(&mcdi->iface_lock); 487 spin_unlock(&mcdi->iface_lock);
473} 488}
474 489
@@ -502,49 +517,6 @@ static void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev)
502 efx_link_status_changed(efx); 517 efx_link_status_changed(efx);
503} 518}
504 519
505static const char *sensor_names[] = {
506 [MC_CMD_SENSOR_CONTROLLER_TEMP] = "Controller temp. sensor",
507 [MC_CMD_SENSOR_PHY_COMMON_TEMP] = "PHY shared temp. sensor",
508 [MC_CMD_SENSOR_CONTROLLER_COOLING] = "Controller cooling",
509 [MC_CMD_SENSOR_PHY0_TEMP] = "PHY 0 temp. sensor",
510 [MC_CMD_SENSOR_PHY0_COOLING] = "PHY 0 cooling",
511 [MC_CMD_SENSOR_PHY1_TEMP] = "PHY 1 temp. sensor",
512 [MC_CMD_SENSOR_PHY1_COOLING] = "PHY 1 cooling",
513 [MC_CMD_SENSOR_IN_1V0] = "1.0V supply sensor",
514 [MC_CMD_SENSOR_IN_1V2] = "1.2V supply sensor",
515 [MC_CMD_SENSOR_IN_1V8] = "1.8V supply sensor",
516 [MC_CMD_SENSOR_IN_2V5] = "2.5V supply sensor",
517 [MC_CMD_SENSOR_IN_3V3] = "3.3V supply sensor",
518 [MC_CMD_SENSOR_IN_12V0] = "12V supply sensor"
519};
520
521static const char *sensor_status_names[] = {
522 [MC_CMD_SENSOR_STATE_OK] = "OK",
523 [MC_CMD_SENSOR_STATE_WARNING] = "Warning",
524 [MC_CMD_SENSOR_STATE_FATAL] = "Fatal",
525 [MC_CMD_SENSOR_STATE_BROKEN] = "Device failure",
526};
527
528static void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev)
529{
530 unsigned int monitor, state, value;
531 const char *name, *state_txt;
532 monitor = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_MONITOR);
533 state = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_STATE);
534 value = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_VALUE);
535 /* Deal gracefully with the board having more drivers than we
536 * know about, but do not expect new sensor states. */
537 name = (monitor >= ARRAY_SIZE(sensor_names))
538 ? "No sensor name available" :
539 sensor_names[monitor];
540 EFX_BUG_ON_PARANOID(state >= ARRAY_SIZE(sensor_status_names));
541 state_txt = sensor_status_names[state];
542
543 netif_err(efx, hw, efx->net_dev,
544 "Sensor %d (%s) reports condition '%s' for raw value %d\n",
545 monitor, name, state_txt, value);
546}
547
548/* Called from falcon_process_eventq for MCDI events */ 520/* Called from falcon_process_eventq for MCDI events */
549void efx_mcdi_process_event(struct efx_channel *channel, 521void efx_mcdi_process_event(struct efx_channel *channel,
550 efx_qword_t *event) 522 efx_qword_t *event)
@@ -604,7 +576,7 @@ void efx_mcdi_process_event(struct efx_channel *channel,
604 576
605void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len) 577void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len)
606{ 578{
607 u8 outbuf[ALIGN(MC_CMD_GET_VERSION_V1_OUT_LEN, 4)]; 579 u8 outbuf[ALIGN(MC_CMD_GET_VERSION_OUT_LEN, 4)];
608 size_t outlength; 580 size_t outlength;
609 const __le16 *ver_words; 581 const __le16 *ver_words;
610 int rc; 582 int rc;
@@ -616,7 +588,7 @@ void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len)
616 if (rc) 588 if (rc)
617 goto fail; 589 goto fail;
618 590
619 if (outlength < MC_CMD_GET_VERSION_V1_OUT_LEN) { 591 if (outlength < MC_CMD_GET_VERSION_OUT_LEN) {
620 rc = -EIO; 592 rc = -EIO;
621 goto fail; 593 goto fail;
622 } 594 }
@@ -663,9 +635,9 @@ fail:
663} 635}
664 636
665int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, 637int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
666 u16 *fw_subtype_list) 638 u16 *fw_subtype_list, u32 *capabilities)
667{ 639{
668 uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LEN]; 640 uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LENMIN];
669 size_t outlen; 641 size_t outlen;
670 int port_num = efx_port_num(efx); 642 int port_num = efx_port_num(efx);
671 int offset; 643 int offset;
@@ -678,7 +650,7 @@ int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
678 if (rc) 650 if (rc)
679 goto fail; 651 goto fail;
680 652
681 if (outlen < MC_CMD_GET_BOARD_CFG_OUT_LEN) { 653 if (outlen < MC_CMD_GET_BOARD_CFG_OUT_LENMIN) {
682 rc = -EIO; 654 rc = -EIO;
683 goto fail; 655 goto fail;
684 } 656 }
@@ -691,7 +663,16 @@ int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
691 if (fw_subtype_list) 663 if (fw_subtype_list)
692 memcpy(fw_subtype_list, 664 memcpy(fw_subtype_list,
693 outbuf + MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST, 665 outbuf + MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST,
694 MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_LEN); 666 MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MINNUM *
667 sizeof(fw_subtype_list[0]));
668 if (capabilities) {
669 if (port_num)
670 *capabilities = MCDI_DWORD(outbuf,
671 GET_BOARD_CFG_OUT_CAPABILITIES_PORT1);
672 else
673 *capabilities = MCDI_DWORD(outbuf,
674 GET_BOARD_CFG_OUT_CAPABILITIES_PORT0);
675 }
695 676
696 return 0; 677 return 0;
697 678
@@ -779,7 +760,7 @@ int efx_mcdi_nvram_info(struct efx_nic *efx, unsigned int type,
779 *size_out = MCDI_DWORD(outbuf, NVRAM_INFO_OUT_SIZE); 760 *size_out = MCDI_DWORD(outbuf, NVRAM_INFO_OUT_SIZE);
780 *erase_size_out = MCDI_DWORD(outbuf, NVRAM_INFO_OUT_ERASESIZE); 761 *erase_size_out = MCDI_DWORD(outbuf, NVRAM_INFO_OUT_ERASESIZE);
781 *protected_out = !!(MCDI_DWORD(outbuf, NVRAM_INFO_OUT_FLAGS) & 762 *protected_out = !!(MCDI_DWORD(outbuf, NVRAM_INFO_OUT_FLAGS) &
782 (1 << MC_CMD_NVRAM_PROTECTED_LBN)); 763 (1 << MC_CMD_NVRAM_INFO_OUT_PROTECTED_LBN));
783 return 0; 764 return 0;
784 765
785fail: 766fail:
@@ -1060,7 +1041,7 @@ void efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode)
1060 1041
1061int efx_mcdi_reset_port(struct efx_nic *efx) 1042int efx_mcdi_reset_port(struct efx_nic *efx)
1062{ 1043{
1063 int rc = efx_mcdi_rpc(efx, MC_CMD_PORT_RESET, NULL, 0, NULL, 0, NULL); 1044 int rc = efx_mcdi_rpc(efx, MC_CMD_ENTITY_RESET, NULL, 0, NULL, 0, NULL);
1064 if (rc) 1045 if (rc)
1065 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n", 1046 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n",
1066 __func__, rc); 1047 __func__, rc);
diff --git a/drivers/net/ethernet/sfc/mcdi.h b/drivers/net/ethernet/sfc/mcdi.h
index aced2a7856fc..fbaa6efcd744 100644
--- a/drivers/net/ethernet/sfc/mcdi.h
+++ b/drivers/net/ethernet/sfc/mcdi.h
@@ -56,6 +56,15 @@ struct efx_mcdi_iface {
56 size_t resplen; 56 size_t resplen;
57}; 57};
58 58
59struct efx_mcdi_mon {
60 struct efx_buffer dma_buf;
61 struct mutex update_lock;
62 unsigned long last_update;
63 struct device *device;
64 struct efx_mcdi_mon_attribute *attrs;
65 unsigned int n_attrs;
66};
67
59extern void efx_mcdi_init(struct efx_nic *efx); 68extern void efx_mcdi_init(struct efx_nic *efx);
60 69
61extern int efx_mcdi_rpc(struct efx_nic *efx, unsigned cmd, const u8 *inbuf, 70extern int efx_mcdi_rpc(struct efx_nic *efx, unsigned cmd, const u8 *inbuf,
@@ -68,6 +77,7 @@ extern void efx_mcdi_mode_event(struct efx_nic *efx);
68 77
69extern void efx_mcdi_process_event(struct efx_channel *channel, 78extern void efx_mcdi_process_event(struct efx_channel *channel,
70 efx_qword_t *event); 79 efx_qword_t *event);
80extern void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev);
71 81
72#define MCDI_PTR2(_buf, _ofst) \ 82#define MCDI_PTR2(_buf, _ofst) \
73 (((u8 *)_buf) + _ofst) 83 (((u8 *)_buf) + _ofst)
@@ -83,6 +93,10 @@ extern void efx_mcdi_process_event(struct efx_channel *channel,
83 93
84#define MCDI_PTR(_buf, _ofst) \ 94#define MCDI_PTR(_buf, _ofst) \
85 MCDI_PTR2(_buf, MC_CMD_ ## _ofst ## _OFST) 95 MCDI_PTR2(_buf, MC_CMD_ ## _ofst ## _OFST)
96#define MCDI_ARRAY_PTR(_buf, _field, _type, _index) \
97 MCDI_PTR2(_buf, \
98 MC_CMD_ ## _field ## _OFST + \
99 (_index) * MC_CMD_ ## _type ## _TYPEDEF_LEN)
86#define MCDI_SET_DWORD(_buf, _ofst, _value) \ 100#define MCDI_SET_DWORD(_buf, _ofst, _value) \
87 MCDI_SET_DWORD2(_buf, MC_CMD_ ## _ofst ## _OFST, _value) 101 MCDI_SET_DWORD2(_buf, MC_CMD_ ## _ofst ## _OFST, _value)
88#define MCDI_DWORD(_buf, _ofst) \ 102#define MCDI_DWORD(_buf, _ofst) \
@@ -92,12 +106,18 @@ extern void efx_mcdi_process_event(struct efx_channel *channel,
92 106
93#define MCDI_EVENT_FIELD(_ev, _field) \ 107#define MCDI_EVENT_FIELD(_ev, _field) \
94 EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field) 108 EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field)
109#define MCDI_ARRAY_FIELD(_buf, _field1, _type, _index, _field2) \
110 EFX_DWORD_FIELD( \
111 *((efx_dword_t *) \
112 (MCDI_ARRAY_PTR(_buf, _field1, _type, _index) + \
113 (MC_CMD_ ## _type ## _TYPEDEF_ ## _field2 ## _OFST & ~3))), \
114 MC_CMD_ ## _type ## _TYPEDEF_ ## _field2)
95 115
96extern void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len); 116extern void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len);
97extern int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, 117extern int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
98 bool *was_attached_out); 118 bool *was_attached_out);
99extern int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, 119extern int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
100 u16 *fw_subtype_list); 120 u16 *fw_subtype_list, u32 *capabilities);
101extern int efx_mcdi_log_ctrl(struct efx_nic *efx, bool evq, bool uart, 121extern int efx_mcdi_log_ctrl(struct efx_nic *efx, bool evq, bool uart,
102 u32 dest_evq); 122 u32 dest_evq);
103extern int efx_mcdi_nvram_types(struct efx_nic *efx, u32 *nvram_types_out); 123extern int efx_mcdi_nvram_types(struct efx_nic *efx, u32 *nvram_types_out);
@@ -126,5 +146,17 @@ extern int efx_mcdi_wol_filter_set_magic(struct efx_nic *efx,
126extern int efx_mcdi_wol_filter_get_magic(struct efx_nic *efx, int *id_out); 146extern int efx_mcdi_wol_filter_get_magic(struct efx_nic *efx, int *id_out);
127extern int efx_mcdi_wol_filter_remove(struct efx_nic *efx, int id); 147extern int efx_mcdi_wol_filter_remove(struct efx_nic *efx, int id);
128extern int efx_mcdi_wol_filter_reset(struct efx_nic *efx); 148extern int efx_mcdi_wol_filter_reset(struct efx_nic *efx);
149extern int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr,
150 u32 dma_len, int enable, int clear);
151extern int efx_mcdi_mac_reconfigure(struct efx_nic *efx);
152extern bool efx_mcdi_mac_check_fault(struct efx_nic *efx);
153
154#ifdef CONFIG_SFC_MCDI_MON
155extern int efx_mcdi_mon_probe(struct efx_nic *efx);
156extern void efx_mcdi_mon_remove(struct efx_nic *efx);
157#else
158static inline int efx_mcdi_mon_probe(struct efx_nic *efx) { return 0; }
159static inline void efx_mcdi_mon_remove(struct efx_nic *efx) {}
160#endif
129 161
130#endif /* EFX_MCDI_H */ 162#endif /* EFX_MCDI_H */
diff --git a/drivers/net/ethernet/sfc/mcdi_mac.c b/drivers/net/ethernet/sfc/mcdi_mac.c
index 50c20777a564..f67cf921bd1b 100644
--- a/drivers/net/ethernet/sfc/mcdi_mac.c
+++ b/drivers/net/ethernet/sfc/mcdi_mac.c
@@ -9,7 +9,6 @@
9 9
10#include "net_driver.h" 10#include "net_driver.h"
11#include "efx.h" 11#include "efx.h"
12#include "mac.h"
13#include "mcdi.h" 12#include "mcdi.h"
14#include "mcdi_pcol.h" 13#include "mcdi_pcol.h"
15 14
@@ -52,7 +51,7 @@ static int efx_mcdi_set_mac(struct efx_nic *efx)
52 NULL, 0, NULL); 51 NULL, 0, NULL);
53} 52}
54 53
55static int efx_mcdi_get_mac_faults(struct efx_nic *efx, u32 *faults) 54bool efx_mcdi_mac_check_fault(struct efx_nic *efx)
56{ 55{
57 u8 outbuf[MC_CMD_GET_LINK_OUT_LEN]; 56 u8 outbuf[MC_CMD_GET_LINK_OUT_LEN];
58 size_t outlength; 57 size_t outlength;
@@ -62,16 +61,13 @@ static int efx_mcdi_get_mac_faults(struct efx_nic *efx, u32 *faults)
62 61
63 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0, 62 rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0,
64 outbuf, sizeof(outbuf), &outlength); 63 outbuf, sizeof(outbuf), &outlength);
65 if (rc) 64 if (rc) {
66 goto fail; 65 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n",
67 66 __func__, rc);
68 *faults = MCDI_DWORD(outbuf, GET_LINK_OUT_MAC_FAULT); 67 return true;
69 return 0; 68 }
70 69
71fail: 70 return MCDI_DWORD(outbuf, GET_LINK_OUT_MAC_FAULT) != 0;
72 netif_err(efx, hw, efx->net_dev, "%s: failed rc=%d\n",
73 __func__, rc);
74 return rc;
75} 71}
76 72
77int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr, 73int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr,
@@ -84,7 +80,7 @@ int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr,
84 u32 addr_hi; 80 u32 addr_hi;
85 u32 addr_lo; 81 u32 addr_lo;
86 82
87 BUILD_BUG_ON(MC_CMD_MAC_STATS_OUT_LEN != 0); 83 BUILD_BUG_ON(MC_CMD_MAC_STATS_OUT_DMA_LEN != 0);
88 84
89 addr_lo = ((u64)dma_addr) >> 0; 85 addr_lo = ((u64)dma_addr) >> 0;
90 addr_hi = ((u64)dma_addr) >> 32; 86 addr_hi = ((u64)dma_addr) >> 32;
@@ -93,13 +89,13 @@ int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr,
93 MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_ADDR_HI, addr_hi); 89 MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_ADDR_HI, addr_hi);
94 cmd_ptr = (efx_dword_t *)MCDI_PTR(inbuf, MAC_STATS_IN_CMD); 90 cmd_ptr = (efx_dword_t *)MCDI_PTR(inbuf, MAC_STATS_IN_CMD);
95 EFX_POPULATE_DWORD_7(*cmd_ptr, 91 EFX_POPULATE_DWORD_7(*cmd_ptr,
96 MC_CMD_MAC_STATS_CMD_DMA, !!enable, 92 MC_CMD_MAC_STATS_IN_DMA, !!enable,
97 MC_CMD_MAC_STATS_CMD_CLEAR, clear, 93 MC_CMD_MAC_STATS_IN_CLEAR, clear,
98 MC_CMD_MAC_STATS_CMD_PERIODIC_CHANGE, 1, 94 MC_CMD_MAC_STATS_IN_PERIODIC_CHANGE, 1,
99 MC_CMD_MAC_STATS_CMD_PERIODIC_ENABLE, !!enable, 95 MC_CMD_MAC_STATS_IN_PERIODIC_ENABLE, !!enable,
100 MC_CMD_MAC_STATS_CMD_PERIODIC_CLEAR, 0, 96 MC_CMD_MAC_STATS_IN_PERIODIC_CLEAR, 0,
101 MC_CMD_MAC_STATS_CMD_PERIODIC_NOEVENT, 1, 97 MC_CMD_MAC_STATS_IN_PERIODIC_NOEVENT, 1,
102 MC_CMD_MAC_STATS_CMD_PERIOD_MS, period); 98 MC_CMD_MAC_STATS_IN_PERIOD_MS, period);
103 MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len); 99 MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len);
104 100
105 rc = efx_mcdi_rpc(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf), 101 rc = efx_mcdi_rpc(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf),
@@ -115,31 +111,18 @@ fail:
115 return rc; 111 return rc;
116} 112}
117 113
118static int efx_mcdi_mac_reconfigure(struct efx_nic *efx) 114int efx_mcdi_mac_reconfigure(struct efx_nic *efx)
119{ 115{
120 int rc; 116 int rc;
121 117
118 WARN_ON(!mutex_is_locked(&efx->mac_lock));
119
122 rc = efx_mcdi_set_mac(efx); 120 rc = efx_mcdi_set_mac(efx);
123 if (rc != 0) 121 if (rc != 0)
124 return rc; 122 return rc;
125 123
126 /* Restore the multicast hash registers. */ 124 return efx_mcdi_rpc(efx, MC_CMD_SET_MCAST_HASH,
127 efx->type->push_multicast_hash(efx); 125 efx->multicast_hash.byte,
128 126 sizeof(efx->multicast_hash),
129 return 0; 127 NULL, 0, NULL);
130}
131
132
133static bool efx_mcdi_mac_check_fault(struct efx_nic *efx)
134{
135 u32 faults;
136 int rc = efx_mcdi_get_mac_faults(efx, &faults);
137 return (rc != 0) || (faults != 0);
138} 128}
139
140
141const struct efx_mac_operations efx_mcdi_mac_operations = {
142 .reconfigure = efx_mcdi_mac_reconfigure,
143 .update_stats = efx_port_dummy_op_void,
144 .check_fault = efx_mcdi_mac_check_fault,
145};
diff --git a/drivers/net/ethernet/sfc/mcdi_mon.c b/drivers/net/ethernet/sfc/mcdi_mon.c
new file mode 100644
index 000000000000..8a72c10b9a6c
--- /dev/null
+++ b/drivers/net/ethernet/sfc/mcdi_mon.c
@@ -0,0 +1,415 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2011 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10#include <linux/bitops.h>
11#include <linux/slab.h>
12#include <linux/hwmon.h>
13#include <linux/stat.h>
14
15#include "net_driver.h"
16#include "mcdi.h"
17#include "mcdi_pcol.h"
18#include "nic.h"
19
20enum efx_hwmon_type {
21 EFX_HWMON_UNKNOWN,
22 EFX_HWMON_TEMP, /* temperature */
23 EFX_HWMON_COOL, /* cooling device, probably a heatsink */
24 EFX_HWMON_IN /* input voltage */
25};
26
27static const struct {
28 const char *label;
29 enum efx_hwmon_type hwmon_type;
30 int port;
31} efx_mcdi_sensor_type[MC_CMD_SENSOR_ENTRY_MAXNUM] = {
32#define SENSOR(name, label, hwmon_type, port) \
33 [MC_CMD_SENSOR_##name] = { label, hwmon_type, port }
34 SENSOR(CONTROLLER_TEMP, "Controller temp.", EFX_HWMON_TEMP, -1),
35 SENSOR(PHY_COMMON_TEMP, "PHY temp.", EFX_HWMON_TEMP, -1),
36 SENSOR(CONTROLLER_COOLING, "Controller cooling", EFX_HWMON_COOL, -1),
37 SENSOR(PHY0_TEMP, "PHY temp.", EFX_HWMON_TEMP, 0),
38 SENSOR(PHY0_COOLING, "PHY cooling", EFX_HWMON_COOL, 0),
39 SENSOR(PHY1_TEMP, "PHY temp.", EFX_HWMON_TEMP, 1),
40 SENSOR(PHY1_COOLING, "PHY cooling", EFX_HWMON_COOL, 1),
41 SENSOR(IN_1V0, "1.0V supply", EFX_HWMON_IN, -1),
42 SENSOR(IN_1V2, "1.2V supply", EFX_HWMON_IN, -1),
43 SENSOR(IN_1V8, "1.8V supply", EFX_HWMON_IN, -1),
44 SENSOR(IN_2V5, "2.5V supply", EFX_HWMON_IN, -1),
45 SENSOR(IN_3V3, "3.3V supply", EFX_HWMON_IN, -1),
46 SENSOR(IN_12V0, "12.0V supply", EFX_HWMON_IN, -1),
47 SENSOR(IN_1V2A, "1.2V analogue supply", EFX_HWMON_IN, -1),
48 SENSOR(IN_VREF, "ref. voltage", EFX_HWMON_IN, -1),
49#undef SENSOR
50};
51
52static const char *const sensor_status_names[] = {
53 [MC_CMD_SENSOR_STATE_OK] = "OK",
54 [MC_CMD_SENSOR_STATE_WARNING] = "Warning",
55 [MC_CMD_SENSOR_STATE_FATAL] = "Fatal",
56 [MC_CMD_SENSOR_STATE_BROKEN] = "Device failure",
57};
58
59void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev)
60{
61 unsigned int type, state, value;
62 const char *name = NULL, *state_txt;
63
64 type = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_MONITOR);
65 state = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_STATE);
66 value = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_VALUE);
67
68 /* Deal gracefully with the board having more drivers than we
69 * know about, but do not expect new sensor states. */
70 if (type < ARRAY_SIZE(efx_mcdi_sensor_type))
71 name = efx_mcdi_sensor_type[type].label;
72 if (!name)
73 name = "No sensor name available";
74 EFX_BUG_ON_PARANOID(state >= ARRAY_SIZE(sensor_status_names));
75 state_txt = sensor_status_names[state];
76
77 netif_err(efx, hw, efx->net_dev,
78 "Sensor %d (%s) reports condition '%s' for raw value %d\n",
79 type, name, state_txt, value);
80}
81
82#ifdef CONFIG_SFC_MCDI_MON
83
84struct efx_mcdi_mon_attribute {
85 struct device_attribute dev_attr;
86 unsigned int index;
87 unsigned int type;
88 unsigned int limit_value;
89 char name[12];
90};
91
92static int efx_mcdi_mon_update(struct efx_nic *efx)
93{
94 struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
95 u8 inbuf[MC_CMD_READ_SENSORS_IN_LEN];
96 int rc;
97
98 MCDI_SET_DWORD(inbuf, READ_SENSORS_IN_DMA_ADDR_LO,
99 hwmon->dma_buf.dma_addr & 0xffffffff);
100 MCDI_SET_DWORD(inbuf, READ_SENSORS_IN_DMA_ADDR_HI,
101 (u64)hwmon->dma_buf.dma_addr >> 32);
102
103 rc = efx_mcdi_rpc(efx, MC_CMD_READ_SENSORS,
104 inbuf, sizeof(inbuf), NULL, 0, NULL);
105 if (rc == 0)
106 hwmon->last_update = jiffies;
107 return rc;
108}
109
110static ssize_t efx_mcdi_mon_show_name(struct device *dev,
111 struct device_attribute *attr,
112 char *buf)
113{
114 return sprintf(buf, "%s\n", KBUILD_MODNAME);
115}
116
117static int efx_mcdi_mon_get_entry(struct device *dev, unsigned int index,
118 efx_dword_t *entry)
119{
120 struct efx_nic *efx = dev_get_drvdata(dev);
121 struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
122 int rc;
123
124 BUILD_BUG_ON(MC_CMD_READ_SENSORS_OUT_LEN != 0);
125
126 mutex_lock(&hwmon->update_lock);
127
128 /* Use cached value if last update was < 1 s ago */
129 if (time_before(jiffies, hwmon->last_update + HZ))
130 rc = 0;
131 else
132 rc = efx_mcdi_mon_update(efx);
133
134 /* Copy out the requested entry */
135 *entry = ((efx_dword_t *)hwmon->dma_buf.addr)[index];
136
137 mutex_unlock(&hwmon->update_lock);
138
139 return rc;
140}
141
142static ssize_t efx_mcdi_mon_show_value(struct device *dev,
143 struct device_attribute *attr,
144 char *buf)
145{
146 struct efx_mcdi_mon_attribute *mon_attr =
147 container_of(attr, struct efx_mcdi_mon_attribute, dev_attr);
148 efx_dword_t entry;
149 unsigned int value;
150 int rc;
151
152 rc = efx_mcdi_mon_get_entry(dev, mon_attr->index, &entry);
153 if (rc)
154 return rc;
155
156 value = EFX_DWORD_FIELD(entry, MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE);
157
158 /* Convert temperature from degrees to milli-degrees Celsius */
159 if (efx_mcdi_sensor_type[mon_attr->type].hwmon_type == EFX_HWMON_TEMP)
160 value *= 1000;
161
162 return sprintf(buf, "%u\n", value);
163}
164
165static ssize_t efx_mcdi_mon_show_limit(struct device *dev,
166 struct device_attribute *attr,
167 char *buf)
168{
169 struct efx_mcdi_mon_attribute *mon_attr =
170 container_of(attr, struct efx_mcdi_mon_attribute, dev_attr);
171 unsigned int value;
172
173 value = mon_attr->limit_value;
174
175 /* Convert temperature from degrees to milli-degrees Celsius */
176 if (efx_mcdi_sensor_type[mon_attr->type].hwmon_type == EFX_HWMON_TEMP)
177 value *= 1000;
178
179 return sprintf(buf, "%u\n", value);
180}
181
182static ssize_t efx_mcdi_mon_show_alarm(struct device *dev,
183 struct device_attribute *attr,
184 char *buf)
185{
186 struct efx_mcdi_mon_attribute *mon_attr =
187 container_of(attr, struct efx_mcdi_mon_attribute, dev_attr);
188 efx_dword_t entry;
189 int state;
190 int rc;
191
192 rc = efx_mcdi_mon_get_entry(dev, mon_attr->index, &entry);
193 if (rc)
194 return rc;
195
196 state = EFX_DWORD_FIELD(entry, MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE);
197 return sprintf(buf, "%d\n", state != MC_CMD_SENSOR_STATE_OK);
198}
199
200static ssize_t efx_mcdi_mon_show_label(struct device *dev,
201 struct device_attribute *attr,
202 char *buf)
203{
204 struct efx_mcdi_mon_attribute *mon_attr =
205 container_of(attr, struct efx_mcdi_mon_attribute, dev_attr);
206 return sprintf(buf, "%s\n",
207 efx_mcdi_sensor_type[mon_attr->type].label);
208}
209
210static int
211efx_mcdi_mon_add_attr(struct efx_nic *efx, const char *name,
212 ssize_t (*reader)(struct device *,
213 struct device_attribute *, char *),
214 unsigned int index, unsigned int type,
215 unsigned int limit_value)
216{
217 struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
218 struct efx_mcdi_mon_attribute *attr = &hwmon->attrs[hwmon->n_attrs];
219 int rc;
220
221 strlcpy(attr->name, name, sizeof(attr->name));
222 attr->index = index;
223 attr->type = type;
224 attr->limit_value = limit_value;
225 attr->dev_attr.attr.name = attr->name;
226 attr->dev_attr.attr.mode = S_IRUGO;
227 attr->dev_attr.show = reader;
228 rc = device_create_file(&efx->pci_dev->dev, &attr->dev_attr);
229 if (rc == 0)
230 ++hwmon->n_attrs;
231 return rc;
232}
233
234int efx_mcdi_mon_probe(struct efx_nic *efx)
235{
236 struct efx_mcdi_mon *hwmon = efx_mcdi_mon(efx);
237 unsigned int n_attrs, n_temp = 0, n_cool = 0, n_in = 0;
238 u8 outbuf[MC_CMD_SENSOR_INFO_OUT_LENMAX];
239 size_t outlen;
240 char name[12];
241 u32 mask;
242 int rc, i, type;
243
244 BUILD_BUG_ON(MC_CMD_SENSOR_INFO_IN_LEN != 0);
245
246 rc = efx_mcdi_rpc(efx, MC_CMD_SENSOR_INFO, NULL, 0,
247 outbuf, sizeof(outbuf), &outlen);
248 if (rc)
249 return rc;
250 if (outlen < MC_CMD_SENSOR_INFO_OUT_LENMIN)
251 return -EIO;
252
253 /* Find out which sensors are present. Don't create a device
254 * if there are none.
255 */
256 mask = MCDI_DWORD(outbuf, SENSOR_INFO_OUT_MASK);
257 if (mask == 0)
258 return 0;
259
260 /* Check again for short response */
261 if (outlen < MC_CMD_SENSOR_INFO_OUT_LEN(hweight32(mask)))
262 return -EIO;
263
264 rc = efx_nic_alloc_buffer(efx, &hwmon->dma_buf,
265 4 * MC_CMD_SENSOR_ENTRY_MAXNUM);
266 if (rc)
267 return rc;
268
269 mutex_init(&hwmon->update_lock);
270 efx_mcdi_mon_update(efx);
271
272 /* Allocate space for the maximum possible number of
273 * attributes for this set of sensors: name of the driver plus
274 * value, min, max, crit, alarm and label for each sensor.
275 */
276 n_attrs = 1 + 6 * hweight32(mask);
277 hwmon->attrs = kcalloc(n_attrs, sizeof(*hwmon->attrs), GFP_KERNEL);
278 if (!hwmon->attrs) {
279 rc = -ENOMEM;
280 goto fail;
281 }
282
283 hwmon->device = hwmon_device_register(&efx->pci_dev->dev);
284 if (IS_ERR(hwmon->device)) {
285 rc = PTR_ERR(hwmon->device);
286 goto fail;
287 }
288
289 rc = efx_mcdi_mon_add_attr(efx, "name", efx_mcdi_mon_show_name, 0, 0, 0);
290 if (rc)
291 goto fail;
292
293 for (i = 0, type = -1; ; i++) {
294 const char *hwmon_prefix;
295 unsigned hwmon_index;
296 u16 min1, max1, min2, max2;
297
298 /* Find next sensor type or exit if there is none */
299 type++;
300 while (!(mask & (1 << type))) {
301 type++;
302 if (type == 32)
303 return 0;
304 }
305
306 /* Skip sensors specific to a different port */
307 if (efx_mcdi_sensor_type[type].hwmon_type != EFX_HWMON_UNKNOWN &&
308 efx_mcdi_sensor_type[type].port >= 0 &&
309 efx_mcdi_sensor_type[type].port != efx_port_num(efx))
310 continue;
311
312 switch (efx_mcdi_sensor_type[type].hwmon_type) {
313 case EFX_HWMON_TEMP:
314 hwmon_prefix = "temp";
315 hwmon_index = ++n_temp; /* 1-based */
316 break;
317 case EFX_HWMON_COOL:
318 /* This is likely to be a heatsink, but there
319 * is no convention for representing cooling
320 * devices other than fans.
321 */
322 hwmon_prefix = "fan";
323 hwmon_index = ++n_cool; /* 1-based */
324 break;
325 default:
326 hwmon_prefix = "in";
327 hwmon_index = n_in++; /* 0-based */
328 break;
329 }
330
331 min1 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
332 SENSOR_INFO_ENTRY, i, MIN1);
333 max1 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
334 SENSOR_INFO_ENTRY, i, MAX1);
335 min2 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
336 SENSOR_INFO_ENTRY, i, MIN2);
337 max2 = MCDI_ARRAY_FIELD(outbuf, SENSOR_ENTRY,
338 SENSOR_INFO_ENTRY, i, MAX2);
339
340 if (min1 != max1) {
341 snprintf(name, sizeof(name), "%s%u_input",
342 hwmon_prefix, hwmon_index);
343 rc = efx_mcdi_mon_add_attr(
344 efx, name, efx_mcdi_mon_show_value, i, type, 0);
345 if (rc)
346 goto fail;
347
348 snprintf(name, sizeof(name), "%s%u_min",
349 hwmon_prefix, hwmon_index);
350 rc = efx_mcdi_mon_add_attr(
351 efx, name, efx_mcdi_mon_show_limit,
352 i, type, min1);
353 if (rc)
354 goto fail;
355
356 snprintf(name, sizeof(name), "%s%u_max",
357 hwmon_prefix, hwmon_index);
358 rc = efx_mcdi_mon_add_attr(
359 efx, name, efx_mcdi_mon_show_limit,
360 i, type, max1);
361 if (rc)
362 goto fail;
363
364 if (min2 != max2) {
365 /* Assume max2 is critical value.
366 * But we have no good way to expose min2.
367 */
368 snprintf(name, sizeof(name), "%s%u_crit",
369 hwmon_prefix, hwmon_index);
370 rc = efx_mcdi_mon_add_attr(
371 efx, name, efx_mcdi_mon_show_limit,
372 i, type, max2);
373 if (rc)
374 goto fail;
375 }
376 }
377
378 snprintf(name, sizeof(name), "%s%u_alarm",
379 hwmon_prefix, hwmon_index);
380 rc = efx_mcdi_mon_add_attr(
381 efx, name, efx_mcdi_mon_show_alarm, i, type, 0);
382 if (rc)
383 goto fail;
384
385 if (efx_mcdi_sensor_type[type].label) {
386 snprintf(name, sizeof(name), "%s%u_label",
387 hwmon_prefix, hwmon_index);
388 rc = efx_mcdi_mon_add_attr(
389 efx, name, efx_mcdi_mon_show_label, i, type, 0);
390 if (rc)
391 goto fail;
392 }
393 }
394
395fail:
396 efx_mcdi_mon_remove(efx);
397 return rc;
398}
399
400void efx_mcdi_mon_remove(struct efx_nic *efx)
401{
402 struct siena_nic_data *nic_data = efx->nic_data;
403 struct efx_mcdi_mon *hwmon = &nic_data->hwmon;
404 unsigned int i;
405
406 for (i = 0; i < hwmon->n_attrs; i++)
407 device_remove_file(&efx->pci_dev->dev,
408 &hwmon->attrs[i].dev_attr);
409 kfree(hwmon->attrs);
410 if (hwmon->device)
411 hwmon_device_unregister(hwmon->device);
412 efx_nic_free_buffer(efx, &hwmon->dma_buf);
413}
414
415#endif /* CONFIG_SFC_MCDI_MON */
diff --git a/drivers/net/ethernet/sfc/mcdi_pcol.h b/drivers/net/ethernet/sfc/mcdi_pcol.h
index 41fe06fa0600..0310b9f08c9b 100644
--- a/drivers/net/ethernet/sfc/mcdi_pcol.h
+++ b/drivers/net/ethernet/sfc/mcdi_pcol.h
@@ -22,6 +22,18 @@
22/* The Scheduler has started. */ 22/* The Scheduler has started. */
23#define MC_FW_STATE_SCHED (8) 23#define MC_FW_STATE_SCHED (8)
24 24
25/* Siena MC shared memmory offsets */
26/* The 'doorbell' addresses are hard-wired to alert the MC when written */
27#define MC_SMEM_P0_DOORBELL_OFST 0x000
28#define MC_SMEM_P1_DOORBELL_OFST 0x004
29/* The rest of these are firmware-defined */
30#define MC_SMEM_P0_PDU_OFST 0x008
31#define MC_SMEM_P1_PDU_OFST 0x108
32#define MC_SMEM_PDU_LEN 0x100
33#define MC_SMEM_P0_PTP_TIME_OFST 0x7f0
34#define MC_SMEM_P0_STATUS_OFST 0x7f8
35#define MC_SMEM_P1_STATUS_OFST 0x7fc
36
25/* Values to be written to the per-port status dword in shared 37/* Values to be written to the per-port status dword in shared
26 * memory on reboot and assert */ 38 * memory on reboot and assert */
27#define MC_STATUS_DWORD_REBOOT (0xb007b007) 39#define MC_STATUS_DWORD_REBOOT (0xb007b007)
@@ -34,6 +46,8 @@
34 */ 46 */
35#define MCDI_PCOL_VERSION 1 47#define MCDI_PCOL_VERSION 1
36 48
49/* Unused commands: 0x23, 0x27, 0x30, 0x31 */
50
37/** 51/**
38 * MCDI version 1 52 * MCDI version 1
39 * 53 *
@@ -131,53 +145,6 @@
131 */ 145 */
132#define FSE_AZ_EV_CODE_MCDI_EVRESPONSE 0xc 146#define FSE_AZ_EV_CODE_MCDI_EVRESPONSE 0xc
133 147
134#define MCDI_EVENT_DATA_LBN 0
135#define MCDI_EVENT_DATA_WIDTH 32
136#define MCDI_EVENT_CONT_LBN 32
137#define MCDI_EVENT_CONT_WIDTH 1
138#define MCDI_EVENT_LEVEL_LBN 33
139#define MCDI_EVENT_LEVEL_WIDTH 3
140#define MCDI_EVENT_LEVEL_INFO (0)
141#define MCDI_EVENT_LEVEL_WARN (1)
142#define MCDI_EVENT_LEVEL_ERR (2)
143#define MCDI_EVENT_LEVEL_FATAL (3)
144#define MCDI_EVENT_SRC_LBN 36
145#define MCDI_EVENT_SRC_WIDTH 8
146#define MCDI_EVENT_CODE_LBN 44
147#define MCDI_EVENT_CODE_WIDTH 8
148#define MCDI_EVENT_CODE_BADSSERT (1)
149#define MCDI_EVENT_CODE_PMNOTICE (2)
150#define MCDI_EVENT_CODE_CMDDONE (3)
151#define MCDI_EVENT_CMDDONE_SEQ_LBN 0
152#define MCDI_EVENT_CMDDONE_SEQ_WIDTH 8
153#define MCDI_EVENT_CMDDONE_DATALEN_LBN 8
154#define MCDI_EVENT_CMDDONE_DATALEN_WIDTH 8
155#define MCDI_EVENT_CMDDONE_ERRNO_LBN 16
156#define MCDI_EVENT_CMDDONE_ERRNO_WIDTH 8
157#define MCDI_EVENT_CODE_LINKCHANGE (4)
158#define MCDI_EVENT_LINKCHANGE_LP_CAP_LBN 0
159#define MCDI_EVENT_LINKCHANGE_LP_CAP_WIDTH 16
160#define MCDI_EVENT_LINKCHANGE_SPEED_LBN 16
161#define MCDI_EVENT_LINKCHANGE_SPEED_WIDTH 4
162#define MCDI_EVENT_LINKCHANGE_SPEED_100M 1
163#define MCDI_EVENT_LINKCHANGE_SPEED_1G 2
164#define MCDI_EVENT_LINKCHANGE_SPEED_10G 3
165#define MCDI_EVENT_LINKCHANGE_FCNTL_LBN 20
166#define MCDI_EVENT_LINKCHANGE_FCNTL_WIDTH 4
167#define MCDI_EVENT_LINKCHANGE_LINK_FLAGS_LBN 24
168#define MCDI_EVENT_LINKCHANGE_LINK_FLAGS_WIDTH 8
169#define MCDI_EVENT_CODE_SENSOREVT (5)
170#define MCDI_EVENT_SENSOREVT_MONITOR_LBN 0
171#define MCDI_EVENT_SENSOREVT_MONITOR_WIDTH 8
172#define MCDI_EVENT_SENSOREVT_STATE_LBN 8
173#define MCDI_EVENT_SENSOREVT_STATE_WIDTH 8
174#define MCDI_EVENT_SENSOREVT_VALUE_LBN 16
175#define MCDI_EVENT_SENSOREVT_VALUE_WIDTH 16
176#define MCDI_EVENT_CODE_SCHEDERR (6)
177#define MCDI_EVENT_CODE_REBOOT (7)
178#define MCDI_EVENT_CODE_MAC_STATS_DMA (8)
179#define MCDI_EVENT_MAC_STATS_DMA_GENERATION_LBN 0
180#define MCDI_EVENT_MAC_STATS_DMA_GENERATION_WIDTH 32
181 148
182/* Non-existent command target */ 149/* Non-existent command target */
183#define MC_CMD_ERR_ENOENT 2 150#define MC_CMD_ERR_ENOENT 2
@@ -198,121 +165,24 @@
198 165
199#define MC_CMD_ERR_CODE_OFST 0 166#define MC_CMD_ERR_CODE_OFST 0
200 167
168/* We define 8 "escape" commands to allow
169 for command number space extension */
170
171#define MC_CMD_CMD_SPACE_ESCAPE_0 0x78
172#define MC_CMD_CMD_SPACE_ESCAPE_1 0x79
173#define MC_CMD_CMD_SPACE_ESCAPE_2 0x7A
174#define MC_CMD_CMD_SPACE_ESCAPE_3 0x7B
175#define MC_CMD_CMD_SPACE_ESCAPE_4 0x7C
176#define MC_CMD_CMD_SPACE_ESCAPE_5 0x7D
177#define MC_CMD_CMD_SPACE_ESCAPE_6 0x7E
178#define MC_CMD_CMD_SPACE_ESCAPE_7 0x7F
179
180/* Vectors in the boot ROM */
181/* Point to the copycode entry point. */
182#define MC_BOOTROM_COPYCODE_VEC (0x7f4)
183/* Points to the recovery mode entry point. */
184#define MC_BOOTROM_NOFLASH_VEC (0x7f8)
201 185
202/* MC_CMD_READ32: (debug, variadic out)
203 * Read multiple 32byte words from MC memory
204 */
205#define MC_CMD_READ32 0x01
206#define MC_CMD_READ32_IN_LEN 8
207#define MC_CMD_READ32_IN_ADDR_OFST 0
208#define MC_CMD_READ32_IN_NUMWORDS_OFST 4
209#define MC_CMD_READ32_OUT_LEN(_numwords) \
210 (4 * (_numwords))
211#define MC_CMD_READ32_OUT_BUFFER_OFST 0
212
213/* MC_CMD_WRITE32: (debug, variadic in)
214 * Write multiple 32byte words to MC memory
215 */
216#define MC_CMD_WRITE32 0x02
217#define MC_CMD_WRITE32_IN_LEN(_numwords) (((_numwords) * 4) + 4)
218#define MC_CMD_WRITE32_IN_ADDR_OFST 0
219#define MC_CMD_WRITE32_IN_BUFFER_OFST 4
220#define MC_CMD_WRITE32_OUT_LEN 0
221
222/* MC_CMD_COPYCODE: (debug)
223 * Copy MC code between two locations and jump
224 */
225#define MC_CMD_COPYCODE 0x03
226#define MC_CMD_COPYCODE_IN_LEN 16
227#define MC_CMD_COPYCODE_IN_SRC_ADDR_OFST 0
228#define MC_CMD_COPYCODE_IN_DEST_ADDR_OFST 4
229#define MC_CMD_COPYCODE_IN_NUMWORDS_OFST 8
230#define MC_CMD_COPYCODE_IN_JUMP_OFST 12
231/* Control should return to the caller rather than jumping */
232#define MC_CMD_COPYCODE_JUMP_NONE 1
233#define MC_CMD_COPYCODE_OUT_LEN 0
234
235/* MC_CMD_SET_FUNC: (debug)
236 * Select function for function-specific commands.
237 */
238#define MC_CMD_SET_FUNC 0x04
239#define MC_CMD_SET_FUNC_IN_LEN 4
240#define MC_CMD_SET_FUNC_IN_FUNC_OFST 0
241#define MC_CMD_SET_FUNC_OUT_LEN 0
242
243/* MC_CMD_GET_BOOT_STATUS:
244 * Get the instruction address from which the MC booted.
245 */
246#define MC_CMD_GET_BOOT_STATUS 0x05
247#define MC_CMD_GET_BOOT_STATUS_IN_LEN 0
248#define MC_CMD_GET_BOOT_STATUS_OUT_LEN 8
249#define MC_CMD_GET_BOOT_STATUS_OUT_BOOT_OFFSET_OFST 0
250#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_OFST 4
251/* Reboot caused by watchdog */
252#define MC_CMD_GET_BOOT_STATUS_FLAGS_WATCHDOG_LBN (0)
253#define MC_CMD_GET_BOOT_STATUS_FLAGS_WATCHDOG_WIDTH (1)
254/* MC booted from primary flash partition */
255#define MC_CMD_GET_BOOT_STATUS_FLAGS_PRIMARY_LBN (1)
256#define MC_CMD_GET_BOOT_STATUS_FLAGS_PRIMARY_WIDTH (1)
257/* MC booted from backup flash partition */
258#define MC_CMD_GET_BOOT_STATUS_FLAGS_BACKUP_LBN (2)
259#define MC_CMD_GET_BOOT_STATUS_FLAGS_BACKUP_WIDTH (1)
260
261/* MC_CMD_GET_ASSERTS: (debug, variadic out)
262 * Get (and optionally clear) the current assertion status.
263 *
264 * Only OUT.GLOBAL_FLAGS is guaranteed to exist in the completion
265 * payload. The other fields will only be present if
266 * OUT.GLOBAL_FLAGS != NO_FAILS
267 */
268#define MC_CMD_GET_ASSERTS 0x06
269#define MC_CMD_GET_ASSERTS_IN_LEN 4
270#define MC_CMD_GET_ASSERTS_IN_CLEAR_OFST 0
271#define MC_CMD_GET_ASSERTS_OUT_LEN 140
272/* Assertion status flag */
273#define MC_CMD_GET_ASSERTS_OUT_GLOBAL_FLAGS_OFST 0
274/*! No assertions have failed. */
275#define MC_CMD_GET_ASSERTS_FLAGS_NO_FAILS 1
276/*! A system-level assertion has failed. */
277#define MC_CMD_GET_ASSERTS_FLAGS_SYS_FAIL 2
278/*! A thread-level assertion has failed. */
279#define MC_CMD_GET_ASSERTS_FLAGS_THR_FAIL 3
280/*! The system was reset by the watchdog. */
281#define MC_CMD_GET_ASSERTS_FLAGS_WDOG_FIRED 4
282/* Failing PC value */
283#define MC_CMD_GET_ASSERTS_OUT_SAVED_PC_OFFS_OFST 4
284/* Saved GP regs */
285#define MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_OFST 8
286#define MC_CMD_GET_ASSERTS_OUT_GP_REGS_LEN 124
287/* Failing thread address */
288#define MC_CMD_GET_ASSERTS_OUT_THREAD_OFFS_OFST 132
289
290/* MC_CMD_LOG_CTRL:
291 * Determine the output stream for various events and messages
292 */
293#define MC_CMD_LOG_CTRL 0x07
294#define MC_CMD_LOG_CTRL_IN_LEN 8
295#define MC_CMD_LOG_CTRL_IN_LOG_DEST_OFST 0
296#define MC_CMD_LOG_CTRL_IN_LOG_DEST_UART (1)
297#define MC_CMD_LOG_CTRL_IN_LOG_DEST_EVQ (2)
298#define MC_CMD_LOG_CTRL_IN_LOG_DEST_EVQ_OFST 4
299#define MC_CMD_LOG_CTRL_OUT_LEN 0
300
301/* MC_CMD_GET_VERSION:
302 * Get version information about the MC firmware
303 */
304#define MC_CMD_GET_VERSION 0x08
305#define MC_CMD_GET_VERSION_IN_LEN 0
306#define MC_CMD_GET_VERSION_V0_OUT_LEN 4
307#define MC_CMD_GET_VERSION_V1_OUT_LEN 32
308#define MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0
309/* Reserved version number to indicate "any" version. */
310#define MC_CMD_GET_VERSION_OUT_FIRMWARE_ANY 0xffffffff
311/* The version response of a boot ROM awaiting rescue */
312#define MC_CMD_GET_VERSION_OUT_FIRMWARE_BOOTROM 0xb0070000
313#define MC_CMD_GET_VERSION_V1_OUT_PCOL_OFST 4
314/* 128bit mask of functions supported by the current firmware */
315#define MC_CMD_GET_VERSION_V1_OUT_SUPPORTED_FUNCS_OFST 8
316/* The command set exported by the boot ROM (MCDI v0) */ 186/* The command set exported by the boot ROM (MCDI v0) */
317#define MC_CMD_GET_VERSION_V0_SUPPORTED_FUNCS { \ 187#define MC_CMD_GET_VERSION_V0_SUPPORTED_FUNCS { \
318 (1 << MC_CMD_READ32) | \ 188 (1 << MC_CMD_READ32) | \
@@ -320,1456 +190,2214 @@
320 (1 << MC_CMD_COPYCODE) | \ 190 (1 << MC_CMD_COPYCODE) | \
321 (1 << MC_CMD_GET_VERSION), \ 191 (1 << MC_CMD_GET_VERSION), \
322 0, 0, 0 } 192 0, 0, 0 }
323#define MC_CMD_GET_VERSION_OUT_VERSION_OFST 24
324 193
325/* Vectors in the boot ROM */ 194#define MC_CMD_SENSOR_INFO_OUT_OFFSET_OFST(_x) \
326/* Point to the copycode entry point. */ 195 (MC_CMD_SENSOR_ENTRY_OFST + (_x))
327#define MC_BOOTROM_COPYCODE_VEC (0x7f4) 196
328/* Points to the recovery mode entry point. */ 197#define MC_CMD_DBI_WRITE_IN_ADDRESS_OFST(n) \
329#define MC_BOOTROM_NOFLASH_VEC (0x7f8) 198 (MC_CMD_DBI_WRITE_IN_DBIWROP_OFST + \
199 MC_CMD_DBIWROP_TYPEDEF_ADDRESS_OFST + \
200 (n) * MC_CMD_DBIWROP_TYPEDEF_LEN)
201
202#define MC_CMD_DBI_WRITE_IN_BYTE_MASK_OFST(n) \
203 (MC_CMD_DBI_WRITE_IN_DBIWROP_OFST + \
204 MC_CMD_DBIWROP_TYPEDEF_BYTE_MASK_OFST + \
205 (n) * MC_CMD_DBIWROP_TYPEDEF_LEN)
206
207#define MC_CMD_DBI_WRITE_IN_VALUE_OFST(n) \
208 (MC_CMD_DBI_WRITE_IN_DBIWROP_OFST + \
209 MC_CMD_DBIWROP_TYPEDEF_VALUE_OFST + \
210 (n) * MC_CMD_DBIWROP_TYPEDEF_LEN)
211
212
213/* MCDI_EVENT structuredef */
214#define MCDI_EVENT_LEN 8
215#define MCDI_EVENT_CONT_LBN 32
216#define MCDI_EVENT_CONT_WIDTH 1
217#define MCDI_EVENT_LEVEL_LBN 33
218#define MCDI_EVENT_LEVEL_WIDTH 3
219#define MCDI_EVENT_LEVEL_INFO 0x0 /* enum */
220#define MCDI_EVENT_LEVEL_WARN 0x1 /* enum */
221#define MCDI_EVENT_LEVEL_ERR 0x2 /* enum */
222#define MCDI_EVENT_LEVEL_FATAL 0x3 /* enum */
223#define MCDI_EVENT_DATA_OFST 0
224#define MCDI_EVENT_CMDDONE_SEQ_LBN 0
225#define MCDI_EVENT_CMDDONE_SEQ_WIDTH 8
226#define MCDI_EVENT_CMDDONE_DATALEN_LBN 8
227#define MCDI_EVENT_CMDDONE_DATALEN_WIDTH 8
228#define MCDI_EVENT_CMDDONE_ERRNO_LBN 16
229#define MCDI_EVENT_CMDDONE_ERRNO_WIDTH 8
230#define MCDI_EVENT_LINKCHANGE_LP_CAP_LBN 0
231#define MCDI_EVENT_LINKCHANGE_LP_CAP_WIDTH 16
232#define MCDI_EVENT_LINKCHANGE_SPEED_LBN 16
233#define MCDI_EVENT_LINKCHANGE_SPEED_WIDTH 4
234#define MCDI_EVENT_LINKCHANGE_SPEED_100M 0x1 /* enum */
235#define MCDI_EVENT_LINKCHANGE_SPEED_1G 0x2 /* enum */
236#define MCDI_EVENT_LINKCHANGE_SPEED_10G 0x3 /* enum */
237#define MCDI_EVENT_LINKCHANGE_FCNTL_LBN 20
238#define MCDI_EVENT_LINKCHANGE_FCNTL_WIDTH 4
239#define MCDI_EVENT_LINKCHANGE_LINK_FLAGS_LBN 24
240#define MCDI_EVENT_LINKCHANGE_LINK_FLAGS_WIDTH 8
241#define MCDI_EVENT_SENSOREVT_MONITOR_LBN 0
242#define MCDI_EVENT_SENSOREVT_MONITOR_WIDTH 8
243#define MCDI_EVENT_SENSOREVT_STATE_LBN 8
244#define MCDI_EVENT_SENSOREVT_STATE_WIDTH 8
245#define MCDI_EVENT_SENSOREVT_VALUE_LBN 16
246#define MCDI_EVENT_SENSOREVT_VALUE_WIDTH 16
247#define MCDI_EVENT_FWALERT_DATA_LBN 8
248#define MCDI_EVENT_FWALERT_DATA_WIDTH 24
249#define MCDI_EVENT_FWALERT_REASON_LBN 0
250#define MCDI_EVENT_FWALERT_REASON_WIDTH 8
251#define MCDI_EVENT_FWALERT_REASON_SRAM_ACCESS 0x1 /* enum */
252#define MCDI_EVENT_FLR_VF_LBN 0
253#define MCDI_EVENT_FLR_VF_WIDTH 8
254#define MCDI_EVENT_TX_ERR_TXQ_LBN 0
255#define MCDI_EVENT_TX_ERR_TXQ_WIDTH 12
256#define MCDI_EVENT_TX_ERR_TYPE_LBN 12
257#define MCDI_EVENT_TX_ERR_TYPE_WIDTH 4
258#define MCDI_EVENT_TX_ERR_DL_FAIL 0x1 /* enum */
259#define MCDI_EVENT_TX_ERR_NO_EOP 0x2 /* enum */
260#define MCDI_EVENT_TX_ERR_2BIG 0x3 /* enum */
261#define MCDI_EVENT_TX_ERR_INFO_LBN 16
262#define MCDI_EVENT_TX_ERR_INFO_WIDTH 16
263#define MCDI_EVENT_TX_FLUSH_TXQ_LBN 0
264#define MCDI_EVENT_TX_FLUSH_TXQ_WIDTH 12
265#define MCDI_EVENT_PTP_ERR_TYPE_LBN 0
266#define MCDI_EVENT_PTP_ERR_TYPE_WIDTH 8
267#define MCDI_EVENT_PTP_ERR_PLL_LOST 0x1 /* enum */
268#define MCDI_EVENT_PTP_ERR_FILTER 0x2 /* enum */
269#define MCDI_EVENT_PTP_ERR_FIFO 0x3 /* enum */
270#define MCDI_EVENT_PTP_ERR_QUEUE 0x4 /* enum */
271#define MCDI_EVENT_DATA_LBN 0
272#define MCDI_EVENT_DATA_WIDTH 32
273#define MCDI_EVENT_SRC_LBN 36
274#define MCDI_EVENT_SRC_WIDTH 8
275#define MCDI_EVENT_EV_CODE_LBN 60
276#define MCDI_EVENT_EV_CODE_WIDTH 4
277#define MCDI_EVENT_CODE_LBN 44
278#define MCDI_EVENT_CODE_WIDTH 8
279#define MCDI_EVENT_CODE_BADSSERT 0x1 /* enum */
280#define MCDI_EVENT_CODE_PMNOTICE 0x2 /* enum */
281#define MCDI_EVENT_CODE_CMDDONE 0x3 /* enum */
282#define MCDI_EVENT_CODE_LINKCHANGE 0x4 /* enum */
283#define MCDI_EVENT_CODE_SENSOREVT 0x5 /* enum */
284#define MCDI_EVENT_CODE_SCHEDERR 0x6 /* enum */
285#define MCDI_EVENT_CODE_REBOOT 0x7 /* enum */
286#define MCDI_EVENT_CODE_MAC_STATS_DMA 0x8 /* enum */
287#define MCDI_EVENT_CODE_FWALERT 0x9 /* enum */
288#define MCDI_EVENT_CODE_FLR 0xa /* enum */
289#define MCDI_EVENT_CODE_TX_ERR 0xb /* enum */
290#define MCDI_EVENT_CODE_TX_FLUSH 0xc /* enum */
291#define MCDI_EVENT_CODE_PTP_RX 0xd /* enum */
292#define MCDI_EVENT_CODE_PTP_FAULT 0xe /* enum */
293#define MCDI_EVENT_CMDDONE_DATA_OFST 0
294#define MCDI_EVENT_CMDDONE_DATA_LBN 0
295#define MCDI_EVENT_CMDDONE_DATA_WIDTH 32
296#define MCDI_EVENT_LINKCHANGE_DATA_OFST 0
297#define MCDI_EVENT_LINKCHANGE_DATA_LBN 0
298#define MCDI_EVENT_LINKCHANGE_DATA_WIDTH 32
299#define MCDI_EVENT_SENSOREVT_DATA_OFST 0
300#define MCDI_EVENT_SENSOREVT_DATA_LBN 0
301#define MCDI_EVENT_SENSOREVT_DATA_WIDTH 32
302#define MCDI_EVENT_MAC_STATS_DMA_GENERATION_OFST 0
303#define MCDI_EVENT_MAC_STATS_DMA_GENERATION_LBN 0
304#define MCDI_EVENT_MAC_STATS_DMA_GENERATION_WIDTH 32
305#define MCDI_EVENT_TX_ERR_DATA_OFST 0
306#define MCDI_EVENT_TX_ERR_DATA_LBN 0
307#define MCDI_EVENT_TX_ERR_DATA_WIDTH 32
308#define MCDI_EVENT_PTP_SECONDS_OFST 0
309#define MCDI_EVENT_PTP_SECONDS_LBN 0
310#define MCDI_EVENT_PTP_SECONDS_WIDTH 32
311#define MCDI_EVENT_PTP_NANOSECONDS_OFST 0
312#define MCDI_EVENT_PTP_NANOSECONDS_LBN 0
313#define MCDI_EVENT_PTP_NANOSECONDS_WIDTH 32
314#define MCDI_EVENT_PTP_UUID_OFST 0
315#define MCDI_EVENT_PTP_UUID_LBN 0
316#define MCDI_EVENT_PTP_UUID_WIDTH 32
317
318
319/***********************************/
320/* MC_CMD_READ32
321 * Read multiple 32byte words from MC memory.
322 */
323#define MC_CMD_READ32 0x1
324
325/* MC_CMD_READ32_IN msgrequest */
326#define MC_CMD_READ32_IN_LEN 8
327#define MC_CMD_READ32_IN_ADDR_OFST 0
328#define MC_CMD_READ32_IN_NUMWORDS_OFST 4
329
330/* MC_CMD_READ32_OUT msgresponse */
331#define MC_CMD_READ32_OUT_LENMIN 4
332#define MC_CMD_READ32_OUT_LENMAX 252
333#define MC_CMD_READ32_OUT_LEN(num) (0+4*(num))
334#define MC_CMD_READ32_OUT_BUFFER_OFST 0
335#define MC_CMD_READ32_OUT_BUFFER_LEN 4
336#define MC_CMD_READ32_OUT_BUFFER_MINNUM 1
337#define MC_CMD_READ32_OUT_BUFFER_MAXNUM 63
338
339
340/***********************************/
341/* MC_CMD_WRITE32
342 * Write multiple 32byte words to MC memory.
343 */
344#define MC_CMD_WRITE32 0x2
345
346/* MC_CMD_WRITE32_IN msgrequest */
347#define MC_CMD_WRITE32_IN_LENMIN 8
348#define MC_CMD_WRITE32_IN_LENMAX 252
349#define MC_CMD_WRITE32_IN_LEN(num) (4+4*(num))
350#define MC_CMD_WRITE32_IN_ADDR_OFST 0
351#define MC_CMD_WRITE32_IN_BUFFER_OFST 4
352#define MC_CMD_WRITE32_IN_BUFFER_LEN 4
353#define MC_CMD_WRITE32_IN_BUFFER_MINNUM 1
354#define MC_CMD_WRITE32_IN_BUFFER_MAXNUM 62
355
356/* MC_CMD_WRITE32_OUT msgresponse */
357#define MC_CMD_WRITE32_OUT_LEN 0
358
359
360/***********************************/
361/* MC_CMD_COPYCODE
362 * Copy MC code between two locations and jump.
363 */
364#define MC_CMD_COPYCODE 0x3
365
366/* MC_CMD_COPYCODE_IN msgrequest */
367#define MC_CMD_COPYCODE_IN_LEN 16
368#define MC_CMD_COPYCODE_IN_SRC_ADDR_OFST 0
369#define MC_CMD_COPYCODE_IN_DEST_ADDR_OFST 4
370#define MC_CMD_COPYCODE_IN_NUMWORDS_OFST 8
371#define MC_CMD_COPYCODE_IN_JUMP_OFST 12
372#define MC_CMD_COPYCODE_JUMP_NONE 0x1 /* enum */
373
374/* MC_CMD_COPYCODE_OUT msgresponse */
375#define MC_CMD_COPYCODE_OUT_LEN 0
376
377
378/***********************************/
379/* MC_CMD_SET_FUNC
380 */
381#define MC_CMD_SET_FUNC 0x4
382
383/* MC_CMD_SET_FUNC_IN msgrequest */
384#define MC_CMD_SET_FUNC_IN_LEN 4
385#define MC_CMD_SET_FUNC_IN_FUNC_OFST 0
386
387/* MC_CMD_SET_FUNC_OUT msgresponse */
388#define MC_CMD_SET_FUNC_OUT_LEN 0
389
390
391/***********************************/
392/* MC_CMD_GET_BOOT_STATUS
393 */
394#define MC_CMD_GET_BOOT_STATUS 0x5
395
396/* MC_CMD_GET_BOOT_STATUS_IN msgrequest */
397#define MC_CMD_GET_BOOT_STATUS_IN_LEN 0
398
399/* MC_CMD_GET_BOOT_STATUS_OUT msgresponse */
400#define MC_CMD_GET_BOOT_STATUS_OUT_LEN 8
401#define MC_CMD_GET_BOOT_STATUS_OUT_BOOT_OFFSET_OFST 0
402#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_OFST 4
403#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_WATCHDOG_LBN 0
404#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_WATCHDOG_WIDTH 1
405#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_PRIMARY_LBN 1
406#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_PRIMARY_WIDTH 1
407#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_BACKUP_LBN 2
408#define MC_CMD_GET_BOOT_STATUS_OUT_FLAGS_BACKUP_WIDTH 1
330 409
331/* Test execution limits */
332#define MC_TESTEXEC_VARIANT_COUNT 16
333#define MC_TESTEXEC_RESULT_COUNT 7
334 410
335/* MC_CMD_SET_TESTVARS: (debug, variadic in) 411/***********************************/
336 * Write variant words for test. 412/* MC_CMD_GET_ASSERTS
337 * 413 * Get and clear any assertion status.
338 * The user supplies a bitmap of the variants they wish to set.
339 * They must ensure that IN.LEN >= 4 + 4 * ffs(BITMAP)
340 */
341#define MC_CMD_SET_TESTVARS 0x09
342#define MC_CMD_SET_TESTVARS_IN_LEN(_numwords) \
343 (4 + 4*(_numwords))
344#define MC_CMD_SET_TESTVARS_IN_ARGS_BITMAP_OFST 0
345/* Up to MC_TESTEXEC_VARIANT_COUNT of 32byte words start here */
346#define MC_CMD_SET_TESTVARS_IN_ARGS_BUFFER_OFST 4
347#define MC_CMD_SET_TESTVARS_OUT_LEN 0
348
349/* MC_CMD_GET_TESTRCS: (debug, variadic out)
350 * Return result words from test.
351 */
352#define MC_CMD_GET_TESTRCS 0x0a
353#define MC_CMD_GET_TESTRCS_IN_LEN 4
354#define MC_CMD_GET_TESTRCS_IN_NUMWORDS_OFST 0
355#define MC_CMD_GET_TESTRCS_OUT_LEN(_numwords) \
356 (4 * (_numwords))
357#define MC_CMD_GET_TESTRCS_OUT_BUFFER_OFST 0
358
359/* MC_CMD_RUN_TEST: (debug)
360 * Run the test exported by this firmware image
361 */
362#define MC_CMD_RUN_TEST 0x0b
363#define MC_CMD_RUN_TEST_IN_LEN 0
364#define MC_CMD_RUN_TEST_OUT_LEN 0
365
366/* MC_CMD_CSR_READ32: (debug, variadic out)
367 * Read 32bit words from the indirect memory map
368 */
369#define MC_CMD_CSR_READ32 0x0c
370#define MC_CMD_CSR_READ32_IN_LEN 12
371#define MC_CMD_CSR_READ32_IN_ADDR_OFST 0
372#define MC_CMD_CSR_READ32_IN_STEP_OFST 4
373#define MC_CMD_CSR_READ32_IN_NUMWORDS_OFST 8
374#define MC_CMD_CSR_READ32_OUT_LEN(_numwords) \
375 (((_numwords) * 4) + 4)
376/* IN.NUMWORDS of 32bit words start here */
377#define MC_CMD_CSR_READ32_OUT_BUFFER_OFST 0
378#define MC_CMD_CSR_READ32_OUT_IREG_STATUS_OFST(_numwords) \
379 ((_numwords) * 4)
380
381/* MC_CMD_CSR_WRITE32: (debug, variadic in)
382 * Write 32bit dwords to the indirect memory map
383 */
384#define MC_CMD_CSR_WRITE32 0x0d
385#define MC_CMD_CSR_WRITE32_IN_LEN(_numwords) \
386 (((_numwords) * 4) + 8)
387#define MC_CMD_CSR_WRITE32_IN_ADDR_OFST 0
388#define MC_CMD_CSR_WRITE32_IN_STEP_OFST 4
389/* Multiple 32bit words of data to write start here */
390#define MC_CMD_CSR_WRITE32_IN_BUFFER_OFST 8
391#define MC_CMD_CSR_WRITE32_OUT_LEN 4
392#define MC_CMD_CSR_WRITE32_OUT_STATUS_OFST 0
393
394/* MC_CMD_JTAG_WORK: (debug, fpga only)
395 * Process JTAG work buffer for RBF acceleration.
396 *
397 * Host: bit count, (up to) 32 words of data to clock out to JTAG
398 * (bits 1,0=TMS,TDO for first bit; bits 3,2=TMS,TDO for second bit, etc.)
399 * MC: bit count, (up to) 32 words of data clocked in from JTAG
400 * (bit 0=TDI for first bit, bit 1=TDI for second bit, etc.; [31:16] unused)
401 */ 414 */
402#define MC_CMD_JTAG_WORK 0x0e 415#define MC_CMD_GET_ASSERTS 0x6
403 416
404/* MC_CMD_STACKINFO: (debug, variadic out) 417/* MC_CMD_GET_ASSERTS_IN msgrequest */
405 * Get stack information 418#define MC_CMD_GET_ASSERTS_IN_LEN 4
406 * 419#define MC_CMD_GET_ASSERTS_IN_CLEAR_OFST 0
407 * Host: nothing 420
408 * MC: (thread ptr, stack size, free space) for each thread in system 421/* MC_CMD_GET_ASSERTS_OUT msgresponse */
409 */ 422#define MC_CMD_GET_ASSERTS_OUT_LEN 140
410#define MC_CMD_STACKINFO 0x0f 423#define MC_CMD_GET_ASSERTS_OUT_GLOBAL_FLAGS_OFST 0
424#define MC_CMD_GET_ASSERTS_FLAGS_NO_FAILS 0x1 /* enum */
425#define MC_CMD_GET_ASSERTS_FLAGS_SYS_FAIL 0x2 /* enum */
426#define MC_CMD_GET_ASSERTS_FLAGS_THR_FAIL 0x3 /* enum */
427#define MC_CMD_GET_ASSERTS_FLAGS_WDOG_FIRED 0x4 /* enum */
428#define MC_CMD_GET_ASSERTS_OUT_SAVED_PC_OFFS_OFST 4
429#define MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_OFST 8
430#define MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_LEN 4
431#define MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_NUM 31
432#define MC_CMD_GET_ASSERTS_OUT_THREAD_OFFS_OFST 132
433#define MC_CMD_GET_ASSERTS_OUT_RESERVED_OFST 136
411 434
412/* MC_CMD_MDIO_READ: 435
413 * MDIO register read 436/***********************************/
437/* MC_CMD_LOG_CTRL
438 * Configure the output stream for various events and messages.
439 */
440#define MC_CMD_LOG_CTRL 0x7
441
442/* MC_CMD_LOG_CTRL_IN msgrequest */
443#define MC_CMD_LOG_CTRL_IN_LEN 8
444#define MC_CMD_LOG_CTRL_IN_LOG_DEST_OFST 0
445#define MC_CMD_LOG_CTRL_IN_LOG_DEST_UART 0x1 /* enum */
446#define MC_CMD_LOG_CTRL_IN_LOG_DEST_EVQ 0x2 /* enum */
447#define MC_CMD_LOG_CTRL_IN_LOG_DEST_EVQ_OFST 4
448
449/* MC_CMD_LOG_CTRL_OUT msgresponse */
450#define MC_CMD_LOG_CTRL_OUT_LEN 0
451
452
453/***********************************/
454/* MC_CMD_GET_VERSION
455 * Get version information about the MC firmware.
456 */
457#define MC_CMD_GET_VERSION 0x8
458
459/* MC_CMD_GET_VERSION_IN msgrequest */
460#define MC_CMD_GET_VERSION_IN_LEN 0
461
462/* MC_CMD_GET_VERSION_V0_OUT msgresponse */
463#define MC_CMD_GET_VERSION_V0_OUT_LEN 4
464#define MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0
465#define MC_CMD_GET_VERSION_OUT_FIRMWARE_ANY 0xffffffff /* enum */
466#define MC_CMD_GET_VERSION_OUT_FIRMWARE_BOOTROM 0xb0070000 /* enum */
467
468/* MC_CMD_GET_VERSION_OUT msgresponse */
469#define MC_CMD_GET_VERSION_OUT_LEN 32
470/* MC_CMD_GET_VERSION_OUT_FIRMWARE_OFST 0 */
471/* Enum values, see field(s): */
472/* MC_CMD_GET_VERSION_V0_OUT/MC_CMD_GET_VERSION_OUT_FIRMWARE */
473#define MC_CMD_GET_VERSION_OUT_PCOL_OFST 4
474#define MC_CMD_GET_VERSION_OUT_SUPPORTED_FUNCS_OFST 8
475#define MC_CMD_GET_VERSION_OUT_SUPPORTED_FUNCS_LEN 16
476#define MC_CMD_GET_VERSION_OUT_VERSION_OFST 24
477#define MC_CMD_GET_VERSION_OUT_VERSION_LEN 8
478#define MC_CMD_GET_VERSION_OUT_VERSION_LO_OFST 24
479#define MC_CMD_GET_VERSION_OUT_VERSION_HI_OFST 28
480
481
482/***********************************/
483/* MC_CMD_GET_FPGAREG
484 * Read multiple bytes from PTP FPGA.
485 */
486#define MC_CMD_GET_FPGAREG 0x9
487
488/* MC_CMD_GET_FPGAREG_IN msgrequest */
489#define MC_CMD_GET_FPGAREG_IN_LEN 8
490#define MC_CMD_GET_FPGAREG_IN_ADDR_OFST 0
491#define MC_CMD_GET_FPGAREG_IN_NUMBYTES_OFST 4
492
493/* MC_CMD_GET_FPGAREG_OUT msgresponse */
494#define MC_CMD_GET_FPGAREG_OUT_LENMIN 1
495#define MC_CMD_GET_FPGAREG_OUT_LENMAX 255
496#define MC_CMD_GET_FPGAREG_OUT_LEN(num) (0+1*(num))
497#define MC_CMD_GET_FPGAREG_OUT_BUFFER_OFST 0
498#define MC_CMD_GET_FPGAREG_OUT_BUFFER_LEN 1
499#define MC_CMD_GET_FPGAREG_OUT_BUFFER_MINNUM 1
500#define MC_CMD_GET_FPGAREG_OUT_BUFFER_MAXNUM 255
501
502
503/***********************************/
504/* MC_CMD_PUT_FPGAREG
505 * Write multiple bytes to PTP FPGA.
506 */
507#define MC_CMD_PUT_FPGAREG 0xa
508
509/* MC_CMD_PUT_FPGAREG_IN msgrequest */
510#define MC_CMD_PUT_FPGAREG_IN_LENMIN 5
511#define MC_CMD_PUT_FPGAREG_IN_LENMAX 255
512#define MC_CMD_PUT_FPGAREG_IN_LEN(num) (4+1*(num))
513#define MC_CMD_PUT_FPGAREG_IN_ADDR_OFST 0
514#define MC_CMD_PUT_FPGAREG_IN_BUFFER_OFST 4
515#define MC_CMD_PUT_FPGAREG_IN_BUFFER_LEN 1
516#define MC_CMD_PUT_FPGAREG_IN_BUFFER_MINNUM 1
517#define MC_CMD_PUT_FPGAREG_IN_BUFFER_MAXNUM 251
518
519/* MC_CMD_PUT_FPGAREG_OUT msgresponse */
520#define MC_CMD_PUT_FPGAREG_OUT_LEN 0
521
522
523/***********************************/
524/* MC_CMD_PTP
525 * Perform PTP operation
526 */
527#define MC_CMD_PTP 0xb
528
529/* MC_CMD_PTP_IN msgrequest */
530#define MC_CMD_PTP_IN_LEN 1
531#define MC_CMD_PTP_IN_OP_OFST 0
532#define MC_CMD_PTP_IN_OP_LEN 1
533#define MC_CMD_PTP_OP_ENABLE 0x1 /* enum */
534#define MC_CMD_PTP_OP_DISABLE 0x2 /* enum */
535#define MC_CMD_PTP_OP_TRANSMIT 0x3 /* enum */
536#define MC_CMD_PTP_OP_READ_NIC_TIME 0x4 /* enum */
537#define MC_CMD_PTP_OP_STATUS 0x5 /* enum */
538#define MC_CMD_PTP_OP_ADJUST 0x6 /* enum */
539#define MC_CMD_PTP_OP_SYNCHRONIZE 0x7 /* enum */
540#define MC_CMD_PTP_OP_MANFTEST_BASIC 0x8 /* enum */
541#define MC_CMD_PTP_OP_MANFTEST_PACKET 0x9 /* enum */
542#define MC_CMD_PTP_OP_RESET_STATS 0xa /* enum */
543#define MC_CMD_PTP_OP_DEBUG 0xb /* enum */
544#define MC_CMD_PTP_OP_MAX 0xc /* enum */
545
546/* MC_CMD_PTP_IN_ENABLE msgrequest */
547#define MC_CMD_PTP_IN_ENABLE_LEN 16
548#define MC_CMD_PTP_IN_CMD_OFST 0
549#define MC_CMD_PTP_IN_PERIPH_ID_OFST 4
550#define MC_CMD_PTP_IN_ENABLE_QUEUE_OFST 8
551#define MC_CMD_PTP_IN_ENABLE_MODE_OFST 12
552#define MC_CMD_PTP_MODE_V1 0x0 /* enum */
553#define MC_CMD_PTP_MODE_V1_VLAN 0x1 /* enum */
554#define MC_CMD_PTP_MODE_V2 0x2 /* enum */
555#define MC_CMD_PTP_MODE_V2_VLAN 0x3 /* enum */
556
557/* MC_CMD_PTP_IN_DISABLE msgrequest */
558#define MC_CMD_PTP_IN_DISABLE_LEN 8
559/* MC_CMD_PTP_IN_CMD_OFST 0 */
560/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
561
562/* MC_CMD_PTP_IN_TRANSMIT msgrequest */
563#define MC_CMD_PTP_IN_TRANSMIT_LENMIN 13
564#define MC_CMD_PTP_IN_TRANSMIT_LENMAX 255
565#define MC_CMD_PTP_IN_TRANSMIT_LEN(num) (12+1*(num))
566/* MC_CMD_PTP_IN_CMD_OFST 0 */
567/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
568#define MC_CMD_PTP_IN_TRANSMIT_LENGTH_OFST 8
569#define MC_CMD_PTP_IN_TRANSMIT_PACKET_OFST 12
570#define MC_CMD_PTP_IN_TRANSMIT_PACKET_LEN 1
571#define MC_CMD_PTP_IN_TRANSMIT_PACKET_MINNUM 1
572#define MC_CMD_PTP_IN_TRANSMIT_PACKET_MAXNUM 243
573
574/* MC_CMD_PTP_IN_READ_NIC_TIME msgrequest */
575#define MC_CMD_PTP_IN_READ_NIC_TIME_LEN 8
576/* MC_CMD_PTP_IN_CMD_OFST 0 */
577/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
578
579/* MC_CMD_PTP_IN_STATUS msgrequest */
580#define MC_CMD_PTP_IN_STATUS_LEN 8
581/* MC_CMD_PTP_IN_CMD_OFST 0 */
582/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
583
584/* MC_CMD_PTP_IN_ADJUST msgrequest */
585#define MC_CMD_PTP_IN_ADJUST_LEN 24
586/* MC_CMD_PTP_IN_CMD_OFST 0 */
587/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
588#define MC_CMD_PTP_IN_ADJUST_FREQ_OFST 8
589#define MC_CMD_PTP_IN_ADJUST_FREQ_LEN 8
590#define MC_CMD_PTP_IN_ADJUST_FREQ_LO_OFST 8
591#define MC_CMD_PTP_IN_ADJUST_FREQ_HI_OFST 12
592#define MC_CMD_PTP_IN_ADJUST_BITS 0x28 /* enum */
593#define MC_CMD_PTP_IN_ADJUST_SECONDS_OFST 16
594#define MC_CMD_PTP_IN_ADJUST_NANOSECONDS_OFST 20
595
596/* MC_CMD_PTP_IN_SYNCHRONIZE msgrequest */
597#define MC_CMD_PTP_IN_SYNCHRONIZE_LEN 20
598/* MC_CMD_PTP_IN_CMD_OFST 0 */
599/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
600#define MC_CMD_PTP_IN_SYNCHRONIZE_NUMTIMESETS_OFST 8
601#define MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_OFST 12
602#define MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_LEN 8
603#define MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_LO_OFST 12
604#define MC_CMD_PTP_IN_SYNCHRONIZE_START_ADDR_HI_OFST 16
605
606/* MC_CMD_PTP_IN_MANFTEST_BASIC msgrequest */
607#define MC_CMD_PTP_IN_MANFTEST_BASIC_LEN 8
608/* MC_CMD_PTP_IN_CMD_OFST 0 */
609/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
610
611/* MC_CMD_PTP_IN_MANFTEST_PACKET msgrequest */
612#define MC_CMD_PTP_IN_MANFTEST_PACKET_LEN 12
613/* MC_CMD_PTP_IN_CMD_OFST 0 */
614/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
615#define MC_CMD_PTP_IN_MANFTEST_PACKET_TEST_ENABLE_OFST 8
616
617/* MC_CMD_PTP_IN_RESET_STATS msgrequest */
618#define MC_CMD_PTP_IN_RESET_STATS_LEN 8
619/* MC_CMD_PTP_IN_CMD_OFST 0 */
620/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
621
622/* MC_CMD_PTP_IN_DEBUG msgrequest */
623#define MC_CMD_PTP_IN_DEBUG_LEN 12
624/* MC_CMD_PTP_IN_CMD_OFST 0 */
625/* MC_CMD_PTP_IN_PERIPH_ID_OFST 4 */
626#define MC_CMD_PTP_IN_DEBUG_DEBUG_PARAM_OFST 8
627
628/* MC_CMD_PTP_OUT msgresponse */
629#define MC_CMD_PTP_OUT_LEN 0
630
631/* MC_CMD_PTP_OUT_TRANSMIT msgresponse */
632#define MC_CMD_PTP_OUT_TRANSMIT_LEN 8
633#define MC_CMD_PTP_OUT_TRANSMIT_SECONDS_OFST 0
634#define MC_CMD_PTP_OUT_TRANSMIT_NANOSECONDS_OFST 4
635
636/* MC_CMD_PTP_OUT_READ_NIC_TIME msgresponse */
637#define MC_CMD_PTP_OUT_READ_NIC_TIME_LEN 8
638#define MC_CMD_PTP_OUT_READ_NIC_TIME_SECONDS_OFST 0
639#define MC_CMD_PTP_OUT_READ_NIC_TIME_NANOSECONDS_OFST 4
640
641/* MC_CMD_PTP_OUT_STATUS msgresponse */
642#define MC_CMD_PTP_OUT_STATUS_LEN 64
643#define MC_CMD_PTP_OUT_STATUS_CLOCK_FREQ_OFST 0
644#define MC_CMD_PTP_OUT_STATUS_STATS_TX_OFST 4
645#define MC_CMD_PTP_OUT_STATUS_STATS_RX_OFST 8
646#define MC_CMD_PTP_OUT_STATUS_STATS_TS_OFST 12
647#define MC_CMD_PTP_OUT_STATUS_STATS_FM_OFST 16
648#define MC_CMD_PTP_OUT_STATUS_STATS_NFM_OFST 20
649#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFLOW_OFST 24
650#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_BAD_OFST 28
651#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_MIN_OFST 32
652#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_MAX_OFST 36
653#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_LAST_OFST 40
654#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_PER_MEAN_OFST 44
655#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_MIN_OFST 48
656#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_MAX_OFST 52
657#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_LAST_OFST 56
658#define MC_CMD_PTP_OUT_STATUS_STATS_PPS_OFF_MEAN_OFST 60
659
660/* MC_CMD_PTP_OUT_SYNCHRONIZE msgresponse */
661#define MC_CMD_PTP_OUT_SYNCHRONIZE_LENMIN 20
662#define MC_CMD_PTP_OUT_SYNCHRONIZE_LENMAX 240
663#define MC_CMD_PTP_OUT_SYNCHRONIZE_LEN(num) (0+20*(num))
664#define MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_OFST 0
665#define MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_LEN 20
666#define MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_MINNUM 1
667#define MC_CMD_PTP_OUT_SYNCHRONIZE_TIMESET_MAXNUM 12
668#define MC_CMD_PTP_OUT_SYNCHRONIZE_HOSTSTART_OFST 0
669#define MC_CMD_PTP_OUT_SYNCHRONIZE_SECONDS_OFST 4
670#define MC_CMD_PTP_OUT_SYNCHRONIZE_NANOSECONDS_OFST 8
671#define MC_CMD_PTP_OUT_SYNCHRONIZE_HOSTEND_OFST 12
672#define MC_CMD_PTP_OUT_SYNCHRONIZE_WAITNS_OFST 16
673
674/* MC_CMD_PTP_OUT_MANFTEST_BASIC msgresponse */
675#define MC_CMD_PTP_OUT_MANFTEST_BASIC_LEN 8
676#define MC_CMD_PTP_OUT_MANFTEST_BASIC_TEST_RESULT_OFST 0
677#define MC_CMD_PTP_MANF_SUCCESS 0x0 /* enum */
678#define MC_CMD_PTP_MANF_FPGA_LOAD 0x1 /* enum */
679#define MC_CMD_PTP_MANF_FPGA_VERSION 0x2 /* enum */
680#define MC_CMD_PTP_MANF_FPGA_REGISTERS 0x3 /* enum */
681#define MC_CMD_PTP_MANF_OSCILLATOR 0x4 /* enum */
682#define MC_CMD_PTP_MANF_TIMESTAMPS 0x5 /* enum */
683#define MC_CMD_PTP_MANF_PACKET_COUNT 0x6 /* enum */
684#define MC_CMD_PTP_MANF_FILTER_COUNT 0x7 /* enum */
685#define MC_CMD_PTP_MANF_PACKET_ENOUGH 0x8 /* enum */
686#define MC_CMD_PTP_MANF_GPIO_TRIGGER 0x9 /* enum */
687#define MC_CMD_PTP_OUT_MANFTEST_BASIC_TEST_EXTOSC_OFST 4
688
689/* MC_CMD_PTP_OUT_MANFTEST_PACKET msgresponse */
690#define MC_CMD_PTP_OUT_MANFTEST_PACKET_LEN 12
691#define MC_CMD_PTP_OUT_MANFTEST_PACKET_TEST_RESULT_OFST 0
692#define MC_CMD_PTP_OUT_MANFTEST_PACKET_TEST_FPGACOUNT_OFST 4
693#define MC_CMD_PTP_OUT_MANFTEST_PACKET_TEST_FILTERCOUNT_OFST 8
694
695
696/***********************************/
697/* MC_CMD_CSR_READ32
698 * Read 32bit words from the indirect memory map.
699 */
700#define MC_CMD_CSR_READ32 0xc
701
702/* MC_CMD_CSR_READ32_IN msgrequest */
703#define MC_CMD_CSR_READ32_IN_LEN 12
704#define MC_CMD_CSR_READ32_IN_ADDR_OFST 0
705#define MC_CMD_CSR_READ32_IN_STEP_OFST 4
706#define MC_CMD_CSR_READ32_IN_NUMWORDS_OFST 8
707
708/* MC_CMD_CSR_READ32_OUT msgresponse */
709#define MC_CMD_CSR_READ32_OUT_LENMIN 4
710#define MC_CMD_CSR_READ32_OUT_LENMAX 252
711#define MC_CMD_CSR_READ32_OUT_LEN(num) (0+4*(num))
712#define MC_CMD_CSR_READ32_OUT_BUFFER_OFST 0
713#define MC_CMD_CSR_READ32_OUT_BUFFER_LEN 4
714#define MC_CMD_CSR_READ32_OUT_BUFFER_MINNUM 1
715#define MC_CMD_CSR_READ32_OUT_BUFFER_MAXNUM 63
716
717
718/***********************************/
719/* MC_CMD_CSR_WRITE32
720 * Write 32bit dwords to the indirect memory map.
721 */
722#define MC_CMD_CSR_WRITE32 0xd
723
724/* MC_CMD_CSR_WRITE32_IN msgrequest */
725#define MC_CMD_CSR_WRITE32_IN_LENMIN 12
726#define MC_CMD_CSR_WRITE32_IN_LENMAX 252
727#define MC_CMD_CSR_WRITE32_IN_LEN(num) (8+4*(num))
728#define MC_CMD_CSR_WRITE32_IN_ADDR_OFST 0
729#define MC_CMD_CSR_WRITE32_IN_STEP_OFST 4
730#define MC_CMD_CSR_WRITE32_IN_BUFFER_OFST 8
731#define MC_CMD_CSR_WRITE32_IN_BUFFER_LEN 4
732#define MC_CMD_CSR_WRITE32_IN_BUFFER_MINNUM 1
733#define MC_CMD_CSR_WRITE32_IN_BUFFER_MAXNUM 61
734
735/* MC_CMD_CSR_WRITE32_OUT msgresponse */
736#define MC_CMD_CSR_WRITE32_OUT_LEN 4
737#define MC_CMD_CSR_WRITE32_OUT_STATUS_OFST 0
738
739
740/***********************************/
741/* MC_CMD_STACKINFO
742 * Get stack information.
743 */
744#define MC_CMD_STACKINFO 0xf
745
746/* MC_CMD_STACKINFO_IN msgrequest */
747#define MC_CMD_STACKINFO_IN_LEN 0
748
749/* MC_CMD_STACKINFO_OUT msgresponse */
750#define MC_CMD_STACKINFO_OUT_LENMIN 12
751#define MC_CMD_STACKINFO_OUT_LENMAX 252
752#define MC_CMD_STACKINFO_OUT_LEN(num) (0+12*(num))
753#define MC_CMD_STACKINFO_OUT_THREAD_INFO_OFST 0
754#define MC_CMD_STACKINFO_OUT_THREAD_INFO_LEN 12
755#define MC_CMD_STACKINFO_OUT_THREAD_INFO_MINNUM 1
756#define MC_CMD_STACKINFO_OUT_THREAD_INFO_MAXNUM 21
757
758
759/***********************************/
760/* MC_CMD_MDIO_READ
761 * MDIO register read.
414 */ 762 */
415#define MC_CMD_MDIO_READ 0x10 763#define MC_CMD_MDIO_READ 0x10
416#define MC_CMD_MDIO_READ_IN_LEN 16
417#define MC_CMD_MDIO_READ_IN_BUS_OFST 0
418#define MC_CMD_MDIO_READ_IN_PRTAD_OFST 4
419#define MC_CMD_MDIO_READ_IN_DEVAD_OFST 8
420#define MC_CMD_MDIO_READ_IN_ADDR_OFST 12
421#define MC_CMD_MDIO_READ_OUT_LEN 8
422#define MC_CMD_MDIO_READ_OUT_VALUE_OFST 0
423#define MC_CMD_MDIO_READ_OUT_STATUS_OFST 4
424
425/* MC_CMD_MDIO_WRITE:
426 * MDIO register write
427 */
428#define MC_CMD_MDIO_WRITE 0x11
429#define MC_CMD_MDIO_WRITE_IN_LEN 20
430#define MC_CMD_MDIO_WRITE_IN_BUS_OFST 0
431#define MC_CMD_MDIO_WRITE_IN_PRTAD_OFST 4
432#define MC_CMD_MDIO_WRITE_IN_DEVAD_OFST 8
433#define MC_CMD_MDIO_WRITE_IN_ADDR_OFST 12
434#define MC_CMD_MDIO_WRITE_IN_VALUE_OFST 16
435#define MC_CMD_MDIO_WRITE_OUT_LEN 4
436#define MC_CMD_MDIO_WRITE_OUT_STATUS_OFST 0
437 764
438/* By default all the MCDI MDIO operations perform clause45 mode. 765/* MC_CMD_MDIO_READ_IN msgrequest */
439 * If you want to use clause22 then set DEVAD = MC_CMD_MDIO_CLAUSE22. 766#define MC_CMD_MDIO_READ_IN_LEN 16
440 */ 767#define MC_CMD_MDIO_READ_IN_BUS_OFST 0
441#define MC_CMD_MDIO_CLAUSE22 32 768#define MC_CMD_MDIO_BUS_INTERNAL 0x0 /* enum */
769#define MC_CMD_MDIO_BUS_EXTERNAL 0x1 /* enum */
770#define MC_CMD_MDIO_READ_IN_PRTAD_OFST 4
771#define MC_CMD_MDIO_READ_IN_DEVAD_OFST 8
772#define MC_CMD_MDIO_CLAUSE22 0x20 /* enum */
773#define MC_CMD_MDIO_READ_IN_ADDR_OFST 12
442 774
443/* There are two MDIO buses: one for the internal PHY, and one for external 775/* MC_CMD_MDIO_READ_OUT msgresponse */
444 * devices. 776#define MC_CMD_MDIO_READ_OUT_LEN 8
445 */ 777#define MC_CMD_MDIO_READ_OUT_VALUE_OFST 0
446#define MC_CMD_MDIO_BUS_INTERNAL 0 778#define MC_CMD_MDIO_READ_OUT_STATUS_OFST 4
447#define MC_CMD_MDIO_BUS_EXTERNAL 1 779#define MC_CMD_MDIO_STATUS_GOOD 0x8 /* enum */
448 780
449/* The MDIO commands return the raw status bits from the MDIO block. A "good" 781
450 * transaction should have the DONE bit set and all other bits clear. 782/***********************************/
783/* MC_CMD_MDIO_WRITE
784 * MDIO register write.
451 */ 785 */
452#define MC_CMD_MDIO_STATUS_GOOD 0x08 786#define MC_CMD_MDIO_WRITE 0x11
453 787
788/* MC_CMD_MDIO_WRITE_IN msgrequest */
789#define MC_CMD_MDIO_WRITE_IN_LEN 20
790#define MC_CMD_MDIO_WRITE_IN_BUS_OFST 0
791/* MC_CMD_MDIO_BUS_INTERNAL 0x0 */
792/* MC_CMD_MDIO_BUS_EXTERNAL 0x1 */
793#define MC_CMD_MDIO_WRITE_IN_PRTAD_OFST 4
794#define MC_CMD_MDIO_WRITE_IN_DEVAD_OFST 8
795/* MC_CMD_MDIO_CLAUSE22 0x20 */
796#define MC_CMD_MDIO_WRITE_IN_ADDR_OFST 12
797#define MC_CMD_MDIO_WRITE_IN_VALUE_OFST 16
454 798
455/* MC_CMD_DBI_WRITE: (debug) 799/* MC_CMD_MDIO_WRITE_OUT msgresponse */
456 * Write DBI register(s) 800#define MC_CMD_MDIO_WRITE_OUT_LEN 4
457 * 801#define MC_CMD_MDIO_WRITE_OUT_STATUS_OFST 0
458 * Host: address, byte-enables (and VF selection, and cs2 flag), 802/* MC_CMD_MDIO_STATUS_GOOD 0x8 */
459 * value [,address ...] 803
460 * MC: nothing 804
805/***********************************/
806/* MC_CMD_DBI_WRITE
807 * Write DBI register(s).
461 */ 808 */
462#define MC_CMD_DBI_WRITE 0x12 809#define MC_CMD_DBI_WRITE 0x12
463#define MC_CMD_DBI_WRITE_IN_LEN(_numwords) \ 810
464 (12 * (_numwords)) 811/* MC_CMD_DBI_WRITE_IN msgrequest */
465#define MC_CMD_DBI_WRITE_IN_ADDRESS_OFST(_word) \ 812#define MC_CMD_DBI_WRITE_IN_LENMIN 12
466 (((_word) * 12) + 0) 813#define MC_CMD_DBI_WRITE_IN_LENMAX 252
467#define MC_CMD_DBI_WRITE_IN_BYTE_MASK_OFST(_word) \ 814#define MC_CMD_DBI_WRITE_IN_LEN(num) (0+12*(num))
468 (((_word) * 12) + 4) 815#define MC_CMD_DBI_WRITE_IN_DBIWROP_OFST 0
469#define MC_CMD_DBI_WRITE_IN_VALUE_OFST(_word) \ 816#define MC_CMD_DBI_WRITE_IN_DBIWROP_LEN 12
470 (((_word) * 12) + 8) 817#define MC_CMD_DBI_WRITE_IN_DBIWROP_MINNUM 1
471#define MC_CMD_DBI_WRITE_OUT_LEN 0 818#define MC_CMD_DBI_WRITE_IN_DBIWROP_MAXNUM 21
472 819
473/* MC_CMD_DBI_READ: (debug) 820/* MC_CMD_DBI_WRITE_OUT msgresponse */
474 * Read DBI register(s) 821#define MC_CMD_DBI_WRITE_OUT_LEN 0
475 * 822
476 * Host: address, [,address ...] 823/* MC_CMD_DBIWROP_TYPEDEF structuredef */
477 * MC: value [,value ...] 824#define MC_CMD_DBIWROP_TYPEDEF_LEN 12
478 * (note: this does not support reading from VFs, but is retained for backwards 825#define MC_CMD_DBIWROP_TYPEDEF_ADDRESS_OFST 0
479 * compatibility; see MC_CMD_DBI_READX below) 826#define MC_CMD_DBIWROP_TYPEDEF_ADDRESS_LBN 0
480 */ 827#define MC_CMD_DBIWROP_TYPEDEF_ADDRESS_WIDTH 32
481#define MC_CMD_DBI_READ 0x13 828#define MC_CMD_DBIWROP_TYPEDEF_BYTE_MASK_OFST 4
482#define MC_CMD_DBI_READ_IN_LEN(_numwords) \ 829#define MC_CMD_DBIWROP_TYPEDEF_BYTE_MASK_LBN 32
483 (4 * (_numwords)) 830#define MC_CMD_DBIWROP_TYPEDEF_BYTE_MASK_WIDTH 32
484#define MC_CMD_DBI_READ_OUT_LEN(_numwords) \ 831#define MC_CMD_DBIWROP_TYPEDEF_VALUE_OFST 8
485 (4 * (_numwords)) 832#define MC_CMD_DBIWROP_TYPEDEF_VALUE_LBN 64
486 833#define MC_CMD_DBIWROP_TYPEDEF_VALUE_WIDTH 32
487/* MC_CMD_PORT_READ32: (debug) 834
835
836/***********************************/
837/* MC_CMD_PORT_READ32
488 * Read a 32-bit register from the indirect port register map. 838 * Read a 32-bit register from the indirect port register map.
489 *
490 * The port to access is implied by the Shared memory channel used.
491 */ 839 */
492#define MC_CMD_PORT_READ32 0x14 840#define MC_CMD_PORT_READ32 0x14
493#define MC_CMD_PORT_READ32_IN_LEN 4
494#define MC_CMD_PORT_READ32_IN_ADDR_OFST 0
495#define MC_CMD_PORT_READ32_OUT_LEN 8
496#define MC_CMD_PORT_READ32_OUT_VALUE_OFST 0
497#define MC_CMD_PORT_READ32_OUT_STATUS_OFST 4
498 841
499/* MC_CMD_PORT_WRITE32: (debug) 842/* MC_CMD_PORT_READ32_IN msgrequest */
843#define MC_CMD_PORT_READ32_IN_LEN 4
844#define MC_CMD_PORT_READ32_IN_ADDR_OFST 0
845
846/* MC_CMD_PORT_READ32_OUT msgresponse */
847#define MC_CMD_PORT_READ32_OUT_LEN 8
848#define MC_CMD_PORT_READ32_OUT_VALUE_OFST 0
849#define MC_CMD_PORT_READ32_OUT_STATUS_OFST 4
850
851
852/***********************************/
853/* MC_CMD_PORT_WRITE32
500 * Write a 32-bit register to the indirect port register map. 854 * Write a 32-bit register to the indirect port register map.
501 *
502 * The port to access is implied by the Shared memory channel used.
503 */ 855 */
504#define MC_CMD_PORT_WRITE32 0x15 856#define MC_CMD_PORT_WRITE32 0x15
505#define MC_CMD_PORT_WRITE32_IN_LEN 8 857
506#define MC_CMD_PORT_WRITE32_IN_ADDR_OFST 0 858/* MC_CMD_PORT_WRITE32_IN msgrequest */
507#define MC_CMD_PORT_WRITE32_IN_VALUE_OFST 4 859#define MC_CMD_PORT_WRITE32_IN_LEN 8
508#define MC_CMD_PORT_WRITE32_OUT_LEN 4 860#define MC_CMD_PORT_WRITE32_IN_ADDR_OFST 0
509#define MC_CMD_PORT_WRITE32_OUT_STATUS_OFST 0 861#define MC_CMD_PORT_WRITE32_IN_VALUE_OFST 4
510 862
511/* MC_CMD_PORT_READ128: (debug) 863/* MC_CMD_PORT_WRITE32_OUT msgresponse */
512 * Read a 128-bit register from indirect port register map 864#define MC_CMD_PORT_WRITE32_OUT_LEN 4
513 * 865#define MC_CMD_PORT_WRITE32_OUT_STATUS_OFST 0
514 * The port to access is implied by the Shared memory channel used. 866
867
868/***********************************/
869/* MC_CMD_PORT_READ128
870 * Read a 128-bit register from the indirect port register map.
515 */ 871 */
516#define MC_CMD_PORT_READ128 0x16 872#define MC_CMD_PORT_READ128 0x16
517#define MC_CMD_PORT_READ128_IN_LEN 4 873
518#define MC_CMD_PORT_READ128_IN_ADDR_OFST 0 874/* MC_CMD_PORT_READ128_IN msgrequest */
519#define MC_CMD_PORT_READ128_OUT_LEN 20 875#define MC_CMD_PORT_READ128_IN_LEN 4
520#define MC_CMD_PORT_READ128_OUT_VALUE_OFST 0 876#define MC_CMD_PORT_READ128_IN_ADDR_OFST 0
521#define MC_CMD_PORT_READ128_OUT_STATUS_OFST 16 877
522 878/* MC_CMD_PORT_READ128_OUT msgresponse */
523/* MC_CMD_PORT_WRITE128: (debug) 879#define MC_CMD_PORT_READ128_OUT_LEN 20
524 * Write a 128-bit register to indirect port register map. 880#define MC_CMD_PORT_READ128_OUT_VALUE_OFST 0
525 * 881#define MC_CMD_PORT_READ128_OUT_VALUE_LEN 16
526 * The port to access is implied by the Shared memory channel used. 882#define MC_CMD_PORT_READ128_OUT_STATUS_OFST 16
883
884
885/***********************************/
886/* MC_CMD_PORT_WRITE128
887 * Write a 128-bit register to the indirect port register map.
527 */ 888 */
528#define MC_CMD_PORT_WRITE128 0x17 889#define MC_CMD_PORT_WRITE128 0x17
529#define MC_CMD_PORT_WRITE128_IN_LEN 20 890
530#define MC_CMD_PORT_WRITE128_IN_ADDR_OFST 0 891/* MC_CMD_PORT_WRITE128_IN msgrequest */
531#define MC_CMD_PORT_WRITE128_IN_VALUE_OFST 4 892#define MC_CMD_PORT_WRITE128_IN_LEN 20
532#define MC_CMD_PORT_WRITE128_OUT_LEN 4 893#define MC_CMD_PORT_WRITE128_IN_ADDR_OFST 0
533#define MC_CMD_PORT_WRITE128_OUT_STATUS_OFST 0 894#define MC_CMD_PORT_WRITE128_IN_VALUE_OFST 4
534 895#define MC_CMD_PORT_WRITE128_IN_VALUE_LEN 16
535/* MC_CMD_GET_BOARD_CFG: 896
536 * Returns the MC firmware configuration structure 897/* MC_CMD_PORT_WRITE128_OUT msgresponse */
537 * 898#define MC_CMD_PORT_WRITE128_OUT_LEN 4
538 * The FW_SUBTYPE_LIST contains a 16-bit value for each of the 12 types of 899#define MC_CMD_PORT_WRITE128_OUT_STATUS_OFST 0
539 * NVRAM area. The values are defined in the firmware/mc/platform/<xxx>.c file 900
540 * for a specific board type, but otherwise have no meaning to the MC; they 901
541 * are used by the driver to manage selection of appropriate firmware updates. 902/***********************************/
903/* MC_CMD_GET_BOARD_CFG
904 * Returns the MC firmware configuration structure.
542 */ 905 */
543#define MC_CMD_GET_BOARD_CFG 0x18 906#define MC_CMD_GET_BOARD_CFG 0x18
544#define MC_CMD_GET_BOARD_CFG_IN_LEN 0 907
545#define MC_CMD_GET_BOARD_CFG_OUT_LEN 96 908/* MC_CMD_GET_BOARD_CFG_IN msgrequest */
546#define MC_CMD_GET_BOARD_CFG_OUT_BOARD_TYPE_OFST 0 909#define MC_CMD_GET_BOARD_CFG_IN_LEN 0
547#define MC_CMD_GET_BOARD_CFG_OUT_BOARD_NAME_OFST 4 910
548#define MC_CMD_GET_BOARD_CFG_OUT_BOARD_NAME_LEN 32 911/* MC_CMD_GET_BOARD_CFG_OUT msgresponse */
549#define MC_CMD_GET_BOARD_CFG_OUT_CAPABILITIES_PORT0_OFST 36 912#define MC_CMD_GET_BOARD_CFG_OUT_LENMIN 96
550#define MC_CMD_GET_BOARD_CFG_OUT_CAPABILITIES_PORT1_OFST 40 913#define MC_CMD_GET_BOARD_CFG_OUT_LENMAX 136
551#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0_OFST 44 914#define MC_CMD_GET_BOARD_CFG_OUT_LEN(num) (72+2*(num))
552#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0_LEN 6 915#define MC_CMD_GET_BOARD_CFG_OUT_BOARD_TYPE_OFST 0
553#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1_OFST 50 916#define MC_CMD_GET_BOARD_CFG_OUT_BOARD_NAME_OFST 4
554#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1_LEN 6 917#define MC_CMD_GET_BOARD_CFG_OUT_BOARD_NAME_LEN 32
555#define MC_CMD_GET_BOARD_CFG_OUT_MAC_COUNT_PORT0_OFST 56 918#define MC_CMD_GET_BOARD_CFG_OUT_CAPABILITIES_PORT0_OFST 36
556#define MC_CMD_GET_BOARD_CFG_OUT_MAC_COUNT_PORT1_OFST 60 919#define MC_CMD_CAPABILITIES_SMALL_BUF_TBL_LBN 0x0 /* enum */
557#define MC_CMD_GET_BOARD_CFG_OUT_MAC_STRIDE_PORT0_OFST 64 920#define MC_CMD_CAPABILITIES_SMALL_BUF_TBL_WIDTH 0x1 /* enum */
558#define MC_CMD_GET_BOARD_CFG_OUT_MAC_STRIDE_PORT1_OFST 68 921#define MC_CMD_CAPABILITIES_TURBO_LBN 0x1 /* enum */
559#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST 72 922#define MC_CMD_CAPABILITIES_TURBO_WIDTH 0x1 /* enum */
560#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_LEN 24 923#define MC_CMD_CAPABILITIES_TURBO_ACTIVE_LBN 0x2 /* enum */
561 924#define MC_CMD_CAPABILITIES_TURBO_ACTIVE_WIDTH 0x1 /* enum */
562/* MC_CMD_DBI_READX: (debug) 925#define MC_CMD_CAPABILITIES_PTP_LBN 0x3 /* enum */
563 * Read DBI register(s) -- extended functionality 926#define MC_CMD_CAPABILITIES_PTP_WIDTH 0x1 /* enum */
564 * 927#define MC_CMD_GET_BOARD_CFG_OUT_CAPABILITIES_PORT1_OFST 40
565 * Host: vf selection, address, [,vf selection ...] 928/* Enum values, see field(s): */
566 * MC: value [,value ...] 929/* CAPABILITIES_PORT0 */
930#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0_OFST 44
931#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT0_LEN 6
932#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1_OFST 50
933#define MC_CMD_GET_BOARD_CFG_OUT_MAC_ADDR_BASE_PORT1_LEN 6
934#define MC_CMD_GET_BOARD_CFG_OUT_MAC_COUNT_PORT0_OFST 56
935#define MC_CMD_GET_BOARD_CFG_OUT_MAC_COUNT_PORT1_OFST 60
936#define MC_CMD_GET_BOARD_CFG_OUT_MAC_STRIDE_PORT0_OFST 64
937#define MC_CMD_GET_BOARD_CFG_OUT_MAC_STRIDE_PORT1_OFST 68
938#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_OFST 72
939#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_LEN 2
940#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MINNUM 12
941#define MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MAXNUM 32
942
943
944/***********************************/
945/* MC_CMD_DBI_READX
946 * Read DBI register(s).
567 */ 947 */
568#define MC_CMD_DBI_READX 0x19 948#define MC_CMD_DBI_READX 0x19
569#define MC_CMD_DBI_READX_IN_LEN(_numwords) \
570 (8*(_numwords))
571#define MC_CMD_DBI_READX_OUT_LEN(_numwords) \
572 (4*(_numwords))
573 949
574/* MC_CMD_SET_RAND_SEED: 950/* MC_CMD_DBI_READX_IN msgrequest */
575 * Set the 16byte seed for the MC pseudo-random generator 951#define MC_CMD_DBI_READX_IN_LENMIN 8
952#define MC_CMD_DBI_READX_IN_LENMAX 248
953#define MC_CMD_DBI_READX_IN_LEN(num) (0+8*(num))
954#define MC_CMD_DBI_READX_IN_DBIRDOP_OFST 0
955#define MC_CMD_DBI_READX_IN_DBIRDOP_LEN 8
956#define MC_CMD_DBI_READX_IN_DBIRDOP_LO_OFST 0
957#define MC_CMD_DBI_READX_IN_DBIRDOP_HI_OFST 4
958#define MC_CMD_DBI_READX_IN_DBIRDOP_MINNUM 1
959#define MC_CMD_DBI_READX_IN_DBIRDOP_MAXNUM 31
960
961/* MC_CMD_DBI_READX_OUT msgresponse */
962#define MC_CMD_DBI_READX_OUT_LENMIN 4
963#define MC_CMD_DBI_READX_OUT_LENMAX 252
964#define MC_CMD_DBI_READX_OUT_LEN(num) (0+4*(num))
965#define MC_CMD_DBI_READX_OUT_VALUE_OFST 0
966#define MC_CMD_DBI_READX_OUT_VALUE_LEN 4
967#define MC_CMD_DBI_READX_OUT_VALUE_MINNUM 1
968#define MC_CMD_DBI_READX_OUT_VALUE_MAXNUM 63
969
970
971/***********************************/
972/* MC_CMD_SET_RAND_SEED
973 * Set the 16byte seed for the MC pseudo-random generator.
576 */ 974 */
577#define MC_CMD_SET_RAND_SEED 0x1a 975#define MC_CMD_SET_RAND_SEED 0x1a
578#define MC_CMD_SET_RAND_SEED_IN_LEN 16
579#define MC_CMD_SET_RAND_SEED_IN_SEED_OFST 0
580#define MC_CMD_SET_RAND_SEED_OUT_LEN 0
581 976
582/* MC_CMD_LTSSM_HIST: (debug) 977/* MC_CMD_SET_RAND_SEED_IN msgrequest */
583 * Retrieve the history of the LTSSM, if the build supports it. 978#define MC_CMD_SET_RAND_SEED_IN_LEN 16
584 * 979#define MC_CMD_SET_RAND_SEED_IN_SEED_OFST 0
585 * Host: nothing 980#define MC_CMD_SET_RAND_SEED_IN_SEED_LEN 16
586 * MC: variable number of LTSSM values, as bytes 981
587 * The history is read-to-clear. 982/* MC_CMD_SET_RAND_SEED_OUT msgresponse */
983#define MC_CMD_SET_RAND_SEED_OUT_LEN 0
984
985
986/***********************************/
987/* MC_CMD_LTSSM_HIST
988 * Retrieve the history of the PCIE LTSSM.
588 */ 989 */
589#define MC_CMD_LTSSM_HIST 0x1b 990#define MC_CMD_LTSSM_HIST 0x1b
590 991
591/* MC_CMD_DRV_ATTACH: 992/* MC_CMD_LTSSM_HIST_IN msgrequest */
592 * Inform MCPU that this port is managed on the host (i.e. driver active) 993#define MC_CMD_LTSSM_HIST_IN_LEN 0
994
995/* MC_CMD_LTSSM_HIST_OUT msgresponse */
996#define MC_CMD_LTSSM_HIST_OUT_LENMIN 0
997#define MC_CMD_LTSSM_HIST_OUT_LENMAX 252
998#define MC_CMD_LTSSM_HIST_OUT_LEN(num) (0+4*(num))
999#define MC_CMD_LTSSM_HIST_OUT_DATA_OFST 0
1000#define MC_CMD_LTSSM_HIST_OUT_DATA_LEN 4
1001#define MC_CMD_LTSSM_HIST_OUT_DATA_MINNUM 0
1002#define MC_CMD_LTSSM_HIST_OUT_DATA_MAXNUM 63
1003
1004
1005/***********************************/
1006/* MC_CMD_DRV_ATTACH
1007 * Inform MCPU that this port is managed on the host.
593 */ 1008 */
594#define MC_CMD_DRV_ATTACH 0x1c 1009#define MC_CMD_DRV_ATTACH 0x1c
595#define MC_CMD_DRV_ATTACH_IN_LEN 8
596#define MC_CMD_DRV_ATTACH_IN_NEW_STATE_OFST 0
597#define MC_CMD_DRV_ATTACH_IN_UPDATE_OFST 4
598#define MC_CMD_DRV_ATTACH_OUT_LEN 4
599#define MC_CMD_DRV_ATTACH_OUT_OLD_STATE_OFST 0
600 1010
601/* MC_CMD_NCSI_PROD: (debug) 1011/* MC_CMD_DRV_ATTACH_IN msgrequest */
602 * Trigger an NC-SI event (and possibly an AEN in response) 1012#define MC_CMD_DRV_ATTACH_IN_LEN 8
1013#define MC_CMD_DRV_ATTACH_IN_NEW_STATE_OFST 0
1014#define MC_CMD_DRV_ATTACH_IN_UPDATE_OFST 4
1015
1016/* MC_CMD_DRV_ATTACH_OUT msgresponse */
1017#define MC_CMD_DRV_ATTACH_OUT_LEN 4
1018#define MC_CMD_DRV_ATTACH_OUT_OLD_STATE_OFST 0
1019
1020
1021/***********************************/
1022/* MC_CMD_NCSI_PROD
1023 * Trigger an NC-SI event.
603 */ 1024 */
604#define MC_CMD_NCSI_PROD 0x1d 1025#define MC_CMD_NCSI_PROD 0x1d
605#define MC_CMD_NCSI_PROD_IN_LEN 4 1026
606#define MC_CMD_NCSI_PROD_IN_EVENTS_OFST 0 1027/* MC_CMD_NCSI_PROD_IN msgrequest */
607#define MC_CMD_NCSI_PROD_LINKCHANGE_LBN 0 1028#define MC_CMD_NCSI_PROD_IN_LEN 4
608#define MC_CMD_NCSI_PROD_LINKCHANGE_WIDTH 1 1029#define MC_CMD_NCSI_PROD_IN_EVENTS_OFST 0
609#define MC_CMD_NCSI_PROD_RESET_LBN 1 1030#define MC_CMD_NCSI_PROD_LINKCHANGE 0x0 /* enum */
610#define MC_CMD_NCSI_PROD_RESET_WIDTH 1 1031#define MC_CMD_NCSI_PROD_RESET 0x1 /* enum */
611#define MC_CMD_NCSI_PROD_DRVATTACH_LBN 2 1032#define MC_CMD_NCSI_PROD_DRVATTACH 0x2 /* enum */
612#define MC_CMD_NCSI_PROD_DRVATTACH_WIDTH 1 1033#define MC_CMD_NCSI_PROD_IN_LINKCHANGE_LBN 0
613#define MC_CMD_NCSI_PROD_OUT_LEN 0 1034#define MC_CMD_NCSI_PROD_IN_LINKCHANGE_WIDTH 1
614 1035#define MC_CMD_NCSI_PROD_IN_RESET_LBN 1
615/* Enumeration */ 1036#define MC_CMD_NCSI_PROD_IN_RESET_WIDTH 1
616#define MC_CMD_NCSI_PROD_LINKCHANGE 0 1037#define MC_CMD_NCSI_PROD_IN_DRVATTACH_LBN 2
617#define MC_CMD_NCSI_PROD_RESET 1 1038#define MC_CMD_NCSI_PROD_IN_DRVATTACH_WIDTH 1
618#define MC_CMD_NCSI_PROD_DRVATTACH 2 1039
619 1040/* MC_CMD_NCSI_PROD_OUT msgresponse */
620/* MC_CMD_DEVEL: (debug) 1041#define MC_CMD_NCSI_PROD_OUT_LEN 0
621 * Reserved for development 1042
622 */ 1043
623#define MC_CMD_DEVEL 0x1e 1044/***********************************/
624 1045/* MC_CMD_SHMUART
625/* MC_CMD_SHMUART: (debug)
626 * Route UART output to circular buffer in shared memory instead. 1046 * Route UART output to circular buffer in shared memory instead.
627 */ 1047 */
628#define MC_CMD_SHMUART 0x1f 1048#define MC_CMD_SHMUART 0x1f
629#define MC_CMD_SHMUART_IN_FLAG_OFST 0
630#define MC_CMD_SHMUART_IN_LEN 4
631#define MC_CMD_SHMUART_OUT_LEN 0
632 1049
633/* MC_CMD_PORT_RESET: 1050/* MC_CMD_SHMUART_IN msgrequest */
634 * Generic per-port reset. There is no equivalent for per-board reset. 1051#define MC_CMD_SHMUART_IN_LEN 4
635 * 1052#define MC_CMD_SHMUART_IN_FLAG_OFST 0
636 * Locks required: None 1053
637 * Return code: 0, ETIME 1054/* MC_CMD_SHMUART_OUT msgresponse */
638 */ 1055#define MC_CMD_SHMUART_OUT_LEN 0
639#define MC_CMD_PORT_RESET 0x20 1056
640#define MC_CMD_PORT_RESET_IN_LEN 0 1057
641#define MC_CMD_PORT_RESET_OUT_LEN 0 1058/***********************************/
642 1059/* MC_CMD_ENTITY_RESET
643/* MC_CMD_RESOURCE_LOCK: 1060 * Generic per-port reset.
644 * Generic resource lock/unlock interface. 1061 */
645 * 1062#define MC_CMD_ENTITY_RESET 0x20
646 * Locks required: None 1063
647 * Return code: 0, 1064/* MC_CMD_ENTITY_RESET_IN msgrequest */
648 * EBUSY (if trylock is contended by other port), 1065#define MC_CMD_ENTITY_RESET_IN_LEN 4
649 * EDEADLK (if trylock is already acquired by this port) 1066#define MC_CMD_ENTITY_RESET_IN_FLAG_OFST 0
650 * EINVAL (if unlock doesn't own the lock) 1067#define MC_CMD_ENTITY_RESET_IN_FUNCTION_RESOURCE_RESET_LBN 0
651 */ 1068#define MC_CMD_ENTITY_RESET_IN_FUNCTION_RESOURCE_RESET_WIDTH 1
652#define MC_CMD_RESOURCE_LOCK 0x21 1069
653#define MC_CMD_RESOURCE_LOCK_IN_LEN 8 1070/* MC_CMD_ENTITY_RESET_OUT msgresponse */
654#define MC_CMD_RESOURCE_LOCK_IN_ACTION_OFST 0 1071#define MC_CMD_ENTITY_RESET_OUT_LEN 0
655#define MC_CMD_RESOURCE_LOCK_ACTION_TRYLOCK 1 1072
656#define MC_CMD_RESOURCE_LOCK_ACTION_UNLOCK 0 1073
657#define MC_CMD_RESOURCE_LOCK_IN_RESOURCE_OFST 4 1074/***********************************/
658#define MC_CMD_RESOURCE_LOCK_I2C 2 1075/* MC_CMD_PCIE_CREDITS
659#define MC_CMD_RESOURCE_LOCK_PHY 3 1076 * Read instantaneous and minimum flow control thresholds.
660#define MC_CMD_RESOURCE_LOCK_OUT_LEN 0 1077 */
661 1078#define MC_CMD_PCIE_CREDITS 0x21
662/* MC_CMD_SPI_COMMAND: (variadic in, variadic out) 1079
663 * Read/Write to/from the SPI device. 1080/* MC_CMD_PCIE_CREDITS_IN msgrequest */
664 * 1081#define MC_CMD_PCIE_CREDITS_IN_LEN 8
665 * Locks required: SPI_LOCK 1082#define MC_CMD_PCIE_CREDITS_IN_POLL_PERIOD_OFST 0
666 * Return code: 0, ETIME, EINVAL, EACCES (if SPI_LOCK is not held) 1083#define MC_CMD_PCIE_CREDITS_IN_WIPE_OFST 4
667 */ 1084
668#define MC_CMD_SPI_COMMAND 0x22 1085/* MC_CMD_PCIE_CREDITS_OUT msgresponse */
669#define MC_CMD_SPI_COMMAND_IN_LEN(_write_bytes) (12 + (_write_bytes)) 1086#define MC_CMD_PCIE_CREDITS_OUT_LEN 16
670#define MC_CMD_SPI_COMMAND_IN_ARGS_OFST 0 1087#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_P_HDR_OFST 0
671#define MC_CMD_SPI_COMMAND_IN_ARGS_ADDRESS_OFST 0 1088#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_P_HDR_LEN 2
672#define MC_CMD_SPI_COMMAND_IN_ARGS_READ_BYTES_OFST 4 1089#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_P_DATA_OFST 2
673#define MC_CMD_SPI_COMMAND_IN_ARGS_CHIP_SELECT_OFST 8 1090#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_P_DATA_LEN 2
674/* Data to write here */ 1091#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_NP_HDR_OFST 4
675#define MC_CMD_SPI_COMMAND_IN_WRITE_BUFFER_OFST 12 1092#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_NP_HDR_LEN 2
676#define MC_CMD_SPI_COMMAND_OUT_LEN(_read_bytes) (_read_bytes) 1093#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_NP_DATA_OFST 6
677/* Data read here */ 1094#define MC_CMD_PCIE_CREDITS_OUT_CURRENT_NP_DATA_LEN 2
678#define MC_CMD_SPI_COMMAND_OUT_READ_BUFFER_OFST 0 1095#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_P_HDR_OFST 8
679 1096#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_P_HDR_LEN 2
680/* MC_CMD_I2C_READ_WRITE: (variadic in, variadic out) 1097#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_P_DATA_OFST 10
681 * Read/Write to/from the I2C bus. 1098#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_P_DATA_LEN 2
682 * 1099#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_NP_HDR_OFST 12
683 * Locks required: I2C_LOCK 1100#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_NP_HDR_LEN 2
684 * Return code: 0, ETIME, EINVAL, EACCES (if I2C_LOCK is not held) 1101#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_NP_DATA_OFST 14
685 */ 1102#define MC_CMD_PCIE_CREDITS_OUT_MINIMUM_NP_DATA_LEN 2
686#define MC_CMD_I2C_RW 0x23 1103
687#define MC_CMD_I2C_RW_IN_LEN(_write_bytes) (8 + (_write_bytes)) 1104
688#define MC_CMD_I2C_RW_IN_ARGS_OFST 0 1105/***********************************/
689#define MC_CMD_I2C_RW_IN_ARGS_ADDR_OFST 0 1106/* MC_CMD_RXD_MONITOR
690#define MC_CMD_I2C_RW_IN_ARGS_READ_BYTES_OFST 4 1107 * Get histogram of RX queue fill level.
691/* Data to write here */ 1108 */
692#define MC_CMD_I2C_RW_IN_WRITE_BUFFER_OFSET 8 1109#define MC_CMD_RXD_MONITOR 0x22
693#define MC_CMD_I2C_RW_OUT_LEN(_read_bytes) (_read_bytes) 1110
694/* Data read here */ 1111/* MC_CMD_RXD_MONITOR_IN msgrequest */
695#define MC_CMD_I2C_RW_OUT_READ_BUFFER_OFST 0 1112#define MC_CMD_RXD_MONITOR_IN_LEN 12
696 1113#define MC_CMD_RXD_MONITOR_IN_QID_OFST 0
697/* Generic phy capability bitmask */ 1114#define MC_CMD_RXD_MONITOR_IN_POLL_PERIOD_OFST 4
698#define MC_CMD_PHY_CAP_10HDX_LBN 1 1115#define MC_CMD_RXD_MONITOR_IN_WIPE_OFST 8
699#define MC_CMD_PHY_CAP_10HDX_WIDTH 1 1116
700#define MC_CMD_PHY_CAP_10FDX_LBN 2 1117/* MC_CMD_RXD_MONITOR_OUT msgresponse */
701#define MC_CMD_PHY_CAP_10FDX_WIDTH 1 1118#define MC_CMD_RXD_MONITOR_OUT_LEN 80
702#define MC_CMD_PHY_CAP_100HDX_LBN 3 1119#define MC_CMD_RXD_MONITOR_OUT_QID_OFST 0
703#define MC_CMD_PHY_CAP_100HDX_WIDTH 1 1120#define MC_CMD_RXD_MONITOR_OUT_RING_FILL_OFST 4
704#define MC_CMD_PHY_CAP_100FDX_LBN 4 1121#define MC_CMD_RXD_MONITOR_OUT_CACHE_FILL_OFST 8
705#define MC_CMD_PHY_CAP_100FDX_WIDTH 1 1122#define MC_CMD_RXD_MONITOR_OUT_RING_LT_1_OFST 12
706#define MC_CMD_PHY_CAP_1000HDX_LBN 5 1123#define MC_CMD_RXD_MONITOR_OUT_RING_LT_2_OFST 16
707#define MC_CMD_PHY_CAP_1000HDX_WIDTH 1 1124#define MC_CMD_RXD_MONITOR_OUT_RING_LT_4_OFST 20
708#define MC_CMD_PHY_CAP_1000FDX_LBN 6 1125#define MC_CMD_RXD_MONITOR_OUT_RING_LT_8_OFST 24
709#define MC_CMD_PHY_CAP_1000FDX_WIDTH 1 1126#define MC_CMD_RXD_MONITOR_OUT_RING_LT_16_OFST 28
710#define MC_CMD_PHY_CAP_10000FDX_LBN 7 1127#define MC_CMD_RXD_MONITOR_OUT_RING_LT_32_OFST 32
711#define MC_CMD_PHY_CAP_10000FDX_WIDTH 1 1128#define MC_CMD_RXD_MONITOR_OUT_RING_LT_64_OFST 36
712#define MC_CMD_PHY_CAP_PAUSE_LBN 8 1129#define MC_CMD_RXD_MONITOR_OUT_RING_LT_128_OFST 40
713#define MC_CMD_PHY_CAP_PAUSE_WIDTH 1 1130#define MC_CMD_RXD_MONITOR_OUT_RING_LT_256_OFST 44
714#define MC_CMD_PHY_CAP_ASYM_LBN 9 1131#define MC_CMD_RXD_MONITOR_OUT_RING_GE_256_OFST 48
715#define MC_CMD_PHY_CAP_ASYM_WIDTH 1 1132#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_1_OFST 52
716#define MC_CMD_PHY_CAP_AN_LBN 10 1133#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_2_OFST 56
717#define MC_CMD_PHY_CAP_AN_WIDTH 1 1134#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_4_OFST 60
718 1135#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_8_OFST 64
719/* Generic loopback enumeration */ 1136#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_16_OFST 68
720#define MC_CMD_LOOPBACK_NONE 0 1137#define MC_CMD_RXD_MONITOR_OUT_CACHE_LT_32_OFST 72
721#define MC_CMD_LOOPBACK_DATA 1 1138#define MC_CMD_RXD_MONITOR_OUT_CACHE_GE_32_OFST 76
722#define MC_CMD_LOOPBACK_GMAC 2 1139
723#define MC_CMD_LOOPBACK_XGMII 3 1140
724#define MC_CMD_LOOPBACK_XGXS 4 1141/***********************************/
725#define MC_CMD_LOOPBACK_XAUI 5 1142/* MC_CMD_PUTS
726#define MC_CMD_LOOPBACK_GMII 6 1143 * puts(3) implementation over MCDI
727#define MC_CMD_LOOPBACK_SGMII 7 1144 */
728#define MC_CMD_LOOPBACK_XGBR 8 1145#define MC_CMD_PUTS 0x23
729#define MC_CMD_LOOPBACK_XFI 9 1146
730#define MC_CMD_LOOPBACK_XAUI_FAR 10 1147/* MC_CMD_PUTS_IN msgrequest */
731#define MC_CMD_LOOPBACK_GMII_FAR 11 1148#define MC_CMD_PUTS_IN_LENMIN 13
732#define MC_CMD_LOOPBACK_SGMII_FAR 12 1149#define MC_CMD_PUTS_IN_LENMAX 255
733#define MC_CMD_LOOPBACK_XFI_FAR 13 1150#define MC_CMD_PUTS_IN_LEN(num) (12+1*(num))
734#define MC_CMD_LOOPBACK_GPHY 14 1151#define MC_CMD_PUTS_IN_DEST_OFST 0
735#define MC_CMD_LOOPBACK_PHYXS 15 1152#define MC_CMD_PUTS_IN_UART_LBN 0
736#define MC_CMD_LOOPBACK_PCS 16 1153#define MC_CMD_PUTS_IN_UART_WIDTH 1
737#define MC_CMD_LOOPBACK_PMAPMD 17 1154#define MC_CMD_PUTS_IN_PORT_LBN 1
738#define MC_CMD_LOOPBACK_XPORT 18 1155#define MC_CMD_PUTS_IN_PORT_WIDTH 1
739#define MC_CMD_LOOPBACK_XGMII_WS 19 1156#define MC_CMD_PUTS_IN_DHOST_OFST 4
740#define MC_CMD_LOOPBACK_XAUI_WS 20 1157#define MC_CMD_PUTS_IN_DHOST_LEN 6
741#define MC_CMD_LOOPBACK_XAUI_WS_FAR 21 1158#define MC_CMD_PUTS_IN_STRING_OFST 12
742#define MC_CMD_LOOPBACK_XAUI_WS_NEAR 22 1159#define MC_CMD_PUTS_IN_STRING_LEN 1
743#define MC_CMD_LOOPBACK_GMII_WS 23 1160#define MC_CMD_PUTS_IN_STRING_MINNUM 1
744#define MC_CMD_LOOPBACK_XFI_WS 24 1161#define MC_CMD_PUTS_IN_STRING_MAXNUM 243
745#define MC_CMD_LOOPBACK_XFI_WS_FAR 25 1162
746#define MC_CMD_LOOPBACK_PHYXS_WS 26 1163/* MC_CMD_PUTS_OUT msgresponse */
747 1164#define MC_CMD_PUTS_OUT_LEN 0
748/* Generic PHY statistics enumeration */ 1165
749#define MC_CMD_OUI 0 1166
750#define MC_CMD_PMA_PMD_LINK_UP 1 1167/***********************************/
751#define MC_CMD_PMA_PMD_RX_FAULT 2 1168/* MC_CMD_GET_PHY_CFG
752#define MC_CMD_PMA_PMD_TX_FAULT 3 1169 * Report PHY configuration.
753#define MC_CMD_PMA_PMD_SIGNAL 4
754#define MC_CMD_PMA_PMD_SNR_A 5
755#define MC_CMD_PMA_PMD_SNR_B 6
756#define MC_CMD_PMA_PMD_SNR_C 7
757#define MC_CMD_PMA_PMD_SNR_D 8
758#define MC_CMD_PCS_LINK_UP 9
759#define MC_CMD_PCS_RX_FAULT 10
760#define MC_CMD_PCS_TX_FAULT 11
761#define MC_CMD_PCS_BER 12
762#define MC_CMD_PCS_BLOCK_ERRORS 13
763#define MC_CMD_PHYXS_LINK_UP 14
764#define MC_CMD_PHYXS_RX_FAULT 15
765#define MC_CMD_PHYXS_TX_FAULT 16
766#define MC_CMD_PHYXS_ALIGN 17
767#define MC_CMD_PHYXS_SYNC 18
768#define MC_CMD_AN_LINK_UP 19
769#define MC_CMD_AN_COMPLETE 20
770#define MC_CMD_AN_10GBT_STATUS 21
771#define MC_CMD_CL22_LINK_UP 22
772#define MC_CMD_PHY_NSTATS 23
773
774/* MC_CMD_GET_PHY_CFG:
775 * Report PHY configuration. This guarantees to succeed even if the PHY is in
776 * a "zombie" state.
777 *
778 * Locks required: None
779 * Return code: 0
780 */ 1170 */
781#define MC_CMD_GET_PHY_CFG 0x24 1171#define MC_CMD_GET_PHY_CFG 0x24
782 1172
783#define MC_CMD_GET_PHY_CFG_IN_LEN 0 1173/* MC_CMD_GET_PHY_CFG_IN msgrequest */
784#define MC_CMD_GET_PHY_CFG_OUT_LEN 72 1174#define MC_CMD_GET_PHY_CFG_IN_LEN 0
785 1175
786#define MC_CMD_GET_PHY_CFG_OUT_FLAGS_OFST 0 1176/* MC_CMD_GET_PHY_CFG_OUT msgresponse */
787#define MC_CMD_GET_PHY_CFG_PRESENT_LBN 0 1177#define MC_CMD_GET_PHY_CFG_OUT_LEN 72
788#define MC_CMD_GET_PHY_CFG_PRESENT_WIDTH 1 1178#define MC_CMD_GET_PHY_CFG_OUT_FLAGS_OFST 0
789#define MC_CMD_GET_PHY_CFG_BIST_CABLE_SHORT_LBN 1 1179#define MC_CMD_GET_PHY_CFG_OUT_PRESENT_LBN 0
790#define MC_CMD_GET_PHY_CFG_BIST_CABLE_SHORT_WIDTH 1 1180#define MC_CMD_GET_PHY_CFG_OUT_PRESENT_WIDTH 1
791#define MC_CMD_GET_PHY_CFG_BIST_CABLE_LONG_LBN 2 1181#define MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_LBN 1
792#define MC_CMD_GET_PHY_CFG_BIST_CABLE_LONG_WIDTH 1 1182#define MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_WIDTH 1
793#define MC_CMD_GET_PHY_CFG_LOWPOWER_LBN 3 1183#define MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN 2
794#define MC_CMD_GET_PHY_CFG_LOWPOWER_WIDTH 1 1184#define MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_WIDTH 1
795#define MC_CMD_GET_PHY_CFG_POWEROFF_LBN 4 1185#define MC_CMD_GET_PHY_CFG_OUT_LOWPOWER_LBN 3
796#define MC_CMD_GET_PHY_CFG_POWEROFF_WIDTH 1 1186#define MC_CMD_GET_PHY_CFG_OUT_LOWPOWER_WIDTH 1
797#define MC_CMD_GET_PHY_CFG_TXDIS_LBN 5 1187#define MC_CMD_GET_PHY_CFG_OUT_POWEROFF_LBN 4
798#define MC_CMD_GET_PHY_CFG_TXDIS_WIDTH 1 1188#define MC_CMD_GET_PHY_CFG_OUT_POWEROFF_WIDTH 1
799#define MC_CMD_GET_PHY_CFG_BIST_LBN 6 1189#define MC_CMD_GET_PHY_CFG_OUT_TXDIS_LBN 5
800#define MC_CMD_GET_PHY_CFG_BIST_WIDTH 1 1190#define MC_CMD_GET_PHY_CFG_OUT_TXDIS_WIDTH 1
801#define MC_CMD_GET_PHY_CFG_OUT_TYPE_OFST 4 1191#define MC_CMD_GET_PHY_CFG_OUT_BIST_LBN 6
802/* Bitmask of supported capabilities */ 1192#define MC_CMD_GET_PHY_CFG_OUT_BIST_WIDTH 1
803#define MC_CMD_GET_PHY_CFG_OUT_SUPPORTED_CAP_OFST 8 1193#define MC_CMD_GET_PHY_CFG_OUT_TYPE_OFST 4
804#define MC_CMD_GET_PHY_CFG_OUT_CHANNEL_OFST 12 1194#define MC_CMD_GET_PHY_CFG_OUT_SUPPORTED_CAP_OFST 8
805#define MC_CMD_GET_PHY_CFG_OUT_PRT_OFST 16 1195#define MC_CMD_PHY_CAP_10HDX_LBN 1
806/* PHY statistics bitmap */ 1196#define MC_CMD_PHY_CAP_10HDX_WIDTH 1
807#define MC_CMD_GET_PHY_CFG_OUT_STATS_MASK_OFST 20 1197#define MC_CMD_PHY_CAP_10FDX_LBN 2
808/* PHY type/name string */ 1198#define MC_CMD_PHY_CAP_10FDX_WIDTH 1
809#define MC_CMD_GET_PHY_CFG_OUT_NAME_OFST 24 1199#define MC_CMD_PHY_CAP_100HDX_LBN 3
810#define MC_CMD_GET_PHY_CFG_OUT_NAME_LEN 20 1200#define MC_CMD_PHY_CAP_100HDX_WIDTH 1
811#define MC_CMD_GET_PHY_CFG_OUT_MEDIA_TYPE_OFST 44 1201#define MC_CMD_PHY_CAP_100FDX_LBN 4
812#define MC_CMD_MEDIA_XAUI 1 1202#define MC_CMD_PHY_CAP_100FDX_WIDTH 1
813#define MC_CMD_MEDIA_CX4 2 1203#define MC_CMD_PHY_CAP_1000HDX_LBN 5
814#define MC_CMD_MEDIA_KX4 3 1204#define MC_CMD_PHY_CAP_1000HDX_WIDTH 1
815#define MC_CMD_MEDIA_XFP 4 1205#define MC_CMD_PHY_CAP_1000FDX_LBN 6
816#define MC_CMD_MEDIA_SFP_PLUS 5 1206#define MC_CMD_PHY_CAP_1000FDX_WIDTH 1
817#define MC_CMD_MEDIA_BASE_T 6 1207#define MC_CMD_PHY_CAP_10000FDX_LBN 7
818/* MDIO "MMDS" supported */ 1208#define MC_CMD_PHY_CAP_10000FDX_WIDTH 1
819#define MC_CMD_GET_PHY_CFG_OUT_MMD_MASK_OFST 48 1209#define MC_CMD_PHY_CAP_PAUSE_LBN 8
820/* Native clause 22 */ 1210#define MC_CMD_PHY_CAP_PAUSE_WIDTH 1
821#define MC_CMD_MMD_CLAUSE22 0 1211#define MC_CMD_PHY_CAP_ASYM_LBN 9
822#define MC_CMD_MMD_CLAUSE45_PMAPMD 1 1212#define MC_CMD_PHY_CAP_ASYM_WIDTH 1
823#define MC_CMD_MMD_CLAUSE45_WIS 2 1213#define MC_CMD_PHY_CAP_AN_LBN 10
824#define MC_CMD_MMD_CLAUSE45_PCS 3 1214#define MC_CMD_PHY_CAP_AN_WIDTH 1
825#define MC_CMD_MMD_CLAUSE45_PHYXS 4 1215#define MC_CMD_GET_PHY_CFG_OUT_CHANNEL_OFST 12
826#define MC_CMD_MMD_CLAUSE45_DTEXS 5 1216#define MC_CMD_GET_PHY_CFG_OUT_PRT_OFST 16
827#define MC_CMD_MMD_CLAUSE45_TC 6 1217#define MC_CMD_GET_PHY_CFG_OUT_STATS_MASK_OFST 20
828#define MC_CMD_MMD_CLAUSE45_AN 7 1218#define MC_CMD_GET_PHY_CFG_OUT_NAME_OFST 24
829/* Clause22 proxied over clause45 by PHY */ 1219#define MC_CMD_GET_PHY_CFG_OUT_NAME_LEN 20
830#define MC_CMD_MMD_CLAUSE45_C22EXT 29 1220#define MC_CMD_GET_PHY_CFG_OUT_MEDIA_TYPE_OFST 44
831#define MC_CMD_MMD_CLAUSE45_VEND1 30 1221#define MC_CMD_MEDIA_XAUI 0x1 /* enum */
832#define MC_CMD_MMD_CLAUSE45_VEND2 31 1222#define MC_CMD_MEDIA_CX4 0x2 /* enum */
833/* PHY stepping version */ 1223#define MC_CMD_MEDIA_KX4 0x3 /* enum */
834#define MC_CMD_GET_PHY_CFG_OUT_REVISION_OFST 52 1224#define MC_CMD_MEDIA_XFP 0x4 /* enum */
835#define MC_CMD_GET_PHY_CFG_OUT_REVISION_LEN 20 1225#define MC_CMD_MEDIA_SFP_PLUS 0x5 /* enum */
836 1226#define MC_CMD_MEDIA_BASE_T 0x6 /* enum */
837/* MC_CMD_START_BIST: 1227#define MC_CMD_GET_PHY_CFG_OUT_MMD_MASK_OFST 48
1228#define MC_CMD_MMD_CLAUSE22 0x0 /* enum */
1229#define MC_CMD_MMD_CLAUSE45_PMAPMD 0x1 /* enum */
1230#define MC_CMD_MMD_CLAUSE45_WIS 0x2 /* enum */
1231#define MC_CMD_MMD_CLAUSE45_PCS 0x3 /* enum */
1232#define MC_CMD_MMD_CLAUSE45_PHYXS 0x4 /* enum */
1233#define MC_CMD_MMD_CLAUSE45_DTEXS 0x5 /* enum */
1234#define MC_CMD_MMD_CLAUSE45_TC 0x6 /* enum */
1235#define MC_CMD_MMD_CLAUSE45_AN 0x7 /* enum */
1236#define MC_CMD_MMD_CLAUSE45_C22EXT 0x1d /* enum */
1237#define MC_CMD_MMD_CLAUSE45_VEND1 0x1e /* enum */
1238#define MC_CMD_MMD_CLAUSE45_VEND2 0x1f /* enum */
1239#define MC_CMD_GET_PHY_CFG_OUT_REVISION_OFST 52
1240#define MC_CMD_GET_PHY_CFG_OUT_REVISION_LEN 20
1241
1242
1243/***********************************/
1244/* MC_CMD_START_BIST
838 * Start a BIST test on the PHY. 1245 * Start a BIST test on the PHY.
839 *
840 * Locks required: PHY_LOCK if doing a PHY BIST
841 * Return code: 0, EINVAL, EACCES (if PHY_LOCK is not held)
842 */ 1246 */
843#define MC_CMD_START_BIST 0x25 1247#define MC_CMD_START_BIST 0x25
844#define MC_CMD_START_BIST_IN_LEN 4 1248
845#define MC_CMD_START_BIST_IN_TYPE_OFST 0 1249/* MC_CMD_START_BIST_IN msgrequest */
846#define MC_CMD_START_BIST_OUT_LEN 0 1250#define MC_CMD_START_BIST_IN_LEN 4
847 1251#define MC_CMD_START_BIST_IN_TYPE_OFST 0
848/* Run the PHY's short cable BIST */ 1252#define MC_CMD_PHY_BIST_CABLE_SHORT 0x1 /* enum */
849#define MC_CMD_PHY_BIST_CABLE_SHORT 1 1253#define MC_CMD_PHY_BIST_CABLE_LONG 0x2 /* enum */
850/* Run the PHY's long cable BIST */ 1254#define MC_CMD_BPX_SERDES_BIST 0x3 /* enum */
851#define MC_CMD_PHY_BIST_CABLE_LONG 2 1255#define MC_CMD_MC_LOOPBACK_BIST 0x4 /* enum */
852/* Run BIST on the currently selected BPX Serdes (XAUI or XFI) */ 1256#define MC_CMD_PHY_BIST 0x5 /* enum */
853#define MC_CMD_BPX_SERDES_BIST 3 1257
854/* Run the MC loopback tests */ 1258/* MC_CMD_START_BIST_OUT msgresponse */
855#define MC_CMD_MC_LOOPBACK_BIST 4 1259#define MC_CMD_START_BIST_OUT_LEN 0
856/* Run the PHY's standard BIST */ 1260
857#define MC_CMD_PHY_BIST 5 1261
858 1262/***********************************/
859/* MC_CMD_POLL_PHY_BIST: (variadic output) 1263/* MC_CMD_POLL_BIST
860 * Poll for BIST completion 1264 * Poll for BIST completion.
861 *
862 * Returns a single status code, and optionally some PHY specific
863 * bist output. The driver should only consume the BIST output
864 * after validating OUTLEN and PHY_CFG.PHY_TYPE.
865 *
866 * If a driver can't successfully parse the BIST output, it should
867 * still respect the pass/Fail in OUT.RESULT
868 *
869 * Locks required: PHY_LOCK if doing a PHY BIST
870 * Return code: 0, EACCES (if PHY_LOCK is not held)
871 */ 1265 */
872#define MC_CMD_POLL_BIST 0x26 1266#define MC_CMD_POLL_BIST 0x26
873#define MC_CMD_POLL_BIST_IN_LEN 0 1267
874#define MC_CMD_POLL_BIST_OUT_LEN UNKNOWN 1268/* MC_CMD_POLL_BIST_IN msgrequest */
875#define MC_CMD_POLL_BIST_OUT_SFT9001_LEN 36 1269#define MC_CMD_POLL_BIST_IN_LEN 0
876#define MC_CMD_POLL_BIST_OUT_MRSFP_LEN 8 1270
877#define MC_CMD_POLL_BIST_OUT_RESULT_OFST 0 1271/* MC_CMD_POLL_BIST_OUT msgresponse */
878#define MC_CMD_POLL_BIST_RUNNING 1 1272#define MC_CMD_POLL_BIST_OUT_LEN 8
879#define MC_CMD_POLL_BIST_PASSED 2 1273#define MC_CMD_POLL_BIST_OUT_RESULT_OFST 0
880#define MC_CMD_POLL_BIST_FAILED 3 1274#define MC_CMD_POLL_BIST_RUNNING 0x1 /* enum */
881#define MC_CMD_POLL_BIST_TIMEOUT 4 1275#define MC_CMD_POLL_BIST_PASSED 0x2 /* enum */
882/* Generic: */ 1276#define MC_CMD_POLL_BIST_FAILED 0x3 /* enum */
883#define MC_CMD_POLL_BIST_OUT_PRIVATE_OFST 4 1277#define MC_CMD_POLL_BIST_TIMEOUT 0x4 /* enum */
884/* SFT9001-specific: */ 1278#define MC_CMD_POLL_BIST_OUT_PRIVATE_OFST 4
885#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_A_OFST 4 1279
886#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_B_OFST 8 1280/* MC_CMD_POLL_BIST_OUT_SFT9001 msgresponse */
887#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_C_OFST 12 1281#define MC_CMD_POLL_BIST_OUT_SFT9001_LEN 36
888#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_D_OFST 16 1282/* MC_CMD_POLL_BIST_OUT_RESULT_OFST 0 */
889#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_A_OFST 20 1283/* Enum values, see field(s): */
890#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_B_OFST 24 1284/* MC_CMD_POLL_BIST_OUT/MC_CMD_POLL_BIST_OUT_RESULT */
891#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_C_OFST 28 1285#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_A_OFST 4
892#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_D_OFST 32 1286#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_B_OFST 8
893#define MC_CMD_POLL_BIST_SFT9001_PAIR_OK 1 1287#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_C_OFST 12
894#define MC_CMD_POLL_BIST_SFT9001_PAIR_OPEN 2 1288#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_D_OFST 16
895#define MC_CMD_POLL_BIST_SFT9001_INTRA_PAIR_SHORT 3 1289#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_A_OFST 20
896#define MC_CMD_POLL_BIST_SFT9001_INTER_PAIR_SHORT 4 1290#define MC_CMD_POLL_BIST_SFT9001_PAIR_OK 0x1 /* enum */
897#define MC_CMD_POLL_BIST_SFT9001_PAIR_BUSY 9 1291#define MC_CMD_POLL_BIST_SFT9001_PAIR_OPEN 0x2 /* enum */
898/* mrsfp "PHY" driver: */ 1292#define MC_CMD_POLL_BIST_SFT9001_INTRA_PAIR_SHORT 0x3 /* enum */
899#define MC_CMD_POLL_BIST_OUT_MRSFP_TEST_OFST 4 1293#define MC_CMD_POLL_BIST_SFT9001_INTER_PAIR_SHORT 0x4 /* enum */
900#define MC_CMD_POLL_BIST_MRSFP_TEST_COMPLETE 0 1294#define MC_CMD_POLL_BIST_SFT9001_PAIR_BUSY 0x9 /* enum */
901#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_WRITE 1 1295#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_B_OFST 24
902#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_IO_EXP 2 1296/* Enum values, see field(s): */
903#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_MODULE 3 1297/* CABLE_STATUS_A */
904#define MC_CMD_POLL_BIST_MRSFP_TEST_IO_EXP_I2C_CONFIGURE 4 1298#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_C_OFST 28
905#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_I2C_NO_CROSSTALK 5 1299/* Enum values, see field(s): */
906#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_PRESENCE 6 1300/* CABLE_STATUS_A */
907#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_I2C_ACCESS 7 1301#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_D_OFST 32
908#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_SANE_VALUE 8 1302/* Enum values, see field(s): */
909 1303/* CABLE_STATUS_A */
910/* MC_CMD_PHY_SPI: (variadic in, variadic out) 1304
911 * Read/Write/Erase the PHY SPI device 1305/* MC_CMD_POLL_BIST_OUT_MRSFP msgresponse */
912 * 1306#define MC_CMD_POLL_BIST_OUT_MRSFP_LEN 8
913 * Locks required: PHY_LOCK 1307/* MC_CMD_POLL_BIST_OUT_RESULT_OFST 0 */
914 * Return code: 0, ETIME, EINVAL, EACCES (if PHY_LOCK is not held) 1308/* Enum values, see field(s): */
915 */ 1309/* MC_CMD_POLL_BIST_OUT/MC_CMD_POLL_BIST_OUT_RESULT */
916#define MC_CMD_PHY_SPI 0x27 1310#define MC_CMD_POLL_BIST_OUT_MRSFP_TEST_OFST 4
917#define MC_CMD_PHY_SPI_IN_LEN(_write_bytes) (12 + (_write_bytes)) 1311#define MC_CMD_POLL_BIST_MRSFP_TEST_COMPLETE 0x0 /* enum */
918#define MC_CMD_PHY_SPI_IN_ARGS_OFST 0 1312#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_WRITE 0x1 /* enum */
919#define MC_CMD_PHY_SPI_IN_ARGS_ADDR_OFST 0 1313#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_IO_EXP 0x2 /* enum */
920#define MC_CMD_PHY_SPI_IN_ARGS_READ_BYTES_OFST 4 1314#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_MODULE 0x3 /* enum */
921#define MC_CMD_PHY_SPI_IN_ARGS_ERASE_ALL_OFST 8 1315#define MC_CMD_POLL_BIST_MRSFP_TEST_IO_EXP_I2C_CONFIGURE 0x4 /* enum */
922/* Data to write here */ 1316#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_I2C_NO_CROSSTALK 0x5 /* enum */
923#define MC_CMD_PHY_SPI_IN_WRITE_BUFFER_OFSET 12 1317#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_PRESENCE 0x6 /* enum */
924#define MC_CMD_PHY_SPI_OUT_LEN(_read_bytes) (_read_bytes) 1318#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_I2C_ACCESS 0x7 /* enum */
925/* Data read here */ 1319#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_SANE_VALUE 0x8 /* enum */
926#define MC_CMD_PHY_SPI_OUT_READ_BUFFER_OFST 0 1320
927 1321
928 1322/***********************************/
929/* MC_CMD_GET_LOOPBACK_MODES: 1323/* MC_CMD_FLUSH_RX_QUEUES
930 * Returns a bitmask of loopback modes evailable at each speed. 1324 * Flush receive queue(s).
931 * 1325 */
932 * Locks required: None 1326#define MC_CMD_FLUSH_RX_QUEUES 0x27
933 * Return code: 0 1327
1328/* MC_CMD_FLUSH_RX_QUEUES_IN msgrequest */
1329#define MC_CMD_FLUSH_RX_QUEUES_IN_LENMIN 4
1330#define MC_CMD_FLUSH_RX_QUEUES_IN_LENMAX 252
1331#define MC_CMD_FLUSH_RX_QUEUES_IN_LEN(num) (0+4*(num))
1332#define MC_CMD_FLUSH_RX_QUEUES_IN_QID_OFST_OFST 0
1333#define MC_CMD_FLUSH_RX_QUEUES_IN_QID_OFST_LEN 4
1334#define MC_CMD_FLUSH_RX_QUEUES_IN_QID_OFST_MINNUM 1
1335#define MC_CMD_FLUSH_RX_QUEUES_IN_QID_OFST_MAXNUM 63
1336
1337/* MC_CMD_FLUSH_RX_QUEUES_OUT msgresponse */
1338#define MC_CMD_FLUSH_RX_QUEUES_OUT_LEN 0
1339
1340
1341/***********************************/
1342/* MC_CMD_GET_LOOPBACK_MODES
1343 * Get port's loopback modes.
934 */ 1344 */
935#define MC_CMD_GET_LOOPBACK_MODES 0x28 1345#define MC_CMD_GET_LOOPBACK_MODES 0x28
936#define MC_CMD_GET_LOOPBACK_MODES_IN_LEN 0 1346
937#define MC_CMD_GET_LOOPBACK_MODES_OUT_LEN 32 1347/* MC_CMD_GET_LOOPBACK_MODES_IN msgrequest */
938#define MC_CMD_GET_LOOPBACK_MODES_100M_OFST 0 1348#define MC_CMD_GET_LOOPBACK_MODES_IN_LEN 0
939#define MC_CMD_GET_LOOPBACK_MODES_1G_OFST 8 1349
940#define MC_CMD_GET_LOOPBACK_MODES_10G_OFST 16 1350/* MC_CMD_GET_LOOPBACK_MODES_OUT msgresponse */
941#define MC_CMD_GET_LOOPBACK_MODES_SUGGESTED_OFST 24 1351#define MC_CMD_GET_LOOPBACK_MODES_OUT_LEN 32
942 1352#define MC_CMD_GET_LOOPBACK_MODES_OUT_100M_OFST 0
943/* Flow control enumeration */ 1353#define MC_CMD_GET_LOOPBACK_MODES_OUT_100M_LEN 8
944#define MC_CMD_FCNTL_OFF 0 1354#define MC_CMD_GET_LOOPBACK_MODES_OUT_100M_LO_OFST 0
945#define MC_CMD_FCNTL_RESPOND 1 1355#define MC_CMD_GET_LOOPBACK_MODES_OUT_100M_HI_OFST 4
946#define MC_CMD_FCNTL_BIDIR 2 1356#define MC_CMD_LOOPBACK_NONE 0x0 /* enum */
947/* Auto - Use what the link has autonegotiated 1357#define MC_CMD_LOOPBACK_DATA 0x1 /* enum */
948 * - The driver should modify the advertised capabilities via SET_LINK.CAP 1358#define MC_CMD_LOOPBACK_GMAC 0x2 /* enum */
949 * to control the negotiated flow control mode. 1359#define MC_CMD_LOOPBACK_XGMII 0x3 /* enum */
950 * - Can only be set if the PHY supports PAUSE+ASYM capabilities 1360#define MC_CMD_LOOPBACK_XGXS 0x4 /* enum */
951 * - Never returned by GET_LINK as the value programmed into the MAC 1361#define MC_CMD_LOOPBACK_XAUI 0x5 /* enum */
952 */ 1362#define MC_CMD_LOOPBACK_GMII 0x6 /* enum */
953#define MC_CMD_FCNTL_AUTO 3 1363#define MC_CMD_LOOPBACK_SGMII 0x7 /* enum */
954 1364#define MC_CMD_LOOPBACK_XGBR 0x8 /* enum */
955/* Generic mac fault bitmask */ 1365#define MC_CMD_LOOPBACK_XFI 0x9 /* enum */
956#define MC_CMD_MAC_FAULT_XGMII_LOCAL_LBN 0 1366#define MC_CMD_LOOPBACK_XAUI_FAR 0xa /* enum */
957#define MC_CMD_MAC_FAULT_XGMII_LOCAL_WIDTH 1 1367#define MC_CMD_LOOPBACK_GMII_FAR 0xb /* enum */
958#define MC_CMD_MAC_FAULT_XGMII_REMOTE_LBN 1 1368#define MC_CMD_LOOPBACK_SGMII_FAR 0xc /* enum */
959#define MC_CMD_MAC_FAULT_XGMII_REMOTE_WIDTH 1 1369#define MC_CMD_LOOPBACK_XFI_FAR 0xd /* enum */
960#define MC_CMD_MAC_FAULT_SGMII_REMOTE_LBN 2 1370#define MC_CMD_LOOPBACK_GPHY 0xe /* enum */
961#define MC_CMD_MAC_FAULT_SGMII_REMOTE_WIDTH 1 1371#define MC_CMD_LOOPBACK_PHYXS 0xf /* enum */
962 1372#define MC_CMD_LOOPBACK_PCS 0x10 /* enum */
963/* MC_CMD_GET_LINK: 1373#define MC_CMD_LOOPBACK_PMAPMD 0x11 /* enum */
964 * Read the unified MAC/PHY link state 1374#define MC_CMD_LOOPBACK_XPORT 0x12 /* enum */
965 * 1375#define MC_CMD_LOOPBACK_XGMII_WS 0x13 /* enum */
966 * Locks required: None 1376#define MC_CMD_LOOPBACK_XAUI_WS 0x14 /* enum */
967 * Return code: 0, ETIME 1377#define MC_CMD_LOOPBACK_XAUI_WS_FAR 0x15 /* enum */
1378#define MC_CMD_LOOPBACK_XAUI_WS_NEAR 0x16 /* enum */
1379#define MC_CMD_LOOPBACK_GMII_WS 0x17 /* enum */
1380#define MC_CMD_LOOPBACK_XFI_WS 0x18 /* enum */
1381#define MC_CMD_LOOPBACK_XFI_WS_FAR 0x19 /* enum */
1382#define MC_CMD_LOOPBACK_PHYXS_WS 0x1a /* enum */
1383#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_OFST 8
1384#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_LEN 8
1385#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_LO_OFST 8
1386#define MC_CMD_GET_LOOPBACK_MODES_OUT_1G_HI_OFST 12
1387/* Enum values, see field(s): */
1388/* 100M */
1389#define MC_CMD_GET_LOOPBACK_MODES_OUT_10G_OFST 16
1390#define MC_CMD_GET_LOOPBACK_MODES_OUT_10G_LEN 8
1391#define MC_CMD_GET_LOOPBACK_MODES_OUT_10G_LO_OFST 16
1392#define MC_CMD_GET_LOOPBACK_MODES_OUT_10G_HI_OFST 20
1393/* Enum values, see field(s): */
1394/* 100M */
1395#define MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_OFST 24
1396#define MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_LEN 8
1397#define MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_LO_OFST 24
1398#define MC_CMD_GET_LOOPBACK_MODES_OUT_SUGGESTED_HI_OFST 28
1399/* Enum values, see field(s): */
1400/* 100M */
1401
1402
1403/***********************************/
1404/* MC_CMD_GET_LINK
1405 * Read the unified MAC/PHY link state.
968 */ 1406 */
969#define MC_CMD_GET_LINK 0x29 1407#define MC_CMD_GET_LINK 0x29
970#define MC_CMD_GET_LINK_IN_LEN 0 1408
971#define MC_CMD_GET_LINK_OUT_LEN 28 1409/* MC_CMD_GET_LINK_IN msgrequest */
972/* near-side and link-partner advertised capabilities */ 1410#define MC_CMD_GET_LINK_IN_LEN 0
973#define MC_CMD_GET_LINK_OUT_CAP_OFST 0 1411
974#define MC_CMD_GET_LINK_OUT_LP_CAP_OFST 4 1412/* MC_CMD_GET_LINK_OUT msgresponse */
975/* Autonegotiated speed in mbit/s. The link may still be down 1413#define MC_CMD_GET_LINK_OUT_LEN 28
976 * even if this reads non-zero */ 1414#define MC_CMD_GET_LINK_OUT_CAP_OFST 0
977#define MC_CMD_GET_LINK_OUT_LINK_SPEED_OFST 8 1415#define MC_CMD_GET_LINK_OUT_LP_CAP_OFST 4
978#define MC_CMD_GET_LINK_OUT_LOOPBACK_MODE_OFST 12 1416#define MC_CMD_GET_LINK_OUT_LINK_SPEED_OFST 8
979#define MC_CMD_GET_LINK_OUT_FLAGS_OFST 16 1417#define MC_CMD_GET_LINK_OUT_LOOPBACK_MODE_OFST 12
980/* Whether we have overall link up */ 1418/* Enum values, see field(s): */
981#define MC_CMD_GET_LINK_LINK_UP_LBN 0 1419/* MC_CMD_GET_LOOPBACK_MODES/MC_CMD_GET_LOOPBACK_MODES_OUT/100M */
982#define MC_CMD_GET_LINK_LINK_UP_WIDTH 1 1420#define MC_CMD_GET_LINK_OUT_FLAGS_OFST 16
983#define MC_CMD_GET_LINK_FULL_DUPLEX_LBN 1 1421#define MC_CMD_GET_LINK_OUT_LINK_UP_LBN 0
984#define MC_CMD_GET_LINK_FULL_DUPLEX_WIDTH 1 1422#define MC_CMD_GET_LINK_OUT_LINK_UP_WIDTH 1
985/* Whether we have link at the layers provided by the BPX */ 1423#define MC_CMD_GET_LINK_OUT_FULL_DUPLEX_LBN 1
986#define MC_CMD_GET_LINK_BPX_LINK_LBN 2 1424#define MC_CMD_GET_LINK_OUT_FULL_DUPLEX_WIDTH 1
987#define MC_CMD_GET_LINK_BPX_LINK_WIDTH 1 1425#define MC_CMD_GET_LINK_OUT_BPX_LINK_LBN 2
988/* Whether the PHY has external link */ 1426#define MC_CMD_GET_LINK_OUT_BPX_LINK_WIDTH 1
989#define MC_CMD_GET_LINK_PHY_LINK_LBN 3 1427#define MC_CMD_GET_LINK_OUT_PHY_LINK_LBN 3
990#define MC_CMD_GET_LINK_PHY_LINK_WIDTH 1 1428#define MC_CMD_GET_LINK_OUT_PHY_LINK_WIDTH 1
991#define MC_CMD_GET_LINK_OUT_FCNTL_OFST 20 1429#define MC_CMD_GET_LINK_OUT_FCNTL_OFST 20
992#define MC_CMD_GET_LINK_OUT_MAC_FAULT_OFST 24 1430#define MC_CMD_FCNTL_OFF 0x0 /* enum */
993 1431#define MC_CMD_FCNTL_RESPOND 0x1 /* enum */
994/* MC_CMD_SET_LINK: 1432#define MC_CMD_FCNTL_BIDIR 0x2 /* enum */
995 * Write the unified MAC/PHY link configuration 1433#define MC_CMD_GET_LINK_OUT_MAC_FAULT_OFST 24
996 * 1434#define MC_CMD_MAC_FAULT_XGMII_LOCAL_LBN 0
997 * A loopback speed of "0" is supported, and means 1435#define MC_CMD_MAC_FAULT_XGMII_LOCAL_WIDTH 1
998 * (choose any available speed) 1436#define MC_CMD_MAC_FAULT_XGMII_REMOTE_LBN 1
999 * 1437#define MC_CMD_MAC_FAULT_XGMII_REMOTE_WIDTH 1
1000 * Locks required: None 1438#define MC_CMD_MAC_FAULT_SGMII_REMOTE_LBN 2
1001 * Return code: 0, EINVAL, ETIME 1439#define MC_CMD_MAC_FAULT_SGMII_REMOTE_WIDTH 1
1440#define MC_CMD_MAC_FAULT_PENDING_RECONFIG_LBN 3
1441#define MC_CMD_MAC_FAULT_PENDING_RECONFIG_WIDTH 1
1442
1443
1444/***********************************/
1445/* MC_CMD_SET_LINK
1446 * Write the unified MAC/PHY link configuration.
1002 */ 1447 */
1003#define MC_CMD_SET_LINK 0x2a 1448#define MC_CMD_SET_LINK 0x2a
1004#define MC_CMD_SET_LINK_IN_LEN 16 1449
1005#define MC_CMD_SET_LINK_IN_CAP_OFST 0 1450/* MC_CMD_SET_LINK_IN msgrequest */
1006#define MC_CMD_SET_LINK_IN_FLAGS_OFST 4 1451#define MC_CMD_SET_LINK_IN_LEN 16
1007#define MC_CMD_SET_LINK_LOWPOWER_LBN 0 1452#define MC_CMD_SET_LINK_IN_CAP_OFST 0
1008#define MC_CMD_SET_LINK_LOWPOWER_WIDTH 1 1453#define MC_CMD_SET_LINK_IN_FLAGS_OFST 4
1009#define MC_CMD_SET_LINK_POWEROFF_LBN 1 1454#define MC_CMD_SET_LINK_IN_LOWPOWER_LBN 0
1010#define MC_CMD_SET_LINK_POWEROFF_WIDTH 1 1455#define MC_CMD_SET_LINK_IN_LOWPOWER_WIDTH 1
1011#define MC_CMD_SET_LINK_TXDIS_LBN 2 1456#define MC_CMD_SET_LINK_IN_POWEROFF_LBN 1
1012#define MC_CMD_SET_LINK_TXDIS_WIDTH 1 1457#define MC_CMD_SET_LINK_IN_POWEROFF_WIDTH 1
1013#define MC_CMD_SET_LINK_IN_LOOPBACK_MODE_OFST 8 1458#define MC_CMD_SET_LINK_IN_TXDIS_LBN 2
1014#define MC_CMD_SET_LINK_IN_LOOPBACK_SPEED_OFST 12 1459#define MC_CMD_SET_LINK_IN_TXDIS_WIDTH 1
1015#define MC_CMD_SET_LINK_OUT_LEN 0 1460#define MC_CMD_SET_LINK_IN_LOOPBACK_MODE_OFST 8
1016 1461/* Enum values, see field(s): */
1017/* MC_CMD_SET_ID_LED: 1462/* MC_CMD_GET_LOOPBACK_MODES/MC_CMD_GET_LOOPBACK_MODES_OUT/100M */
1018 * Set indentification LED state 1463#define MC_CMD_SET_LINK_IN_LOOPBACK_SPEED_OFST 12
1019 * 1464
1020 * Locks required: None 1465/* MC_CMD_SET_LINK_OUT msgresponse */
1021 * Return code: 0, EINVAL 1466#define MC_CMD_SET_LINK_OUT_LEN 0
1467
1468
1469/***********************************/
1470/* MC_CMD_SET_ID_LED
1471 * Set indentification LED state.
1022 */ 1472 */
1023#define MC_CMD_SET_ID_LED 0x2b 1473#define MC_CMD_SET_ID_LED 0x2b
1024#define MC_CMD_SET_ID_LED_IN_LEN 4 1474
1025#define MC_CMD_SET_ID_LED_IN_STATE_OFST 0 1475/* MC_CMD_SET_ID_LED_IN msgrequest */
1026#define MC_CMD_LED_OFF 0 1476#define MC_CMD_SET_ID_LED_IN_LEN 4
1027#define MC_CMD_LED_ON 1 1477#define MC_CMD_SET_ID_LED_IN_STATE_OFST 0
1028#define MC_CMD_LED_DEFAULT 2 1478#define MC_CMD_LED_OFF 0x0 /* enum */
1029#define MC_CMD_SET_ID_LED_OUT_LEN 0 1479#define MC_CMD_LED_ON 0x1 /* enum */
1030 1480#define MC_CMD_LED_DEFAULT 0x2 /* enum */
1031/* MC_CMD_SET_MAC: 1481
1032 * Set MAC configuration 1482/* MC_CMD_SET_ID_LED_OUT msgresponse */
1033 * 1483#define MC_CMD_SET_ID_LED_OUT_LEN 0
1034 * The MTU is the MTU programmed directly into the XMAC/GMAC 1484
1035 * (inclusive of EtherII, VLAN, bug16011 padding) 1485
1036 * 1486/***********************************/
1037 * Locks required: None 1487/* MC_CMD_SET_MAC
1038 * Return code: 0, EINVAL 1488 * Set MAC configuration.
1039 */ 1489 */
1040#define MC_CMD_SET_MAC 0x2c 1490#define MC_CMD_SET_MAC 0x2c
1041#define MC_CMD_SET_MAC_IN_LEN 24 1491
1042#define MC_CMD_SET_MAC_IN_MTU_OFST 0 1492/* MC_CMD_SET_MAC_IN msgrequest */
1043#define MC_CMD_SET_MAC_IN_DRAIN_OFST 4 1493#define MC_CMD_SET_MAC_IN_LEN 24
1044#define MC_CMD_SET_MAC_IN_ADDR_OFST 8 1494#define MC_CMD_SET_MAC_IN_MTU_OFST 0
1045#define MC_CMD_SET_MAC_IN_REJECT_OFST 16 1495#define MC_CMD_SET_MAC_IN_DRAIN_OFST 4
1046#define MC_CMD_SET_MAC_IN_REJECT_UNCST_LBN 0 1496#define MC_CMD_SET_MAC_IN_ADDR_OFST 8
1047#define MC_CMD_SET_MAC_IN_REJECT_UNCST_WIDTH 1 1497#define MC_CMD_SET_MAC_IN_ADDR_LEN 8
1048#define MC_CMD_SET_MAC_IN_REJECT_BRDCST_LBN 1 1498#define MC_CMD_SET_MAC_IN_ADDR_LO_OFST 8
1049#define MC_CMD_SET_MAC_IN_REJECT_BRDCST_WIDTH 1 1499#define MC_CMD_SET_MAC_IN_ADDR_HI_OFST 12
1050#define MC_CMD_SET_MAC_IN_FCNTL_OFST 20 1500#define MC_CMD_SET_MAC_IN_REJECT_OFST 16
1051#define MC_CMD_SET_MAC_OUT_LEN 0 1501#define MC_CMD_SET_MAC_IN_REJECT_UNCST_LBN 0
1052 1502#define MC_CMD_SET_MAC_IN_REJECT_UNCST_WIDTH 1
1053/* MC_CMD_PHY_STATS: 1503#define MC_CMD_SET_MAC_IN_REJECT_BRDCST_LBN 1
1054 * Get generic PHY statistics 1504#define MC_CMD_SET_MAC_IN_REJECT_BRDCST_WIDTH 1
1055 * 1505#define MC_CMD_SET_MAC_IN_FCNTL_OFST 20
1056 * This call returns the statistics for a generic PHY in a sparse 1506/* MC_CMD_FCNTL_OFF 0x0 */
1057 * array (indexed by the enumerate). Each value is represented by 1507/* MC_CMD_FCNTL_RESPOND 0x1 */
1058 * a 32bit number. 1508/* MC_CMD_FCNTL_BIDIR 0x2 */
1059 * 1509#define MC_CMD_FCNTL_AUTO 0x3 /* enum */
1060 * If the DMA_ADDR is 0, then no DMA is performed, and the statistics 1510
1061 * may be read directly out of shared memory. If DMA_ADDR != 0, then 1511/* MC_CMD_SET_MAC_OUT msgresponse */
1062 * the statistics are dmad to that (page-aligned location) 1512#define MC_CMD_SET_MAC_OUT_LEN 0
1063 * 1513
1064 * Locks required: None 1514
1065 * Returns: 0, ETIME 1515/***********************************/
1066 * Response methods: shared memory, event 1516/* MC_CMD_PHY_STATS
1517 * Get generic PHY statistics.
1067 */ 1518 */
1068#define MC_CMD_PHY_STATS 0x2d 1519#define MC_CMD_PHY_STATS 0x2d
1069#define MC_CMD_PHY_STATS_IN_LEN 8
1070#define MC_CMD_PHY_STATS_IN_DMA_ADDR_LO_OFST 0
1071#define MC_CMD_PHY_STATS_IN_DMA_ADDR_HI_OFST 4
1072#define MC_CMD_PHY_STATS_OUT_DMA_LEN 0
1073#define MC_CMD_PHY_STATS_OUT_NO_DMA_LEN (MC_CMD_PHY_NSTATS * 4)
1074
1075/* Unified MAC statistics enumeration */
1076#define MC_CMD_MAC_GENERATION_START 0
1077#define MC_CMD_MAC_TX_PKTS 1
1078#define MC_CMD_MAC_TX_PAUSE_PKTS 2
1079#define MC_CMD_MAC_TX_CONTROL_PKTS 3
1080#define MC_CMD_MAC_TX_UNICAST_PKTS 4
1081#define MC_CMD_MAC_TX_MULTICAST_PKTS 5
1082#define MC_CMD_MAC_TX_BROADCAST_PKTS 6
1083#define MC_CMD_MAC_TX_BYTES 7
1084#define MC_CMD_MAC_TX_BAD_BYTES 8
1085#define MC_CMD_MAC_TX_LT64_PKTS 9
1086#define MC_CMD_MAC_TX_64_PKTS 10
1087#define MC_CMD_MAC_TX_65_TO_127_PKTS 11
1088#define MC_CMD_MAC_TX_128_TO_255_PKTS 12
1089#define MC_CMD_MAC_TX_256_TO_511_PKTS 13
1090#define MC_CMD_MAC_TX_512_TO_1023_PKTS 14
1091#define MC_CMD_MAC_TX_1024_TO_15XX_PKTS 15
1092#define MC_CMD_MAC_TX_15XX_TO_JUMBO_PKTS 16
1093#define MC_CMD_MAC_TX_GTJUMBO_PKTS 17
1094#define MC_CMD_MAC_TX_BAD_FCS_PKTS 18
1095#define MC_CMD_MAC_TX_SINGLE_COLLISION_PKTS 19
1096#define MC_CMD_MAC_TX_MULTIPLE_COLLISION_PKTS 20
1097#define MC_CMD_MAC_TX_EXCESSIVE_COLLISION_PKTS 21
1098#define MC_CMD_MAC_TX_LATE_COLLISION_PKTS 22
1099#define MC_CMD_MAC_TX_DEFERRED_PKTS 23
1100#define MC_CMD_MAC_TX_EXCESSIVE_DEFERRED_PKTS 24
1101#define MC_CMD_MAC_TX_NON_TCPUDP_PKTS 25
1102#define MC_CMD_MAC_TX_MAC_SRC_ERR_PKTS 26
1103#define MC_CMD_MAC_TX_IP_SRC_ERR_PKTS 27
1104#define MC_CMD_MAC_RX_PKTS 28
1105#define MC_CMD_MAC_RX_PAUSE_PKTS 29
1106#define MC_CMD_MAC_RX_GOOD_PKTS 30
1107#define MC_CMD_MAC_RX_CONTROL_PKTS 31
1108#define MC_CMD_MAC_RX_UNICAST_PKTS 32
1109#define MC_CMD_MAC_RX_MULTICAST_PKTS 33
1110#define MC_CMD_MAC_RX_BROADCAST_PKTS 34
1111#define MC_CMD_MAC_RX_BYTES 35
1112#define MC_CMD_MAC_RX_BAD_BYTES 36
1113#define MC_CMD_MAC_RX_64_PKTS 37
1114#define MC_CMD_MAC_RX_65_TO_127_PKTS 38
1115#define MC_CMD_MAC_RX_128_TO_255_PKTS 39
1116#define MC_CMD_MAC_RX_256_TO_511_PKTS 40
1117#define MC_CMD_MAC_RX_512_TO_1023_PKTS 41
1118#define MC_CMD_MAC_RX_1024_TO_15XX_PKTS 42
1119#define MC_CMD_MAC_RX_15XX_TO_JUMBO_PKTS 43
1120#define MC_CMD_MAC_RX_GTJUMBO_PKTS 44
1121#define MC_CMD_MAC_RX_UNDERSIZE_PKTS 45
1122#define MC_CMD_MAC_RX_BAD_FCS_PKTS 46
1123#define MC_CMD_MAC_RX_OVERFLOW_PKTS 47
1124#define MC_CMD_MAC_RX_FALSE_CARRIER_PKTS 48
1125#define MC_CMD_MAC_RX_SYMBOL_ERROR_PKTS 49
1126#define MC_CMD_MAC_RX_ALIGN_ERROR_PKTS 50
1127#define MC_CMD_MAC_RX_LENGTH_ERROR_PKTS 51
1128#define MC_CMD_MAC_RX_INTERNAL_ERROR_PKTS 52
1129#define MC_CMD_MAC_RX_JABBER_PKTS 53
1130#define MC_CMD_MAC_RX_NODESC_DROPS 54
1131#define MC_CMD_MAC_RX_LANES01_CHAR_ERR 55
1132#define MC_CMD_MAC_RX_LANES23_CHAR_ERR 56
1133#define MC_CMD_MAC_RX_LANES01_DISP_ERR 57
1134#define MC_CMD_MAC_RX_LANES23_DISP_ERR 58
1135#define MC_CMD_MAC_RX_MATCH_FAULT 59
1136#define MC_CMD_GMAC_DMABUF_START 64
1137#define MC_CMD_GMAC_DMABUF_END 95
1138/* Insert new members here. */
1139#define MC_CMD_MAC_GENERATION_END 96
1140#define MC_CMD_MAC_NSTATS (MC_CMD_MAC_GENERATION_END+1)
1141
1142/* MC_CMD_MAC_STATS:
1143 * Get unified GMAC/XMAC statistics
1144 *
1145 * This call returns unified statistics maintained by the MC as it
1146 * switches between the GMAC and XMAC. The MC will write out all
1147 * supported stats. The driver should zero initialise the buffer to
1148 * guarantee consistent results.
1149 *
1150 * Locks required: None
1151 * Returns: 0
1152 * Response methods: shared memory, event
1153 */
1154#define MC_CMD_MAC_STATS 0x2e
1155#define MC_CMD_MAC_STATS_IN_LEN 16
1156#define MC_CMD_MAC_STATS_IN_DMA_ADDR_LO_OFST 0
1157#define MC_CMD_MAC_STATS_IN_DMA_ADDR_HI_OFST 4
1158#define MC_CMD_MAC_STATS_IN_CMD_OFST 8
1159#define MC_CMD_MAC_STATS_CMD_DMA_LBN 0
1160#define MC_CMD_MAC_STATS_CMD_DMA_WIDTH 1
1161#define MC_CMD_MAC_STATS_CMD_CLEAR_LBN 1
1162#define MC_CMD_MAC_STATS_CMD_CLEAR_WIDTH 1
1163#define MC_CMD_MAC_STATS_CMD_PERIODIC_CHANGE_LBN 2
1164#define MC_CMD_MAC_STATS_CMD_PERIODIC_CHANGE_WIDTH 1
1165/* Remaining PERIOD* fields only relevant when PERIODIC_CHANGE is set */
1166#define MC_CMD_MAC_STATS_CMD_PERIODIC_ENABLE_LBN 3
1167#define MC_CMD_MAC_STATS_CMD_PERIODIC_ENABLE_WIDTH 1
1168#define MC_CMD_MAC_STATS_CMD_PERIODIC_CLEAR_LBN 4
1169#define MC_CMD_MAC_STATS_CMD_PERIODIC_CLEAR_WIDTH 1
1170#define MC_CMD_MAC_STATS_CMD_PERIODIC_NOEVENT_LBN 5
1171#define MC_CMD_MAC_STATS_CMD_PERIODIC_NOEVENT_WIDTH 1
1172#define MC_CMD_MAC_STATS_CMD_PERIOD_MS_LBN 16
1173#define MC_CMD_MAC_STATS_CMD_PERIOD_MS_WIDTH 16
1174#define MC_CMD_MAC_STATS_IN_DMA_LEN_OFST 12
1175
1176#define MC_CMD_MAC_STATS_OUT_LEN 0
1177
1178/* Callisto flags */
1179#define MC_CMD_SFT9001_ROBUST_LBN 0
1180#define MC_CMD_SFT9001_ROBUST_WIDTH 1
1181#define MC_CMD_SFT9001_SHORT_REACH_LBN 1
1182#define MC_CMD_SFT9001_SHORT_REACH_WIDTH 1
1183
1184/* MC_CMD_SFT9001_GET:
1185 * Read current callisto specific setting
1186 *
1187 * Locks required: None
1188 * Returns: 0, ETIME
1189 */
1190#define MC_CMD_SFT9001_GET 0x30
1191#define MC_CMD_SFT9001_GET_IN_LEN 0
1192#define MC_CMD_SFT9001_GET_OUT_LEN 4
1193#define MC_CMD_SFT9001_GET_OUT_FLAGS_OFST 0
1194 1520
1195/* MC_CMD_SFT9001_SET: 1521/* MC_CMD_PHY_STATS_IN msgrequest */
1196 * Write current callisto specific setting 1522#define MC_CMD_PHY_STATS_IN_LEN 8
1197 * 1523#define MC_CMD_PHY_STATS_IN_DMA_ADDR_OFST 0
1198 * Locks required: None 1524#define MC_CMD_PHY_STATS_IN_DMA_ADDR_LEN 8
1199 * Returns: 0, ETIME, EINVAL 1525#define MC_CMD_PHY_STATS_IN_DMA_ADDR_LO_OFST 0
1526#define MC_CMD_PHY_STATS_IN_DMA_ADDR_HI_OFST 4
1527
1528/* MC_CMD_PHY_STATS_OUT_DMA msgresponse */
1529#define MC_CMD_PHY_STATS_OUT_DMA_LEN 0
1530
1531/* MC_CMD_PHY_STATS_OUT_NO_DMA msgresponse */
1532#define MC_CMD_PHY_STATS_OUT_NO_DMA_LEN (((MC_CMD_PHY_NSTATS*32))>>3)
1533#define MC_CMD_PHY_STATS_OUT_NO_DMA_STATISTICS_OFST 0
1534#define MC_CMD_PHY_STATS_OUT_NO_DMA_STATISTICS_LEN 4
1535#define MC_CMD_PHY_STATS_OUT_NO_DMA_STATISTICS_NUM MC_CMD_PHY_NSTATS
1536#define MC_CMD_OUI 0x0 /* enum */
1537#define MC_CMD_PMA_PMD_LINK_UP 0x1 /* enum */
1538#define MC_CMD_PMA_PMD_RX_FAULT 0x2 /* enum */
1539#define MC_CMD_PMA_PMD_TX_FAULT 0x3 /* enum */
1540#define MC_CMD_PMA_PMD_SIGNAL 0x4 /* enum */
1541#define MC_CMD_PMA_PMD_SNR_A 0x5 /* enum */
1542#define MC_CMD_PMA_PMD_SNR_B 0x6 /* enum */
1543#define MC_CMD_PMA_PMD_SNR_C 0x7 /* enum */
1544#define MC_CMD_PMA_PMD_SNR_D 0x8 /* enum */
1545#define MC_CMD_PCS_LINK_UP 0x9 /* enum */
1546#define MC_CMD_PCS_RX_FAULT 0xa /* enum */
1547#define MC_CMD_PCS_TX_FAULT 0xb /* enum */
1548#define MC_CMD_PCS_BER 0xc /* enum */
1549#define MC_CMD_PCS_BLOCK_ERRORS 0xd /* enum */
1550#define MC_CMD_PHYXS_LINK_UP 0xe /* enum */
1551#define MC_CMD_PHYXS_RX_FAULT 0xf /* enum */
1552#define MC_CMD_PHYXS_TX_FAULT 0x10 /* enum */
1553#define MC_CMD_PHYXS_ALIGN 0x11 /* enum */
1554#define MC_CMD_PHYXS_SYNC 0x12 /* enum */
1555#define MC_CMD_AN_LINK_UP 0x13 /* enum */
1556#define MC_CMD_AN_COMPLETE 0x14 /* enum */
1557#define MC_CMD_AN_10GBT_STATUS 0x15 /* enum */
1558#define MC_CMD_CL22_LINK_UP 0x16 /* enum */
1559#define MC_CMD_PHY_NSTATS 0x17 /* enum */
1560
1561
1562/***********************************/
1563/* MC_CMD_MAC_STATS
1564 * Get generic MAC statistics.
1200 */ 1565 */
1201#define MC_CMD_SFT9001_SET 0x31 1566#define MC_CMD_MAC_STATS 0x2e
1202#define MC_CMD_SFT9001_SET_IN_LEN 4
1203#define MC_CMD_SFT9001_SET_IN_FLAGS_OFST 0
1204#define MC_CMD_SFT9001_SET_OUT_LEN 0
1205
1206 1567
1207/* MC_CMD_WOL_FILTER_SET: 1568/* MC_CMD_MAC_STATS_IN msgrequest */
1208 * Set a WoL filter 1569#define MC_CMD_MAC_STATS_IN_LEN 16
1209 * 1570#define MC_CMD_MAC_STATS_IN_DMA_ADDR_OFST 0
1210 * Locks required: None 1571#define MC_CMD_MAC_STATS_IN_DMA_ADDR_LEN 8
1211 * Returns: 0, EBUSY, EINVAL, ENOSYS 1572#define MC_CMD_MAC_STATS_IN_DMA_ADDR_LO_OFST 0
1573#define MC_CMD_MAC_STATS_IN_DMA_ADDR_HI_OFST 4
1574#define MC_CMD_MAC_STATS_IN_CMD_OFST 8
1575#define MC_CMD_MAC_STATS_IN_DMA_LBN 0
1576#define MC_CMD_MAC_STATS_IN_DMA_WIDTH 1
1577#define MC_CMD_MAC_STATS_IN_CLEAR_LBN 1
1578#define MC_CMD_MAC_STATS_IN_CLEAR_WIDTH 1
1579#define MC_CMD_MAC_STATS_IN_PERIODIC_CHANGE_LBN 2
1580#define MC_CMD_MAC_STATS_IN_PERIODIC_CHANGE_WIDTH 1
1581#define MC_CMD_MAC_STATS_IN_PERIODIC_ENABLE_LBN 3
1582#define MC_CMD_MAC_STATS_IN_PERIODIC_ENABLE_WIDTH 1
1583#define MC_CMD_MAC_STATS_IN_PERIODIC_CLEAR_LBN 4
1584#define MC_CMD_MAC_STATS_IN_PERIODIC_CLEAR_WIDTH 1
1585#define MC_CMD_MAC_STATS_IN_PERIODIC_NOEVENT_LBN 5
1586#define MC_CMD_MAC_STATS_IN_PERIODIC_NOEVENT_WIDTH 1
1587#define MC_CMD_MAC_STATS_IN_PERIOD_MS_LBN 16
1588#define MC_CMD_MAC_STATS_IN_PERIOD_MS_WIDTH 16
1589#define MC_CMD_MAC_STATS_IN_DMA_LEN_OFST 12
1590
1591/* MC_CMD_MAC_STATS_OUT_DMA msgresponse */
1592#define MC_CMD_MAC_STATS_OUT_DMA_LEN 0
1593
1594/* MC_CMD_MAC_STATS_OUT_NO_DMA msgresponse */
1595#define MC_CMD_MAC_STATS_OUT_NO_DMA_LEN (((MC_CMD_MAC_NSTATS*64))>>3)
1596#define MC_CMD_MAC_STATS_OUT_NO_DMA_STATISTICS_OFST 0
1597#define MC_CMD_MAC_STATS_OUT_NO_DMA_STATISTICS_LEN 8
1598#define MC_CMD_MAC_STATS_OUT_NO_DMA_STATISTICS_LO_OFST 0
1599#define MC_CMD_MAC_STATS_OUT_NO_DMA_STATISTICS_HI_OFST 4
1600#define MC_CMD_MAC_STATS_OUT_NO_DMA_STATISTICS_NUM MC_CMD_MAC_NSTATS
1601#define MC_CMD_MAC_GENERATION_START 0x0 /* enum */
1602#define MC_CMD_MAC_TX_PKTS 0x1 /* enum */
1603#define MC_CMD_MAC_TX_PAUSE_PKTS 0x2 /* enum */
1604#define MC_CMD_MAC_TX_CONTROL_PKTS 0x3 /* enum */
1605#define MC_CMD_MAC_TX_UNICAST_PKTS 0x4 /* enum */
1606#define MC_CMD_MAC_TX_MULTICAST_PKTS 0x5 /* enum */
1607#define MC_CMD_MAC_TX_BROADCAST_PKTS 0x6 /* enum */
1608#define MC_CMD_MAC_TX_BYTES 0x7 /* enum */
1609#define MC_CMD_MAC_TX_BAD_BYTES 0x8 /* enum */
1610#define MC_CMD_MAC_TX_LT64_PKTS 0x9 /* enum */
1611#define MC_CMD_MAC_TX_64_PKTS 0xa /* enum */
1612#define MC_CMD_MAC_TX_65_TO_127_PKTS 0xb /* enum */
1613#define MC_CMD_MAC_TX_128_TO_255_PKTS 0xc /* enum */
1614#define MC_CMD_MAC_TX_256_TO_511_PKTS 0xd /* enum */
1615#define MC_CMD_MAC_TX_512_TO_1023_PKTS 0xe /* enum */
1616#define MC_CMD_MAC_TX_1024_TO_15XX_PKTS 0xf /* enum */
1617#define MC_CMD_MAC_TX_15XX_TO_JUMBO_PKTS 0x10 /* enum */
1618#define MC_CMD_MAC_TX_GTJUMBO_PKTS 0x11 /* enum */
1619#define MC_CMD_MAC_TX_BAD_FCS_PKTS 0x12 /* enum */
1620#define MC_CMD_MAC_TX_SINGLE_COLLISION_PKTS 0x13 /* enum */
1621#define MC_CMD_MAC_TX_MULTIPLE_COLLISION_PKTS 0x14 /* enum */
1622#define MC_CMD_MAC_TX_EXCESSIVE_COLLISION_PKTS 0x15 /* enum */
1623#define MC_CMD_MAC_TX_LATE_COLLISION_PKTS 0x16 /* enum */
1624#define MC_CMD_MAC_TX_DEFERRED_PKTS 0x17 /* enum */
1625#define MC_CMD_MAC_TX_EXCESSIVE_DEFERRED_PKTS 0x18 /* enum */
1626#define MC_CMD_MAC_TX_NON_TCPUDP_PKTS 0x19 /* enum */
1627#define MC_CMD_MAC_TX_MAC_SRC_ERR_PKTS 0x1a /* enum */
1628#define MC_CMD_MAC_TX_IP_SRC_ERR_PKTS 0x1b /* enum */
1629#define MC_CMD_MAC_RX_PKTS 0x1c /* enum */
1630#define MC_CMD_MAC_RX_PAUSE_PKTS 0x1d /* enum */
1631#define MC_CMD_MAC_RX_GOOD_PKTS 0x1e /* enum */
1632#define MC_CMD_MAC_RX_CONTROL_PKTS 0x1f /* enum */
1633#define MC_CMD_MAC_RX_UNICAST_PKTS 0x20 /* enum */
1634#define MC_CMD_MAC_RX_MULTICAST_PKTS 0x21 /* enum */
1635#define MC_CMD_MAC_RX_BROADCAST_PKTS 0x22 /* enum */
1636#define MC_CMD_MAC_RX_BYTES 0x23 /* enum */
1637#define MC_CMD_MAC_RX_BAD_BYTES 0x24 /* enum */
1638#define MC_CMD_MAC_RX_64_PKTS 0x25 /* enum */
1639#define MC_CMD_MAC_RX_65_TO_127_PKTS 0x26 /* enum */
1640#define MC_CMD_MAC_RX_128_TO_255_PKTS 0x27 /* enum */
1641#define MC_CMD_MAC_RX_256_TO_511_PKTS 0x28 /* enum */
1642#define MC_CMD_MAC_RX_512_TO_1023_PKTS 0x29 /* enum */
1643#define MC_CMD_MAC_RX_1024_TO_15XX_PKTS 0x2a /* enum */
1644#define MC_CMD_MAC_RX_15XX_TO_JUMBO_PKTS 0x2b /* enum */
1645#define MC_CMD_MAC_RX_GTJUMBO_PKTS 0x2c /* enum */
1646#define MC_CMD_MAC_RX_UNDERSIZE_PKTS 0x2d /* enum */
1647#define MC_CMD_MAC_RX_BAD_FCS_PKTS 0x2e /* enum */
1648#define MC_CMD_MAC_RX_OVERFLOW_PKTS 0x2f /* enum */
1649#define MC_CMD_MAC_RX_FALSE_CARRIER_PKTS 0x30 /* enum */
1650#define MC_CMD_MAC_RX_SYMBOL_ERROR_PKTS 0x31 /* enum */
1651#define MC_CMD_MAC_RX_ALIGN_ERROR_PKTS 0x32 /* enum */
1652#define MC_CMD_MAC_RX_LENGTH_ERROR_PKTS 0x33 /* enum */
1653#define MC_CMD_MAC_RX_INTERNAL_ERROR_PKTS 0x34 /* enum */
1654#define MC_CMD_MAC_RX_JABBER_PKTS 0x35 /* enum */
1655#define MC_CMD_MAC_RX_NODESC_DROPS 0x36 /* enum */
1656#define MC_CMD_MAC_RX_LANES01_CHAR_ERR 0x37 /* enum */
1657#define MC_CMD_MAC_RX_LANES23_CHAR_ERR 0x38 /* enum */
1658#define MC_CMD_MAC_RX_LANES01_DISP_ERR 0x39 /* enum */
1659#define MC_CMD_MAC_RX_LANES23_DISP_ERR 0x3a /* enum */
1660#define MC_CMD_MAC_RX_MATCH_FAULT 0x3b /* enum */
1661#define MC_CMD_GMAC_DMABUF_START 0x40 /* enum */
1662#define MC_CMD_GMAC_DMABUF_END 0x5f /* enum */
1663#define MC_CMD_MAC_GENERATION_END 0x60 /* enum */
1664#define MC_CMD_MAC_NSTATS 0x61 /* enum */
1665
1666
1667/***********************************/
1668/* MC_CMD_SRIOV
1669 * to be documented
1670 */
1671#define MC_CMD_SRIOV 0x30
1672
1673/* MC_CMD_SRIOV_IN msgrequest */
1674#define MC_CMD_SRIOV_IN_LEN 12
1675#define MC_CMD_SRIOV_IN_ENABLE_OFST 0
1676#define MC_CMD_SRIOV_IN_VI_BASE_OFST 4
1677#define MC_CMD_SRIOV_IN_VF_COUNT_OFST 8
1678
1679/* MC_CMD_SRIOV_OUT msgresponse */
1680#define MC_CMD_SRIOV_OUT_LEN 8
1681#define MC_CMD_SRIOV_OUT_VI_SCALE_OFST 0
1682#define MC_CMD_SRIOV_OUT_VF_TOTAL_OFST 4
1683
1684/* MC_CMD_MEMCPY_RECORD_TYPEDEF structuredef */
1685#define MC_CMD_MEMCPY_RECORD_TYPEDEF_LEN 32
1686#define MC_CMD_MEMCPY_RECORD_TYPEDEF_NUM_RECORDS_OFST 0
1687#define MC_CMD_MEMCPY_RECORD_TYPEDEF_NUM_RECORDS_LBN 0
1688#define MC_CMD_MEMCPY_RECORD_TYPEDEF_NUM_RECORDS_WIDTH 32
1689#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_RID_OFST 4
1690#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_RID_LBN 32
1691#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_RID_WIDTH 32
1692#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_ADDR_OFST 8
1693#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_ADDR_LEN 8
1694#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_ADDR_LO_OFST 8
1695#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_ADDR_HI_OFST 12
1696#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_ADDR_LBN 64
1697#define MC_CMD_MEMCPY_RECORD_TYPEDEF_TO_ADDR_WIDTH 64
1698#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_RID_OFST 16
1699#define MC_CMD_MEMCPY_RECORD_TYPEDEF_RID_INLINE 0x100 /* enum */
1700#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_RID_LBN 128
1701#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_RID_WIDTH 32
1702#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_ADDR_OFST 20
1703#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_ADDR_LEN 8
1704#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_ADDR_LO_OFST 20
1705#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_ADDR_HI_OFST 24
1706#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_ADDR_LBN 160
1707#define MC_CMD_MEMCPY_RECORD_TYPEDEF_FROM_ADDR_WIDTH 64
1708#define MC_CMD_MEMCPY_RECORD_TYPEDEF_LENGTH_OFST 28
1709#define MC_CMD_MEMCPY_RECORD_TYPEDEF_LENGTH_LBN 224
1710#define MC_CMD_MEMCPY_RECORD_TYPEDEF_LENGTH_WIDTH 32
1711
1712
1713/***********************************/
1714/* MC_CMD_MEMCPY
1715 * Perform memory copy operation.
1716 */
1717#define MC_CMD_MEMCPY 0x31
1718
1719/* MC_CMD_MEMCPY_IN msgrequest */
1720#define MC_CMD_MEMCPY_IN_LENMIN 32
1721#define MC_CMD_MEMCPY_IN_LENMAX 224
1722#define MC_CMD_MEMCPY_IN_LEN(num) (0+32*(num))
1723#define MC_CMD_MEMCPY_IN_RECORD_OFST 0
1724#define MC_CMD_MEMCPY_IN_RECORD_LEN 32
1725#define MC_CMD_MEMCPY_IN_RECORD_MINNUM 1
1726#define MC_CMD_MEMCPY_IN_RECORD_MAXNUM 7
1727
1728/* MC_CMD_MEMCPY_OUT msgresponse */
1729#define MC_CMD_MEMCPY_OUT_LEN 0
1730
1731
1732/***********************************/
1733/* MC_CMD_WOL_FILTER_SET
1734 * Set a WoL filter.
1212 */ 1735 */
1213#define MC_CMD_WOL_FILTER_SET 0x32 1736#define MC_CMD_WOL_FILTER_SET 0x32
1214#define MC_CMD_WOL_FILTER_SET_IN_LEN 192 /* 190 rounded up to a word */ 1737
1215#define MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0 1738/* MC_CMD_WOL_FILTER_SET_IN msgrequest */
1216#define MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4 1739#define MC_CMD_WOL_FILTER_SET_IN_LEN 192
1217 1740#define MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0
1218/* There is a union at offset 8, following defines overlap due to 1741#define MC_CMD_FILTER_MODE_SIMPLE 0x0 /* enum */
1219 * this */ 1742#define MC_CMD_FILTER_MODE_STRUCTURED 0xffffffff /* enum */
1220#define MC_CMD_WOL_FILTER_SET_IN_DATA_OFST 8 1743#define MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4
1221 1744#define MC_CMD_WOL_TYPE_MAGIC 0x0 /* enum */
1222#define MC_CMD_WOL_FILTER_SET_IN_MAGIC_MAC_OFST \ 1745#define MC_CMD_WOL_TYPE_WIN_MAGIC 0x2 /* enum */
1223 MC_CMD_WOL_FILTER_SET_IN_DATA_OFST 1746#define MC_CMD_WOL_TYPE_IPV4_SYN 0x3 /* enum */
1224 1747#define MC_CMD_WOL_TYPE_IPV6_SYN 0x4 /* enum */
1225#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_SRC_IP_OFST \ 1748#define MC_CMD_WOL_TYPE_BITMAP 0x5 /* enum */
1226 MC_CMD_WOL_FILTER_SET_IN_DATA_OFST 1749#define MC_CMD_WOL_TYPE_LINK 0x6 /* enum */
1227#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_DST_IP_OFST \ 1750#define MC_CMD_WOL_TYPE_MAX 0x7 /* enum */
1228 (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 4) 1751#define MC_CMD_WOL_FILTER_SET_IN_DATA_OFST 8
1229#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_SRC_PORT_OFST \ 1752#define MC_CMD_WOL_FILTER_SET_IN_DATA_LEN 4
1230 (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 8) 1753#define MC_CMD_WOL_FILTER_SET_IN_DATA_NUM 46
1231#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_DST_PORT_OFST \ 1754
1232 (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 10) 1755/* MC_CMD_WOL_FILTER_SET_IN_MAGIC msgrequest */
1233 1756#define MC_CMD_WOL_FILTER_SET_IN_MAGIC_LEN 16
1234#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_SRC_IP_OFST \ 1757/* MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0 */
1235 MC_CMD_WOL_FILTER_SET_IN_DATA_OFST 1758/* MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4 */
1236#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_DST_IP_OFST \ 1759#define MC_CMD_WOL_FILTER_SET_IN_MAGIC_MAC_OFST 8
1237 (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 16) 1760#define MC_CMD_WOL_FILTER_SET_IN_MAGIC_MAC_LEN 8
1238#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_SRC_PORT_OFST \ 1761#define MC_CMD_WOL_FILTER_SET_IN_MAGIC_MAC_LO_OFST 8
1239 (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 32) 1762#define MC_CMD_WOL_FILTER_SET_IN_MAGIC_MAC_HI_OFST 12
1240#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_DST_PORT_OFST \ 1763
1241 (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 34) 1764/* MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN msgrequest */
1242 1765#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_LEN 20
1243#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_MASK_OFST \ 1766/* MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0 */
1244 MC_CMD_WOL_FILTER_SET_IN_DATA_OFST 1767/* MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4 */
1245#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_OFST \ 1768#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_SRC_IP_OFST 8
1246 (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 48) 1769#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_DST_IP_OFST 12
1247#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LEN_OFST \ 1770#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_SRC_PORT_OFST 16
1248 (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 176) 1771#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_SRC_PORT_LEN 2
1249#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER3_OFST \ 1772#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_DST_PORT_OFST 18
1250 (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 177) 1773#define MC_CMD_WOL_FILTER_SET_IN_IPV4_SYN_DST_PORT_LEN 2
1251#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER4_OFST \ 1774
1252 (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 178) 1775/* MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN msgrequest */
1253 1776#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_LEN 44
1254#define MC_CMD_WOL_FILTER_SET_IN_LINK_MASK_OFST \ 1777/* MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0 */
1255 MC_CMD_WOL_FILTER_SET_IN_DATA_OFST 1778/* MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4 */
1256#define MC_CMD_WOL_FILTER_SET_IN_LINK_UP_LBN 0 1779#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_SRC_IP_OFST 8
1257#define MC_CMD_WOL_FILTER_SET_IN_LINK_UP_WIDTH 1 1780#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_SRC_IP_LEN 16
1258#define MC_CMD_WOL_FILTER_SET_IN_LINK_DOWN_LBN 1 1781#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_DST_IP_OFST 24
1259#define MC_CMD_WOL_FILTER_SET_IN_LINK_DOWN_WIDTH 1 1782#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_DST_IP_LEN 16
1260 1783#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_SRC_PORT_OFST 40
1261#define MC_CMD_WOL_FILTER_SET_OUT_LEN 4 1784#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_SRC_PORT_LEN 2
1262#define MC_CMD_WOL_FILTER_SET_OUT_FILTER_ID_OFST 0 1785#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_DST_PORT_OFST 42
1263 1786#define MC_CMD_WOL_FILTER_SET_IN_IPV6_SYN_DST_PORT_LEN 2
1264/* WOL Filter types enumeration */ 1787
1265#define MC_CMD_WOL_TYPE_MAGIC 0x0 1788/* MC_CMD_WOL_FILTER_SET_IN_BITMAP msgrequest */
1266 /* unused 0x1 */ 1789#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LEN 187
1267#define MC_CMD_WOL_TYPE_WIN_MAGIC 0x2 1790/* MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0 */
1268#define MC_CMD_WOL_TYPE_IPV4_SYN 0x3 1791/* MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4 */
1269#define MC_CMD_WOL_TYPE_IPV6_SYN 0x4 1792#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_MASK_OFST 8
1270#define MC_CMD_WOL_TYPE_BITMAP 0x5 1793#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_MASK_LEN 48
1271#define MC_CMD_WOL_TYPE_LINK 0x6 1794#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_BITMAP_OFST 56
1272#define MC_CMD_WOL_TYPE_MAX 0x7 1795#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_BITMAP_LEN 128
1273 1796#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LEN_OFST 184
1274#define MC_CMD_FILTER_MODE_SIMPLE 0x0 1797#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LEN_LEN 1
1275#define MC_CMD_FILTER_MODE_STRUCTURED 0xffffffff 1798#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER3_OFST 185
1276 1799#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER3_LEN 1
1277/* MC_CMD_WOL_FILTER_REMOVE: 1800#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER4_OFST 186
1278 * Remove a WoL filter 1801#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER4_LEN 1
1279 * 1802
1280 * Locks required: None 1803/* MC_CMD_WOL_FILTER_SET_IN_LINK msgrequest */
1281 * Returns: 0, EINVAL, ENOSYS 1804#define MC_CMD_WOL_FILTER_SET_IN_LINK_LEN 12
1805/* MC_CMD_WOL_FILTER_SET_IN_FILTER_MODE_OFST 0 */
1806/* MC_CMD_WOL_FILTER_SET_IN_WOL_TYPE_OFST 4 */
1807#define MC_CMD_WOL_FILTER_SET_IN_LINK_MASK_OFST 8
1808#define MC_CMD_WOL_FILTER_SET_IN_LINK_UP_LBN 0
1809#define MC_CMD_WOL_FILTER_SET_IN_LINK_UP_WIDTH 1
1810#define MC_CMD_WOL_FILTER_SET_IN_LINK_DOWN_LBN 1
1811#define MC_CMD_WOL_FILTER_SET_IN_LINK_DOWN_WIDTH 1
1812
1813/* MC_CMD_WOL_FILTER_SET_OUT msgresponse */
1814#define MC_CMD_WOL_FILTER_SET_OUT_LEN 4
1815#define MC_CMD_WOL_FILTER_SET_OUT_FILTER_ID_OFST 0
1816
1817
1818/***********************************/
1819/* MC_CMD_WOL_FILTER_REMOVE
1820 * Remove a WoL filter.
1282 */ 1821 */
1283#define MC_CMD_WOL_FILTER_REMOVE 0x33 1822#define MC_CMD_WOL_FILTER_REMOVE 0x33
1284#define MC_CMD_WOL_FILTER_REMOVE_IN_LEN 4
1285#define MC_CMD_WOL_FILTER_REMOVE_IN_FILTER_ID_OFST 0
1286#define MC_CMD_WOL_FILTER_REMOVE_OUT_LEN 0
1287 1823
1824/* MC_CMD_WOL_FILTER_REMOVE_IN msgrequest */
1825#define MC_CMD_WOL_FILTER_REMOVE_IN_LEN 4
1826#define MC_CMD_WOL_FILTER_REMOVE_IN_FILTER_ID_OFST 0
1288 1827
1289/* MC_CMD_WOL_FILTER_RESET: 1828/* MC_CMD_WOL_FILTER_REMOVE_OUT msgresponse */
1290 * Reset (i.e. remove all) WoL filters 1829#define MC_CMD_WOL_FILTER_REMOVE_OUT_LEN 0
1291 * 1830
1292 * Locks required: None 1831
1293 * Returns: 0, ENOSYS 1832/***********************************/
1833/* MC_CMD_WOL_FILTER_RESET
1834 * Reset (i.e. remove all) WoL filters.
1294 */ 1835 */
1295#define MC_CMD_WOL_FILTER_RESET 0x34 1836#define MC_CMD_WOL_FILTER_RESET 0x34
1296#define MC_CMD_WOL_FILTER_RESET_IN_LEN 0
1297#define MC_CMD_WOL_FILTER_RESET_OUT_LEN 0
1298 1837
1299/* MC_CMD_SET_MCAST_HASH: 1838/* MC_CMD_WOL_FILTER_RESET_IN msgrequest */
1300 * Set the MCASH hash value without otherwise 1839#define MC_CMD_WOL_FILTER_RESET_IN_LEN 4
1301 * reconfiguring the MAC 1840#define MC_CMD_WOL_FILTER_RESET_IN_MASK_OFST 0
1841#define MC_CMD_WOL_FILTER_RESET_IN_WAKE_FILTERS 0x1 /* enum */
1842#define MC_CMD_WOL_FILTER_RESET_IN_LIGHTSOUT_OFFLOADS 0x2 /* enum */
1843
1844/* MC_CMD_WOL_FILTER_RESET_OUT msgresponse */
1845#define MC_CMD_WOL_FILTER_RESET_OUT_LEN 0
1846
1847
1848/***********************************/
1849/* MC_CMD_SET_MCAST_HASH
1850 * Set the MCASH hash value.
1302 */ 1851 */
1303#define MC_CMD_SET_MCAST_HASH 0x35 1852#define MC_CMD_SET_MCAST_HASH 0x35
1304#define MC_CMD_SET_MCAST_HASH_IN_LEN 32
1305#define MC_CMD_SET_MCAST_HASH_IN_HASH0_OFST 0
1306#define MC_CMD_SET_MCAST_HASH_IN_HASH1_OFST 16
1307#define MC_CMD_SET_MCAST_HASH_OUT_LEN 0
1308 1853
1309/* MC_CMD_NVRAM_TYPES: 1854/* MC_CMD_SET_MCAST_HASH_IN msgrequest */
1310 * Return bitfield indicating available types of virtual NVRAM partitions 1855#define MC_CMD_SET_MCAST_HASH_IN_LEN 32
1311 * 1856#define MC_CMD_SET_MCAST_HASH_IN_HASH0_OFST 0
1312 * Locks required: none 1857#define MC_CMD_SET_MCAST_HASH_IN_HASH0_LEN 16
1313 * Returns: 0 1858#define MC_CMD_SET_MCAST_HASH_IN_HASH1_OFST 16
1859#define MC_CMD_SET_MCAST_HASH_IN_HASH1_LEN 16
1860
1861/* MC_CMD_SET_MCAST_HASH_OUT msgresponse */
1862#define MC_CMD_SET_MCAST_HASH_OUT_LEN 0
1863
1864
1865/***********************************/
1866/* MC_CMD_NVRAM_TYPES
1867 * Get virtual NVRAM partitions information.
1314 */ 1868 */
1315#define MC_CMD_NVRAM_TYPES 0x36 1869#define MC_CMD_NVRAM_TYPES 0x36
1316#define MC_CMD_NVRAM_TYPES_IN_LEN 0 1870
1317#define MC_CMD_NVRAM_TYPES_OUT_LEN 4 1871/* MC_CMD_NVRAM_TYPES_IN msgrequest */
1318#define MC_CMD_NVRAM_TYPES_OUT_TYPES_OFST 0 1872#define MC_CMD_NVRAM_TYPES_IN_LEN 0
1319 1873
1320/* Supported NVRAM types */ 1874/* MC_CMD_NVRAM_TYPES_OUT msgresponse */
1321#define MC_CMD_NVRAM_TYPE_DISABLED_CALLISTO 0 1875#define MC_CMD_NVRAM_TYPES_OUT_LEN 4
1322#define MC_CMD_NVRAM_TYPE_MC_FW 1 1876#define MC_CMD_NVRAM_TYPES_OUT_TYPES_OFST 0
1323#define MC_CMD_NVRAM_TYPE_MC_FW_BACKUP 2 1877#define MC_CMD_NVRAM_TYPE_DISABLED_CALLISTO 0x0 /* enum */
1324#define MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT0 3 1878#define MC_CMD_NVRAM_TYPE_MC_FW 0x1 /* enum */
1325#define MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT1 4 1879#define MC_CMD_NVRAM_TYPE_MC_FW_BACKUP 0x2 /* enum */
1326#define MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT0 5 1880#define MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT0 0x3 /* enum */
1327#define MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT1 6 1881#define MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT1 0x4 /* enum */
1328#define MC_CMD_NVRAM_TYPE_EXP_ROM 7 1882#define MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT0 0x5 /* enum */
1329#define MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT0 8 1883#define MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT1 0x6 /* enum */
1330#define MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT1 9 1884#define MC_CMD_NVRAM_TYPE_EXP_ROM 0x7 /* enum */
1331#define MC_CMD_NVRAM_TYPE_PHY_PORT0 10 1885#define MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT0 0x8 /* enum */
1332#define MC_CMD_NVRAM_TYPE_PHY_PORT1 11 1886#define MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT1 0x9 /* enum */
1333#define MC_CMD_NVRAM_TYPE_LOG 12 1887#define MC_CMD_NVRAM_TYPE_PHY_PORT0 0xa /* enum */
1334 1888#define MC_CMD_NVRAM_TYPE_PHY_PORT1 0xb /* enum */
1335/* MC_CMD_NVRAM_INFO: 1889#define MC_CMD_NVRAM_TYPE_LOG 0xc /* enum */
1336 * Read info about a virtual NVRAM partition 1890#define MC_CMD_NVRAM_TYPE_FPGA 0xd /* enum */
1337 * 1891
1338 * Locks required: none 1892
1339 * Returns: 0, EINVAL (bad type) 1893/***********************************/
1894/* MC_CMD_NVRAM_INFO
1895 * Read info about a virtual NVRAM partition.
1340 */ 1896 */
1341#define MC_CMD_NVRAM_INFO 0x37 1897#define MC_CMD_NVRAM_INFO 0x37
1342#define MC_CMD_NVRAM_INFO_IN_LEN 4 1898
1343#define MC_CMD_NVRAM_INFO_IN_TYPE_OFST 0 1899/* MC_CMD_NVRAM_INFO_IN msgrequest */
1344#define MC_CMD_NVRAM_INFO_OUT_LEN 24 1900#define MC_CMD_NVRAM_INFO_IN_LEN 4
1345#define MC_CMD_NVRAM_INFO_OUT_TYPE_OFST 0 1901#define MC_CMD_NVRAM_INFO_IN_TYPE_OFST 0
1346#define MC_CMD_NVRAM_INFO_OUT_SIZE_OFST 4 1902/* Enum values, see field(s): */
1347#define MC_CMD_NVRAM_INFO_OUT_ERASESIZE_OFST 8 1903/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */
1348#define MC_CMD_NVRAM_INFO_OUT_FLAGS_OFST 12 1904
1349#define MC_CMD_NVRAM_PROTECTED_LBN 0 1905/* MC_CMD_NVRAM_INFO_OUT msgresponse */
1350#define MC_CMD_NVRAM_PROTECTED_WIDTH 1 1906#define MC_CMD_NVRAM_INFO_OUT_LEN 24
1351#define MC_CMD_NVRAM_INFO_OUT_PHYSDEV_OFST 16 1907#define MC_CMD_NVRAM_INFO_OUT_TYPE_OFST 0
1352#define MC_CMD_NVRAM_INFO_OUT_PHYSADDR_OFST 20 1908/* Enum values, see field(s): */
1353 1909/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */
1354/* MC_CMD_NVRAM_UPDATE_START: 1910#define MC_CMD_NVRAM_INFO_OUT_SIZE_OFST 4
1355 * Start a group of update operations on a virtual NVRAM partition 1911#define MC_CMD_NVRAM_INFO_OUT_ERASESIZE_OFST 8
1356 * 1912#define MC_CMD_NVRAM_INFO_OUT_FLAGS_OFST 12
1357 * Locks required: PHY_LOCK if type==*PHY* 1913#define MC_CMD_NVRAM_INFO_OUT_PROTECTED_LBN 0
1358 * Returns: 0, EINVAL (bad type), EACCES (if PHY_LOCK required and not held) 1914#define MC_CMD_NVRAM_INFO_OUT_PROTECTED_WIDTH 1
1915#define MC_CMD_NVRAM_INFO_OUT_PHYSDEV_OFST 16
1916#define MC_CMD_NVRAM_INFO_OUT_PHYSADDR_OFST 20
1917
1918
1919/***********************************/
1920/* MC_CMD_NVRAM_UPDATE_START
1921 * Start a group of update operations on a virtual NVRAM partition.
1359 */ 1922 */
1360#define MC_CMD_NVRAM_UPDATE_START 0x38 1923#define MC_CMD_NVRAM_UPDATE_START 0x38
1361#define MC_CMD_NVRAM_UPDATE_START_IN_LEN 4
1362#define MC_CMD_NVRAM_UPDATE_START_IN_TYPE_OFST 0
1363#define MC_CMD_NVRAM_UPDATE_START_OUT_LEN 0
1364 1924
1365/* MC_CMD_NVRAM_READ: 1925/* MC_CMD_NVRAM_UPDATE_START_IN msgrequest */
1366 * Read data from a virtual NVRAM partition 1926#define MC_CMD_NVRAM_UPDATE_START_IN_LEN 4
1367 * 1927#define MC_CMD_NVRAM_UPDATE_START_IN_TYPE_OFST 0
1368 * Locks required: PHY_LOCK if type==*PHY* 1928/* Enum values, see field(s): */
1369 * Returns: 0, EINVAL (bad type/offset/length), EACCES (if PHY_LOCK required and not held) 1929/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */
1930
1931/* MC_CMD_NVRAM_UPDATE_START_OUT msgresponse */
1932#define MC_CMD_NVRAM_UPDATE_START_OUT_LEN 0
1933
1934
1935/***********************************/
1936/* MC_CMD_NVRAM_READ
1937 * Read data from a virtual NVRAM partition.
1370 */ 1938 */
1371#define MC_CMD_NVRAM_READ 0x39 1939#define MC_CMD_NVRAM_READ 0x39
1372#define MC_CMD_NVRAM_READ_IN_LEN 12 1940
1373#define MC_CMD_NVRAM_READ_IN_TYPE_OFST 0 1941/* MC_CMD_NVRAM_READ_IN msgrequest */
1374#define MC_CMD_NVRAM_READ_IN_OFFSET_OFST 4 1942#define MC_CMD_NVRAM_READ_IN_LEN 12
1375#define MC_CMD_NVRAM_READ_IN_LENGTH_OFST 8 1943#define MC_CMD_NVRAM_READ_IN_TYPE_OFST 0
1376#define MC_CMD_NVRAM_READ_OUT_LEN(_read_bytes) (_read_bytes) 1944/* Enum values, see field(s): */
1377#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_OFST 0 1945/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */
1378 1946#define MC_CMD_NVRAM_READ_IN_OFFSET_OFST 4
1379/* MC_CMD_NVRAM_WRITE: 1947#define MC_CMD_NVRAM_READ_IN_LENGTH_OFST 8
1380 * Write data to a virtual NVRAM partition 1948
1381 * 1949/* MC_CMD_NVRAM_READ_OUT msgresponse */
1382 * Locks required: PHY_LOCK if type==*PHY* 1950#define MC_CMD_NVRAM_READ_OUT_LENMIN 1
1383 * Returns: 0, EINVAL (bad type/offset/length), EACCES (if PHY_LOCK required and not held) 1951#define MC_CMD_NVRAM_READ_OUT_LENMAX 255
1952#define MC_CMD_NVRAM_READ_OUT_LEN(num) (0+1*(num))
1953#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_OFST 0
1954#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_LEN 1
1955#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_MINNUM 1
1956#define MC_CMD_NVRAM_READ_OUT_READ_BUFFER_MAXNUM 255
1957
1958
1959/***********************************/
1960/* MC_CMD_NVRAM_WRITE
1961 * Write data to a virtual NVRAM partition.
1384 */ 1962 */
1385#define MC_CMD_NVRAM_WRITE 0x3a 1963#define MC_CMD_NVRAM_WRITE 0x3a
1386#define MC_CMD_NVRAM_WRITE_IN_TYPE_OFST 0 1964
1387#define MC_CMD_NVRAM_WRITE_IN_OFFSET_OFST 4 1965/* MC_CMD_NVRAM_WRITE_IN msgrequest */
1388#define MC_CMD_NVRAM_WRITE_IN_LENGTH_OFST 8 1966#define MC_CMD_NVRAM_WRITE_IN_LENMIN 13
1389#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_OFST 12 1967#define MC_CMD_NVRAM_WRITE_IN_LENMAX 255
1390#define MC_CMD_NVRAM_WRITE_IN_LEN(_write_bytes) (12 + _write_bytes) 1968#define MC_CMD_NVRAM_WRITE_IN_LEN(num) (12+1*(num))
1391#define MC_CMD_NVRAM_WRITE_OUT_LEN 0 1969#define MC_CMD_NVRAM_WRITE_IN_TYPE_OFST 0
1392 1970/* Enum values, see field(s): */
1393/* MC_CMD_NVRAM_ERASE: 1971/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */
1394 * Erase sector(s) from a virtual NVRAM partition 1972#define MC_CMD_NVRAM_WRITE_IN_OFFSET_OFST 4
1395 * 1973#define MC_CMD_NVRAM_WRITE_IN_LENGTH_OFST 8
1396 * Locks required: PHY_LOCK if type==*PHY* 1974#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_OFST 12
1397 * Returns: 0, EINVAL (bad type/offset/length), EACCES (if PHY_LOCK required and not held) 1975#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_LEN 1
1976#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_MINNUM 1
1977#define MC_CMD_NVRAM_WRITE_IN_WRITE_BUFFER_MAXNUM 243
1978
1979/* MC_CMD_NVRAM_WRITE_OUT msgresponse */
1980#define MC_CMD_NVRAM_WRITE_OUT_LEN 0
1981
1982
1983/***********************************/
1984/* MC_CMD_NVRAM_ERASE
1985 * Erase sector(s) from a virtual NVRAM partition.
1398 */ 1986 */
1399#define MC_CMD_NVRAM_ERASE 0x3b 1987#define MC_CMD_NVRAM_ERASE 0x3b
1400#define MC_CMD_NVRAM_ERASE_IN_LEN 12 1988
1401#define MC_CMD_NVRAM_ERASE_IN_TYPE_OFST 0 1989/* MC_CMD_NVRAM_ERASE_IN msgrequest */
1402#define MC_CMD_NVRAM_ERASE_IN_OFFSET_OFST 4 1990#define MC_CMD_NVRAM_ERASE_IN_LEN 12
1403#define MC_CMD_NVRAM_ERASE_IN_LENGTH_OFST 8 1991#define MC_CMD_NVRAM_ERASE_IN_TYPE_OFST 0
1404#define MC_CMD_NVRAM_ERASE_OUT_LEN 0 1992/* Enum values, see field(s): */
1405 1993/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */
1406/* MC_CMD_NVRAM_UPDATE_FINISH: 1994#define MC_CMD_NVRAM_ERASE_IN_OFFSET_OFST 4
1407 * Finish a group of update operations on a virtual NVRAM partition 1995#define MC_CMD_NVRAM_ERASE_IN_LENGTH_OFST 8
1408 * 1996
1409 * Locks required: PHY_LOCK if type==*PHY* 1997/* MC_CMD_NVRAM_ERASE_OUT msgresponse */
1410 * Returns: 0, EINVAL (bad type/offset/length), EACCES (if PHY_LOCK required and not held) 1998#define MC_CMD_NVRAM_ERASE_OUT_LEN 0
1999
2000
2001/***********************************/
2002/* MC_CMD_NVRAM_UPDATE_FINISH
2003 * Finish a group of update operations on a virtual NVRAM partition.
1411 */ 2004 */
1412#define MC_CMD_NVRAM_UPDATE_FINISH 0x3c 2005#define MC_CMD_NVRAM_UPDATE_FINISH 0x3c
1413#define MC_CMD_NVRAM_UPDATE_FINISH_IN_LEN 8
1414#define MC_CMD_NVRAM_UPDATE_FINISH_IN_TYPE_OFST 0
1415#define MC_CMD_NVRAM_UPDATE_FINISH_IN_REBOOT_OFST 4
1416#define MC_CMD_NVRAM_UPDATE_FINISH_OUT_LEN 0
1417 2006
1418/* MC_CMD_REBOOT: 2007/* MC_CMD_NVRAM_UPDATE_FINISH_IN msgrequest */
2008#define MC_CMD_NVRAM_UPDATE_FINISH_IN_LEN 8
2009#define MC_CMD_NVRAM_UPDATE_FINISH_IN_TYPE_OFST 0
2010/* Enum values, see field(s): */
2011/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */
2012#define MC_CMD_NVRAM_UPDATE_FINISH_IN_REBOOT_OFST 4
2013
2014/* MC_CMD_NVRAM_UPDATE_FINISH_OUT msgresponse */
2015#define MC_CMD_NVRAM_UPDATE_FINISH_OUT_LEN 0
2016
2017
2018/***********************************/
2019/* MC_CMD_REBOOT
1419 * Reboot the MC. 2020 * Reboot the MC.
1420 *
1421 * The AFTER_ASSERTION flag is intended to be used when the driver notices
1422 * an assertion failure (at which point it is expected to perform a complete
1423 * tear down and reinitialise), to allow both ports to reset the MC once
1424 * in an atomic fashion.
1425 *
1426 * Production mc firmwares are generally compiled with REBOOT_ON_ASSERT=1,
1427 * which means that they will automatically reboot out of the assertion
1428 * handler, so this is in practise an optional operation. It is still
1429 * recommended that drivers execute this to support custom firmwares
1430 * with REBOOT_ON_ASSERT=0.
1431 *
1432 * Locks required: NONE
1433 * Returns: Nothing. You get back a response with ERR=1, DATALEN=0
1434 */ 2021 */
1435#define MC_CMD_REBOOT 0x3d 2022#define MC_CMD_REBOOT 0x3d
1436#define MC_CMD_REBOOT_IN_LEN 4
1437#define MC_CMD_REBOOT_IN_FLAGS_OFST 0
1438#define MC_CMD_REBOOT_FLAGS_AFTER_ASSERTION 1
1439#define MC_CMD_REBOOT_OUT_LEN 0
1440 2023
1441/* MC_CMD_SCHEDINFO: 2024/* MC_CMD_REBOOT_IN msgrequest */
1442 * Request scheduler info. from the MC. 2025#define MC_CMD_REBOOT_IN_LEN 4
1443 * 2026#define MC_CMD_REBOOT_IN_FLAGS_OFST 0
1444 * Locks required: NONE 2027#define MC_CMD_REBOOT_FLAGS_AFTER_ASSERTION 0x1 /* enum */
1445 * Returns: An array of (timeslice,maximum overrun), one for each thread, 2028
1446 * in ascending order of thread address.s 2029/* MC_CMD_REBOOT_OUT msgresponse */
2030#define MC_CMD_REBOOT_OUT_LEN 0
2031
2032
2033/***********************************/
2034/* MC_CMD_SCHEDINFO
2035 * Request scheduler info.
1447 */ 2036 */
1448#define MC_CMD_SCHEDINFO 0x3e 2037#define MC_CMD_SCHEDINFO 0x3e
1449#define MC_CMD_SCHEDINFO_IN_LEN 0
1450 2038
2039/* MC_CMD_SCHEDINFO_IN msgrequest */
2040#define MC_CMD_SCHEDINFO_IN_LEN 0
1451 2041
1452/* MC_CMD_SET_REBOOT_MODE: (debug) 2042/* MC_CMD_SCHEDINFO_OUT msgresponse */
1453 * Set the mode for the next MC reboot. 2043#define MC_CMD_SCHEDINFO_OUT_LENMIN 4
1454 * 2044#define MC_CMD_SCHEDINFO_OUT_LENMAX 252
1455 * Locks required: NONE 2045#define MC_CMD_SCHEDINFO_OUT_LEN(num) (0+4*(num))
1456 * 2046#define MC_CMD_SCHEDINFO_OUT_DATA_OFST 0
1457 * Sets the reboot mode to the specified value. Returns the old mode. 2047#define MC_CMD_SCHEDINFO_OUT_DATA_LEN 4
2048#define MC_CMD_SCHEDINFO_OUT_DATA_MINNUM 1
2049#define MC_CMD_SCHEDINFO_OUT_DATA_MAXNUM 63
2050
2051
2052/***********************************/
2053/* MC_CMD_REBOOT_MODE
1458 */ 2054 */
1459#define MC_CMD_REBOOT_MODE 0x3f 2055#define MC_CMD_REBOOT_MODE 0x3f
1460#define MC_CMD_REBOOT_MODE_IN_LEN 4 2056
1461#define MC_CMD_REBOOT_MODE_IN_VALUE_OFST 0 2057/* MC_CMD_REBOOT_MODE_IN msgrequest */
1462#define MC_CMD_REBOOT_MODE_OUT_LEN 4 2058#define MC_CMD_REBOOT_MODE_IN_LEN 4
1463#define MC_CMD_REBOOT_MODE_OUT_VALUE_OFST 0 2059#define MC_CMD_REBOOT_MODE_IN_VALUE_OFST 0
1464#define MC_CMD_REBOOT_MODE_NORMAL 0 2060#define MC_CMD_REBOOT_MODE_NORMAL 0x0 /* enum */
1465#define MC_CMD_REBOOT_MODE_SNAPPER 3 2061#define MC_CMD_REBOOT_MODE_SNAPPER 0x3 /* enum */
1466 2062
1467/* MC_CMD_DEBUG_LOG: 2063/* MC_CMD_REBOOT_MODE_OUT msgresponse */
1468 * Null request/response command (debug) 2064#define MC_CMD_REBOOT_MODE_OUT_LEN 4
1469 * - sequence number is always zero 2065#define MC_CMD_REBOOT_MODE_OUT_VALUE_OFST 0
1470 * - only supported on the UART interface 2066
1471 * (the same set of bytes is delivered as an 2067
1472 * event over PCI) 2068/***********************************/
1473 */ 2069/* MC_CMD_SENSOR_INFO
1474#define MC_CMD_DEBUG_LOG 0x40
1475#define MC_CMD_DEBUG_LOG_IN_LEN 0
1476#define MC_CMD_DEBUG_LOG_OUT_LEN 0
1477
1478/* Generic sensor enumeration. Note that a dual port NIC
1479 * will EITHER expose PHY_COMMON_TEMP OR PHY0_TEMP and
1480 * PHY1_TEMP depending on whether there is a single sensor
1481 * in the vicinity of the two port, or one per port.
1482 */
1483#define MC_CMD_SENSOR_CONTROLLER_TEMP 0 /* degC */
1484#define MC_CMD_SENSOR_PHY_COMMON_TEMP 1 /* degC */
1485#define MC_CMD_SENSOR_CONTROLLER_COOLING 2 /* bool */
1486#define MC_CMD_SENSOR_PHY0_TEMP 3 /* degC */
1487#define MC_CMD_SENSOR_PHY0_COOLING 4 /* bool */
1488#define MC_CMD_SENSOR_PHY1_TEMP 5 /* degC */
1489#define MC_CMD_SENSOR_PHY1_COOLING 6 /* bool */
1490#define MC_CMD_SENSOR_IN_1V0 7 /* mV */
1491#define MC_CMD_SENSOR_IN_1V2 8 /* mV */
1492#define MC_CMD_SENSOR_IN_1V8 9 /* mV */
1493#define MC_CMD_SENSOR_IN_2V5 10 /* mV */
1494#define MC_CMD_SENSOR_IN_3V3 11 /* mV */
1495#define MC_CMD_SENSOR_IN_12V0 12 /* mV */
1496
1497
1498/* Sensor state */
1499#define MC_CMD_SENSOR_STATE_OK 0
1500#define MC_CMD_SENSOR_STATE_WARNING 1
1501#define MC_CMD_SENSOR_STATE_FATAL 2
1502#define MC_CMD_SENSOR_STATE_BROKEN 3
1503
1504/* MC_CMD_SENSOR_INFO:
1505 * Returns information about every available sensor. 2070 * Returns information about every available sensor.
1506 *
1507 * Each sensor has a single (16bit) value, and a corresponding state.
1508 * The mapping between value and sensor is nominally determined by the
1509 * MC, but in practise is implemented as zero (BROKEN), one (TEMPERATURE),
1510 * or two (VOLTAGE) ranges per sensor per state.
1511 *
1512 * This call returns a mask (32bit) of the sensors that are supported
1513 * by this platform, then an array (indexed by MC_CMD_SENSOR) of byte
1514 * offsets to the per-sensor arrays. Each sensor array has four 16bit
1515 * numbers, min1, max1, min2, max2.
1516 *
1517 * Locks required: None
1518 * Returns: 0
1519 */ 2071 */
1520#define MC_CMD_SENSOR_INFO 0x41 2072#define MC_CMD_SENSOR_INFO 0x41
1521#define MC_CMD_SENSOR_INFO_IN_LEN 0
1522#define MC_CMD_SENSOR_INFO_OUT_MASK_OFST 0
1523#define MC_CMD_SENSOR_INFO_OUT_OFFSET_OFST(_x) \
1524 (4 + (_x))
1525#define MC_CMD_SENSOR_INFO_OUT_MIN1_OFST(_ofst) \
1526 ((_ofst) + 0)
1527#define MC_CMD_SENSOR_INFO_OUT_MAX1_OFST(_ofst) \
1528 ((_ofst) + 2)
1529#define MC_CMD_SENSOR_INFO_OUT_MIN2_OFST(_ofst) \
1530 ((_ofst) + 4)
1531#define MC_CMD_SENSOR_INFO_OUT_MAX2_OFST(_ofst) \
1532 ((_ofst) + 6)
1533 2073
2074/* MC_CMD_SENSOR_INFO_IN msgrequest */
2075#define MC_CMD_SENSOR_INFO_IN_LEN 0
2076
2077/* MC_CMD_SENSOR_INFO_OUT msgresponse */
2078#define MC_CMD_SENSOR_INFO_OUT_LENMIN 12
2079#define MC_CMD_SENSOR_INFO_OUT_LENMAX 252
2080#define MC_CMD_SENSOR_INFO_OUT_LEN(num) (4+8*(num))
2081#define MC_CMD_SENSOR_INFO_OUT_MASK_OFST 0
2082#define MC_CMD_SENSOR_CONTROLLER_TEMP 0x0 /* enum */
2083#define MC_CMD_SENSOR_PHY_COMMON_TEMP 0x1 /* enum */
2084#define MC_CMD_SENSOR_CONTROLLER_COOLING 0x2 /* enum */
2085#define MC_CMD_SENSOR_PHY0_TEMP 0x3 /* enum */
2086#define MC_CMD_SENSOR_PHY0_COOLING 0x4 /* enum */
2087#define MC_CMD_SENSOR_PHY1_TEMP 0x5 /* enum */
2088#define MC_CMD_SENSOR_PHY1_COOLING 0x6 /* enum */
2089#define MC_CMD_SENSOR_IN_1V0 0x7 /* enum */
2090#define MC_CMD_SENSOR_IN_1V2 0x8 /* enum */
2091#define MC_CMD_SENSOR_IN_1V8 0x9 /* enum */
2092#define MC_CMD_SENSOR_IN_2V5 0xa /* enum */
2093#define MC_CMD_SENSOR_IN_3V3 0xb /* enum */
2094#define MC_CMD_SENSOR_IN_12V0 0xc /* enum */
2095#define MC_CMD_SENSOR_IN_1V2A 0xd /* enum */
2096#define MC_CMD_SENSOR_IN_VREF 0xe /* enum */
2097#define MC_CMD_SENSOR_ENTRY_OFST 4
2098#define MC_CMD_SENSOR_ENTRY_LEN 8
2099#define MC_CMD_SENSOR_ENTRY_LO_OFST 4
2100#define MC_CMD_SENSOR_ENTRY_HI_OFST 8
2101#define MC_CMD_SENSOR_ENTRY_MINNUM 1
2102#define MC_CMD_SENSOR_ENTRY_MAXNUM 31
2103
2104/* MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF structuredef */
2105#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_LEN 8
2106#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN1_OFST 0
2107#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN1_LEN 2
2108#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN1_LBN 0
2109#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN1_WIDTH 16
2110#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX1_OFST 2
2111#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX1_LEN 2
2112#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX1_LBN 16
2113#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX1_WIDTH 16
2114#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN2_OFST 4
2115#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN2_LEN 2
2116#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN2_LBN 32
2117#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MIN2_WIDTH 16
2118#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX2_OFST 6
2119#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX2_LEN 2
2120#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX2_LBN 48
2121#define MC_CMD_SENSOR_INFO_ENTRY_TYPEDEF_MAX2_WIDTH 16
2122
2123
2124/***********************************/
1534/* MC_CMD_READ_SENSORS 2125/* MC_CMD_READ_SENSORS
1535 * Returns the current reading from each sensor 2126 * Returns the current reading from each sensor.
1536 *
1537 * Returns a sparse array of sensor readings (indexed by the sensor
1538 * type) into host memory. Each array element is a dword.
1539 *
1540 * The MC will send a SENSOREVT event every time any sensor changes state. The
1541 * driver is responsible for ensuring that it doesn't miss any events. The board
1542 * will function normally if all sensors are in STATE_OK or state_WARNING.
1543 * Otherwise the board should not be expected to function.
1544 */ 2127 */
1545#define MC_CMD_READ_SENSORS 0x42 2128#define MC_CMD_READ_SENSORS 0x42
1546#define MC_CMD_READ_SENSORS_IN_LEN 8
1547#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_LO_OFST 0
1548#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_HI_OFST 4
1549#define MC_CMD_READ_SENSORS_OUT_LEN 0
1550 2129
1551/* Sensor reading fields */ 2130/* MC_CMD_READ_SENSORS_IN msgrequest */
1552#define MC_CMD_READ_SENSOR_VALUE_LBN 0 2131#define MC_CMD_READ_SENSORS_IN_LEN 8
1553#define MC_CMD_READ_SENSOR_VALUE_WIDTH 16 2132#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_OFST 0
1554#define MC_CMD_READ_SENSOR_STATE_LBN 16 2133#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_LEN 8
1555#define MC_CMD_READ_SENSOR_STATE_WIDTH 8 2134#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_LO_OFST 0
1556 2135#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_HI_OFST 4
1557 2136
1558/* MC_CMD_GET_PHY_STATE: 2137/* MC_CMD_READ_SENSORS_OUT msgresponse */
1559 * Report current state of PHY. A "zombie" PHY is a PHY that has failed to 2138#define MC_CMD_READ_SENSORS_OUT_LEN 0
1560 * boot (e.g. due to missing or corrupted firmware). 2139
1561 * 2140/* MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF structuredef */
1562 * Locks required: None 2141#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_LEN 3
1563 * Return code: 0 2142#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE_OFST 0
2143#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE_LEN 2
2144#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE_LBN 0
2145#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_VALUE_WIDTH 16
2146#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE_OFST 2
2147#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE_LEN 1
2148#define MC_CMD_SENSOR_STATE_OK 0x0 /* enum */
2149#define MC_CMD_SENSOR_STATE_WARNING 0x1 /* enum */
2150#define MC_CMD_SENSOR_STATE_FATAL 0x2 /* enum */
2151#define MC_CMD_SENSOR_STATE_BROKEN 0x3 /* enum */
2152#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE_LBN 16
2153#define MC_CMD_SENSOR_VALUE_ENTRY_TYPEDEF_STATE_WIDTH 8
2154
2155
2156/***********************************/
2157/* MC_CMD_GET_PHY_STATE
2158 * Report current state of PHY.
1564 */ 2159 */
1565#define MC_CMD_GET_PHY_STATE 0x43 2160#define MC_CMD_GET_PHY_STATE 0x43
1566 2161
1567#define MC_CMD_GET_PHY_STATE_IN_LEN 0 2162/* MC_CMD_GET_PHY_STATE_IN msgrequest */
1568#define MC_CMD_GET_PHY_STATE_OUT_LEN 4 2163#define MC_CMD_GET_PHY_STATE_IN_LEN 0
1569#define MC_CMD_GET_PHY_STATE_STATE_OFST 0
1570/* PHY state enumeration: */
1571#define MC_CMD_PHY_STATE_OK 1
1572#define MC_CMD_PHY_STATE_ZOMBIE 2
1573 2164
2165/* MC_CMD_GET_PHY_STATE_OUT msgresponse */
2166#define MC_CMD_GET_PHY_STATE_OUT_LEN 4
2167#define MC_CMD_GET_PHY_STATE_OUT_STATE_OFST 0
2168#define MC_CMD_PHY_STATE_OK 0x1 /* enum */
2169#define MC_CMD_PHY_STATE_ZOMBIE 0x2 /* enum */
1574 2170
1575/* 802.1Qbb control. 8 Tx queues that map to priorities 0 - 7. Use all 1s to 2171
1576 * disable 802.Qbb for a given priority. */ 2172/***********************************/
2173/* MC_CMD_SETUP_8021QBB
2174 * 802.1Qbb control.
2175 */
1577#define MC_CMD_SETUP_8021QBB 0x44 2176#define MC_CMD_SETUP_8021QBB 0x44
1578#define MC_CMD_SETUP_8021QBB_IN_LEN 32
1579#define MC_CMD_SETUP_8021QBB_OUT_LEN 0
1580#define MC_CMD_SETUP_8021QBB_IN_TXQS_OFFST 0
1581 2177
2178/* MC_CMD_SETUP_8021QBB_IN msgrequest */
2179#define MC_CMD_SETUP_8021QBB_IN_LEN 32
2180#define MC_CMD_SETUP_8021QBB_IN_TXQS_OFST 0
2181#define MC_CMD_SETUP_8021QBB_IN_TXQS_LEN 32
1582 2182
1583/* MC_CMD_WOL_FILTER_GET: 2183/* MC_CMD_SETUP_8021QBB_OUT msgresponse */
1584 * Retrieve ID of any WoL filters 2184#define MC_CMD_SETUP_8021QBB_OUT_LEN 0
1585 *
1586 * Locks required: None
1587 * Returns: 0, ENOSYS
1588 */
1589#define MC_CMD_WOL_FILTER_GET 0x45
1590#define MC_CMD_WOL_FILTER_GET_IN_LEN 0
1591#define MC_CMD_WOL_FILTER_GET_OUT_LEN 4
1592#define MC_CMD_WOL_FILTER_GET_OUT_FILTER_ID_OFST 0
1593 2185
1594 2186
1595/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD: 2187/***********************************/
1596 * Offload a protocol to NIC for lights-out state 2188/* MC_CMD_WOL_FILTER_GET
1597 * 2189 * Retrieve ID of any WoL filters.
1598 * Locks required: None
1599 * Returns: 0, ENOSYS
1600 */ 2190 */
1601#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD 0x46 2191#define MC_CMD_WOL_FILTER_GET 0x45
1602 2192
1603#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_LEN 16 2193/* MC_CMD_WOL_FILTER_GET_IN msgrequest */
1604#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_PROTOCOL_OFST 0 2194#define MC_CMD_WOL_FILTER_GET_IN_LEN 0
1605 2195
1606/* There is a union at offset 4, following defines overlap due to 2196/* MC_CMD_WOL_FILTER_GET_OUT msgresponse */
1607 * this */ 2197#define MC_CMD_WOL_FILTER_GET_OUT_LEN 4
1608#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_DATA_OFST 4 2198#define MC_CMD_WOL_FILTER_GET_OUT_FILTER_ID_OFST 0
1609#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARPMAC_OFST 4
1610#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARPIP_OFST 10
1611#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NSMAC_OFST 4
1612#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NSSNIPV6_OFST 10
1613#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NSIPV6_OFST 26
1614 2199
1615#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_OUT_LEN 4
1616#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_OUT_FILTER_ID_OFST 0
1617 2200
2201/***********************************/
2202/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD
2203 * Add a protocol offload to NIC for lights-out state.
2204 */
2205#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD 0x46
1618 2206
1619/* MC_CMD_REMOVE_LIGHTSOUT_PROTOCOL_OFFLOAD: 2207/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN msgrequest */
1620 * Offload a protocol to NIC for lights-out state 2208#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_LENMIN 8
1621 * 2209#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_LENMAX 252
1622 * Locks required: None 2210#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_LEN(num) (4+4*(num))
1623 * Returns: 0, ENOSYS 2211#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_PROTOCOL_OFST 0
2212#define MC_CMD_LIGHTSOUT_OFFLOAD_PROTOCOL_ARP 0x1 /* enum */
2213#define MC_CMD_LIGHTSOUT_OFFLOAD_PROTOCOL_NS 0x2 /* enum */
2214#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_DATA_OFST 4
2215#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_DATA_LEN 4
2216#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_DATA_MINNUM 1
2217#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_DATA_MAXNUM 62
2218
2219/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARP msgrequest */
2220#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARP_LEN 14
2221/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_PROTOCOL_OFST 0 */
2222#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARP_MAC_OFST 4
2223#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARP_MAC_LEN 6
2224#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_ARP_IP_OFST 10
2225
2226/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS msgrequest */
2227#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_LEN 42
2228/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_PROTOCOL_OFST 0 */
2229#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_MAC_OFST 4
2230#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_MAC_LEN 6
2231#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_SNIPV6_OFST 10
2232#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_SNIPV6_LEN 16
2233#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_IPV6_OFST 26
2234#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_IN_NS_IPV6_LEN 16
2235
2236/* MC_CMD_ADD_LIGHTSOUT_OFFLOAD_OUT msgresponse */
2237#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_OUT_LEN 4
2238#define MC_CMD_ADD_LIGHTSOUT_OFFLOAD_OUT_FILTER_ID_OFST 0
2239
2240
2241/***********************************/
2242/* MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD
2243 * Remove a protocol offload from NIC for lights-out state.
1624 */ 2244 */
1625#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD 0x47 2245#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD 0x47
1626#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_LEN 8
1627#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_OUT_LEN 0
1628 2246
1629#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_PROTOCOL_OFST 0 2247/* MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN msgrequest */
1630#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_FILTER_ID_OFST 4 2248#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_LEN 8
2249#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_PROTOCOL_OFST 0
2250#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_IN_FILTER_ID_OFST 4
1631 2251
1632/* Lights-out offload protocols enumeration */ 2252/* MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_OUT msgresponse */
1633#define MC_CMD_LIGHTSOUT_OFFLOAD_PROTOCOL_ARP 0x1 2253#define MC_CMD_REMOVE_LIGHTSOUT_OFFLOAD_OUT_LEN 0
1634#define MC_CMD_LIGHTSOUT_OFFLOAD_PROTOCOL_NS 0x2
1635 2254
1636 2255
1637/* MC_CMD_MAC_RESET_RESTORE: 2256/***********************************/
1638 * Restore MAC after block reset 2257/* MC_CMD_MAC_RESET_RESTORE
1639 * 2258 * Restore MAC after block reset.
1640 * Locks required: None
1641 * Returns: 0
1642 */ 2259 */
1643
1644#define MC_CMD_MAC_RESET_RESTORE 0x48 2260#define MC_CMD_MAC_RESET_RESTORE 0x48
1645#define MC_CMD_MAC_RESET_RESTORE_IN_LEN 0
1646#define MC_CMD_MAC_RESET_RESTORE_OUT_LEN 0
1647 2261
2262/* MC_CMD_MAC_RESET_RESTORE_IN msgrequest */
2263#define MC_CMD_MAC_RESET_RESTORE_IN_LEN 0
2264
2265/* MC_CMD_MAC_RESET_RESTORE_OUT msgresponse */
2266#define MC_CMD_MAC_RESET_RESTORE_OUT_LEN 0
1648 2267
1649/* MC_CMD_TEST_ASSERT:
1650 * Deliberately trigger an assert-detonation in the firmware for testing
1651 * purposes (i.e. to allow tests that the driver copes gracefully).
1652 *
1653 * Locks required: None
1654 * Returns: 0
1655 */
1656 2268
2269/***********************************/
2270/* MC_CMD_TESTASSERT
2271 */
1657#define MC_CMD_TESTASSERT 0x49 2272#define MC_CMD_TESTASSERT 0x49
1658#define MC_CMD_TESTASSERT_IN_LEN 0
1659#define MC_CMD_TESTASSERT_OUT_LEN 0
1660 2273
1661/* MC_CMD_WORKAROUND 0x4a 2274/* MC_CMD_TESTASSERT_IN msgrequest */
1662 * 2275#define MC_CMD_TESTASSERT_IN_LEN 0
1663 * Enable/Disable a given workaround. The mcfw will return EINVAL if it 2276
1664 * doesn't understand the given workaround number - which should not 2277/* MC_CMD_TESTASSERT_OUT msgresponse */
1665 * be treated as a hard error by client code. 2278#define MC_CMD_TESTASSERT_OUT_LEN 0
1666 * 2279
1667 * This op does not imply any semantics about each workaround, that's between 2280
1668 * the driver and the mcfw on a per-workaround basis. 2281/***********************************/
1669 * 2282/* MC_CMD_WORKAROUND
1670 * Locks required: None 2283 * Enable/Disable a given workaround.
1671 * Returns: 0, EINVAL
1672 */ 2284 */
1673#define MC_CMD_WORKAROUND 0x4a 2285#define MC_CMD_WORKAROUND 0x4a
1674#define MC_CMD_WORKAROUND_IN_LEN 8 2286
1675#define MC_CMD_WORKAROUND_IN_TYPE_OFST 0 2287/* MC_CMD_WORKAROUND_IN msgrequest */
1676#define MC_CMD_WORKAROUND_BUG17230 1 2288#define MC_CMD_WORKAROUND_IN_LEN 8
1677#define MC_CMD_WORKAROUND_IN_ENABLED_OFST 4 2289#define MC_CMD_WORKAROUND_IN_TYPE_OFST 0
1678#define MC_CMD_WORKAROUND_OUT_LEN 0 2290#define MC_CMD_WORKAROUND_BUG17230 0x1 /* enum */
1679 2291#define MC_CMD_WORKAROUND_IN_ENABLED_OFST 4
1680/* MC_CMD_GET_PHY_MEDIA_INFO: 2292
1681 * Read media-specific data from PHY (e.g. SFP/SFP+ module ID information for 2293/* MC_CMD_WORKAROUND_OUT msgresponse */
1682 * SFP+ PHYs). 2294#define MC_CMD_WORKAROUND_OUT_LEN 0
1683 * 2295
1684 * The "media type" can be found via GET_PHY_CFG (GET_PHY_CFG_OUT_MEDIA_TYPE); 2296
1685 * the valid "page number" input values, and the output data, are interpreted 2297/***********************************/
1686 * on a per-type basis. 2298/* MC_CMD_GET_PHY_MEDIA_INFO
1687 * 2299 * Read media-specific data from PHY.
1688 * For SFP+: PAGE=0 or 1 returns a 128-byte block read from module I2C address
1689 * 0xA0 offset 0 or 0x80.
1690 * Anything else: currently undefined.
1691 *
1692 * Locks required: None
1693 * Return code: 0
1694 */ 2300 */
1695#define MC_CMD_GET_PHY_MEDIA_INFO 0x4b 2301#define MC_CMD_GET_PHY_MEDIA_INFO 0x4b
1696#define MC_CMD_GET_PHY_MEDIA_INFO_IN_LEN 4 2302
1697#define MC_CMD_GET_PHY_MEDIA_INFO_IN_PAGE_OFST 0 2303/* MC_CMD_GET_PHY_MEDIA_INFO_IN msgrequest */
1698#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_LEN(_num_bytes) (4 + (_num_bytes)) 2304#define MC_CMD_GET_PHY_MEDIA_INFO_IN_LEN 4
1699#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATALEN_OFST 0 2305#define MC_CMD_GET_PHY_MEDIA_INFO_IN_PAGE_OFST 0
1700#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_OFST 4 2306
1701 2307/* MC_CMD_GET_PHY_MEDIA_INFO_OUT msgresponse */
1702/* MC_CMD_NVRAM_TEST: 2308#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_LENMIN 5
1703 * Test a particular NVRAM partition for valid contents (where "valid" 2309#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_LENMAX 255
1704 * depends on the type of partition). 2310#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_LEN(num) (4+1*(num))
1705 * 2311#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATALEN_OFST 0
1706 * Locks required: None 2312#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_OFST 4
1707 * Return code: 0 2313#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_LEN 1
2314#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_MINNUM 1
2315#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_MAXNUM 251
2316
2317
2318/***********************************/
2319/* MC_CMD_NVRAM_TEST
2320 * Test a particular NVRAM partition.
1708 */ 2321 */
1709#define MC_CMD_NVRAM_TEST 0x4c 2322#define MC_CMD_NVRAM_TEST 0x4c
1710#define MC_CMD_NVRAM_TEST_IN_LEN 4 2323
1711#define MC_CMD_NVRAM_TEST_IN_TYPE_OFST 0 2324/* MC_CMD_NVRAM_TEST_IN msgrequest */
1712#define MC_CMD_NVRAM_TEST_OUT_LEN 4 2325#define MC_CMD_NVRAM_TEST_IN_LEN 4
1713#define MC_CMD_NVRAM_TEST_OUT_RESULT_OFST 0 2326#define MC_CMD_NVRAM_TEST_IN_TYPE_OFST 0
1714#define MC_CMD_NVRAM_TEST_PASS 0 2327/* Enum values, see field(s): */
1715#define MC_CMD_NVRAM_TEST_FAIL 1 2328/* MC_CMD_NVRAM_TYPES/MC_CMD_NVRAM_TYPES_OUT/TYPES */
1716#define MC_CMD_NVRAM_TEST_NOTSUPP 2 2329
1717 2330/* MC_CMD_NVRAM_TEST_OUT msgresponse */
1718/* MC_CMD_MRSFP_TWEAK: (debug) 2331#define MC_CMD_NVRAM_TEST_OUT_LEN 4
1719 * Read status and/or set parameters for the "mrsfp" driver in mr_rusty builds. 2332#define MC_CMD_NVRAM_TEST_OUT_RESULT_OFST 0
1720 * I2C I/O expander bits are always read; if equaliser parameters are supplied, 2333#define MC_CMD_NVRAM_TEST_PASS 0x0 /* enum */
1721 * they are configured first. 2334#define MC_CMD_NVRAM_TEST_FAIL 0x1 /* enum */
1722 * 2335#define MC_CMD_NVRAM_TEST_NOTSUPP 0x2 /* enum */
1723 * Locks required: None 2336
1724 * Return code: 0, EINVAL 2337
2338/***********************************/
2339/* MC_CMD_MRSFP_TWEAK
2340 * Read status and/or set parameters for the 'mrsfp' driver.
1725 */ 2341 */
1726#define MC_CMD_MRSFP_TWEAK 0x4d 2342#define MC_CMD_MRSFP_TWEAK 0x4d
1727#define MC_CMD_MRSFP_TWEAK_IN_LEN_READ_ONLY 0 2343
1728#define MC_CMD_MRSFP_TWEAK_IN_LEN_EQ_CONFIG 16 2344/* MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG msgrequest */
1729#define MC_CMD_MRSFP_TWEAK_IN_TXEQ_LEVEL_OFST 0 /* 0-6 low->high de-emph. */ 2345#define MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_LEN 16
1730#define MC_CMD_MRSFP_TWEAK_IN_TXEQ_DT_CFG_OFST 4 /* 0-8 low->high ref.V */ 2346#define MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_TXEQ_LEVEL_OFST 0
1731#define MC_CMD_MRSFP_TWEAK_IN_RXEQ_BOOST_OFST 8 /* 0-8 low->high boost */ 2347#define MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_TXEQ_DT_CFG_OFST 4
1732#define MC_CMD_MRSFP_TWEAK_IN_RXEQ_DT_CFG_OFST 12 /* 0-8 low->high ref.V */ 2348#define MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_RXEQ_BOOST_OFST 8
1733#define MC_CMD_MRSFP_TWEAK_OUT_LEN 12 2349#define MC_CMD_MRSFP_TWEAK_IN_EQ_CONFIG_RXEQ_DT_CFG_OFST 12
1734#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_INPUTS_OFST 0 /* input bits */ 2350
1735#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_OUTPUTS_OFST 4 /* output bits */ 2351/* MC_CMD_MRSFP_TWEAK_IN_READ_ONLY msgrequest */
1736#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_OFST 8 /* dirs: 0=out, 1=in */ 2352#define MC_CMD_MRSFP_TWEAK_IN_READ_ONLY_LEN 0
1737 2353
1738/* MC_CMD_TEST_HACK: (debug (unsurprisingly)) 2354/* MC_CMD_MRSFP_TWEAK_OUT msgresponse */
1739 * Change bits of network port state for test purposes in ways that would never be 2355#define MC_CMD_MRSFP_TWEAK_OUT_LEN 12
1740 * useful in normal operation and so need a special command to change. */ 2356#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_INPUTS_OFST 0
1741#define MC_CMD_TEST_HACK 0x2f 2357#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_OUTPUTS_OFST 4
1742#define MC_CMD_TEST_HACK_IN_LEN 8 2358#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_OFST 8
1743#define MC_CMD_TEST_HACK_IN_TXPAD_OFST 0 2359#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_OUT 0x0 /* enum */
1744#define MC_CMD_TEST_HACK_IN_TXPAD_AUTO 0 /* Let the MC manage things */ 2360#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_IN 0x1 /* enum */
1745#define MC_CMD_TEST_HACK_IN_TXPAD_ON 1 /* Force on */ 2361
1746#define MC_CMD_TEST_HACK_IN_TXPAD_OFF 2 /* Force on */ 2362
1747#define MC_CMD_TEST_HACK_IN_IPG_OFST 4 /* Takes a value in bits */ 2363/***********************************/
1748#define MC_CMD_TEST_HACK_IN_IPG_AUTO 0 /* The MC picks the value */ 2364/* MC_CMD_SENSOR_SET_LIMS
1749#define MC_CMD_TEST_HACK_OUT_LEN 0 2365 * Adjusts the sensor limits.
1750
1751/* MC_CMD_SENSOR_SET_LIMS: (debug) (mostly) adjust the sensor limits. This
1752 * is a warranty-voiding operation.
1753 *
1754 * IN: sensor identifier (one of the enumeration starting with MC_CMD_SENSOR_CONTROLLER_TEMP
1755 * followed by 4 32-bit values: min(warning) max(warning), min(fatal), max(fatal). Which
1756 * of these limits are meaningful and what their interpretation is is sensor-specific.
1757 *
1758 * OUT: nothing
1759 *
1760 * Returns: ENOENT if the sensor specified does not exist, EINVAL if the limits are
1761 * out of range.
1762 */ 2366 */
1763#define MC_CMD_SENSOR_SET_LIMS 0x4e 2367#define MC_CMD_SENSOR_SET_LIMS 0x4e
1764#define MC_CMD_SENSOR_SET_LIMS_IN_LEN 20 2368
1765#define MC_CMD_SENSOR_SET_LIMS_IN_SENSOR_OFST 0 2369/* MC_CMD_SENSOR_SET_LIMS_IN msgrequest */
1766#define MC_CMD_SENSOR_SET_LIMS_IN_LOW0_OFST 4 2370#define MC_CMD_SENSOR_SET_LIMS_IN_LEN 20
1767#define MC_CMD_SENSOR_SET_LIMS_IN_HI0_OFST 8 2371#define MC_CMD_SENSOR_SET_LIMS_IN_SENSOR_OFST 0
1768#define MC_CMD_SENSOR_SET_LIMS_IN_LOW1_OFST 12 2372/* Enum values, see field(s): */
1769#define MC_CMD_SENSOR_SET_LIMS_IN_HI1_OFST 16 2373/* MC_CMD_SENSOR_INFO/MC_CMD_SENSOR_INFO_OUT/MASK */
1770 2374#define MC_CMD_SENSOR_SET_LIMS_IN_LOW0_OFST 4
1771/* Do NOT add new commands beyond 0x4f as part of 3.0 : 0x50 - 0x7f will be 2375#define MC_CMD_SENSOR_SET_LIMS_IN_HI0_OFST 8
1772 * used for post-3.0 extensions. If you run out of space, look for gaps or 2376#define MC_CMD_SENSOR_SET_LIMS_IN_LOW1_OFST 12
1773 * commands that are unused in the existing range. */ 2377#define MC_CMD_SENSOR_SET_LIMS_IN_HI1_OFST 16
2378
2379/* MC_CMD_SENSOR_SET_LIMS_OUT msgresponse */
2380#define MC_CMD_SENSOR_SET_LIMS_OUT_LEN 0
2381
2382
2383/***********************************/
2384/* MC_CMD_GET_RESOURCE_LIMITS
2385 */
2386#define MC_CMD_GET_RESOURCE_LIMITS 0x4f
2387
2388/* MC_CMD_GET_RESOURCE_LIMITS_IN msgrequest */
2389#define MC_CMD_GET_RESOURCE_LIMITS_IN_LEN 0
2390
2391/* MC_CMD_GET_RESOURCE_LIMITS_OUT msgresponse */
2392#define MC_CMD_GET_RESOURCE_LIMITS_OUT_LEN 16
2393#define MC_CMD_GET_RESOURCE_LIMITS_OUT_BUFTBL_OFST 0
2394#define MC_CMD_GET_RESOURCE_LIMITS_OUT_EVQ_OFST 4
2395#define MC_CMD_GET_RESOURCE_LIMITS_OUT_RXQ_OFST 8
2396#define MC_CMD_GET_RESOURCE_LIMITS_OUT_TXQ_OFST 12
2397
2398/* MC_CMD_RESOURCE_SPECIFIER enum */
2399#define MC_CMD_RESOURCE_INSTANCE_ANY 0xffffffff /* enum */
2400#define MC_CMD_RESOURCE_INSTANCE_NONE 0xfffffffe /* enum */
2401
1774 2402
1775#endif /* MCDI_PCOL_H */ 2403#endif /* MCDI_PCOL_H */
diff --git a/drivers/net/ethernet/sfc/mcdi_phy.c b/drivers/net/ethernet/sfc/mcdi_phy.c
index 6c63ab0710af..7bcad899a936 100644
--- a/drivers/net/ethernet/sfc/mcdi_phy.c
+++ b/drivers/net/ethernet/sfc/mcdi_phy.c
@@ -116,7 +116,7 @@ static int efx_mcdi_loopback_modes(struct efx_nic *efx, u64 *loopback_modes)
116 goto fail; 116 goto fail;
117 } 117 }
118 118
119 *loopback_modes = MCDI_QWORD(outbuf, GET_LOOPBACK_MODES_SUGGESTED); 119 *loopback_modes = MCDI_QWORD(outbuf, GET_LOOPBACK_MODES_OUT_SUGGESTED);
120 120
121 return 0; 121 return 0;
122 122
@@ -264,22 +264,22 @@ static u32 efx_get_mcdi_phy_flags(struct efx_nic *efx)
264 264
265 /* TODO: Advertise the capabilities supported by this PHY */ 265 /* TODO: Advertise the capabilities supported by this PHY */
266 supported = 0; 266 supported = 0;
267 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_TXDIS_LBN)) 267 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_TXDIS_LBN))
268 supported |= PHY_MODE_TX_DISABLED; 268 supported |= PHY_MODE_TX_DISABLED;
269 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_LOWPOWER_LBN)) 269 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_LOWPOWER_LBN))
270 supported |= PHY_MODE_LOW_POWER; 270 supported |= PHY_MODE_LOW_POWER;
271 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_POWEROFF_LBN)) 271 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_POWEROFF_LBN))
272 supported |= PHY_MODE_OFF; 272 supported |= PHY_MODE_OFF;
273 273
274 mode = efx->phy_mode & supported; 274 mode = efx->phy_mode & supported;
275 275
276 flags = 0; 276 flags = 0;
277 if (mode & PHY_MODE_TX_DISABLED) 277 if (mode & PHY_MODE_TX_DISABLED)
278 flags |= (1 << MC_CMD_SET_LINK_TXDIS_LBN); 278 flags |= (1 << MC_CMD_SET_LINK_IN_TXDIS_LBN);
279 if (mode & PHY_MODE_LOW_POWER) 279 if (mode & PHY_MODE_LOW_POWER)
280 flags |= (1 << MC_CMD_SET_LINK_LOWPOWER_LBN); 280 flags |= (1 << MC_CMD_SET_LINK_IN_LOWPOWER_LBN);
281 if (mode & PHY_MODE_OFF) 281 if (mode & PHY_MODE_OFF)
282 flags |= (1 << MC_CMD_SET_LINK_POWEROFF_LBN); 282 flags |= (1 << MC_CMD_SET_LINK_IN_POWEROFF_LBN);
283 283
284 return flags; 284 return flags;
285} 285}
@@ -436,8 +436,8 @@ void efx_mcdi_phy_decode_link(struct efx_nic *efx,
436 break; 436 break;
437 } 437 }
438 438
439 link_state->up = !!(flags & (1 << MC_CMD_GET_LINK_LINK_UP_LBN)); 439 link_state->up = !!(flags & (1 << MC_CMD_GET_LINK_OUT_LINK_UP_LBN));
440 link_state->fd = !!(flags & (1 << MC_CMD_GET_LINK_FULL_DUPLEX_LBN)); 440 link_state->fd = !!(flags & (1 << MC_CMD_GET_LINK_OUT_FULL_DUPLEX_LBN));
441 link_state->speed = speed; 441 link_state->speed = speed;
442} 442}
443 443
@@ -592,7 +592,7 @@ static int efx_mcdi_phy_test_alive(struct efx_nic *efx)
592 592
593 if (outlen < MC_CMD_GET_PHY_STATE_OUT_LEN) 593 if (outlen < MC_CMD_GET_PHY_STATE_OUT_LEN)
594 return -EIO; 594 return -EIO;
595 if (MCDI_DWORD(outbuf, GET_PHY_STATE_STATE) != MC_CMD_PHY_STATE_OK) 595 if (MCDI_DWORD(outbuf, GET_PHY_STATE_OUT_STATE) != MC_CMD_PHY_STATE_OK)
596 return -EINVAL; 596 return -EINVAL;
597 597
598 return 0; 598 return 0;
@@ -680,7 +680,7 @@ static int efx_mcdi_phy_run_tests(struct efx_nic *efx, int *results,
680 u32 mode; 680 u32 mode;
681 int rc; 681 int rc;
682 682
683 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_BIST_LBN)) { 683 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_LBN)) {
684 rc = efx_mcdi_bist(efx, MC_CMD_PHY_BIST, results); 684 rc = efx_mcdi_bist(efx, MC_CMD_PHY_BIST, results);
685 if (rc < 0) 685 if (rc < 0)
686 return rc; 686 return rc;
@@ -691,15 +691,15 @@ static int efx_mcdi_phy_run_tests(struct efx_nic *efx, int *results,
691 /* If we support both LONG and SHORT, then run each in response to 691 /* If we support both LONG and SHORT, then run each in response to
692 * break or not. Otherwise, run the one we support */ 692 * break or not. Otherwise, run the one we support */
693 mode = 0; 693 mode = 0;
694 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_BIST_CABLE_SHORT_LBN)) { 694 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_LBN)) {
695 if ((flags & ETH_TEST_FL_OFFLINE) && 695 if ((flags & ETH_TEST_FL_OFFLINE) &&
696 (phy_cfg->flags & 696 (phy_cfg->flags &
697 (1 << MC_CMD_GET_PHY_CFG_BIST_CABLE_LONG_LBN))) 697 (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN)))
698 mode = MC_CMD_PHY_BIST_CABLE_LONG; 698 mode = MC_CMD_PHY_BIST_CABLE_LONG;
699 else 699 else
700 mode = MC_CMD_PHY_BIST_CABLE_SHORT; 700 mode = MC_CMD_PHY_BIST_CABLE_SHORT;
701 } else if (phy_cfg->flags & 701 } else if (phy_cfg->flags &
702 (1 << MC_CMD_GET_PHY_CFG_BIST_CABLE_LONG_LBN)) 702 (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN))
703 mode = MC_CMD_PHY_BIST_CABLE_LONG; 703 mode = MC_CMD_PHY_BIST_CABLE_LONG;
704 704
705 if (mode != 0) { 705 if (mode != 0) {
@@ -717,14 +717,14 @@ static const char *efx_mcdi_phy_test_name(struct efx_nic *efx,
717{ 717{
718 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data; 718 struct efx_mcdi_phy_data *phy_cfg = efx->phy_data;
719 719
720 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_BIST_LBN)) { 720 if (phy_cfg->flags & (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_LBN)) {
721 if (index == 0) 721 if (index == 0)
722 return "bist"; 722 return "bist";
723 --index; 723 --index;
724 } 724 }
725 725
726 if (phy_cfg->flags & ((1 << MC_CMD_GET_PHY_CFG_BIST_CABLE_SHORT_LBN) | 726 if (phy_cfg->flags & ((1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_SHORT_LBN) |
727 (1 << MC_CMD_GET_PHY_CFG_BIST_CABLE_LONG_LBN))) { 727 (1 << MC_CMD_GET_PHY_CFG_OUT_BIST_CABLE_LONG_LBN))) {
728 if (index == 0) 728 if (index == 0)
729 return "cable"; 729 return "cable";
730 --index; 730 --index;
@@ -741,7 +741,7 @@ static const char *efx_mcdi_phy_test_name(struct efx_nic *efx,
741 741
742const struct efx_phy_operations efx_mcdi_phy_ops = { 742const struct efx_phy_operations efx_mcdi_phy_ops = {
743 .probe = efx_mcdi_phy_probe, 743 .probe = efx_mcdi_phy_probe,
744 .init = efx_port_dummy_op_int, 744 .init = efx_port_dummy_op_int,
745 .reconfigure = efx_mcdi_phy_reconfigure, 745 .reconfigure = efx_mcdi_phy_reconfigure,
746 .poll = efx_mcdi_phy_poll, 746 .poll = efx_mcdi_phy_poll,
747 .fini = efx_port_dummy_op_void, 747 .fini = efx_port_dummy_op_void,
diff --git a/drivers/net/ethernet/sfc/mdio_10g.c b/drivers/net/ethernet/sfc/mdio_10g.c
index 7ab385c8136d..9acfd6696ffb 100644
--- a/drivers/net/ethernet/sfc/mdio_10g.c
+++ b/drivers/net/ethernet/sfc/mdio_10g.c
@@ -228,7 +228,7 @@ void efx_mdio_set_mmds_lpower(struct efx_nic *efx,
228/** 228/**
229 * efx_mdio_set_settings - Set (some of) the PHY settings over MDIO. 229 * efx_mdio_set_settings - Set (some of) the PHY settings over MDIO.
230 * @efx: Efx NIC 230 * @efx: Efx NIC
231 * @ecmd: New settings 231 * @ecmd: New settings
232 */ 232 */
233int efx_mdio_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) 233int efx_mdio_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
234{ 234{
diff --git a/drivers/net/ethernet/sfc/mtd.c b/drivers/net/ethernet/sfc/mtd.c
index bc9dcd6b30d7..79c192272047 100644
--- a/drivers/net/ethernet/sfc/mtd.c
+++ b/drivers/net/ethernet/sfc/mtd.c
@@ -382,7 +382,7 @@ static int falcon_mtd_sync(struct mtd_info *mtd)
382 return rc; 382 return rc;
383} 383}
384 384
385static struct efx_mtd_ops falcon_mtd_ops = { 385static const struct efx_mtd_ops falcon_mtd_ops = {
386 .read = falcon_mtd_read, 386 .read = falcon_mtd_read,
387 .erase = falcon_mtd_erase, 387 .erase = falcon_mtd_erase,
388 .write = falcon_mtd_write, 388 .write = falcon_mtd_write,
@@ -560,7 +560,7 @@ static int siena_mtd_sync(struct mtd_info *mtd)
560 return rc; 560 return rc;
561} 561}
562 562
563static struct efx_mtd_ops siena_mtd_ops = { 563static const struct efx_mtd_ops siena_mtd_ops = {
564 .read = siena_mtd_read, 564 .read = siena_mtd_read,
565 .erase = siena_mtd_erase, 565 .erase = siena_mtd_erase,
566 .write = siena_mtd_write, 566 .write = siena_mtd_write,
@@ -572,7 +572,7 @@ struct siena_nvram_type_info {
572 const char *name; 572 const char *name;
573}; 573};
574 574
575static struct siena_nvram_type_info siena_nvram_types[] = { 575static const struct siena_nvram_type_info siena_nvram_types[] = {
576 [MC_CMD_NVRAM_TYPE_DISABLED_CALLISTO] = { 0, "sfc_dummy_phy" }, 576 [MC_CMD_NVRAM_TYPE_DISABLED_CALLISTO] = { 0, "sfc_dummy_phy" },
577 [MC_CMD_NVRAM_TYPE_MC_FW] = { 0, "sfc_mcfw" }, 577 [MC_CMD_NVRAM_TYPE_MC_FW] = { 0, "sfc_mcfw" },
578 [MC_CMD_NVRAM_TYPE_MC_FW_BACKUP] = { 0, "sfc_mcfw_backup" }, 578 [MC_CMD_NVRAM_TYPE_MC_FW_BACKUP] = { 0, "sfc_mcfw_backup" },
@@ -593,7 +593,7 @@ static int siena_mtd_probe_partition(struct efx_nic *efx,
593 unsigned int type) 593 unsigned int type)
594{ 594{
595 struct efx_mtd_partition *part = &efx_mtd->part[part_id]; 595 struct efx_mtd_partition *part = &efx_mtd->part[part_id];
596 struct siena_nvram_type_info *info; 596 const struct siena_nvram_type_info *info;
597 size_t size, erase_size; 597 size_t size, erase_size;
598 bool protected; 598 bool protected;
599 int rc; 599 int rc;
@@ -627,11 +627,10 @@ static int siena_mtd_get_fw_subtypes(struct efx_nic *efx,
627 struct efx_mtd *efx_mtd) 627 struct efx_mtd *efx_mtd)
628{ 628{
629 struct efx_mtd_partition *part; 629 struct efx_mtd_partition *part;
630 uint16_t fw_subtype_list[MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_LEN / 630 uint16_t fw_subtype_list[MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MINNUM];
631 sizeof(uint16_t)];
632 int rc; 631 int rc;
633 632
634 rc = efx_mcdi_get_board_cfg(efx, NULL, fw_subtype_list); 633 rc = efx_mcdi_get_board_cfg(efx, NULL, fw_subtype_list, NULL);
635 if (rc) 634 if (rc)
636 return rc; 635 return rc;
637 636
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h
index c49502bab6a3..53864014c2b4 100644
--- a/drivers/net/ethernet/sfc/net_driver.h
+++ b/drivers/net/ethernet/sfc/net_driver.h
@@ -13,10 +13,6 @@
13#ifndef EFX_NET_DRIVER_H 13#ifndef EFX_NET_DRIVER_H
14#define EFX_NET_DRIVER_H 14#define EFX_NET_DRIVER_H
15 15
16#if defined(EFX_ENABLE_DEBUG) && !defined(DEBUG)
17#define DEBUG
18#endif
19
20#include <linux/netdevice.h> 16#include <linux/netdevice.h>
21#include <linux/etherdevice.h> 17#include <linux/etherdevice.h>
22#include <linux/ethtool.h> 18#include <linux/ethtool.h>
@@ -42,7 +38,7 @@
42 38
43#define EFX_DRIVER_VERSION "3.1" 39#define EFX_DRIVER_VERSION "3.1"
44 40
45#ifdef EFX_ENABLE_DEBUG 41#ifdef DEBUG
46#define EFX_BUG_ON_PARANOID(x) BUG_ON(x) 42#define EFX_BUG_ON_PARANOID(x) BUG_ON(x)
47#define EFX_WARN_ON_PARANOID(x) WARN_ON(x) 43#define EFX_WARN_ON_PARANOID(x) WARN_ON(x)
48#else 44#else
@@ -209,12 +205,12 @@ struct efx_tx_queue {
209/** 205/**
210 * struct efx_rx_buffer - An Efx RX data buffer 206 * struct efx_rx_buffer - An Efx RX data buffer
211 * @dma_addr: DMA base address of the buffer 207 * @dma_addr: DMA base address of the buffer
212 * @skb: The associated socket buffer, if any. 208 * @skb: The associated socket buffer. Valid iff !(@flags & %EFX_RX_BUF_PAGE).
213 * If both this and page are %NULL, the buffer slot is currently free. 209 * Will be %NULL if the buffer slot is currently free.
214 * @page: The associated page buffer, if any. 210 * @page: The associated page buffer. Valif iff @flags & %EFX_RX_BUF_PAGE.
215 * If both this and skb are %NULL, the buffer slot is currently free. 211 * Will be %NULL if the buffer slot is currently free.
216 * @len: Buffer length, in bytes. 212 * @len: Buffer length, in bytes.
217 * @is_page: Indicates if @page is valid. If false, @skb is valid. 213 * @flags: Flags for buffer and packet state.
218 */ 214 */
219struct efx_rx_buffer { 215struct efx_rx_buffer {
220 dma_addr_t dma_addr; 216 dma_addr_t dma_addr;
@@ -223,8 +219,11 @@ struct efx_rx_buffer {
223 struct page *page; 219 struct page *page;
224 } u; 220 } u;
225 unsigned int len; 221 unsigned int len;
226 bool is_page; 222 u16 flags;
227}; 223};
224#define EFX_RX_BUF_PAGE 0x0001
225#define EFX_RX_PKT_CSUMMED 0x0002
226#define EFX_RX_PKT_DISCARD 0x0004
228 227
229/** 228/**
230 * struct efx_rx_page_state - Page-based rx buffer state 229 * struct efx_rx_page_state - Page-based rx buffer state
@@ -329,6 +328,7 @@ enum efx_rx_alloc_method {
329 * @eventq_mask: Event queue pointer mask 328 * @eventq_mask: Event queue pointer mask
330 * @eventq_read_ptr: Event queue read pointer 329 * @eventq_read_ptr: Event queue read pointer
331 * @last_eventq_read_ptr: Last event queue read pointer value. 330 * @last_eventq_read_ptr: Last event queue read pointer value.
331 * @last_irq_cpu: Last CPU to handle interrupt for this channel
332 * @irq_count: Number of IRQs since last adaptive moderation decision 332 * @irq_count: Number of IRQs since last adaptive moderation decision
333 * @irq_mod_score: IRQ moderation score 333 * @irq_mod_score: IRQ moderation score
334 * @rx_alloc_level: Watermark based heuristic counter for pushing descriptors 334 * @rx_alloc_level: Watermark based heuristic counter for pushing descriptors
@@ -359,6 +359,7 @@ struct efx_channel {
359 unsigned int eventq_read_ptr; 359 unsigned int eventq_read_ptr;
360 unsigned int last_eventq_read_ptr; 360 unsigned int last_eventq_read_ptr;
361 361
362 int last_irq_cpu;
362 unsigned int irq_count; 363 unsigned int irq_count;
363 unsigned int irq_mod_score; 364 unsigned int irq_mod_score;
364#ifdef CONFIG_RFS_ACCEL 365#ifdef CONFIG_RFS_ACCEL
@@ -380,7 +381,6 @@ struct efx_channel {
380 * access with prefetches. 381 * access with prefetches.
381 */ 382 */
382 struct efx_rx_buffer *rx_pkt; 383 struct efx_rx_buffer *rx_pkt;
383 bool rx_pkt_csummed;
384 384
385 struct efx_rx_queue rx_queue; 385 struct efx_rx_queue rx_queue;
386 struct efx_tx_queue tx_queue[EFX_TXQ_TYPES]; 386 struct efx_tx_queue tx_queue[EFX_TXQ_TYPES];
@@ -395,12 +395,12 @@ enum efx_led_mode {
395#define STRING_TABLE_LOOKUP(val, member) \ 395#define STRING_TABLE_LOOKUP(val, member) \
396 ((val) < member ## _max) ? member ## _names[val] : "(invalid)" 396 ((val) < member ## _max) ? member ## _names[val] : "(invalid)"
397 397
398extern const char *efx_loopback_mode_names[]; 398extern const char *const efx_loopback_mode_names[];
399extern const unsigned int efx_loopback_mode_max; 399extern const unsigned int efx_loopback_mode_max;
400#define LOOPBACK_MODE(efx) \ 400#define LOOPBACK_MODE(efx) \
401 STRING_TABLE_LOOKUP((efx)->loopback_mode, efx_loopback_mode) 401 STRING_TABLE_LOOKUP((efx)->loopback_mode, efx_loopback_mode)
402 402
403extern const char *efx_reset_type_names[]; 403extern const char *const efx_reset_type_names[];
404extern const unsigned int efx_reset_type_max; 404extern const unsigned int efx_reset_type_max;
405#define RESET_TYPE(type) \ 405#define RESET_TYPE(type) \
406 STRING_TABLE_LOOKUP(type, efx_reset_type) 406 STRING_TABLE_LOOKUP(type, efx_reset_type)
@@ -474,18 +474,6 @@ static inline bool efx_link_state_equal(const struct efx_link_state *left,
474} 474}
475 475
476/** 476/**
477 * struct efx_mac_operations - Efx MAC operations table
478 * @reconfigure: Reconfigure MAC. Serialised by the mac_lock
479 * @update_stats: Update statistics
480 * @check_fault: Check fault state. True if fault present.
481 */
482struct efx_mac_operations {
483 int (*reconfigure) (struct efx_nic *efx);
484 void (*update_stats) (struct efx_nic *efx);
485 bool (*check_fault)(struct efx_nic *efx);
486};
487
488/**
489 * struct efx_phy_operations - Efx PHY operations table 477 * struct efx_phy_operations - Efx PHY operations table
490 * @probe: Probe PHY and initialise efx->mdio.mode_support, efx->mdio.mmds, 478 * @probe: Probe PHY and initialise efx->mdio.mode_support, efx->mdio.mmds,
491 * efx->loopback_modes. 479 * efx->loopback_modes.
@@ -552,64 +540,64 @@ struct efx_mac_stats {
552 u64 tx_bytes; 540 u64 tx_bytes;
553 u64 tx_good_bytes; 541 u64 tx_good_bytes;
554 u64 tx_bad_bytes; 542 u64 tx_bad_bytes;
555 unsigned long tx_packets; 543 u64 tx_packets;
556 unsigned long tx_bad; 544 u64 tx_bad;
557 unsigned long tx_pause; 545 u64 tx_pause;
558 unsigned long tx_control; 546 u64 tx_control;
559 unsigned long tx_unicast; 547 u64 tx_unicast;
560 unsigned long tx_multicast; 548 u64 tx_multicast;
561 unsigned long tx_broadcast; 549 u64 tx_broadcast;
562 unsigned long tx_lt64; 550 u64 tx_lt64;
563 unsigned long tx_64; 551 u64 tx_64;
564 unsigned long tx_65_to_127; 552 u64 tx_65_to_127;
565 unsigned long tx_128_to_255; 553 u64 tx_128_to_255;
566 unsigned long tx_256_to_511; 554 u64 tx_256_to_511;
567 unsigned long tx_512_to_1023; 555 u64 tx_512_to_1023;
568 unsigned long tx_1024_to_15xx; 556 u64 tx_1024_to_15xx;
569 unsigned long tx_15xx_to_jumbo; 557 u64 tx_15xx_to_jumbo;
570 unsigned long tx_gtjumbo; 558 u64 tx_gtjumbo;
571 unsigned long tx_collision; 559 u64 tx_collision;
572 unsigned long tx_single_collision; 560 u64 tx_single_collision;
573 unsigned long tx_multiple_collision; 561 u64 tx_multiple_collision;
574 unsigned long tx_excessive_collision; 562 u64 tx_excessive_collision;
575 unsigned long tx_deferred; 563 u64 tx_deferred;
576 unsigned long tx_late_collision; 564 u64 tx_late_collision;
577 unsigned long tx_excessive_deferred; 565 u64 tx_excessive_deferred;
578 unsigned long tx_non_tcpudp; 566 u64 tx_non_tcpudp;
579 unsigned long tx_mac_src_error; 567 u64 tx_mac_src_error;
580 unsigned long tx_ip_src_error; 568 u64 tx_ip_src_error;
581 u64 rx_bytes; 569 u64 rx_bytes;
582 u64 rx_good_bytes; 570 u64 rx_good_bytes;
583 u64 rx_bad_bytes; 571 u64 rx_bad_bytes;
584 unsigned long rx_packets; 572 u64 rx_packets;
585 unsigned long rx_good; 573 u64 rx_good;
586 unsigned long rx_bad; 574 u64 rx_bad;
587 unsigned long rx_pause; 575 u64 rx_pause;
588 unsigned long rx_control; 576 u64 rx_control;
589 unsigned long rx_unicast; 577 u64 rx_unicast;
590 unsigned long rx_multicast; 578 u64 rx_multicast;
591 unsigned long rx_broadcast; 579 u64 rx_broadcast;
592 unsigned long rx_lt64; 580 u64 rx_lt64;
593 unsigned long rx_64; 581 u64 rx_64;
594 unsigned long rx_65_to_127; 582 u64 rx_65_to_127;
595 unsigned long rx_128_to_255; 583 u64 rx_128_to_255;
596 unsigned long rx_256_to_511; 584 u64 rx_256_to_511;
597 unsigned long rx_512_to_1023; 585 u64 rx_512_to_1023;
598 unsigned long rx_1024_to_15xx; 586 u64 rx_1024_to_15xx;
599 unsigned long rx_15xx_to_jumbo; 587 u64 rx_15xx_to_jumbo;
600 unsigned long rx_gtjumbo; 588 u64 rx_gtjumbo;
601 unsigned long rx_bad_lt64; 589 u64 rx_bad_lt64;
602 unsigned long rx_bad_64_to_15xx; 590 u64 rx_bad_64_to_15xx;
603 unsigned long rx_bad_15xx_to_jumbo; 591 u64 rx_bad_15xx_to_jumbo;
604 unsigned long rx_bad_gtjumbo; 592 u64 rx_bad_gtjumbo;
605 unsigned long rx_overflow; 593 u64 rx_overflow;
606 unsigned long rx_missed; 594 u64 rx_missed;
607 unsigned long rx_false_carrier; 595 u64 rx_false_carrier;
608 unsigned long rx_symbol_error; 596 u64 rx_symbol_error;
609 unsigned long rx_align_error; 597 u64 rx_align_error;
610 unsigned long rx_length_error; 598 u64 rx_length_error;
611 unsigned long rx_internal_error; 599 u64 rx_internal_error;
612 unsigned long rx_good_lt64; 600 u64 rx_good_lt64;
613}; 601};
614 602
615/* Number of bits used in a multicast filter hash address */ 603/* Number of bits used in a multicast filter hash address */
@@ -640,6 +628,7 @@ struct efx_filter_state;
640 * @membase_phys: Memory BAR value as physical address 628 * @membase_phys: Memory BAR value as physical address
641 * @membase: Memory BAR value 629 * @membase: Memory BAR value
642 * @interrupt_mode: Interrupt mode 630 * @interrupt_mode: Interrupt mode
631 * @timer_quantum_ns: Interrupt timer quantum, in nanoseconds
643 * @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues 632 * @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues
644 * @irq_rx_moderation: IRQ moderation time for RX event queues 633 * @irq_rx_moderation: IRQ moderation time for RX event queues
645 * @msg_enable: Log message enable flags 634 * @msg_enable: Log message enable flags
@@ -663,7 +652,7 @@ struct efx_filter_state;
663 * @int_error_expire: Time at which error count will be expired 652 * @int_error_expire: Time at which error count will be expired
664 * @irq_status: Interrupt status buffer 653 * @irq_status: Interrupt status buffer
665 * @irq_zero_count: Number of legacy IRQs seen with queue flags == 0 654 * @irq_zero_count: Number of legacy IRQs seen with queue flags == 0
666 * @fatal_irq_level: IRQ level (bit number) used for serious errors 655 * @irq_level: IRQ level/index for IRQs not triggered by an event queue
667 * @mtd_list: List of MTDs attached to the NIC 656 * @mtd_list: List of MTDs attached to the NIC
668 * @nic_data: Hardware dependent state 657 * @nic_data: Hardware dependent state
669 * @mac_lock: MAC access lock. Protects @port_enabled, @phy_mode, 658 * @mac_lock: MAC access lock. Protects @port_enabled, @phy_mode,
@@ -676,7 +665,6 @@ struct efx_filter_state;
676 * @port_initialized: Port initialized? 665 * @port_initialized: Port initialized?
677 * @net_dev: Operating system network device. Consider holding the rtnl lock 666 * @net_dev: Operating system network device. Consider holding the rtnl lock
678 * @stats_buffer: DMA buffer for statistics 667 * @stats_buffer: DMA buffer for statistics
679 * @mac_op: MAC interface
680 * @phy_type: PHY type 668 * @phy_type: PHY type
681 * @phy_op: PHY interface 669 * @phy_op: PHY interface
682 * @phy_data: PHY private data (including PHY-specific stats) 670 * @phy_data: PHY private data (including PHY-specific stats)
@@ -695,15 +683,15 @@ struct efx_filter_state;
695 * @loopback_selftest: Offline self-test private state 683 * @loopback_selftest: Offline self-test private state
696 * @monitor_work: Hardware monitor workitem 684 * @monitor_work: Hardware monitor workitem
697 * @biu_lock: BIU (bus interface unit) lock 685 * @biu_lock: BIU (bus interface unit) lock
698 * @last_irq_cpu: Last CPU to handle interrupt. 686 * @last_irq_cpu: Last CPU to handle a possible test interrupt. This
699 * This register is written with the SMP processor ID whenever an 687 * field is used by efx_test_interrupts() to verify that an
700 * interrupt is handled. It is used by efx_nic_test_interrupt() 688 * interrupt has occurred.
701 * to verify that an interrupt has occurred.
702 * @n_rx_nodesc_drop_cnt: RX no descriptor drop count 689 * @n_rx_nodesc_drop_cnt: RX no descriptor drop count
703 * @mac_stats: MAC statistics. These include all statistics the MACs 690 * @mac_stats: MAC statistics. These include all statistics the MACs
704 * can provide. Generic code converts these into a standard 691 * can provide. Generic code converts these into a standard
705 * &struct net_device_stats. 692 * &struct net_device_stats.
706 * @stats_lock: Statistics update lock. Serialises statistics fetches 693 * @stats_lock: Statistics update lock. Serialises statistics fetches
694 * and access to @mac_stats.
707 * 695 *
708 * This is stored in the private area of the &struct net_device. 696 * This is stored in the private area of the &struct net_device.
709 */ 697 */
@@ -722,6 +710,7 @@ struct efx_nic {
722 void __iomem *membase; 710 void __iomem *membase;
723 711
724 enum efx_int_mode interrupt_mode; 712 enum efx_int_mode interrupt_mode;
713 unsigned int timer_quantum_ns;
725 bool irq_rx_adaptive; 714 bool irq_rx_adaptive;
726 unsigned int irq_rx_moderation; 715 unsigned int irq_rx_moderation;
727 u32 msg_enable; 716 u32 msg_enable;
@@ -749,7 +738,7 @@ struct efx_nic {
749 738
750 struct efx_buffer irq_status; 739 struct efx_buffer irq_status;
751 unsigned irq_zero_count; 740 unsigned irq_zero_count;
752 unsigned fatal_irq_level; 741 unsigned irq_level;
753 742
754#ifdef CONFIG_SFC_MTD 743#ifdef CONFIG_SFC_MTD
755 struct list_head mtd_list; 744 struct list_head mtd_list;
@@ -766,8 +755,6 @@ struct efx_nic {
766 755
767 struct efx_buffer stats_buffer; 756 struct efx_buffer stats_buffer;
768 757
769 const struct efx_mac_operations *mac_op;
770
771 unsigned int phy_type; 758 unsigned int phy_type;
772 const struct efx_phy_operations *phy_op; 759 const struct efx_phy_operations *phy_op;
773 void *phy_data; 760 void *phy_data;
@@ -795,7 +782,7 @@ struct efx_nic {
795 782
796 struct delayed_work monitor_work ____cacheline_aligned_in_smp; 783 struct delayed_work monitor_work ____cacheline_aligned_in_smp;
797 spinlock_t biu_lock; 784 spinlock_t biu_lock;
798 volatile signed int last_irq_cpu; 785 int last_irq_cpu;
799 unsigned n_rx_nodesc_drop_cnt; 786 unsigned n_rx_nodesc_drop_cnt;
800 struct efx_mac_stats mac_stats; 787 struct efx_mac_stats mac_stats;
801 spinlock_t stats_lock; 788 spinlock_t stats_lock;
@@ -806,15 +793,6 @@ static inline int efx_dev_registered(struct efx_nic *efx)
806 return efx->net_dev->reg_state == NETREG_REGISTERED; 793 return efx->net_dev->reg_state == NETREG_REGISTERED;
807} 794}
808 795
809/* Net device name, for inclusion in log messages if it has been registered.
810 * Use efx->name not efx->net_dev->name so that races with (un)registration
811 * are harmless.
812 */
813static inline const char *efx_dev_name(struct efx_nic *efx)
814{
815 return efx_dev_registered(efx) ? efx->name : "";
816}
817
818static inline unsigned int efx_port_num(struct efx_nic *efx) 796static inline unsigned int efx_port_num(struct efx_nic *efx)
819{ 797{
820 return efx->net_dev->dev_id; 798 return efx->net_dev->dev_id;
@@ -840,14 +818,15 @@ static inline unsigned int efx_port_num(struct efx_nic *efx)
840 * @stop_stats: Stop the regular fetching of statistics 818 * @stop_stats: Stop the regular fetching of statistics
841 * @set_id_led: Set state of identifying LED or revert to automatic function 819 * @set_id_led: Set state of identifying LED or revert to automatic function
842 * @push_irq_moderation: Apply interrupt moderation value 820 * @push_irq_moderation: Apply interrupt moderation value
843 * @push_multicast_hash: Apply multicast hash table
844 * @reconfigure_port: Push loopback/power/txdis changes to the MAC and PHY 821 * @reconfigure_port: Push loopback/power/txdis changes to the MAC and PHY
822 * @reconfigure_mac: Push MAC address, MTU, flow control and filter settings
823 * to the hardware. Serialised by the mac_lock.
824 * @check_mac_fault: Check MAC fault state. True if fault present.
845 * @get_wol: Get WoL configuration from driver state 825 * @get_wol: Get WoL configuration from driver state
846 * @set_wol: Push WoL configuration to the NIC 826 * @set_wol: Push WoL configuration to the NIC
847 * @resume_wol: Synchronise WoL state between driver and MC (e.g. after resume) 827 * @resume_wol: Synchronise WoL state between driver and MC (e.g. after resume)
848 * @test_registers: Test read/write functionality of control registers 828 * @test_registers: Test read/write functionality of control registers
849 * @test_nvram: Test validity of NVRAM contents 829 * @test_nvram: Test validity of NVRAM contents
850 * @default_mac_ops: efx_mac_operations to set at startup
851 * @revision: Hardware architecture revision 830 * @revision: Hardware architecture revision
852 * @mem_map_size: Memory BAR mapped size 831 * @mem_map_size: Memory BAR mapped size
853 * @txd_ptr_tbl_base: TX descriptor ring base address 832 * @txd_ptr_tbl_base: TX descriptor ring base address
@@ -862,6 +841,7 @@ static inline unsigned int efx_port_num(struct efx_nic *efx)
862 * from &enum efx_init_mode. 841 * from &enum efx_init_mode.
863 * @phys_addr_channels: Number of channels with physically addressed 842 * @phys_addr_channels: Number of channels with physically addressed
864 * descriptors 843 * descriptors
844 * @timer_period_max: Maximum period of interrupt timer (in ticks)
865 * @tx_dc_base: Base address in SRAM of TX queue descriptor caches 845 * @tx_dc_base: Base address in SRAM of TX queue descriptor caches
866 * @rx_dc_base: Base address in SRAM of RX queue descriptor caches 846 * @rx_dc_base: Base address in SRAM of RX queue descriptor caches
867 * @offload_features: net_device feature flags for protocol offload 847 * @offload_features: net_device feature flags for protocol offload
@@ -885,14 +865,14 @@ struct efx_nic_type {
885 void (*stop_stats)(struct efx_nic *efx); 865 void (*stop_stats)(struct efx_nic *efx);
886 void (*set_id_led)(struct efx_nic *efx, enum efx_led_mode mode); 866 void (*set_id_led)(struct efx_nic *efx, enum efx_led_mode mode);
887 void (*push_irq_moderation)(struct efx_channel *channel); 867 void (*push_irq_moderation)(struct efx_channel *channel);
888 void (*push_multicast_hash)(struct efx_nic *efx);
889 int (*reconfigure_port)(struct efx_nic *efx); 868 int (*reconfigure_port)(struct efx_nic *efx);
869 int (*reconfigure_mac)(struct efx_nic *efx);
870 bool (*check_mac_fault)(struct efx_nic *efx);
890 void (*get_wol)(struct efx_nic *efx, struct ethtool_wolinfo *wol); 871 void (*get_wol)(struct efx_nic *efx, struct ethtool_wolinfo *wol);
891 int (*set_wol)(struct efx_nic *efx, u32 type); 872 int (*set_wol)(struct efx_nic *efx, u32 type);
892 void (*resume_wol)(struct efx_nic *efx); 873 void (*resume_wol)(struct efx_nic *efx);
893 int (*test_registers)(struct efx_nic *efx); 874 int (*test_registers)(struct efx_nic *efx);
894 int (*test_nvram)(struct efx_nic *efx); 875 int (*test_nvram)(struct efx_nic *efx);
895 const struct efx_mac_operations *default_mac_ops;
896 876
897 int revision; 877 int revision;
898 unsigned int mem_map_size; 878 unsigned int mem_map_size;
@@ -906,6 +886,7 @@ struct efx_nic_type {
906 unsigned int rx_buffer_padding; 886 unsigned int rx_buffer_padding;
907 unsigned int max_interrupt_mode; 887 unsigned int max_interrupt_mode;
908 unsigned int phys_addr_channels; 888 unsigned int phys_addr_channels;
889 unsigned int timer_period_max;
909 unsigned int tx_dc_base; 890 unsigned int tx_dc_base;
910 unsigned int rx_dc_base; 891 unsigned int rx_dc_base;
911 netdev_features_t offload_features; 892 netdev_features_t offload_features;
diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c
index 3edfbaf5f022..a43d1ca270c0 100644
--- a/drivers/net/ethernet/sfc/nic.c
+++ b/drivers/net/ethernet/sfc/nic.c
@@ -726,11 +726,9 @@ efx_handle_tx_event(struct efx_channel *channel, efx_qword_t *event)
726 tx_queue = efx_channel_get_tx_queue( 726 tx_queue = efx_channel_get_tx_queue(
727 channel, tx_ev_q_label % EFX_TXQ_TYPES); 727 channel, tx_ev_q_label % EFX_TXQ_TYPES);
728 728
729 if (efx_dev_registered(efx)) 729 netif_tx_lock(efx->net_dev);
730 netif_tx_lock(efx->net_dev);
731 efx_notify_tx_desc(tx_queue); 730 efx_notify_tx_desc(tx_queue);
732 if (efx_dev_registered(efx)) 731 netif_tx_unlock(efx->net_dev);
733 netif_tx_unlock(efx->net_dev);
734 } else if (EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_PKT_ERR) && 732 } else if (EFX_QWORD_FIELD(*event, FSF_AZ_TX_EV_PKT_ERR) &&
735 EFX_WORKAROUND_10727(efx)) { 733 EFX_WORKAROUND_10727(efx)) {
736 efx_schedule_reset(efx, RESET_TYPE_TX_DESC_FETCH); 734 efx_schedule_reset(efx, RESET_TYPE_TX_DESC_FETCH);
@@ -745,10 +743,8 @@ efx_handle_tx_event(struct efx_channel *channel, efx_qword_t *event)
745} 743}
746 744
747/* Detect errors included in the rx_evt_pkt_ok bit. */ 745/* Detect errors included in the rx_evt_pkt_ok bit. */
748static void efx_handle_rx_not_ok(struct efx_rx_queue *rx_queue, 746static u16 efx_handle_rx_not_ok(struct efx_rx_queue *rx_queue,
749 const efx_qword_t *event, 747 const efx_qword_t *event)
750 bool *rx_ev_pkt_ok,
751 bool *discard)
752{ 748{
753 struct efx_channel *channel = efx_rx_queue_channel(rx_queue); 749 struct efx_channel *channel = efx_rx_queue_channel(rx_queue);
754 struct efx_nic *efx = rx_queue->efx; 750 struct efx_nic *efx = rx_queue->efx;
@@ -793,15 +789,11 @@ static void efx_handle_rx_not_ok(struct efx_rx_queue *rx_queue,
793 ++channel->n_rx_tcp_udp_chksum_err; 789 ++channel->n_rx_tcp_udp_chksum_err;
794 } 790 }
795 791
796 /* The frame must be discarded if any of these are true. */
797 *discard = (rx_ev_eth_crc_err | rx_ev_frm_trunc | rx_ev_drib_nib |
798 rx_ev_tobe_disc | rx_ev_pause_frm);
799
800 /* TOBE_DISC is expected on unicast mismatches; don't print out an 792 /* TOBE_DISC is expected on unicast mismatches; don't print out an
801 * error message. FRM_TRUNC indicates RXDP dropped the packet due 793 * error message. FRM_TRUNC indicates RXDP dropped the packet due
802 * to a FIFO overflow. 794 * to a FIFO overflow.
803 */ 795 */
804#ifdef EFX_ENABLE_DEBUG 796#ifdef DEBUG
805 if (rx_ev_other_err && net_ratelimit()) { 797 if (rx_ev_other_err && net_ratelimit()) {
806 netif_dbg(efx, rx_err, efx->net_dev, 798 netif_dbg(efx, rx_err, efx->net_dev,
807 " RX queue %d unexpected RX event " 799 " RX queue %d unexpected RX event "
@@ -819,6 +811,11 @@ static void efx_handle_rx_not_ok(struct efx_rx_queue *rx_queue,
819 rx_ev_pause_frm ? " [PAUSE]" : ""); 811 rx_ev_pause_frm ? " [PAUSE]" : "");
820 } 812 }
821#endif 813#endif
814
815 /* The frame must be discarded if any of these are true. */
816 return (rx_ev_eth_crc_err | rx_ev_frm_trunc | rx_ev_drib_nib |
817 rx_ev_tobe_disc | rx_ev_pause_frm) ?
818 EFX_RX_PKT_DISCARD : 0;
822} 819}
823 820
824/* Handle receive events that are not in-order. */ 821/* Handle receive events that are not in-order. */
@@ -851,7 +848,8 @@ efx_handle_rx_event(struct efx_channel *channel, const efx_qword_t *event)
851 unsigned int rx_ev_desc_ptr, rx_ev_byte_cnt; 848 unsigned int rx_ev_desc_ptr, rx_ev_byte_cnt;
852 unsigned int rx_ev_hdr_type, rx_ev_mcast_pkt; 849 unsigned int rx_ev_hdr_type, rx_ev_mcast_pkt;
853 unsigned expected_ptr; 850 unsigned expected_ptr;
854 bool rx_ev_pkt_ok, discard = false, checksummed; 851 bool rx_ev_pkt_ok;
852 u16 flags;
855 struct efx_rx_queue *rx_queue; 853 struct efx_rx_queue *rx_queue;
856 854
857 /* Basic packet information */ 855 /* Basic packet information */
@@ -874,12 +872,11 @@ efx_handle_rx_event(struct efx_channel *channel, const efx_qword_t *event)
874 /* If packet is marked as OK and packet type is TCP/IP or 872 /* If packet is marked as OK and packet type is TCP/IP or
875 * UDP/IP, then we can rely on the hardware checksum. 873 * UDP/IP, then we can rely on the hardware checksum.
876 */ 874 */
877 checksummed = 875 flags = (rx_ev_hdr_type == FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_TCP ||
878 rx_ev_hdr_type == FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_TCP || 876 rx_ev_hdr_type == FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_UDP) ?
879 rx_ev_hdr_type == FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_UDP; 877 EFX_RX_PKT_CSUMMED : 0;
880 } else { 878 } else {
881 efx_handle_rx_not_ok(rx_queue, event, &rx_ev_pkt_ok, &discard); 879 flags = efx_handle_rx_not_ok(rx_queue, event);
882 checksummed = false;
883 } 880 }
884 881
885 /* Detect multicast packets that didn't match the filter */ 882 /* Detect multicast packets that didn't match the filter */
@@ -890,15 +887,14 @@ efx_handle_rx_event(struct efx_channel *channel, const efx_qword_t *event)
890 887
891 if (unlikely(!rx_ev_mcast_hash_match)) { 888 if (unlikely(!rx_ev_mcast_hash_match)) {
892 ++channel->n_rx_mcast_mismatch; 889 ++channel->n_rx_mcast_mismatch;
893 discard = true; 890 flags |= EFX_RX_PKT_DISCARD;
894 } 891 }
895 } 892 }
896 893
897 channel->irq_mod_score += 2; 894 channel->irq_mod_score += 2;
898 895
899 /* Handle received packet */ 896 /* Handle received packet */
900 efx_rx_packet(rx_queue, rx_ev_desc_ptr, rx_ev_byte_cnt, 897 efx_rx_packet(rx_queue, rx_ev_desc_ptr, rx_ev_byte_cnt, flags);
901 checksummed, discard);
902} 898}
903 899
904static void 900static void
@@ -1311,7 +1307,7 @@ static inline void efx_nic_interrupts(struct efx_nic *efx,
1311 efx_oword_t int_en_reg_ker; 1307 efx_oword_t int_en_reg_ker;
1312 1308
1313 EFX_POPULATE_OWORD_3(int_en_reg_ker, 1309 EFX_POPULATE_OWORD_3(int_en_reg_ker,
1314 FRF_AZ_KER_INT_LEVE_SEL, efx->fatal_irq_level, 1310 FRF_AZ_KER_INT_LEVE_SEL, efx->irq_level,
1315 FRF_AZ_KER_INT_KER, force, 1311 FRF_AZ_KER_INT_KER, force,
1316 FRF_AZ_DRV_INT_EN_KER, enabled); 1312 FRF_AZ_DRV_INT_EN_KER, enabled);
1317 efx_writeo(efx, &int_en_reg_ker, FR_AZ_INT_EN_KER); 1313 efx_writeo(efx, &int_en_reg_ker, FR_AZ_INT_EN_KER);
@@ -1427,11 +1423,12 @@ static irqreturn_t efx_legacy_interrupt(int irq, void *dev_id)
1427 efx_readd(efx, &reg, FR_BZ_INT_ISR0); 1423 efx_readd(efx, &reg, FR_BZ_INT_ISR0);
1428 queues = EFX_EXTRACT_DWORD(reg, 0, 31); 1424 queues = EFX_EXTRACT_DWORD(reg, 0, 31);
1429 1425
1430 /* Check to see if we have a serious error condition */ 1426 /* Handle non-event-queue sources */
1431 if (queues & (1U << efx->fatal_irq_level)) { 1427 if (queues & (1U << efx->irq_level)) {
1432 syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT); 1428 syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT);
1433 if (unlikely(syserr)) 1429 if (unlikely(syserr))
1434 return efx_nic_fatal_interrupt(efx); 1430 return efx_nic_fatal_interrupt(efx);
1431 efx->last_irq_cpu = raw_smp_processor_id();
1435 } 1432 }
1436 1433
1437 if (queues != 0) { 1434 if (queues != 0) {
@@ -1441,7 +1438,7 @@ static irqreturn_t efx_legacy_interrupt(int irq, void *dev_id)
1441 /* Schedule processing of any interrupting queues */ 1438 /* Schedule processing of any interrupting queues */
1442 efx_for_each_channel(channel, efx) { 1439 efx_for_each_channel(channel, efx) {
1443 if (queues & 1) 1440 if (queues & 1)
1444 efx_schedule_channel(channel); 1441 efx_schedule_channel_irq(channel);
1445 queues >>= 1; 1442 queues >>= 1;
1446 } 1443 }
1447 result = IRQ_HANDLED; 1444 result = IRQ_HANDLED;
@@ -1458,18 +1455,16 @@ static irqreturn_t efx_legacy_interrupt(int irq, void *dev_id)
1458 efx_for_each_channel(channel, efx) { 1455 efx_for_each_channel(channel, efx) {
1459 event = efx_event(channel, channel->eventq_read_ptr); 1456 event = efx_event(channel, channel->eventq_read_ptr);
1460 if (efx_event_present(event)) 1457 if (efx_event_present(event))
1461 efx_schedule_channel(channel); 1458 efx_schedule_channel_irq(channel);
1462 else 1459 else
1463 efx_nic_eventq_read_ack(channel); 1460 efx_nic_eventq_read_ack(channel);
1464 } 1461 }
1465 } 1462 }
1466 1463
1467 if (result == IRQ_HANDLED) { 1464 if (result == IRQ_HANDLED)
1468 efx->last_irq_cpu = raw_smp_processor_id();
1469 netif_vdbg(efx, intr, efx->net_dev, 1465 netif_vdbg(efx, intr, efx->net_dev,
1470 "IRQ %d on CPU %d status " EFX_DWORD_FMT "\n", 1466 "IRQ %d on CPU %d status " EFX_DWORD_FMT "\n",
1471 irq, raw_smp_processor_id(), EFX_DWORD_VAL(reg)); 1467 irq, raw_smp_processor_id(), EFX_DWORD_VAL(reg));
1472 }
1473 1468
1474 return result; 1469 return result;
1475} 1470}
@@ -1488,20 +1483,20 @@ static irqreturn_t efx_msi_interrupt(int irq, void *dev_id)
1488 efx_oword_t *int_ker = efx->irq_status.addr; 1483 efx_oword_t *int_ker = efx->irq_status.addr;
1489 int syserr; 1484 int syserr;
1490 1485
1491 efx->last_irq_cpu = raw_smp_processor_id();
1492 netif_vdbg(efx, intr, efx->net_dev, 1486 netif_vdbg(efx, intr, efx->net_dev,
1493 "IRQ %d on CPU %d status " EFX_OWORD_FMT "\n", 1487 "IRQ %d on CPU %d status " EFX_OWORD_FMT "\n",
1494 irq, raw_smp_processor_id(), EFX_OWORD_VAL(*int_ker)); 1488 irq, raw_smp_processor_id(), EFX_OWORD_VAL(*int_ker));
1495 1489
1496 /* Check to see if we have a serious error condition */ 1490 /* Handle non-event-queue sources */
1497 if (channel->channel == efx->fatal_irq_level) { 1491 if (channel->channel == efx->irq_level) {
1498 syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT); 1492 syserr = EFX_OWORD_FIELD(*int_ker, FSF_AZ_NET_IVEC_FATAL_INT);
1499 if (unlikely(syserr)) 1493 if (unlikely(syserr))
1500 return efx_nic_fatal_interrupt(efx); 1494 return efx_nic_fatal_interrupt(efx);
1495 efx->last_irq_cpu = raw_smp_processor_id();
1501 } 1496 }
1502 1497
1503 /* Schedule processing of the channel */ 1498 /* Schedule processing of the channel */
1504 efx_schedule_channel(channel); 1499 efx_schedule_channel_irq(channel);
1505 1500
1506 return IRQ_HANDLED; 1501 return IRQ_HANDLED;
1507} 1502}
@@ -1640,10 +1635,10 @@ void efx_nic_init_common(struct efx_nic *efx)
1640 1635
1641 if (EFX_WORKAROUND_17213(efx) && !EFX_INT_MODE_USE_MSI(efx)) 1636 if (EFX_WORKAROUND_17213(efx) && !EFX_INT_MODE_USE_MSI(efx))
1642 /* Use an interrupt level unused by event queues */ 1637 /* Use an interrupt level unused by event queues */
1643 efx->fatal_irq_level = 0x1f; 1638 efx->irq_level = 0x1f;
1644 else 1639 else
1645 /* Use a valid MSI-X vector */ 1640 /* Use a valid MSI-X vector */
1646 efx->fatal_irq_level = 0; 1641 efx->irq_level = 0;
1647 1642
1648 /* Enable all the genuinely fatal interrupts. (They are still 1643 /* Enable all the genuinely fatal interrupts. (They are still
1649 * masked by the overall interrupt mask, controlled by 1644 * masked by the overall interrupt mask, controlled by
@@ -1837,7 +1832,7 @@ struct efx_nic_reg_table {
1837 REGISTER_REVISION_ ## min_rev, REGISTER_REVISION_ ## max_rev, \ 1832 REGISTER_REVISION_ ## min_rev, REGISTER_REVISION_ ## max_rev, \
1838 step, rows \ 1833 step, rows \
1839} 1834}
1840#define REGISTER_TABLE(name, min_rev, max_rev) \ 1835#define REGISTER_TABLE(name, min_rev, max_rev) \
1841 REGISTER_TABLE_DIMENSIONS( \ 1836 REGISTER_TABLE_DIMENSIONS( \
1842 name, FR_ ## min_rev ## max_rev ## _ ## name, \ 1837 name, FR_ ## min_rev ## max_rev ## _ ## name, \
1843 min_rev, max_rev, \ 1838 min_rev, max_rev, \
diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h
index 5fb24d3aa3ca..905a1877d603 100644
--- a/drivers/net/ethernet/sfc/nic.h
+++ b/drivers/net/ethernet/sfc/nic.h
@@ -144,12 +144,26 @@ static inline struct falcon_board *falcon_board(struct efx_nic *efx)
144 * struct siena_nic_data - Siena NIC state 144 * struct siena_nic_data - Siena NIC state
145 * @mcdi: Management-Controller-to-Driver Interface 145 * @mcdi: Management-Controller-to-Driver Interface
146 * @wol_filter_id: Wake-on-LAN packet filter id 146 * @wol_filter_id: Wake-on-LAN packet filter id
147 * @hwmon: Hardware monitor state
147 */ 148 */
148struct siena_nic_data { 149struct siena_nic_data {
149 struct efx_mcdi_iface mcdi; 150 struct efx_mcdi_iface mcdi;
150 int wol_filter_id; 151 int wol_filter_id;
152#ifdef CONFIG_SFC_MCDI_MON
153 struct efx_mcdi_mon hwmon;
154#endif
151}; 155};
152 156
157#ifdef CONFIG_SFC_MCDI_MON
158static inline struct efx_mcdi_mon *efx_mcdi_mon(struct efx_nic *efx)
159{
160 struct siena_nic_data *nic_data;
161 EFX_BUG_ON_PARANOID(efx_nic_rev(efx) < EFX_REV_SIENA_A0);
162 nic_data = efx->nic_data;
163 return &nic_data->hwmon;
164}
165#endif
166
153extern const struct efx_nic_type falcon_a1_nic_type; 167extern const struct efx_nic_type falcon_a1_nic_type;
154extern const struct efx_nic_type falcon_b0_nic_type; 168extern const struct efx_nic_type falcon_b0_nic_type;
155extern const struct efx_nic_type siena_a0_nic_type; 169extern const struct efx_nic_type siena_a0_nic_type;
@@ -189,6 +203,9 @@ extern bool efx_nic_event_present(struct efx_channel *channel);
189/* MAC/PHY */ 203/* MAC/PHY */
190extern void falcon_drain_tx_fifo(struct efx_nic *efx); 204extern void falcon_drain_tx_fifo(struct efx_nic *efx);
191extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx); 205extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx);
206extern bool falcon_xmac_check_fault(struct efx_nic *efx);
207extern int falcon_reconfigure_xmac(struct efx_nic *efx);
208extern void falcon_update_stats_xmac(struct efx_nic *efx);
192 209
193/* Interrupts and test events */ 210/* Interrupts and test events */
194extern int efx_nic_init_interrupt(struct efx_nic *efx); 211extern int efx_nic_init_interrupt(struct efx_nic *efx);
@@ -202,9 +219,6 @@ extern irqreturn_t efx_nic_fatal_interrupt(struct efx_nic *efx);
202extern irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id); 219extern irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id);
203extern void falcon_irq_ack_a1(struct efx_nic *efx); 220extern void falcon_irq_ack_a1(struct efx_nic *efx);
204 221
205#define EFX_IRQ_MOD_RESOLUTION 5
206#define EFX_IRQ_MOD_MAX 0x1000
207
208/* Global Resources */ 222/* Global Resources */
209extern int efx_nic_flush_queues(struct efx_nic *efx); 223extern int efx_nic_flush_queues(struct efx_nic *efx);
210extern void falcon_start_nic_stats(struct efx_nic *efx); 224extern void falcon_start_nic_stats(struct efx_nic *efx);
diff --git a/drivers/net/ethernet/sfc/qt202x_phy.c b/drivers/net/ethernet/sfc/qt202x_phy.c
index 7ad97e397406..8a7caf88ffb6 100644
--- a/drivers/net/ethernet/sfc/qt202x_phy.c
+++ b/drivers/net/ethernet/sfc/qt202x_phy.c
@@ -47,7 +47,7 @@
47#define PMA_PMD_FTX_STATIC_LBN 13 47#define PMA_PMD_FTX_STATIC_LBN 13
48#define PMA_PMD_VEND1_REG 0xc001 48#define PMA_PMD_VEND1_REG 0xc001
49#define PMA_PMD_VEND1_LBTXD_LBN 15 49#define PMA_PMD_VEND1_LBTXD_LBN 15
50#define PCS_VEND1_REG 0xc000 50#define PCS_VEND1_REG 0xc000
51#define PCS_VEND1_LBTXD_LBN 5 51#define PCS_VEND1_LBTXD_LBN 5
52 52
53void falcon_qt202x_set_led(struct efx_nic *p, int led, int mode) 53void falcon_qt202x_set_led(struct efx_nic *p, int led, int mode)
@@ -453,9 +453,9 @@ const struct efx_phy_operations falcon_qt202x_phy_ops = {
453 .probe = qt202x_phy_probe, 453 .probe = qt202x_phy_probe,
454 .init = qt202x_phy_init, 454 .init = qt202x_phy_init,
455 .reconfigure = qt202x_phy_reconfigure, 455 .reconfigure = qt202x_phy_reconfigure,
456 .poll = qt202x_phy_poll, 456 .poll = qt202x_phy_poll,
457 .fini = efx_port_dummy_op_void, 457 .fini = efx_port_dummy_op_void,
458 .remove = qt202x_phy_remove, 458 .remove = qt202x_phy_remove,
459 .get_settings = qt202x_phy_get_settings, 459 .get_settings = qt202x_phy_get_settings,
460 .set_settings = efx_mdio_set_settings, 460 .set_settings = efx_mdio_set_settings,
461 .test_alive = efx_mdio_test_alive, 461 .test_alive = efx_mdio_test_alive,
diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c
index aca349861767..1dfda5e27919 100644
--- a/drivers/net/ethernet/sfc/rx.c
+++ b/drivers/net/ethernet/sfc/rx.c
@@ -98,8 +98,8 @@ static inline unsigned int efx_rx_buf_offset(struct efx_nic *efx,
98 /* Offset is always within one page, so we don't need to consider 98 /* Offset is always within one page, so we don't need to consider
99 * the page order. 99 * the page order.
100 */ 100 */
101 return (((__force unsigned long) buf->dma_addr & (PAGE_SIZE - 1)) + 101 return ((unsigned int) buf->dma_addr & (PAGE_SIZE - 1)) +
102 efx->type->rx_buffer_hash_size); 102 efx->type->rx_buffer_hash_size;
103} 103}
104static inline unsigned int efx_rx_buf_size(struct efx_nic *efx) 104static inline unsigned int efx_rx_buf_size(struct efx_nic *efx)
105{ 105{
@@ -108,11 +108,10 @@ static inline unsigned int efx_rx_buf_size(struct efx_nic *efx)
108 108
109static u8 *efx_rx_buf_eh(struct efx_nic *efx, struct efx_rx_buffer *buf) 109static u8 *efx_rx_buf_eh(struct efx_nic *efx, struct efx_rx_buffer *buf)
110{ 110{
111 if (buf->is_page) 111 if (buf->flags & EFX_RX_BUF_PAGE)
112 return page_address(buf->u.page) + efx_rx_buf_offset(efx, buf); 112 return page_address(buf->u.page) + efx_rx_buf_offset(efx, buf);
113 else 113 else
114 return ((u8 *)buf->u.skb->data + 114 return (u8 *)buf->u.skb->data + efx->type->rx_buffer_hash_size;
115 efx->type->rx_buffer_hash_size);
116} 115}
117 116
118static inline u32 efx_rx_buf_hash(const u8 *eh) 117static inline u32 efx_rx_buf_hash(const u8 *eh)
@@ -122,10 +121,10 @@ static inline u32 efx_rx_buf_hash(const u8 *eh)
122 return __le32_to_cpup((const __le32 *)(eh - 4)); 121 return __le32_to_cpup((const __le32 *)(eh - 4));
123#else 122#else
124 const u8 *data = eh - 4; 123 const u8 *data = eh - 4;
125 return ((u32)data[0] | 124 return (u32)data[0] |
126 (u32)data[1] << 8 | 125 (u32)data[1] << 8 |
127 (u32)data[2] << 16 | 126 (u32)data[2] << 16 |
128 (u32)data[3] << 24); 127 (u32)data[3] << 24;
129#endif 128#endif
130} 129}
131 130
@@ -159,7 +158,7 @@ static int efx_init_rx_buffers_skb(struct efx_rx_queue *rx_queue)
159 /* Adjust the SKB for padding and checksum */ 158 /* Adjust the SKB for padding and checksum */
160 skb_reserve(skb, NET_IP_ALIGN); 159 skb_reserve(skb, NET_IP_ALIGN);
161 rx_buf->len = skb_len - NET_IP_ALIGN; 160 rx_buf->len = skb_len - NET_IP_ALIGN;
162 rx_buf->is_page = false; 161 rx_buf->flags = 0;
163 skb->ip_summed = CHECKSUM_UNNECESSARY; 162 skb->ip_summed = CHECKSUM_UNNECESSARY;
164 163
165 rx_buf->dma_addr = pci_map_single(efx->pci_dev, 164 rx_buf->dma_addr = pci_map_single(efx->pci_dev,
@@ -228,7 +227,7 @@ static int efx_init_rx_buffers_page(struct efx_rx_queue *rx_queue)
228 rx_buf->dma_addr = dma_addr + EFX_PAGE_IP_ALIGN; 227 rx_buf->dma_addr = dma_addr + EFX_PAGE_IP_ALIGN;
229 rx_buf->u.page = page; 228 rx_buf->u.page = page;
230 rx_buf->len = efx->rx_buffer_len - EFX_PAGE_IP_ALIGN; 229 rx_buf->len = efx->rx_buffer_len - EFX_PAGE_IP_ALIGN;
231 rx_buf->is_page = true; 230 rx_buf->flags = EFX_RX_BUF_PAGE;
232 ++rx_queue->added_count; 231 ++rx_queue->added_count;
233 ++rx_queue->alloc_page_count; 232 ++rx_queue->alloc_page_count;
234 ++state->refcnt; 233 ++state->refcnt;
@@ -249,7 +248,7 @@ static int efx_init_rx_buffers_page(struct efx_rx_queue *rx_queue)
249static void efx_unmap_rx_buffer(struct efx_nic *efx, 248static void efx_unmap_rx_buffer(struct efx_nic *efx,
250 struct efx_rx_buffer *rx_buf) 249 struct efx_rx_buffer *rx_buf)
251{ 250{
252 if (rx_buf->is_page && rx_buf->u.page) { 251 if ((rx_buf->flags & EFX_RX_BUF_PAGE) && rx_buf->u.page) {
253 struct efx_rx_page_state *state; 252 struct efx_rx_page_state *state;
254 253
255 state = page_address(rx_buf->u.page); 254 state = page_address(rx_buf->u.page);
@@ -259,7 +258,7 @@ static void efx_unmap_rx_buffer(struct efx_nic *efx,
259 efx_rx_buf_size(efx), 258 efx_rx_buf_size(efx),
260 PCI_DMA_FROMDEVICE); 259 PCI_DMA_FROMDEVICE);
261 } 260 }
262 } else if (!rx_buf->is_page && rx_buf->u.skb) { 261 } else if (!(rx_buf->flags & EFX_RX_BUF_PAGE) && rx_buf->u.skb) {
263 pci_unmap_single(efx->pci_dev, rx_buf->dma_addr, 262 pci_unmap_single(efx->pci_dev, rx_buf->dma_addr,
264 rx_buf->len, PCI_DMA_FROMDEVICE); 263 rx_buf->len, PCI_DMA_FROMDEVICE);
265 } 264 }
@@ -268,10 +267,10 @@ static void efx_unmap_rx_buffer(struct efx_nic *efx,
268static void efx_free_rx_buffer(struct efx_nic *efx, 267static void efx_free_rx_buffer(struct efx_nic *efx,
269 struct efx_rx_buffer *rx_buf) 268 struct efx_rx_buffer *rx_buf)
270{ 269{
271 if (rx_buf->is_page && rx_buf->u.page) { 270 if ((rx_buf->flags & EFX_RX_BUF_PAGE) && rx_buf->u.page) {
272 __free_pages(rx_buf->u.page, efx->rx_buffer_order); 271 __free_pages(rx_buf->u.page, efx->rx_buffer_order);
273 rx_buf->u.page = NULL; 272 rx_buf->u.page = NULL;
274 } else if (!rx_buf->is_page && rx_buf->u.skb) { 273 } else if (!(rx_buf->flags & EFX_RX_BUF_PAGE) && rx_buf->u.skb) {
275 dev_kfree_skb_any(rx_buf->u.skb); 274 dev_kfree_skb_any(rx_buf->u.skb);
276 rx_buf->u.skb = NULL; 275 rx_buf->u.skb = NULL;
277 } 276 }
@@ -311,7 +310,7 @@ static void efx_resurrect_rx_buffer(struct efx_rx_queue *rx_queue,
311 new_buf->dma_addr = rx_buf->dma_addr ^ (PAGE_SIZE >> 1); 310 new_buf->dma_addr = rx_buf->dma_addr ^ (PAGE_SIZE >> 1);
312 new_buf->u.page = rx_buf->u.page; 311 new_buf->u.page = rx_buf->u.page;
313 new_buf->len = rx_buf->len; 312 new_buf->len = rx_buf->len;
314 new_buf->is_page = true; 313 new_buf->flags = EFX_RX_BUF_PAGE;
315 ++rx_queue->added_count; 314 ++rx_queue->added_count;
316} 315}
317 316
@@ -325,7 +324,10 @@ static void efx_recycle_rx_buffer(struct efx_channel *channel,
325 struct efx_rx_buffer *new_buf; 324 struct efx_rx_buffer *new_buf;
326 unsigned index; 325 unsigned index;
327 326
328 if (rx_buf->is_page && efx->rx_buffer_len <= EFX_RX_HALF_PAGE && 327 rx_buf->flags &= EFX_RX_BUF_PAGE;
328
329 if ((rx_buf->flags & EFX_RX_BUF_PAGE) &&
330 efx->rx_buffer_len <= EFX_RX_HALF_PAGE &&
329 page_count(rx_buf->u.page) == 1) 331 page_count(rx_buf->u.page) == 1)
330 efx_resurrect_rx_buffer(rx_queue, rx_buf); 332 efx_resurrect_rx_buffer(rx_queue, rx_buf);
331 333
@@ -412,8 +414,7 @@ void efx_rx_slow_fill(unsigned long context)
412 414
413static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue, 415static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue,
414 struct efx_rx_buffer *rx_buf, 416 struct efx_rx_buffer *rx_buf,
415 int len, bool *discard, 417 int len, bool *leak_packet)
416 bool *leak_packet)
417{ 418{
418 struct efx_nic *efx = rx_queue->efx; 419 struct efx_nic *efx = rx_queue->efx;
419 unsigned max_len = rx_buf->len - efx->type->rx_buffer_padding; 420 unsigned max_len = rx_buf->len - efx->type->rx_buffer_padding;
@@ -424,7 +425,7 @@ static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue,
424 /* The packet must be discarded, but this is only a fatal error 425 /* The packet must be discarded, but this is only a fatal error
425 * if the caller indicated it was 426 * if the caller indicated it was
426 */ 427 */
427 *discard = true; 428 rx_buf->flags |= EFX_RX_PKT_DISCARD;
428 429
429 if ((len > rx_buf->len) && EFX_WORKAROUND_8071(efx)) { 430 if ((len > rx_buf->len) && EFX_WORKAROUND_8071(efx)) {
430 if (net_ratelimit()) 431 if (net_ratelimit())
@@ -437,7 +438,7 @@ static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue,
437 * data at the end of the skb will be trashed. So 438 * data at the end of the skb will be trashed. So
438 * we have no choice but to leak the fragment. 439 * we have no choice but to leak the fragment.
439 */ 440 */
440 *leak_packet = !rx_buf->is_page; 441 *leak_packet = !(rx_buf->flags & EFX_RX_BUF_PAGE);
441 efx_schedule_reset(efx, RESET_TYPE_RX_RECOVERY); 442 efx_schedule_reset(efx, RESET_TYPE_RX_RECOVERY);
442 } else { 443 } else {
443 if (net_ratelimit()) 444 if (net_ratelimit())
@@ -457,13 +458,13 @@ static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue,
457 */ 458 */
458static void efx_rx_packet_gro(struct efx_channel *channel, 459static void efx_rx_packet_gro(struct efx_channel *channel,
459 struct efx_rx_buffer *rx_buf, 460 struct efx_rx_buffer *rx_buf,
460 const u8 *eh, bool checksummed) 461 const u8 *eh)
461{ 462{
462 struct napi_struct *napi = &channel->napi_str; 463 struct napi_struct *napi = &channel->napi_str;
463 gro_result_t gro_result; 464 gro_result_t gro_result;
464 465
465 /* Pass the skb/page into the GRO engine */ 466 /* Pass the skb/page into the GRO engine */
466 if (rx_buf->is_page) { 467 if (rx_buf->flags & EFX_RX_BUF_PAGE) {
467 struct efx_nic *efx = channel->efx; 468 struct efx_nic *efx = channel->efx;
468 struct page *page = rx_buf->u.page; 469 struct page *page = rx_buf->u.page;
469 struct sk_buff *skb; 470 struct sk_buff *skb;
@@ -485,8 +486,8 @@ static void efx_rx_packet_gro(struct efx_channel *channel,
485 skb->len = rx_buf->len; 486 skb->len = rx_buf->len;
486 skb->data_len = rx_buf->len; 487 skb->data_len = rx_buf->len;
487 skb->truesize += rx_buf->len; 488 skb->truesize += rx_buf->len;
488 skb->ip_summed = 489 skb->ip_summed = ((rx_buf->flags & EFX_RX_PKT_CSUMMED) ?
489 checksummed ? CHECKSUM_UNNECESSARY : CHECKSUM_NONE; 490 CHECKSUM_UNNECESSARY : CHECKSUM_NONE);
490 491
491 skb_record_rx_queue(skb, channel->channel); 492 skb_record_rx_queue(skb, channel->channel);
492 493
@@ -494,7 +495,7 @@ static void efx_rx_packet_gro(struct efx_channel *channel,
494 } else { 495 } else {
495 struct sk_buff *skb = rx_buf->u.skb; 496 struct sk_buff *skb = rx_buf->u.skb;
496 497
497 EFX_BUG_ON_PARANOID(!checksummed); 498 EFX_BUG_ON_PARANOID(!(rx_buf->flags & EFX_RX_PKT_CSUMMED));
498 rx_buf->u.skb = NULL; 499 rx_buf->u.skb = NULL;
499 500
500 gro_result = napi_gro_receive(napi, skb); 501 gro_result = napi_gro_receive(napi, skb);
@@ -509,7 +510,7 @@ static void efx_rx_packet_gro(struct efx_channel *channel,
509} 510}
510 511
511void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index, 512void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index,
512 unsigned int len, bool checksummed, bool discard) 513 unsigned int len, u16 flags)
513{ 514{
514 struct efx_nic *efx = rx_queue->efx; 515 struct efx_nic *efx = rx_queue->efx;
515 struct efx_channel *channel = efx_rx_queue_channel(rx_queue); 516 struct efx_channel *channel = efx_rx_queue_channel(rx_queue);
@@ -517,6 +518,7 @@ void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index,
517 bool leak_packet = false; 518 bool leak_packet = false;
518 519
519 rx_buf = efx_rx_buffer(rx_queue, index); 520 rx_buf = efx_rx_buffer(rx_queue, index);
521 rx_buf->flags |= flags;
520 522
521 /* This allows the refill path to post another buffer. 523 /* This allows the refill path to post another buffer.
522 * EFX_RXD_HEAD_ROOM ensures that the slot we are using 524 * EFX_RXD_HEAD_ROOM ensures that the slot we are using
@@ -525,18 +527,17 @@ void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index,
525 rx_queue->removed_count++; 527 rx_queue->removed_count++;
526 528
527 /* Validate the length encoded in the event vs the descriptor pushed */ 529 /* Validate the length encoded in the event vs the descriptor pushed */
528 efx_rx_packet__check_len(rx_queue, rx_buf, len, 530 efx_rx_packet__check_len(rx_queue, rx_buf, len, &leak_packet);
529 &discard, &leak_packet);
530 531
531 netif_vdbg(efx, rx_status, efx->net_dev, 532 netif_vdbg(efx, rx_status, efx->net_dev,
532 "RX queue %d received id %x at %llx+%x %s%s\n", 533 "RX queue %d received id %x at %llx+%x %s%s\n",
533 efx_rx_queue_index(rx_queue), index, 534 efx_rx_queue_index(rx_queue), index,
534 (unsigned long long)rx_buf->dma_addr, len, 535 (unsigned long long)rx_buf->dma_addr, len,
535 (checksummed ? " [SUMMED]" : ""), 536 (rx_buf->flags & EFX_RX_PKT_CSUMMED) ? " [SUMMED]" : "",
536 (discard ? " [DISCARD]" : "")); 537 (rx_buf->flags & EFX_RX_PKT_DISCARD) ? " [DISCARD]" : "");
537 538
538 /* Discard packet, if instructed to do so */ 539 /* Discard packet, if instructed to do so */
539 if (unlikely(discard)) { 540 if (unlikely(rx_buf->flags & EFX_RX_PKT_DISCARD)) {
540 if (unlikely(leak_packet)) 541 if (unlikely(leak_packet))
541 channel->n_skbuff_leaks++; 542 channel->n_skbuff_leaks++;
542 else 543 else
@@ -563,18 +564,33 @@ void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index,
563 rx_buf->len = len - efx->type->rx_buffer_hash_size; 564 rx_buf->len = len - efx->type->rx_buffer_hash_size;
564out: 565out:
565 if (channel->rx_pkt) 566 if (channel->rx_pkt)
566 __efx_rx_packet(channel, 567 __efx_rx_packet(channel, channel->rx_pkt);
567 channel->rx_pkt, channel->rx_pkt_csummed);
568 channel->rx_pkt = rx_buf; 568 channel->rx_pkt = rx_buf;
569 channel->rx_pkt_csummed = checksummed; 569}
570
571static void efx_rx_deliver(struct efx_channel *channel,
572 struct efx_rx_buffer *rx_buf)
573{
574 struct sk_buff *skb;
575
576 /* We now own the SKB */
577 skb = rx_buf->u.skb;
578 rx_buf->u.skb = NULL;
579
580 /* Set the SKB flags */
581 skb_checksum_none_assert(skb);
582
583 /* Pass the packet up */
584 netif_receive_skb(skb);
585
586 /* Update allocation strategy method */
587 channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB;
570} 588}
571 589
572/* Handle a received packet. Second half: Touches packet payload. */ 590/* Handle a received packet. Second half: Touches packet payload. */
573void __efx_rx_packet(struct efx_channel *channel, 591void __efx_rx_packet(struct efx_channel *channel, struct efx_rx_buffer *rx_buf)
574 struct efx_rx_buffer *rx_buf, bool checksummed)
575{ 592{
576 struct efx_nic *efx = channel->efx; 593 struct efx_nic *efx = channel->efx;
577 struct sk_buff *skb;
578 u8 *eh = efx_rx_buf_eh(efx, rx_buf); 594 u8 *eh = efx_rx_buf_eh(efx, rx_buf);
579 595
580 /* If we're in loopback test, then pass the packet directly to the 596 /* If we're in loopback test, then pass the packet directly to the
@@ -586,8 +602,8 @@ void __efx_rx_packet(struct efx_channel *channel,
586 return; 602 return;
587 } 603 }
588 604
589 if (!rx_buf->is_page) { 605 if (!(rx_buf->flags & EFX_RX_BUF_PAGE)) {
590 skb = rx_buf->u.skb; 606 struct sk_buff *skb = rx_buf->u.skb;
591 607
592 prefetch(skb_shinfo(skb)); 608 prefetch(skb_shinfo(skb));
593 609
@@ -605,25 +621,12 @@ void __efx_rx_packet(struct efx_channel *channel,
605 } 621 }
606 622
607 if (unlikely(!(efx->net_dev->features & NETIF_F_RXCSUM))) 623 if (unlikely(!(efx->net_dev->features & NETIF_F_RXCSUM)))
608 checksummed = false; 624 rx_buf->flags &= ~EFX_RX_PKT_CSUMMED;
609
610 if (likely(checksummed || rx_buf->is_page)) {
611 efx_rx_packet_gro(channel, rx_buf, eh, checksummed);
612 return;
613 }
614
615 /* We now own the SKB */
616 skb = rx_buf->u.skb;
617 rx_buf->u.skb = NULL;
618 625
619 /* Set the SKB flags */ 626 if (likely(rx_buf->flags & (EFX_RX_BUF_PAGE | EFX_RX_PKT_CSUMMED)))
620 skb_checksum_none_assert(skb); 627 efx_rx_packet_gro(channel, rx_buf, eh);
621 628 else
622 /* Pass the packet up */ 629 efx_rx_deliver(channel, rx_buf);
623 netif_receive_skb(skb);
624
625 /* Update allocation strategy method */
626 channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB;
627} 630}
628 631
629void efx_rx_strategy(struct efx_channel *channel) 632void efx_rx_strategy(struct efx_channel *channel)
diff --git a/drivers/net/ethernet/sfc/selftest.c b/drivers/net/ethernet/sfc/selftest.c
index 52edd24fcde3..febe2a9e6211 100644
--- a/drivers/net/ethernet/sfc/selftest.c
+++ b/drivers/net/ethernet/sfc/selftest.c
@@ -19,7 +19,6 @@
19#include <linux/udp.h> 19#include <linux/udp.h>
20#include <linux/rtnetlink.h> 20#include <linux/rtnetlink.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <asm/io.h>
23#include "net_driver.h" 22#include "net_driver.h"
24#include "efx.h" 23#include "efx.h"
25#include "nic.h" 24#include "nic.h"
@@ -50,7 +49,7 @@ static const char payload_msg[] =
50 49
51/* Interrupt mode names */ 50/* Interrupt mode names */
52static const unsigned int efx_interrupt_mode_max = EFX_INT_MODE_MAX; 51static const unsigned int efx_interrupt_mode_max = EFX_INT_MODE_MAX;
53static const char *efx_interrupt_mode_names[] = { 52static const char *const efx_interrupt_mode_names[] = {
54 [EFX_INT_MODE_MSIX] = "MSI-X", 53 [EFX_INT_MODE_MSIX] = "MSI-X",
55 [EFX_INT_MODE_MSI] = "MSI", 54 [EFX_INT_MODE_MSI] = "MSI",
56 [EFX_INT_MODE_LEGACY] = "legacy", 55 [EFX_INT_MODE_LEGACY] = "legacy",
@@ -131,6 +130,8 @@ static int efx_test_chip(struct efx_nic *efx, struct efx_self_tests *tests)
131static int efx_test_interrupts(struct efx_nic *efx, 130static int efx_test_interrupts(struct efx_nic *efx,
132 struct efx_self_tests *tests) 131 struct efx_self_tests *tests)
133{ 132{
133 int cpu;
134
134 netif_dbg(efx, drv, efx->net_dev, "testing interrupts\n"); 135 netif_dbg(efx, drv, efx->net_dev, "testing interrupts\n");
135 tests->interrupt = -1; 136 tests->interrupt = -1;
136 137
@@ -143,7 +144,8 @@ static int efx_test_interrupts(struct efx_nic *efx,
143 /* Wait for arrival of test interrupt. */ 144 /* Wait for arrival of test interrupt. */
144 netif_dbg(efx, drv, efx->net_dev, "waiting for test interrupt\n"); 145 netif_dbg(efx, drv, efx->net_dev, "waiting for test interrupt\n");
145 schedule_timeout_uninterruptible(HZ / 10); 146 schedule_timeout_uninterruptible(HZ / 10);
146 if (efx->last_irq_cpu >= 0) 147 cpu = ACCESS_ONCE(efx->last_irq_cpu);
148 if (cpu >= 0)
147 goto success; 149 goto success;
148 150
149 netif_err(efx, drv, efx->net_dev, "timed out waiting for interrupt\n"); 151 netif_err(efx, drv, efx->net_dev, "timed out waiting for interrupt\n");
@@ -151,8 +153,7 @@ static int efx_test_interrupts(struct efx_nic *efx,
151 153
152 success: 154 success:
153 netif_dbg(efx, drv, efx->net_dev, "%s test interrupt seen on CPU%d\n", 155 netif_dbg(efx, drv, efx->net_dev, "%s test interrupt seen on CPU%d\n",
154 INT_MODE(efx), 156 INT_MODE(efx), cpu);
155 efx->last_irq_cpu);
156 tests->interrupt = 1; 157 tests->interrupt = 1;
157 return 0; 158 return 0;
158} 159}
@@ -162,56 +163,57 @@ static int efx_test_eventq_irq(struct efx_channel *channel,
162 struct efx_self_tests *tests) 163 struct efx_self_tests *tests)
163{ 164{
164 struct efx_nic *efx = channel->efx; 165 struct efx_nic *efx = channel->efx;
165 unsigned int read_ptr, count; 166 unsigned int read_ptr;
166 167 bool napi_ran, dma_seen, int_seen;
167 tests->eventq_dma[channel->channel] = -1;
168 tests->eventq_int[channel->channel] = -1;
169 tests->eventq_poll[channel->channel] = -1;
170 168
171 read_ptr = channel->eventq_read_ptr; 169 read_ptr = channel->eventq_read_ptr;
172 channel->efx->last_irq_cpu = -1; 170 channel->last_irq_cpu = -1;
173 smp_wmb(); 171 smp_wmb();
174 172
175 efx_nic_generate_test_event(channel); 173 efx_nic_generate_test_event(channel);
176 174
177 /* Wait for arrival of interrupt */ 175 /* Wait for arrival of interrupt. NAPI processing may or may
178 count = 0; 176 * not complete in time, but we can cope in any case.
179 do { 177 */
180 schedule_timeout_uninterruptible(HZ / 100); 178 msleep(10);
181 179 napi_disable(&channel->napi_str);
182 if (ACCESS_ONCE(channel->eventq_read_ptr) != read_ptr) 180 if (channel->eventq_read_ptr != read_ptr) {
183 goto eventq_ok; 181 napi_ran = true;
184 } while (++count < 2); 182 dma_seen = true;
185 183 int_seen = true;
186 netif_err(efx, drv, efx->net_dev, 184 } else {
187 "channel %d timed out waiting for event queue\n", 185 napi_ran = false;
188 channel->channel); 186 dma_seen = efx_nic_event_present(channel);
189 187 int_seen = ACCESS_ONCE(channel->last_irq_cpu) >= 0;
190 /* See if interrupt arrived */
191 if (channel->efx->last_irq_cpu >= 0) {
192 netif_err(efx, drv, efx->net_dev,
193 "channel %d saw interrupt on CPU%d "
194 "during event queue test\n", channel->channel,
195 raw_smp_processor_id());
196 tests->eventq_int[channel->channel] = 1;
197 } 188 }
189 napi_enable(&channel->napi_str);
190 efx_nic_eventq_read_ack(channel);
191
192 tests->eventq_dma[channel->channel] = dma_seen ? 1 : -1;
193 tests->eventq_int[channel->channel] = int_seen ? 1 : -1;
198 194
199 /* Check to see if event was received even if interrupt wasn't */ 195 if (dma_seen && int_seen) {
200 if (efx_nic_event_present(channel)) { 196 netif_dbg(efx, drv, efx->net_dev,
197 "channel %d event queue passed (with%s NAPI)\n",
198 channel->channel, napi_ran ? "" : "out");
199 return 0;
200 } else {
201 /* Report failure and whether either interrupt or DMA worked */
201 netif_err(efx, drv, efx->net_dev, 202 netif_err(efx, drv, efx->net_dev,
202 "channel %d event was generated, but " 203 "channel %d timed out waiting for event queue\n",
203 "failed to trigger an interrupt\n", channel->channel); 204 channel->channel);
204 tests->eventq_dma[channel->channel] = 1; 205 if (int_seen)
206 netif_err(efx, drv, efx->net_dev,
207 "channel %d saw interrupt "
208 "during event queue test\n",
209 channel->channel);
210 if (dma_seen)
211 netif_err(efx, drv, efx->net_dev,
212 "channel %d event was generated, but "
213 "failed to trigger an interrupt\n",
214 channel->channel);
215 return -ETIMEDOUT;
205 } 216 }
206
207 return -ETIMEDOUT;
208 eventq_ok:
209 netif_dbg(efx, drv, efx->net_dev, "channel %d event queue passed\n",
210 channel->channel);
211 tests->eventq_dma[channel->channel] = 1;
212 tests->eventq_int[channel->channel] = 1;
213 tests->eventq_poll[channel->channel] = 1;
214 return 0;
215} 217}
216 218
217static int efx_test_phy(struct efx_nic *efx, struct efx_self_tests *tests, 219static int efx_test_phy(struct efx_nic *efx, struct efx_self_tests *tests,
@@ -316,7 +318,7 @@ void efx_loopback_rx_packet(struct efx_nic *efx,
316 return; 318 return;
317 319
318 err: 320 err:
319#ifdef EFX_ENABLE_DEBUG 321#ifdef DEBUG
320 if (atomic_read(&state->rx_bad) == 0) { 322 if (atomic_read(&state->rx_bad) == 0) {
321 netif_err(efx, drv, efx->net_dev, "received packet:\n"); 323 netif_err(efx, drv, efx->net_dev, "received packet:\n");
322 print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1, 324 print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1,
@@ -395,11 +397,9 @@ static int efx_begin_loopback(struct efx_tx_queue *tx_queue)
395 * interrupt handler. */ 397 * interrupt handler. */
396 smp_wmb(); 398 smp_wmb();
397 399
398 if (efx_dev_registered(efx)) 400 netif_tx_lock_bh(efx->net_dev);
399 netif_tx_lock_bh(efx->net_dev);
400 rc = efx_enqueue_skb(tx_queue, skb); 401 rc = efx_enqueue_skb(tx_queue, skb);
401 if (efx_dev_registered(efx)) 402 netif_tx_unlock_bh(efx->net_dev);
402 netif_tx_unlock_bh(efx->net_dev);
403 403
404 if (rc != NETDEV_TX_OK) { 404 if (rc != NETDEV_TX_OK) {
405 netif_err(efx, drv, efx->net_dev, 405 netif_err(efx, drv, efx->net_dev,
@@ -440,20 +440,18 @@ static int efx_end_loopback(struct efx_tx_queue *tx_queue,
440 int tx_done = 0, rx_good, rx_bad; 440 int tx_done = 0, rx_good, rx_bad;
441 int i, rc = 0; 441 int i, rc = 0;
442 442
443 if (efx_dev_registered(efx)) 443 netif_tx_lock_bh(efx->net_dev);
444 netif_tx_lock_bh(efx->net_dev);
445 444
446 /* Count the number of tx completions, and decrement the refcnt. Any 445 /* Count the number of tx completions, and decrement the refcnt. Any
447 * skbs not already completed will be free'd when the queue is flushed */ 446 * skbs not already completed will be free'd when the queue is flushed */
448 for (i=0; i < state->packet_count; i++) { 447 for (i = 0; i < state->packet_count; i++) {
449 skb = state->skbs[i]; 448 skb = state->skbs[i];
450 if (skb && !skb_shared(skb)) 449 if (skb && !skb_shared(skb))
451 ++tx_done; 450 ++tx_done;
452 dev_kfree_skb_any(skb); 451 dev_kfree_skb_any(skb);
453 } 452 }
454 453
455 if (efx_dev_registered(efx)) 454 netif_tx_unlock_bh(efx->net_dev);
456 netif_tx_unlock_bh(efx->net_dev);
457 455
458 /* Check TX completion and received packet counts */ 456 /* Check TX completion and received packet counts */
459 rx_good = atomic_read(&state->rx_good); 457 rx_good = atomic_read(&state->rx_good);
@@ -570,7 +568,7 @@ static int efx_wait_for_link(struct efx_nic *efx)
570 mutex_lock(&efx->mac_lock); 568 mutex_lock(&efx->mac_lock);
571 link_up = link_state->up; 569 link_up = link_state->up;
572 if (link_up) 570 if (link_up)
573 link_up = !efx->mac_op->check_fault(efx); 571 link_up = !efx->type->check_mac_fault(efx);
574 mutex_unlock(&efx->mac_lock); 572 mutex_unlock(&efx->mac_lock);
575 573
576 if (link_up) { 574 if (link_up) {
diff --git a/drivers/net/ethernet/sfc/selftest.h b/drivers/net/ethernet/sfc/selftest.h
index dba5456e70f3..87abe2a53846 100644
--- a/drivers/net/ethernet/sfc/selftest.h
+++ b/drivers/net/ethernet/sfc/selftest.h
@@ -37,7 +37,6 @@ struct efx_self_tests {
37 int interrupt; 37 int interrupt;
38 int eventq_dma[EFX_MAX_CHANNELS]; 38 int eventq_dma[EFX_MAX_CHANNELS];
39 int eventq_int[EFX_MAX_CHANNELS]; 39 int eventq_int[EFX_MAX_CHANNELS];
40 int eventq_poll[EFX_MAX_CHANNELS];
41 /* offline tests */ 40 /* offline tests */
42 int registers; 41 int registers;
43 int phy_ext[EFX_MAX_PHY_TESTS]; 42 int phy_ext[EFX_MAX_PHY_TESTS];
diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c
index 4d5d619feaa6..d3c4169e2a0b 100644
--- a/drivers/net/ethernet/sfc/siena.c
+++ b/drivers/net/ethernet/sfc/siena.c
@@ -18,7 +18,6 @@
18#include "bitfield.h" 18#include "bitfield.h"
19#include "efx.h" 19#include "efx.h"
20#include "nic.h" 20#include "nic.h"
21#include "mac.h"
22#include "spi.h" 21#include "spi.h"
23#include "regs.h" 22#include "regs.h"
24#include "io.h" 23#include "io.h"
@@ -36,8 +35,6 @@ static void siena_push_irq_moderation(struct efx_channel *channel)
36{ 35{
37 efx_dword_t timer_cmd; 36 efx_dword_t timer_cmd;
38 37
39 BUILD_BUG_ON(EFX_IRQ_MOD_MAX > (1 << FRF_CZ_TC_TIMER_VAL_WIDTH));
40
41 if (channel->irq_moderation) 38 if (channel->irq_moderation)
42 EFX_POPULATE_DWORD_2(timer_cmd, 39 EFX_POPULATE_DWORD_2(timer_cmd,
43 FRF_CZ_TC_TIMER_MODE, 40 FRF_CZ_TC_TIMER_MODE,
@@ -53,15 +50,6 @@ static void siena_push_irq_moderation(struct efx_channel *channel)
53 channel->channel); 50 channel->channel);
54} 51}
55 52
56static void siena_push_multicast_hash(struct efx_nic *efx)
57{
58 WARN_ON(!mutex_is_locked(&efx->mac_lock));
59
60 efx_mcdi_rpc(efx, MC_CMD_SET_MCAST_HASH,
61 efx->multicast_hash.byte, sizeof(efx->multicast_hash),
62 NULL, 0, NULL);
63}
64
65static int siena_mdio_write(struct net_device *net_dev, 53static int siena_mdio_write(struct net_device *net_dev,
66 int prtad, int devad, u16 addr, u16 value) 54 int prtad, int devad, u16 addr, u16 value)
67{ 55{
@@ -226,7 +214,15 @@ static int siena_reset_hw(struct efx_nic *efx, enum reset_type method)
226 214
227static int siena_probe_nvconfig(struct efx_nic *efx) 215static int siena_probe_nvconfig(struct efx_nic *efx)
228{ 216{
229 return efx_mcdi_get_board_cfg(efx, efx->net_dev->perm_addr, NULL); 217 u32 caps = 0;
218 int rc;
219
220 rc = efx_mcdi_get_board_cfg(efx, efx->net_dev->perm_addr, NULL, &caps);
221
222 efx->timer_quantum_ns =
223 (caps & (1 << MC_CMD_CAPABILITIES_TURBO_ACTIVE_LBN)) ?
224 3072 : 6144; /* 768 cycles */
225 return rc;
230} 226}
231 227
232static int siena_probe_nic(struct efx_nic *efx) 228static int siena_probe_nic(struct efx_nic *efx)
@@ -304,6 +300,10 @@ static int siena_probe_nic(struct efx_nic *efx)
304 goto fail5; 300 goto fail5;
305 } 301 }
306 302
303 rc = efx_mcdi_mon_probe(efx);
304 if (rc)
305 goto fail5;
306
307 return 0; 307 return 0;
308 308
309fail5: 309fail5:
@@ -391,6 +391,8 @@ static int siena_init_nic(struct efx_nic *efx)
391 391
392static void siena_remove_nic(struct efx_nic *efx) 392static void siena_remove_nic(struct efx_nic *efx)
393{ 393{
394 efx_mcdi_mon_remove(efx);
395
394 efx_nic_free_buffer(efx, &efx->irq_status); 396 efx_nic_free_buffer(efx, &efx->irq_status);
395 397
396 siena_reset_hw(efx, RESET_TYPE_ALL); 398 siena_reset_hw(efx, RESET_TYPE_ALL);
@@ -630,14 +632,14 @@ const struct efx_nic_type siena_a0_nic_type = {
630 .stop_stats = siena_stop_nic_stats, 632 .stop_stats = siena_stop_nic_stats,
631 .set_id_led = efx_mcdi_set_id_led, 633 .set_id_led = efx_mcdi_set_id_led,
632 .push_irq_moderation = siena_push_irq_moderation, 634 .push_irq_moderation = siena_push_irq_moderation,
633 .push_multicast_hash = siena_push_multicast_hash, 635 .reconfigure_mac = efx_mcdi_mac_reconfigure,
636 .check_mac_fault = efx_mcdi_mac_check_fault,
634 .reconfigure_port = efx_mcdi_phy_reconfigure, 637 .reconfigure_port = efx_mcdi_phy_reconfigure,
635 .get_wol = siena_get_wol, 638 .get_wol = siena_get_wol,
636 .set_wol = siena_set_wol, 639 .set_wol = siena_set_wol,
637 .resume_wol = siena_init_wol, 640 .resume_wol = siena_init_wol,
638 .test_registers = siena_test_registers, 641 .test_registers = siena_test_registers,
639 .test_nvram = efx_mcdi_nvram_test_all, 642 .test_nvram = efx_mcdi_nvram_test_all,
640 .default_mac_ops = &efx_mcdi_mac_operations,
641 643
642 .revision = EFX_REV_SIENA_A0, 644 .revision = EFX_REV_SIENA_A0,
643 .mem_map_size = (FR_CZ_MC_TREG_SMEM + 645 .mem_map_size = (FR_CZ_MC_TREG_SMEM +
@@ -654,6 +656,7 @@ const struct efx_nic_type siena_a0_nic_type = {
654 .phys_addr_channels = 32, /* Hardware limit is 64, but the legacy 656 .phys_addr_channels = 32, /* Hardware limit is 64, but the legacy
655 * interrupt handler only supports 32 657 * interrupt handler only supports 32
656 * channels */ 658 * channels */
659 .timer_period_max = 1 << FRF_CZ_TC_TIMER_VAL_WIDTH,
657 .tx_dc_base = 0x88000, 660 .tx_dc_base = 0x88000,
658 .rx_dc_base = 0x68000, 661 .rx_dc_base = 0x68000,
659 .offload_features = (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | 662 .offload_features = (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
diff --git a/drivers/net/ethernet/sfc/spi.h b/drivers/net/ethernet/sfc/spi.h
index 71f2e3ebe1c7..5431a1bbff5c 100644
--- a/drivers/net/ethernet/sfc/spi.h
+++ b/drivers/net/ethernet/sfc/spi.h
@@ -68,7 +68,7 @@ static inline bool efx_spi_present(const struct efx_spi_device *spi)
68 68
69int falcon_spi_cmd(struct efx_nic *efx, 69int falcon_spi_cmd(struct efx_nic *efx,
70 const struct efx_spi_device *spi, unsigned int command, 70 const struct efx_spi_device *spi, unsigned int command,
71 int address, const void* in, void *out, size_t len); 71 int address, const void *in, void *out, size_t len);
72int falcon_spi_wait_write(struct efx_nic *efx, 72int falcon_spi_wait_write(struct efx_nic *efx,
73 const struct efx_spi_device *spi); 73 const struct efx_spi_device *spi);
74int falcon_spi_read(struct efx_nic *efx, 74int falcon_spi_read(struct efx_nic *efx,
diff --git a/drivers/net/ethernet/sfc/tenxpress.c b/drivers/net/ethernet/sfc/tenxpress.c
index 7b0fd89e7b85..d37cb5017129 100644
--- a/drivers/net/ethernet/sfc/tenxpress.c
+++ b/drivers/net/ethernet/sfc/tenxpress.c
@@ -121,7 +121,7 @@
121#define GPHY_XCONTROL_REG 49152 121#define GPHY_XCONTROL_REG 49152
122#define GPHY_ISOLATE_LBN 10 122#define GPHY_ISOLATE_LBN 10
123#define GPHY_ISOLATE_WIDTH 1 123#define GPHY_ISOLATE_WIDTH 1
124#define GPHY_DUPLEX_LBN 8 124#define GPHY_DUPLEX_LBN 8
125#define GPHY_DUPLEX_WIDTH 1 125#define GPHY_DUPLEX_WIDTH 1
126#define GPHY_LOOPBACK_NEAR_LBN 14 126#define GPHY_LOOPBACK_NEAR_LBN 14
127#define GPHY_LOOPBACK_NEAR_WIDTH 1 127#define GPHY_LOOPBACK_NEAR_WIDTH 1
diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c
index 72f0fbc73b1a..5cb81fa3fcbd 100644
--- a/drivers/net/ethernet/sfc/tx.c
+++ b/drivers/net/ethernet/sfc/tx.c
@@ -446,10 +446,8 @@ void efx_xmit_done(struct efx_tx_queue *tx_queue, unsigned int index)
446 likely(efx->port_enabled) && 446 likely(efx->port_enabled) &&
447 likely(netif_device_present(efx->net_dev))) { 447 likely(netif_device_present(efx->net_dev))) {
448 fill_level = tx_queue->insert_count - tx_queue->read_count; 448 fill_level = tx_queue->insert_count - tx_queue->read_count;
449 if (fill_level < EFX_TXQ_THRESHOLD(efx)) { 449 if (fill_level < EFX_TXQ_THRESHOLD(efx))
450 EFX_BUG_ON_PARANOID(!efx_dev_registered(efx));
451 netif_tx_wake_queue(tx_queue->core_txq); 450 netif_tx_wake_queue(tx_queue->core_txq);
452 }
453 } 451 }
454 452
455 /* Check whether the hardware queue is now empty */ 453 /* Check whether the hardware queue is now empty */
diff --git a/drivers/net/ethernet/sfc/txc43128_phy.c b/drivers/net/ethernet/sfc/txc43128_phy.c
index 7c21b334a75b..29bb3f9941c0 100644
--- a/drivers/net/ethernet/sfc/txc43128_phy.c
+++ b/drivers/net/ethernet/sfc/txc43128_phy.c
@@ -512,7 +512,7 @@ static bool txc43128_phy_poll(struct efx_nic *efx)
512 return efx->link_state.up != was_up; 512 return efx->link_state.up != was_up;
513} 513}
514 514
515static const char *txc43128_test_names[] = { 515static const char *const txc43128_test_names[] = {
516 "bist" 516 "bist"
517}; 517};
518 518
diff --git a/drivers/net/ethernet/sis/sis190.c b/drivers/net/ethernet/sis/sis190.c
index 5b118cd5bf94..a9deda8eaf63 100644
--- a/drivers/net/ethernet/sis/sis190.c
+++ b/drivers/net/ethernet/sis/sis190.c
@@ -1462,8 +1462,6 @@ static struct net_device * __devinit sis190_init_board(struct pci_dev *pdev)
1462 1462
1463 dev = alloc_etherdev(sizeof(*tp)); 1463 dev = alloc_etherdev(sizeof(*tp));
1464 if (!dev) { 1464 if (!dev) {
1465 if (netif_msg_drv(&debug))
1466 pr_err("unable to alloc new ethernet\n");
1467 rc = -ENOMEM; 1465 rc = -ENOMEM;
1468 goto err_out_0; 1466 goto err_out_0;
1469 } 1467 }
diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c
index c8efc708c792..f968898c86db 100644
--- a/drivers/net/ethernet/sis/sis900.c
+++ b/drivers/net/ethernet/sis/sis900.c
@@ -619,7 +619,6 @@ static int __devinit sis900_mii_probe(struct net_device * net_dev)
619 } 619 }
620 620
621 if ((mii_phy = kmalloc(sizeof(struct mii_phy), GFP_KERNEL)) == NULL) { 621 if ((mii_phy = kmalloc(sizeof(struct mii_phy), GFP_KERNEL)) == NULL) {
622 printk(KERN_WARNING "Cannot allocate mem for struct mii_phy\n");
623 mii_phy = sis_priv->first_mii; 622 mii_phy = sis_priv->first_mii;
624 while (mii_phy) { 623 while (mii_phy) {
625 struct mii_phy *phy; 624 struct mii_phy *phy;
@@ -1167,7 +1166,7 @@ sis900_init_rx_ring(struct net_device *net_dev)
1167 for (i = 0; i < NUM_RX_DESC; i++) { 1166 for (i = 0; i < NUM_RX_DESC; i++) {
1168 struct sk_buff *skb; 1167 struct sk_buff *skb;
1169 1168
1170 if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) { 1169 if ((skb = netdev_alloc_skb(net_dev, RX_BUF_SIZE)) == NULL) {
1171 /* not enough memory for skbuff, this makes a "hole" 1170 /* not enough memory for skbuff, this makes a "hole"
1172 on the buffer ring, it is not clear how the 1171 on the buffer ring, it is not clear how the
1173 hardware will react to this kind of degenerated 1172 hardware will react to this kind of degenerated
@@ -1770,7 +1769,7 @@ static int sis900_rx(struct net_device *net_dev)
1770 1769
1771 /* refill the Rx buffer, what if there is not enough 1770 /* refill the Rx buffer, what if there is not enough
1772 * memory for new socket buffer ?? */ 1771 * memory for new socket buffer ?? */
1773 if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) { 1772 if ((skb = netdev_alloc_skb(net_dev, RX_BUF_SIZE)) == NULL) {
1774 /* 1773 /*
1775 * Not enough memory to refill the buffer 1774 * Not enough memory to refill the buffer
1776 * so we need to recycle the old one so 1775 * so we need to recycle the old one so
@@ -1828,7 +1827,7 @@ refill_rx_ring:
1828 entry = sis_priv->dirty_rx % NUM_RX_DESC; 1827 entry = sis_priv->dirty_rx % NUM_RX_DESC;
1829 1828
1830 if (sis_priv->rx_skbuff[entry] == NULL) { 1829 if (sis_priv->rx_skbuff[entry] == NULL) {
1831 if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) { 1830 if ((skb = netdev_alloc_skb(net_dev, RX_BUF_SIZE)) == NULL) {
1832 /* not enough memory for skbuff, this makes a 1831 /* not enough memory for skbuff, this makes a
1833 * "hole" on the buffer ring, it is not clear 1832 * "hole" on the buffer ring, it is not clear
1834 * how the hardware will react to this kind 1833 * how the hardware will react to this kind
diff --git a/drivers/net/ethernet/smsc/epic100.c b/drivers/net/ethernet/smsc/epic100.c
index 2c077ce0b6d6..2a662e6112e9 100644
--- a/drivers/net/ethernet/smsc/epic100.c
+++ b/drivers/net/ethernet/smsc/epic100.c
@@ -363,10 +363,9 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
363 ret = -ENOMEM; 363 ret = -ENOMEM;
364 364
365 dev = alloc_etherdev(sizeof (*ep)); 365 dev = alloc_etherdev(sizeof (*ep));
366 if (!dev) { 366 if (!dev)
367 dev_err(&pdev->dev, "no memory for eth device\n");
368 goto err_out_free_res; 367 goto err_out_free_res;
369 } 368
370 SET_NETDEV_DEV(dev, &pdev->dev); 369 SET_NETDEV_DEV(dev, &pdev->dev);
371 370
372#ifdef USE_IO_OPS 371#ifdef USE_IO_OPS
@@ -935,7 +934,7 @@ static void epic_init_ring(struct net_device *dev)
935 934
936 /* Fill in the Rx buffers. Handle allocation failure gracefully. */ 935 /* Fill in the Rx buffers. Handle allocation failure gracefully. */
937 for (i = 0; i < RX_RING_SIZE; i++) { 936 for (i = 0; i < RX_RING_SIZE; i++) {
938 struct sk_buff *skb = dev_alloc_skb(ep->rx_buf_sz + 2); 937 struct sk_buff *skb = netdev_alloc_skb(dev, ep->rx_buf_sz + 2);
939 ep->rx_skbuff[i] = skb; 938 ep->rx_skbuff[i] = skb;
940 if (skb == NULL) 939 if (skb == NULL)
941 break; 940 break;
@@ -1200,7 +1199,7 @@ static int epic_rx(struct net_device *dev, int budget)
1200 /* Check if the packet is long enough to accept without copying 1199 /* Check if the packet is long enough to accept without copying
1201 to a minimally-sized skbuff. */ 1200 to a minimally-sized skbuff. */
1202 if (pkt_len < rx_copybreak && 1201 if (pkt_len < rx_copybreak &&
1203 (skb = dev_alloc_skb(pkt_len + 2)) != NULL) { 1202 (skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) {
1204 skb_reserve(skb, 2); /* 16 byte align the IP header */ 1203 skb_reserve(skb, 2); /* 16 byte align the IP header */
1205 pci_dma_sync_single_for_cpu(ep->pci_dev, 1204 pci_dma_sync_single_for_cpu(ep->pci_dev,
1206 ep->rx_ring[entry].bufaddr, 1205 ep->rx_ring[entry].bufaddr,
@@ -1233,7 +1232,7 @@ static int epic_rx(struct net_device *dev, int budget)
1233 entry = ep->dirty_rx % RX_RING_SIZE; 1232 entry = ep->dirty_rx % RX_RING_SIZE;
1234 if (ep->rx_skbuff[entry] == NULL) { 1233 if (ep->rx_skbuff[entry] == NULL) {
1235 struct sk_buff *skb; 1234 struct sk_buff *skb;
1236 skb = ep->rx_skbuff[entry] = dev_alloc_skb(ep->rx_buf_sz + 2); 1235 skb = ep->rx_skbuff[entry] = netdev_alloc_skb(dev, ep->rx_buf_sz + 2);
1237 if (skb == NULL) 1236 if (skb == NULL)
1238 break; 1237 break;
1239 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1238 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
diff --git a/drivers/net/ethernet/smsc/smc911x.c b/drivers/net/ethernet/smsc/smc911x.c
index 313ba3b32ab4..8814b2f5d46f 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -401,7 +401,7 @@ static inline void smc911x_rcv(struct net_device *dev)
401 } else { 401 } else {
402 /* Receive a valid packet */ 402 /* Receive a valid packet */
403 /* Alloc a buffer with extra room for DMA alignment */ 403 /* Alloc a buffer with extra room for DMA alignment */
404 skb=dev_alloc_skb(pkt_len+32); 404 skb = netdev_alloc_skb(dev, pkt_len+32);
405 if (unlikely(skb == NULL)) { 405 if (unlikely(skb == NULL)) {
406 PRINTK( "%s: Low memory, rcvd packet dropped.\n", 406 PRINTK( "%s: Low memory, rcvd packet dropped.\n",
407 dev->name); 407 dev->name);
@@ -2065,7 +2065,6 @@ static int __devinit smc911x_drv_probe(struct platform_device *pdev)
2065 2065
2066 ndev = alloc_etherdev(sizeof(struct smc911x_local)); 2066 ndev = alloc_etherdev(sizeof(struct smc911x_local));
2067 if (!ndev) { 2067 if (!ndev) {
2068 printk("%s: could not allocate device.\n", CARDNAME);
2069 ret = -ENOMEM; 2068 ret = -ENOMEM;
2070 goto release_1; 2069 goto release_1;
2071 } 2070 }
diff --git a/drivers/net/ethernet/smsc/smc9194.c b/drivers/net/ethernet/smsc/smc9194.c
index 4e45094efb18..50823da9dc1e 100644
--- a/drivers/net/ethernet/smsc/smc9194.c
+++ b/drivers/net/ethernet/smsc/smc9194.c
@@ -1222,7 +1222,7 @@ static void smc_rcv(struct net_device *dev)
1222 if ( status & RS_MULTICAST ) 1222 if ( status & RS_MULTICAST )
1223 dev->stats.multicast++; 1223 dev->stats.multicast++;
1224 1224
1225 skb = dev_alloc_skb( packet_length + 5); 1225 skb = netdev_alloc_skb(dev, packet_length + 5);
1226 1226
1227 if ( skb == NULL ) { 1227 if ( skb == NULL ) {
1228 printk(KERN_NOTICE CARDNAME ": Low memory, packet dropped.\n"); 1228 printk(KERN_NOTICE CARDNAME ": Low memory, packet dropped.\n");
diff --git a/drivers/net/ethernet/smsc/smc91c92_cs.c b/drivers/net/ethernet/smsc/smc91c92_cs.c
index ada927aba7a5..d12e48a7861d 100644
--- a/drivers/net/ethernet/smsc/smc91c92_cs.c
+++ b/drivers/net/ethernet/smsc/smc91c92_cs.c
@@ -1500,7 +1500,7 @@ static void smc_rx(struct net_device *dev)
1500 struct sk_buff *skb; 1500 struct sk_buff *skb;
1501 1501
1502 /* Note: packet_length adds 5 or 6 extra bytes here! */ 1502 /* Note: packet_length adds 5 or 6 extra bytes here! */
1503 skb = dev_alloc_skb(packet_length+2); 1503 skb = netdev_alloc_skb(dev, packet_length+2);
1504 1504
1505 if (skb == NULL) { 1505 if (skb == NULL) {
1506 pr_debug("%s: Low memory, packet dropped.\n", dev->name); 1506 pr_debug("%s: Low memory, packet dropped.\n", dev->name);
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 64ad3ed74495..1dc4fad593e7 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -463,7 +463,7 @@ static inline void smc_rcv(struct net_device *dev)
463 * multiple of 4 bytes on 32 bit buses. 463 * multiple of 4 bytes on 32 bit buses.
464 * Hence packet_len - 6 + 2 + 2 + 2. 464 * Hence packet_len - 6 + 2 + 2 + 2.
465 */ 465 */
466 skb = dev_alloc_skb(packet_len); 466 skb = netdev_alloc_skb(dev, packet_len);
467 if (unlikely(skb == NULL)) { 467 if (unlikely(skb == NULL)) {
468 printk(KERN_NOTICE "%s: Low memory, packet dropped.\n", 468 printk(KERN_NOTICE "%s: Low memory, packet dropped.\n",
469 dev->name); 469 dev->name);
@@ -2223,7 +2223,6 @@ static int __devinit smc_drv_probe(struct platform_device *pdev)
2223 2223
2224 ndev = alloc_etherdev(sizeof(struct smc_local)); 2224 ndev = alloc_etherdev(sizeof(struct smc_local));
2225 if (!ndev) { 2225 if (!ndev) {
2226 printk("%s: could not allocate device.\n", CARDNAME);
2227 ret = -ENOMEM; 2226 ret = -ENOMEM;
2228 goto out; 2227 goto out;
2229 } 2228 }
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 24d2df068d71..6a1cd2360818 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -2374,7 +2374,6 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
2374 2374
2375 dev = alloc_etherdev(sizeof(struct smsc911x_data)); 2375 dev = alloc_etherdev(sizeof(struct smsc911x_data));
2376 if (!dev) { 2376 if (!dev) {
2377 pr_warn("Could not allocate device\n");
2378 retval = -ENOMEM; 2377 retval = -ENOMEM;
2379 goto out_release_io_1; 2378 goto out_release_io_1;
2380 } 2379 }
diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c
index a9efbdfe5302..ee1a1680b7a8 100644
--- a/drivers/net/ethernet/smsc/smsc9420.c
+++ b/drivers/net/ethernet/smsc/smsc9420.c
@@ -850,8 +850,6 @@ static int smsc9420_alloc_rx_buffer(struct smsc9420_pdata *pd, int index)
850 return -ENOMEM; 850 return -ENOMEM;
851 } 851 }
852 852
853 skb->dev = pd->dev;
854
855 mapping = pci_map_single(pd->pdev, skb_tail_pointer(skb), 853 mapping = pci_map_single(pd->pdev, skb_tail_pointer(skb),
856 PKT_BUF_SZ, PCI_DMA_FROMDEVICE); 854 PKT_BUF_SZ, PCI_DMA_FROMDEVICE);
857 if (pci_dma_mapping_error(pd->pdev, mapping)) { 855 if (pci_dma_mapping_error(pd->pdev, mapping)) {
@@ -1598,10 +1596,8 @@ smsc9420_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1598 pci_set_master(pdev); 1596 pci_set_master(pdev);
1599 1597
1600 dev = alloc_etherdev(sizeof(*pd)); 1598 dev = alloc_etherdev(sizeof(*pd));
1601 if (!dev) { 1599 if (!dev)
1602 printk(KERN_ERR "ether device alloc failed\n");
1603 goto out_disable_pci_device_1; 1600 goto out_disable_pci_device_1;
1604 }
1605 1601
1606 SET_NETDEV_DEV(dev, &pdev->dev); 1602 SET_NETDEV_DEV(dev, &pdev->dev);
1607 1603
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 96fa2da30763..166fc95e5baf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -954,10 +954,9 @@ static int stmmac_open(struct net_device *dev)
954 954
955#ifdef CONFIG_STMMAC_TIMER 955#ifdef CONFIG_STMMAC_TIMER
956 priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL); 956 priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL);
957 if (unlikely(priv->tm == NULL)) { 957 if (unlikely(priv->tm == NULL))
958 pr_err("%s: ERROR: timer memory alloc failed\n", __func__);
959 return -ENOMEM; 958 return -ENOMEM;
960 } 959
961 priv->tm->freq = tmrate; 960 priv->tm->freq = tmrate;
962 961
963 /* Test if the external timer can be actually used. 962 /* Test if the external timer can be actually used.
@@ -1802,10 +1801,8 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
1802 struct stmmac_priv *priv; 1801 struct stmmac_priv *priv;
1803 1802
1804 ndev = alloc_etherdev(sizeof(struct stmmac_priv)); 1803 ndev = alloc_etherdev(sizeof(struct stmmac_priv));
1805 if (!ndev) { 1804 if (!ndev)
1806 pr_err("%s: ERROR: allocating the device\n", __func__);
1807 return NULL; 1805 return NULL;
1808 }
1809 1806
1810 SET_NETDEV_DEV(ndev, device); 1807 SET_NETDEV_DEV(ndev, device);
1811 1808
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index c796de9eed72..6ce0706b2d1b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -85,7 +85,7 @@ static int __devinit stmmac_pci_probe(struct pci_dev *pdev,
85 continue; 85 continue;
86 addr = pci_iomap(pdev, i, 0); 86 addr = pci_iomap(pdev, i, 0);
87 if (addr == NULL) { 87 if (addr == NULL) {
88 pr_err("%s: ERROR: cannot map regiser memory, aborting", 88 pr_err("%s: ERROR: cannot map register memory, aborting",
89 __func__); 89 __func__);
90 ret = -EIO; 90 ret = -EIO;
91 goto err_out_map_failed; 91 goto err_out_map_failed;
diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index f10665f594c4..b36edbd625dd 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -835,7 +835,6 @@ static int cas_saturn_firmware_init(struct cas *cp)
835 cp->fw_data = vmalloc(cp->fw_size); 835 cp->fw_data = vmalloc(cp->fw_size);
836 if (!cp->fw_data) { 836 if (!cp->fw_data) {
837 err = -ENOMEM; 837 err = -ENOMEM;
838 pr_err("\"%s\" Failed %d\n", fw_name, err);
839 goto out; 838 goto out;
840 } 839 }
841 memcpy(cp->fw_data, &fw->data[2], cp->fw_size); 840 memcpy(cp->fw_data, &fw->data[2], cp->fw_size);
@@ -1975,7 +1974,7 @@ static int cas_rx_process_pkt(struct cas *cp, struct cas_rx_comp *rxc,
1975 else 1974 else
1976 alloclen = max(hlen, RX_COPY_MIN); 1975 alloclen = max(hlen, RX_COPY_MIN);
1977 1976
1978 skb = dev_alloc_skb(alloclen + swivel + cp->crc_size); 1977 skb = netdev_alloc_skb(cp->dev, alloclen + swivel + cp->crc_size);
1979 if (skb == NULL) 1978 if (skb == NULL)
1980 return -1; 1979 return -1;
1981 1980
@@ -4947,7 +4946,6 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
4947 4946
4948 dev = alloc_etherdev(sizeof(*cp)); 4947 dev = alloc_etherdev(sizeof(*cp));
4949 if (!dev) { 4948 if (!dev) {
4950 dev_err(&pdev->dev, "Etherdev alloc failed, aborting\n");
4951 err = -ENOMEM; 4949 err = -ENOMEM;
4952 goto err_out_disable_pdev; 4950 goto err_out_disable_pdev;
4953 } 4951 }
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index cf433931304f..d83c50816714 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -9685,10 +9685,8 @@ static struct net_device * __devinit niu_alloc_and_init(
9685 struct niu *np; 9685 struct niu *np;
9686 9686
9687 dev = alloc_etherdev_mq(sizeof(struct niu), NIU_NUM_TXCHAN); 9687 dev = alloc_etherdev_mq(sizeof(struct niu), NIU_NUM_TXCHAN);
9688 if (!dev) { 9688 if (!dev)
9689 dev_err(gen_dev, "Etherdev alloc failed, aborting\n");
9690 return NULL; 9689 return NULL;
9691 }
9692 9690
9693 SET_NETDEV_DEV(dev, gen_dev); 9691 SET_NETDEV_DEV(dev, gen_dev);
9694 9692
diff --git a/drivers/net/ethernet/sun/sunbmac.c b/drivers/net/ethernet/sun/sunbmac.c
index 220f724c3377..f359863b5340 100644
--- a/drivers/net/ethernet/sun/sunbmac.c
+++ b/drivers/net/ethernet/sun/sunbmac.c
@@ -853,7 +853,7 @@ static void bigmac_rx(struct bigmac *bp)
853 /* Trim the original skb for the netif. */ 853 /* Trim the original skb for the netif. */
854 skb_trim(skb, len); 854 skb_trim(skb, len);
855 } else { 855 } else {
856 struct sk_buff *copy_skb = dev_alloc_skb(len + 2); 856 struct sk_buff *copy_skb = netdev_alloc_skb(bp->dev, len + 2);
857 857
858 if (copy_skb == NULL) { 858 if (copy_skb == NULL) {
859 drops++; 859 drops++;
diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c
index 31441a870b0b..ba041596e046 100644
--- a/drivers/net/ethernet/sun/sungem.c
+++ b/drivers/net/ethernet/sun/sungem.c
@@ -2885,7 +2885,6 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
2885 2885
2886 dev = alloc_etherdev(sizeof(*gp)); 2886 dev = alloc_etherdev(sizeof(*gp));
2887 if (!dev) { 2887 if (!dev) {
2888 pr_err("Etherdev alloc failed, aborting\n");
2889 err = -ENOMEM; 2888 err = -ENOMEM;
2890 goto err_disable_device; 2889 goto err_disable_device;
2891 } 2890 }
diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index 09c518655db2..8b627e2f798d 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -2043,7 +2043,7 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
2043 /* Trim the original skb for the netif. */ 2043 /* Trim the original skb for the netif. */
2044 skb_trim(skb, len); 2044 skb_trim(skb, len);
2045 } else { 2045 } else {
2046 struct sk_buff *copy_skb = dev_alloc_skb(len + 2); 2046 struct sk_buff *copy_skb = netdev_alloc_skb(dev, len + 2);
2047 2047
2048 if (copy_skb == NULL) { 2048 if (copy_skb == NULL) {
2049 drops++; 2049 drops++;
diff --git a/drivers/net/ethernet/sun/sunqe.c b/drivers/net/ethernet/sun/sunqe.c
index b28f74367ebe..b42d1c5a6ca1 100644
--- a/drivers/net/ethernet/sun/sunqe.c
+++ b/drivers/net/ethernet/sun/sunqe.c
@@ -435,7 +435,7 @@ static void qe_rx(struct sunqe *qep)
435 dev->stats.rx_length_errors++; 435 dev->stats.rx_length_errors++;
436 dev->stats.rx_dropped++; 436 dev->stats.rx_dropped++;
437 } else { 437 } else {
438 skb = dev_alloc_skb(len + 2); 438 skb = netdev_alloc_skb(dev, len + 2);
439 if (skb == NULL) { 439 if (skb == NULL) {
440 drops++; 440 drops++;
441 dev->stats.rx_dropped++; 441 dev->stats.rx_dropped++;
diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c
index 8c6c059f3489..92a037a8228a 100644
--- a/drivers/net/ethernet/sun/sunvnet.c
+++ b/drivers/net/ethernet/sun/sunvnet.c
@@ -949,10 +949,9 @@ static int __devinit vnet_port_alloc_tx_bufs(struct vnet_port *port)
949 int map_len = (ETH_FRAME_LEN + 7) & ~7; 949 int map_len = (ETH_FRAME_LEN + 7) & ~7;
950 950
951 err = -ENOMEM; 951 err = -ENOMEM;
952 if (!buf) { 952 if (!buf)
953 pr_err("TX buffer allocation failure\n");
954 goto err_out; 953 goto err_out;
955 } 954
956 err = -EFAULT; 955 err = -EFAULT;
957 if ((unsigned long)buf & (8UL - 1)) { 956 if ((unsigned long)buf & (8UL - 1)) {
958 pr_err("TX buffer misaligned\n"); 957 pr_err("TX buffer misaligned\n");
@@ -1027,10 +1026,8 @@ static struct vnet * __devinit vnet_new(const u64 *local_mac)
1027 int err, i; 1026 int err, i;
1028 1027
1029 dev = alloc_etherdev(sizeof(*vp)); 1028 dev = alloc_etherdev(sizeof(*vp));
1030 if (!dev) { 1029 if (!dev)
1031 pr_err("Etherdev alloc failed, aborting\n");
1032 return ERR_PTR(-ENOMEM); 1030 return ERR_PTR(-ENOMEM);
1033 }
1034 1031
1035 for (i = 0; i < ETH_ALEN; i++) 1032 for (i = 0; i < ETH_ALEN; i++)
1036 dev->dev_addr[i] = (*local_mac >> (5 - i) * 8) & 0xff; 1033 dev->dev_addr[i] = (*local_mac >> (5 - i) * 8) & 0xff;
@@ -1165,10 +1162,8 @@ static int __devinit vnet_port_probe(struct vio_dev *vdev,
1165 1162
1166 port = kzalloc(sizeof(*port), GFP_KERNEL); 1163 port = kzalloc(sizeof(*port), GFP_KERNEL);
1167 err = -ENOMEM; 1164 err = -ENOMEM;
1168 if (!port) { 1165 if (!port)
1169 pr_err("Cannot allocate vnet_port\n");
1170 goto err_out_put_mdesc; 1166 goto err_out_put_mdesc;
1171 }
1172 1167
1173 for (i = 0; i < ETH_ALEN; i++) 1168 for (i = 0; i < ETH_ALEN; i++)
1174 port->raddr[i] = (*rmac >> (5 - i) * 8) & 0xff; 1169 port->raddr[i] = (*rmac >> (5 - i) * 8) & 0xff;
diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c
index 4b19e9b0606b..ad973ffc9ff3 100644
--- a/drivers/net/ethernet/tehuti/tehuti.c
+++ b/drivers/net/ethernet/tehuti/tehuti.c
@@ -1089,12 +1089,11 @@ static void bdx_rx_alloc_skbs(struct bdx_priv *priv, struct rxf_fifo *f)
1089 ENTER; 1089 ENTER;
1090 dno = bdx_rxdb_available(db) - 1; 1090 dno = bdx_rxdb_available(db) - 1;
1091 while (dno > 0) { 1091 while (dno > 0) {
1092 skb = dev_alloc_skb(f->m.pktsz + NET_IP_ALIGN); 1092 skb = netdev_alloc_skb(priv->ndev, f->m.pktsz + NET_IP_ALIGN);
1093 if (!skb) { 1093 if (!skb) {
1094 pr_err("NO MEM: dev_alloc_skb failed\n"); 1094 pr_err("NO MEM: netdev_alloc_skb failed\n");
1095 break; 1095 break;
1096 } 1096 }
1097 skb->dev = priv->ndev;
1098 skb_reserve(skb, NET_IP_ALIGN); 1097 skb_reserve(skb, NET_IP_ALIGN);
1099 1098
1100 idx = bdx_rxdb_alloc_elem(db); 1099 idx = bdx_rxdb_alloc_elem(db);
@@ -1258,7 +1257,7 @@ static int bdx_rx_receive(struct bdx_priv *priv, struct rxd_fifo *f, int budget)
1258 skb = dm->skb; 1257 skb = dm->skb;
1259 1258
1260 if (len < BDX_COPYBREAK && 1259 if (len < BDX_COPYBREAK &&
1261 (skb2 = dev_alloc_skb(len + NET_IP_ALIGN))) { 1260 (skb2 = netdev_alloc_skb(priv->ndev, len + NET_IP_ALIGN))) {
1262 skb_reserve(skb2, NET_IP_ALIGN); 1261 skb_reserve(skb2, NET_IP_ALIGN);
1263 /*skb_put(skb2, len); */ 1262 /*skb_put(skb2, len); */
1264 pci_dma_sync_single_for_cpu(priv->pdev, 1263 pci_dma_sync_single_for_cpu(priv->pdev,
@@ -1978,7 +1977,6 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1978 ndev = alloc_etherdev(sizeof(struct bdx_priv)); 1977 ndev = alloc_etherdev(sizeof(struct bdx_priv));
1979 if (!ndev) { 1978 if (!ndev) {
1980 err = -ENOMEM; 1979 err = -ENOMEM;
1981 pr_err("alloc_etherdev failed\n");
1982 goto err_out_iomap; 1980 goto err_out_iomap;
1983 } 1981 }
1984 1982
diff --git a/drivers/net/ethernet/ti/cpmac.c b/drivers/net/ethernet/ti/cpmac.c
index 4d9a28ffd3c3..97e1df330a17 100644
--- a/drivers/net/ethernet/ti/cpmac.c
+++ b/drivers/net/ethernet/ti/cpmac.c
@@ -1143,11 +1143,8 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
1143 } 1143 }
1144 1144
1145 dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES); 1145 dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES);
1146 1146 if (!dev)
1147 if (!dev) {
1148 printk(KERN_ERR "cpmac: Unable to allocate net_device\n");
1149 return -ENOMEM; 1147 return -ENOMEM;
1150 }
1151 1148
1152 platform_set_drvdata(pdev, dev); 1149 platform_set_drvdata(pdev, dev);
1153 priv = netdev_priv(dev); 1150 priv = netdev_priv(dev);
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 4fa0bcb25dfc..6b0659c59ddd 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -992,10 +992,9 @@ static irqreturn_t emac_irq(int irq, void *dev_id)
992 992
993static struct sk_buff *emac_rx_alloc(struct emac_priv *priv) 993static struct sk_buff *emac_rx_alloc(struct emac_priv *priv)
994{ 994{
995 struct sk_buff *skb = dev_alloc_skb(priv->rx_buf_size); 995 struct sk_buff *skb = netdev_alloc_skb(priv->ndev, priv->rx_buf_size);
996 if (WARN_ON(!skb)) 996 if (WARN_ON(!skb))
997 return NULL; 997 return NULL;
998 skb->dev = priv->ndev;
999 skb_reserve(skb, NET_IP_ALIGN); 998 skb_reserve(skb, NET_IP_ALIGN);
1000 return skb; 999 return skb;
1001} 1000}
@@ -1790,7 +1789,6 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev)
1790 1789
1791 ndev = alloc_etherdev(sizeof(struct emac_priv)); 1790 ndev = alloc_etherdev(sizeof(struct emac_priv));
1792 if (!ndev) { 1791 if (!ndev) {
1793 dev_err(&pdev->dev, "error allocating net_device\n");
1794 rc = -ENOMEM; 1792 rc = -ENOMEM;
1795 goto free_clk; 1793 goto free_clk;
1796 } 1794 }
diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c
index 9c0dd6b8d6c9..817ad3bc4957 100644
--- a/drivers/net/ethernet/ti/tlan.c
+++ b/drivers/net/ethernet/ti/tlan.c
@@ -486,7 +486,6 @@ static int __devinit tlan_probe1(struct pci_dev *pdev,
486 486
487 dev = alloc_etherdev(sizeof(struct tlan_priv)); 487 dev = alloc_etherdev(sizeof(struct tlan_priv));
488 if (dev == NULL) { 488 if (dev == NULL) {
489 pr_err("Could not allocate memory for device\n");
490 rc = -ENOMEM; 489 rc = -ENOMEM;
491 goto err_out_regions; 490 goto err_out_regions;
492 } 491 }
diff --git a/drivers/net/ethernet/tile/tilepro.c b/drivers/net/ethernet/tile/tilepro.c
index d9951afb9269..a8e5daaef6fa 100644
--- a/drivers/net/ethernet/tile/tilepro.c
+++ b/drivers/net/ethernet/tile/tilepro.c
@@ -419,7 +419,7 @@ static bool tile_net_provide_needed_buffer(struct tile_net_cpu *info,
419#endif 419#endif
420 420
421 /* Avoid "false sharing" with last cache line. */ 421 /* Avoid "false sharing" with last cache line. */
422 /* ISSUE: This is already done by "dev_alloc_skb()". */ 422 /* ISSUE: This is already done by "netdev_alloc_skb()". */
423 unsigned int len = 423 unsigned int len =
424 (((small ? LIPP_SMALL_PACKET_SIZE : large_size) + 424 (((small ? LIPP_SMALL_PACKET_SIZE : large_size) +
425 CHIP_L2_LINE_SIZE() - 1) & -CHIP_L2_LINE_SIZE()); 425 CHIP_L2_LINE_SIZE() - 1) & -CHIP_L2_LINE_SIZE());
@@ -433,7 +433,7 @@ static bool tile_net_provide_needed_buffer(struct tile_net_cpu *info,
433 struct sk_buff **skb_ptr; 433 struct sk_buff **skb_ptr;
434 434
435 /* Request 96 extra bytes for alignment purposes. */ 435 /* Request 96 extra bytes for alignment purposes. */
436 skb = dev_alloc_skb(len + padding); 436 skb = netdev_alloc_skb(info->napi->dev, len + padding);
437 if (skb == NULL) 437 if (skb == NULL)
438 return false; 438 return false;
439 439
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c
index fd4ed7f8cfa1..5c14f82c4954 100644
--- a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c
+++ b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c
@@ -1621,10 +1621,9 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
1621 kfree(target->hwinfo); 1621 kfree(target->hwinfo);
1622 target->hwinfo = kzalloc(be16_to_cpu(scan_info->size), 1622 target->hwinfo = kzalloc(be16_to_cpu(scan_info->size),
1623 GFP_KERNEL); 1623 GFP_KERNEL);
1624 if (!target->hwinfo) { 1624 if (!target->hwinfo)
1625 pr_info("%s: kzalloc failed\n", __func__);
1626 continue; 1625 continue;
1627 } 1626
1628 /* copy hw scan info */ 1627 /* copy hw scan info */
1629 memcpy(target->hwinfo, scan_info, scan_info->size); 1628 memcpy(target->hwinfo, scan_info, scan_info->size);
1630 target->essid_len = strnlen(scan_info->essid, 1629 target->essid_len = strnlen(scan_info->essid,
diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/ethernet/toshiba/tc35815.c
index 71b785cd7563..d117ad475c3e 100644
--- a/drivers/net/ethernet/toshiba/tc35815.c
+++ b/drivers/net/ethernet/toshiba/tc35815.c
@@ -453,7 +453,7 @@ static struct sk_buff *alloc_rxbuf_skb(struct net_device *dev,
453 dma_addr_t *dma_handle) 453 dma_addr_t *dma_handle)
454{ 454{
455 struct sk_buff *skb; 455 struct sk_buff *skb;
456 skb = dev_alloc_skb(RX_BUF_SIZE); 456 skb = netdev_alloc_skb(dev, RX_BUF_SIZE);
457 if (!skb) 457 if (!skb)
458 return NULL; 458 return NULL;
459 *dma_handle = pci_map_single(hwdev, skb->data, RX_BUF_SIZE, 459 *dma_handle = pci_map_single(hwdev, skb->data, RX_BUF_SIZE,
@@ -808,10 +808,9 @@ static int __devinit tc35815_init_one(struct pci_dev *pdev,
808 808
809 /* dev zeroed in alloc_etherdev */ 809 /* dev zeroed in alloc_etherdev */
810 dev = alloc_etherdev(sizeof(*lp)); 810 dev = alloc_etherdev(sizeof(*lp));
811 if (dev == NULL) { 811 if (dev == NULL)
812 dev_err(&pdev->dev, "unable to alloc new ethernet\n");
813 return -ENOMEM; 812 return -ENOMEM;
814 } 813
815 SET_NETDEV_DEV(dev, &pdev->dev); 814 SET_NETDEV_DEV(dev, &pdev->dev);
816 lp = netdev_priv(dev); 815 lp = netdev_priv(dev);
817 lp->dev = dev; 816 lp->dev = dev;
diff --git a/drivers/net/ethernet/tundra/tsi108_eth.c b/drivers/net/ethernet/tundra/tsi108_eth.c
index 164fb775d7b3..fc5521c9c089 100644
--- a/drivers/net/ethernet/tundra/tsi108_eth.c
+++ b/drivers/net/ethernet/tundra/tsi108_eth.c
@@ -1582,10 +1582,8 @@ tsi108_init_one(struct platform_device *pdev)
1582 /* Create an ethernet device instance */ 1582 /* Create an ethernet device instance */
1583 1583
1584 dev = alloc_etherdev(sizeof(struct tsi108_prv_data)); 1584 dev = alloc_etherdev(sizeof(struct tsi108_prv_data));
1585 if (!dev) { 1585 if (!dev)
1586 printk("tsi108_eth: Could not allocate a device structure\n");
1587 return -ENOMEM; 1586 return -ENOMEM;
1588 }
1589 1587
1590 printk("tsi108_eth%d: probe...\n", pdev->id); 1588 printk("tsi108_eth%d: probe...\n", pdev->id);
1591 data = netdev_priv(dev); 1589 data = netdev_priv(dev);
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index 10b18eb63d25..cb2ff28a0602 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -927,7 +927,6 @@ static int __devinit rhine_init_one(struct pci_dev *pdev,
927 dev = alloc_etherdev(sizeof(struct rhine_private)); 927 dev = alloc_etherdev(sizeof(struct rhine_private));
928 if (!dev) { 928 if (!dev) {
929 rc = -ENOMEM; 929 rc = -ENOMEM;
930 dev_err(&pdev->dev, "alloc_etherdev failed\n");
931 goto err_out; 930 goto err_out;
932 } 931 }
933 SET_NETDEV_DEV(dev, &pdev->dev); 932 SET_NETDEV_DEV(dev, &pdev->dev);
@@ -1156,7 +1155,6 @@ static void alloc_rbufs(struct net_device *dev)
1156 rp->rx_skbuff[i] = skb; 1155 rp->rx_skbuff[i] = skb;
1157 if (skb == NULL) 1156 if (skb == NULL)
1158 break; 1157 break;
1159 skb->dev = dev; /* Mark as being used by this device. */
1160 1158
1161 rp->rx_skbuff_dma[i] = 1159 rp->rx_skbuff_dma[i] =
1162 pci_map_single(rp->pdev, skb->data, rp->rx_buf_sz, 1160 pci_map_single(rp->pdev, skb->data, rp->rx_buf_sz,
@@ -1941,7 +1939,6 @@ static int rhine_rx(struct net_device *dev, int limit)
1941 rp->rx_skbuff[entry] = skb; 1939 rp->rx_skbuff[entry] = skb;
1942 if (skb == NULL) 1940 if (skb == NULL)
1943 break; /* Better luck next round. */ 1941 break; /* Better luck next round. */
1944 skb->dev = dev; /* Mark as being used by this device. */
1945 rp->rx_skbuff_dma[entry] = 1942 rp->rx_skbuff_dma[entry] =
1946 pci_map_single(rp->pdev, skb->data, 1943 pci_map_single(rp->pdev, skb->data,
1947 rp->rx_buf_sz, 1944 rp->rx_buf_sz,
diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c
index cb35b14b73bb..8a5d7c100a5e 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -1509,7 +1509,7 @@ static int velocity_alloc_rx_buf(struct velocity_info *vptr, int idx)
1509 struct rx_desc *rd = &(vptr->rx.ring[idx]); 1509 struct rx_desc *rd = &(vptr->rx.ring[idx]);
1510 struct velocity_rd_info *rd_info = &(vptr->rx.info[idx]); 1510 struct velocity_rd_info *rd_info = &(vptr->rx.info[idx]);
1511 1511
1512 rd_info->skb = dev_alloc_skb(vptr->rx.buf_sz + 64); 1512 rd_info->skb = netdev_alloc_skb(vptr->dev, vptr->rx.buf_sz + 64);
1513 if (rd_info->skb == NULL) 1513 if (rd_info->skb == NULL)
1514 return -ENOMEM; 1514 return -ENOMEM;
1515 1515
@@ -2730,10 +2730,8 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi
2730 } 2730 }
2731 2731
2732 dev = alloc_etherdev(sizeof(struct velocity_info)); 2732 dev = alloc_etherdev(sizeof(struct velocity_info));
2733 if (!dev) { 2733 if (!dev)
2734 dev_err(&pdev->dev, "allocate net device failed.\n");
2735 goto out; 2734 goto out;
2736 }
2737 2735
2738 /* Chain it all together */ 2736 /* Chain it all together */
2739 2737
diff --git a/drivers/net/ethernet/xilinx/Kconfig b/drivers/net/ethernet/xilinx/Kconfig
index d5a826063a82..5778a4ae1164 100644
--- a/drivers/net/ethernet/xilinx/Kconfig
+++ b/drivers/net/ethernet/xilinx/Kconfig
@@ -25,6 +25,14 @@ config XILINX_EMACLITE
25 ---help--- 25 ---help---
26 This driver supports the 10/100 Ethernet Lite from Xilinx. 26 This driver supports the 10/100 Ethernet Lite from Xilinx.
27 27
28config XILINX_AXI_EMAC
29 tristate "Xilinx 10/100/1000 AXI Ethernet support"
30 depends on (PPC32 || MICROBLAZE)
31 select PHYLIB
32 ---help---
33 This driver supports the 10/100/1000 Ethernet from Xilinx for the
34 AXI bus interface used in Xilinx Virtex FPGAs.
35
28config XILINX_LL_TEMAC 36config XILINX_LL_TEMAC
29 tristate "Xilinx LL TEMAC (LocalLink Tri-mode Ethernet MAC) driver" 37 tristate "Xilinx LL TEMAC (LocalLink Tri-mode Ethernet MAC) driver"
30 depends on (PPC || MICROBLAZE) 38 depends on (PPC || MICROBLAZE)
diff --git a/drivers/net/ethernet/xilinx/Makefile b/drivers/net/ethernet/xilinx/Makefile
index 5feac734ea45..214205e975e3 100644
--- a/drivers/net/ethernet/xilinx/Makefile
+++ b/drivers/net/ethernet/xilinx/Makefile
@@ -5,3 +5,5 @@
5ll_temac-objs := ll_temac_main.o ll_temac_mdio.o 5ll_temac-objs := ll_temac_main.o ll_temac_mdio.o
6obj-$(CONFIG_XILINX_LL_TEMAC) += ll_temac.o 6obj-$(CONFIG_XILINX_LL_TEMAC) += ll_temac.o
7obj-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o 7obj-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o
8xilinx_emac-objs := xilinx_axienet_main.o xilinx_axienet_mdio.o
9obj-$(CONFIG_XILINX_AXI_EMAC) += xilinx_emac.o
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index f21addb1db95..d8eb9c9e3ee2 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -1011,10 +1011,9 @@ static int __devinit temac_of_probe(struct platform_device *op)
1011 1011
1012 /* Init network device structure */ 1012 /* Init network device structure */
1013 ndev = alloc_etherdev(sizeof(*lp)); 1013 ndev = alloc_etherdev(sizeof(*lp));
1014 if (!ndev) { 1014 if (!ndev)
1015 dev_err(&op->dev, "could not allocate device.\n");
1016 return -ENOMEM; 1015 return -ENOMEM;
1017 } 1016
1018 ether_setup(ndev); 1017 ether_setup(ndev);
1019 dev_set_drvdata(&op->dev, ndev); 1018 dev_set_drvdata(&op->dev, ndev);
1020 SET_NETDEV_DEV(ndev, &op->dev); 1019 SET_NETDEV_DEV(ndev, &op->dev);
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h
new file mode 100644
index 000000000000..cc83af083fd7
--- /dev/null
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h
@@ -0,0 +1,508 @@
1/*
2 * Definitions for Xilinx Axi Ethernet device driver.
3 *
4 * Copyright (c) 2009 Secret Lab Technologies, Ltd.
5 * Copyright (c) 2010 Xilinx, Inc. All rights reserved.
6 * Copyright (c) 2012 Daniel Borkmann, <daniel.borkmann@tik.ee.ethz.ch>
7 * Copyright (c) 2012 Ariane Keller, <ariane.keller@tik.ee.ethz.ch>
8 */
9
10#ifndef XILINX_AXIENET_H
11#define XILINX_AXIENET_H
12
13#include <linux/netdevice.h>
14#include <linux/spinlock.h>
15#include <linux/interrupt.h>
16
17/* Packet size info */
18#define XAE_HDR_SIZE 14 /* Size of Ethernet header */
19#define XAE_HDR_VLAN_SIZE 18 /* Size of an Ethernet hdr + VLAN */
20#define XAE_TRL_SIZE 4 /* Size of Ethernet trailer (FCS) */
21#define XAE_MTU 1500 /* Max MTU of an Ethernet frame */
22#define XAE_JUMBO_MTU 9000 /* Max MTU of a jumbo Eth. frame */
23
24#define XAE_MAX_FRAME_SIZE (XAE_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE)
25#define XAE_MAX_VLAN_FRAME_SIZE (XAE_MTU + XAE_HDR_VLAN_SIZE + XAE_TRL_SIZE)
26#define XAE_MAX_JUMBO_FRAME_SIZE (XAE_JUMBO_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE)
27
28/* Configuration options */
29
30/* Accept all incoming packets. Default: disabled (cleared) */
31#define XAE_OPTION_PROMISC (1 << 0)
32
33/* Jumbo frame support for Tx & Rx. Default: disabled (cleared) */
34#define XAE_OPTION_JUMBO (1 << 1)
35
36/* VLAN Rx & Tx frame support. Default: disabled (cleared) */
37#define XAE_OPTION_VLAN (1 << 2)
38
39/* Enable recognition of flow control frames on Rx. Default: enabled (set) */
40#define XAE_OPTION_FLOW_CONTROL (1 << 4)
41
42/* Strip FCS and PAD from incoming frames. Note: PAD from VLAN frames is not
43 * stripped. Default: disabled (set) */
44#define XAE_OPTION_FCS_STRIP (1 << 5)
45
46/* Generate FCS field and add PAD automatically for outgoing frames.
47 * Default: enabled (set) */
48#define XAE_OPTION_FCS_INSERT (1 << 6)
49
50/* Enable Length/Type error checking for incoming frames. When this option is
51 * set, the MAC will filter frames that have a mismatched type/length field
52 * and if XAE_OPTION_REPORT_RXERR is set, the user is notified when these
53 * types of frames are encountered. When this option is cleared, the MAC will
54 * allow these types of frames to be received. Default: enabled (set) */
55#define XAE_OPTION_LENTYPE_ERR (1 << 7)
56
57/* Enable the transmitter. Default: enabled (set) */
58#define XAE_OPTION_TXEN (1 << 11)
59
60/* Enable the receiver. Default: enabled (set) */
61#define XAE_OPTION_RXEN (1 << 12)
62
63/* Default options set when device is initialized or reset */
64#define XAE_OPTION_DEFAULTS \
65 (XAE_OPTION_TXEN | \
66 XAE_OPTION_FLOW_CONTROL | \
67 XAE_OPTION_RXEN)
68
69/* Axi DMA Register definitions */
70
71#define XAXIDMA_TX_CR_OFFSET 0x00000000 /* Channel control */
72#define XAXIDMA_TX_SR_OFFSET 0x00000004 /* Status */
73#define XAXIDMA_TX_CDESC_OFFSET 0x00000008 /* Current descriptor pointer */
74#define XAXIDMA_TX_TDESC_OFFSET 0x00000010 /* Tail descriptor pointer */
75
76#define XAXIDMA_RX_CR_OFFSET 0x00000030 /* Channel control */
77#define XAXIDMA_RX_SR_OFFSET 0x00000034 /* Status */
78#define XAXIDMA_RX_CDESC_OFFSET 0x00000038 /* Current descriptor pointer */
79#define XAXIDMA_RX_TDESC_OFFSET 0x00000040 /* Tail descriptor pointer */
80
81#define XAXIDMA_CR_RUNSTOP_MASK 0x00000001 /* Start/stop DMA channel */
82#define XAXIDMA_CR_RESET_MASK 0x00000004 /* Reset DMA engine */
83
84#define XAXIDMA_BD_NDESC_OFFSET 0x00 /* Next descriptor pointer */
85#define XAXIDMA_BD_BUFA_OFFSET 0x08 /* Buffer address */
86#define XAXIDMA_BD_CTRL_LEN_OFFSET 0x18 /* Control/buffer length */
87#define XAXIDMA_BD_STS_OFFSET 0x1C /* Status */
88#define XAXIDMA_BD_USR0_OFFSET 0x20 /* User IP specific word0 */
89#define XAXIDMA_BD_USR1_OFFSET 0x24 /* User IP specific word1 */
90#define XAXIDMA_BD_USR2_OFFSET 0x28 /* User IP specific word2 */
91#define XAXIDMA_BD_USR3_OFFSET 0x2C /* User IP specific word3 */
92#define XAXIDMA_BD_USR4_OFFSET 0x30 /* User IP specific word4 */
93#define XAXIDMA_BD_ID_OFFSET 0x34 /* Sw ID */
94#define XAXIDMA_BD_HAS_STSCNTRL_OFFSET 0x38 /* Whether has stscntrl strm */
95#define XAXIDMA_BD_HAS_DRE_OFFSET 0x3C /* Whether has DRE */
96
97#define XAXIDMA_BD_HAS_DRE_SHIFT 8 /* Whether has DRE shift */
98#define XAXIDMA_BD_HAS_DRE_MASK 0xF00 /* Whether has DRE mask */
99#define XAXIDMA_BD_WORDLEN_MASK 0xFF /* Whether has DRE mask */
100
101#define XAXIDMA_BD_CTRL_LENGTH_MASK 0x007FFFFF /* Requested len */
102#define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */
103#define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */
104#define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000 /* All control bits */
105
106#define XAXIDMA_DELAY_MASK 0xFF000000 /* Delay timeout counter */
107#define XAXIDMA_COALESCE_MASK 0x00FF0000 /* Coalesce counter */
108
109#define XAXIDMA_DELAY_SHIFT 24
110#define XAXIDMA_COALESCE_SHIFT 16
111
112#define XAXIDMA_IRQ_IOC_MASK 0x00001000 /* Completion intr */
113#define XAXIDMA_IRQ_DELAY_MASK 0x00002000 /* Delay interrupt */
114#define XAXIDMA_IRQ_ERROR_MASK 0x00004000 /* Error interrupt */
115#define XAXIDMA_IRQ_ALL_MASK 0x00007000 /* All interrupts */
116
117/* Default TX/RX Threshold and waitbound values for SGDMA mode */
118#define XAXIDMA_DFT_TX_THRESHOLD 24
119#define XAXIDMA_DFT_TX_WAITBOUND 254
120#define XAXIDMA_DFT_RX_THRESHOLD 24
121#define XAXIDMA_DFT_RX_WAITBOUND 254
122
123#define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */
124#define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */
125#define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000 /* All control bits */
126
127#define XAXIDMA_BD_STS_ACTUAL_LEN_MASK 0x007FFFFF /* Actual len */
128#define XAXIDMA_BD_STS_COMPLETE_MASK 0x80000000 /* Completed */
129#define XAXIDMA_BD_STS_DEC_ERR_MASK 0x40000000 /* Decode error */
130#define XAXIDMA_BD_STS_SLV_ERR_MASK 0x20000000 /* Slave error */
131#define XAXIDMA_BD_STS_INT_ERR_MASK 0x10000000 /* Internal err */
132#define XAXIDMA_BD_STS_ALL_ERR_MASK 0x70000000 /* All errors */
133#define XAXIDMA_BD_STS_RXSOF_MASK 0x08000000 /* First rx pkt */
134#define XAXIDMA_BD_STS_RXEOF_MASK 0x04000000 /* Last rx pkt */
135#define XAXIDMA_BD_STS_ALL_MASK 0xFC000000 /* All status bits */
136
137#define XAXIDMA_BD_MINIMUM_ALIGNMENT 0x40
138
139/* Axi Ethernet registers definition */
140#define XAE_RAF_OFFSET 0x00000000 /* Reset and Address filter */
141#define XAE_TPF_OFFSET 0x00000004 /* Tx Pause Frame */
142#define XAE_IFGP_OFFSET 0x00000008 /* Tx Inter-frame gap adjustment*/
143#define XAE_IS_OFFSET 0x0000000C /* Interrupt status */
144#define XAE_IP_OFFSET 0x00000010 /* Interrupt pending */
145#define XAE_IE_OFFSET 0x00000014 /* Interrupt enable */
146#define XAE_TTAG_OFFSET 0x00000018 /* Tx VLAN TAG */
147#define XAE_RTAG_OFFSET 0x0000001C /* Rx VLAN TAG */
148#define XAE_UAWL_OFFSET 0x00000020 /* Unicast address word lower */
149#define XAE_UAWU_OFFSET 0x00000024 /* Unicast address word upper */
150#define XAE_TPID0_OFFSET 0x00000028 /* VLAN TPID0 register */
151#define XAE_TPID1_OFFSET 0x0000002C /* VLAN TPID1 register */
152#define XAE_PPST_OFFSET 0x00000030 /* PCS PMA Soft Temac Status Reg */
153#define XAE_RCW0_OFFSET 0x00000400 /* Rx Configuration Word 0 */
154#define XAE_RCW1_OFFSET 0x00000404 /* Rx Configuration Word 1 */
155#define XAE_TC_OFFSET 0x00000408 /* Tx Configuration */
156#define XAE_FCC_OFFSET 0x0000040C /* Flow Control Configuration */
157#define XAE_EMMC_OFFSET 0x00000410 /* EMAC mode configuration */
158#define XAE_PHYC_OFFSET 0x00000414 /* RGMII/SGMII configuration */
159#define XAE_MDIO_MC_OFFSET 0x00000500 /* MII Management Config */
160#define XAE_MDIO_MCR_OFFSET 0x00000504 /* MII Management Control */
161#define XAE_MDIO_MWD_OFFSET 0x00000508 /* MII Management Write Data */
162#define XAE_MDIO_MRD_OFFSET 0x0000050C /* MII Management Read Data */
163#define XAE_MDIO_MIS_OFFSET 0x00000600 /* MII Management Interrupt Status */
164#define XAE_MDIO_MIP_OFFSET 0x00000620 /* MII Mgmt Interrupt Pending
165 * register offset */
166#define XAE_MDIO_MIE_OFFSET 0x00000640 /* MII Management Interrupt Enable
167 * register offset */
168#define XAE_MDIO_MIC_OFFSET 0x00000660 /* MII Management Interrupt Clear
169 * register offset. */
170#define XAE_UAW0_OFFSET 0x00000700 /* Unicast address word 0 */
171#define XAE_UAW1_OFFSET 0x00000704 /* Unicast address word 1 */
172#define XAE_FMI_OFFSET 0x00000708 /* Filter Mask Index */
173#define XAE_AF0_OFFSET 0x00000710 /* Address Filter 0 */
174#define XAE_AF1_OFFSET 0x00000714 /* Address Filter 1 */
175
176#define XAE_TX_VLAN_DATA_OFFSET 0x00004000 /* TX VLAN data table address */
177#define XAE_RX_VLAN_DATA_OFFSET 0x00008000 /* RX VLAN data table address */
178#define XAE_MCAST_TABLE_OFFSET 0x00020000 /* Multicast table address */
179
180/* Bit Masks for Axi Ethernet RAF register */
181#define XAE_RAF_MCSTREJ_MASK 0x00000002 /* Reject receive multicast
182 * destination address */
183#define XAE_RAF_BCSTREJ_MASK 0x00000004 /* Reject receive broadcast
184 * destination address */
185#define XAE_RAF_TXVTAGMODE_MASK 0x00000018 /* Tx VLAN TAG mode */
186#define XAE_RAF_RXVTAGMODE_MASK 0x00000060 /* Rx VLAN TAG mode */
187#define XAE_RAF_TXVSTRPMODE_MASK 0x00000180 /* Tx VLAN STRIP mode */
188#define XAE_RAF_RXVSTRPMODE_MASK 0x00000600 /* Rx VLAN STRIP mode */
189#define XAE_RAF_NEWFNCENBL_MASK 0x00000800 /* New function mode */
190#define XAE_RAF_EMULTIFLTRENBL_MASK 0x00001000 /* Exteneded Multicast
191 * Filtering mode
192 */
193#define XAE_RAF_STATSRST_MASK 0x00002000 /* Stats. Counter Reset */
194#define XAE_RAF_RXBADFRMEN_MASK 0x00004000 /* Recv Bad Frame Enable */
195#define XAE_RAF_TXVTAGMODE_SHIFT 3 /* Tx Tag mode shift bits */
196#define XAE_RAF_RXVTAGMODE_SHIFT 5 /* Rx Tag mode shift bits */
197#define XAE_RAF_TXVSTRPMODE_SHIFT 7 /* Tx strip mode shift bits*/
198#define XAE_RAF_RXVSTRPMODE_SHIFT 9 /* Rx Strip mode shift bits*/
199
200/* Bit Masks for Axi Ethernet TPF and IFGP registers */
201#define XAE_TPF_TPFV_MASK 0x0000FFFF /* Tx pause frame value */
202#define XAE_IFGP0_IFGP_MASK 0x0000007F /* Transmit inter-frame
203 * gap adjustment value */
204
205/* Bit Masks for Axi Ethernet IS, IE and IP registers, Same masks apply
206 * for all 3 registers. */
207#define XAE_INT_HARDACSCMPLT_MASK 0x00000001 /* Hard register access
208 * complete */
209#define XAE_INT_AUTONEG_MASK 0x00000002 /* Auto negotiation
210 * complete */
211#define XAE_INT_RXCMPIT_MASK 0x00000004 /* Rx complete */
212#define XAE_INT_RXRJECT_MASK 0x00000008 /* Rx frame rejected */
213#define XAE_INT_RXFIFOOVR_MASK 0x00000010 /* Rx fifo overrun */
214#define XAE_INT_TXCMPIT_MASK 0x00000020 /* Tx complete */
215#define XAE_INT_RXDCMLOCK_MASK 0x00000040 /* Rx Dcm Lock */
216#define XAE_INT_MGTRDY_MASK 0x00000080 /* MGT clock Lock */
217#define XAE_INT_PHYRSTCMPLT_MASK 0x00000100 /* Phy Reset complete */
218#define XAE_INT_ALL_MASK 0x0000003F /* All the ints */
219
220#define XAE_INT_RECV_ERROR_MASK \
221 (XAE_INT_RXRJECT_MASK | XAE_INT_RXFIFOOVR_MASK) /* INT bits that
222 * indicate receive
223 * errors */
224
225/* Bit masks for Axi Ethernet VLAN TPID Word 0 register */
226#define XAE_TPID_0_MASK 0x0000FFFF /* TPID 0 */
227#define XAE_TPID_1_MASK 0xFFFF0000 /* TPID 1 */
228
229/* Bit masks for Axi Ethernet VLAN TPID Word 1 register */
230#define XAE_TPID_2_MASK 0x0000FFFF /* TPID 0 */
231#define XAE_TPID_3_MASK 0xFFFF0000 /* TPID 1 */
232
233/* Bit masks for Axi Ethernet RCW1 register */
234#define XAE_RCW1_RST_MASK 0x80000000 /* Reset */
235#define XAE_RCW1_JUM_MASK 0x40000000 /* Jumbo frame enable */
236#define XAE_RCW1_FCS_MASK 0x20000000 /* In-Band FCS enable
237 * (FCS not stripped) */
238#define XAE_RCW1_RX_MASK 0x10000000 /* Receiver enable */
239#define XAE_RCW1_VLAN_MASK 0x08000000 /* VLAN frame enable */
240#define XAE_RCW1_LT_DIS_MASK 0x02000000 /* Length/type field valid check
241 * disable */
242#define XAE_RCW1_CL_DIS_MASK 0x01000000 /* Control frame Length check
243 * disable */
244#define XAE_RCW1_PAUSEADDR_MASK 0x0000FFFF /* Pause frame source address
245 * bits [47:32]. Bits [31:0] are
246 * stored in register RCW0 */
247
248/* Bit masks for Axi Ethernet TC register */
249#define XAE_TC_RST_MASK 0x80000000 /* Reset */
250#define XAE_TC_JUM_MASK 0x40000000 /* Jumbo frame enable */
251#define XAE_TC_FCS_MASK 0x20000000 /* In-Band FCS enable
252 * (FCS not generated) */
253#define XAE_TC_TX_MASK 0x10000000 /* Transmitter enable */
254#define XAE_TC_VLAN_MASK 0x08000000 /* VLAN frame enable */
255#define XAE_TC_IFG_MASK 0x02000000 /* Inter-frame gap adjustment
256 * enable */
257
258/* Bit masks for Axi Ethernet FCC register */
259#define XAE_FCC_FCRX_MASK 0x20000000 /* Rx flow control enable */
260#define XAE_FCC_FCTX_MASK 0x40000000 /* Tx flow control enable */
261
262/* Bit masks for Axi Ethernet EMMC register */
263#define XAE_EMMC_LINKSPEED_MASK 0xC0000000 /* Link speed */
264#define XAE_EMMC_RGMII_MASK 0x20000000 /* RGMII mode enable */
265#define XAE_EMMC_SGMII_MASK 0x10000000 /* SGMII mode enable */
266#define XAE_EMMC_GPCS_MASK 0x08000000 /* 1000BaseX mode enable */
267#define XAE_EMMC_HOST_MASK 0x04000000 /* Host interface enable */
268#define XAE_EMMC_TX16BIT 0x02000000 /* 16 bit Tx client enable */
269#define XAE_EMMC_RX16BIT 0x01000000 /* 16 bit Rx client enable */
270#define XAE_EMMC_LINKSPD_10 0x00000000 /* Link Speed mask for 10 Mbit */
271#define XAE_EMMC_LINKSPD_100 0x40000000 /* Link Speed mask for 100 Mbit */
272#define XAE_EMMC_LINKSPD_1000 0x80000000 /* Link Speed mask for 1000 Mbit */
273
274/* Bit masks for Axi Ethernet PHYC register */
275#define XAE_PHYC_SGMIILINKSPEED_MASK 0xC0000000 /* SGMII link speed mask*/
276#define XAE_PHYC_RGMIILINKSPEED_MASK 0x0000000C /* RGMII link speed */
277#define XAE_PHYC_RGMIIHD_MASK 0x00000002 /* RGMII Half-duplex */
278#define XAE_PHYC_RGMIILINK_MASK 0x00000001 /* RGMII link status */
279#define XAE_PHYC_RGLINKSPD_10 0x00000000 /* RGMII link 10 Mbit */
280#define XAE_PHYC_RGLINKSPD_100 0x00000004 /* RGMII link 100 Mbit */
281#define XAE_PHYC_RGLINKSPD_1000 0x00000008 /* RGMII link 1000 Mbit */
282#define XAE_PHYC_SGLINKSPD_10 0x00000000 /* SGMII link 10 Mbit */
283#define XAE_PHYC_SGLINKSPD_100 0x40000000 /* SGMII link 100 Mbit */
284#define XAE_PHYC_SGLINKSPD_1000 0x80000000 /* SGMII link 1000 Mbit */
285
286/* Bit masks for Axi Ethernet MDIO interface MC register */
287#define XAE_MDIO_MC_MDIOEN_MASK 0x00000040 /* MII management enable */
288#define XAE_MDIO_MC_CLOCK_DIVIDE_MAX 0x3F /* Maximum MDIO divisor */
289
290/* Bit masks for Axi Ethernet MDIO interface MCR register */
291#define XAE_MDIO_MCR_PHYAD_MASK 0x1F000000 /* Phy Address Mask */
292#define XAE_MDIO_MCR_PHYAD_SHIFT 24 /* Phy Address Shift */
293#define XAE_MDIO_MCR_REGAD_MASK 0x001F0000 /* Reg Address Mask */
294#define XAE_MDIO_MCR_REGAD_SHIFT 16 /* Reg Address Shift */
295#define XAE_MDIO_MCR_OP_MASK 0x0000C000 /* Operation Code Mask */
296#define XAE_MDIO_MCR_OP_SHIFT 13 /* Operation Code Shift */
297#define XAE_MDIO_MCR_OP_READ_MASK 0x00008000 /* Op Code Read Mask */
298#define XAE_MDIO_MCR_OP_WRITE_MASK 0x00004000 /* Op Code Write Mask */
299#define XAE_MDIO_MCR_INITIATE_MASK 0x00000800 /* Ready Mask */
300#define XAE_MDIO_MCR_READY_MASK 0x00000080 /* Ready Mask */
301
302/* Bit masks for Axi Ethernet MDIO interface MIS, MIP, MIE, MIC registers */
303#define XAE_MDIO_INT_MIIM_RDY_MASK 0x00000001 /* MIIM Interrupt */
304
305/* Bit masks for Axi Ethernet UAW1 register */
306#define XAE_UAW1_UNICASTADDR_MASK 0x0000FFFF /* Station address bits
307 * [47:32]; Station address
308 * bits [31:0] are stored in
309 * register UAW0 */
310
311/* Bit masks for Axi Ethernet FMI register */
312#define XAE_FMI_PM_MASK 0x80000000 /* Promis. mode enable */
313#define XAE_FMI_IND_MASK 0x00000003 /* Index Mask */
314
315#define XAE_MDIO_DIV_DFT 29 /* Default MDIO clock divisor */
316
317/* Defines for different options for C_PHY_TYPE parameter in Axi Ethernet IP */
318#define XAE_PHY_TYPE_MII 0
319#define XAE_PHY_TYPE_GMII 1
320#define XAE_PHY_TYPE_RGMII_1_3 2
321#define XAE_PHY_TYPE_RGMII_2_0 3
322#define XAE_PHY_TYPE_SGMII 4
323#define XAE_PHY_TYPE_1000BASE_X 5
324
325#define XAE_MULTICAST_CAM_TABLE_NUM 4 /* Total number of entries in the
326 * hardware multicast table. */
327
328/* Axi Ethernet Synthesis features */
329#define XAE_FEATURE_PARTIAL_RX_CSUM (1 << 0)
330#define XAE_FEATURE_PARTIAL_TX_CSUM (1 << 1)
331#define XAE_FEATURE_FULL_RX_CSUM (1 << 2)
332#define XAE_FEATURE_FULL_TX_CSUM (1 << 3)
333
334#define XAE_NO_CSUM_OFFLOAD 0
335
336#define XAE_FULL_CSUM_STATUS_MASK 0x00000038
337#define XAE_IP_UDP_CSUM_VALIDATED 0x00000003
338#define XAE_IP_TCP_CSUM_VALIDATED 0x00000002
339
340#define DELAY_OF_ONE_MILLISEC 1000
341
342/**
343 * struct axidma_bd - Axi Dma buffer descriptor layout
344 * @next: MM2S/S2MM Next Descriptor Pointer
345 * @reserved1: Reserved and not used
346 * @phys: MM2S/S2MM Buffer Address
347 * @reserved2: Reserved and not used
348 * @reserved3: Reserved and not used
349 * @reserved4: Reserved and not used
350 * @cntrl: MM2S/S2MM Control value
351 * @status: MM2S/S2MM Status value
352 * @app0: MM2S/S2MM User Application Field 0.
353 * @app1: MM2S/S2MM User Application Field 1.
354 * @app2: MM2S/S2MM User Application Field 2.
355 * @app3: MM2S/S2MM User Application Field 3.
356 * @app4: MM2S/S2MM User Application Field 4.
357 * @sw_id_offset: MM2S/S2MM Sw ID
358 * @reserved5: Reserved and not used
359 * @reserved6: Reserved and not used
360 */
361struct axidma_bd {
362 u32 next; /* Physical address of next buffer descriptor */
363 u32 reserved1;
364 u32 phys;
365 u32 reserved2;
366 u32 reserved3;
367 u32 reserved4;
368 u32 cntrl;
369 u32 status;
370 u32 app0;
371 u32 app1; /* TX start << 16 | insert */
372 u32 app2; /* TX csum seed */
373 u32 app3;
374 u32 app4;
375 u32 sw_id_offset;
376 u32 reserved5;
377 u32 reserved6;
378};
379
380/**
381 * struct axienet_local - axienet private per device data
382 * @ndev: Pointer for net_device to which it will be attached.
383 * @dev: Pointer to device structure
384 * @phy_dev: Pointer to PHY device structure attached to the axienet_local
385 * @phy_node: Pointer to device node structure
386 * @mii_bus: Pointer to MII bus structure
387 * @mdio_irqs: IRQs table for MDIO bus required in mii_bus structure
388 * @regs: Base address for the axienet_local device address space
389 * @dma_regs: Base address for the axidma device address space
390 * @dma_err_tasklet: Tasklet structure to process Axi DMA errors
391 * @tx_irq: Axidma TX IRQ number
392 * @rx_irq: Axidma RX IRQ number
393 * @temac_type: axienet type to identify between soft and hard temac
394 * @phy_type: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X
395 * @options: AxiEthernet option word
396 * @last_link: Phy link state in which the PHY was negotiated earlier
397 * @features: Stores the extended features supported by the axienet hw
398 * @tx_bd_v: Virtual address of the TX buffer descriptor ring
399 * @tx_bd_p: Physical address(start address) of the TX buffer descr. ring
400 * @rx_bd_v: Virtual address of the RX buffer descriptor ring
401 * @rx_bd_p: Physical address(start address) of the RX buffer descr. ring
402 * @tx_bd_ci: Stores the index of the Tx buffer descriptor in the ring being
403 * accessed currently. Used while alloc. BDs before a TX starts
404 * @tx_bd_tail: Stores the index of the Tx buffer descriptor in the ring being
405 * accessed currently. Used while processing BDs after the TX
406 * completed.
407 * @rx_bd_ci: Stores the index of the Rx buffer descriptor in the ring being
408 * accessed currently.
409 * @max_frm_size: Stores the maximum size of the frame that can be that
410 * Txed/Rxed in the existing hardware. If jumbo option is
411 * supported, the maximum frame size would be 9k. Else it is
412 * 1522 bytes (assuming support for basic VLAN)
413 * @jumbo_support: Stores hardware configuration for jumbo support. If hardware
414 * can handle jumbo packets, this entry will be 1, else 0.
415 */
416struct axienet_local {
417 struct net_device *ndev;
418 struct device *dev;
419
420 /* Connection to PHY device */
421 struct phy_device *phy_dev; /* Pointer to PHY device */
422 struct device_node *phy_node;
423
424 /* MDIO bus data */
425 struct mii_bus *mii_bus; /* MII bus reference */
426 int mdio_irqs[PHY_MAX_ADDR]; /* IRQs table for MDIO bus */
427
428 /* IO registers, dma functions and IRQs */
429 void __iomem *regs;
430 void __iomem *dma_regs;
431
432 struct tasklet_struct dma_err_tasklet;
433
434 int tx_irq;
435 int rx_irq;
436 u32 temac_type;
437 u32 phy_type;
438
439 u32 options; /* Current options word */
440 u32 last_link;
441 u32 features;
442
443 /* Buffer descriptors */
444 struct axidma_bd *tx_bd_v;
445 dma_addr_t tx_bd_p;
446 struct axidma_bd *rx_bd_v;
447 dma_addr_t rx_bd_p;
448 u32 tx_bd_ci;
449 u32 tx_bd_tail;
450 u32 rx_bd_ci;
451
452 u32 max_frm_size;
453 u32 jumbo_support;
454
455 int csum_offload_on_tx_path;
456 int csum_offload_on_rx_path;
457
458 u32 coalesce_count_rx;
459 u32 coalesce_count_tx;
460};
461
462/**
463 * struct axiethernet_option - Used to set axi ethernet hardware options
464 * @opt: Option to be set.
465 * @reg: Register offset to be written for setting the option
466 * @m_or: Mask to be ORed for setting the option in the register
467 */
468struct axienet_option {
469 u32 opt;
470 u32 reg;
471 u32 m_or;
472};
473
474/**
475 * axienet_ior - Memory mapped Axi Ethernet register read
476 * @lp: Pointer to axienet local structure
477 * @offset: Address offset from the base address of Axi Ethernet core
478 *
479 * returns: The contents of the Axi Ethernet register
480 *
481 * This function returns the contents of the corresponding register.
482 */
483static inline u32 axienet_ior(struct axienet_local *lp, off_t offset)
484{
485 return in_be32(lp->regs + offset);
486}
487
488/**
489 * axienet_iow - Memory mapped Axi Ethernet register write
490 * @lp: Pointer to axienet local structure
491 * @offset: Address offset from the base address of Axi Ethernet core
492 * @value: Value to be written into the Axi Ethernet register
493 *
494 * This function writes the desired value into the corresponding Axi Ethernet
495 * register.
496 */
497static inline void axienet_iow(struct axienet_local *lp, off_t offset,
498 u32 value)
499{
500 out_be32((lp->regs + offset), value);
501}
502
503/* Function prototypes visible in xilinx_axienet_mdio.c for other files */
504int axienet_mdio_setup(struct axienet_local *lp, struct device_node *np);
505int axienet_mdio_wait_until_ready(struct axienet_local *lp);
506void axienet_mdio_teardown(struct axienet_local *lp);
507
508#endif /* XILINX_AXI_ENET_H */
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
new file mode 100644
index 000000000000..a7cf00438a36
--- /dev/null
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -0,0 +1,1680 @@
1/*
2 * Xilinx Axi Ethernet device driver
3 *
4 * Copyright (c) 2008 Nissin Systems Co., Ltd., Yoshio Kashiwagi
5 * Copyright (c) 2005-2008 DLA Systems, David H. Lynch Jr. <dhlii@dlasys.net>
6 * Copyright (c) 2008-2009 Secret Lab Technologies Ltd.
7 * Copyright (c) 2010 Xilinx, Inc. All rights reserved.
8 * Copyright (c) 2012 Daniel Borkmann, <daniel.borkmann@tik.ee.ethz.ch>
9 * Copyright (c) 2012 Ariane Keller, <ariane.keller@tik.ee.ethz.ch>
10 *
11 * This is a driver for the Xilinx Axi Ethernet which is used in the Virtex6
12 * and Spartan6.
13 *
14 * TODO:
15 * - Add Axi Fifo support.
16 * - Factor out Axi DMA code into separate driver.
17 * - Test and fix basic multicast filtering.
18 * - Add support for extended multicast filtering.
19 * - Test basic VLAN support.
20 * - Add support for extended VLAN support.
21 */
22
23#include <linux/delay.h>
24#include <linux/etherdevice.h>
25#include <linux/init.h>
26#include <linux/module.h>
27#include <linux/netdevice.h>
28#include <linux/of_mdio.h>
29#include <linux/of_platform.h>
30#include <linux/of_address.h>
31#include <linux/skbuff.h>
32#include <linux/spinlock.h>
33#include <linux/phy.h>
34#include <linux/mii.h>
35#include <linux/ethtool.h>
36
37#include "xilinx_axienet.h"
38
39/* Descriptors defines for Tx and Rx DMA - 2^n for the best performance */
40#define TX_BD_NUM 64
41#define RX_BD_NUM 128
42
43/* Must be shorter than length of ethtool_drvinfo.driver field to fit */
44#define DRIVER_NAME "xaxienet"
45#define DRIVER_DESCRIPTION "Xilinx Axi Ethernet driver"
46#define DRIVER_VERSION "1.00a"
47
48#define AXIENET_REGS_N 32
49
50/* Match table for of_platform binding */
51static struct of_device_id axienet_of_match[] __devinitdata = {
52 { .compatible = "xlnx,axi-ethernet-1.00.a", },
53 { .compatible = "xlnx,axi-ethernet-1.01.a", },
54 { .compatible = "xlnx,axi-ethernet-2.01.a", },
55 {},
56};
57
58MODULE_DEVICE_TABLE(of, axienet_of_match);
59
60/* Option table for setting up Axi Ethernet hardware options */
61static struct axienet_option axienet_options[] = {
62 /* Turn on jumbo packet support for both Rx and Tx */
63 {
64 .opt = XAE_OPTION_JUMBO,
65 .reg = XAE_TC_OFFSET,
66 .m_or = XAE_TC_JUM_MASK,
67 }, {
68 .opt = XAE_OPTION_JUMBO,
69 .reg = XAE_RCW1_OFFSET,
70 .m_or = XAE_RCW1_JUM_MASK,
71 }, { /* Turn on VLAN packet support for both Rx and Tx */
72 .opt = XAE_OPTION_VLAN,
73 .reg = XAE_TC_OFFSET,
74 .m_or = XAE_TC_VLAN_MASK,
75 }, {
76 .opt = XAE_OPTION_VLAN,
77 .reg = XAE_RCW1_OFFSET,
78 .m_or = XAE_RCW1_VLAN_MASK,
79 }, { /* Turn on FCS stripping on receive packets */
80 .opt = XAE_OPTION_FCS_STRIP,
81 .reg = XAE_RCW1_OFFSET,
82 .m_or = XAE_RCW1_FCS_MASK,
83 }, { /* Turn on FCS insertion on transmit packets */
84 .opt = XAE_OPTION_FCS_INSERT,
85 .reg = XAE_TC_OFFSET,
86 .m_or = XAE_TC_FCS_MASK,
87 }, { /* Turn off length/type field checking on receive packets */
88 .opt = XAE_OPTION_LENTYPE_ERR,
89 .reg = XAE_RCW1_OFFSET,
90 .m_or = XAE_RCW1_LT_DIS_MASK,
91 }, { /* Turn on Rx flow control */
92 .opt = XAE_OPTION_FLOW_CONTROL,
93 .reg = XAE_FCC_OFFSET,
94 .m_or = XAE_FCC_FCRX_MASK,
95 }, { /* Turn on Tx flow control */
96 .opt = XAE_OPTION_FLOW_CONTROL,
97 .reg = XAE_FCC_OFFSET,
98 .m_or = XAE_FCC_FCTX_MASK,
99 }, { /* Turn on promiscuous frame filtering */
100 .opt = XAE_OPTION_PROMISC,
101 .reg = XAE_FMI_OFFSET,
102 .m_or = XAE_FMI_PM_MASK,
103 }, { /* Enable transmitter */
104 .opt = XAE_OPTION_TXEN,
105 .reg = XAE_TC_OFFSET,
106 .m_or = XAE_TC_TX_MASK,
107 }, { /* Enable receiver */
108 .opt = XAE_OPTION_RXEN,
109 .reg = XAE_RCW1_OFFSET,
110 .m_or = XAE_RCW1_RX_MASK,
111 },
112 {}
113};
114
115/**
116 * axienet_dma_in32 - Memory mapped Axi DMA register read
117 * @lp: Pointer to axienet local structure
118 * @reg: Address offset from the base address of the Axi DMA core
119 *
120 * returns: The contents of the Axi DMA register
121 *
122 * This function returns the contents of the corresponding Axi DMA register.
123 */
124static inline u32 axienet_dma_in32(struct axienet_local *lp, off_t reg)
125{
126 return in_be32(lp->dma_regs + reg);
127}
128
129/**
130 * axienet_dma_out32 - Memory mapped Axi DMA register write.
131 * @lp: Pointer to axienet local structure
132 * @reg: Address offset from the base address of the Axi DMA core
133 * @value: Value to be written into the Axi DMA register
134 *
135 * This function writes the desired value into the corresponding Axi DMA
136 * register.
137 */
138static inline void axienet_dma_out32(struct axienet_local *lp,
139 off_t reg, u32 value)
140{
141 out_be32((lp->dma_regs + reg), value);
142}
143
144/**
145 * axienet_dma_bd_release - Release buffer descriptor rings
146 * @ndev: Pointer to the net_device structure
147 *
148 * This function is used to release the descriptors allocated in
149 * axienet_dma_bd_init. axienet_dma_bd_release is called when Axi Ethernet
150 * driver stop api is called.
151 */
152static void axienet_dma_bd_release(struct net_device *ndev)
153{
154 int i;
155 struct axienet_local *lp = netdev_priv(ndev);
156
157 for (i = 0; i < RX_BD_NUM; i++) {
158 dma_unmap_single(ndev->dev.parent, lp->rx_bd_v[i].phys,
159 lp->max_frm_size, DMA_FROM_DEVICE);
160 dev_kfree_skb((struct sk_buff *)
161 (lp->rx_bd_v[i].sw_id_offset));
162 }
163
164 if (lp->rx_bd_v) {
165 dma_free_coherent(ndev->dev.parent,
166 sizeof(*lp->rx_bd_v) * RX_BD_NUM,
167 lp->rx_bd_v,
168 lp->rx_bd_p);
169 }
170 if (lp->tx_bd_v) {
171 dma_free_coherent(ndev->dev.parent,
172 sizeof(*lp->tx_bd_v) * TX_BD_NUM,
173 lp->tx_bd_v,
174 lp->tx_bd_p);
175 }
176}
177
178/**
179 * axienet_dma_bd_init - Setup buffer descriptor rings for Axi DMA
180 * @ndev: Pointer to the net_device structure
181 *
182 * returns: 0, on success
183 * -ENOMEM, on failure
184 *
185 * This function is called to initialize the Rx and Tx DMA descriptor
186 * rings. This initializes the descriptors with required default values
187 * and is called when Axi Ethernet driver reset is called.
188 */
189static int axienet_dma_bd_init(struct net_device *ndev)
190{
191 u32 cr;
192 int i;
193 struct sk_buff *skb;
194 struct axienet_local *lp = netdev_priv(ndev);
195
196 /* Reset the indexes which are used for accessing the BDs */
197 lp->tx_bd_ci = 0;
198 lp->tx_bd_tail = 0;
199 lp->rx_bd_ci = 0;
200
201 /*
202 * Allocate the Tx and Rx buffer descriptors.
203 */
204 lp->tx_bd_v = dma_alloc_coherent(ndev->dev.parent,
205 sizeof(*lp->tx_bd_v) * TX_BD_NUM,
206 &lp->tx_bd_p,
207 GFP_KERNEL);
208 if (!lp->tx_bd_v) {
209 dev_err(&ndev->dev, "unable to allocate DMA Tx buffer "
210 "descriptors");
211 goto out;
212 }
213
214 lp->rx_bd_v = dma_alloc_coherent(ndev->dev.parent,
215 sizeof(*lp->rx_bd_v) * RX_BD_NUM,
216 &lp->rx_bd_p,
217 GFP_KERNEL);
218 if (!lp->rx_bd_v) {
219 dev_err(&ndev->dev, "unable to allocate DMA Rx buffer "
220 "descriptors");
221 goto out;
222 }
223
224 memset(lp->tx_bd_v, 0, sizeof(*lp->tx_bd_v) * TX_BD_NUM);
225 for (i = 0; i < TX_BD_NUM; i++) {
226 lp->tx_bd_v[i].next = lp->tx_bd_p +
227 sizeof(*lp->tx_bd_v) *
228 ((i + 1) % TX_BD_NUM);
229 }
230
231 memset(lp->rx_bd_v, 0, sizeof(*lp->rx_bd_v) * RX_BD_NUM);
232 for (i = 0; i < RX_BD_NUM; i++) {
233 lp->rx_bd_v[i].next = lp->rx_bd_p +
234 sizeof(*lp->rx_bd_v) *
235 ((i + 1) % RX_BD_NUM);
236
237 skb = netdev_alloc_skb_ip_align(ndev, lp->max_frm_size);
238 if (!skb) {
239 dev_err(&ndev->dev, "alloc_skb error %d\n", i);
240 goto out;
241 }
242
243 lp->rx_bd_v[i].sw_id_offset = (u32) skb;
244 lp->rx_bd_v[i].phys = dma_map_single(ndev->dev.parent,
245 skb->data,
246 lp->max_frm_size,
247 DMA_FROM_DEVICE);
248 lp->rx_bd_v[i].cntrl = lp->max_frm_size;
249 }
250
251 /* Start updating the Rx channel control register */
252 cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET);
253 /* Update the interrupt coalesce count */
254 cr = ((cr & ~XAXIDMA_COALESCE_MASK) |
255 ((lp->coalesce_count_rx) << XAXIDMA_COALESCE_SHIFT));
256 /* Update the delay timer count */
257 cr = ((cr & ~XAXIDMA_DELAY_MASK) |
258 (XAXIDMA_DFT_RX_WAITBOUND << XAXIDMA_DELAY_SHIFT));
259 /* Enable coalesce, delay timer and error interrupts */
260 cr |= XAXIDMA_IRQ_ALL_MASK;
261 /* Write to the Rx channel control register */
262 axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr);
263
264 /* Start updating the Tx channel control register */
265 cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET);
266 /* Update the interrupt coalesce count */
267 cr = (((cr & ~XAXIDMA_COALESCE_MASK)) |
268 ((lp->coalesce_count_tx) << XAXIDMA_COALESCE_SHIFT));
269 /* Update the delay timer count */
270 cr = (((cr & ~XAXIDMA_DELAY_MASK)) |
271 (XAXIDMA_DFT_TX_WAITBOUND << XAXIDMA_DELAY_SHIFT));
272 /* Enable coalesce, delay timer and error interrupts */
273 cr |= XAXIDMA_IRQ_ALL_MASK;
274 /* Write to the Tx channel control register */
275 axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr);
276
277 /* Populate the tail pointer and bring the Rx Axi DMA engine out of
278 * halted state. This will make the Rx side ready for reception.*/
279 axienet_dma_out32(lp, XAXIDMA_RX_CDESC_OFFSET, lp->rx_bd_p);
280 cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET);
281 axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET,
282 cr | XAXIDMA_CR_RUNSTOP_MASK);
283 axienet_dma_out32(lp, XAXIDMA_RX_TDESC_OFFSET, lp->rx_bd_p +
284 (sizeof(*lp->rx_bd_v) * (RX_BD_NUM - 1)));
285
286 /* Write to the RS (Run-stop) bit in the Tx channel control register.
287 * Tx channel is now ready to run. But only after we write to the
288 * tail pointer register that the Tx channel will start transmitting */
289 axienet_dma_out32(lp, XAXIDMA_TX_CDESC_OFFSET, lp->tx_bd_p);
290 cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET);
291 axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET,
292 cr | XAXIDMA_CR_RUNSTOP_MASK);
293
294 return 0;
295out:
296 axienet_dma_bd_release(ndev);
297 return -ENOMEM;
298}
299
300/**
301 * axienet_set_mac_address - Write the MAC address
302 * @ndev: Pointer to the net_device structure
303 * @address: 6 byte Address to be written as MAC address
304 *
305 * This function is called to initialize the MAC address of the Axi Ethernet
306 * core. It writes to the UAW0 and UAW1 registers of the core.
307 */
308static void axienet_set_mac_address(struct net_device *ndev, void *address)
309{
310 struct axienet_local *lp = netdev_priv(ndev);
311
312 if (address)
313 memcpy(ndev->dev_addr, address, ETH_ALEN);
314 if (!is_valid_ether_addr(ndev->dev_addr))
315 random_ether_addr(ndev->dev_addr);
316
317 /* Set up unicast MAC address filter set its mac address */
318 axienet_iow(lp, XAE_UAW0_OFFSET,
319 (ndev->dev_addr[0]) |
320 (ndev->dev_addr[1] << 8) |
321 (ndev->dev_addr[2] << 16) |
322 (ndev->dev_addr[3] << 24));
323 axienet_iow(lp, XAE_UAW1_OFFSET,
324 (((axienet_ior(lp, XAE_UAW1_OFFSET)) &
325 ~XAE_UAW1_UNICASTADDR_MASK) |
326 (ndev->dev_addr[4] |
327 (ndev->dev_addr[5] << 8))));
328}
329
330/**
331 * netdev_set_mac_address - Write the MAC address (from outside the driver)
332 * @ndev: Pointer to the net_device structure
333 * @p: 6 byte Address to be written as MAC address
334 *
335 * returns: 0 for all conditions. Presently, there is no failure case.
336 *
337 * This function is called to initialize the MAC address of the Axi Ethernet
338 * core. It calls the core specific axienet_set_mac_address. This is the
339 * function that goes into net_device_ops structure entry ndo_set_mac_address.
340 */
341static int netdev_set_mac_address(struct net_device *ndev, void *p)
342{
343 struct sockaddr *addr = p;
344 axienet_set_mac_address(ndev, addr->sa_data);
345 return 0;
346}
347
348/**
349 * axienet_set_multicast_list - Prepare the multicast table
350 * @ndev: Pointer to the net_device structure
351 *
352 * This function is called to initialize the multicast table during
353 * initialization. The Axi Ethernet basic multicast support has a four-entry
354 * multicast table which is initialized here. Additionally this function
355 * goes into the net_device_ops structure entry ndo_set_multicast_list. This
356 * means whenever the multicast table entries need to be updated this
357 * function gets called.
358 */
359static void axienet_set_multicast_list(struct net_device *ndev)
360{
361 int i;
362 u32 reg, af0reg, af1reg;
363 struct axienet_local *lp = netdev_priv(ndev);
364
365 if (ndev->flags & (IFF_ALLMULTI | IFF_PROMISC) ||
366 netdev_mc_count(ndev) > XAE_MULTICAST_CAM_TABLE_NUM) {
367 /* We must make the kernel realize we had to move into
368 * promiscuous mode. If it was a promiscuous mode request
369 * the flag is already set. If not we set it. */
370 ndev->flags |= IFF_PROMISC;
371 reg = axienet_ior(lp, XAE_FMI_OFFSET);
372 reg |= XAE_FMI_PM_MASK;
373 axienet_iow(lp, XAE_FMI_OFFSET, reg);
374 dev_info(&ndev->dev, "Promiscuous mode enabled.\n");
375 } else if (!netdev_mc_empty(ndev)) {
376 struct netdev_hw_addr *ha;
377
378 i = 0;
379 netdev_for_each_mc_addr(ha, ndev) {
380 if (i >= XAE_MULTICAST_CAM_TABLE_NUM)
381 break;
382
383 af0reg = (ha->addr[0]);
384 af0reg |= (ha->addr[1] << 8);
385 af0reg |= (ha->addr[2] << 16);
386 af0reg |= (ha->addr[3] << 24);
387
388 af1reg = (ha->addr[4]);
389 af1reg |= (ha->addr[5] << 8);
390
391 reg = axienet_ior(lp, XAE_FMI_OFFSET) & 0xFFFFFF00;
392 reg |= i;
393
394 axienet_iow(lp, XAE_FMI_OFFSET, reg);
395 axienet_iow(lp, XAE_AF0_OFFSET, af0reg);
396 axienet_iow(lp, XAE_AF1_OFFSET, af1reg);
397 i++;
398 }
399 } else {
400 reg = axienet_ior(lp, XAE_FMI_OFFSET);
401 reg &= ~XAE_FMI_PM_MASK;
402
403 axienet_iow(lp, XAE_FMI_OFFSET, reg);
404
405 for (i = 0; i < XAE_MULTICAST_CAM_TABLE_NUM; i++) {
406 reg = axienet_ior(lp, XAE_FMI_OFFSET) & 0xFFFFFF00;
407 reg |= i;
408
409 axienet_iow(lp, XAE_FMI_OFFSET, reg);
410 axienet_iow(lp, XAE_AF0_OFFSET, 0);
411 axienet_iow(lp, XAE_AF1_OFFSET, 0);
412 }
413
414 dev_info(&ndev->dev, "Promiscuous mode disabled.\n");
415 }
416}
417
418/**
419 * axienet_setoptions - Set an Axi Ethernet option
420 * @ndev: Pointer to the net_device structure
421 * @options: Option to be enabled/disabled
422 *
423 * The Axi Ethernet core has multiple features which can be selectively turned
424 * on or off. The typical options could be jumbo frame option, basic VLAN
425 * option, promiscuous mode option etc. This function is used to set or clear
426 * these options in the Axi Ethernet hardware. This is done through
427 * axienet_option structure .
428 */
429static void axienet_setoptions(struct net_device *ndev, u32 options)
430{
431 int reg;
432 struct axienet_local *lp = netdev_priv(ndev);
433 struct axienet_option *tp = &axienet_options[0];
434
435 while (tp->opt) {
436 reg = ((axienet_ior(lp, tp->reg)) & ~(tp->m_or));
437 if (options & tp->opt)
438 reg |= tp->m_or;
439 axienet_iow(lp, tp->reg, reg);
440 tp++;
441 }
442
443 lp->options |= options;
444}
445
446static void __axienet_device_reset(struct axienet_local *lp,
447 struct device *dev, off_t offset)
448{
449 u32 timeout;
450 /* Reset Axi DMA. This would reset Axi Ethernet core as well. The reset
451 * process of Axi DMA takes a while to complete as all pending
452 * commands/transfers will be flushed or completed during this
453 * reset process. */
454 axienet_dma_out32(lp, offset, XAXIDMA_CR_RESET_MASK);
455 timeout = DELAY_OF_ONE_MILLISEC;
456 while (axienet_dma_in32(lp, offset) & XAXIDMA_CR_RESET_MASK) {
457 udelay(1);
458 if (--timeout == 0) {
459 dev_err(dev, "axienet_device_reset DMA "
460 "reset timeout!\n");
461 break;
462 }
463 }
464}
465
466/**
467 * axienet_device_reset - Reset and initialize the Axi Ethernet hardware.
468 * @ndev: Pointer to the net_device structure
469 *
470 * This function is called to reset and initialize the Axi Ethernet core. This
471 * is typically called during initialization. It does a reset of the Axi DMA
472 * Rx/Tx channels and initializes the Axi DMA BDs. Since Axi DMA reset lines
473 * areconnected to Axi Ethernet reset lines, this in turn resets the Axi
474 * Ethernet core. No separate hardware reset is done for the Axi Ethernet
475 * core.
476 */
477static void axienet_device_reset(struct net_device *ndev)
478{
479 u32 axienet_status;
480 struct axienet_local *lp = netdev_priv(ndev);
481
482 __axienet_device_reset(lp, &ndev->dev, XAXIDMA_TX_CR_OFFSET);
483 __axienet_device_reset(lp, &ndev->dev, XAXIDMA_RX_CR_OFFSET);
484
485 lp->max_frm_size = XAE_MAX_VLAN_FRAME_SIZE;
486 lp->options &= (~XAE_OPTION_JUMBO);
487
488 if ((ndev->mtu > XAE_MTU) &&
489 (ndev->mtu <= XAE_JUMBO_MTU) &&
490 (lp->jumbo_support)) {
491 lp->max_frm_size = ndev->mtu + XAE_HDR_VLAN_SIZE +
492 XAE_TRL_SIZE;
493 lp->options |= XAE_OPTION_JUMBO;
494 }
495
496 if (axienet_dma_bd_init(ndev)) {
497 dev_err(&ndev->dev, "axienet_device_reset descriptor "
498 "allocation failed\n");
499 }
500
501 axienet_status = axienet_ior(lp, XAE_RCW1_OFFSET);
502 axienet_status &= ~XAE_RCW1_RX_MASK;
503 axienet_iow(lp, XAE_RCW1_OFFSET, axienet_status);
504
505 axienet_status = axienet_ior(lp, XAE_IP_OFFSET);
506 if (axienet_status & XAE_INT_RXRJECT_MASK)
507 axienet_iow(lp, XAE_IS_OFFSET, XAE_INT_RXRJECT_MASK);
508
509 axienet_iow(lp, XAE_FCC_OFFSET, XAE_FCC_FCRX_MASK);
510
511 /* Sync default options with HW but leave receiver and
512 * transmitter disabled.*/
513 axienet_setoptions(ndev, lp->options &
514 ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN));
515 axienet_set_mac_address(ndev, NULL);
516 axienet_set_multicast_list(ndev);
517 axienet_setoptions(ndev, lp->options);
518
519 ndev->trans_start = jiffies;
520}
521
522/**
523 * axienet_adjust_link - Adjust the PHY link speed/duplex.
524 * @ndev: Pointer to the net_device structure
525 *
526 * This function is called to change the speed and duplex setting after
527 * auto negotiation is done by the PHY. This is the function that gets
528 * registered with the PHY interface through the "of_phy_connect" call.
529 */
530static void axienet_adjust_link(struct net_device *ndev)
531{
532 u32 emmc_reg;
533 u32 link_state;
534 u32 setspeed = 1;
535 struct axienet_local *lp = netdev_priv(ndev);
536 struct phy_device *phy = lp->phy_dev;
537
538 link_state = phy->speed | (phy->duplex << 1) | phy->link;
539 if (lp->last_link != link_state) {
540 if ((phy->speed == SPEED_10) || (phy->speed == SPEED_100)) {
541 if (lp->phy_type == XAE_PHY_TYPE_1000BASE_X)
542 setspeed = 0;
543 } else {
544 if ((phy->speed == SPEED_1000) &&
545 (lp->phy_type == XAE_PHY_TYPE_MII))
546 setspeed = 0;
547 }
548
549 if (setspeed == 1) {
550 emmc_reg = axienet_ior(lp, XAE_EMMC_OFFSET);
551 emmc_reg &= ~XAE_EMMC_LINKSPEED_MASK;
552
553 switch (phy->speed) {
554 case SPEED_1000:
555 emmc_reg |= XAE_EMMC_LINKSPD_1000;
556 break;
557 case SPEED_100:
558 emmc_reg |= XAE_EMMC_LINKSPD_100;
559 break;
560 case SPEED_10:
561 emmc_reg |= XAE_EMMC_LINKSPD_10;
562 break;
563 default:
564 dev_err(&ndev->dev, "Speed other than 10, 100 "
565 "or 1Gbps is not supported\n");
566 break;
567 }
568
569 axienet_iow(lp, XAE_EMMC_OFFSET, emmc_reg);
570 lp->last_link = link_state;
571 phy_print_status(phy);
572 } else {
573 dev_err(&ndev->dev, "Error setting Axi Ethernet "
574 "mac speed\n");
575 }
576 }
577}
578
579/**
580 * axienet_start_xmit_done - Invoked once a transmit is completed by the
581 * Axi DMA Tx channel.
582 * @ndev: Pointer to the net_device structure
583 *
584 * This function is invoked from the Axi DMA Tx isr to notify the completion
585 * of transmit operation. It clears fields in the corresponding Tx BDs and
586 * unmaps the corresponding buffer so that CPU can regain ownership of the
587 * buffer. It finally invokes "netif_wake_queue" to restart transmission if
588 * required.
589 */
590static void axienet_start_xmit_done(struct net_device *ndev)
591{
592 u32 size = 0;
593 u32 packets = 0;
594 struct axienet_local *lp = netdev_priv(ndev);
595 struct axidma_bd *cur_p;
596 unsigned int status = 0;
597
598 cur_p = &lp->tx_bd_v[lp->tx_bd_ci];
599 status = cur_p->status;
600 while (status & XAXIDMA_BD_STS_COMPLETE_MASK) {
601 dma_unmap_single(ndev->dev.parent, cur_p->phys,
602 (cur_p->cntrl & XAXIDMA_BD_CTRL_LENGTH_MASK),
603 DMA_TO_DEVICE);
604 if (cur_p->app4)
605 dev_kfree_skb_irq((struct sk_buff *)cur_p->app4);
606 /*cur_p->phys = 0;*/
607 cur_p->app0 = 0;
608 cur_p->app1 = 0;
609 cur_p->app2 = 0;
610 cur_p->app4 = 0;
611 cur_p->status = 0;
612
613 size += status & XAXIDMA_BD_STS_ACTUAL_LEN_MASK;
614 packets++;
615
616 lp->tx_bd_ci = ++lp->tx_bd_ci % TX_BD_NUM;
617 cur_p = &lp->tx_bd_v[lp->tx_bd_ci];
618 status = cur_p->status;
619 }
620
621 ndev->stats.tx_packets += packets;
622 ndev->stats.tx_bytes += size;
623 netif_wake_queue(ndev);
624}
625
626/**
627 * axienet_check_tx_bd_space - Checks if a BD/group of BDs are currently busy
628 * @lp: Pointer to the axienet_local structure
629 * @num_frag: The number of BDs to check for
630 *
631 * returns: 0, on success
632 * NETDEV_TX_BUSY, if any of the descriptors are not free
633 *
634 * This function is invoked before BDs are allocated and transmission starts.
635 * This function returns 0 if a BD or group of BDs can be allocated for
636 * transmission. If the BD or any of the BDs are not free the function
637 * returns a busy status. This is invoked from axienet_start_xmit.
638 */
639static inline int axienet_check_tx_bd_space(struct axienet_local *lp,
640 int num_frag)
641{
642 struct axidma_bd *cur_p;
643 cur_p = &lp->tx_bd_v[(lp->tx_bd_tail + num_frag) % TX_BD_NUM];
644 if (cur_p->status & XAXIDMA_BD_STS_ALL_MASK)
645 return NETDEV_TX_BUSY;
646 return 0;
647}
648
649/**
650 * axienet_start_xmit - Starts the transmission.
651 * @skb: sk_buff pointer that contains data to be Txed.
652 * @ndev: Pointer to net_device structure.
653 *
654 * returns: NETDEV_TX_OK, on success
655 * NETDEV_TX_BUSY, if any of the descriptors are not free
656 *
657 * This function is invoked from upper layers to initiate transmission. The
658 * function uses the next available free BDs and populates their fields to
659 * start the transmission. Additionally if checksum offloading is supported,
660 * it populates AXI Stream Control fields with appropriate values.
661 */
662static int axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
663{
664 u32 ii;
665 u32 num_frag;
666 u32 csum_start_off;
667 u32 csum_index_off;
668 skb_frag_t *frag;
669 dma_addr_t tail_p;
670 struct axienet_local *lp = netdev_priv(ndev);
671 struct axidma_bd *cur_p;
672
673 num_frag = skb_shinfo(skb)->nr_frags;
674 cur_p = &lp->tx_bd_v[lp->tx_bd_tail];
675
676 if (axienet_check_tx_bd_space(lp, num_frag)) {
677 if (!netif_queue_stopped(ndev))
678 netif_stop_queue(ndev);
679 return NETDEV_TX_BUSY;
680 }
681
682 if (skb->ip_summed == CHECKSUM_PARTIAL) {
683 if (lp->features & XAE_FEATURE_FULL_TX_CSUM) {
684 /* Tx Full Checksum Offload Enabled */
685 cur_p->app0 |= 2;
686 } else if (lp->features & XAE_FEATURE_PARTIAL_RX_CSUM) {
687 csum_start_off = skb_transport_offset(skb);
688 csum_index_off = csum_start_off + skb->csum_offset;
689 /* Tx Partial Checksum Offload Enabled */
690 cur_p->app0 |= 1;
691 cur_p->app1 = (csum_start_off << 16) | csum_index_off;
692 }
693 } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
694 cur_p->app0 |= 2; /* Tx Full Checksum Offload Enabled */
695 }
696
697 cur_p->cntrl = skb_headlen(skb) | XAXIDMA_BD_CTRL_TXSOF_MASK;
698 cur_p->phys = dma_map_single(ndev->dev.parent, skb->data,
699 skb_headlen(skb), DMA_TO_DEVICE);
700
701 for (ii = 0; ii < num_frag; ii++) {
702 lp->tx_bd_tail = ++lp->tx_bd_tail % TX_BD_NUM;
703 cur_p = &lp->tx_bd_v[lp->tx_bd_tail];
704 frag = &skb_shinfo(skb)->frags[ii];
705 cur_p->phys = dma_map_single(ndev->dev.parent,
706 skb_frag_address(frag),
707 skb_frag_size(frag),
708 DMA_TO_DEVICE);
709 cur_p->cntrl = skb_frag_size(frag);
710 }
711
712 cur_p->cntrl |= XAXIDMA_BD_CTRL_TXEOF_MASK;
713 cur_p->app4 = (unsigned long)skb;
714
715 tail_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail;
716 /* Start the transfer */
717 axienet_dma_out32(lp, XAXIDMA_TX_TDESC_OFFSET, tail_p);
718 lp->tx_bd_tail = ++lp->tx_bd_tail % TX_BD_NUM;
719
720 return NETDEV_TX_OK;
721}
722
723/**
724 * axienet_recv - Is called from Axi DMA Rx Isr to complete the received
725 * BD processing.
726 * @ndev: Pointer to net_device structure.
727 *
728 * This function is invoked from the Axi DMA Rx isr to process the Rx BDs. It
729 * does minimal processing and invokes "netif_rx" to complete further
730 * processing.
731 */
732static void axienet_recv(struct net_device *ndev)
733{
734 u32 length;
735 u32 csumstatus;
736 u32 size = 0;
737 u32 packets = 0;
738 dma_addr_t tail_p;
739 struct axienet_local *lp = netdev_priv(ndev);
740 struct sk_buff *skb, *new_skb;
741 struct axidma_bd *cur_p;
742
743 tail_p = lp->rx_bd_p + sizeof(*lp->rx_bd_v) * lp->rx_bd_ci;
744 cur_p = &lp->rx_bd_v[lp->rx_bd_ci];
745
746 while ((cur_p->status & XAXIDMA_BD_STS_COMPLETE_MASK)) {
747 skb = (struct sk_buff *) (cur_p->sw_id_offset);
748 length = cur_p->app4 & 0x0000FFFF;
749
750 dma_unmap_single(ndev->dev.parent, cur_p->phys,
751 lp->max_frm_size,
752 DMA_FROM_DEVICE);
753
754 skb_put(skb, length);
755 skb->protocol = eth_type_trans(skb, ndev);
756 /*skb_checksum_none_assert(skb);*/
757 skb->ip_summed = CHECKSUM_NONE;
758
759 /* if we're doing Rx csum offload, set it up */
760 if (lp->features & XAE_FEATURE_FULL_RX_CSUM) {
761 csumstatus = (cur_p->app2 &
762 XAE_FULL_CSUM_STATUS_MASK) >> 3;
763 if ((csumstatus == XAE_IP_TCP_CSUM_VALIDATED) ||
764 (csumstatus == XAE_IP_UDP_CSUM_VALIDATED)) {
765 skb->ip_summed = CHECKSUM_UNNECESSARY;
766 }
767 } else if ((lp->features & XAE_FEATURE_PARTIAL_RX_CSUM) != 0 &&
768 skb->protocol == __constant_htons(ETH_P_IP) &&
769 skb->len > 64) {
770 skb->csum = be32_to_cpu(cur_p->app3 & 0xFFFF);
771 skb->ip_summed = CHECKSUM_COMPLETE;
772 }
773
774 netif_rx(skb);
775
776 size += length;
777 packets++;
778
779 new_skb = netdev_alloc_skb_ip_align(ndev, lp->max_frm_size);
780 if (!new_skb) {
781 dev_err(&ndev->dev, "no memory for new sk_buff\n");
782 return;
783 }
784 cur_p->phys = dma_map_single(ndev->dev.parent, new_skb->data,
785 lp->max_frm_size,
786 DMA_FROM_DEVICE);
787 cur_p->cntrl = lp->max_frm_size;
788 cur_p->status = 0;
789 cur_p->sw_id_offset = (u32) new_skb;
790
791 lp->rx_bd_ci = ++lp->rx_bd_ci % RX_BD_NUM;
792 cur_p = &lp->rx_bd_v[lp->rx_bd_ci];
793 }
794
795 ndev->stats.rx_packets += packets;
796 ndev->stats.rx_bytes += size;
797
798 axienet_dma_out32(lp, XAXIDMA_RX_TDESC_OFFSET, tail_p);
799}
800
801/**
802 * axienet_tx_irq - Tx Done Isr.
803 * @irq: irq number
804 * @_ndev: net_device pointer
805 *
806 * returns: IRQ_HANDLED for all cases.
807 *
808 * This is the Axi DMA Tx done Isr. It invokes "axienet_start_xmit_done"
809 * to complete the BD processing.
810 */
811static irqreturn_t axienet_tx_irq(int irq, void *_ndev)
812{
813 u32 cr;
814 unsigned int status;
815 struct net_device *ndev = _ndev;
816 struct axienet_local *lp = netdev_priv(ndev);
817
818 status = axienet_dma_in32(lp, XAXIDMA_TX_SR_OFFSET);
819 if (status & (XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK)) {
820 axienet_start_xmit_done(lp->ndev);
821 goto out;
822 }
823 if (!(status & XAXIDMA_IRQ_ALL_MASK))
824 dev_err(&ndev->dev, "No interrupts asserted in Tx path");
825 if (status & XAXIDMA_IRQ_ERROR_MASK) {
826 dev_err(&ndev->dev, "DMA Tx error 0x%x\n", status);
827 dev_err(&ndev->dev, "Current BD is at: 0x%x\n",
828 (lp->tx_bd_v[lp->tx_bd_ci]).phys);
829
830 cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET);
831 /* Disable coalesce, delay timer and error interrupts */
832 cr &= (~XAXIDMA_IRQ_ALL_MASK);
833 /* Write to the Tx channel control register */
834 axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr);
835
836 cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET);
837 /* Disable coalesce, delay timer and error interrupts */
838 cr &= (~XAXIDMA_IRQ_ALL_MASK);
839 /* Write to the Rx channel control register */
840 axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr);
841
842 tasklet_schedule(&lp->dma_err_tasklet);
843 }
844out:
845 axienet_dma_out32(lp, XAXIDMA_TX_SR_OFFSET, status);
846 return IRQ_HANDLED;
847}
848
849/**
850 * axienet_rx_irq - Rx Isr.
851 * @irq: irq number
852 * @_ndev: net_device pointer
853 *
854 * returns: IRQ_HANDLED for all cases.
855 *
856 * This is the Axi DMA Rx Isr. It invokes "axienet_recv" to complete the BD
857 * processing.
858 */
859static irqreturn_t axienet_rx_irq(int irq, void *_ndev)
860{
861 u32 cr;
862 unsigned int status;
863 struct net_device *ndev = _ndev;
864 struct axienet_local *lp = netdev_priv(ndev);
865
866 status = axienet_dma_in32(lp, XAXIDMA_RX_SR_OFFSET);
867 if (status & (XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK)) {
868 axienet_recv(lp->ndev);
869 goto out;
870 }
871 if (!(status & XAXIDMA_IRQ_ALL_MASK))
872 dev_err(&ndev->dev, "No interrupts asserted in Rx path");
873 if (status & XAXIDMA_IRQ_ERROR_MASK) {
874 dev_err(&ndev->dev, "DMA Rx error 0x%x\n", status);
875 dev_err(&ndev->dev, "Current BD is at: 0x%x\n",
876 (lp->rx_bd_v[lp->rx_bd_ci]).phys);
877
878 cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET);
879 /* Disable coalesce, delay timer and error interrupts */
880 cr &= (~XAXIDMA_IRQ_ALL_MASK);
881 /* Finally write to the Tx channel control register */
882 axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr);
883
884 cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET);
885 /* Disable coalesce, delay timer and error interrupts */
886 cr &= (~XAXIDMA_IRQ_ALL_MASK);
887 /* write to the Rx channel control register */
888 axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr);
889
890 tasklet_schedule(&lp->dma_err_tasklet);
891 }
892out:
893 axienet_dma_out32(lp, XAXIDMA_RX_SR_OFFSET, status);
894 return IRQ_HANDLED;
895}
896
897/**
898 * axienet_open - Driver open routine.
899 * @ndev: Pointer to net_device structure
900 *
901 * returns: 0, on success.
902 * -ENODEV, if PHY cannot be connected to
903 * non-zero error value on failure
904 *
905 * This is the driver open routine. It calls phy_start to start the PHY device.
906 * It also allocates interrupt service routines, enables the interrupt lines
907 * and ISR handling. Axi Ethernet core is reset through Axi DMA core. Buffer
908 * descriptors are initialized.
909 */
910static int axienet_open(struct net_device *ndev)
911{
912 int ret, mdio_mcreg;
913 struct axienet_local *lp = netdev_priv(ndev);
914
915 dev_dbg(&ndev->dev, "axienet_open()\n");
916
917 mdio_mcreg = axienet_ior(lp, XAE_MDIO_MC_OFFSET);
918 ret = axienet_mdio_wait_until_ready(lp);
919 if (ret < 0)
920 return ret;
921 /* Disable the MDIO interface till Axi Ethernet Reset is completed.
922 * When we do an Axi Ethernet reset, it resets the complete core
923 * including the MDIO. If MDIO is not disabled when the reset
924 * process is started, MDIO will be broken afterwards. */
925 axienet_iow(lp, XAE_MDIO_MC_OFFSET,
926 (mdio_mcreg & (~XAE_MDIO_MC_MDIOEN_MASK)));
927 axienet_device_reset(ndev);
928 /* Enable the MDIO */
929 axienet_iow(lp, XAE_MDIO_MC_OFFSET, mdio_mcreg);
930 ret = axienet_mdio_wait_until_ready(lp);
931 if (ret < 0)
932 return ret;
933
934 if (lp->phy_node) {
935 lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node,
936 axienet_adjust_link, 0,
937 PHY_INTERFACE_MODE_GMII);
938 if (!lp->phy_dev) {
939 dev_err(lp->dev, "of_phy_connect() failed\n");
940 return -ENODEV;
941 }
942 phy_start(lp->phy_dev);
943 }
944
945 /* Enable interrupts for Axi DMA Tx */
946 ret = request_irq(lp->tx_irq, axienet_tx_irq, 0, ndev->name, ndev);
947 if (ret)
948 goto err_tx_irq;
949 /* Enable interrupts for Axi DMA Rx */
950 ret = request_irq(lp->rx_irq, axienet_rx_irq, 0, ndev->name, ndev);
951 if (ret)
952 goto err_rx_irq;
953 /* Enable tasklets for Axi DMA error handling */
954 tasklet_enable(&lp->dma_err_tasklet);
955 return 0;
956
957err_rx_irq:
958 free_irq(lp->tx_irq, ndev);
959err_tx_irq:
960 if (lp->phy_dev)
961 phy_disconnect(lp->phy_dev);
962 lp->phy_dev = NULL;
963 dev_err(lp->dev, "request_irq() failed\n");
964 return ret;
965}
966
967/**
968 * axienet_stop - Driver stop routine.
969 * @ndev: Pointer to net_device structure
970 *
971 * returns: 0, on success.
972 *
973 * This is the driver stop routine. It calls phy_disconnect to stop the PHY
974 * device. It also removes the interrupt handlers and disables the interrupts.
975 * The Axi DMA Tx/Rx BDs are released.
976 */
977static int axienet_stop(struct net_device *ndev)
978{
979 u32 cr;
980 struct axienet_local *lp = netdev_priv(ndev);
981
982 dev_dbg(&ndev->dev, "axienet_close()\n");
983
984 cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET);
985 axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET,
986 cr & (~XAXIDMA_CR_RUNSTOP_MASK));
987 cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET);
988 axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET,
989 cr & (~XAXIDMA_CR_RUNSTOP_MASK));
990 axienet_setoptions(ndev, lp->options &
991 ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN));
992
993 tasklet_disable(&lp->dma_err_tasklet);
994
995 free_irq(lp->tx_irq, ndev);
996 free_irq(lp->rx_irq, ndev);
997
998 if (lp->phy_dev)
999 phy_disconnect(lp->phy_dev);
1000 lp->phy_dev = NULL;
1001
1002 axienet_dma_bd_release(ndev);
1003 return 0;
1004}
1005
1006/**
1007 * axienet_change_mtu - Driver change mtu routine.
1008 * @ndev: Pointer to net_device structure
1009 * @new_mtu: New mtu value to be applied
1010 *
1011 * returns: Always returns 0 (success).
1012 *
1013 * This is the change mtu driver routine. It checks if the Axi Ethernet
1014 * hardware supports jumbo frames before changing the mtu. This can be
1015 * called only when the device is not up.
1016 */
1017static int axienet_change_mtu(struct net_device *ndev, int new_mtu)
1018{
1019 struct axienet_local *lp = netdev_priv(ndev);
1020
1021 if (netif_running(ndev))
1022 return -EBUSY;
1023 if (lp->jumbo_support) {
1024 if ((new_mtu > XAE_JUMBO_MTU) || (new_mtu < 64))
1025 return -EINVAL;
1026 ndev->mtu = new_mtu;
1027 } else {
1028 if ((new_mtu > XAE_MTU) || (new_mtu < 64))
1029 return -EINVAL;
1030 ndev->mtu = new_mtu;
1031 }
1032
1033 return 0;
1034}
1035
1036#ifdef CONFIG_NET_POLL_CONTROLLER
1037/**
1038 * axienet_poll_controller - Axi Ethernet poll mechanism.
1039 * @ndev: Pointer to net_device structure
1040 *
1041 * This implements Rx/Tx ISR poll mechanisms. The interrupts are disabled prior
1042 * to polling the ISRs and are enabled back after the polling is done.
1043 */
1044static void axienet_poll_controller(struct net_device *ndev)
1045{
1046 struct axienet_local *lp = netdev_priv(ndev);
1047 disable_irq(lp->tx_irq);
1048 disable_irq(lp->rx_irq);
1049 axienet_rx_irq(lp->tx_irq, ndev);
1050 axienet_tx_irq(lp->rx_irq, ndev);
1051 enable_irq(lp->tx_irq);
1052 enable_irq(lp->rx_irq);
1053}
1054#endif
1055
1056static const struct net_device_ops axienet_netdev_ops = {
1057 .ndo_open = axienet_open,
1058 .ndo_stop = axienet_stop,
1059 .ndo_start_xmit = axienet_start_xmit,
1060 .ndo_change_mtu = axienet_change_mtu,
1061 .ndo_set_mac_address = netdev_set_mac_address,
1062 .ndo_validate_addr = eth_validate_addr,
1063 .ndo_set_rx_mode = axienet_set_multicast_list,
1064#ifdef CONFIG_NET_POLL_CONTROLLER
1065 .ndo_poll_controller = axienet_poll_controller,
1066#endif
1067};
1068
1069/**
1070 * axienet_ethtools_get_settings - Get Axi Ethernet settings related to PHY.
1071 * @ndev: Pointer to net_device structure
1072 * @ecmd: Pointer to ethtool_cmd structure
1073 *
1074 * This implements ethtool command for getting PHY settings. If PHY could
1075 * not be found, the function returns -ENODEV. This function calls the
1076 * relevant PHY ethtool API to get the PHY settings.
1077 * Issue "ethtool ethX" under linux prompt to execute this function.
1078 */
1079static int axienet_ethtools_get_settings(struct net_device *ndev,
1080 struct ethtool_cmd *ecmd)
1081{
1082 struct axienet_local *lp = netdev_priv(ndev);
1083 struct phy_device *phydev = lp->phy_dev;
1084 if (!phydev)
1085 return -ENODEV;
1086 return phy_ethtool_gset(phydev, ecmd);
1087}
1088
1089/**
1090 * axienet_ethtools_set_settings - Set PHY settings as passed in the argument.
1091 * @ndev: Pointer to net_device structure
1092 * @ecmd: Pointer to ethtool_cmd structure
1093 *
1094 * This implements ethtool command for setting various PHY settings. If PHY
1095 * could not be found, the function returns -ENODEV. This function calls the
1096 * relevant PHY ethtool API to set the PHY.
1097 * Issue e.g. "ethtool -s ethX speed 1000" under linux prompt to execute this
1098 * function.
1099 */
1100static int axienet_ethtools_set_settings(struct net_device *ndev,
1101 struct ethtool_cmd *ecmd)
1102{
1103 struct axienet_local *lp = netdev_priv(ndev);
1104 struct phy_device *phydev = lp->phy_dev;
1105 if (!phydev)
1106 return -ENODEV;
1107 return phy_ethtool_sset(phydev, ecmd);
1108}
1109
1110/**
1111 * axienet_ethtools_get_drvinfo - Get various Axi Ethernet driver information.
1112 * @ndev: Pointer to net_device structure
1113 * @ed: Pointer to ethtool_drvinfo structure
1114 *
1115 * This implements ethtool command for getting the driver information.
1116 * Issue "ethtool -i ethX" under linux prompt to execute this function.
1117 */
1118static void axienet_ethtools_get_drvinfo(struct net_device *ndev,
1119 struct ethtool_drvinfo *ed)
1120{
1121 memset(ed, 0, sizeof(struct ethtool_drvinfo));
1122 strcpy(ed->driver, DRIVER_NAME);
1123 strcpy(ed->version, DRIVER_VERSION);
1124 ed->regdump_len = sizeof(u32) * AXIENET_REGS_N;
1125}
1126
1127/**
1128 * axienet_ethtools_get_regs_len - Get the total regs length present in the
1129 * AxiEthernet core.
1130 * @ndev: Pointer to net_device structure
1131 *
1132 * This implements ethtool command for getting the total register length
1133 * information.
1134 */
1135static int axienet_ethtools_get_regs_len(struct net_device *ndev)
1136{
1137 return sizeof(u32) * AXIENET_REGS_N;
1138}
1139
1140/**
1141 * axienet_ethtools_get_regs - Dump the contents of all registers present
1142 * in AxiEthernet core.
1143 * @ndev: Pointer to net_device structure
1144 * @regs: Pointer to ethtool_regs structure
1145 * @ret: Void pointer used to return the contents of the registers.
1146 *
1147 * This implements ethtool command for getting the Axi Ethernet register dump.
1148 * Issue "ethtool -d ethX" to execute this function.
1149 */
1150static void axienet_ethtools_get_regs(struct net_device *ndev,
1151 struct ethtool_regs *regs, void *ret)
1152{
1153 u32 *data = (u32 *) ret;
1154 size_t len = sizeof(u32) * AXIENET_REGS_N;
1155 struct axienet_local *lp = netdev_priv(ndev);
1156
1157 regs->version = 0;
1158 regs->len = len;
1159
1160 memset(data, 0, len);
1161 data[0] = axienet_ior(lp, XAE_RAF_OFFSET);
1162 data[1] = axienet_ior(lp, XAE_TPF_OFFSET);
1163 data[2] = axienet_ior(lp, XAE_IFGP_OFFSET);
1164 data[3] = axienet_ior(lp, XAE_IS_OFFSET);
1165 data[4] = axienet_ior(lp, XAE_IP_OFFSET);
1166 data[5] = axienet_ior(lp, XAE_IE_OFFSET);
1167 data[6] = axienet_ior(lp, XAE_TTAG_OFFSET);
1168 data[7] = axienet_ior(lp, XAE_RTAG_OFFSET);
1169 data[8] = axienet_ior(lp, XAE_UAWL_OFFSET);
1170 data[9] = axienet_ior(lp, XAE_UAWU_OFFSET);
1171 data[10] = axienet_ior(lp, XAE_TPID0_OFFSET);
1172 data[11] = axienet_ior(lp, XAE_TPID1_OFFSET);
1173 data[12] = axienet_ior(lp, XAE_PPST_OFFSET);
1174 data[13] = axienet_ior(lp, XAE_RCW0_OFFSET);
1175 data[14] = axienet_ior(lp, XAE_RCW1_OFFSET);
1176 data[15] = axienet_ior(lp, XAE_TC_OFFSET);
1177 data[16] = axienet_ior(lp, XAE_FCC_OFFSET);
1178 data[17] = axienet_ior(lp, XAE_EMMC_OFFSET);
1179 data[18] = axienet_ior(lp, XAE_PHYC_OFFSET);
1180 data[19] = axienet_ior(lp, XAE_MDIO_MC_OFFSET);
1181 data[20] = axienet_ior(lp, XAE_MDIO_MCR_OFFSET);
1182 data[21] = axienet_ior(lp, XAE_MDIO_MWD_OFFSET);
1183 data[22] = axienet_ior(lp, XAE_MDIO_MRD_OFFSET);
1184 data[23] = axienet_ior(lp, XAE_MDIO_MIS_OFFSET);
1185 data[24] = axienet_ior(lp, XAE_MDIO_MIP_OFFSET);
1186 data[25] = axienet_ior(lp, XAE_MDIO_MIE_OFFSET);
1187 data[26] = axienet_ior(lp, XAE_MDIO_MIC_OFFSET);
1188 data[27] = axienet_ior(lp, XAE_UAW0_OFFSET);
1189 data[28] = axienet_ior(lp, XAE_UAW1_OFFSET);
1190 data[29] = axienet_ior(lp, XAE_FMI_OFFSET);
1191 data[30] = axienet_ior(lp, XAE_AF0_OFFSET);
1192 data[31] = axienet_ior(lp, XAE_AF1_OFFSET);
1193}
1194
1195/**
1196 * axienet_ethtools_get_pauseparam - Get the pause parameter setting for
1197 * Tx and Rx paths.
1198 * @ndev: Pointer to net_device structure
1199 * @epauseparm: Pointer to ethtool_pauseparam structure.
1200 *
1201 * This implements ethtool command for getting axi ethernet pause frame
1202 * setting. Issue "ethtool -a ethX" to execute this function.
1203 */
1204static void
1205axienet_ethtools_get_pauseparam(struct net_device *ndev,
1206 struct ethtool_pauseparam *epauseparm)
1207{
1208 u32 regval;
1209 struct axienet_local *lp = netdev_priv(ndev);
1210 epauseparm->autoneg = 0;
1211 regval = axienet_ior(lp, XAE_FCC_OFFSET);
1212 epauseparm->tx_pause = regval & XAE_FCC_FCTX_MASK;
1213 epauseparm->rx_pause = regval & XAE_FCC_FCRX_MASK;
1214}
1215
1216/**
1217 * axienet_ethtools_set_pauseparam - Set device pause parameter(flow control)
1218 * settings.
1219 * @ndev: Pointer to net_device structure
1220 * @epauseparam:Pointer to ethtool_pauseparam structure
1221 *
1222 * This implements ethtool command for enabling flow control on Rx and Tx
1223 * paths. Issue "ethtool -A ethX tx on|off" under linux prompt to execute this
1224 * function.
1225 */
1226static int
1227axienet_ethtools_set_pauseparam(struct net_device *ndev,
1228 struct ethtool_pauseparam *epauseparm)
1229{
1230 u32 regval = 0;
1231 struct axienet_local *lp = netdev_priv(ndev);
1232
1233 if (netif_running(ndev)) {
1234 printk(KERN_ERR "%s: Please stop netif before applying "
1235 "configruation\n", ndev->name);
1236 return -EFAULT;
1237 }
1238
1239 regval = axienet_ior(lp, XAE_FCC_OFFSET);
1240 if (epauseparm->tx_pause)
1241 regval |= XAE_FCC_FCTX_MASK;
1242 else
1243 regval &= ~XAE_FCC_FCTX_MASK;
1244 if (epauseparm->rx_pause)
1245 regval |= XAE_FCC_FCRX_MASK;
1246 else
1247 regval &= ~XAE_FCC_FCRX_MASK;
1248 axienet_iow(lp, XAE_FCC_OFFSET, regval);
1249
1250 return 0;
1251}
1252
1253/**
1254 * axienet_ethtools_get_coalesce - Get DMA interrupt coalescing count.
1255 * @ndev: Pointer to net_device structure
1256 * @ecoalesce: Pointer to ethtool_coalesce structure
1257 *
1258 * This implements ethtool command for getting the DMA interrupt coalescing
1259 * count on Tx and Rx paths. Issue "ethtool -c ethX" under linux prompt to
1260 * execute this function.
1261 */
1262static int axienet_ethtools_get_coalesce(struct net_device *ndev,
1263 struct ethtool_coalesce *ecoalesce)
1264{
1265 u32 regval = 0;
1266 struct axienet_local *lp = netdev_priv(ndev);
1267 regval = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET);
1268 ecoalesce->rx_max_coalesced_frames = (regval & XAXIDMA_COALESCE_MASK)
1269 >> XAXIDMA_COALESCE_SHIFT;
1270 regval = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET);
1271 ecoalesce->tx_max_coalesced_frames = (regval & XAXIDMA_COALESCE_MASK)
1272 >> XAXIDMA_COALESCE_SHIFT;
1273 return 0;
1274}
1275
1276/**
1277 * axienet_ethtools_set_coalesce - Set DMA interrupt coalescing count.
1278 * @ndev: Pointer to net_device structure
1279 * @ecoalesce: Pointer to ethtool_coalesce structure
1280 *
1281 * This implements ethtool command for setting the DMA interrupt coalescing
1282 * count on Tx and Rx paths. Issue "ethtool -C ethX rx-frames 5" under linux
1283 * prompt to execute this function.
1284 */
1285static int axienet_ethtools_set_coalesce(struct net_device *ndev,
1286 struct ethtool_coalesce *ecoalesce)
1287{
1288 struct axienet_local *lp = netdev_priv(ndev);
1289
1290 if (netif_running(ndev)) {
1291 printk(KERN_ERR "%s: Please stop netif before applying "
1292 "configruation\n", ndev->name);
1293 return -EFAULT;
1294 }
1295
1296 if ((ecoalesce->rx_coalesce_usecs) ||
1297 (ecoalesce->rx_coalesce_usecs_irq) ||
1298 (ecoalesce->rx_max_coalesced_frames_irq) ||
1299 (ecoalesce->tx_coalesce_usecs) ||
1300 (ecoalesce->tx_coalesce_usecs_irq) ||
1301 (ecoalesce->tx_max_coalesced_frames_irq) ||
1302 (ecoalesce->stats_block_coalesce_usecs) ||
1303 (ecoalesce->use_adaptive_rx_coalesce) ||
1304 (ecoalesce->use_adaptive_tx_coalesce) ||
1305 (ecoalesce->pkt_rate_low) ||
1306 (ecoalesce->rx_coalesce_usecs_low) ||
1307 (ecoalesce->rx_max_coalesced_frames_low) ||
1308 (ecoalesce->tx_coalesce_usecs_low) ||
1309 (ecoalesce->tx_max_coalesced_frames_low) ||
1310 (ecoalesce->pkt_rate_high) ||
1311 (ecoalesce->rx_coalesce_usecs_high) ||
1312 (ecoalesce->rx_max_coalesced_frames_high) ||
1313 (ecoalesce->tx_coalesce_usecs_high) ||
1314 (ecoalesce->tx_max_coalesced_frames_high) ||
1315 (ecoalesce->rate_sample_interval))
1316 return -EOPNOTSUPP;
1317 if (ecoalesce->rx_max_coalesced_frames)
1318 lp->coalesce_count_rx = ecoalesce->rx_max_coalesced_frames;
1319 if (ecoalesce->tx_max_coalesced_frames)
1320 lp->coalesce_count_tx = ecoalesce->tx_max_coalesced_frames;
1321
1322 return 0;
1323}
1324
1325static struct ethtool_ops axienet_ethtool_ops = {
1326 .get_settings = axienet_ethtools_get_settings,
1327 .set_settings = axienet_ethtools_set_settings,
1328 .get_drvinfo = axienet_ethtools_get_drvinfo,
1329 .get_regs_len = axienet_ethtools_get_regs_len,
1330 .get_regs = axienet_ethtools_get_regs,
1331 .get_link = ethtool_op_get_link,
1332 .get_pauseparam = axienet_ethtools_get_pauseparam,
1333 .set_pauseparam = axienet_ethtools_set_pauseparam,
1334 .get_coalesce = axienet_ethtools_get_coalesce,
1335 .set_coalesce = axienet_ethtools_set_coalesce,
1336};
1337
1338/**
1339 * axienet_dma_err_handler - Tasklet handler for Axi DMA Error
1340 * @data: Data passed
1341 *
1342 * Resets the Axi DMA and Axi Ethernet devices, and reconfigures the
1343 * Tx/Rx BDs.
1344 */
1345static void axienet_dma_err_handler(unsigned long data)
1346{
1347 u32 axienet_status;
1348 u32 cr, i;
1349 int mdio_mcreg;
1350 struct axienet_local *lp = (struct axienet_local *) data;
1351 struct net_device *ndev = lp->ndev;
1352 struct axidma_bd *cur_p;
1353
1354 axienet_setoptions(ndev, lp->options &
1355 ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN));
1356 mdio_mcreg = axienet_ior(lp, XAE_MDIO_MC_OFFSET);
1357 axienet_mdio_wait_until_ready(lp);
1358 /* Disable the MDIO interface till Axi Ethernet Reset is completed.
1359 * When we do an Axi Ethernet reset, it resets the complete core
1360 * including the MDIO. So if MDIO is not disabled when the reset
1361 * process is started, MDIO will be broken afterwards. */
1362 axienet_iow(lp, XAE_MDIO_MC_OFFSET, (mdio_mcreg &
1363 ~XAE_MDIO_MC_MDIOEN_MASK));
1364
1365 __axienet_device_reset(lp, &ndev->dev, XAXIDMA_TX_CR_OFFSET);
1366 __axienet_device_reset(lp, &ndev->dev, XAXIDMA_RX_CR_OFFSET);
1367
1368 axienet_iow(lp, XAE_MDIO_MC_OFFSET, mdio_mcreg);
1369 axienet_mdio_wait_until_ready(lp);
1370
1371 for (i = 0; i < TX_BD_NUM; i++) {
1372 cur_p = &lp->tx_bd_v[i];
1373 if (cur_p->phys)
1374 dma_unmap_single(ndev->dev.parent, cur_p->phys,
1375 (cur_p->cntrl &
1376 XAXIDMA_BD_CTRL_LENGTH_MASK),
1377 DMA_TO_DEVICE);
1378 if (cur_p->app4)
1379 dev_kfree_skb_irq((struct sk_buff *) cur_p->app4);
1380 cur_p->phys = 0;
1381 cur_p->cntrl = 0;
1382 cur_p->status = 0;
1383 cur_p->app0 = 0;
1384 cur_p->app1 = 0;
1385 cur_p->app2 = 0;
1386 cur_p->app3 = 0;
1387 cur_p->app4 = 0;
1388 cur_p->sw_id_offset = 0;
1389 }
1390
1391 for (i = 0; i < RX_BD_NUM; i++) {
1392 cur_p = &lp->rx_bd_v[i];
1393 cur_p->status = 0;
1394 cur_p->app0 = 0;
1395 cur_p->app1 = 0;
1396 cur_p->app2 = 0;
1397 cur_p->app3 = 0;
1398 cur_p->app4 = 0;
1399 }
1400
1401 lp->tx_bd_ci = 0;
1402 lp->tx_bd_tail = 0;
1403 lp->rx_bd_ci = 0;
1404
1405 /* Start updating the Rx channel control register */
1406 cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET);
1407 /* Update the interrupt coalesce count */
1408 cr = ((cr & ~XAXIDMA_COALESCE_MASK) |
1409 (XAXIDMA_DFT_RX_THRESHOLD << XAXIDMA_COALESCE_SHIFT));
1410 /* Update the delay timer count */
1411 cr = ((cr & ~XAXIDMA_DELAY_MASK) |
1412 (XAXIDMA_DFT_RX_WAITBOUND << XAXIDMA_DELAY_SHIFT));
1413 /* Enable coalesce, delay timer and error interrupts */
1414 cr |= XAXIDMA_IRQ_ALL_MASK;
1415 /* Finally write to the Rx channel control register */
1416 axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr);
1417
1418 /* Start updating the Tx channel control register */
1419 cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET);
1420 /* Update the interrupt coalesce count */
1421 cr = (((cr & ~XAXIDMA_COALESCE_MASK)) |
1422 (XAXIDMA_DFT_TX_THRESHOLD << XAXIDMA_COALESCE_SHIFT));
1423 /* Update the delay timer count */
1424 cr = (((cr & ~XAXIDMA_DELAY_MASK)) |
1425 (XAXIDMA_DFT_TX_WAITBOUND << XAXIDMA_DELAY_SHIFT));
1426 /* Enable coalesce, delay timer and error interrupts */
1427 cr |= XAXIDMA_IRQ_ALL_MASK;
1428 /* Finally write to the Tx channel control register */
1429 axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr);
1430
1431 /* Populate the tail pointer and bring the Rx Axi DMA engine out of
1432 * halted state. This will make the Rx side ready for reception.*/
1433 axienet_dma_out32(lp, XAXIDMA_RX_CDESC_OFFSET, lp->rx_bd_p);
1434 cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET);
1435 axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET,
1436 cr | XAXIDMA_CR_RUNSTOP_MASK);
1437 axienet_dma_out32(lp, XAXIDMA_RX_TDESC_OFFSET, lp->rx_bd_p +
1438 (sizeof(*lp->rx_bd_v) * (RX_BD_NUM - 1)));
1439
1440 /* Write to the RS (Run-stop) bit in the Tx channel control register.
1441 * Tx channel is now ready to run. But only after we write to the
1442 * tail pointer register that the Tx channel will start transmitting */
1443 axienet_dma_out32(lp, XAXIDMA_TX_CDESC_OFFSET, lp->tx_bd_p);
1444 cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET);
1445 axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET,
1446 cr | XAXIDMA_CR_RUNSTOP_MASK);
1447
1448 axienet_status = axienet_ior(lp, XAE_RCW1_OFFSET);
1449 axienet_status &= ~XAE_RCW1_RX_MASK;
1450 axienet_iow(lp, XAE_RCW1_OFFSET, axienet_status);
1451
1452 axienet_status = axienet_ior(lp, XAE_IP_OFFSET);
1453 if (axienet_status & XAE_INT_RXRJECT_MASK)
1454 axienet_iow(lp, XAE_IS_OFFSET, XAE_INT_RXRJECT_MASK);
1455 axienet_iow(lp, XAE_FCC_OFFSET, XAE_FCC_FCRX_MASK);
1456
1457 /* Sync default options with HW but leave receiver and
1458 * transmitter disabled.*/
1459 axienet_setoptions(ndev, lp->options &
1460 ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN));
1461 axienet_set_mac_address(ndev, NULL);
1462 axienet_set_multicast_list(ndev);
1463 axienet_setoptions(ndev, lp->options);
1464}
1465
1466/**
1467 * axienet_of_probe - Axi Ethernet probe function.
1468 * @op: Pointer to platform device structure.
1469 * @match: Pointer to device id structure
1470 *
1471 * returns: 0, on success
1472 * Non-zero error value on failure.
1473 *
1474 * This is the probe routine for Axi Ethernet driver. This is called before
1475 * any other driver routines are invoked. It allocates and sets up the Ethernet
1476 * device. Parses through device tree and populates fields of
1477 * axienet_local. It registers the Ethernet device.
1478 */
1479static int __devinit axienet_of_probe(struct platform_device *op)
1480{
1481 __be32 *p;
1482 int size, ret = 0;
1483 struct device_node *np;
1484 struct axienet_local *lp;
1485 struct net_device *ndev;
1486 const void *addr;
1487
1488 ndev = alloc_etherdev(sizeof(*lp));
1489 if (!ndev)
1490 return -ENOMEM;
1491
1492 ether_setup(ndev);
1493 dev_set_drvdata(&op->dev, ndev);
1494
1495 SET_NETDEV_DEV(ndev, &op->dev);
1496 ndev->flags &= ~IFF_MULTICAST; /* clear multicast */
1497 ndev->features = NETIF_F_SG | NETIF_F_FRAGLIST;
1498 ndev->netdev_ops = &axienet_netdev_ops;
1499 ndev->ethtool_ops = &axienet_ethtool_ops;
1500
1501 lp = netdev_priv(ndev);
1502 lp->ndev = ndev;
1503 lp->dev = &op->dev;
1504 lp->options = XAE_OPTION_DEFAULTS;
1505 /* Map device registers */
1506 lp->regs = of_iomap(op->dev.of_node, 0);
1507 if (!lp->regs) {
1508 dev_err(&op->dev, "could not map Axi Ethernet regs.\n");
1509 goto nodev;
1510 }
1511 /* Setup checksum offload, but default to off if not specified */
1512 lp->features = 0;
1513
1514 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,txcsum", NULL);
1515 if (p) {
1516 switch (be32_to_cpup(p)) {
1517 case 1:
1518 lp->csum_offload_on_tx_path =
1519 XAE_FEATURE_PARTIAL_TX_CSUM;
1520 lp->features |= XAE_FEATURE_PARTIAL_TX_CSUM;
1521 /* Can checksum TCP/UDP over IPv4. */
1522 ndev->features |= NETIF_F_IP_CSUM;
1523 break;
1524 case 2:
1525 lp->csum_offload_on_tx_path =
1526 XAE_FEATURE_FULL_TX_CSUM;
1527 lp->features |= XAE_FEATURE_FULL_TX_CSUM;
1528 /* Can checksum TCP/UDP over IPv4. */
1529 ndev->features |= NETIF_F_IP_CSUM;
1530 break;
1531 default:
1532 lp->csum_offload_on_tx_path = XAE_NO_CSUM_OFFLOAD;
1533 }
1534 }
1535 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,rxcsum", NULL);
1536 if (p) {
1537 switch (be32_to_cpup(p)) {
1538 case 1:
1539 lp->csum_offload_on_rx_path =
1540 XAE_FEATURE_PARTIAL_RX_CSUM;
1541 lp->features |= XAE_FEATURE_PARTIAL_RX_CSUM;
1542 break;
1543 case 2:
1544 lp->csum_offload_on_rx_path =
1545 XAE_FEATURE_FULL_RX_CSUM;
1546 lp->features |= XAE_FEATURE_FULL_RX_CSUM;
1547 break;
1548 default:
1549 lp->csum_offload_on_rx_path = XAE_NO_CSUM_OFFLOAD;
1550 }
1551 }
1552 /* For supporting jumbo frames, the Axi Ethernet hardware must have
1553 * a larger Rx/Tx Memory. Typically, the size must be more than or
1554 * equal to 16384 bytes, so that we can enable jumbo option and start
1555 * supporting jumbo frames. Here we check for memory allocated for
1556 * Rx/Tx in the hardware from the device-tree and accordingly set
1557 * flags. */
1558 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,rxmem", NULL);
1559 if (p) {
1560 if ((be32_to_cpup(p)) >= 0x4000)
1561 lp->jumbo_support = 1;
1562 }
1563 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,temac-type",
1564 NULL);
1565 if (p)
1566 lp->temac_type = be32_to_cpup(p);
1567 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,phy-type", NULL);
1568 if (p)
1569 lp->phy_type = be32_to_cpup(p);
1570
1571 /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */
1572 np = of_parse_phandle(op->dev.of_node, "axistream-connected", 0);
1573 if (!np) {
1574 dev_err(&op->dev, "could not find DMA node\n");
1575 goto err_iounmap;
1576 }
1577 lp->dma_regs = of_iomap(np, 0);
1578 if (lp->dma_regs) {
1579 dev_dbg(&op->dev, "MEM base: %p\n", lp->dma_regs);
1580 } else {
1581 dev_err(&op->dev, "unable to map DMA registers\n");
1582 of_node_put(np);
1583 }
1584 lp->rx_irq = irq_of_parse_and_map(np, 1);
1585 lp->tx_irq = irq_of_parse_and_map(np, 0);
1586 of_node_put(np);
1587 if ((lp->rx_irq == NO_IRQ) || (lp->tx_irq == NO_IRQ)) {
1588 dev_err(&op->dev, "could not determine irqs\n");
1589 ret = -ENOMEM;
1590 goto err_iounmap_2;
1591 }
1592
1593 /* Retrieve the MAC address */
1594 addr = of_get_property(op->dev.of_node, "local-mac-address", &size);
1595 if ((!addr) || (size != 6)) {
1596 dev_err(&op->dev, "could not find MAC address\n");
1597 ret = -ENODEV;
1598 goto err_iounmap_2;
1599 }
1600 axienet_set_mac_address(ndev, (void *) addr);
1601
1602 lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD;
1603 lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD;
1604
1605 lp->phy_node = of_parse_phandle(op->dev.of_node, "phy-handle", 0);
1606 ret = axienet_mdio_setup(lp, op->dev.of_node);
1607 if (ret)
1608 dev_warn(&op->dev, "error registering MDIO bus\n");
1609
1610 ret = register_netdev(lp->ndev);
1611 if (ret) {
1612 dev_err(lp->dev, "register_netdev() error (%i)\n", ret);
1613 goto err_iounmap_2;
1614 }
1615
1616 tasklet_init(&lp->dma_err_tasklet, axienet_dma_err_handler,
1617 (unsigned long) lp);
1618 tasklet_disable(&lp->dma_err_tasklet);
1619
1620 return 0;
1621
1622err_iounmap_2:
1623 if (lp->dma_regs)
1624 iounmap(lp->dma_regs);
1625err_iounmap:
1626 iounmap(lp->regs);
1627nodev:
1628 free_netdev(ndev);
1629 ndev = NULL;
1630 return ret;
1631}
1632
1633static int __devexit axienet_of_remove(struct platform_device *op)
1634{
1635 struct net_device *ndev = dev_get_drvdata(&op->dev);
1636 struct axienet_local *lp = netdev_priv(ndev);
1637
1638 axienet_mdio_teardown(lp);
1639 unregister_netdev(ndev);
1640
1641 if (lp->phy_node)
1642 of_node_put(lp->phy_node);
1643 lp->phy_node = NULL;
1644
1645 dev_set_drvdata(&op->dev, NULL);
1646
1647 iounmap(lp->regs);
1648 if (lp->dma_regs)
1649 iounmap(lp->dma_regs);
1650 free_netdev(ndev);
1651
1652 return 0;
1653}
1654
1655static struct platform_driver axienet_of_driver = {
1656 .probe = axienet_of_probe,
1657 .remove = __devexit_p(axienet_of_remove),
1658 .driver = {
1659 .owner = THIS_MODULE,
1660 .name = "xilinx_axienet",
1661 .of_match_table = axienet_of_match,
1662 },
1663};
1664
1665static int __init axienet_init(void)
1666{
1667 return platform_driver_register(&axienet_of_driver);
1668}
1669
1670static void __exit axienet_exit(void)
1671{
1672 platform_driver_unregister(&axienet_of_driver);
1673}
1674
1675module_init(axienet_init);
1676module_exit(axienet_exit);
1677
1678MODULE_DESCRIPTION("Xilinx Axi Ethernet driver");
1679MODULE_AUTHOR("Xilinx");
1680MODULE_LICENSE("GPL");
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
new file mode 100644
index 000000000000..d70b6e79f6c0
--- /dev/null
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
@@ -0,0 +1,238 @@
1/*
2 * MDIO bus driver for the Xilinx Axi Ethernet device
3 *
4 * Copyright (c) 2009 Secret Lab Technologies, Ltd.
5 * Copyright (c) 2010 Xilinx, Inc. All rights reserved.
6 * Copyright (c) 2012 Daniel Borkmann, <daniel.borkmann@tik.ee.ethz.ch>
7 * Copyright (c) 2012 Ariane Keller, <ariane.keller@tik.ee.ethz.ch>
8 */
9
10#include <linux/of_address.h>
11#include <linux/of_mdio.h>
12#include <linux/jiffies.h>
13
14#include "xilinx_axienet.h"
15
16#define MAX_MDIO_FREQ 2500000 /* 2.5 MHz */
17#define DEFAULT_CLOCK_DIVISOR XAE_MDIO_DIV_DFT
18
19/* Wait till MDIO interface is ready to accept a new transaction.*/
20int axienet_mdio_wait_until_ready(struct axienet_local *lp)
21{
22 long end = jiffies + 2;
23 while (!(axienet_ior(lp, XAE_MDIO_MCR_OFFSET) &
24 XAE_MDIO_MCR_READY_MASK)) {
25 if (end - jiffies <= 0) {
26 WARN_ON(1);
27 return -ETIMEDOUT;
28 }
29 udelay(1);
30 }
31 return 0;
32}
33
34/**
35 * axienet_mdio_read - MDIO interface read function
36 * @bus: Pointer to mii bus structure
37 * @phy_id: Address of the PHY device
38 * @reg: PHY register to read
39 *
40 * returns: The register contents on success, -ETIMEDOUT on a timeout
41 *
42 * Reads the contents of the requested register from the requested PHY
43 * address by first writing the details into MCR register. After a while
44 * the register MRD is read to obtain the PHY register content.
45 */
46static int axienet_mdio_read(struct mii_bus *bus, int phy_id, int reg)
47{
48 u32 rc;
49 int ret;
50 struct axienet_local *lp = bus->priv;
51
52 ret = axienet_mdio_wait_until_ready(lp);
53 if (ret < 0)
54 return ret;
55
56 axienet_iow(lp, XAE_MDIO_MCR_OFFSET,
57 (((phy_id << XAE_MDIO_MCR_PHYAD_SHIFT) &
58 XAE_MDIO_MCR_PHYAD_MASK) |
59 ((reg << XAE_MDIO_MCR_REGAD_SHIFT) &
60 XAE_MDIO_MCR_REGAD_MASK) |
61 XAE_MDIO_MCR_INITIATE_MASK |
62 XAE_MDIO_MCR_OP_READ_MASK));
63
64 ret = axienet_mdio_wait_until_ready(lp);
65 if (ret < 0)
66 return ret;
67
68 rc = axienet_ior(lp, XAE_MDIO_MRD_OFFSET) & 0x0000FFFF;
69
70 dev_dbg(lp->dev, "axienet_mdio_read(phy_id=%i, reg=%x) == %x\n",
71 phy_id, reg, rc);
72
73 return rc;
74}
75
76/**
77 * axienet_mdio_write - MDIO interface write function
78 * @bus: Pointer to mii bus structure
79 * @phy_id: Address of the PHY device
80 * @reg: PHY register to write to
81 * @val: Value to be written into the register
82 *
83 * returns: 0 on success, -ETIMEDOUT on a timeout
84 *
85 * Writes the value to the requested register by first writing the value
86 * into MWD register. The the MCR register is then appropriately setup
87 * to finish the write operation.
88 */
89static int axienet_mdio_write(struct mii_bus *bus, int phy_id, int reg,
90 u16 val)
91{
92 int ret;
93 struct axienet_local *lp = bus->priv;
94
95 dev_dbg(lp->dev, "axienet_mdio_write(phy_id=%i, reg=%x, val=%x)\n",
96 phy_id, reg, val);
97
98 ret = axienet_mdio_wait_until_ready(lp);
99 if (ret < 0)
100 return ret;
101
102 axienet_iow(lp, XAE_MDIO_MWD_OFFSET, (u32) val);
103 axienet_iow(lp, XAE_MDIO_MCR_OFFSET,
104 (((phy_id << XAE_MDIO_MCR_PHYAD_SHIFT) &
105 XAE_MDIO_MCR_PHYAD_MASK) |
106 ((reg << XAE_MDIO_MCR_REGAD_SHIFT) &
107 XAE_MDIO_MCR_REGAD_MASK) |
108 XAE_MDIO_MCR_INITIATE_MASK |
109 XAE_MDIO_MCR_OP_WRITE_MASK));
110
111 ret = axienet_mdio_wait_until_ready(lp);
112 if (ret < 0)
113 return ret;
114 return 0;
115}
116
117/**
118 * axienet_mdio_setup - MDIO setup function
119 * @lp: Pointer to axienet local data structure.
120 * @np: Pointer to device node
121 *
122 * returns: 0 on success, -ETIMEDOUT on a timeout, -ENOMEM when
123 * mdiobus_alloc (to allocate memory for mii bus structure) fails.
124 *
125 * Sets up the MDIO interface by initializing the MDIO clock and enabling the
126 * MDIO interface in hardware. Register the MDIO interface.
127 **/
128int axienet_mdio_setup(struct axienet_local *lp, struct device_node *np)
129{
130 int ret;
131 u32 clk_div, host_clock;
132 u32 *property_p;
133 struct mii_bus *bus;
134 struct resource res;
135 struct device_node *np1;
136
137 /* clk_div can be calculated by deriving it from the equation:
138 * fMDIO = fHOST / ((1 + clk_div) * 2)
139 *
140 * Where fMDIO <= 2500000, so we get:
141 * fHOST / ((1 + clk_div) * 2) <= 2500000
142 *
143 * Then we get:
144 * 1 / ((1 + clk_div) * 2) <= (2500000 / fHOST)
145 *
146 * Then we get:
147 * 1 / (1 + clk_div) <= ((2500000 * 2) / fHOST)
148 *
149 * Then we get:
150 * 1 / (1 + clk_div) <= (5000000 / fHOST)
151 *
152 * So:
153 * (1 + clk_div) >= (fHOST / 5000000)
154 *
155 * And finally:
156 * clk_div >= (fHOST / 5000000) - 1
157 *
158 * fHOST can be read from the flattened device tree as property
159 * "clock-frequency" from the CPU
160 */
161
162 np1 = of_find_node_by_name(NULL, "cpu");
163 if (!np1) {
164 printk(KERN_WARNING "%s(): Could not find CPU device node.",
165 __func__);
166 printk(KERN_WARNING "Setting MDIO clock divisor to "
167 "default %d\n", DEFAULT_CLOCK_DIVISOR);
168 clk_div = DEFAULT_CLOCK_DIVISOR;
169 goto issue;
170 }
171 property_p = (u32 *) of_get_property(np1, "clock-frequency", NULL);
172 if (!property_p) {
173 printk(KERN_WARNING "%s(): Could not find CPU property: "
174 "clock-frequency.", __func__);
175 printk(KERN_WARNING "Setting MDIO clock divisor to "
176 "default %d\n", DEFAULT_CLOCK_DIVISOR);
177 clk_div = DEFAULT_CLOCK_DIVISOR;
178 goto issue;
179 }
180
181 host_clock = be32_to_cpup(property_p);
182 clk_div = (host_clock / (MAX_MDIO_FREQ * 2)) - 1;
183 /* If there is any remainder from the division of
184 * fHOST / (MAX_MDIO_FREQ * 2), then we need to add
185 * 1 to the clock divisor or we will surely be above 2.5 MHz */
186 if (host_clock % (MAX_MDIO_FREQ * 2))
187 clk_div++;
188
189 printk(KERN_DEBUG "%s(): Setting MDIO clock divisor to %u based "
190 "on %u Hz host clock.\n", __func__, clk_div, host_clock);
191
192 of_node_put(np1);
193issue:
194 axienet_iow(lp, XAE_MDIO_MC_OFFSET,
195 (((u32) clk_div) | XAE_MDIO_MC_MDIOEN_MASK));
196
197 ret = axienet_mdio_wait_until_ready(lp);
198 if (ret < 0)
199 return ret;
200
201 bus = mdiobus_alloc();
202 if (!bus)
203 return -ENOMEM;
204
205 np1 = of_get_parent(lp->phy_node);
206 of_address_to_resource(np1, 0, &res);
207 snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx",
208 (unsigned long long) res.start);
209
210 bus->priv = lp;
211 bus->name = "Xilinx Axi Ethernet MDIO";
212 bus->read = axienet_mdio_read;
213 bus->write = axienet_mdio_write;
214 bus->parent = lp->dev;
215 bus->irq = lp->mdio_irqs; /* preallocated IRQ table */
216 lp->mii_bus = bus;
217
218 ret = of_mdiobus_register(bus, np1);
219 if (ret) {
220 mdiobus_free(bus);
221 return ret;
222 }
223 return 0;
224}
225
226/**
227 * axienet_mdio_teardown - MDIO remove function
228 * @lp: Pointer to axienet local data structure.
229 *
230 * Unregisters the MDIO and frees any associate memory for mii bus.
231 */
232void axienet_mdio_teardown(struct axienet_local *lp)
233{
234 mdiobus_unregister(lp->mii_bus);
235 kfree(lp->mii_bus->irq);
236 mdiobus_free(lp->mii_bus);
237 lp->mii_bus = NULL;
238}
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 79013e5731a5..77cfe5110318 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -613,7 +613,7 @@ static void xemaclite_rx_handler(struct net_device *dev)
613 u32 len; 613 u32 len;
614 614
615 len = ETH_FRAME_LEN + ETH_FCS_LEN; 615 len = ETH_FRAME_LEN + ETH_FCS_LEN;
616 skb = dev_alloc_skb(len + ALIGNMENT); 616 skb = netdev_alloc_skb(dev, len + ALIGNMENT);
617 if (!skb) { 617 if (!skb) {
618 /* Couldn't get memory. */ 618 /* Couldn't get memory. */
619 dev->stats.rx_dropped++; 619 dev->stats.rx_dropped++;
@@ -1136,10 +1136,8 @@ static int __devinit xemaclite_of_probe(struct platform_device *ofdev)
1136 1136
1137 /* Create an ethernet device instance */ 1137 /* Create an ethernet device instance */
1138 ndev = alloc_etherdev(sizeof(struct net_local)); 1138 ndev = alloc_etherdev(sizeof(struct net_local));
1139 if (!ndev) { 1139 if (!ndev)
1140 dev_err(dev, "Could not allocate network device\n");
1141 return -ENOMEM; 1140 return -ENOMEM;
1142 }
1143 1141
1144 dev_set_drvdata(dev, ndev); 1142 dev_set_drvdata(dev, ndev);
1145 SET_NETDEV_DEV(ndev, &ofdev->dev); 1143 SET_NETDEV_DEV(ndev, &ofdev->dev);
diff --git a/drivers/net/ethernet/xircom/xirc2ps_cs.c b/drivers/net/ethernet/xircom/xirc2ps_cs.c
index 33979c3ac943..5c69c6f93fb8 100644
--- a/drivers/net/ethernet/xircom/xirc2ps_cs.c
+++ b/drivers/net/ethernet/xircom/xirc2ps_cs.c
@@ -1039,7 +1039,8 @@ xirc2ps_interrupt(int irq, void *dev_id)
1039 1039
1040 pr_debug("rsr=%#02x packet_length=%u\n", rsr, pktlen); 1040 pr_debug("rsr=%#02x packet_length=%u\n", rsr, pktlen);
1041 1041
1042 skb = dev_alloc_skb(pktlen+3); /* 1 extra so we can use insw */ 1042 /* 1 extra so we can use insw */
1043 skb = netdev_alloc_skb(dev, pktlen + 3);
1043 if (!skb) { 1044 if (!skb) {
1044 pr_notice("low memory, packet dropped (size=%u)\n", pktlen); 1045 pr_notice("low memory, packet dropped (size=%u)\n", pktlen);
1045 dev->stats.rx_dropped++; 1046 dev->stats.rx_dropped++;
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 9537aaa50c2f..49b8b58fc5c6 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -1162,7 +1162,7 @@ static void baycom_probe(struct net_device *dev)
1162/* 1162/*
1163 * command line settable parameters 1163 * command line settable parameters
1164 */ 1164 */
1165static const char *mode[NR_PORTS] = { "", }; 1165static char *mode[NR_PORTS] = { "", };
1166static int iobase[NR_PORTS] = { 0x378, }; 1166static int iobase[NR_PORTS] = { 0x378, };
1167 1167
1168module_param_array(mode, charp, NULL, 0); 1168module_param_array(mode, charp, NULL, 0);
diff --git a/drivers/net/hamradio/baycom_par.c b/drivers/net/hamradio/baycom_par.c
index 279d2296290a..f1aea0c98333 100644
--- a/drivers/net/hamradio/baycom_par.c
+++ b/drivers/net/hamradio/baycom_par.c
@@ -477,7 +477,7 @@ static int baycom_ioctl(struct net_device *dev, struct ifreq *ifr,
477/* 477/*
478 * command line settable parameters 478 * command line settable parameters
479 */ 479 */
480static const char *mode[NR_PORTS] = { "picpar", }; 480static char *mode[NR_PORTS] = { "picpar", };
481static int iobase[NR_PORTS] = { 0x378, }; 481static int iobase[NR_PORTS] = { 0x378, };
482 482
483module_param_array(mode, charp, NULL, 0); 483module_param_array(mode, charp, NULL, 0);
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 96a98d2ff151..696327773fbe 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -403,7 +403,6 @@ static unsigned char *add_mcs(unsigned char *bits, int bitrate,
403 403
404 /* Allocate a new mcs */ 404 /* Allocate a new mcs */
405 if ((p = kmalloc(sizeof(struct yam_mcs), GFP_KERNEL)) == NULL) { 405 if ((p = kmalloc(sizeof(struct yam_mcs), GFP_KERNEL)) == NULL) {
406 printk(KERN_WARNING "YAM: no memory to allocate mcs\n");
407 release_firmware(fw); 406 release_firmware(fw);
408 return NULL; 407 return NULL;
409 } 408 }
diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index e68c941926f1..2a51363d9fed 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -1600,12 +1600,8 @@ static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1600 } 1600 }
1601 1601
1602 image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL); 1602 image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
1603 if (!image){ 1603 if (!image)
1604 printk(KERN_ERR "%s: Unable to allocate memory "
1605 "for EEPROM image\n", dev->name);
1606 return -ENOMEM; 1604 return -ENOMEM;
1607 }
1608
1609 1605
1610 if (rrpriv->fw_running){ 1606 if (rrpriv->fw_running){
1611 printk("%s: Firmware already running\n", dev->name); 1607 printk("%s: Firmware already running\n", dev->name);
@@ -1637,8 +1633,6 @@ static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1637 image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL); 1633 image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
1638 oldimage = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL); 1634 oldimage = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
1639 if (!image || !oldimage) { 1635 if (!image || !oldimage) {
1640 printk(KERN_ERR "%s: Unable to allocate memory "
1641 "for EEPROM image\n", dev->name);
1642 error = -ENOMEM; 1636 error = -ENOMEM;
1643 goto wf_out; 1637 goto wf_out;
1644 } 1638 }
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 466c58a7353d..0ae7a1a6aeb0 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -267,13 +267,10 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,
267int netvsc_recv_callback(struct hv_device *device_obj, 267int netvsc_recv_callback(struct hv_device *device_obj,
268 struct hv_netvsc_packet *packet) 268 struct hv_netvsc_packet *packet)
269{ 269{
270 struct net_device *net = dev_get_drvdata(&device_obj->device); 270 struct net_device *net;
271 struct sk_buff *skb; 271 struct sk_buff *skb;
272 struct netvsc_device *net_device;
273
274 net_device = hv_get_drvdata(device_obj);
275 net = net_device->ndev;
276 272
273 net = ((struct netvsc_device *)hv_get_drvdata(device_obj))->ndev;
277 if (!net) { 274 if (!net) {
278 netdev_err(net, "got receive callback but net device" 275 netdev_err(net, "got receive callback but net device"
279 " not initialized yet\n"); 276 " not initialized yet\n");
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 133b7fbf8595..136efd84373f 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -758,66 +758,64 @@ int rndis_filter_open(struct hv_device *dev)
758 758
759int rndis_filter_close(struct hv_device *dev) 759int rndis_filter_close(struct hv_device *dev)
760{ 760{
761 struct netvsc_device *netDevice = hv_get_drvdata(dev); 761 struct netvsc_device *nvdev = hv_get_drvdata(dev);
762 762
763 if (!netDevice) 763 if (!nvdev)
764 return -EINVAL; 764 return -EINVAL;
765 765
766 return rndis_filter_close_device(netDevice->extension); 766 return rndis_filter_close_device(nvdev->extension);
767} 767}
768 768
769int rndis_filter_send(struct hv_device *dev, 769int rndis_filter_send(struct hv_device *dev,
770 struct hv_netvsc_packet *pkt) 770 struct hv_netvsc_packet *pkt)
771{ 771{
772 int ret; 772 int ret;
773 struct rndis_filter_packet *filterPacket; 773 struct rndis_filter_packet *filter_pkt;
774 struct rndis_message *rndisMessage; 774 struct rndis_message *rndis_msg;
775 struct rndis_packet *rndisPacket; 775 struct rndis_packet *rndis_pkt;
776 u32 rndisMessageSize; 776 u32 rndis_msg_size;
777 777
778 /* Add the rndis header */ 778 /* Add the rndis header */
779 filterPacket = (struct rndis_filter_packet *)pkt->extension; 779 filter_pkt = (struct rndis_filter_packet *)pkt->extension;
780
781 memset(filterPacket, 0, sizeof(struct rndis_filter_packet));
782 780
783 rndisMessage = &filterPacket->msg; 781 rndis_msg = &filter_pkt->msg;
784 rndisMessageSize = RNDIS_MESSAGE_SIZE(struct rndis_packet); 782 rndis_msg_size = RNDIS_MESSAGE_SIZE(struct rndis_packet);
785 783
786 rndisMessage->ndis_msg_type = REMOTE_NDIS_PACKET_MSG; 784 rndis_msg->ndis_msg_type = REMOTE_NDIS_PACKET_MSG;
787 rndisMessage->msg_len = pkt->total_data_buflen + 785 rndis_msg->msg_len = pkt->total_data_buflen +
788 rndisMessageSize; 786 rndis_msg_size;
789 787
790 rndisPacket = &rndisMessage->msg.pkt; 788 rndis_pkt = &rndis_msg->msg.pkt;
791 rndisPacket->data_offset = sizeof(struct rndis_packet); 789 rndis_pkt->data_offset = sizeof(struct rndis_packet);
792 rndisPacket->data_len = pkt->total_data_buflen; 790 rndis_pkt->data_len = pkt->total_data_buflen;
793 791
794 pkt->is_data_pkt = true; 792 pkt->is_data_pkt = true;
795 pkt->page_buf[0].pfn = virt_to_phys(rndisMessage) >> PAGE_SHIFT; 793 pkt->page_buf[0].pfn = virt_to_phys(rndis_msg) >> PAGE_SHIFT;
796 pkt->page_buf[0].offset = 794 pkt->page_buf[0].offset =
797 (unsigned long)rndisMessage & (PAGE_SIZE-1); 795 (unsigned long)rndis_msg & (PAGE_SIZE-1);
798 pkt->page_buf[0].len = rndisMessageSize; 796 pkt->page_buf[0].len = rndis_msg_size;
799 797
800 /* Add one page_buf if the rndis msg goes beyond page boundary */ 798 /* Add one page_buf if the rndis msg goes beyond page boundary */
801 if (pkt->page_buf[0].offset + rndisMessageSize > PAGE_SIZE) { 799 if (pkt->page_buf[0].offset + rndis_msg_size > PAGE_SIZE) {
802 int i; 800 int i;
803 for (i = pkt->page_buf_cnt; i > 1; i--) 801 for (i = pkt->page_buf_cnt; i > 1; i--)
804 pkt->page_buf[i] = pkt->page_buf[i-1]; 802 pkt->page_buf[i] = pkt->page_buf[i-1];
805 pkt->page_buf_cnt++; 803 pkt->page_buf_cnt++;
806 pkt->page_buf[0].len = PAGE_SIZE - pkt->page_buf[0].offset; 804 pkt->page_buf[0].len = PAGE_SIZE - pkt->page_buf[0].offset;
807 pkt->page_buf[1].pfn = virt_to_phys((void *)((ulong) 805 pkt->page_buf[1].pfn = virt_to_phys((void *)((ulong)
808 rndisMessage + pkt->page_buf[0].len)) >> PAGE_SHIFT; 806 rndis_msg + pkt->page_buf[0].len)) >> PAGE_SHIFT;
809 pkt->page_buf[1].offset = 0; 807 pkt->page_buf[1].offset = 0;
810 pkt->page_buf[1].len = rndisMessageSize - pkt->page_buf[0].len; 808 pkt->page_buf[1].len = rndis_msg_size - pkt->page_buf[0].len;
811 } 809 }
812 810
813 /* Save the packet send completion and context */ 811 /* Save the packet send completion and context */
814 filterPacket->completion = pkt->completion.send.send_completion; 812 filter_pkt->completion = pkt->completion.send.send_completion;
815 filterPacket->completion_ctx = 813 filter_pkt->completion_ctx =
816 pkt->completion.send.send_completion_ctx; 814 pkt->completion.send.send_completion_ctx;
817 815
818 /* Use ours */ 816 /* Use ours */
819 pkt->completion.send.send_completion = rndis_filter_send_completion; 817 pkt->completion.send.send_completion = rndis_filter_send_completion;
820 pkt->completion.send.send_completion_ctx = filterPacket; 818 pkt->completion.send.send_completion_ctx = filter_pkt;
821 819
822 ret = netvsc_send(dev, pkt); 820 ret = netvsc_send(dev, pkt);
823 if (ret != 0) { 821 if (ret != 0) {
@@ -826,9 +824,9 @@ int rndis_filter_send(struct hv_device *dev,
826 * above 824 * above
827 */ 825 */
828 pkt->completion.send.send_completion = 826 pkt->completion.send.send_completion =
829 filterPacket->completion; 827 filter_pkt->completion;
830 pkt->completion.send.send_completion_ctx = 828 pkt->completion.send.send_completion_ctx =
831 filterPacket->completion_ctx; 829 filter_pkt->completion_ctx;
832 } 830 }
833 831
834 return ret; 832 return ret;
@@ -836,10 +834,10 @@ int rndis_filter_send(struct hv_device *dev,
836 834
837static void rndis_filter_send_completion(void *ctx) 835static void rndis_filter_send_completion(void *ctx)
838{ 836{
839 struct rndis_filter_packet *filterPacket = ctx; 837 struct rndis_filter_packet *filter_pkt = ctx;
840 838
841 /* Pass it back to the original handler */ 839 /* Pass it back to the original handler */
842 filterPacket->completion(filterPacket->completion_ctx); 840 filter_pkt->completion(filter_pkt->completion_ctx);
843} 841}
844 842
845 843
diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c
index 64f403da101c..617a446d126c 100644
--- a/drivers/net/irda/donauboe.c
+++ b/drivers/net/irda/donauboe.c
@@ -1608,7 +1608,6 @@ toshoboe_open (struct pci_dev *pci_dev, const struct pci_device_id *pdid)
1608 self->ringbuf = kmalloc(OBOE_RING_LEN << 1, GFP_KERNEL); 1608 self->ringbuf = kmalloc(OBOE_RING_LEN << 1, GFP_KERNEL);
1609 if (!self->ringbuf) 1609 if (!self->ringbuf)
1610 { 1610 {
1611 printk (KERN_ERR DRIVER_NAME ": can't allocate DMA buffers\n");
1612 err = -ENOMEM; 1611 err = -ENOMEM;
1613 goto freeregion; 1612 goto freeregion;
1614 } 1613 }
@@ -1647,7 +1646,6 @@ toshoboe_open (struct pci_dev *pci_dev, const struct pci_device_id *pdid)
1647 1646
1648 if (!ok) 1647 if (!ok)
1649 { 1648 {
1650 printk (KERN_ERR DRIVER_NAME ": can't allocate rx/tx buffers\n");
1651 err = -ENOMEM; 1649 err = -ENOMEM;
1652 goto freebufs; 1650 goto freebufs;
1653 } 1651 }
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index e8882023576b..f9347ea3d381 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -169,10 +169,8 @@ static struct netconsole_target *alloc_param_target(char *target_config)
169 * Note that these targets get their config_item fields zeroed-out. 169 * Note that these targets get their config_item fields zeroed-out.
170 */ 170 */
171 nt = kzalloc(sizeof(*nt), GFP_KERNEL); 171 nt = kzalloc(sizeof(*nt), GFP_KERNEL);
172 if (!nt) { 172 if (!nt)
173 printk(KERN_ERR "netconsole: failed to allocate memory\n");
174 goto fail; 173 goto fail;
175 }
176 174
177 nt->np.name = "netconsole"; 175 nt->np.name = "netconsole";
178 strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ); 176 strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ);
@@ -551,10 +549,8 @@ static struct config_item *make_netconsole_target(struct config_group *group,
551 * Target is disabled at creation (enabled == 0). 549 * Target is disabled at creation (enabled == 0).
552 */ 550 */
553 nt = kzalloc(sizeof(*nt), GFP_KERNEL); 551 nt = kzalloc(sizeof(*nt), GFP_KERNEL);
554 if (!nt) { 552 if (!nt)
555 printk(KERN_ERR "netconsole: failed to allocate memory\n");
556 return ERR_PTR(-ENOMEM); 553 return ERR_PTR(-ENOMEM);
557 }
558 554
559 nt->np.name = "netconsole"; 555 nt->np.name = "netconsole";
560 strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ); 556 strlcpy(nt->np.dev_name, "eth0", IFNAMSIZ);
diff --git a/drivers/net/plip/plip.c b/drivers/net/plip/plip.c
index a9e9ca8a86ed..1a5a316cc968 100644
--- a/drivers/net/plip/plip.c
+++ b/drivers/net/plip/plip.c
@@ -1260,10 +1260,8 @@ static void plip_attach (struct parport *port)
1260 1260
1261 sprintf(name, "plip%d", unit); 1261 sprintf(name, "plip%d", unit);
1262 dev = alloc_etherdev(sizeof(struct net_local)); 1262 dev = alloc_etherdev(sizeof(struct net_local));
1263 if (!dev) { 1263 if (!dev)
1264 printk(KERN_ERR "plip: memory squeeze\n");
1265 return; 1264 return;
1266 }
1267 1265
1268 strcpy(dev->name, name); 1266 strcpy(dev->name, name);
1269 1267
diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index df884dde2a51..234cd9d87ed9 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -670,10 +670,8 @@ static int __init pptp_init_module(void)
670 pr_info("PPTP driver version " PPTP_DRIVER_VERSION "\n"); 670 pr_info("PPTP driver version " PPTP_DRIVER_VERSION "\n");
671 671
672 callid_sock = vzalloc((MAX_CALLID + 1) * sizeof(void *)); 672 callid_sock = vzalloc((MAX_CALLID + 1) * sizeof(void *));
673 if (!callid_sock) { 673 if (!callid_sock)
674 pr_err("PPTP: cann't allocate memory\n");
675 return -ENOMEM; 674 return -ENOMEM;
676 }
677 675
678 err = gre_add_protocol(&gre_pptp_protocol, GREPROTO_PPTP); 676 err = gre_add_protocol(&gre_pptp_protocol, GREPROTO_PPTP);
679 if (err) { 677 if (err) {
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index 7145714a5ec9..a57f05726b57 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -497,8 +497,6 @@ static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id)
497 /* Allocate our net_device structure */ 497 /* Allocate our net_device structure */
498 ndev = alloc_etherdev(sizeof(struct rionet_private)); 498 ndev = alloc_etherdev(sizeof(struct rionet_private));
499 if (ndev == NULL) { 499 if (ndev == NULL) {
500 printk(KERN_INFO "%s: could not allocate ethernet device.\n",
501 DRV_NAME);
502 rc = -ENOMEM; 500 rc = -ENOMEM;
503 goto out; 501 goto out;
504 } 502 }
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index ba08341fb92c..69345dfae0fd 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -1296,10 +1296,8 @@ static int __init slip_init(void)
1296 1296
1297 slip_devs = kzalloc(sizeof(struct net_device *)*slip_maxdev, 1297 slip_devs = kzalloc(sizeof(struct net_device *)*slip_maxdev,
1298 GFP_KERNEL); 1298 GFP_KERNEL);
1299 if (!slip_devs) { 1299 if (!slip_devs)
1300 printk(KERN_ERR "SLIP: Can't allocate slip devices array.\n");
1301 return -ENOMEM; 1300 return -ENOMEM;
1302 }
1303 1301
1304 /* Fill in our line protocol discipline, and register it */ 1302 /* Fill in our line protocol discipline, and register it */
1305 status = tty_register_ldisc(N_SLIP, &sl_ldisc); 1303 status = tty_register_ldisc(N_SLIP, &sl_ldisc);
diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index ef9fdf3652f6..d7c292aa76b1 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -674,15 +674,11 @@ static int xl_open(struct net_device *dev)
674 /* These MUST be on 8 byte boundaries */ 674 /* These MUST be on 8 byte boundaries */
675 xl_priv->xl_tx_ring = kzalloc((sizeof(struct xl_tx_desc) * XL_TX_RING_SIZE) + 7, GFP_DMA | GFP_KERNEL); 675 xl_priv->xl_tx_ring = kzalloc((sizeof(struct xl_tx_desc) * XL_TX_RING_SIZE) + 7, GFP_DMA | GFP_KERNEL);
676 if (xl_priv->xl_tx_ring == NULL) { 676 if (xl_priv->xl_tx_ring == NULL) {
677 printk(KERN_WARNING "%s: Not enough memory to allocate tx buffers.\n",
678 dev->name);
679 free_irq(dev->irq,dev); 677 free_irq(dev->irq,dev);
680 return -ENOMEM; 678 return -ENOMEM;
681 } 679 }
682 xl_priv->xl_rx_ring = kzalloc((sizeof(struct xl_rx_desc) * XL_RX_RING_SIZE) +7, GFP_DMA | GFP_KERNEL); 680 xl_priv->xl_rx_ring = kzalloc((sizeof(struct xl_rx_desc) * XL_RX_RING_SIZE) +7, GFP_DMA | GFP_KERNEL);
683 if (xl_priv->xl_rx_ring == NULL) { 681 if (xl_priv->xl_rx_ring == NULL) {
684 printk(KERN_WARNING "%s: Not enough memory to allocate rx buffers.\n",
685 dev->name);
686 free_irq(dev->irq,dev); 682 free_irq(dev->irq,dev);
687 kfree(xl_priv->xl_tx_ring); 683 kfree(xl_priv->xl_tx_ring);
688 return -ENOMEM; 684 return -ENOMEM;
diff --git a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c
index 6153cfd696b6..1cdc034f6aec 100644
--- a/drivers/net/tokenring/madgemc.c
+++ b/drivers/net/tokenring/madgemc.c
@@ -171,7 +171,6 @@ static int __devinit madgemc_probe(struct device *device)
171 171
172 card = kmalloc(sizeof(struct card_info), GFP_KERNEL); 172 card = kmalloc(sizeof(struct card_info), GFP_KERNEL);
173 if (card==NULL) { 173 if (card==NULL) {
174 printk("madgemc: unable to allocate card struct\n");
175 ret = -ENOMEM; 174 ret = -ENOMEM;
176 goto getout1; 175 goto getout1;
177 } 176 }
diff --git a/drivers/net/tokenring/tms380tr.c b/drivers/net/tokenring/tms380tr.c
index 65e9cf3a71fe..102f896bbc58 100644
--- a/drivers/net/tokenring/tms380tr.c
+++ b/drivers/net/tokenring/tms380tr.c
@@ -1525,10 +1525,8 @@ static void tms380tr_chk_outstanding_cmds(struct net_device *dev)
1525 /* Check if adapter is opened, avoiding COMMAND_REJECT 1525 /* Check if adapter is opened, avoiding COMMAND_REJECT
1526 * interrupt by the adapter! 1526 * interrupt by the adapter!
1527 */ 1527 */
1528 if(tp->AdapterOpenFlag == 0) 1528 if (tp->AdapterOpenFlag == 0) {
1529 { 1529 if (tp->CMDqueue & OC_OPEN) {
1530 if(tp->CMDqueue & OC_OPEN)
1531 {
1532 /* Execute OPEN command */ 1530 /* Execute OPEN command */
1533 tp->CMDqueue ^= OC_OPEN; 1531 tp->CMDqueue ^= OC_OPEN;
1534 1532
@@ -1536,21 +1534,17 @@ static void tms380tr_chk_outstanding_cmds(struct net_device *dev)
1536 tp->scb.Parm[0] = LOWORD(Addr); 1534 tp->scb.Parm[0] = LOWORD(Addr);
1537 tp->scb.Parm[1] = HIWORD(Addr); 1535 tp->scb.Parm[1] = HIWORD(Addr);
1538 tp->scb.CMD = OPEN; 1536 tp->scb.CMD = OPEN;
1539 } 1537 } else
1540 else
1541 /* No OPEN command queued, but adapter closed. Note: 1538 /* No OPEN command queued, but adapter closed. Note:
1542 * We'll try to re-open the adapter in DriverPoll() 1539 * We'll try to re-open the adapter in DriverPoll()
1543 */ 1540 */
1544 return; /* No adapter command issued */ 1541 return; /* No adapter command issued */
1545 } 1542 } else {
1546 else
1547 {
1548 /* Adapter is open; evaluate command queue: try to execute 1543 /* Adapter is open; evaluate command queue: try to execute
1549 * outstanding commands (depending on priority!) CLOSE 1544 * outstanding commands (depending on priority!) CLOSE
1550 * command queued 1545 * command queued
1551 */ 1546 */
1552 if(tp->CMDqueue & OC_CLOSE) 1547 if (tp->CMDqueue & OC_CLOSE) {
1553 {
1554 tp->CMDqueue ^= OC_CLOSE; 1548 tp->CMDqueue ^= OC_CLOSE;
1555 tp->AdapterOpenFlag = 0; 1549 tp->AdapterOpenFlag = 0;
1556 tp->scb.Parm[0] = 0; /* Parm[0], Parm[1] are ignored */ 1550 tp->scb.Parm[0] = 0; /* Parm[0], Parm[1] are ignored */
@@ -1560,109 +1554,70 @@ static void tms380tr_chk_outstanding_cmds(struct net_device *dev)
1560 tp->CMDqueue |= OC_OPEN; /* re-open adapter */ 1554 tp->CMDqueue |= OC_OPEN; /* re-open adapter */
1561 else 1555 else
1562 tp->CMDqueue = 0; /* no more commands */ 1556 tp->CMDqueue = 0; /* no more commands */
1563 } 1557 } else if (tp->CMDqueue & OC_RECEIVE) {
1564 else 1558 tp->CMDqueue ^= OC_RECEIVE;
1565 { 1559 Addr = htonl(((char *)tp->RplHead - (char *)tp) + tp->dmabuffer);
1566 if(tp->CMDqueue & OC_RECEIVE) 1560 tp->scb.Parm[0] = LOWORD(Addr);
1567 { 1561 tp->scb.Parm[1] = HIWORD(Addr);
1568 tp->CMDqueue ^= OC_RECEIVE; 1562 tp->scb.CMD = RECEIVE;
1569 Addr = htonl(((char *)tp->RplHead - (char *)tp) + tp->dmabuffer); 1563 } else if (tp->CMDqueue & OC_TRANSMIT_HALT) {
1570 tp->scb.Parm[0] = LOWORD(Addr); 1564 /* NOTE: TRANSMIT.HALT must be checked
1571 tp->scb.Parm[1] = HIWORD(Addr); 1565 * before TRANSMIT.
1572 tp->scb.CMD = RECEIVE; 1566 */
1573 } 1567 tp->CMDqueue ^= OC_TRANSMIT_HALT;
1574 else 1568 tp->scb.CMD = TRANSMIT_HALT;
1575 { 1569
1576 if(tp->CMDqueue & OC_TRANSMIT_HALT) 1570 /* Parm[0] and Parm[1] are ignored
1577 { 1571 * but should be set to zero!
1578 /* NOTE: TRANSMIT.HALT must be checked 1572 */
1579 * before TRANSMIT. 1573 tp->scb.Parm[0] = 0;
1580 */ 1574 tp->scb.Parm[1] = 0;
1581 tp->CMDqueue ^= OC_TRANSMIT_HALT; 1575 } else if (tp->CMDqueue & OC_TRANSMIT) {
1582 tp->scb.CMD = TRANSMIT_HALT; 1576 /* NOTE: TRANSMIT must be
1583 1577 * checked after TRANSMIT.HALT
1584 /* Parm[0] and Parm[1] are ignored 1578 */
1585 * but should be set to zero! 1579 if (tp->TransmitCommandActive) {
1586 */ 1580 if (!tp->TransmitHaltScheduled) {
1587 tp->scb.Parm[0] = 0; 1581 tp->TransmitHaltScheduled = 1;
1588 tp->scb.Parm[1] = 0; 1582 tms380tr_exec_cmd(dev, OC_TRANSMIT_HALT);
1589 }
1590 else
1591 {
1592 if(tp->CMDqueue & OC_TRANSMIT)
1593 {
1594 /* NOTE: TRANSMIT must be
1595 * checked after TRANSMIT.HALT
1596 */
1597 if(tp->TransmitCommandActive)
1598 {
1599 if(!tp->TransmitHaltScheduled)
1600 {
1601 tp->TransmitHaltScheduled = 1;
1602 tms380tr_exec_cmd(dev, OC_TRANSMIT_HALT) ;
1603 }
1604 tp->TransmitCommandActive = 0;
1605 return;
1606 }
1607
1608 tp->CMDqueue ^= OC_TRANSMIT;
1609 tms380tr_cancel_tx_queue(tp);
1610 Addr = htonl(((char *)tp->TplBusy - (char *)tp) + tp->dmabuffer);
1611 tp->scb.Parm[0] = LOWORD(Addr);
1612 tp->scb.Parm[1] = HIWORD(Addr);
1613 tp->scb.CMD = TRANSMIT;
1614 tp->TransmitCommandActive = 1;
1615 }
1616 else
1617 {
1618 if(tp->CMDqueue & OC_MODIFY_OPEN_PARMS)
1619 {
1620 tp->CMDqueue ^= OC_MODIFY_OPEN_PARMS;
1621 tp->scb.Parm[0] = tp->ocpl.OPENOptions; /* new OPEN options*/
1622 tp->scb.Parm[0] |= ENABLE_FULL_DUPLEX_SELECTION;
1623 tp->scb.Parm[1] = 0; /* is ignored but should be zero */
1624 tp->scb.CMD = MODIFY_OPEN_PARMS;
1625 }
1626 else
1627 {
1628 if(tp->CMDqueue & OC_SET_FUNCT_ADDR)
1629 {
1630 tp->CMDqueue ^= OC_SET_FUNCT_ADDR;
1631 tp->scb.Parm[0] = LOWORD(tp->ocpl.FunctAddr);
1632 tp->scb.Parm[1] = HIWORD(tp->ocpl.FunctAddr);
1633 tp->scb.CMD = SET_FUNCT_ADDR;
1634 }
1635 else
1636 {
1637 if(tp->CMDqueue & OC_SET_GROUP_ADDR)
1638 {
1639 tp->CMDqueue ^= OC_SET_GROUP_ADDR;
1640 tp->scb.Parm[0] = LOWORD(tp->ocpl.GroupAddr);
1641 tp->scb.Parm[1] = HIWORD(tp->ocpl.GroupAddr);
1642 tp->scb.CMD = SET_GROUP_ADDR;
1643 }
1644 else
1645 {
1646 if(tp->CMDqueue & OC_READ_ERROR_LOG)
1647 {
1648 tp->CMDqueue ^= OC_READ_ERROR_LOG;
1649 Addr = htonl(((char *)&tp->errorlogtable - (char *)tp) + tp->dmabuffer);
1650 tp->scb.Parm[0] = LOWORD(Addr);
1651 tp->scb.Parm[1] = HIWORD(Addr);
1652 tp->scb.CMD = READ_ERROR_LOG;
1653 }
1654 else
1655 {
1656 printk(KERN_WARNING "CheckForOutstandingCommand: unknown Command\n");
1657 tp->CMDqueue = 0;
1658 return;
1659 }
1660 }
1661 }
1662 }
1663 }
1664 } 1583 }
1584 tp->TransmitCommandActive = 0;
1585 return;
1665 } 1586 }
1587
1588 tp->CMDqueue ^= OC_TRANSMIT;
1589 tms380tr_cancel_tx_queue(tp);
1590 Addr = htonl(((char *)tp->TplBusy - (char *)tp) + tp->dmabuffer);
1591 tp->scb.Parm[0] = LOWORD(Addr);
1592 tp->scb.Parm[1] = HIWORD(Addr);
1593 tp->scb.CMD = TRANSMIT;
1594 tp->TransmitCommandActive = 1;
1595 } else if (tp->CMDqueue & OC_MODIFY_OPEN_PARMS) {
1596 tp->CMDqueue ^= OC_MODIFY_OPEN_PARMS;
1597 tp->scb.Parm[0] = tp->ocpl.OPENOptions; /* new OPEN options*/
1598 tp->scb.Parm[0] |= ENABLE_FULL_DUPLEX_SELECTION;
1599 tp->scb.Parm[1] = 0; /* is ignored but should be zero */
1600 tp->scb.CMD = MODIFY_OPEN_PARMS;
1601 } else if (tp->CMDqueue & OC_SET_FUNCT_ADDR) {
1602 tp->CMDqueue ^= OC_SET_FUNCT_ADDR;
1603 tp->scb.Parm[0] = LOWORD(tp->ocpl.FunctAddr);
1604 tp->scb.Parm[1] = HIWORD(tp->ocpl.FunctAddr);
1605 tp->scb.CMD = SET_FUNCT_ADDR;
1606 } else if (tp->CMDqueue & OC_SET_GROUP_ADDR) {
1607 tp->CMDqueue ^= OC_SET_GROUP_ADDR;
1608 tp->scb.Parm[0] = LOWORD(tp->ocpl.GroupAddr);
1609 tp->scb.Parm[1] = HIWORD(tp->ocpl.GroupAddr);
1610 tp->scb.CMD = SET_GROUP_ADDR;
1611 } else if (tp->CMDqueue & OC_READ_ERROR_LOG) {
1612 tp->CMDqueue ^= OC_READ_ERROR_LOG;
1613 Addr = htonl(((char *)&tp->errorlogtable - (char *)tp) + tp->dmabuffer);
1614 tp->scb.Parm[0] = LOWORD(Addr);
1615 tp->scb.Parm[1] = HIWORD(Addr);
1616 tp->scb.CMD = READ_ERROR_LOG;
1617 } else {
1618 printk(KERN_WARNING "CheckForOutstandingCommand: unknown Command\n");
1619 tp->CMDqueue = 0;
1620 return;
1666 } 1621 }
1667 } 1622 }
1668 1623
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index 233576127934..4bad899fb38f 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -398,6 +398,27 @@ config USB_NET_KALMIA
398 To compile this driver as a module, choose M here: the 398 To compile this driver as a module, choose M here: the
399 module will be called kalmia. 399 module will be called kalmia.
400 400
401config USB_NET_QMI_WWAN
402 tristate "QMI WWAN driver for Qualcomm MSM based 3G and LTE modems"
403 depends on USB_USBNET
404 help
405 Support WWAN LTE/3G devices based on Qualcomm Mobile Data Modem
406 (MDM) chipsets. Examples of such devices are
407 * Huawei E392/E398
408
409 This driver will only drive the ethernet part of the chips.
410 The devices require additional configuration to be usable.
411 Multiple management interfaces with linux drivers are
412 available:
413
414 * option: AT commands on /dev/ttyUSBx
415 * cdc-wdm: Qualcomm MSM Interface (QMI) protocol on /dev/cdc-wdmx
416
417 A modem manager with support for QMI is recommended.
418
419 To compile this driver as a module, choose M here: the
420 module will be called qmi_wwan.
421
401config USB_HSO 422config USB_HSO
402 tristate "Option USB High Speed Mobile Devices" 423 tristate "Option USB High Speed Mobile Devices"
403 depends on USB && RFKILL 424 depends on USB && RFKILL
@@ -461,4 +482,5 @@ config USB_VL600
461 482
462 http://ubuntuforums.org/showpost.php?p=10589647&postcount=17 483 http://ubuntuforums.org/showpost.php?p=10589647&postcount=17
463 484
485
464endmenu 486endmenu
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index c203fa21f6b1..a2e2d72c52a0 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -29,4 +29,5 @@ obj-$(CONFIG_USB_SIERRA_NET) += sierra_net.o
29obj-$(CONFIG_USB_NET_CX82310_ETH) += cx82310_eth.o 29obj-$(CONFIG_USB_NET_CX82310_ETH) += cx82310_eth.o
30obj-$(CONFIG_USB_NET_CDC_NCM) += cdc_ncm.o 30obj-$(CONFIG_USB_NET_CDC_NCM) += cdc_ncm.o
31obj-$(CONFIG_USB_VL600) += lg-vl600.o 31obj-$(CONFIG_USB_VL600) += lg-vl600.o
32obj-$(CONFIG_USB_NET_QMI_WWAN) += qmi_wwan.o
32 33
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
index 5d99b8cacd7d..752393092325 100644
--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -1332,10 +1332,8 @@ static int pegasus_probe(struct usb_interface *intf,
1332 usb_get_dev(dev); 1332 usb_get_dev(dev);
1333 1333
1334 net = alloc_etherdev(sizeof(struct pegasus)); 1334 net = alloc_etherdev(sizeof(struct pegasus));
1335 if (!net) { 1335 if (!net)
1336 dev_err(&intf->dev, "can't allocate %s\n", "device");
1337 goto out; 1336 goto out;
1338 }
1339 1337
1340 pegasus = netdev_priv(net); 1338 pegasus = netdev_priv(net);
1341 pegasus->dev_index = dev_index; 1339 pegasus->dev_index = dev_index;
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
new file mode 100644
index 000000000000..739e6de7abcb
--- /dev/null
+++ b/drivers/net/usb/qmi_wwan.c
@@ -0,0 +1,228 @@
1/*
2 * Copyright (c) 2012 Bjørn Mork <bjorn@mork.no>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * version 2 as published by the Free Software Foundation.
7 */
8
9#include <linux/module.h>
10#include <linux/netdevice.h>
11#include <linux/ethtool.h>
12#include <linux/mii.h>
13#include <linux/usb.h>
14#include <linux/usb/cdc.h>
15#include <linux/usb/usbnet.h>
16
17/* The name of the CDC Device Management driver */
18#define DM_DRIVER "cdc_wdm"
19
20/*
21 * This driver supports wwan (3G/LTE/?) devices using a vendor
22 * specific management protocol called Qualcomm MSM Interface (QMI) -
23 * in addition to the more common AT commands over serial interface
24 * management
25 *
26 * QMI is wrapped in CDC, using CDC encapsulated commands on the
27 * control ("master") interface of a two-interface CDC Union
28 * resembling standard CDC ECM. The devices do not use the control
29 * interface for any other CDC messages. Most likely because the
30 * management protocol is used in place of the standard CDC
31 * notifications NOTIFY_NETWORK_CONNECTION and NOTIFY_SPEED_CHANGE
32 *
33 * Handling a protocol like QMI is out of the scope for any driver.
34 * It can be exported as a character device using the cdc-wdm driver,
35 * which will enable userspace applications ("modem managers") to
36 * handle it. This may be required to use the network interface
37 * provided by the driver.
38 *
39 * These devices may alternatively/additionally be configured using AT
40 * commands on any of the serial interfaces driven by the option driver
41 *
42 * This driver binds only to the data ("slave") interface to enable
43 * the cdc-wdm driver to bind to the control interface. It still
44 * parses the CDC functional descriptors on the control interface to
45 * a) verify that this is indeed a handled interface (CDC Union
46 * header lists it as slave)
47 * b) get MAC address and other ethernet config from the CDC Ethernet
48 * header
49 * c) enable user bind requests against the control interface, which
50 * is the common way to bind to CDC Ethernet Control Model type
51 * interfaces
52 * d) provide a hint to the user about which interface is the
53 * corresponding management interface
54 */
55
56static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
57{
58 int status = -1;
59 struct usb_interface *control = NULL;
60 u8 *buf = intf->cur_altsetting->extra;
61 int len = intf->cur_altsetting->extralen;
62 struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
63 struct usb_cdc_union_desc *cdc_union = NULL;
64 struct usb_cdc_ether_desc *cdc_ether = NULL;
65 u32 required = 1 << USB_CDC_HEADER_TYPE | 1 << USB_CDC_UNION_TYPE;
66 u32 found = 0;
67
68 /*
69 * assume a data interface has no additional descriptors and
70 * that the control and data interface are numbered
71 * consecutively - this holds for the Huawei device at least
72 */
73 if (len == 0 && desc->bInterfaceNumber > 0) {
74 control = usb_ifnum_to_if(dev->udev, desc->bInterfaceNumber - 1);
75 if (!control)
76 goto err;
77
78 buf = control->cur_altsetting->extra;
79 len = control->cur_altsetting->extralen;
80 dev_dbg(&intf->dev, "guessing \"control\" => %s, \"data\" => this\n",
81 dev_name(&control->dev));
82 }
83
84 while (len > 3) {
85 struct usb_descriptor_header *h = (void *)buf;
86
87 /* ignore any misplaced descriptors */
88 if (h->bDescriptorType != USB_DT_CS_INTERFACE)
89 goto next_desc;
90
91 /* buf[2] is CDC descriptor subtype */
92 switch (buf[2]) {
93 case USB_CDC_HEADER_TYPE:
94 if (found & 1 << USB_CDC_HEADER_TYPE) {
95 dev_dbg(&intf->dev, "extra CDC header\n");
96 goto err;
97 }
98 if (h->bLength != sizeof(struct usb_cdc_header_desc)) {
99 dev_dbg(&intf->dev, "CDC header len %u\n", h->bLength);
100 goto err;
101 }
102 break;
103 case USB_CDC_UNION_TYPE:
104 if (found & 1 << USB_CDC_UNION_TYPE) {
105 dev_dbg(&intf->dev, "extra CDC union\n");
106 goto err;
107 }
108 if (h->bLength != sizeof(struct usb_cdc_union_desc)) {
109 dev_dbg(&intf->dev, "CDC union len %u\n", h->bLength);
110 goto err;
111 }
112 cdc_union = (struct usb_cdc_union_desc *)buf;
113 break;
114 case USB_CDC_ETHERNET_TYPE:
115 if (found & 1 << USB_CDC_ETHERNET_TYPE) {
116 dev_dbg(&intf->dev, "extra CDC ether\n");
117 goto err;
118 }
119 if (h->bLength != sizeof(struct usb_cdc_ether_desc)) {
120 dev_dbg(&intf->dev, "CDC ether len %u\n", h->bLength);
121 goto err;
122 }
123 cdc_ether = (struct usb_cdc_ether_desc *)buf;
124 break;
125 }
126
127 /*
128 * Remember which CDC functional descriptors we've seen. Works
129 * for all types we care about, of which USB_CDC_ETHERNET_TYPE
130 * (0x0f) is the highest numbered
131 */
132 if (buf[2] < 32)
133 found |= 1 << buf[2];
134
135next_desc:
136 len -= h->bLength;
137 buf += h->bLength;
138 }
139
140 /* did we find all the required ones? */
141 if ((found & required) != required) {
142 dev_err(&intf->dev, "CDC functional descriptors missing\n");
143 goto err;
144 }
145
146 /* give the user a helpful hint if trying to bind to the wrong interface */
147 if (cdc_union && desc->bInterfaceNumber == cdc_union->bMasterInterface0) {
148 dev_err(&intf->dev, "leaving \"control\" interface for " DM_DRIVER " - try binding to %s instead!\n",
149 dev_name(&usb_ifnum_to_if(dev->udev, cdc_union->bSlaveInterface0)->dev));
150 goto err;
151 }
152
153 /* errors aren't fatal - we can live with the dynamic address */
154 if (cdc_ether) {
155 dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
156 usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
157 }
158
159 /* success! point the user to the management interface */
160 if (control)
161 dev_info(&intf->dev, "Use \"" DM_DRIVER "\" for QMI interface %s\n",
162 dev_name(&control->dev));
163
164 /* XXX: add a sysfs symlink somewhere to help management applications find it? */
165
166 /* collect bulk endpoints now that we know intf == "data" interface */
167 status = usbnet_get_endpoints(dev, intf);
168
169err:
170 return status;
171}
172
173/* stolen from cdc_ether.c */
174static int qmi_wwan_manage_power(struct usbnet *dev, int on)
175{
176 dev->intf->needs_remote_wakeup = on;
177 return 0;
178}
179
180static const struct driver_info qmi_wwan_info = {
181 .description = "QMI speaking wwan device",
182 .flags = FLAG_WWAN,
183 .bind = qmi_wwan_bind,
184 .manage_power = qmi_wwan_manage_power,
185};
186
187#define HUAWEI_VENDOR_ID 0x12D1
188
189static const struct usb_device_id products[] = {
190{
191 /* Huawei E392, E398 and possibly others sharing both device id and more... */
192 .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO,
193 .idVendor = HUAWEI_VENDOR_ID,
194 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
195 .bInterfaceSubClass = 1,
196 .bInterfaceProtocol = 8, /* NOTE: This is the *slave* interface of the CDC Union! */
197 .driver_info = (unsigned long)&qmi_wwan_info,
198}, {
199}, /* END */
200};
201MODULE_DEVICE_TABLE(usb, products);
202
203static struct usb_driver qmi_wwan_driver = {
204 .name = "qmi_wwan",
205 .id_table = products,
206 .probe = usbnet_probe,
207 .disconnect = usbnet_disconnect,
208 .suspend = usbnet_suspend,
209 .resume = usbnet_resume,
210 .reset_resume = usbnet_resume,
211 .supports_autosuspend = 1,
212};
213
214static int __init qmi_wwan_init(void)
215{
216 return usb_register(&qmi_wwan_driver);
217}
218module_init(qmi_wwan_init);
219
220static void __exit qmi_wwan_exit(void)
221{
222 usb_deregister(&qmi_wwan_driver);
223}
224module_exit(qmi_wwan_exit);
225
226MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
227MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
228MODULE_LICENSE("GPL");
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index 0710b4ca9252..6dda2fe5b15b 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -894,10 +894,8 @@ static int rtl8150_probe(struct usb_interface *intf,
894 struct net_device *netdev; 894 struct net_device *netdev;
895 895
896 netdev = alloc_etherdev(sizeof(rtl8150_t)); 896 netdev = alloc_etherdev(sizeof(rtl8150_t));
897 if (!netdev) { 897 if (!netdev)
898 err("Out of memory");
899 return -ENOMEM; 898 return -ENOMEM;
900 }
901 899
902 dev = netdev_priv(netdev); 900 dev = netdev_priv(netdev);
903 901
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index fae0fbd8bc88..b924f46c963c 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1334,10 +1334,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1334 1334
1335 // set up our own records 1335 // set up our own records
1336 net = alloc_etherdev(sizeof(*dev)); 1336 net = alloc_etherdev(sizeof(*dev));
1337 if (!net) { 1337 if (!net)
1338 dbg ("can't kmalloc dev");
1339 goto out; 1338 goto out;
1340 }
1341 1339
1342 /* netdev_printk() needs this so do it as early as possible */ 1340 /* netdev_printk() needs this so do it as early as possible */
1343 SET_NETDEV_DEV(net, &udev->dev); 1341 SET_NETDEV_DEV(net, &udev->dev);
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index de7fc345148a..e1562e8acba5 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -537,11 +537,8 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
537 537
538 tq->buf_info = kcalloc(tq->tx_ring.size, sizeof(tq->buf_info[0]), 538 tq->buf_info = kcalloc(tq->tx_ring.size, sizeof(tq->buf_info[0]),
539 GFP_KERNEL); 539 GFP_KERNEL);
540 if (!tq->buf_info) { 540 if (!tq->buf_info)
541 printk(KERN_ERR "%s: failed to allocate tx bufinfo\n",
542 adapter->netdev->name);
543 goto err; 541 goto err;
544 }
545 542
546 return 0; 543 return 0;
547 544
@@ -636,7 +633,7 @@ vmxnet3_rq_alloc_rx_buf(struct vmxnet3_rx_queue *rq, u32 ring_idx,
636 633
637 dev_dbg(&adapter->netdev->dev, 634 dev_dbg(&adapter->netdev->dev,
638 "alloc_rx_buf: %d allocated, next2fill %u, next2comp " 635 "alloc_rx_buf: %d allocated, next2fill %u, next2comp "
639 "%u, uncommited %u\n", num_allocated, ring->next2fill, 636 "%u, uncommitted %u\n", num_allocated, ring->next2fill,
640 ring->next2comp, rq->uncommitted[ring_idx]); 637 ring->next2comp, rq->uncommitted[ring_idx]);
641 638
642 /* so that the device can distinguish a full ring and an empty ring */ 639 /* so that the device can distinguish a full ring and an empty ring */
@@ -816,27 +813,24 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
816 813
817 if (ctx->mss) { /* TSO */ 814 if (ctx->mss) { /* TSO */
818 ctx->eth_ip_hdr_size = skb_transport_offset(skb); 815 ctx->eth_ip_hdr_size = skb_transport_offset(skb);
819 ctx->l4_hdr_size = ((struct tcphdr *) 816 ctx->l4_hdr_size = tcp_hdrlen(skb);
820 skb_transport_header(skb))->doff * 4;
821 ctx->copy_size = ctx->eth_ip_hdr_size + ctx->l4_hdr_size; 817 ctx->copy_size = ctx->eth_ip_hdr_size + ctx->l4_hdr_size;
822 } else { 818 } else {
823 if (skb->ip_summed == CHECKSUM_PARTIAL) { 819 if (skb->ip_summed == CHECKSUM_PARTIAL) {
824 ctx->eth_ip_hdr_size = skb_checksum_start_offset(skb); 820 ctx->eth_ip_hdr_size = skb_checksum_start_offset(skb);
825 821
826 if (ctx->ipv4) { 822 if (ctx->ipv4) {
827 struct iphdr *iph = (struct iphdr *) 823 const struct iphdr *iph = ip_hdr(skb);
828 skb_network_header(skb); 824
829 if (iph->protocol == IPPROTO_TCP) 825 if (iph->protocol == IPPROTO_TCP)
830 ctx->l4_hdr_size = ((struct tcphdr *) 826 ctx->l4_hdr_size = tcp_hdrlen(skb);
831 skb_transport_header(skb))->doff * 4;
832 else if (iph->protocol == IPPROTO_UDP) 827 else if (iph->protocol == IPPROTO_UDP)
833 /* 828 /*
834 * Use tcp header size so that bytes to 829 * Use tcp header size so that bytes to
835 * be copied are more than required by 830 * be copied are more than required by
836 * the device. 831 * the device.
837 */ 832 */
838 ctx->l4_hdr_size = 833 ctx->l4_hdr_size = sizeof(struct tcphdr);
839 sizeof(struct tcphdr);
840 else 834 else
841 ctx->l4_hdr_size = 0; 835 ctx->l4_hdr_size = 0;
842 } else { 836 } else {
@@ -881,14 +875,17 @@ static void
881vmxnet3_prepare_tso(struct sk_buff *skb, 875vmxnet3_prepare_tso(struct sk_buff *skb,
882 struct vmxnet3_tx_ctx *ctx) 876 struct vmxnet3_tx_ctx *ctx)
883{ 877{
884 struct tcphdr *tcph = (struct tcphdr *)skb_transport_header(skb); 878 struct tcphdr *tcph = tcp_hdr(skb);
879
885 if (ctx->ipv4) { 880 if (ctx->ipv4) {
886 struct iphdr *iph = (struct iphdr *)skb_network_header(skb); 881 struct iphdr *iph = ip_hdr(skb);
882
887 iph->check = 0; 883 iph->check = 0;
888 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0, 884 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0,
889 IPPROTO_TCP, 0); 885 IPPROTO_TCP, 0);
890 } else { 886 } else {
891 struct ipv6hdr *iph = (struct ipv6hdr *)skb_network_header(skb); 887 struct ipv6hdr *iph = ipv6_hdr(skb);
888
892 tcph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, 0, 889 tcph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, 0,
893 IPPROTO_TCP, 0); 890 IPPROTO_TCP, 0);
894 } 891 }
@@ -1519,11 +1516,9 @@ vmxnet3_rq_create(struct vmxnet3_rx_queue *rq, struct vmxnet3_adapter *adapter)
1519 sz = sizeof(struct vmxnet3_rx_buf_info) * (rq->rx_ring[0].size + 1516 sz = sizeof(struct vmxnet3_rx_buf_info) * (rq->rx_ring[0].size +
1520 rq->rx_ring[1].size); 1517 rq->rx_ring[1].size);
1521 bi = kzalloc(sz, GFP_KERNEL); 1518 bi = kzalloc(sz, GFP_KERNEL);
1522 if (!bi) { 1519 if (!bi)
1523 printk(KERN_ERR "%s: failed to allocate rx bufinfo\n",
1524 adapter->netdev->name);
1525 goto err; 1520 goto err;
1526 } 1521
1527 rq->buf_info[0] = bi; 1522 rq->buf_info[0] = bi;
1528 rq->buf_info[1] = bi + rq->rx_ring[0].size; 1523 rq->buf_info[1] = bi + rq->rx_ring[0].size;
1529 1524
@@ -2923,11 +2918,8 @@ vmxnet3_probe_device(struct pci_dev *pdev,
2923 printk(KERN_INFO "# of Tx queues : %d, # of Rx queues : %d\n", 2918 printk(KERN_INFO "# of Tx queues : %d, # of Rx queues : %d\n",
2924 num_tx_queues, num_rx_queues); 2919 num_tx_queues, num_rx_queues);
2925 2920
2926 if (!netdev) { 2921 if (!netdev)
2927 printk(KERN_ERR "Failed to alloc ethernet device for adapter "
2928 "%s\n", pci_name(pdev));
2929 return -ENOMEM; 2922 return -ENOMEM;
2930 }
2931 2923
2932 pci_set_drvdata(pdev, netdev); 2924 pci_set_drvdata(pdev, netdev);
2933 adapter = netdev_priv(netdev); 2925 adapter = netdev_priv(netdev);
@@ -2964,8 +2956,6 @@ vmxnet3_probe_device(struct pci_dev *pdev,
2964 2956
2965 adapter->pm_conf = kmalloc(sizeof(struct Vmxnet3_PMConf), GFP_KERNEL); 2957 adapter->pm_conf = kmalloc(sizeof(struct Vmxnet3_PMConf), GFP_KERNEL);
2966 if (adapter->pm_conf == NULL) { 2958 if (adapter->pm_conf == NULL) {
2967 printk(KERN_ERR "Failed to allocate memory for %s\n",
2968 pci_name(pdev));
2969 err = -ENOMEM; 2959 err = -ENOMEM;
2970 goto err_alloc_pm; 2960 goto err_alloc_pm;
2971 } 2961 }
@@ -2974,8 +2964,6 @@ vmxnet3_probe_device(struct pci_dev *pdev,
2974 2964
2975 adapter->rss_conf = kmalloc(sizeof(struct UPT1_RSSConf), GFP_KERNEL); 2965 adapter->rss_conf = kmalloc(sizeof(struct UPT1_RSSConf), GFP_KERNEL);
2976 if (adapter->rss_conf == NULL) { 2966 if (adapter->rss_conf == NULL) {
2977 printk(KERN_ERR "Failed to allocate memory for %s\n",
2978 pci_name(pdev));
2979 err = -ENOMEM; 2967 err = -ENOMEM;
2980 goto err_alloc_rss; 2968 goto err_alloc_rss;
2981 } 2969 }
diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c
index 54f995f4a5a3..09a50751763b 100644
--- a/drivers/net/wan/c101.c
+++ b/drivers/net/wan/c101.c
@@ -325,10 +325,8 @@ static int __init c101_run(unsigned long irq, unsigned long winbase)
325 } 325 }
326 326
327 card = kzalloc(sizeof(card_t), GFP_KERNEL); 327 card = kzalloc(sizeof(card_t), GFP_KERNEL);
328 if (card == NULL) { 328 if (card == NULL)
329 pr_err("unable to allocate memory\n");
330 return -ENOBUFS; 329 return -ENOBUFS;
331 }
332 330
333 card->dev = alloc_hdlcdev(card); 331 card->dev = alloc_hdlcdev(card);
334 if (!card->dev) { 332 if (!card->dev) {
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 058e1697c174..fe8d060d8fff 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -903,10 +903,8 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr)
903 int i, ret = -ENOMEM; 903 int i, ret = -ENOMEM;
904 904
905 root = kcalloc(dev_per_card, sizeof(*root), GFP_KERNEL); 905 root = kcalloc(dev_per_card, sizeof(*root), GFP_KERNEL);
906 if (!root) { 906 if (!root)
907 pr_err("can't allocate data\n");
908 goto err_out; 907 goto err_out;
909 }
910 908
911 for (i = 0; i < dev_per_card; i++) { 909 for (i = 0; i < dev_per_card; i++) {
912 root[i].dev = alloc_hdlcdev(root + i); 910 root[i].dev = alloc_hdlcdev(root + i);
@@ -915,10 +913,8 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr)
915 } 913 }
916 914
917 ppriv = kzalloc(sizeof(*ppriv), GFP_KERNEL); 915 ppriv = kzalloc(sizeof(*ppriv), GFP_KERNEL);
918 if (!ppriv) { 916 if (!ppriv)
919 pr_err("can't allocate private data\n");
920 goto err_free_dev; 917 goto err_free_dev;
921 }
922 918
923 ppriv->root = root; 919 ppriv->root = root;
924 spin_lock_init(&ppriv->lock); 920 spin_lock_init(&ppriv->lock);
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index b7f2358d23be..76a8a4a522e9 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -497,7 +497,6 @@ int lmc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/
497 497
498 data = kmalloc(xc.len, GFP_KERNEL); 498 data = kmalloc(xc.len, GFP_KERNEL);
499 if (!data) { 499 if (!data) {
500 printk(KERN_WARNING "%s: Failed to allocate memory for copy\n", dev->name);
501 ret = -ENOMEM; 500 ret = -ENOMEM;
502 break; 501 break;
503 } 502 }
diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c
index 5129ad514d26..315bf09d6a20 100644
--- a/drivers/net/wan/n2.c
+++ b/drivers/net/wan/n2.c
@@ -358,10 +358,8 @@ static int __init n2_run(unsigned long io, unsigned long irq,
358 } 358 }
359 359
360 card = kzalloc(sizeof(card_t), GFP_KERNEL); 360 card = kzalloc(sizeof(card_t), GFP_KERNEL);
361 if (card == NULL) { 361 if (card == NULL)
362 pr_err("unable to allocate memory\n");
363 return -ENOBUFS; 362 return -ENOBUFS;
364 }
365 363
366 card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); 364 card->ports[0].dev = alloc_hdlcdev(&card->ports[0]);
367 card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); 365 card->ports[1].dev = alloc_hdlcdev(&card->ports[1]);
diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c
index c49c1b3c7aad..5fe246e060d7 100644
--- a/drivers/net/wan/pc300too.c
+++ b/drivers/net/wan/pc300too.c
@@ -320,7 +320,6 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev,
320 320
321 card = kzalloc(sizeof(card_t), GFP_KERNEL); 321 card = kzalloc(sizeof(card_t), GFP_KERNEL);
322 if (card == NULL) { 322 if (card == NULL) {
323 pr_err("unable to allocate memory\n");
324 pci_release_regions(pdev); 323 pci_release_regions(pdev);
325 pci_disable_device(pdev); 324 pci_disable_device(pdev);
326 return -ENOBUFS; 325 return -ENOBUFS;
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c
index 1ce21163c776..9659fcaa34ed 100644
--- a/drivers/net/wan/pci200syn.c
+++ b/drivers/net/wan/pci200syn.c
@@ -299,7 +299,6 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
299 299
300 card = kzalloc(sizeof(card_t), GFP_KERNEL); 300 card = kzalloc(sizeof(card_t), GFP_KERNEL);
301 if (card == NULL) { 301 if (card == NULL) {
302 pr_err("unable to allocate memory\n");
303 pci_release_regions(pdev); 302 pci_release_regions(pdev);
304 pci_disable_device(pdev); 303 pci_disable_device(pdev);
305 return -ENOBUFS; 304 return -ENOBUFS;
diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
index 44b707197258..feb7541b33fb 100644
--- a/drivers/net/wan/wanxl.c
+++ b/drivers/net/wan/wanxl.c
@@ -604,7 +604,6 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev,
604 alloc_size = sizeof(card_t) + ports * sizeof(port_t); 604 alloc_size = sizeof(card_t) + ports * sizeof(port_t);
605 card = kzalloc(alloc_size, GFP_KERNEL); 605 card = kzalloc(alloc_size, GFP_KERNEL);
606 if (card == NULL) { 606 if (card == NULL) {
607 pr_err("%s: unable to allocate memory\n", pci_name(pdev));
608 pci_release_regions(pdev); 607 pci_release_regions(pdev);
609 pci_disable_device(pdev); 608 pci_disable_device(pdev);
610 return -ENOBUFS; 609 return -ENOBUFS;
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 8a10bb730d5a..e862369b4a6d 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -786,10 +786,8 @@ static int __init init_x25_asy(void)
786 786
787 x25_asy_devs = kcalloc(x25_asy_maxdev, sizeof(struct net_device *), 787 x25_asy_devs = kcalloc(x25_asy_maxdev, sizeof(struct net_device *),
788 GFP_KERNEL); 788 GFP_KERNEL);
789 if (!x25_asy_devs) { 789 if (!x25_asy_devs)
790 pr_warn("Can't allocate x25_asy_ctrls[] array! Uaargh! (-> No X.25 available)\n");
791 return -ENOMEM; 790 return -ENOMEM;
792 }
793 791
794 return tty_register_ldisc(N_X25, &x25_ldisc); 792 return tty_register_ldisc(N_X25, &x25_ldisc);
795} 793}
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index d366dadcf86e..a339693fbe26 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -80,7 +80,7 @@ static bool modparam_fastchanswitch;
80module_param_named(fastchanswitch, modparam_fastchanswitch, bool, S_IRUGO); 80module_param_named(fastchanswitch, modparam_fastchanswitch, bool, S_IRUGO);
81MODULE_PARM_DESC(fastchanswitch, "Enable fast channel switching for AR2413/AR5413 radios."); 81MODULE_PARM_DESC(fastchanswitch, "Enable fast channel switching for AR2413/AR5413 radios.");
82 82
83static int ath5k_modparam_no_hw_rfkill_switch; 83static bool ath5k_modparam_no_hw_rfkill_switch;
84module_param_named(no_hw_rfkill_switch, ath5k_modparam_no_hw_rfkill_switch, 84module_param_named(no_hw_rfkill_switch, ath5k_modparam_no_hw_rfkill_switch,
85 bool, S_IRUGO); 85 bool, S_IRUGO);
86MODULE_PARM_DESC(no_hw_rfkill_switch, "Ignore the GPIO RFKill switch state"); 86MODULE_PARM_DESC(no_hw_rfkill_switch, "Ignore the GPIO RFKill switch state");
@@ -2442,6 +2442,9 @@ ath5k_init_ah(struct ath5k_hw *ah, const struct ath_bus_ops *bus_ops)
2442 BIT(NL80211_IFTYPE_ADHOC) | 2442 BIT(NL80211_IFTYPE_ADHOC) |
2443 BIT(NL80211_IFTYPE_MESH_POINT); 2443 BIT(NL80211_IFTYPE_MESH_POINT);
2444 2444
2445 /* SW support for IBSS_RSN is provided by mac80211 */
2446 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
2447
2445 /* both antennas can be configured as RX or TX */ 2448 /* both antennas can be configured as RX or TX */
2446 hw->wiphy->available_antennas_tx = 0x3; 2449 hw->wiphy->available_antennas_tx = 0x3;
2447 hw->wiphy->available_antennas_rx = 0x3; 2450 hw->wiphy->available_antennas_rx = 0x3;
diff --git a/drivers/net/wireless/ath/ath5k/mac80211-ops.c b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
index 6ed4c0717e3e..af4c7ecb4b30 100644
--- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
+++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
@@ -483,6 +483,14 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
483 if (ath5k_modparam_nohwcrypt) 483 if (ath5k_modparam_nohwcrypt)
484 return -EOPNOTSUPP; 484 return -EOPNOTSUPP;
485 485
486 if (vif->type == NL80211_IFTYPE_ADHOC &&
487 (key->cipher == WLAN_CIPHER_SUITE_TKIP ||
488 key->cipher == WLAN_CIPHER_SUITE_CCMP) &&
489 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
490 /* don't program group keys when using IBSS_RSN */
491 return -EOPNOTSUPP;
492 }
493
486 switch (key->cipher) { 494 switch (key->cipher) {
487 case WLAN_CIPHER_SUITE_WEP40: 495 case WLAN_CIPHER_SUITE_WEP40:
488 case WLAN_CIPHER_SUITE_WEP104: 496 case WLAN_CIPHER_SUITE_WEP104:
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 77c8ded8de57..f317515d8bf3 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -968,8 +968,7 @@ static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev)
968 ath9k_hif_usb_dealloc_rx_urbs(hif_dev); 968 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
969} 969}
970 970
971static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev, 971static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
972 u32 drv_info)
973{ 972{
974 int transfer, err; 973 int transfer, err;
975 const void *data = hif_dev->firmware->data; 974 const void *data = hif_dev->firmware->data;
@@ -1000,7 +999,7 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev,
1000 } 999 }
1001 kfree(buf); 1000 kfree(buf);
1002 1001
1003 if (IS_AR7010_DEVICE(drv_info)) 1002 if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
1004 firm_offset = AR7010_FIRMWARE_TEXT; 1003 firm_offset = AR7010_FIRMWARE_TEXT;
1005 else 1004 else
1006 firm_offset = AR9271_FIRMWARE_TEXT; 1005 firm_offset = AR9271_FIRMWARE_TEXT;
@@ -1021,28 +1020,18 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev,
1021 return 0; 1020 return 0;
1022} 1021}
1023 1022
1024static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev, u32 drv_info) 1023static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev)
1025{ 1024{
1026 int ret, idx;
1027 struct usb_host_interface *alt = &hif_dev->interface->altsetting[0]; 1025 struct usb_host_interface *alt = &hif_dev->interface->altsetting[0];
1028 struct usb_endpoint_descriptor *endp; 1026 struct usb_endpoint_descriptor *endp;
1027 int ret, idx;
1029 1028
1030 /* Request firmware */ 1029 ret = ath9k_hif_usb_download_fw(hif_dev);
1031 ret = request_firmware(&hif_dev->firmware, hif_dev->fw_name,
1032 &hif_dev->udev->dev);
1033 if (ret) {
1034 dev_err(&hif_dev->udev->dev,
1035 "ath9k_htc: Firmware - %s not found\n", hif_dev->fw_name);
1036 goto err_fw_req;
1037 }
1038
1039 /* Download firmware */
1040 ret = ath9k_hif_usb_download_fw(hif_dev, drv_info);
1041 if (ret) { 1030 if (ret) {
1042 dev_err(&hif_dev->udev->dev, 1031 dev_err(&hif_dev->udev->dev,
1043 "ath9k_htc: Firmware - %s download failed\n", 1032 "ath9k_htc: Firmware - %s download failed\n",
1044 hif_dev->fw_name); 1033 hif_dev->fw_name);
1045 goto err_fw_download; 1034 return ret;
1046 } 1035 }
1047 1036
1048 /* On downloading the firmware to the target, the USB descriptor of EP4 1037 /* On downloading the firmware to the target, the USB descriptor of EP4
@@ -1064,23 +1053,84 @@ static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev, u32 drv_info)
1064 if (ret) { 1053 if (ret) {
1065 dev_err(&hif_dev->udev->dev, 1054 dev_err(&hif_dev->udev->dev,
1066 "ath9k_htc: Unable to allocate URBs\n"); 1055 "ath9k_htc: Unable to allocate URBs\n");
1067 goto err_fw_download; 1056 return ret;
1068 } 1057 }
1069 1058
1070 return 0; 1059 return 0;
1071
1072err_fw_download:
1073 release_firmware(hif_dev->firmware);
1074err_fw_req:
1075 hif_dev->firmware = NULL;
1076 return ret;
1077} 1060}
1078 1061
1079static void ath9k_hif_usb_dev_deinit(struct hif_device_usb *hif_dev) 1062static void ath9k_hif_usb_dev_deinit(struct hif_device_usb *hif_dev)
1080{ 1063{
1081 ath9k_hif_usb_dealloc_urbs(hif_dev); 1064 ath9k_hif_usb_dealloc_urbs(hif_dev);
1082 if (hif_dev->firmware) 1065}
1083 release_firmware(hif_dev->firmware); 1066
1067/*
1068 * If initialization fails or the FW cannot be retrieved,
1069 * detach the device.
1070 */
1071static void ath9k_hif_usb_firmware_fail(struct hif_device_usb *hif_dev)
1072{
1073 struct device *parent = hif_dev->udev->dev.parent;
1074
1075 complete(&hif_dev->fw_done);
1076
1077 if (parent)
1078 device_lock(parent);
1079
1080 device_release_driver(&hif_dev->udev->dev);
1081
1082 if (parent)
1083 device_unlock(parent);
1084}
1085
1086static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context)
1087{
1088 struct hif_device_usb *hif_dev = context;
1089 int ret;
1090
1091 if (!fw) {
1092 dev_err(&hif_dev->udev->dev,
1093 "ath9k_htc: Failed to get firmware %s\n",
1094 hif_dev->fw_name);
1095 goto err_fw;
1096 }
1097
1098 hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev, &hif_usb,
1099 &hif_dev->udev->dev);
1100 if (hif_dev->htc_handle == NULL) {
1101 goto err_fw;
1102 }
1103
1104 hif_dev->firmware = fw;
1105
1106 /* Proceed with initialization */
1107
1108 ret = ath9k_hif_usb_dev_init(hif_dev);
1109 if (ret)
1110 goto err_dev_init;
1111
1112 ret = ath9k_htc_hw_init(hif_dev->htc_handle,
1113 &hif_dev->interface->dev,
1114 hif_dev->usb_device_id->idProduct,
1115 hif_dev->udev->product,
1116 hif_dev->usb_device_id->driver_info);
1117 if (ret) {
1118 ret = -EINVAL;
1119 goto err_htc_hw_init;
1120 }
1121
1122 complete(&hif_dev->fw_done);
1123
1124 return;
1125
1126err_htc_hw_init:
1127 ath9k_hif_usb_dev_deinit(hif_dev);
1128err_dev_init:
1129 ath9k_htc_hw_free(hif_dev->htc_handle);
1130 release_firmware(fw);
1131 hif_dev->firmware = NULL;
1132err_fw:
1133 ath9k_hif_usb_firmware_fail(hif_dev);
1084} 1134}
1085 1135
1086/* 1136/*
@@ -1155,20 +1205,16 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
1155 } 1205 }
1156 1206
1157 usb_get_dev(udev); 1207 usb_get_dev(udev);
1208
1158 hif_dev->udev = udev; 1209 hif_dev->udev = udev;
1159 hif_dev->interface = interface; 1210 hif_dev->interface = interface;
1160 hif_dev->device_id = id->idProduct; 1211 hif_dev->usb_device_id = id;
1161#ifdef CONFIG_PM 1212#ifdef CONFIG_PM
1162 udev->reset_resume = 1; 1213 udev->reset_resume = 1;
1163#endif 1214#endif
1164 usb_set_intfdata(interface, hif_dev); 1215 usb_set_intfdata(interface, hif_dev);
1165 1216
1166 hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev, &hif_usb, 1217 init_completion(&hif_dev->fw_done);
1167 &hif_dev->udev->dev);
1168 if (hif_dev->htc_handle == NULL) {
1169 ret = -ENOMEM;
1170 goto err_htc_hw_alloc;
1171 }
1172 1218
1173 /* Find out which firmware to load */ 1219 /* Find out which firmware to load */
1174 1220
@@ -1177,29 +1223,22 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
1177 else 1223 else
1178 hif_dev->fw_name = FIRMWARE_AR9271; 1224 hif_dev->fw_name = FIRMWARE_AR9271;
1179 1225
1180 ret = ath9k_hif_usb_dev_init(hif_dev, id->driver_info); 1226 ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
1181 if (ret) { 1227 &hif_dev->udev->dev, GFP_KERNEL,
1182 ret = -EINVAL; 1228 hif_dev, ath9k_hif_usb_firmware_cb);
1183 goto err_hif_init_usb;
1184 }
1185
1186 ret = ath9k_htc_hw_init(hif_dev->htc_handle,
1187 &interface->dev, hif_dev->device_id,
1188 hif_dev->udev->product, id->driver_info);
1189 if (ret) { 1229 if (ret) {
1190 ret = -EINVAL; 1230 dev_err(&hif_dev->udev->dev,
1191 goto err_htc_hw_init; 1231 "ath9k_htc: Async request for firmware %s failed\n",
1232 hif_dev->fw_name);
1233 goto err_fw_req;
1192 } 1234 }
1193 1235
1194 dev_info(&hif_dev->udev->dev, "ath9k_htc: USB layer initialized\n"); 1236 dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
1237 hif_dev->fw_name);
1195 1238
1196 return 0; 1239 return 0;
1197 1240
1198err_htc_hw_init: 1241err_fw_req:
1199 ath9k_hif_usb_dev_deinit(hif_dev);
1200err_hif_init_usb:
1201 ath9k_htc_hw_free(hif_dev->htc_handle);
1202err_htc_hw_alloc:
1203 usb_set_intfdata(interface, NULL); 1242 usb_set_intfdata(interface, NULL);
1204 kfree(hif_dev); 1243 kfree(hif_dev);
1205 usb_put_dev(udev); 1244 usb_put_dev(udev);
@@ -1234,9 +1273,15 @@ static void ath9k_hif_usb_disconnect(struct usb_interface *interface)
1234 if (!hif_dev) 1273 if (!hif_dev)
1235 return; 1274 return;
1236 1275
1237 ath9k_htc_hw_deinit(hif_dev->htc_handle, unplugged); 1276 wait_for_completion(&hif_dev->fw_done);
1238 ath9k_htc_hw_free(hif_dev->htc_handle); 1277
1239 ath9k_hif_usb_dev_deinit(hif_dev); 1278 if (hif_dev->firmware) {
1279 ath9k_htc_hw_deinit(hif_dev->htc_handle, unplugged);
1280 ath9k_htc_hw_free(hif_dev->htc_handle);
1281 ath9k_hif_usb_dev_deinit(hif_dev);
1282 release_firmware(hif_dev->firmware);
1283 }
1284
1240 usb_set_intfdata(interface, NULL); 1285 usb_set_intfdata(interface, NULL);
1241 1286
1242 if (!unplugged && (hif_dev->flags & HIF_USB_START)) 1287 if (!unplugged && (hif_dev->flags & HIF_USB_START))
@@ -1276,8 +1321,7 @@ static int ath9k_hif_usb_resume(struct usb_interface *interface)
1276 return ret; 1321 return ret;
1277 1322
1278 if (hif_dev->firmware) { 1323 if (hif_dev->firmware) {
1279 ret = ath9k_hif_usb_download_fw(hif_dev, 1324 ret = ath9k_hif_usb_download_fw(hif_dev);
1280 htc_handle->drv_priv->ah->hw_version.usbdev);
1281 if (ret) 1325 if (ret)
1282 goto fail_resume; 1326 goto fail_resume;
1283 } else { 1327 } else {
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h
index 794f63094e5d..487ff658b4c1 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.h
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.h
@@ -87,10 +87,11 @@ struct cmd_buf {
87#define HIF_USB_START BIT(0) 87#define HIF_USB_START BIT(0)
88 88
89struct hif_device_usb { 89struct hif_device_usb {
90 u16 device_id;
91 struct usb_device *udev; 90 struct usb_device *udev;
92 struct usb_interface *interface; 91 struct usb_interface *interface;
92 const struct usb_device_id *usb_device_id;
93 const struct firmware *firmware; 93 const struct firmware *firmware;
94 struct completion fw_done;
94 struct htc_target *htc_handle; 95 struct htc_target *htc_handle;
95 struct hif_usb_tx tx; 96 struct hif_usb_tx tx;
96 struct usb_anchor regout_submitted; 97 struct usb_anchor regout_submitted;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 9be10a2da1c2..fc7519c93390 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -741,6 +741,8 @@ static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv,
741 741
742 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 742 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
743 743
744 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
745
744 hw->queues = 4; 746 hw->queues = 4;
745 hw->channel_change_time = 5000; 747 hw->channel_change_time = 5000;
746 hw->max_listen_interval = 10; 748 hw->max_listen_interval = 10;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index ef4c60661290..06101b6bdeac 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -1409,6 +1409,21 @@ static int ath9k_htc_set_key(struct ieee80211_hw *hw,
1409 if (htc_modparam_nohwcrypt) 1409 if (htc_modparam_nohwcrypt)
1410 return -ENOSPC; 1410 return -ENOSPC;
1411 1411
1412 if ((vif->type == NL80211_IFTYPE_ADHOC ||
1413 vif->type == NL80211_IFTYPE_MESH_POINT) &&
1414 (key->cipher == WLAN_CIPHER_SUITE_TKIP ||
1415 key->cipher == WLAN_CIPHER_SUITE_CCMP) &&
1416 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
1417 /*
1418 * For now, disable hw crypto for the RSN IBSS group keys. This
1419 * could be optimized in the future to use a modified key cache
1420 * design to support per-STA RX GTK, but until that gets
1421 * implemented, use of software crypto for group addressed
1422 * frames is a acceptable to allow RSN IBSS to be used.
1423 */
1424 return -EOPNOTSUPP;
1425 }
1426
1412 mutex_lock(&priv->mutex); 1427 mutex_lock(&priv->mutex);
1413 ath_dbg(common, CONFIG, "Set HW Key\n"); 1428 ath_dbg(common, CONFIG, "Set HW Key\n");
1414 ath9k_htc_ps_wakeup(priv); 1429 ath9k_htc_ps_wakeup(priv);
diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c
index 1b90ed8795c3..c25226a32ddc 100644
--- a/drivers/net/wireless/ath/ath9k/htc_hst.c
+++ b/drivers/net/wireless/ath/ath9k/htc_hst.c
@@ -431,11 +431,8 @@ struct htc_target *ath9k_htc_hw_alloc(void *hif_handle,
431 struct htc_target *target; 431 struct htc_target *target;
432 432
433 target = kzalloc(sizeof(struct htc_target), GFP_KERNEL); 433 target = kzalloc(sizeof(struct htc_target), GFP_KERNEL);
434 if (!target) { 434 if (!target)
435 printk(KERN_ERR "Unable to allocate memory for"
436 "target device\n");
437 return NULL; 435 return NULL;
438 }
439 436
440 init_completion(&target->target_wait); 437 init_completion(&target->target_wait);
441 init_completion(&target->cmd_wait); 438 init_completion(&target->cmd_wait);
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 4a00806e2852..ec82e926badc 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -340,9 +340,7 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan,
340 fastcc = false; 340 fastcc = false;
341 341
342 ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n", 342 ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n",
343 hchan->channel, !!(hchan->channelFlags & (CHANNEL_HT40MINUS | 343 hchan->channel, IS_CHAN_HT40(hchan), fastcc);
344 CHANNEL_HT40PLUS)),
345 fastcc);
346 344
347 r = ath9k_hw_reset(ah, hchan, caldata, fastcc); 345 r = ath9k_hw_reset(ah, hchan, caldata, fastcc);
348 if (r) { 346 if (r) {
diff --git a/drivers/net/wireless/ath/carl9170/carl9170.h b/drivers/net/wireless/ath/carl9170/carl9170.h
index 6cfbb419e2f6..0cea20e3e250 100644
--- a/drivers/net/wireless/ath/carl9170/carl9170.h
+++ b/drivers/net/wireless/ath/carl9170/carl9170.h
@@ -559,6 +559,7 @@ int carl9170_set_hwretry_limit(struct ar9170 *ar, const u32 max_retry);
559int carl9170_upload_key(struct ar9170 *ar, const u8 id, const u8 *mac, 559int carl9170_upload_key(struct ar9170 *ar, const u8 id, const u8 *mac,
560 const u8 ktype, const u8 keyidx, const u8 *keydata, const int keylen); 560 const u8 ktype, const u8 keyidx, const u8 *keydata, const int keylen);
561int carl9170_disable_key(struct ar9170 *ar, const u8 id); 561int carl9170_disable_key(struct ar9170 *ar, const u8 id);
562int carl9170_set_mac_tpc(struct ar9170 *ar, struct ieee80211_channel *channel);
562 563
563/* RX */ 564/* RX */
564void carl9170_rx(struct ar9170 *ar, void *buf, unsigned int len); 565void carl9170_rx(struct ar9170 *ar, void *buf, unsigned int len);
@@ -593,7 +594,6 @@ int carl9170_get_noisefloor(struct ar9170 *ar);
593 594
594/* FW */ 595/* FW */
595int carl9170_parse_firmware(struct ar9170 *ar); 596int carl9170_parse_firmware(struct ar9170 *ar);
596int carl9170_fw_fix_eeprom(struct ar9170 *ar);
597 597
598extern struct ieee80211_rate __carl9170_ratetable[]; 598extern struct ieee80211_rate __carl9170_ratetable[];
599extern int modparam_noht; 599extern int modparam_noht;
diff --git a/drivers/net/wireless/ath/carl9170/fw.c b/drivers/net/wireless/ath/carl9170/fw.c
index 3de61adacd34..cffde8d9a521 100644
--- a/drivers/net/wireless/ath/carl9170/fw.c
+++ b/drivers/net/wireless/ath/carl9170/fw.c
@@ -389,39 +389,6 @@ carl9170_find_fw_desc(struct ar9170 *ar, const __u8 *fw_data, const size_t len)
389 return (void *)&fw_data[scan - found]; 389 return (void *)&fw_data[scan - found];
390} 390}
391 391
392int carl9170_fw_fix_eeprom(struct ar9170 *ar)
393{
394 const struct carl9170fw_fix_desc *fix_desc = NULL;
395 unsigned int i, n, off;
396 u32 *data = (void *)&ar->eeprom;
397
398 fix_desc = carl9170_fw_find_desc(ar, FIX_MAGIC,
399 sizeof(*fix_desc), CARL9170FW_FIX_DESC_CUR_VER);
400
401 if (!fix_desc)
402 return 0;
403
404 n = (le16_to_cpu(fix_desc->head.length) - sizeof(*fix_desc)) /
405 sizeof(struct carl9170fw_fix_entry);
406
407 for (i = 0; i < n; i++) {
408 off = le32_to_cpu(fix_desc->data[i].address) -
409 AR9170_EEPROM_START;
410
411 if (off >= sizeof(struct ar9170_eeprom) || (off & 3)) {
412 dev_err(&ar->udev->dev, "Skip invalid entry %d\n", i);
413 continue;
414 }
415
416 data[off / sizeof(*data)] &=
417 le32_to_cpu(fix_desc->data[i].mask);
418 data[off / sizeof(*data)] |=
419 le32_to_cpu(fix_desc->data[i].value);
420 }
421
422 return 0;
423}
424
425int carl9170_parse_firmware(struct ar9170 *ar) 392int carl9170_parse_firmware(struct ar9170 *ar)
426{ 393{
427 const struct carl9170fw_desc_head *fw_desc = NULL; 394 const struct carl9170fw_desc_head *fw_desc = NULL;
diff --git a/drivers/net/wireless/ath/carl9170/mac.c b/drivers/net/wireless/ath/carl9170/mac.c
index dfda91970995..53415bfd8bef 100644
--- a/drivers/net/wireless/ath/carl9170/mac.c
+++ b/drivers/net/wireless/ath/carl9170/mac.c
@@ -485,3 +485,38 @@ int carl9170_disable_key(struct ar9170 *ar, const u8 id)
485 return carl9170_exec_cmd(ar, CARL9170_CMD_DKEY, 485 return carl9170_exec_cmd(ar, CARL9170_CMD_DKEY,
486 sizeof(key), (u8 *)&key, 0, NULL); 486 sizeof(key), (u8 *)&key, 0, NULL);
487} 487}
488
489int carl9170_set_mac_tpc(struct ar9170 *ar, struct ieee80211_channel *channel)
490{
491 unsigned int power, chains;
492
493 if (ar->eeprom.tx_mask != 1)
494 chains = AR9170_TX_PHY_TXCHAIN_2;
495 else
496 chains = AR9170_TX_PHY_TXCHAIN_1;
497
498 switch (channel->band) {
499 case IEEE80211_BAND_2GHZ:
500 power = ar->power_2G_ofdm[0] & 0x3f;
501 break;
502 case IEEE80211_BAND_5GHZ:
503 power = ar->power_5G_leg[0] & 0x3f;
504 break;
505 default:
506 BUG_ON(1);
507 }
508
509 power = min_t(unsigned int, power, ar->hw->conf.power_level * 2);
510
511 carl9170_regwrite_begin(ar);
512 carl9170_regwrite(AR9170_MAC_REG_ACK_TPC,
513 0x3c1e | power << 20 | chains << 26);
514 carl9170_regwrite(AR9170_MAC_REG_RTS_CTS_TPC,
515 power << 5 | chains << 11 |
516 power << 21 | chains << 27);
517 carl9170_regwrite(AR9170_MAC_REG_CFEND_QOSNULL_TPC,
518 power << 5 | chains << 11 |
519 power << 21 | chains << 27);
520 carl9170_regwrite_finish();
521 return carl9170_regwrite_result();
522}
diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
index db774212161b..8d2523b3f722 100644
--- a/drivers/net/wireless/ath/carl9170/main.c
+++ b/drivers/net/wireless/ath/carl9170/main.c
@@ -853,11 +853,6 @@ static int carl9170_op_config(struct ieee80211_hw *hw, u32 changed)
853 goto out; 853 goto out;
854 } 854 }
855 855
856 if (changed & IEEE80211_CONF_CHANGE_POWER) {
857 /* TODO */
858 err = 0;
859 }
860
861 if (changed & IEEE80211_CONF_CHANGE_SMPS) { 856 if (changed & IEEE80211_CONF_CHANGE_SMPS) {
862 /* TODO */ 857 /* TODO */
863 err = 0; 858 err = 0;
@@ -891,6 +886,12 @@ static int carl9170_op_config(struct ieee80211_hw *hw, u32 changed)
891 goto out; 886 goto out;
892 } 887 }
893 888
889 if (changed & IEEE80211_CONF_CHANGE_POWER) {
890 err = carl9170_set_mac_tpc(ar, ar->hw->conf.channel);
891 if (err)
892 goto out;
893 }
894
894out: 895out:
895 mutex_unlock(&ar->mutex); 896 mutex_unlock(&ar->mutex);
896 return err; 897 return err;
@@ -1796,6 +1797,9 @@ void *carl9170_alloc(size_t priv_size)
1796 ar->noise[i] = -95; /* ATH_DEFAULT_NOISE_FLOOR */ 1797 ar->noise[i] = -95; /* ATH_DEFAULT_NOISE_FLOOR */
1797 1798
1798 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 1799 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
1800
1801 /* As IBSS Encryption is software-based, IBSS RSN is supported. */
1802 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
1799 return ar; 1803 return ar;
1800 1804
1801err_nomem: 1805err_nomem:
@@ -1931,10 +1935,6 @@ int carl9170_register(struct ar9170 *ar)
1931 if (err) 1935 if (err)
1932 return err; 1936 return err;
1933 1937
1934 err = carl9170_fw_fix_eeprom(ar);
1935 if (err)
1936 return err;
1937
1938 err = carl9170_parse_eeprom(ar); 1938 err = carl9170_parse_eeprom(ar);
1939 if (err) 1939 if (err)
1940 return err; 1940 return err;
diff --git a/drivers/net/wireless/ath/carl9170/phy.c b/drivers/net/wireless/ath/carl9170/phy.c
index 472efc7e3402..b72c09cf43a4 100644
--- a/drivers/net/wireless/ath/carl9170/phy.c
+++ b/drivers/net/wireless/ath/carl9170/phy.c
@@ -1426,15 +1426,15 @@ static void carl9170_calc_ctl(struct ar9170 *ar, u32 freq, enum carl9170_bw bw)
1426#undef EDGES 1426#undef EDGES
1427} 1427}
1428 1428
1429static int carl9170_set_power_cal(struct ar9170 *ar, u32 freq, 1429static void carl9170_set_power_cal(struct ar9170 *ar, u32 freq,
1430 enum carl9170_bw bw) 1430 enum carl9170_bw bw)
1431{ 1431{
1432 struct ar9170_calibration_target_power_legacy *ctpl; 1432 struct ar9170_calibration_target_power_legacy *ctpl;
1433 struct ar9170_calibration_target_power_ht *ctph; 1433 struct ar9170_calibration_target_power_ht *ctph;
1434 u8 *ctpres; 1434 u8 *ctpres;
1435 int ntargets; 1435 int ntargets;
1436 int idx, i, n; 1436 int idx, i, n;
1437 u8 ackpower, ackchains, f; 1437 u8 f;
1438 u8 pwr_freqs[AR5416_MAX_NUM_TGT_PWRS]; 1438 u8 pwr_freqs[AR5416_MAX_NUM_TGT_PWRS];
1439 1439
1440 if (freq < 3000) 1440 if (freq < 3000)
@@ -1523,32 +1523,6 @@ static int carl9170_set_power_cal(struct ar9170 *ar, u32 freq,
1523 1523
1524 /* calc. conformance test limits and apply to ar->power*[] */ 1524 /* calc. conformance test limits and apply to ar->power*[] */
1525 carl9170_calc_ctl(ar, freq, bw); 1525 carl9170_calc_ctl(ar, freq, bw);
1526
1527 /* set ACK/CTS TX power */
1528 carl9170_regwrite_begin(ar);
1529
1530 if (ar->eeprom.tx_mask != 1)
1531 ackchains = AR9170_TX_PHY_TXCHAIN_2;
1532 else
1533 ackchains = AR9170_TX_PHY_TXCHAIN_1;
1534
1535 if (freq < 3000)
1536 ackpower = ar->power_2G_ofdm[0] & 0x3f;
1537 else
1538 ackpower = ar->power_5G_leg[0] & 0x3f;
1539
1540 carl9170_regwrite(AR9170_MAC_REG_ACK_TPC,
1541 0x3c1e | ackpower << 20 | ackchains << 26);
1542 carl9170_regwrite(AR9170_MAC_REG_RTS_CTS_TPC,
1543 ackpower << 5 | ackchains << 11 |
1544 ackpower << 21 | ackchains << 27);
1545
1546 carl9170_regwrite(AR9170_MAC_REG_CFEND_QOSNULL_TPC,
1547 ackpower << 5 | ackchains << 11 |
1548 ackpower << 21 | ackchains << 27);
1549
1550 carl9170_regwrite_finish();
1551 return carl9170_regwrite_result();
1552} 1526}
1553 1527
1554int carl9170_get_noisefloor(struct ar9170 *ar) 1528int carl9170_get_noisefloor(struct ar9170 *ar)
@@ -1712,7 +1686,9 @@ int carl9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel,
1712 if (err) 1686 if (err)
1713 return err; 1687 return err;
1714 1688
1715 err = carl9170_set_power_cal(ar, channel->center_freq, bw); 1689 carl9170_set_power_cal(ar, channel->center_freq, bw);
1690
1691 err = carl9170_set_mac_tpc(ar, channel);
1716 if (err) 1692 if (err)
1717 return err; 1693 return err;
1718 1694
diff --git a/drivers/net/wireless/ath/carl9170/tx.c b/drivers/net/wireless/ath/carl9170/tx.c
index d19a9ee9d057..771e1a9294c5 100644
--- a/drivers/net/wireless/ath/carl9170/tx.c
+++ b/drivers/net/wireless/ath/carl9170/tx.c
@@ -719,6 +719,8 @@ static void carl9170_tx_rate_tpc_chains(struct ar9170 *ar,
719 else 719 else
720 *chains = AR9170_TX_PHY_TXCHAIN_2; 720 *chains = AR9170_TX_PHY_TXCHAIN_2;
721 } 721 }
722
723 *tpc = min_t(unsigned int, *tpc, ar->hw->conf.power_level * 2);
722} 724}
723 725
724static __le32 carl9170_tx_physet(struct ar9170 *ar, 726static __le32 carl9170_tx_physet(struct ar9170 *ar,
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 7e45ca2e78ef..3010cee7b95a 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -1533,10 +1533,9 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port,
1533 1533
1534 /* Create the network device object. */ 1534 /* Create the network device object. */
1535 dev = alloc_etherdev(sizeof(*priv)); 1535 dev = alloc_etherdev(sizeof(*priv));
1536 if (!dev) { 1536 if (!dev)
1537 printk(KERN_ERR "atmel: Couldn't alloc_etherdev\n");
1538 return NULL; 1537 return NULL;
1539 } 1538
1540 if (dev_alloc_name(dev, dev->name) < 0) { 1539 if (dev_alloc_name(dev, dev->name) < 0) {
1541 printk(KERN_ERR "atmel: Couldn't get name!\n"); 1540 printk(KERN_ERR "atmel: Couldn't get name!\n");
1542 goto err_out_free; 1541 goto err_out_free;
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index 16e8f8058155..835462dc1206 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -999,6 +999,12 @@ static inline void b43_write16(struct b43_wldev *dev, u16 offset, u16 value)
999 dev->dev->write16(dev->dev, offset, value); 999 dev->dev->write16(dev->dev, offset, value);
1000} 1000}
1001 1001
1002static inline void b43_maskset16(struct b43_wldev *dev, u16 offset, u16 mask,
1003 u16 set)
1004{
1005 b43_write16(dev, offset, (b43_read16(dev, offset) & mask) | set);
1006}
1007
1002static inline u32 b43_read32(struct b43_wldev *dev, u16 offset) 1008static inline u32 b43_read32(struct b43_wldev *dev, u16 offset)
1003{ 1009{
1004 return dev->dev->read32(dev->dev, offset); 1010 return dev->dev->read32(dev->dev, offset);
@@ -1009,6 +1015,12 @@ static inline void b43_write32(struct b43_wldev *dev, u16 offset, u32 value)
1009 dev->dev->write32(dev->dev, offset, value); 1015 dev->dev->write32(dev->dev, offset, value);
1010} 1016}
1011 1017
1018static inline void b43_maskset32(struct b43_wldev *dev, u16 offset, u32 mask,
1019 u32 set)
1020{
1021 b43_write32(dev, offset, (b43_read32(dev, offset) & mask) | set);
1022}
1023
1012static inline void b43_block_read(struct b43_wldev *dev, void *buffer, 1024static inline void b43_block_read(struct b43_wldev *dev, void *buffer,
1013 size_t count, u16 offset, u8 reg_width) 1025 size_t count, u16 offset, u8 reg_width)
1014{ 1026{
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 23ffb1b9a86f..5189cf38123a 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -580,22 +580,14 @@ void b43_tsf_read(struct b43_wldev *dev, u64 *tsf)
580 580
581static void b43_time_lock(struct b43_wldev *dev) 581static void b43_time_lock(struct b43_wldev *dev)
582{ 582{
583 u32 macctl; 583 b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_TBTTHOLD);
584
585 macctl = b43_read32(dev, B43_MMIO_MACCTL);
586 macctl |= B43_MACCTL_TBTTHOLD;
587 b43_write32(dev, B43_MMIO_MACCTL, macctl);
588 /* Commit the write */ 584 /* Commit the write */
589 b43_read32(dev, B43_MMIO_MACCTL); 585 b43_read32(dev, B43_MMIO_MACCTL);
590} 586}
591 587
592static void b43_time_unlock(struct b43_wldev *dev) 588static void b43_time_unlock(struct b43_wldev *dev)
593{ 589{
594 u32 macctl; 590 b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_TBTTHOLD, 0);
595
596 macctl = b43_read32(dev, B43_MMIO_MACCTL);
597 macctl &= ~B43_MACCTL_TBTTHOLD;
598 b43_write32(dev, B43_MMIO_MACCTL, macctl);
599 /* Commit the write */ 591 /* Commit the write */
600 b43_read32(dev, B43_MMIO_MACCTL); 592 b43_read32(dev, B43_MMIO_MACCTL);
601} 593}
@@ -2487,10 +2479,8 @@ static int b43_upload_microcode(struct b43_wldev *dev)
2487 b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, B43_IRQ_ALL); 2479 b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, B43_IRQ_ALL);
2488 2480
2489 /* Start the microcode PSM */ 2481 /* Start the microcode PSM */
2490 macctl = b43_read32(dev, B43_MMIO_MACCTL); 2482 b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_JMP0,
2491 macctl &= ~B43_MACCTL_PSM_JMP0; 2483 B43_MACCTL_PSM_RUN);
2492 macctl |= B43_MACCTL_PSM_RUN;
2493 b43_write32(dev, B43_MMIO_MACCTL, macctl);
2494 2484
2495 /* Wait for the microcode to load and respond */ 2485 /* Wait for the microcode to load and respond */
2496 i = 0; 2486 i = 0;
@@ -2590,10 +2580,9 @@ static int b43_upload_microcode(struct b43_wldev *dev)
2590 return 0; 2580 return 0;
2591 2581
2592error: 2582error:
2593 macctl = b43_read32(dev, B43_MMIO_MACCTL); 2583 /* Stop the microcode PSM. */
2594 macctl &= ~B43_MACCTL_PSM_RUN; 2584 b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_RUN,
2595 macctl |= B43_MACCTL_PSM_JMP0; 2585 B43_MACCTL_PSM_JMP0);
2596 b43_write32(dev, B43_MMIO_MACCTL, macctl);
2597 2586
2598 return err; 2587 return err;
2599} 2588}
@@ -2708,11 +2697,8 @@ static int b43_gpio_init(struct b43_wldev *dev)
2708 struct ssb_device *gpiodev; 2697 struct ssb_device *gpiodev;
2709 u32 mask, set; 2698 u32 mask, set;
2710 2699
2711 b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL) 2700 b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_GPOUTSMSK, 0);
2712 & ~B43_MACCTL_GPOUTSMSK); 2701 b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, 0xF);
2713
2714 b43_write16(dev, B43_MMIO_GPIO_MASK, b43_read16(dev, B43_MMIO_GPIO_MASK)
2715 | 0x000F);
2716 2702
2717 mask = 0x0000001F; 2703 mask = 0x0000001F;
2718 set = 0x0000000F; 2704 set = 0x0000000F;
@@ -2800,9 +2786,7 @@ void b43_mac_enable(struct b43_wldev *dev)
2800 dev->mac_suspended--; 2786 dev->mac_suspended--;
2801 B43_WARN_ON(dev->mac_suspended < 0); 2787 B43_WARN_ON(dev->mac_suspended < 0);
2802 if (dev->mac_suspended == 0) { 2788 if (dev->mac_suspended == 0) {
2803 b43_write32(dev, B43_MMIO_MACCTL, 2789 b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_ENABLED);
2804 b43_read32(dev, B43_MMIO_MACCTL)
2805 | B43_MACCTL_ENABLED);
2806 b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, 2790 b43_write32(dev, B43_MMIO_GEN_IRQ_REASON,
2807 B43_IRQ_MAC_SUSPENDED); 2791 B43_IRQ_MAC_SUSPENDED);
2808 /* Commit writes */ 2792 /* Commit writes */
@@ -2823,9 +2807,7 @@ void b43_mac_suspend(struct b43_wldev *dev)
2823 2807
2824 if (dev->mac_suspended == 0) { 2808 if (dev->mac_suspended == 0) {
2825 b43_power_saving_ctl_bits(dev, B43_PS_AWAKE); 2809 b43_power_saving_ctl_bits(dev, B43_PS_AWAKE);
2826 b43_write32(dev, B43_MMIO_MACCTL, 2810 b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_ENABLED, 0);
2827 b43_read32(dev, B43_MMIO_MACCTL)
2828 & ~B43_MACCTL_ENABLED);
2829 /* force pci to flush the write */ 2811 /* force pci to flush the write */
2830 b43_read32(dev, B43_MMIO_MACCTL); 2812 b43_read32(dev, B43_MMIO_MACCTL);
2831 for (i = 35; i; i--) { 2813 for (i = 35; i; i--) {
@@ -2931,15 +2913,10 @@ static void b43_adjust_opmode(struct b43_wldev *dev)
2931 * so always disable it. If we want to implement PMQ, 2913 * so always disable it. If we want to implement PMQ,
2932 * we need to enable it here (clear DISCPMQ) in AP mode. 2914 * we need to enable it here (clear DISCPMQ) in AP mode.
2933 */ 2915 */
2934 if (0 /* ctl & B43_MACCTL_AP */) { 2916 if (0 /* ctl & B43_MACCTL_AP */)
2935 b43_write32(dev, B43_MMIO_MACCTL, 2917 b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_DISCPMQ, 0);
2936 b43_read32(dev, B43_MMIO_MACCTL) 2918 else
2937 & ~B43_MACCTL_DISCPMQ); 2919 b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_DISCPMQ);
2938 } else {
2939 b43_write32(dev, B43_MMIO_MACCTL,
2940 b43_read32(dev, B43_MMIO_MACCTL)
2941 | B43_MACCTL_DISCPMQ);
2942 }
2943} 2920}
2944 2921
2945static void b43_rate_memory_write(struct b43_wldev *dev, u16 rate, int is_ofdm) 2922static void b43_rate_memory_write(struct b43_wldev *dev, u16 rate, int is_ofdm)
@@ -3083,10 +3060,8 @@ static int b43_chip_init(struct b43_wldev *dev)
3083 if (dev->dev->core_rev < 5) 3060 if (dev->dev->core_rev < 5)
3084 b43_write32(dev, 0x010C, 0x01000000); 3061 b43_write32(dev, 0x010C, 0x01000000);
3085 3062
3086 b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL) 3063 b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_INFRA, 0);
3087 & ~B43_MACCTL_INFRA); 3064 b43_maskset32(dev, B43_MMIO_MACCTL, ~0, B43_MACCTL_INFRA);
3088 b43_write32(dev, B43_MMIO_MACCTL, b43_read32(dev, B43_MMIO_MACCTL)
3089 | B43_MACCTL_INFRA);
3090 3065
3091 /* Probe Response Timeout value */ 3066 /* Probe Response Timeout value */
3092 /* FIXME: Default to 0, has to be set by ioctl probably... :-/ */ 3067 /* FIXME: Default to 0, has to be set by ioctl probably... :-/ */
@@ -4564,8 +4539,6 @@ static void b43_set_pretbtt(struct b43_wldev *dev)
4564/* Locking: wl->mutex */ 4539/* Locking: wl->mutex */
4565static void b43_wireless_core_exit(struct b43_wldev *dev) 4540static void b43_wireless_core_exit(struct b43_wldev *dev)
4566{ 4541{
4567 u32 macctl;
4568
4569 B43_WARN_ON(dev && b43_status(dev) > B43_STAT_INITIALIZED); 4542 B43_WARN_ON(dev && b43_status(dev) > B43_STAT_INITIALIZED);
4570 if (!dev || b43_status(dev) != B43_STAT_INITIALIZED) 4543 if (!dev || b43_status(dev) != B43_STAT_INITIALIZED)
4571 return; 4544 return;
@@ -4576,10 +4549,8 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
4576 b43_set_status(dev, B43_STAT_UNINIT); 4549 b43_set_status(dev, B43_STAT_UNINIT);
4577 4550
4578 /* Stop the microcode PSM. */ 4551 /* Stop the microcode PSM. */
4579 macctl = b43_read32(dev, B43_MMIO_MACCTL); 4552 b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_PSM_RUN,
4580 macctl &= ~B43_MACCTL_PSM_RUN; 4553 B43_MACCTL_PSM_JMP0);
4581 macctl |= B43_MACCTL_PSM_JMP0;
4582 b43_write32(dev, B43_MMIO_MACCTL, macctl);
4583 4554
4584 b43_dma_free(dev); 4555 b43_dma_free(dev);
4585 b43_pio_free(dev); 4556 b43_pio_free(dev);
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index bf5a43855358..108118820b36 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -85,22 +85,11 @@ static inline bool b43_nphy_ipa(struct b43_wldev *dev)
85 (dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ)); 85 (dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ));
86} 86}
87 87
88/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetIpaGainTbl */ 88/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreGetState */
89static const u32 *b43_nphy_get_ipa_gain_table(struct b43_wldev *dev) 89static u8 b43_nphy_get_rx_core_state(struct b43_wldev *dev)
90{ 90{
91 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) { 91 return (b43_phy_read(dev, B43_NPHY_RFSEQCA) & B43_NPHY_RFSEQCA_RXEN) >>
92 if (dev->phy.rev >= 6) { 92 B43_NPHY_RFSEQCA_RXEN_SHIFT;
93 if (dev->dev->chip_id == 47162)
94 return txpwrctrl_tx_gain_ipa_rev5;
95 return txpwrctrl_tx_gain_ipa_rev6;
96 } else if (dev->phy.rev >= 5) {
97 return txpwrctrl_tx_gain_ipa_rev5;
98 } else {
99 return txpwrctrl_tx_gain_ipa;
100 }
101 } else {
102 return txpwrctrl_tx_gain_ipa_5g;
103 }
104} 93}
105 94
106/************************************************** 95/**************************************************
@@ -229,7 +218,7 @@ static void b43_nphy_rf_control_intc_override(struct b43_wldev *dev, u8 field,
229 218
230 reg = (i == 0) ? 219 reg = (i == 0) ?
231 B43_NPHY_RFCTL_INTC1 : B43_NPHY_RFCTL_INTC2; 220 B43_NPHY_RFCTL_INTC1 : B43_NPHY_RFCTL_INTC2;
232 b43_phy_mask(dev, reg, 0xFBFF); 221 b43_phy_set(dev, reg, 0x400);
233 222
234 switch (field) { 223 switch (field) {
235 case 0: 224 case 0:
@@ -245,7 +234,7 @@ static void b43_nphy_rf_control_intc_override(struct b43_wldev *dev, u8 field,
245 b43_phy_set(dev, B43_NPHY_RFCTL_CMD, 234 b43_phy_set(dev, B43_NPHY_RFCTL_CMD,
246 B43_NPHY_RFCTL_CMD_START); 235 B43_NPHY_RFCTL_CMD_START);
247 for (j = 0; j < 100; j++) { 236 for (j = 0; j < 100; j++) {
248 if (b43_phy_read(dev, B43_NPHY_RFCTL_CMD) & B43_NPHY_RFCTL_CMD_START) { 237 if (!(b43_phy_read(dev, B43_NPHY_RFCTL_CMD) & B43_NPHY_RFCTL_CMD_START)) {
249 j = 0; 238 j = 0;
250 break; 239 break;
251 } 240 }
@@ -264,7 +253,7 @@ static void b43_nphy_rf_control_intc_override(struct b43_wldev *dev, u8 field,
264 b43_phy_set(dev, B43_NPHY_RFCTL_CMD, 253 b43_phy_set(dev, B43_NPHY_RFCTL_CMD,
265 B43_NPHY_RFCTL_CMD_RXTX); 254 B43_NPHY_RFCTL_CMD_RXTX);
266 for (j = 0; j < 100; j++) { 255 for (j = 0; j < 100; j++) {
267 if (b43_phy_read(dev, B43_NPHY_RFCTL_CMD) & B43_NPHY_RFCTL_CMD_RXTX) { 256 if (!(b43_phy_read(dev, B43_NPHY_RFCTL_CMD) & B43_NPHY_RFCTL_CMD_RXTX)) {
268 j = 0; 257 j = 0;
269 break; 258 break;
270 } 259 }
@@ -1231,12 +1220,12 @@ static int b43_nphy_poll_rssi(struct b43_wldev *dev, u8 type, s32 *buf,
1231 u16 s[2]; 1220 u16 s[2];
1232 1221
1233 if (dev->phy.rev >= 3) { 1222 if (dev->phy.rev >= 3) {
1234 save_regs_phy[0] = b43_phy_read(dev, 1223 save_regs_phy[0] = b43_phy_read(dev, B43_NPHY_AFECTL_C1);
1224 save_regs_phy[1] = b43_phy_read(dev, B43_NPHY_AFECTL_C2);
1225 save_regs_phy[2] = b43_phy_read(dev,
1235 B43_NPHY_RFCTL_LUT_TRSW_UP1); 1226 B43_NPHY_RFCTL_LUT_TRSW_UP1);
1236 save_regs_phy[1] = b43_phy_read(dev, 1227 save_regs_phy[3] = b43_phy_read(dev,
1237 B43_NPHY_RFCTL_LUT_TRSW_UP2); 1228 B43_NPHY_RFCTL_LUT_TRSW_UP2);
1238 save_regs_phy[2] = b43_phy_read(dev, B43_NPHY_AFECTL_C1);
1239 save_regs_phy[3] = b43_phy_read(dev, B43_NPHY_AFECTL_C2);
1240 save_regs_phy[4] = b43_phy_read(dev, B43_NPHY_AFECTL_OVER1); 1229 save_regs_phy[4] = b43_phy_read(dev, B43_NPHY_AFECTL_OVER1);
1241 save_regs_phy[5] = b43_phy_read(dev, B43_NPHY_AFECTL_OVER); 1230 save_regs_phy[5] = b43_phy_read(dev, B43_NPHY_AFECTL_OVER);
1242 save_regs_phy[6] = b43_phy_read(dev, B43_NPHY_TXF_40CO_B1S0); 1231 save_regs_phy[6] = b43_phy_read(dev, B43_NPHY_TXF_40CO_B1S0);
@@ -1285,12 +1274,12 @@ static int b43_nphy_poll_rssi(struct b43_wldev *dev, u8 type, s32 *buf,
1285 b43_phy_write(dev, B43_NPHY_GPIO_SEL, save_regs_phy[8]); 1274 b43_phy_write(dev, B43_NPHY_GPIO_SEL, save_regs_phy[8]);
1286 1275
1287 if (dev->phy.rev >= 3) { 1276 if (dev->phy.rev >= 3) {
1277 b43_phy_write(dev, B43_NPHY_AFECTL_C1, save_regs_phy[0]);
1278 b43_phy_write(dev, B43_NPHY_AFECTL_C2, save_regs_phy[1]);
1288 b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_UP1, 1279 b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_UP1,
1289 save_regs_phy[0]); 1280 save_regs_phy[2]);
1290 b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_UP2, 1281 b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_UP2,
1291 save_regs_phy[1]); 1282 save_regs_phy[3]);
1292 b43_phy_write(dev, B43_NPHY_AFECTL_C1, save_regs_phy[2]);
1293 b43_phy_write(dev, B43_NPHY_AFECTL_C2, save_regs_phy[3]);
1294 b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, save_regs_phy[4]); 1283 b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, save_regs_phy[4]);
1295 b43_phy_write(dev, B43_NPHY_AFECTL_OVER, save_regs_phy[5]); 1284 b43_phy_write(dev, B43_NPHY_AFECTL_OVER, save_regs_phy[5]);
1296 b43_phy_write(dev, B43_NPHY_TXF_40CO_B1S0, save_regs_phy[6]); 1285 b43_phy_write(dev, B43_NPHY_TXF_40CO_B1S0, save_regs_phy[6]);
@@ -1308,6 +1297,186 @@ static int b43_nphy_poll_rssi(struct b43_wldev *dev, u8 type, s32 *buf,
1308 return out; 1297 return out;
1309} 1298}
1310 1299
1300/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */
1301static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
1302{
1303 struct b43_phy_n *nphy = dev->phy.n;
1304
1305 u16 saved_regs_phy_rfctl[2];
1306 u16 saved_regs_phy[13];
1307 u16 regs_to_store[] = {
1308 B43_NPHY_AFECTL_OVER1, B43_NPHY_AFECTL_OVER,
1309 B43_NPHY_AFECTL_C1, B43_NPHY_AFECTL_C2,
1310 B43_NPHY_TXF_40CO_B1S1, B43_NPHY_RFCTL_OVER,
1311 B43_NPHY_TXF_40CO_B1S0, B43_NPHY_TXF_40CO_B32S1,
1312 B43_NPHY_RFCTL_CMD,
1313 B43_NPHY_RFCTL_LUT_TRSW_UP1, B43_NPHY_RFCTL_LUT_TRSW_UP2,
1314 B43_NPHY_RFCTL_RSSIO1, B43_NPHY_RFCTL_RSSIO2
1315 };
1316
1317 u16 class;
1318
1319 u16 clip_state[2];
1320 u16 clip_off[2] = { 0xFFFF, 0xFFFF };
1321
1322 u8 vcm_final = 0;
1323 s8 offset[4];
1324 s32 results[8][4] = { };
1325 s32 results_min[4] = { };
1326 s32 poll_results[4] = { };
1327
1328 u16 *rssical_radio_regs = NULL;
1329 u16 *rssical_phy_regs = NULL;
1330
1331 u16 r; /* routing */
1332 u8 rx_core_state;
1333 u8 core, i, j;
1334
1335 class = b43_nphy_classifier(dev, 0, 0);
1336 b43_nphy_classifier(dev, 7, 4);
1337 b43_nphy_read_clip_detection(dev, clip_state);
1338 b43_nphy_write_clip_detection(dev, clip_off);
1339
1340 saved_regs_phy_rfctl[0] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC1);
1341 saved_regs_phy_rfctl[1] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC2);
1342 for (i = 0; i < ARRAY_SIZE(regs_to_store); i++)
1343 saved_regs_phy[i] = b43_phy_read(dev, regs_to_store[i]);
1344
1345 b43_nphy_rf_control_intc_override(dev, 0, 0, 7);
1346 b43_nphy_rf_control_intc_override(dev, 1, 1, 7);
1347 b43_nphy_rf_control_override(dev, 0x1, 0, 0, false);
1348 b43_nphy_rf_control_override(dev, 0x2, 1, 0, false);
1349 b43_nphy_rf_control_override(dev, 0x80, 1, 0, false);
1350 b43_nphy_rf_control_override(dev, 0x40, 1, 0, false);
1351
1352 if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) {
1353 b43_nphy_rf_control_override(dev, 0x20, 0, 0, false);
1354 b43_nphy_rf_control_override(dev, 0x10, 1, 0, false);
1355 } else {
1356 b43_nphy_rf_control_override(dev, 0x10, 0, 0, false);
1357 b43_nphy_rf_control_override(dev, 0x20, 1, 0, false);
1358 }
1359
1360 rx_core_state = b43_nphy_get_rx_core_state(dev);
1361 for (core = 0; core < 2; core++) {
1362 if (!(rx_core_state & (1 << core)))
1363 continue;
1364 r = core ? B2056_RX1 : B2056_RX0;
1365 b43_nphy_scale_offset_rssi(dev, 0, 0, core + 1, 0, 2);
1366 b43_nphy_scale_offset_rssi(dev, 0, 0, core + 1, 1, 2);
1367 for (i = 0; i < 8; i++) {
1368 b43_radio_maskset(dev, r | B2056_RX_RSSI_MISC, 0xE3,
1369 i << 2);
1370 b43_nphy_poll_rssi(dev, 2, results[i], 8);
1371 }
1372 for (i = 0; i < 4; i++) {
1373 s32 curr;
1374 s32 mind = 40;
1375 s32 minpoll = 249;
1376 u8 minvcm = 0;
1377 if (2 * core != i)
1378 continue;
1379 for (j = 0; j < 8; j++) {
1380 curr = results[j][i] * results[j][i] +
1381 results[j][i + 1] * results[j][i];
1382 if (curr < mind) {
1383 mind = curr;
1384 minvcm = j;
1385 }
1386 if (results[j][i] < minpoll)
1387 minpoll = results[j][i];
1388 }
1389 vcm_final = minvcm;
1390 results_min[i] = minpoll;
1391 }
1392 b43_radio_maskset(dev, r | B2056_RX_RSSI_MISC, 0xE3,
1393 vcm_final << 2);
1394 for (i = 0; i < 4; i++) {
1395 if (core != i / 2)
1396 continue;
1397 offset[i] = -results[vcm_final][i];
1398 if (offset[i] < 0)
1399 offset[i] = -((abs(offset[i]) + 4) / 8);
1400 else
1401 offset[i] = (offset[i] + 4) / 8;
1402 if (results_min[i] == 248)
1403 offset[i] = -32;
1404 b43_nphy_scale_offset_rssi(dev, 0, offset[i],
1405 (i / 2 == 0) ? 1 : 2,
1406 (i % 2 == 0) ? 0 : 1,
1407 2);
1408 }
1409 }
1410 for (core = 0; core < 2; core++) {
1411 if (!(rx_core_state & (1 << core)))
1412 continue;
1413 for (i = 0; i < 2; i++) {
1414 b43_nphy_scale_offset_rssi(dev, 0, 0, core + 1, 0, i);
1415 b43_nphy_scale_offset_rssi(dev, 0, 0, core + 1, 1, i);
1416 b43_nphy_poll_rssi(dev, i, poll_results, 8);
1417 for (j = 0; j < 4; j++) {
1418 if (j / 2 == core)
1419 offset[j] = 232 - poll_results[j];
1420 if (offset[j] < 0)
1421 offset[j] = -(abs(offset[j] + 4) / 8);
1422 else
1423 offset[j] = (offset[j] + 4) / 8;
1424 b43_nphy_scale_offset_rssi(dev, 0,
1425 offset[2 * core], core + 1, j % 2, i);
1426 }
1427 }
1428 }
1429
1430 b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, saved_regs_phy_rfctl[0]);
1431 b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, saved_regs_phy_rfctl[1]);
1432
1433 b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX);
1434
1435 b43_phy_set(dev, B43_NPHY_TXF_40CO_B1S1, 0x1);
1436 b43_phy_set(dev, B43_NPHY_RFCTL_CMD, B43_NPHY_RFCTL_CMD_START);
1437 b43_phy_mask(dev, B43_NPHY_TXF_40CO_B1S1, ~0x1);
1438
1439 b43_phy_set(dev, B43_NPHY_RFCTL_OVER, 0x1);
1440 b43_phy_set(dev, B43_NPHY_RFCTL_CMD, B43_NPHY_RFCTL_CMD_RXTX);
1441 b43_phy_mask(dev, B43_NPHY_TXF_40CO_B1S1, ~0x1);
1442
1443 for (i = 0; i < ARRAY_SIZE(regs_to_store); i++)
1444 b43_phy_write(dev, regs_to_store[i], saved_regs_phy[i]);
1445
1446 /* Store for future configuration */
1447 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
1448 rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_2G;
1449 rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_2G;
1450 } else {
1451 rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_5G;
1452 rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_5G;
1453 }
1454 rssical_radio_regs[0] = b43_radio_read(dev, 0x602B);
1455 rssical_radio_regs[0] = b43_radio_read(dev, 0x702B);
1456 rssical_phy_regs[0] = b43_phy_read(dev, B43_NPHY_RSSIMC_0I_RSSI_Z);
1457 rssical_phy_regs[1] = b43_phy_read(dev, B43_NPHY_RSSIMC_0Q_RSSI_Z);
1458 rssical_phy_regs[2] = b43_phy_read(dev, B43_NPHY_RSSIMC_1I_RSSI_Z);
1459 rssical_phy_regs[3] = b43_phy_read(dev, B43_NPHY_RSSIMC_1Q_RSSI_Z);
1460 rssical_phy_regs[4] = b43_phy_read(dev, B43_NPHY_RSSIMC_0I_RSSI_X);
1461 rssical_phy_regs[5] = b43_phy_read(dev, B43_NPHY_RSSIMC_0Q_RSSI_X);
1462 rssical_phy_regs[6] = b43_phy_read(dev, B43_NPHY_RSSIMC_1I_RSSI_X);
1463 rssical_phy_regs[7] = b43_phy_read(dev, B43_NPHY_RSSIMC_1Q_RSSI_X);
1464 rssical_phy_regs[8] = b43_phy_read(dev, B43_NPHY_RSSIMC_0I_RSSI_Y);
1465 rssical_phy_regs[9] = b43_phy_read(dev, B43_NPHY_RSSIMC_0Q_RSSI_Y);
1466 rssical_phy_regs[10] = b43_phy_read(dev, B43_NPHY_RSSIMC_1I_RSSI_Y);
1467 rssical_phy_regs[11] = b43_phy_read(dev, B43_NPHY_RSSIMC_1Q_RSSI_Y);
1468
1469 /* Remember for which channel we store configuration */
1470 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
1471 nphy->rssical_chanspec_2G.center_freq = dev->phy.channel_freq;
1472 else
1473 nphy->rssical_chanspec_5G.center_freq = dev->phy.channel_freq;
1474
1475 /* End of calibration, restore configuration */
1476 b43_nphy_classifier(dev, 7, class);
1477 b43_nphy_write_clip_detection(dev, clip_state);
1478}
1479
1311/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal */ 1480/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal */
1312static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, u8 type) 1481static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, u8 type)
1313{ 1482{
@@ -1472,12 +1641,6 @@ static void b43_nphy_rev2_rssi_cal(struct b43_wldev *dev, u8 type)
1472 b43_nphy_reset_cca(dev); 1641 b43_nphy_reset_cca(dev);
1473} 1642}
1474 1643
1475/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */
1476static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
1477{
1478 /* TODO */
1479}
1480
1481/* 1644/*
1482 * RSSI Calibration 1645 * RSSI Calibration
1483 * http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal 1646 * http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal
@@ -2229,27 +2392,12 @@ static void b43_nphy_tx_power_fix(struct b43_wldev *dev)
2229 */ 2392 */
2230 2393
2231 for (i = 0; i < 2; i++) { 2394 for (i = 0; i < 2; i++) {
2232 if (dev->phy.rev >= 3) { 2395 txgain = *(b43_nphy_get_tx_gain_table(dev) + txpi[i]);
2233 if (b43_nphy_ipa(dev)) { 2396
2234 txgain = *(b43_nphy_get_ipa_gain_table(dev) + 2397 if (dev->phy.rev >= 3)
2235 txpi[i]);
2236 } else if (b43_current_band(dev->wl) ==
2237 IEEE80211_BAND_5GHZ) {
2238 /* FIXME: use 5GHz tables */
2239 txgain =
2240 b43_ntab_tx_gain_rev3plus_2ghz[txpi[i]];
2241 } else {
2242 if (dev->phy.rev >= 5 &&
2243 sprom->fem.ghz5.extpa_gain == 3)
2244 ; /* FIXME: 5GHz_txgain_HiPwrEPA */
2245 txgain =
2246 b43_ntab_tx_gain_rev3plus_2ghz[txpi[i]];
2247 }
2248 radio_gain = (txgain >> 16) & 0x1FFFF; 2398 radio_gain = (txgain >> 16) & 0x1FFFF;
2249 } else { 2399 else
2250 txgain = b43_ntab_tx_gain_rev0_1_2[txpi[i]];
2251 radio_gain = (txgain >> 16) & 0x1FFF; 2400 radio_gain = (txgain >> 16) & 0x1FFF;
2252 }
2253 2401
2254 if (dev->phy.rev >= 7) 2402 if (dev->phy.rev >= 7)
2255 dac_gain = (txgain >> 8) & 0x7; 2403 dac_gain = (txgain >> 8) & 0x7;
@@ -2420,55 +2568,252 @@ static void b43_nphy_tx_power_ctl_idle_tssi(struct b43_wldev *dev)
2420 nphy->pwr_ctl_info[1].idle_tssi_2g = (tmp >> 8) & 0xFF; 2568 nphy->pwr_ctl_info[1].idle_tssi_2g = (tmp >> 8) & 0xFF;
2421} 2569}
2422 2570
2423static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev) 2571/* http://bcm-v4.sipsolutions.net/PHY/N/TxPwrLimitToTbl */
2572static void b43_nphy_tx_prepare_adjusted_power_table(struct b43_wldev *dev)
2424{ 2573{
2425 struct b43_phy *phy = &dev->phy; 2574 struct b43_phy_n *nphy = dev->phy.n;
2426 2575
2427 const u32 *table = NULL; 2576 u8 idx, delta;
2428#if 0 2577 u8 i, stf_mode;
2429 TODO: b43_ntab_papd_pga_gain_delta_ipa_2*
2430 u32 rfpwr_offset;
2431 u8 pga_gain;
2432 int i;
2433#endif
2434 2578
2435 if (phy->rev >= 3) { 2579 for (i = 0; i < 4; i++)
2436 if (b43_nphy_ipa(dev)) { 2580 nphy->adj_pwr_tbl[i] = nphy->tx_power_offset[i];
2437 table = b43_nphy_get_ipa_gain_table(dev); 2581
2582 for (stf_mode = 0; stf_mode < 4; stf_mode++) {
2583 delta = 0;
2584 switch (stf_mode) {
2585 case 0:
2586 if (dev->phy.is_40mhz && dev->phy.rev >= 5) {
2587 idx = 68;
2588 } else {
2589 delta = 1;
2590 idx = dev->phy.is_40mhz ? 52 : 4;
2591 }
2592 break;
2593 case 1:
2594 idx = dev->phy.is_40mhz ? 76 : 28;
2595 break;
2596 case 2:
2597 idx = dev->phy.is_40mhz ? 84 : 36;
2598 break;
2599 case 3:
2600 idx = dev->phy.is_40mhz ? 92 : 44;
2601 break;
2602 }
2603
2604 for (i = 0; i < 20; i++) {
2605 nphy->adj_pwr_tbl[4 + 4 * i + stf_mode] =
2606 nphy->tx_power_offset[idx];
2607 if (i == 0)
2608 idx += delta;
2609 if (i == 14)
2610 idx += 1 - delta;
2611 if (i == 3 || i == 4 || i == 7 || i == 8 || i == 11 ||
2612 i == 13)
2613 idx += 1;
2614 }
2615 }
2616}
2617
2618/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlSetup */
2619static void b43_nphy_tx_power_ctl_setup(struct b43_wldev *dev)
2620{
2621 struct b43_phy_n *nphy = dev->phy.n;
2622 struct ssb_sprom *sprom = dev->dev->bus_sprom;
2623
2624 s16 a1[2], b0[2], b1[2];
2625 u8 idle[2];
2626 s8 target[2];
2627 s32 num, den, pwr;
2628 u32 regval[64];
2629
2630 u16 freq = dev->phy.channel_freq;
2631 u16 tmp;
2632 u16 r; /* routing */
2633 u8 i, c;
2634
2635 if (dev->dev->core_rev == 11 || dev->dev->core_rev == 12) {
2636 b43_maskset32(dev, B43_MMIO_MACCTL, ~0, 0x200000);
2637 b43_read32(dev, B43_MMIO_MACCTL);
2638 udelay(1);
2639 }
2640
2641 if (nphy->hang_avoid)
2642 b43_nphy_stay_in_carrier_search(dev, true);
2643
2644 b43_phy_set(dev, B43_NPHY_TSSIMODE, B43_NPHY_TSSIMODE_EN);
2645 if (dev->phy.rev >= 3)
2646 b43_phy_mask(dev, B43_NPHY_TXPCTL_CMD,
2647 ~B43_NPHY_TXPCTL_CMD_PCTLEN & 0xFFFF);
2648 else
2649 b43_phy_set(dev, B43_NPHY_TXPCTL_CMD,
2650 B43_NPHY_TXPCTL_CMD_PCTLEN);
2651
2652 if (dev->dev->core_rev == 11 || dev->dev->core_rev == 12)
2653 b43_maskset32(dev, B43_MMIO_MACCTL, ~0x200000, 0);
2654
2655 if (sprom->revision < 4) {
2656 idle[0] = nphy->pwr_ctl_info[0].idle_tssi_2g;
2657 idle[1] = nphy->pwr_ctl_info[1].idle_tssi_2g;
2658 target[0] = target[1] = 52;
2659 a1[0] = a1[1] = -424;
2660 b0[0] = b0[1] = 5612;
2661 b1[0] = b1[1] = -1393;
2662 } else {
2663 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
2664 for (c = 0; c < 2; c++) {
2665 idle[c] = nphy->pwr_ctl_info[c].idle_tssi_2g;
2666 target[c] = sprom->core_pwr_info[c].maxpwr_2g;
2667 a1[c] = sprom->core_pwr_info[c].pa_2g[0];
2668 b0[c] = sprom->core_pwr_info[c].pa_2g[1];
2669 b1[c] = sprom->core_pwr_info[c].pa_2g[2];
2670 }
2671 } else if (freq >= 4900 && freq < 5100) {
2672 for (c = 0; c < 2; c++) {
2673 idle[c] = nphy->pwr_ctl_info[c].idle_tssi_5g;
2674 target[c] = sprom->core_pwr_info[c].maxpwr_5gl;
2675 a1[c] = sprom->core_pwr_info[c].pa_5gl[0];
2676 b0[c] = sprom->core_pwr_info[c].pa_5gl[1];
2677 b1[c] = sprom->core_pwr_info[c].pa_5gl[2];
2678 }
2679 } else if (freq >= 5100 && freq < 5500) {
2680 for (c = 0; c < 2; c++) {
2681 idle[c] = nphy->pwr_ctl_info[c].idle_tssi_5g;
2682 target[c] = sprom->core_pwr_info[c].maxpwr_5g;
2683 a1[c] = sprom->core_pwr_info[c].pa_5g[0];
2684 b0[c] = sprom->core_pwr_info[c].pa_5g[1];
2685 b1[c] = sprom->core_pwr_info[c].pa_5g[2];
2686 }
2687 } else if (freq >= 5500) {
2688 for (c = 0; c < 2; c++) {
2689 idle[c] = nphy->pwr_ctl_info[c].idle_tssi_5g;
2690 target[c] = sprom->core_pwr_info[c].maxpwr_5gh;
2691 a1[c] = sprom->core_pwr_info[c].pa_5gh[0];
2692 b0[c] = sprom->core_pwr_info[c].pa_5gh[1];
2693 b1[c] = sprom->core_pwr_info[c].pa_5gh[2];
2694 }
2438 } else { 2695 } else {
2439 if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) { 2696 idle[0] = nphy->pwr_ctl_info[0].idle_tssi_5g;
2440 if (phy->rev == 3) 2697 idle[1] = nphy->pwr_ctl_info[1].idle_tssi_5g;
2441 table = b43_ntab_tx_gain_rev3_5ghz; 2698 target[0] = target[1] = 52;
2442 if (phy->rev == 4) 2699 a1[0] = a1[1] = -424;
2443 table = b43_ntab_tx_gain_rev4_5ghz; 2700 b0[0] = b0[1] = 5612;
2444 else 2701 b1[0] = b1[1] = -1393;
2445 table = b43_ntab_tx_gain_rev5plus_5ghz; 2702 }
2703 }
2704 /* target[0] = target[1] = nphy->tx_power_max; */
2705
2706 if (dev->phy.rev >= 3) {
2707 if (sprom->fem.ghz2.tssipos)
2708 b43_phy_set(dev, B43_NPHY_TXPCTL_ITSSI, 0x4000);
2709 if (dev->phy.rev >= 7) {
2710 for (c = 0; c < 2; c++) {
2711 r = c ? 0x190 : 0x170;
2712 if (b43_nphy_ipa(dev))
2713 b43_radio_write(dev, r + 0x9, (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) ? 0xE : 0xC);
2714 }
2715 } else {
2716 if (b43_nphy_ipa(dev)) {
2717 tmp = (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) ? 0xC : 0xE;
2718 b43_radio_write(dev,
2719 B2056_TX0 | B2056_TX_TX_SSI_MUX, tmp);
2720 b43_radio_write(dev,
2721 B2056_TX1 | B2056_TX_TX_SSI_MUX, tmp);
2446 } else { 2722 } else {
2447 table = b43_ntab_tx_gain_rev3plus_2ghz; 2723 b43_radio_write(dev,
2724 B2056_TX0 | B2056_TX_TX_SSI_MUX, 0x11);
2725 b43_radio_write(dev,
2726 B2056_TX1 | B2056_TX_TX_SSI_MUX, 0x11);
2448 } 2727 }
2449 } 2728 }
2729 }
2730
2731 if (dev->dev->core_rev == 11 || dev->dev->core_rev == 12) {
2732 b43_maskset32(dev, B43_MMIO_MACCTL, ~0, 0x200000);
2733 b43_read32(dev, B43_MMIO_MACCTL);
2734 udelay(1);
2735 }
2736
2737 if (dev->phy.rev >= 7) {
2738 b43_phy_maskset(dev, B43_NPHY_TXPCTL_CMD,
2739 ~B43_NPHY_TXPCTL_CMD_INIT, 0x19);
2740 b43_phy_maskset(dev, B43_NPHY_TXPCTL_INIT,
2741 ~B43_NPHY_TXPCTL_INIT_PIDXI1, 0x19);
2450 } else { 2742 } else {
2451 table = b43_ntab_tx_gain_rev0_1_2; 2743 b43_phy_maskset(dev, B43_NPHY_TXPCTL_CMD,
2744 ~B43_NPHY_TXPCTL_CMD_INIT, 0x40);
2745 if (dev->phy.rev > 1)
2746 b43_phy_maskset(dev, B43_NPHY_TXPCTL_INIT,
2747 ~B43_NPHY_TXPCTL_INIT_PIDXI1, 0x40);
2748 }
2749
2750 if (dev->dev->core_rev == 11 || dev->dev->core_rev == 12)
2751 b43_maskset32(dev, B43_MMIO_MACCTL, ~0x200000, 0);
2752
2753 b43_phy_write(dev, B43_NPHY_TXPCTL_N,
2754 0xF0 << B43_NPHY_TXPCTL_N_TSSID_SHIFT |
2755 3 << B43_NPHY_TXPCTL_N_NPTIL2_SHIFT);
2756 b43_phy_write(dev, B43_NPHY_TXPCTL_ITSSI,
2757 idle[0] << B43_NPHY_TXPCTL_ITSSI_0_SHIFT |
2758 idle[1] << B43_NPHY_TXPCTL_ITSSI_1_SHIFT |
2759 B43_NPHY_TXPCTL_ITSSI_BINF);
2760 b43_phy_write(dev, B43_NPHY_TXPCTL_TPWR,
2761 target[0] << B43_NPHY_TXPCTL_TPWR_0_SHIFT |
2762 target[1] << B43_NPHY_TXPCTL_TPWR_1_SHIFT);
2763
2764 for (c = 0; c < 2; c++) {
2765 for (i = 0; i < 64; i++) {
2766 num = 8 * (16 * b0[c] + b1[c] * i);
2767 den = 32768 + a1[c] * i;
2768 pwr = max((4 * num + den / 2) / den, -8);
2769 if (dev->phy.rev < 3 && (i <= (31 - idle[c] + 1)))
2770 pwr = max(pwr, target[c] + 1);
2771 regval[i] = pwr;
2772 }
2773 b43_ntab_write_bulk(dev, B43_NTAB32(26 + c, 0), 64, regval);
2452 } 2774 }
2775
2776 b43_nphy_tx_prepare_adjusted_power_table(dev);
2777 /*
2778 b43_ntab_write_bulk(dev, B43_NTAB16(26, 64), 84, nphy->adj_pwr_tbl);
2779 b43_ntab_write_bulk(dev, B43_NTAB16(27, 64), 84, nphy->adj_pwr_tbl);
2780 */
2781
2782 if (nphy->hang_avoid)
2783 b43_nphy_stay_in_carrier_search(dev, false);
2784}
2785
2786static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev)
2787{
2788 struct b43_phy *phy = &dev->phy;
2789
2790 const u32 *table = NULL;
2791 u32 rfpwr_offset;
2792 u8 pga_gain;
2793 int i;
2794
2795 table = b43_nphy_get_tx_gain_table(dev);
2453 b43_ntab_write_bulk(dev, B43_NTAB32(26, 192), 128, table); 2796 b43_ntab_write_bulk(dev, B43_NTAB32(26, 192), 128, table);
2454 b43_ntab_write_bulk(dev, B43_NTAB32(27, 192), 128, table); 2797 b43_ntab_write_bulk(dev, B43_NTAB32(27, 192), 128, table);
2455 2798
2456 if (phy->rev >= 3) { 2799 if (phy->rev >= 3) {
2457#if 0 2800#if 0
2458 nphy->gmval = (table[0] >> 16) & 0x7000; 2801 nphy->gmval = (table[0] >> 16) & 0x7000;
2802#endif
2459 2803
2460 for (i = 0; i < 128; i++) { 2804 for (i = 0; i < 128; i++) {
2461 pga_gain = (table[i] >> 24) & 0xF; 2805 pga_gain = (table[i] >> 24) & 0xF;
2462 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) 2806 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
2463 rfpwr_offset = b43_ntab_papd_pga_gain_delta_ipa_2g[pga_gain]; 2807 rfpwr_offset =
2808 b43_ntab_papd_pga_gain_delta_ipa_2g[pga_gain];
2464 else 2809 else
2465 rfpwr_offset = b43_ntab_papd_pga_gain_delta_ipa_5g[pga_gain]; 2810 rfpwr_offset =
2811 0; /* FIXME */
2466 b43_ntab_write(dev, B43_NTAB32(26, 576 + i), 2812 b43_ntab_write(dev, B43_NTAB32(26, 576 + i),
2467 rfpwr_offset); 2813 rfpwr_offset);
2468 b43_ntab_write(dev, B43_NTAB32(27, 576 + i), 2814 b43_ntab_write(dev, B43_NTAB32(27, 576 + i),
2469 rfpwr_offset); 2815 rfpwr_offset);
2470 } 2816 }
2471#endif
2472 } 2817 }
2473} 2818}
2474 2819
@@ -3139,32 +3484,13 @@ static struct nphy_txgains b43_nphy_get_tx_gains(struct b43_wldev *dev)
3139 B43_NPHY_TXPCTL_STAT_BIDX_SHIFT; 3484 B43_NPHY_TXPCTL_STAT_BIDX_SHIFT;
3140 3485
3141 for (i = 0; i < 2; ++i) { 3486 for (i = 0; i < 2; ++i) {
3487 table = b43_nphy_get_tx_gain_table(dev);
3142 if (dev->phy.rev >= 3) { 3488 if (dev->phy.rev >= 3) {
3143 enum ieee80211_band band =
3144 b43_current_band(dev->wl);
3145
3146 if (b43_nphy_ipa(dev)) {
3147 table = b43_nphy_get_ipa_gain_table(dev);
3148 } else {
3149 if (band == IEEE80211_BAND_5GHZ) {
3150 if (dev->phy.rev == 3)
3151 table = b43_ntab_tx_gain_rev3_5ghz;
3152 else if (dev->phy.rev == 4)
3153 table = b43_ntab_tx_gain_rev4_5ghz;
3154 else
3155 table = b43_ntab_tx_gain_rev5plus_5ghz;
3156 } else {
3157 table = b43_ntab_tx_gain_rev3plus_2ghz;
3158 }
3159 }
3160
3161 target.ipa[i] = (table[index[i]] >> 16) & 0xF; 3489 target.ipa[i] = (table[index[i]] >> 16) & 0xF;
3162 target.pad[i] = (table[index[i]] >> 20) & 0xF; 3490 target.pad[i] = (table[index[i]] >> 20) & 0xF;
3163 target.pga[i] = (table[index[i]] >> 24) & 0xF; 3491 target.pga[i] = (table[index[i]] >> 24) & 0xF;
3164 target.txgm[i] = (table[index[i]] >> 28) & 0xF; 3492 target.txgm[i] = (table[index[i]] >> 28) & 0xF;
3165 } else { 3493 } else {
3166 table = b43_ntab_tx_gain_rev0_1_2;
3167
3168 target.ipa[i] = (table[index[i]] >> 16) & 0x3; 3494 target.ipa[i] = (table[index[i]] >> 16) & 0x3;
3169 target.pad[i] = (table[index[i]] >> 18) & 0x3; 3495 target.pad[i] = (table[index[i]] >> 18) & 0x3;
3170 target.pga[i] = (table[index[i]] >> 20) & 0x7; 3496 target.pga[i] = (table[index[i]] >> 20) & 0x7;
@@ -3968,13 +4294,10 @@ static void b43_nphy_superswitch_init(struct b43_wldev *dev, bool init)
3968#endif 4294#endif
3969 } 4295 }
3970 4296
3971 b43_write32(dev, B43_MMIO_MACCTL, 4297 b43_maskset32(dev, B43_MMIO_MACCTL, ~B43_MACCTL_GPOUTSMSK, 0);
3972 b43_read32(dev, B43_MMIO_MACCTL) & 4298 b43_maskset16(dev, B43_MMIO_GPIO_MASK, ~0, 0xFC00);
3973 ~B43_MACCTL_GPOUTSMSK); 4299 b43_maskset16(dev, B43_MMIO_GPIO_CONTROL, (~0xFC00 & 0xFFFF),
3974 b43_write16(dev, B43_MMIO_GPIO_MASK, 4300 0);
3975 b43_read16(dev, B43_MMIO_GPIO_MASK) | 0xFC00);
3976 b43_write16(dev, B43_MMIO_GPIO_CONTROL,
3977 b43_read16(dev, B43_MMIO_GPIO_CONTROL) & ~0xFC00);
3978 4301
3979 if (init) { 4302 if (init) {
3980 b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_LO1, 0x2D8); 4303 b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_LO1, 0x2D8);
@@ -4110,7 +4433,7 @@ int b43_phy_initn(struct b43_wldev *dev)
4110 b43_nphy_tx_power_ctrl(dev, false); 4433 b43_nphy_tx_power_ctrl(dev, false);
4111 b43_nphy_tx_power_fix(dev); 4434 b43_nphy_tx_power_fix(dev);
4112 b43_nphy_tx_power_ctl_idle_tssi(dev); 4435 b43_nphy_tx_power_ctl_idle_tssi(dev);
4113 /* TODO N PHY TX Power Control Setup */ 4436 b43_nphy_tx_power_ctl_setup(dev);
4114 b43_nphy_tx_gain_table_upload(dev); 4437 b43_nphy_tx_gain_table_upload(dev);
4115 4438
4116 if (nphy->phyrxchain != 3) 4439 if (nphy->phyrxchain != 3)
@@ -4530,8 +4853,7 @@ static void b43_nphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
4530{ 4853{
4531 check_phyreg(dev, reg); 4854 check_phyreg(dev, reg);
4532 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg); 4855 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
4533 b43_write16(dev, B43_MMIO_PHY_DATA, 4856 b43_maskset16(dev, B43_MMIO_PHY_DATA, mask, set);
4534 (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
4535} 4857}
4536 4858
4537static u16 b43_nphy_op_radio_read(struct b43_wldev *dev, u16 reg) 4859static u16 b43_nphy_op_radio_read(struct b43_wldev *dev, u16 reg)
diff --git a/drivers/net/wireless/b43/phy_n.h b/drivers/net/wireless/b43/phy_n.h
index 5de8f74cc02f..fd12b386fea1 100644
--- a/drivers/net/wireless/b43/phy_n.h
+++ b/drivers/net/wireless/b43/phy_n.h
@@ -798,6 +798,7 @@ struct b43_phy_n {
798 bool txpwrctrl; 798 bool txpwrctrl;
799 bool pwg_gain_5ghz; 799 bool pwg_gain_5ghz;
800 u8 tx_pwr_idx[2]; 800 u8 tx_pwr_idx[2];
801 s8 tx_power_offset[101];
801 u16 adj_pwr_tbl[84]; 802 u16 adj_pwr_tbl[84];
802 u16 txcal_bbmult; 803 u16 txcal_bbmult;
803 u16 txiqlocal_bestc[11]; 804 u16 txiqlocal_bestc[11];
diff --git a/drivers/net/wireless/b43/tables_nphy.c b/drivers/net/wireless/b43/tables_nphy.c
index f7def13524dd..f0d8377429c6 100644
--- a/drivers/net/wireless/b43/tables_nphy.c
+++ b/drivers/net/wireless/b43/tables_nphy.c
@@ -2214,7 +2214,7 @@ static const u16 b43_ntab_antswctl2g_r3[4][32] = {
2214}; 2214};
2215 2215
2216/* TX gain tables */ 2216/* TX gain tables */
2217const u32 b43_ntab_tx_gain_rev0_1_2[] = { 2217static const u32 b43_ntab_tx_gain_rev0_1_2[] = {
2218 0x03cc2b44, 0x03cc2b42, 0x03cc2a44, 0x03cc2a42, 2218 0x03cc2b44, 0x03cc2b42, 0x03cc2a44, 0x03cc2a42,
2219 0x03cc2944, 0x03c82b44, 0x03c82b42, 0x03c82a44, 2219 0x03cc2944, 0x03c82b44, 0x03c82b42, 0x03c82a44,
2220 0x03c82a42, 0x03c82944, 0x03c82942, 0x03c82844, 2220 0x03c82a42, 0x03c82944, 0x03c82942, 0x03c82844,
@@ -2249,7 +2249,7 @@ const u32 b43_ntab_tx_gain_rev0_1_2[] = {
2249 0x03801442, 0x03801344, 0x03801342, 0x00002b00, 2249 0x03801442, 0x03801344, 0x03801342, 0x00002b00,
2250}; 2250};
2251 2251
2252const u32 b43_ntab_tx_gain_rev3plus_2ghz[] = { 2252static const u32 b43_ntab_tx_gain_rev3plus_2ghz[] = {
2253 0x1f410044, 0x1f410042, 0x1f410040, 0x1f41003e, 2253 0x1f410044, 0x1f410042, 0x1f410040, 0x1f41003e,
2254 0x1f41003c, 0x1f41003b, 0x1f410039, 0x1f410037, 2254 0x1f41003c, 0x1f41003b, 0x1f410039, 0x1f410037,
2255 0x1e410044, 0x1e410042, 0x1e410040, 0x1e41003e, 2255 0x1e410044, 0x1e410042, 0x1e410040, 0x1e41003e,
@@ -2284,7 +2284,7 @@ const u32 b43_ntab_tx_gain_rev3plus_2ghz[] = {
2284 0x1041003c, 0x1041003b, 0x10410039, 0x10410037, 2284 0x1041003c, 0x1041003b, 0x10410039, 0x10410037,
2285}; 2285};
2286 2286
2287const u32 b43_ntab_tx_gain_rev3_5ghz[] = { 2287static const u32 b43_ntab_tx_gain_rev3_5ghz[] = {
2288 0xcff70044, 0xcff70042, 0xcff70040, 0xcff7003e, 2288 0xcff70044, 0xcff70042, 0xcff70040, 0xcff7003e,
2289 0xcff7003c, 0xcff7003b, 0xcff70039, 0xcff70037, 2289 0xcff7003c, 0xcff7003b, 0xcff70039, 0xcff70037,
2290 0xcef70044, 0xcef70042, 0xcef70040, 0xcef7003e, 2290 0xcef70044, 0xcef70042, 0xcef70040, 0xcef7003e,
@@ -2319,7 +2319,7 @@ const u32 b43_ntab_tx_gain_rev3_5ghz[] = {
2319 0xc0f7003c, 0xc0f7003b, 0xc0f70039, 0xc0f70037, 2319 0xc0f7003c, 0xc0f7003b, 0xc0f70039, 0xc0f70037,
2320}; 2320};
2321 2321
2322const u32 b43_ntab_tx_gain_rev4_5ghz[] = { 2322static const u32 b43_ntab_tx_gain_rev4_5ghz[] = {
2323 0x2ff20044, 0x2ff20042, 0x2ff20040, 0x2ff2003e, 2323 0x2ff20044, 0x2ff20042, 0x2ff20040, 0x2ff2003e,
2324 0x2ff2003c, 0x2ff2003b, 0x2ff20039, 0x2ff20037, 2324 0x2ff2003c, 0x2ff2003b, 0x2ff20039, 0x2ff20037,
2325 0x2ef20044, 0x2ef20042, 0x2ef20040, 0x2ef2003e, 2325 0x2ef20044, 0x2ef20042, 0x2ef20040, 0x2ef2003e,
@@ -2354,7 +2354,7 @@ const u32 b43_ntab_tx_gain_rev4_5ghz[] = {
2354 0x20d2003a, 0x20d20038, 0x20d20036, 0x20d20034, 2354 0x20d2003a, 0x20d20038, 0x20d20036, 0x20d20034,
2355}; 2355};
2356 2356
2357const u32 b43_ntab_tx_gain_rev5plus_5ghz[] = { 2357static const u32 b43_ntab_tx_gain_rev5plus_5ghz[] = {
2358 0x0f62004a, 0x0f620048, 0x0f620046, 0x0f620044, 2358 0x0f62004a, 0x0f620048, 0x0f620046, 0x0f620044,
2359 0x0f620042, 0x0f620040, 0x0f62003e, 0x0f62003c, 2359 0x0f620042, 0x0f620040, 0x0f62003e, 0x0f62003c,
2360 0x0e620044, 0x0e620042, 0x0e620040, 0x0e62003e, 2360 0x0e620044, 0x0e620042, 0x0e620040, 0x0e62003e,
@@ -2389,7 +2389,7 @@ const u32 b43_ntab_tx_gain_rev5plus_5ghz[] = {
2389 0x0062003b, 0x00620039, 0x00620037, 0x00620035, 2389 0x0062003b, 0x00620039, 0x00620037, 0x00620035,
2390}; 2390};
2391 2391
2392const u32 txpwrctrl_tx_gain_ipa[] = { 2392static const u32 txpwrctrl_tx_gain_ipa[] = {
2393 0x5ff7002d, 0x5ff7002b, 0x5ff7002a, 0x5ff70029, 2393 0x5ff7002d, 0x5ff7002b, 0x5ff7002a, 0x5ff70029,
2394 0x5ff70028, 0x5ff70027, 0x5ff70026, 0x5ff70025, 2394 0x5ff70028, 0x5ff70027, 0x5ff70026, 0x5ff70025,
2395 0x5ef7002d, 0x5ef7002b, 0x5ef7002a, 0x5ef70029, 2395 0x5ef7002d, 0x5ef7002b, 0x5ef7002a, 0x5ef70029,
@@ -2424,7 +2424,7 @@ const u32 txpwrctrl_tx_gain_ipa[] = {
2424 0x50f70028, 0x50f70027, 0x50f70026, 0x50f70025, 2424 0x50f70028, 0x50f70027, 0x50f70026, 0x50f70025,
2425}; 2425};
2426 2426
2427const u32 txpwrctrl_tx_gain_ipa_rev5[] = { 2427static const u32 txpwrctrl_tx_gain_ipa_rev5[] = {
2428 0x1ff7002d, 0x1ff7002b, 0x1ff7002a, 0x1ff70029, 2428 0x1ff7002d, 0x1ff7002b, 0x1ff7002a, 0x1ff70029,
2429 0x1ff70028, 0x1ff70027, 0x1ff70026, 0x1ff70025, 2429 0x1ff70028, 0x1ff70027, 0x1ff70026, 0x1ff70025,
2430 0x1ef7002d, 0x1ef7002b, 0x1ef7002a, 0x1ef70029, 2430 0x1ef7002d, 0x1ef7002b, 0x1ef7002a, 0x1ef70029,
@@ -2459,7 +2459,7 @@ const u32 txpwrctrl_tx_gain_ipa_rev5[] = {
2459 0x10f70028, 0x10f70027, 0x10f70026, 0x10f70025, 2459 0x10f70028, 0x10f70027, 0x10f70026, 0x10f70025,
2460}; 2460};
2461 2461
2462const u32 txpwrctrl_tx_gain_ipa_rev6[] = { 2462static const u32 txpwrctrl_tx_gain_ipa_rev6[] = {
2463 0x0ff7002d, 0x0ff7002b, 0x0ff7002a, 0x0ff70029, 2463 0x0ff7002d, 0x0ff7002b, 0x0ff7002a, 0x0ff70029,
2464 0x0ff70028, 0x0ff70027, 0x0ff70026, 0x0ff70025, 2464 0x0ff70028, 0x0ff70027, 0x0ff70026, 0x0ff70025,
2465 0x0ef7002d, 0x0ef7002b, 0x0ef7002a, 0x0ef70029, 2465 0x0ef7002d, 0x0ef7002b, 0x0ef7002a, 0x0ef70029,
@@ -2494,7 +2494,7 @@ const u32 txpwrctrl_tx_gain_ipa_rev6[] = {
2494 0x00f70028, 0x00f70027, 0x00f70026, 0x00f70025, 2494 0x00f70028, 0x00f70027, 0x00f70026, 0x00f70025,
2495}; 2495};
2496 2496
2497const u32 txpwrctrl_tx_gain_ipa_5g[] = { 2497static const u32 txpwrctrl_tx_gain_ipa_5g[] = {
2498 0x7ff70035, 0x7ff70033, 0x7ff70032, 0x7ff70031, 2498 0x7ff70035, 0x7ff70033, 0x7ff70032, 0x7ff70031,
2499 0x7ff7002f, 0x7ff7002e, 0x7ff7002d, 0x7ff7002b, 2499 0x7ff7002f, 0x7ff7002e, 0x7ff7002d, 0x7ff7002b,
2500 0x7ff7002a, 0x7ff70029, 0x7ff70028, 0x7ff70027, 2500 0x7ff7002a, 0x7ff70029, 0x7ff70028, 0x7ff70027,
@@ -2529,6 +2529,11 @@ const u32 txpwrctrl_tx_gain_ipa_5g[] = {
2529 0x70f70021, 0x70f70020, 0x70f70020, 0x70f7001f, 2529 0x70f70021, 0x70f70020, 0x70f70020, 0x70f7001f,
2530}; 2530};
2531 2531
2532const s8 b43_ntab_papd_pga_gain_delta_ipa_2g[] = {
2533 -114, -108, -98, -91, -84, -78, -70, -62,
2534 -54, -46, -39, -31, -23, -15, -8, 0
2535};
2536
2532const u16 tbl_iqcal_gainparams[2][9][8] = { 2537const u16 tbl_iqcal_gainparams[2][9][8] = {
2533 { 2538 {
2534 { 0x000, 0, 0, 2, 0x69, 0x69, 0x69, 0x69 }, 2539 { 0x000, 0, 0, 2, 0x69, 0x69, 0x69, 0x69 },
@@ -2739,11 +2744,11 @@ const struct nphy_rf_control_override_rev3 tbl_rf_control_override_rev3[] = {
2739 { 0x0001, 0, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0002 (fls 2) */ 2744 { 0x0001, 0, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0002 (fls 2) */
2740 { 0x0002, 1, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0004 (fls 3) */ 2745 { 0x0002, 1, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0004 (fls 3) */
2741 { 0x0004, 2, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0008 (fls 4) */ 2746 { 0x0004, 2, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0008 (fls 4) */
2742 { 0x0016, 4, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0010 (fls 5) */ 2747 { 0x0010, 4, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0010 (fls 5) */
2743 { 0x0020, 5, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0020 (fls 6) */ 2748 { 0x0020, 5, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0020 (fls 6) */
2744 { 0x0040, 6, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0040 (fls 7) */ 2749 { 0x0040, 6, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0040 (fls 7) */
2745 { 0x0080, 6, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0080 (fls 8) */ 2750 { 0x0080, 7, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0080 (fls 8) */
2746 { 0x0100, 7, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0100 (fls 9) */ 2751 { 0x0100, 8, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0100 (fls 9) */
2747 { 0x0007, 0, 0xE7, 0xF8, 0xEC, 0xFA }, /* field == 0x0200 (fls 10) */ 2752 { 0x0007, 0, 0xE7, 0xF8, 0xEC, 0xFA }, /* field == 0x0200 (fls 10) */
2748 { 0x0070, 4, 0xE7, 0xF8, 0xEC, 0xFA }, /* field == 0x0400 (fls 11) */ 2753 { 0x0070, 4, 0xE7, 0xF8, 0xEC, 0xFA }, /* field == 0x0400 (fls 11) */
2749 { 0xE000, 13, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0800 (fls 12) */ 2754 { 0xE000, 13, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0800 (fls 12) */
@@ -3126,6 +3131,53 @@ void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev)
3126 B43_WARN_ON(1); 3131 B43_WARN_ON(1);
3127} 3132}
3128 3133
3134/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetIpaGainTbl */
3135static const u32 *b43_nphy_get_ipa_gain_table(struct b43_wldev *dev)
3136{
3137 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
3138 if (dev->phy.rev >= 6) {
3139 if (dev->dev->chip_id == 47162)
3140 return txpwrctrl_tx_gain_ipa_rev5;
3141 return txpwrctrl_tx_gain_ipa_rev6;
3142 } else if (dev->phy.rev >= 5) {
3143 return txpwrctrl_tx_gain_ipa_rev5;
3144 } else {
3145 return txpwrctrl_tx_gain_ipa;
3146 }
3147 } else {
3148 return txpwrctrl_tx_gain_ipa_5g;
3149 }
3150}
3151
3152const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev)
3153{
3154 enum ieee80211_band band = b43_current_band(dev->wl);
3155 struct ssb_sprom *sprom = dev->dev->bus_sprom;
3156
3157 if (dev->phy.rev < 3)
3158 return b43_ntab_tx_gain_rev0_1_2;
3159
3160 /* rev 3+ */
3161 if ((dev->phy.n->ipa2g_on && band == IEEE80211_BAND_2GHZ) ||
3162 (dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ)) {
3163 return b43_nphy_get_ipa_gain_table(dev);
3164 } else if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) {
3165 if (dev->phy.rev == 3)
3166 return b43_ntab_tx_gain_rev3_5ghz;
3167 if (dev->phy.rev == 4)
3168 return sprom->fem.ghz5.extpa_gain == 3 ?
3169 b43_ntab_tx_gain_rev4_5ghz :
3170 b43_ntab_tx_gain_rev4_5ghz; /* FIXME */
3171 else
3172 return b43_ntab_tx_gain_rev5plus_5ghz;
3173 } else {
3174 if (dev->phy.rev >= 5 && sprom->fem.ghz5.extpa_gain == 3)
3175 return b43_ntab_tx_gain_rev3plus_2ghz; /* FIXME */
3176 else
3177 return b43_ntab_tx_gain_rev3plus_2ghz;
3178 }
3179}
3180
3129struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent( 3181struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent(
3130 struct b43_wldev *dev, bool ghz5, bool ext_lna) 3182 struct b43_wldev *dev, bool ghz5, bool ext_lna)
3131{ 3183{
diff --git a/drivers/net/wireless/b43/tables_nphy.h b/drivers/net/wireless/b43/tables_nphy.h
index 97038c481930..f348953c0230 100644
--- a/drivers/net/wireless/b43/tables_nphy.h
+++ b/drivers/net/wireless/b43/tables_nphy.h
@@ -177,16 +177,10 @@ void b43_ntab_write_bulk(struct b43_wldev *dev, u32 offset,
177void b43_nphy_rev0_1_2_tables_init(struct b43_wldev *dev); 177void b43_nphy_rev0_1_2_tables_init(struct b43_wldev *dev);
178void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev); 178void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev);
179 179
180extern const u32 b43_ntab_tx_gain_rev0_1_2[]; 180const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev);
181extern const u32 b43_ntab_tx_gain_rev3plus_2ghz[]; 181
182extern const u32 b43_ntab_tx_gain_rev3_5ghz[]; 182extern const s8 b43_ntab_papd_pga_gain_delta_ipa_2g[];
183extern const u32 b43_ntab_tx_gain_rev4_5ghz[]; 183
184extern const u32 b43_ntab_tx_gain_rev5plus_5ghz[];
185
186extern const u32 txpwrctrl_tx_gain_ipa[];
187extern const u32 txpwrctrl_tx_gain_ipa_rev5[];
188extern const u32 txpwrctrl_tx_gain_ipa_rev6[];
189extern const u32 txpwrctrl_tx_gain_ipa_5g[];
190extern const u16 tbl_iqcal_gainparams[2][9][8]; 184extern const u16 tbl_iqcal_gainparams[2][9][8];
191extern const struct nphy_txiqcal_ladder ladder_lo[]; 185extern const struct nphy_txiqcal_ladder ladder_lo[];
192extern const struct nphy_txiqcal_ladder ladder_iq[]; 186extern const struct nphy_txiqcal_ladder ladder_iq[];
diff --git a/drivers/net/wireless/brcm80211/Makefile b/drivers/net/wireless/brcm80211/Makefile
index f41c047eca82..b987920e982e 100644
--- a/drivers/net/wireless/brcm80211/Makefile
+++ b/drivers/net/wireless/brcm80211/Makefile
@@ -16,7 +16,7 @@
16# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 17
18# common flags 18# common flags
19subdir-ccflags-$(CONFIG_BRCMDBG) += -DBCMDBG 19subdir-ccflags-$(CONFIG_BRCMDBG) += -DDEBUG
20 20
21obj-$(CONFIG_BRCMUTIL) += brcmutil/ 21obj-$(CONFIG_BRCMUTIL) += brcmutil/
22obj-$(CONFIG_BRCMFMAC) += brcmfmac/ 22obj-$(CONFIG_BRCMFMAC) += brcmfmac/
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
index 4bc8d251acf8..e925290b432b 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
@@ -15,6 +15,8 @@
15 */ 15 */
16/* ****************** SDIO CARD Interface Functions **************************/ 16/* ****************** SDIO CARD Interface Functions **************************/
17 17
18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19
18#include <linux/types.h> 20#include <linux/types.h>
19#include <linux/netdevice.h> 21#include <linux/netdevice.h>
20#include <linux/export.h> 22#include <linux/export.h>
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
index 9b8c0ed833d4..ac71adeece51 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
@@ -13,6 +13,9 @@
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
16#include <linux/types.h> 19#include <linux/types.h>
17#include <linux/netdevice.h> 20#include <linux/netdevice.h>
18#include <linux/mmc/sdio.h> 21#include <linux/mmc/sdio.h>
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
index e58ea40a75b0..07686a748d3c 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h
@@ -644,9 +644,9 @@ extern char *brcmf_ifname(struct brcmf_pub *drvr, int idx);
644extern int brcmf_proto_cdc_query_dcmd(struct brcmf_pub *drvr, int ifidx, 644extern int brcmf_proto_cdc_query_dcmd(struct brcmf_pub *drvr, int ifidx,
645 uint cmd, void *buf, uint len); 645 uint cmd, void *buf, uint len);
646 646
647#ifdef BCMDBG 647#ifdef DEBUG
648extern int brcmf_write_to_file(struct brcmf_pub *drvr, const u8 *buf, int size); 648extern int brcmf_write_to_file(struct brcmf_pub *drvr, const u8 *buf, int size);
649#endif /* BCMDBG */ 649#endif /* DEBUG */
650 650
651extern int brcmf_ifname2idx(struct brcmf_pub *drvr, char *name); 651extern int brcmf_ifname2idx(struct brcmf_pub *drvr, char *name);
652extern int brcmf_c_host_event(struct brcmf_pub *drvr, int *idx, 652extern int brcmf_c_host_event(struct brcmf_pub *drvr, int *idx,
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c
index ac8d1f437888..b3e3b7f25d82 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c
@@ -19,6 +19,8 @@
19 * For certain dcmd codes, the dongle interprets string data from the host. 19 * For certain dcmd codes, the dongle interprets string data from the host.
20 ******************************************************************************/ 20 ******************************************************************************/
21 21
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23
22#include <linux/types.h> 24#include <linux/types.h>
23#include <linux/netdevice.h> 25#include <linux/netdevice.h>
24#include <linux/sched.h> 26#include <linux/sched.h>
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c
index a51d8f5d36fc..4187435220f3 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c
@@ -13,6 +13,9 @@
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
16#include <linux/kernel.h> 19#include <linux/kernel.h>
17#include <linux/string.h> 20#include <linux/string.h>
18#include <linux/sched.h> 21#include <linux/sched.h>
@@ -38,7 +41,7 @@
38#define BRCMF_PKT_FILTER_PATTERN_FIXED_LEN \ 41#define BRCMF_PKT_FILTER_PATTERN_FIXED_LEN \
39 offsetof(struct brcmf_pkt_filter_pattern_le, mask_and_pattern) 42 offsetof(struct brcmf_pkt_filter_pattern_le, mask_and_pattern)
40 43
41#ifdef BCMDBG 44#ifdef DEBUG
42static const char brcmf_version[] = 45static const char brcmf_version[] =
43 "Dongle Host Driver, version " BRCMF_VERSION_STR "\nCompiled on " 46 "Dongle Host Driver, version " BRCMF_VERSION_STR "\nCompiled on "
44 __DATE__ " at " __TIME__; 47 __DATE__ " at " __TIME__;
@@ -133,7 +136,7 @@ bool brcmf_c_prec_enq(struct device *dev, struct pktq *q,
133 return p != NULL; 136 return p != NULL;
134} 137}
135 138
136#ifdef BCMDBG 139#ifdef DEBUG
137static void 140static void
138brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data) 141brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data)
139{ 142{
@@ -399,10 +402,10 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data)
399 p = (char *)&buf[sizeof(struct msgtrace_hdr)]; 402 p = (char *)&buf[sizeof(struct msgtrace_hdr)];
400 while ((s = strstr(p, "\n")) != NULL) { 403 while ((s = strstr(p, "\n")) != NULL) {
401 *s = '\0'; 404 *s = '\0';
402 printk(KERN_DEBUG"%s\n", p); 405 pr_debug("%s\n", p);
403 p = s + 1; 406 p = s + 1;
404 } 407 }
405 printk(KERN_DEBUG "%s\n", p); 408 pr_debug("%s\n", p);
406 409
407 /* Reset datalen to avoid display below */ 410 /* Reset datalen to avoid display below */
408 datalen = 0; 411 datalen = 0;
@@ -430,7 +433,7 @@ brcmf_c_show_host_event(struct brcmf_event_msg *event, void *event_data)
430 brcmf_dbg(EVENT, "\n"); 433 brcmf_dbg(EVENT, "\n");
431 } 434 }
432} 435}
433#endif /* BCMDBG */ 436#endif /* DEBUG */
434 437
435int 438int
436brcmf_c_host_event(struct brcmf_pub *drvr, int *ifidx, void *pktdata, 439brcmf_c_host_event(struct brcmf_pub *drvr, int *ifidx, void *pktdata,
@@ -518,9 +521,9 @@ brcmf_c_host_event(struct brcmf_pub *drvr, int *ifidx, void *pktdata,
518 break; 521 break;
519 } 522 }
520 523
521#ifdef BCMDBG 524#ifdef DEBUG
522 brcmf_c_show_host_event(event, event_data); 525 brcmf_c_show_host_event(event, event_data);
523#endif /* BCMDBG */ 526#endif /* DEBUG */
524 527
525 return 0; 528 return 0;
526} 529}
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h
index bb26ee36bc68..a2c4576cf9ff 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_dbg.h
@@ -32,20 +32,20 @@
32#define BRCMF_BTA_VAL 0x1000 32#define BRCMF_BTA_VAL 0x1000
33#define BRCMF_ISCAN_VAL 0x2000 33#define BRCMF_ISCAN_VAL 0x2000
34 34
35#if defined(BCMDBG) 35#if defined(DEBUG)
36 36
37#define brcmf_dbg(level, fmt, ...) \ 37#define brcmf_dbg(level, fmt, ...) \
38do { \ 38do { \
39 if (BRCMF_ERROR_VAL == BRCMF_##level##_VAL) { \ 39 if (BRCMF_ERROR_VAL == BRCMF_##level##_VAL) { \
40 if (brcmf_msg_level & BRCMF_##level##_VAL) { \ 40 if (brcmf_msg_level & BRCMF_##level##_VAL) { \
41 if (net_ratelimit()) \ 41 if (net_ratelimit()) \
42 printk(KERN_DEBUG "%s: " fmt, \ 42 pr_debug("%s: " fmt, \
43 __func__, ##__VA_ARGS__); \ 43 __func__, ##__VA_ARGS__); \
44 } \ 44 } \
45 } else { \ 45 } else { \
46 if (brcmf_msg_level & BRCMF_##level##_VAL) { \ 46 if (brcmf_msg_level & BRCMF_##level##_VAL) { \
47 printk(KERN_DEBUG "%s: " fmt, \ 47 pr_debug("%s: " fmt, \
48 __func__, ##__VA_ARGS__); \ 48 __func__, ##__VA_ARGS__); \
49 } \ 49 } \
50 } \ 50 } \
51} while (0) 51} while (0)
@@ -56,7 +56,7 @@ do { \
56#define BRCMF_BYTES_ON() (brcmf_msg_level & BRCMF_BYTES_VAL) 56#define BRCMF_BYTES_ON() (brcmf_msg_level & BRCMF_BYTES_VAL)
57#define BRCMF_GLOM_ON() (brcmf_msg_level & BRCMF_GLOM_VAL) 57#define BRCMF_GLOM_ON() (brcmf_msg_level & BRCMF_GLOM_VAL)
58 58
59#else /* (defined BCMDBG) || (defined BCMDBG) */ 59#else /* (defined DEBUG) || (defined DEBUG) */
60 60
61#define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__) 61#define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
62 62
@@ -66,7 +66,13 @@ do { \
66#define BRCMF_BYTES_ON() 0 66#define BRCMF_BYTES_ON() 0
67#define BRCMF_GLOM_ON() 0 67#define BRCMF_GLOM_ON() 0
68 68
69#endif /* defined(BCMDBG) */ 69#endif /* defined(DEBUG) */
70
71#define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \
72do { \
73 if (test) \
74 brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__); \
75} while (0)
70 76
71extern int brcmf_msg_level; 77extern int brcmf_msg_level;
72 78
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
index eb9eb766ac27..db2df1f1e6b2 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
@@ -14,6 +14,8 @@
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
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/kthread.h> 21#include <linux/kthread.h>
@@ -590,8 +592,8 @@ static void brcmf_ethtool_get_drvinfo(struct net_device *ndev,
590 sprintf(info->bus_info, "%s", dev_name(drvr->dev)); 592 sprintf(info->bus_info, "%s", dev_name(drvr->dev));
591} 593}
592 594
593static struct ethtool_ops brcmf_ethtool_ops = { 595static const struct ethtool_ops brcmf_ethtool_ops = {
594 .get_drvinfo = brcmf_ethtool_get_drvinfo 596 .get_drvinfo = brcmf_ethtool_get_drvinfo,
595}; 597};
596 598
597static int brcmf_ethtool(struct brcmf_pub *drvr, void __user *uaddr) 599static int brcmf_ethtool(struct brcmf_pub *drvr, void __user *uaddr)
@@ -1146,7 +1148,7 @@ int brcmf_netdev_wait_pend8021x(struct net_device *ndev)
1146 return pend; 1148 return pend;
1147} 1149}
1148 1150
1149#ifdef BCMDBG 1151#ifdef DEBUG
1150int brcmf_write_to_file(struct brcmf_pub *drvr, const u8 *buf, int size) 1152int brcmf_write_to_file(struct brcmf_pub *drvr, const u8 *buf, int size)
1151{ 1153{
1152 int ret = 0; 1154 int ret = 0;
@@ -1180,4 +1182,4 @@ exit:
1180 1182
1181 return ret; 1183 return ret;
1182} 1184}
1183#endif /* BCMDBG */ 1185#endif /* DEBUG */
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index f7eeee1dcdb6..6e4b5e85a099 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -14,6 +14,8 @@
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
17#include <linux/types.h> 19#include <linux/types.h>
18#include <linux/kernel.h> 20#include <linux/kernel.h>
19#include <linux/kthread.h> 21#include <linux/kthread.h>
@@ -40,7 +42,7 @@
40 42
41#define DCMD_RESP_TIMEOUT 2000 /* In milli second */ 43#define DCMD_RESP_TIMEOUT 2000 /* In milli second */
42 44
43#ifdef BCMDBG 45#ifdef DEBUG
44 46
45#define BRCMF_TRAP_INFO_SIZE 80 47#define BRCMF_TRAP_INFO_SIZE 80
46 48
@@ -84,7 +86,7 @@ struct rte_console {
84 char cbuf[CBUF_LEN]; 86 char cbuf[CBUF_LEN];
85}; 87};
86 88
87#endif /* BCMDBG */ 89#endif /* DEBUG */
88#include <chipcommon.h> 90#include <chipcommon.h>
89 91
90#include "dhd_bus.h" 92#include "dhd_bus.h"
@@ -416,7 +418,7 @@ struct sdpcmd_regs {
416 u16 PAD[0x80]; 418 u16 PAD[0x80];
417}; 419};
418 420
419#ifdef BCMDBG 421#ifdef DEBUG
420/* Device console log buffer state */ 422/* Device console log buffer state */
421struct brcmf_console { 423struct brcmf_console {
422 uint count; /* Poll interval msec counter */ 424 uint count; /* Poll interval msec counter */
@@ -426,7 +428,7 @@ struct brcmf_console {
426 u8 *buf; /* Log buffer (host copy) */ 428 u8 *buf; /* Log buffer (host copy) */
427 uint last; /* Last buffer read index */ 429 uint last; /* Last buffer read index */
428}; 430};
429#endif /* BCMDBG */ 431#endif /* DEBUG */
430 432
431struct sdpcm_shared { 433struct sdpcm_shared {
432 u32 flags; 434 u32 flags;
@@ -507,11 +509,11 @@ struct brcmf_sdio {
507 uint polltick; /* Tick counter */ 509 uint polltick; /* Tick counter */
508 uint pollcnt; /* Count of active polls */ 510 uint pollcnt; /* Count of active polls */
509 511
510#ifdef BCMDBG 512#ifdef DEBUG
511 uint console_interval; 513 uint console_interval;
512 struct brcmf_console console; /* Console output polling support */ 514 struct brcmf_console console; /* Console output polling support */
513 uint console_addr; /* Console address from shared struct */ 515 uint console_addr; /* Console address from shared struct */
514#endif /* BCMDBG */ 516#endif /* DEBUG */
515 517
516 uint regfails; /* Count of R_REG failures */ 518 uint regfails; /* Count of R_REG failures */
517 519
@@ -587,10 +589,10 @@ struct brcmf_sdio {
587#define CLK_PENDING 2 /* Not used yet */ 589#define CLK_PENDING 2 /* Not used yet */
588#define CLK_AVAIL 3 590#define CLK_AVAIL 3
589 591
590#ifdef BCMDBG 592#ifdef DEBUG
591static int qcount[NUMPRIO]; 593static int qcount[NUMPRIO];
592static int tx_packets[NUMPRIO]; 594static int tx_packets[NUMPRIO];
593#endif /* BCMDBG */ 595#endif /* DEBUG */
594 596
595#define SDIO_DRIVE_STRENGTH 6 /* in milliamps */ 597#define SDIO_DRIVE_STRENGTH 6 /* in milliamps */
596 598
@@ -764,12 +766,12 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok)
764 bus->clkstate = CLK_AVAIL; 766 bus->clkstate = CLK_AVAIL;
765 brcmf_dbg(INFO, "CLKCTL: turned ON\n"); 767 brcmf_dbg(INFO, "CLKCTL: turned ON\n");
766 768
767#if defined(BCMDBG) 769#if defined(DEBUG)
768 if (bus->alp_only != true) { 770 if (bus->alp_only != true) {
769 if (SBSDIO_ALPONLY(clkctl)) 771 if (SBSDIO_ALPONLY(clkctl))
770 brcmf_dbg(ERROR, "HT Clock should be on\n"); 772 brcmf_dbg(ERROR, "HT Clock should be on\n");
771 } 773 }
772#endif /* defined (BCMDBG) */ 774#endif /* defined (DEBUG) */
773 775
774 bus->activity = true; 776 bus->activity = true;
775 } else { 777 } else {
@@ -814,9 +816,9 @@ static int brcmf_sdbrcm_sdclk(struct brcmf_sdio *bus, bool on)
814/* Transition SD and backplane clock readiness */ 816/* Transition SD and backplane clock readiness */
815static int brcmf_sdbrcm_clkctl(struct brcmf_sdio *bus, uint target, bool pendok) 817static int brcmf_sdbrcm_clkctl(struct brcmf_sdio *bus, uint target, bool pendok)
816{ 818{
817#ifdef BCMDBG 819#ifdef DEBUG
818 uint oldstate = bus->clkstate; 820 uint oldstate = bus->clkstate;
819#endif /* BCMDBG */ 821#endif /* DEBUG */
820 822
821 brcmf_dbg(TRACE, "Enter\n"); 823 brcmf_dbg(TRACE, "Enter\n");
822 824
@@ -861,9 +863,9 @@ static int brcmf_sdbrcm_clkctl(struct brcmf_sdio *bus, uint target, bool pendok)
861 brcmf_sdbrcm_wd_timer(bus, 0); 863 brcmf_sdbrcm_wd_timer(bus, 0);
862 break; 864 break;
863 } 865 }
864#ifdef BCMDBG 866#ifdef DEBUG
865 brcmf_dbg(INFO, "%d -> %d\n", oldstate, bus->clkstate); 867 brcmf_dbg(INFO, "%d -> %d\n", oldstate, bus->clkstate);
866#endif /* BCMDBG */ 868#endif /* DEBUG */
867 869
868 return 0; 870 return 0;
869} 871}
@@ -1279,13 +1281,10 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq)
1279 } 1281 }
1280 return 0; 1282 return 0;
1281 } 1283 }
1282#ifdef BCMDBG 1284
1283 if (BRCMF_GLOM_ON()) { 1285 brcmf_dbg_hex_dump(BRCMF_GLOM_ON(),
1284 printk(KERN_DEBUG "SUPERFRAME:\n"); 1286 pfirst->data, min_t(int, pfirst->len, 48),
1285 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, 1287 "SUPERFRAME:\n");
1286 pfirst->data, min_t(int, pfirst->len, 48));
1287 }
1288#endif
1289 1288
1290 /* Validate the superframe header */ 1289 /* Validate the superframe header */
1291 dptr = (u8 *) (pfirst->data); 1290 dptr = (u8 *) (pfirst->data);
@@ -1362,13 +1361,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq)
1362 check = get_unaligned_le16(dptr + sizeof(u16)); 1361 check = get_unaligned_le16(dptr + sizeof(u16));
1363 chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]); 1362 chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]);
1364 doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); 1363 doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]);
1365#ifdef BCMDBG 1364 brcmf_dbg_hex_dump(BRCMF_GLOM_ON(),
1366 if (BRCMF_GLOM_ON()) { 1365 dptr, 32, "subframe:\n");
1367 printk(KERN_DEBUG "subframe:\n");
1368 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
1369 dptr, 32);
1370 }
1371#endif
1372 1366
1373 if ((u16)~(sublen ^ check)) { 1367 if ((u16)~(sublen ^ check)) {
1374 brcmf_dbg(ERROR, "(subframe %d): HW hdr error: len/check 0x%04x/0x%04x\n", 1368 brcmf_dbg(ERROR, "(subframe %d): HW hdr error: len/check 0x%04x/0x%04x\n",
@@ -1433,13 +1427,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq)
1433 } 1427 }
1434 rxseq++; 1428 rxseq++;
1435 1429
1436#ifdef BCMDBG 1430 brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_DATA_ON(),
1437 if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { 1431 dptr, dlen, "Rx Subframe Data:\n");
1438 printk(KERN_DEBUG "Rx Subframe Data:\n");
1439 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
1440 dptr, dlen);
1441 }
1442#endif
1443 1432
1444 __skb_trim(pfirst, sublen); 1433 __skb_trim(pfirst, sublen);
1445 skb_pull(pfirst, doff); 1434 skb_pull(pfirst, doff);
@@ -1457,17 +1446,13 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq)
1457 continue; 1446 continue;
1458 } 1447 }
1459 1448
1460#ifdef BCMDBG 1449 brcmf_dbg_hex_dump(BRCMF_GLOM_ON(),
1461 if (BRCMF_GLOM_ON()) { 1450 pfirst->data,
1462 brcmf_dbg(GLOM, "subframe %d to stack, %p (%p/%d) nxt/lnk %p/%p\n", 1451 min_t(int, pfirst->len, 32),
1463 bus->glom.qlen, pfirst, pfirst->data, 1452 "subframe %d to stack, %p (%p/%d) nxt/lnk %p/%p\n",
1464 pfirst->len, pfirst->next, 1453 bus->glom.qlen, pfirst, pfirst->data,
1465 pfirst->prev); 1454 pfirst->len, pfirst->next,
1466 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, 1455 pfirst->prev);
1467 pfirst->data,
1468 min_t(int, pfirst->len, 32));
1469 }
1470#endif /* BCMDBG */
1471 } 1456 }
1472 /* sent any remaining packets up */ 1457 /* sent any remaining packets up */
1473 if (bus->glom.qlen) { 1458 if (bus->glom.qlen) {
@@ -1584,12 +1569,8 @@ brcmf_sdbrcm_read_control(struct brcmf_sdio *bus, u8 *hdr, uint len, uint doff)
1584 1569
1585gotpkt: 1570gotpkt:
1586 1571
1587#ifdef BCMDBG 1572 brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_CTL_ON(),
1588 if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { 1573 bus->rxctl, len, "RxCtrl:\n");
1589 printk(KERN_DEBUG "RxCtrl:\n");
1590 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, bus->rxctl, len);
1591 }
1592#endif
1593 1574
1594 /* Point to valid data and indicate its length */ 1575 /* Point to valid data and indicate its length */
1595 bus->rxctl += doff; 1576 bus->rxctl += doff;
@@ -1818,17 +1799,13 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished)
1818 } 1799 }
1819 bus->tx_max = txmax; 1800 bus->tx_max = txmax;
1820 1801
1821#ifdef BCMDBG 1802 brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_DATA_ON(),
1822 if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { 1803 rxbuf, len, "Rx Data:\n");
1823 printk(KERN_DEBUG "Rx Data:\n"); 1804 brcmf_dbg_hex_dump(!(BRCMF_BYTES_ON() &&
1824 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, 1805 BRCMF_DATA_ON()) &&
1825 rxbuf, len); 1806 BRCMF_HDRS_ON(),
1826 } else if (BRCMF_HDRS_ON()) { 1807 bus->rxhdr, SDPCM_HDRLEN,
1827 printk(KERN_DEBUG "RxHdr:\n"); 1808 "RxHdr:\n");
1828 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
1829 bus->rxhdr, SDPCM_HDRLEN);
1830 }
1831#endif
1832 1809
1833 if (chan == SDPCM_CONTROL_CHANNEL) { 1810 if (chan == SDPCM_CONTROL_CHANNEL) {
1834 brcmf_dbg(ERROR, "(nextlen): readahead on control packet %d?\n", 1811 brcmf_dbg(ERROR, "(nextlen): readahead on control packet %d?\n",
@@ -1865,13 +1842,9 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished)
1865 brcmf_sdbrcm_rxfail(bus, true, true); 1842 brcmf_sdbrcm_rxfail(bus, true, true);
1866 continue; 1843 continue;
1867 } 1844 }
1868#ifdef BCMDBG 1845 brcmf_dbg_hex_dump(BRCMF_BYTES_ON() || BRCMF_HDRS_ON(),
1869 if (BRCMF_BYTES_ON() || BRCMF_HDRS_ON()) { 1846 bus->rxhdr, SDPCM_HDRLEN, "RxHdr:\n");
1870 printk(KERN_DEBUG "RxHdr:\n"); 1847
1871 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
1872 bus->rxhdr, SDPCM_HDRLEN);
1873 }
1874#endif
1875 1848
1876 /* Extract hardware header fields */ 1849 /* Extract hardware header fields */
1877 len = get_unaligned_le16(bus->rxhdr); 1850 len = get_unaligned_le16(bus->rxhdr);
@@ -2024,13 +1997,8 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished)
2024 skb_push(pkt, BRCMF_FIRSTREAD); 1997 skb_push(pkt, BRCMF_FIRSTREAD);
2025 memcpy(pkt->data, bus->rxhdr, BRCMF_FIRSTREAD); 1998 memcpy(pkt->data, bus->rxhdr, BRCMF_FIRSTREAD);
2026 1999
2027#ifdef BCMDBG 2000 brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_DATA_ON(),
2028 if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { 2001 pkt->data, len, "Rx Data:\n");
2029 printk(KERN_DEBUG "Rx Data:\n");
2030 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
2031 pkt->data, len);
2032 }
2033#endif
2034 2002
2035deliver: 2003deliver:
2036 /* Save superframe descriptor and allocate packet frame */ 2004 /* Save superframe descriptor and allocate packet frame */
@@ -2038,14 +2006,9 @@ deliver:
2038 if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_FRAMETAG_LEN])) { 2006 if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_FRAMETAG_LEN])) {
2039 brcmf_dbg(GLOM, "glom descriptor, %d bytes:\n", 2007 brcmf_dbg(GLOM, "glom descriptor, %d bytes:\n",
2040 len); 2008 len);
2041#ifdef BCMDBG 2009 brcmf_dbg_hex_dump(BRCMF_GLOM_ON(),
2042 if (BRCMF_GLOM_ON()) { 2010 pkt->data, len,
2043 printk(KERN_DEBUG "Glom Data:\n"); 2011 "Glom Data:\n");
2044 print_hex_dump_bytes("",
2045 DUMP_PREFIX_OFFSET,
2046 pkt->data, len);
2047 }
2048#endif
2049 __skb_trim(pkt, len); 2012 __skb_trim(pkt, len);
2050 skb_pull(pkt, SDPCM_HDRLEN); 2013 skb_pull(pkt, SDPCM_HDRLEN);
2051 bus->glomd = pkt; 2014 bus->glomd = pkt;
@@ -2078,13 +2041,11 @@ deliver:
2078 down(&bus->sdsem); 2041 down(&bus->sdsem);
2079 } 2042 }
2080 rxcount = maxframes - rxleft; 2043 rxcount = maxframes - rxleft;
2081#ifdef BCMDBG
2082 /* Message if we hit the limit */ 2044 /* Message if we hit the limit */
2083 if (!rxleft) 2045 if (!rxleft)
2084 brcmf_dbg(DATA, "hit rx limit of %d frames\n", 2046 brcmf_dbg(DATA, "hit rx limit of %d frames\n",
2085 maxframes); 2047 maxframes);
2086 else 2048 else
2087#endif /* BCMDBG */
2088 brcmf_dbg(DATA, "processed %d frames\n", rxcount); 2049 brcmf_dbg(DATA, "processed %d frames\n", rxcount);
2089 /* Back off rxseq if awaiting rtx, update rx_seq */ 2050 /* Back off rxseq if awaiting rtx, update rx_seq */
2090 if (bus->rxskip) 2051 if (bus->rxskip)
@@ -2176,20 +2137,22 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt,
2176 put_unaligned_le32(swheader, frame + SDPCM_FRAMETAG_LEN); 2137 put_unaligned_le32(swheader, frame + SDPCM_FRAMETAG_LEN);
2177 put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader)); 2138 put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader));
2178 2139
2179#ifdef BCMDBG 2140#ifdef DEBUG
2180 tx_packets[pkt->priority]++; 2141 tx_packets[pkt->priority]++;
2181 if (BRCMF_BYTES_ON() &&
2182 (((BRCMF_CTL_ON() && (chan == SDPCM_CONTROL_CHANNEL)) ||
2183 (BRCMF_DATA_ON() && (chan != SDPCM_CONTROL_CHANNEL))))) {
2184 printk(KERN_DEBUG "Tx Frame:\n");
2185 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, frame, len);
2186 } else if (BRCMF_HDRS_ON()) {
2187 printk(KERN_DEBUG "TxHdr:\n");
2188 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
2189 frame, min_t(u16, len, 16));
2190 }
2191#endif 2142#endif
2192 2143
2144 brcmf_dbg_hex_dump(BRCMF_BYTES_ON() &&
2145 ((BRCMF_CTL_ON() && chan == SDPCM_CONTROL_CHANNEL) ||
2146 (BRCMF_DATA_ON() && chan != SDPCM_CONTROL_CHANNEL)),
2147 frame, len, "Tx Frame:\n");
2148 brcmf_dbg_hex_dump(!(BRCMF_BYTES_ON() &&
2149 ((BRCMF_CTL_ON() &&
2150 chan == SDPCM_CONTROL_CHANNEL) ||
2151 (BRCMF_DATA_ON() &&
2152 chan != SDPCM_CONTROL_CHANNEL))) &&
2153 BRCMF_HDRS_ON(),
2154 frame, min_t(u16, len, 16), "TxHdr:\n");
2155
2193 /* Raise len to next SDIO block to eliminate tail command */ 2156 /* Raise len to next SDIO block to eliminate tail command */
2194 if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { 2157 if (bus->roundup && bus->blocksize && (len > bus->blocksize)) {
2195 u16 pad = bus->blocksize - (len % bus->blocksize); 2158 u16 pad = bus->blocksize - (len % bus->blocksize);
@@ -2410,7 +2373,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
2410 int err; 2373 int err;
2411 u8 clkctl, devctl = 0; 2374 u8 clkctl, devctl = 0;
2412 2375
2413#ifdef BCMDBG 2376#ifdef DEBUG
2414 /* Check for inconsistent device control */ 2377 /* Check for inconsistent device control */
2415 devctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, 2378 devctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
2416 SBSDIO_DEVICE_CTL, &err); 2379 SBSDIO_DEVICE_CTL, &err);
@@ -2418,7 +2381,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
2418 brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", err); 2381 brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", err);
2419 bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN; 2382 bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN;
2420 } 2383 }
2421#endif /* BCMDBG */ 2384#endif /* DEBUG */
2422 2385
2423 /* Read CSR, if clock on switch to AVAIL, else ignore */ 2386 /* Read CSR, if clock on switch to AVAIL, else ignore */
2424 clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, 2387 clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
@@ -2701,7 +2664,7 @@ static int brcmf_sdbrcm_bus_txdata(struct device *dev, struct sk_buff *pkt)
2701 brcmf_txflowcontrol(bus->sdiodev->dev, 0, ON); 2664 brcmf_txflowcontrol(bus->sdiodev->dev, 0, ON);
2702 } 2665 }
2703 2666
2704#ifdef BCMDBG 2667#ifdef DEBUG
2705 if (pktq_plen(&bus->txq, prec) > qcount[prec]) 2668 if (pktq_plen(&bus->txq, prec) > qcount[prec])
2706 qcount[prec] = pktq_plen(&bus->txq, prec); 2669 qcount[prec] = pktq_plen(&bus->txq, prec);
2707#endif 2670#endif
@@ -2774,7 +2737,7 @@ xfer_done:
2774 return bcmerror; 2737 return bcmerror;
2775} 2738}
2776 2739
2777#ifdef BCMDBG 2740#ifdef DEBUG
2778#define CONSOLE_LINE_MAX 192 2741#define CONSOLE_LINE_MAX 192
2779 2742
2780static int brcmf_sdbrcm_readconsole(struct brcmf_sdio *bus) 2743static int brcmf_sdbrcm_readconsole(struct brcmf_sdio *bus)
@@ -2845,14 +2808,14 @@ static int brcmf_sdbrcm_readconsole(struct brcmf_sdio *bus)
2845 if (line[n - 1] == '\r') 2808 if (line[n - 1] == '\r')
2846 n--; 2809 n--;
2847 line[n] = 0; 2810 line[n] = 0;
2848 printk(KERN_DEBUG "CONSOLE: %s\n", line); 2811 pr_debug("CONSOLE: %s\n", line);
2849 } 2812 }
2850 } 2813 }
2851break2: 2814break2:
2852 2815
2853 return 0; 2816 return 0;
2854} 2817}
2855#endif /* BCMDBG */ 2818#endif /* DEBUG */
2856 2819
2857static int brcmf_tx_frame(struct brcmf_sdio *bus, u8 *frame, u16 len) 2820static int brcmf_tx_frame(struct brcmf_sdio *bus, u8 *frame, u16 len)
2858{ 2821{
@@ -2982,17 +2945,11 @@ brcmf_sdbrcm_bus_txctl(struct device *dev, unsigned char *msg, uint msglen)
2982 } 2945 }
2983 2946
2984 if (ret == -1) { 2947 if (ret == -1) {
2985#ifdef BCMDBG 2948 brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_CTL_ON(),
2986 if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { 2949 frame, len, "Tx Frame:\n");
2987 printk(KERN_DEBUG "Tx Frame:\n"); 2950 brcmf_dbg_hex_dump(!(BRCMF_BYTES_ON() && BRCMF_CTL_ON()) &&
2988 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, 2951 BRCMF_HDRS_ON(),
2989 frame, len); 2952 frame, min_t(u16, len, 16), "TxHdr:\n");
2990 } else if (BRCMF_HDRS_ON()) {
2991 printk(KERN_DEBUG "TxHdr:\n");
2992 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
2993 frame, min_t(u16, len, 16));
2994 }
2995#endif
2996 2953
2997 do { 2954 do {
2998 ret = brcmf_tx_frame(bus, frame, len); 2955 ret = brcmf_tx_frame(bus, frame, len);
@@ -3096,9 +3053,9 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_sdio *bus)
3096 u8 *vbuffer; 3053 u8 *vbuffer;
3097 u32 varsizew; 3054 u32 varsizew;
3098 __le32 varsizew_le; 3055 __le32 varsizew_le;
3099#ifdef BCMDBG 3056#ifdef DEBUG
3100 char *nvram_ularray; 3057 char *nvram_ularray;
3101#endif /* BCMDBG */ 3058#endif /* DEBUG */
3102 3059
3103 /* Even if there are no vars are to be written, we still 3060 /* Even if there are no vars are to be written, we still
3104 need to set the ramsize. */ 3061 need to set the ramsize. */
@@ -3115,7 +3072,7 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_sdio *bus)
3115 /* Write the vars list */ 3072 /* Write the vars list */
3116 bcmerror = 3073 bcmerror =
3117 brcmf_sdbrcm_membytes(bus, true, varaddr, vbuffer, varsize); 3074 brcmf_sdbrcm_membytes(bus, true, varaddr, vbuffer, varsize);
3118#ifdef BCMDBG 3075#ifdef DEBUG
3119 /* Verify NVRAM bytes */ 3076 /* Verify NVRAM bytes */
3120 brcmf_dbg(INFO, "Compare NVRAM dl & ul; varsize=%d\n", varsize); 3077 brcmf_dbg(INFO, "Compare NVRAM dl & ul; varsize=%d\n", varsize);
3121 nvram_ularray = kmalloc(varsize, GFP_ATOMIC); 3078 nvram_ularray = kmalloc(varsize, GFP_ATOMIC);
@@ -3142,7 +3099,7 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_sdio *bus)
3142 brcmf_dbg(ERROR, "Download/Upload/Compare of NVRAM ok\n"); 3099 brcmf_dbg(ERROR, "Download/Upload/Compare of NVRAM ok\n");
3143 3100
3144 kfree(nvram_ularray); 3101 kfree(nvram_ularray);
3145#endif /* BCMDBG */ 3102#endif /* DEBUG */
3146 3103
3147 kfree(vbuffer); 3104 kfree(vbuffer);
3148 } 3105 }
@@ -3569,9 +3526,9 @@ void brcmf_sdbrcm_isr(void *arg)
3569 3526
3570static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus) 3527static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus)
3571{ 3528{
3572#ifdef BCMDBG 3529#ifdef DEBUG
3573 struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev); 3530 struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev);
3574#endif /* BCMDBG */ 3531#endif /* DEBUG */
3575 3532
3576 brcmf_dbg(TIMER, "Enter\n"); 3533 brcmf_dbg(TIMER, "Enter\n");
3577 3534
@@ -3616,7 +3573,7 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus)
3616 /* Update interrupt tracking */ 3573 /* Update interrupt tracking */
3617 bus->lastintrs = bus->intrcount; 3574 bus->lastintrs = bus->intrcount;
3618 } 3575 }
3619#ifdef BCMDBG 3576#ifdef DEBUG
3620 /* Poll for console output periodically */ 3577 /* Poll for console output periodically */
3621 if (bus_if->state == BRCMF_BUS_DATA && 3578 if (bus_if->state == BRCMF_BUS_DATA &&
3622 bus->console_interval != 0) { 3579 bus->console_interval != 0) {
@@ -3630,7 +3587,7 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus)
3630 bus->console_interval = 0; 3587 bus->console_interval = 0;
3631 } 3588 }
3632 } 3589 }
3633#endif /* BCMDBG */ 3590#endif /* DEBUG */
3634 3591
3635 /* On idle timeout clear activity flag and/or turn off clock */ 3592 /* On idle timeout clear activity flag and/or turn off clock */
3636 if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) { 3593 if ((bus->idletime > 0) && (bus->clkstate == CLK_AVAIL)) {
@@ -3721,11 +3678,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_sdio *bus, u32 regsva)
3721 if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, SI_ENUM_BASE)) 3678 if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, SI_ENUM_BASE))
3722 brcmf_dbg(ERROR, "FAILED to return to SI_ENUM_BASE\n"); 3679 brcmf_dbg(ERROR, "FAILED to return to SI_ENUM_BASE\n");
3723 3680
3724#ifdef BCMDBG 3681 pr_debug("F1 signature read @0x18000000=0x%4x\n",
3725 printk(KERN_DEBUG "F1 signature read @0x18000000=0x%4x\n", 3682 brcmf_sdcard_reg_read(bus->sdiodev, SI_ENUM_BASE, 4));
3726 brcmf_sdcard_reg_read(bus->sdiodev, SI_ENUM_BASE, 4));
3727
3728#endif /* BCMDBG */
3729 3683
3730 /* 3684 /*
3731 * Force PLL off until brcmf_sdio_chip_attach() 3685 * Force PLL off until brcmf_sdio_chip_attach()
@@ -3944,8 +3898,7 @@ void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev)
3944 bus->watchdog_tsk = kthread_run(brcmf_sdbrcm_watchdog_thread, 3898 bus->watchdog_tsk = kthread_run(brcmf_sdbrcm_watchdog_thread,
3945 bus, "brcmf_watchdog"); 3899 bus, "brcmf_watchdog");
3946 if (IS_ERR(bus->watchdog_tsk)) { 3900 if (IS_ERR(bus->watchdog_tsk)) {
3947 printk(KERN_WARNING 3901 pr_warn("brcmf_watchdog thread failed to start\n");
3948 "brcmf_watchdog thread failed to start\n");
3949 bus->watchdog_tsk = NULL; 3902 bus->watchdog_tsk = NULL;
3950 } 3903 }
3951 /* Initialize DPC thread */ 3904 /* Initialize DPC thread */
@@ -3953,8 +3906,7 @@ void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev)
3953 bus->dpc_tsk = kthread_run(brcmf_sdbrcm_dpc_thread, 3906 bus->dpc_tsk = kthread_run(brcmf_sdbrcm_dpc_thread,
3954 bus, "brcmf_dpc"); 3907 bus, "brcmf_dpc");
3955 if (IS_ERR(bus->dpc_tsk)) { 3908 if (IS_ERR(bus->dpc_tsk)) {
3956 printk(KERN_WARNING 3909 pr_warn("brcmf_dpc thread failed to start\n");
3957 "brcmf_dpc thread failed to start\n");
3958 bus->dpc_tsk = NULL; 3910 bus->dpc_tsk = NULL;
3959 } 3911 }
3960 3912
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c
index 11b2d7c97ba2..1534efc21631 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c
@@ -15,6 +15,8 @@
15 */ 15 */
16/* ***** SDIO interface chip backplane handle functions ***** */ 16/* ***** SDIO interface chip backplane handle functions ***** */
17 17
18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19
18#include <linux/types.h> 20#include <linux/types.h>
19#include <linux/netdevice.h> 21#include <linux/netdevice.h>
20#include <linux/mmc/card.h> 22#include <linux/mmc/card.h>
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
index bf11850a20f1..74c95a597950 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
@@ -16,6 +16,8 @@
16 16
17/* Toplevel file. Relies on dhd_linux.c to send commands to the dongle. */ 17/* Toplevel file. Relies on dhd_linux.c to send commands to the dongle. */
18 18
19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20
19#include <linux/kernel.h> 21#include <linux/kernel.h>
20#include <linux/if_arp.h> 22#include <linux/if_arp.h>
21#include <linux/sched.h> 23#include <linux/sched.h>
@@ -2783,7 +2785,7 @@ static struct wireless_dev *brcmf_alloc_wdev(s32 sizeof_iface,
2783 wiphy_new(&wl_cfg80211_ops, 2785 wiphy_new(&wl_cfg80211_ops,
2784 sizeof(struct brcmf_cfg80211_priv) + sizeof_iface); 2786 sizeof(struct brcmf_cfg80211_priv) + sizeof_iface);
2785 if (!wdev->wiphy) { 2787 if (!wdev->wiphy) {
2786 WL_ERR("Couldn not allocate wiphy device\n"); 2788 WL_ERR("Could not allocate wiphy device\n");
2787 err = -ENOMEM; 2789 err = -ENOMEM;
2788 goto wiphy_new_out; 2790 goto wiphy_new_out;
2789 } 2791 }
@@ -2809,7 +2811,7 @@ static struct wireless_dev *brcmf_alloc_wdev(s32 sizeof_iface,
2809 */ 2811 */
2810 err = wiphy_register(wdev->wiphy); 2812 err = wiphy_register(wdev->wiphy);
2811 if (err < 0) { 2813 if (err < 0) {
2812 WL_ERR("Couldn not register wiphy device (%d)\n", err); 2814 WL_ERR("Could not register wiphy device (%d)\n", err);
2813 goto wiphy_register_out; 2815 goto wiphy_register_out;
2814 } 2816 }
2815 return wdev; 2817 return wdev;
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h
index a613b49cb13f..b5d9b36df3d0 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h
+++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h
@@ -32,63 +32,63 @@ struct brcmf_cfg80211_ibss;
32#define WL_DBG_MASK ((WL_DBG_INFO | WL_DBG_ERR | WL_DBG_TRACE) | \ 32#define WL_DBG_MASK ((WL_DBG_INFO | WL_DBG_ERR | WL_DBG_TRACE) | \
33 (WL_DBG_SCAN) | (WL_DBG_CONN)) 33 (WL_DBG_SCAN) | (WL_DBG_CONN))
34 34
35#define WL_ERR(fmt, args...) \ 35#define WL_ERR(fmt, ...) \
36do { \ 36do { \
37 if (brcmf_dbg_level & WL_DBG_ERR) { \ 37 if (brcmf_dbg_level & WL_DBG_ERR) { \
38 if (net_ratelimit()) { \ 38 if (net_ratelimit()) { \
39 printk(KERN_ERR "ERROR @%s : " fmt, \ 39 pr_err("ERROR @%s : " fmt, \
40 __func__, ##args); \ 40 __func__, ##__VA_ARGS__); \
41 } \ 41 } \
42 } \ 42 } \
43} while (0) 43} while (0)
44 44
45#if (defined BCMDBG) 45#if (defined DEBUG)
46#define WL_INFO(fmt, args...) \ 46#define WL_INFO(fmt, ...) \
47do { \ 47do { \
48 if (brcmf_dbg_level & WL_DBG_INFO) { \ 48 if (brcmf_dbg_level & WL_DBG_INFO) { \
49 if (net_ratelimit()) { \ 49 if (net_ratelimit()) { \
50 printk(KERN_ERR "INFO @%s : " fmt, \ 50 pr_err("INFO @%s : " fmt, \
51 __func__, ##args); \ 51 __func__, ##__VA_ARGS__); \
52 } \ 52 } \
53 } \ 53 } \
54} while (0) 54} while (0)
55 55
56#define WL_TRACE(fmt, args...) \ 56#define WL_TRACE(fmt, ...) \
57do { \ 57do { \
58 if (brcmf_dbg_level & WL_DBG_TRACE) { \ 58 if (brcmf_dbg_level & WL_DBG_TRACE) { \
59 if (net_ratelimit()) { \ 59 if (net_ratelimit()) { \
60 printk(KERN_ERR "TRACE @%s : " fmt, \ 60 pr_err("TRACE @%s : " fmt, \
61 __func__, ##args); \ 61 __func__, ##__VA_ARGS__); \
62 } \ 62 } \
63 } \ 63 } \
64} while (0) 64} while (0)
65 65
66#define WL_SCAN(fmt, args...) \ 66#define WL_SCAN(fmt, ...) \
67do { \ 67do { \
68 if (brcmf_dbg_level & WL_DBG_SCAN) { \ 68 if (brcmf_dbg_level & WL_DBG_SCAN) { \
69 if (net_ratelimit()) { \ 69 if (net_ratelimit()) { \
70 printk(KERN_ERR "SCAN @%s : " fmt, \ 70 pr_err("SCAN @%s : " fmt, \
71 __func__, ##args); \ 71 __func__, ##__VA_ARGS__); \
72 } \ 72 } \
73 } \ 73 } \
74} while (0) 74} while (0)
75 75
76#define WL_CONN(fmt, args...) \ 76#define WL_CONN(fmt, ...) \
77do { \ 77do { \
78 if (brcmf_dbg_level & WL_DBG_CONN) { \ 78 if (brcmf_dbg_level & WL_DBG_CONN) { \
79 if (net_ratelimit()) { \ 79 if (net_ratelimit()) { \
80 printk(KERN_ERR "CONN @%s : " fmt, \ 80 pr_err("CONN @%s : " fmt, \
81 __func__, ##args); \ 81 __func__, ##__VA_ARGS__); \
82 } \ 82 } \
83 } \ 83 } \
84} while (0) 84} while (0)
85 85
86#else /* (defined BCMDBG) */ 86#else /* (defined DEBUG) */
87#define WL_INFO(fmt, args...) 87#define WL_INFO(fmt, args...)
88#define WL_TRACE(fmt, args...) 88#define WL_TRACE(fmt, args...)
89#define WL_SCAN(fmt, args...) 89#define WL_SCAN(fmt, args...)
90#define WL_CONN(fmt, args...) 90#define WL_CONN(fmt, args...)
91#endif /* (defined BCMDBG) */ 91#endif /* (defined DEBUG) */
92 92
93#define WL_NUM_SCAN_MAX 1 93#define WL_NUM_SCAN_MAX 1
94#define WL_NUM_PMKIDS_MAX MAXPMKID /* will be used 94#define WL_NUM_PMKIDS_MAX MAXPMKID /* will be used
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
index ab9bb11abfbb..c93ea35bceec 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
@@ -326,11 +326,11 @@
326 326
327#define PCI_FORCEHT(sih) (PCIE(sih) && (ai_get_chip_id(sih) == BCM4716_CHIP_ID)) 327#define PCI_FORCEHT(sih) (PCIE(sih) && (ai_get_chip_id(sih) == BCM4716_CHIP_ID))
328 328
329#ifdef BCMDBG 329#ifdef DEBUG
330#define SI_MSG(fmt, ...) pr_debug(fmt, ##__VA_ARGS__) 330#define SI_MSG(fmt, ...) pr_debug(fmt, ##__VA_ARGS__)
331#else 331#else
332#define SI_MSG(fmt, ...) no_printk(fmt, ##__VA_ARGS__) 332#define SI_MSG(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
333#endif /* BCMDBG */ 333#endif /* DEBUG */
334 334
335#define GOODCOREADDR(x, b) \ 335#define GOODCOREADDR(x, b) \
336 (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \ 336 (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c
index 90911eec0cf5..d89dcb14cb6d 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c
@@ -915,7 +915,7 @@ brcms_c_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
915 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(p); 915 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(p);
916 struct wiphy *wiphy = wlc->wiphy; 916 struct wiphy *wiphy = wlc->wiphy;
917 917
918#ifdef BCMDBG 918#ifdef DEBUG
919 u8 hole[AMPDU_MAX_MPDU]; 919 u8 hole[AMPDU_MAX_MPDU];
920 memset(hole, 0, sizeof(hole)); 920 memset(hole, 0, sizeof(hole));
921#endif 921#endif
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c
index 2e90a9a16ed6..11054ae9d4f6 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c
@@ -177,7 +177,7 @@
177#define BCMEXTRAHDROOM 172 177#define BCMEXTRAHDROOM 172
178 178
179/* debug/trace */ 179/* debug/trace */
180#ifdef BCMDBG 180#ifdef DEBUG
181#define DMA_ERROR(fmt, ...) \ 181#define DMA_ERROR(fmt, ...) \
182do { \ 182do { \
183 if (*di->msg_level & 1) \ 183 if (*di->msg_level & 1) \
@@ -193,7 +193,7 @@ do { \
193 no_printk(fmt, ##__VA_ARGS__) 193 no_printk(fmt, ##__VA_ARGS__)
194#define DMA_TRACE(fmt, ...) \ 194#define DMA_TRACE(fmt, ...) \
195 no_printk(fmt, ##__VA_ARGS__) 195 no_printk(fmt, ##__VA_ARGS__)
196#endif /* BCMDBG */ 196#endif /* DEBUG */
197 197
198#define DMA_NONE(fmt, ...) \ 198#define DMA_NONE(fmt, ...) \
199 no_printk(fmt, ##__VA_ARGS__) 199 no_printk(fmt, ##__VA_ARGS__)
@@ -968,7 +968,7 @@ int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list)
968 pktcnt++; 968 pktcnt++;
969 } 969 }
970 970
971#ifdef BCMDBG 971#ifdef DEBUG
972 if (resid > 0) { 972 if (resid > 0) {
973 uint cur; 973 uint cur;
974 cur = 974 cur =
@@ -979,7 +979,7 @@ int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list)
979 DMA_ERROR("rxin %d rxout %d, hw_curr %d\n", 979 DMA_ERROR("rxin %d rxout %d, hw_curr %d\n",
980 di->rxin, di->rxout, cur); 980 di->rxin, di->rxout, cur);
981 } 981 }
982#endif /* BCMDBG */ 982#endif /* DEBUG */
983 983
984 if ((di->dma.dmactrlflags & DMA_CTRL_RXMULTI) == 0) { 984 if ((di->dma.dmactrlflags & DMA_CTRL_RXMULTI) == 0) {
985 DMA_ERROR("%s: bad frame length (%d)\n", 985 DMA_ERROR("%s: bad frame length (%d)\n",
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
index 448ab9c4eb47..c8427978d09e 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
@@ -15,6 +15,7 @@
15 */ 15 */
16 16
17#define __UNDEF_NO_VERSION__ 17#define __UNDEF_NO_VERSION__
18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18 19
19#include <linux/etherdevice.h> 20#include <linux/etherdevice.h>
20#include <linux/sched.h> 21#include <linux/sched.h>
@@ -96,10 +97,10 @@ static struct bcma_device_id brcms_coreid_table[] = {
96}; 97};
97MODULE_DEVICE_TABLE(bcma, brcms_coreid_table); 98MODULE_DEVICE_TABLE(bcma, brcms_coreid_table);
98 99
99#ifdef BCMDBG 100#ifdef DEBUG
100static int msglevel = 0xdeadbeef; 101static int msglevel = 0xdeadbeef;
101module_param(msglevel, int, 0); 102module_param(msglevel, int, 0);
102#endif /* BCMDBG */ 103#endif /* DEBUG */
103 104
104static struct ieee80211_channel brcms_2ghz_chantable[] = { 105static struct ieee80211_channel brcms_2ghz_chantable[] = {
105 CHAN2GHZ(1, 2412, IEEE80211_CHAN_NO_HT40MINUS), 106 CHAN2GHZ(1, 2412, IEEE80211_CHAN_NO_HT40MINUS),
@@ -857,7 +858,7 @@ static void brcms_free(struct brcms_info *wl)
857 /* free timers */ 858 /* free timers */
858 for (t = wl->timers; t; t = next) { 859 for (t = wl->timers; t; t = next) {
859 next = t->next; 860 next = t->next;
860#ifdef BCMDBG 861#ifdef DEBUG
861 kfree(t->name); 862 kfree(t->name);
862#endif 863#endif
863 kfree(t); 864 kfree(t);
@@ -1121,8 +1122,7 @@ static int __devinit brcms_bcma_probe(struct bcma_device *pdev)
1121 1122
1122 wl = brcms_attach(pdev); 1123 wl = brcms_attach(pdev);
1123 if (!wl) { 1124 if (!wl) {
1124 pr_err("%s: %s: brcms_attach failed!\n", KBUILD_MODNAME, 1125 pr_err("%s: brcms_attach failed!\n", __func__);
1125 __func__);
1126 return -ENODEV; 1126 return -ENODEV;
1127 } 1127 }
1128 return 0; 1128 return 0;
@@ -1177,13 +1177,13 @@ static int __init brcms_module_init(void)
1177{ 1177{
1178 int error = -ENODEV; 1178 int error = -ENODEV;
1179 1179
1180#ifdef BCMDBG 1180#ifdef DEBUG
1181 if (msglevel != 0xdeadbeef) 1181 if (msglevel != 0xdeadbeef)
1182 brcm_msg_level = msglevel; 1182 brcm_msg_level = msglevel;
1183#endif /* BCMDBG */ 1183#endif /* DEBUG */
1184 1184
1185 error = bcma_driver_register(&brcms_bcma_driver); 1185 error = bcma_driver_register(&brcms_bcma_driver);
1186 printk(KERN_ERR "%s: register returned %d\n", __func__, error); 1186 pr_err("%s: register returned %d\n", __func__, error);
1187 if (!error) 1187 if (!error)
1188 return 0; 1188 return 0;
1189 1189
@@ -1367,7 +1367,7 @@ struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
1367 t->next = wl->timers; 1367 t->next = wl->timers;
1368 wl->timers = t; 1368 wl->timers = t;
1369 1369
1370#ifdef BCMDBG 1370#ifdef DEBUG
1371 t->name = kmalloc(strlen(name) + 1, GFP_ATOMIC); 1371 t->name = kmalloc(strlen(name) + 1, GFP_ATOMIC);
1372 if (t->name) 1372 if (t->name)
1373 strcpy(t->name, name); 1373 strcpy(t->name, name);
@@ -1386,7 +1386,7 @@ void brcms_add_timer(struct brcms_timer *t, uint ms, int periodic)
1386{ 1386{
1387 struct ieee80211_hw *hw = t->wl->pub->ieee_hw; 1387 struct ieee80211_hw *hw = t->wl->pub->ieee_hw;
1388 1388
1389#ifdef BCMDBG 1389#ifdef DEBUG
1390 if (t->set) 1390 if (t->set)
1391 wiphy_err(hw->wiphy, "%s: Already set. Name: %s, per %d\n", 1391 wiphy_err(hw->wiphy, "%s: Already set. Name: %s, per %d\n",
1392 __func__, t->name, periodic); 1392 __func__, t->name, periodic);
@@ -1431,7 +1431,7 @@ void brcms_free_timer(struct brcms_timer *t)
1431 1431
1432 if (wl->timers == t) { 1432 if (wl->timers == t) {
1433 wl->timers = wl->timers->next; 1433 wl->timers = wl->timers->next;
1434#ifdef BCMDBG 1434#ifdef DEBUG
1435 kfree(t->name); 1435 kfree(t->name);
1436#endif 1436#endif
1437 kfree(t); 1437 kfree(t);
@@ -1443,7 +1443,7 @@ void brcms_free_timer(struct brcms_timer *t)
1443 while (tmp) { 1443 while (tmp) {
1444 if (tmp->next == t) { 1444 if (tmp->next == t) {
1445 tmp->next = t->next; 1445 tmp->next = t->next;
1446#ifdef BCMDBG 1446#ifdef DEBUG
1447 kfree(t->name); 1447 kfree(t->name);
1448#endif 1448#endif
1449 kfree(t); 1449 kfree(t);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h
index 8f60419c37bf..9358bd5ebd35 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h
@@ -40,7 +40,7 @@ struct brcms_timer {
40 bool periodic; 40 bool periodic;
41 bool set; /* indicates if timer is active */ 41 bool set; /* indicates if timer is active */
42 struct brcms_timer *next; /* for freeing on unload */ 42 struct brcms_timer *next; /* for freeing on unload */
43#ifdef BCMDBG 43#ifdef DEBUG
44 char *name; /* Description of the timer */ 44 char *name; /* Description of the timer */
45#endif 45#endif
46}; 46};
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
index f6affc6fd12a..fb712cac9157 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
@@ -14,6 +14,8 @@
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
17#include <linux/pci_ids.h> 19#include <linux/pci_ids.h>
18#include <linux/if_ether.h> 20#include <linux/if_ether.h>
19#include <net/mac80211.h> 21#include <net/mac80211.h>
@@ -293,11 +295,11 @@ const u8 prio2fifo[NUMPRIO] = {
293 295
294/* debug/trace */ 296/* debug/trace */
295uint brcm_msg_level = 297uint brcm_msg_level =
296#if defined(BCMDBG) 298#if defined(DEBUG)
297 LOG_ERROR_VAL; 299 LOG_ERROR_VAL;
298#else 300#else
299 0; 301 0;
300#endif /* BCMDBG */ 302#endif /* DEBUG */
301 303
302/* TX FIFO number to WME/802.1E Access Category */ 304/* TX FIFO number to WME/802.1E Access Category */
303static const u8 wme_fifo2ac[] = { 305static const u8 wme_fifo2ac[] = {
@@ -342,14 +344,14 @@ static const u16 xmtfifo_sz[][NFIFO] = {
342 {9, 58, 22, 14, 14, 5}, 344 {9, 58, 22, 14, 14, 5},
343}; 345};
344 346
345#ifdef BCMDBG 347#ifdef DEBUG
346static const char * const fifo_names[] = { 348static const char * const fifo_names[] = {
347 "AC_BK", "AC_BE", "AC_VI", "AC_VO", "BCMC", "ATIM" }; 349 "AC_BK", "AC_BE", "AC_VI", "AC_VO", "BCMC", "ATIM" };
348#else 350#else
349static const char fifo_names[6][0]; 351static const char fifo_names[6][0];
350#endif 352#endif
351 353
352#ifdef BCMDBG 354#ifdef DEBUG
353/* pointer to most recently allocated wl/wlc */ 355/* pointer to most recently allocated wl/wlc */
354static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL); 356static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL);
355#endif 357#endif
@@ -3075,30 +3077,30 @@ static void brcms_c_statsupd(struct brcms_c_info *wlc)
3075{ 3077{
3076 int i; 3078 int i;
3077 struct macstat macstats; 3079 struct macstat macstats;
3078#ifdef BCMDBG 3080#ifdef DEBUG
3079 u16 delta; 3081 u16 delta;
3080 u16 rxf0ovfl; 3082 u16 rxf0ovfl;
3081 u16 txfunfl[NFIFO]; 3083 u16 txfunfl[NFIFO];
3082#endif /* BCMDBG */ 3084#endif /* DEBUG */
3083 3085
3084 /* if driver down, make no sense to update stats */ 3086 /* if driver down, make no sense to update stats */
3085 if (!wlc->pub->up) 3087 if (!wlc->pub->up)
3086 return; 3088 return;
3087 3089
3088#ifdef BCMDBG 3090#ifdef DEBUG
3089 /* save last rx fifo 0 overflow count */ 3091 /* save last rx fifo 0 overflow count */
3090 rxf0ovfl = wlc->core->macstat_snapshot->rxf0ovfl; 3092 rxf0ovfl = wlc->core->macstat_snapshot->rxf0ovfl;
3091 3093
3092 /* save last tx fifo underflow count */ 3094 /* save last tx fifo underflow count */
3093 for (i = 0; i < NFIFO; i++) 3095 for (i = 0; i < NFIFO; i++)
3094 txfunfl[i] = wlc->core->macstat_snapshot->txfunfl[i]; 3096 txfunfl[i] = wlc->core->macstat_snapshot->txfunfl[i];
3095#endif /* BCMDBG */ 3097#endif /* DEBUG */
3096 3098
3097 /* Read mac stats from contiguous shared memory */ 3099 /* Read mac stats from contiguous shared memory */
3098 brcms_b_copyfrom_objmem(wlc->hw, M_UCODE_MACSTAT, &macstats, 3100 brcms_b_copyfrom_objmem(wlc->hw, M_UCODE_MACSTAT, &macstats,
3099 sizeof(struct macstat), OBJADDR_SHM_SEL); 3101 sizeof(struct macstat), OBJADDR_SHM_SEL);
3100 3102
3101#ifdef BCMDBG 3103#ifdef DEBUG
3102 /* check for rx fifo 0 overflow */ 3104 /* check for rx fifo 0 overflow */
3103 delta = (u16) (wlc->core->macstat_snapshot->rxf0ovfl - rxf0ovfl); 3105 delta = (u16) (wlc->core->macstat_snapshot->rxf0ovfl - rxf0ovfl);
3104 if (delta) 3106 if (delta)
@@ -3114,7 +3116,7 @@ static void brcms_c_statsupd(struct brcms_c_info *wlc)
3114 wiphy_err(wlc->wiphy, "wl%d: %u tx fifo %d underflows!" 3116 wiphy_err(wlc->wiphy, "wl%d: %u tx fifo %d underflows!"
3115 "\n", wlc->pub->unit, delta, i); 3117 "\n", wlc->pub->unit, delta, i);
3116 } 3118 }
3117#endif /* BCMDBG */ 3119#endif /* DEBUG */
3118 3120
3119 /* merge counters from dma module */ 3121 /* merge counters from dma module */
3120 for (i = 0; i < NFIFO; i++) { 3122 for (i = 0; i < NFIFO; i++) {
@@ -5765,62 +5767,49 @@ int brcms_c_module_unregister(struct brcms_pub *pub, const char *name,
5765 return -ENODATA; 5767 return -ENODATA;
5766} 5768}
5767 5769
5768#ifdef BCMDBG
5769static const char * const supr_reason[] = {
5770 "None", "PMQ Entry", "Flush request",
5771 "Previous frag failure", "Channel mismatch",
5772 "Lifetime Expiry", "Underflow"
5773};
5774
5775static void brcms_c_print_txs_status(u16 s)
5776{
5777 printk(KERN_DEBUG "[15:12] %d frame attempts\n",
5778 (s & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT);
5779 printk(KERN_DEBUG " [11:8] %d rts attempts\n",
5780 (s & TX_STATUS_RTS_RTX_MASK) >> TX_STATUS_RTS_RTX_SHIFT);
5781 printk(KERN_DEBUG " [7] %d PM mode indicated\n",
5782 ((s & TX_STATUS_PMINDCTD) ? 1 : 0));
5783 printk(KERN_DEBUG " [6] %d intermediate status\n",
5784 ((s & TX_STATUS_INTERMEDIATE) ? 1 : 0));
5785 printk(KERN_DEBUG " [5] %d AMPDU\n",
5786 (s & TX_STATUS_AMPDU) ? 1 : 0);
5787 printk(KERN_DEBUG " [4:2] %d Frame Suppressed Reason (%s)\n",
5788 ((s & TX_STATUS_SUPR_MASK) >> TX_STATUS_SUPR_SHIFT),
5789 supr_reason[(s & TX_STATUS_SUPR_MASK) >> TX_STATUS_SUPR_SHIFT]);
5790 printk(KERN_DEBUG " [1] %d acked\n",
5791 ((s & TX_STATUS_ACK_RCV) ? 1 : 0));
5792}
5793#endif /* BCMDBG */
5794
5795void brcms_c_print_txstatus(struct tx_status *txs) 5770void brcms_c_print_txstatus(struct tx_status *txs)
5796{ 5771{
5797#if defined(BCMDBG) 5772 pr_debug("\ntxpkt (MPDU) Complete\n");
5798 u16 s = txs->status; 5773
5799 u16 ackphyrxsh = txs->ackphyrxsh; 5774 pr_debug("FrameID: %04x TxStatus: %04x\n", txs->frameid, txs->status);
5800 5775
5801 printk(KERN_DEBUG "\ntxpkt (MPDU) Complete\n"); 5776 pr_debug("[15:12] %d frame attempts\n",
5802 5777 (txs->status & TX_STATUS_FRM_RTX_MASK) >>
5803 printk(KERN_DEBUG "FrameID: %04x ", txs->frameid); 5778 TX_STATUS_FRM_RTX_SHIFT);
5804 printk(KERN_DEBUG "TxStatus: %04x", s); 5779 pr_debug(" [11:8] %d rts attempts\n",
5805 printk(KERN_DEBUG "\n"); 5780 (txs->status & TX_STATUS_RTS_RTX_MASK) >>
5806 5781 TX_STATUS_RTS_RTX_SHIFT);
5807 brcms_c_print_txs_status(s); 5782 pr_debug(" [7] %d PM mode indicated\n",
5808 5783 txs->status & TX_STATUS_PMINDCTD ? 1 : 0);
5809 printk(KERN_DEBUG "LastTxTime: %04x ", txs->lasttxtime); 5784 pr_debug(" [6] %d intermediate status\n",
5810 printk(KERN_DEBUG "Seq: %04x ", txs->sequence); 5785 txs->status & TX_STATUS_INTERMEDIATE ? 1 : 0);
5811 printk(KERN_DEBUG "PHYTxStatus: %04x ", txs->phyerr); 5786 pr_debug(" [5] %d AMPDU\n",
5812 printk(KERN_DEBUG "RxAckRSSI: %04x ", 5787 txs->status & TX_STATUS_AMPDU ? 1 : 0);
5813 (ackphyrxsh & PRXS1_JSSI_MASK) >> PRXS1_JSSI_SHIFT); 5788 pr_debug(" [4:2] %d Frame Suppressed Reason (%s)\n",
5814 printk(KERN_DEBUG "RxAckSQ: %04x", 5789 (txs->status & TX_STATUS_SUPR_MASK) >> TX_STATUS_SUPR_SHIFT,
5815 (ackphyrxsh & PRXS1_SQ_MASK) >> PRXS1_SQ_SHIFT); 5790 (const char *[]) {
5816 printk(KERN_DEBUG "\n"); 5791 "None",
5817#endif /* defined(BCMDBG) */ 5792 "PMQ Entry",
5793 "Flush request",
5794 "Previous frag failure",
5795 "Channel mismatch",
5796 "Lifetime Expiry",
5797 "Underflow"
5798 } [(txs->status & TX_STATUS_SUPR_MASK) >>
5799 TX_STATUS_SUPR_SHIFT]);
5800 pr_debug(" [1] %d acked\n",
5801 txs->status & TX_STATUS_ACK_RCV ? 1 : 0);
5802
5803 pr_debug("LastTxTime: %04x Seq: %04x PHYTxStatus: %04x RxAckRSSI: %04x RxAckSQ: %04x\n",
5804 txs->lasttxtime, txs->sequence, txs->phyerr,
5805 (txs->ackphyrxsh & PRXS1_JSSI_MASK) >> PRXS1_JSSI_SHIFT,
5806 (txs->ackphyrxsh & PRXS1_SQ_MASK) >> PRXS1_SQ_SHIFT);
5818} 5807}
5819 5808
5820bool brcms_c_chipmatch(u16 vendor, u16 device) 5809bool brcms_c_chipmatch(u16 vendor, u16 device)
5821{ 5810{
5822 if (vendor != PCI_VENDOR_ID_BROADCOM) { 5811 if (vendor != PCI_VENDOR_ID_BROADCOM) {
5823 pr_err("chipmatch: unknown vendor id %04x\n", vendor); 5812 pr_err("unknown vendor id %04x\n", vendor);
5824 return false; 5813 return false;
5825 } 5814 }
5826 5815
@@ -5833,11 +5822,11 @@ bool brcms_c_chipmatch(u16 vendor, u16 device)
5833 if ((device == BCM43236_D11N_ID) || (device == BCM43236_D11N2G_ID)) 5822 if ((device == BCM43236_D11N_ID) || (device == BCM43236_D11N2G_ID))
5834 return true; 5823 return true;
5835 5824
5836 pr_err("chipmatch: unknown device id %04x\n", device); 5825 pr_err("unknown device id %04x\n", device);
5837 return false; 5826 return false;
5838} 5827}
5839 5828
5840#if defined(BCMDBG) 5829#if defined(DEBUG)
5841void brcms_c_print_txdesc(struct d11txh *txh) 5830void brcms_c_print_txdesc(struct d11txh *txh)
5842{ 5831{
5843 u16 mtcl = le16_to_cpu(txh->MacTxControlLow); 5832 u16 mtcl = le16_to_cpu(txh->MacTxControlLow);
@@ -5871,57 +5860,56 @@ void brcms_c_print_txdesc(struct d11txh *txh)
5871 struct ieee80211_rts rts = txh->rts_frame; 5860 struct ieee80211_rts rts = txh->rts_frame;
5872 5861
5873 /* add plcp header along with txh descriptor */ 5862 /* add plcp header along with txh descriptor */
5874 printk(KERN_DEBUG "Raw TxDesc + plcp header:\n"); 5863 brcmu_dbg_hex_dump(txh, sizeof(struct d11txh) + 48,
5875 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, 5864 "Raw TxDesc + plcp header:\n");
5876 txh, sizeof(struct d11txh) + 48); 5865
5877 5866 pr_debug("TxCtlLow: %04x ", mtcl);
5878 printk(KERN_DEBUG "TxCtlLow: %04x ", mtcl); 5867 pr_debug("TxCtlHigh: %04x ", mtch);
5879 printk(KERN_DEBUG "TxCtlHigh: %04x ", mtch); 5868 pr_debug("FC: %04x ", mfc);
5880 printk(KERN_DEBUG "FC: %04x ", mfc); 5869 pr_debug("FES Time: %04x\n", tfest);
5881 printk(KERN_DEBUG "FES Time: %04x\n", tfest); 5870 pr_debug("PhyCtl: %04x%s ", ptcw,
5882 printk(KERN_DEBUG "PhyCtl: %04x%s ", ptcw,
5883 (ptcw & PHY_TXC_SHORT_HDR) ? " short" : ""); 5871 (ptcw & PHY_TXC_SHORT_HDR) ? " short" : "");
5884 printk(KERN_DEBUG "PhyCtl_1: %04x ", ptcw_1); 5872 pr_debug("PhyCtl_1: %04x ", ptcw_1);
5885 printk(KERN_DEBUG "PhyCtl_1_Fbr: %04x\n", ptcw_1_Fbr); 5873 pr_debug("PhyCtl_1_Fbr: %04x\n", ptcw_1_Fbr);
5886 printk(KERN_DEBUG "PhyCtl_1_Rts: %04x ", ptcw_1_Rts); 5874 pr_debug("PhyCtl_1_Rts: %04x ", ptcw_1_Rts);
5887 printk(KERN_DEBUG "PhyCtl_1_Fbr_Rts: %04x\n", ptcw_1_FbrRts); 5875 pr_debug("PhyCtl_1_Fbr_Rts: %04x\n", ptcw_1_FbrRts);
5888 printk(KERN_DEBUG "MainRates: %04x ", mainrates); 5876 pr_debug("MainRates: %04x ", mainrates);
5889 printk(KERN_DEBUG "XtraFrameTypes: %04x ", xtraft); 5877 pr_debug("XtraFrameTypes: %04x ", xtraft);
5890 printk(KERN_DEBUG "\n"); 5878 pr_debug("\n");
5891 5879
5892 print_hex_dump_bytes("SecIV:", DUMP_PREFIX_OFFSET, iv, sizeof(txh->IV)); 5880 print_hex_dump_bytes("SecIV:", DUMP_PREFIX_OFFSET, iv, sizeof(txh->IV));
5893 print_hex_dump_bytes("RA:", DUMP_PREFIX_OFFSET, 5881 print_hex_dump_bytes("RA:", DUMP_PREFIX_OFFSET,
5894 ra, sizeof(txh->TxFrameRA)); 5882 ra, sizeof(txh->TxFrameRA));
5895 5883
5896 printk(KERN_DEBUG "Fb FES Time: %04x ", tfestfb); 5884 pr_debug("Fb FES Time: %04x ", tfestfb);
5897 print_hex_dump_bytes("Fb RTS PLCP:", DUMP_PREFIX_OFFSET, 5885 print_hex_dump_bytes("Fb RTS PLCP:", DUMP_PREFIX_OFFSET,
5898 rtspfb, sizeof(txh->RTSPLCPFallback)); 5886 rtspfb, sizeof(txh->RTSPLCPFallback));
5899 printk(KERN_DEBUG "RTS DUR: %04x ", rtsdfb); 5887 pr_debug("RTS DUR: %04x ", rtsdfb);
5900 print_hex_dump_bytes("PLCP:", DUMP_PREFIX_OFFSET, 5888 print_hex_dump_bytes("PLCP:", DUMP_PREFIX_OFFSET,
5901 fragpfb, sizeof(txh->FragPLCPFallback)); 5889 fragpfb, sizeof(txh->FragPLCPFallback));
5902 printk(KERN_DEBUG "DUR: %04x", fragdfb); 5890 pr_debug("DUR: %04x", fragdfb);
5903 printk(KERN_DEBUG "\n"); 5891 pr_debug("\n");
5904 5892
5905 printk(KERN_DEBUG "MModeLen: %04x ", mmodelen); 5893 pr_debug("MModeLen: %04x ", mmodelen);
5906 printk(KERN_DEBUG "MModeFbrLen: %04x\n", mmodefbrlen); 5894 pr_debug("MModeFbrLen: %04x\n", mmodefbrlen);
5907 5895
5908 printk(KERN_DEBUG "FrameID: %04x\n", tfid); 5896 pr_debug("FrameID: %04x\n", tfid);
5909 printk(KERN_DEBUG "TxStatus: %04x\n", txs); 5897 pr_debug("TxStatus: %04x\n", txs);
5910 5898
5911 printk(KERN_DEBUG "MaxNumMpdu: %04x\n", mnmpdu); 5899 pr_debug("MaxNumMpdu: %04x\n", mnmpdu);
5912 printk(KERN_DEBUG "MaxAggbyte: %04x\n", mabyte); 5900 pr_debug("MaxAggbyte: %04x\n", mabyte);
5913 printk(KERN_DEBUG "MaxAggbyte_fb: %04x\n", mabyte_f); 5901 pr_debug("MaxAggbyte_fb: %04x\n", mabyte_f);
5914 printk(KERN_DEBUG "MinByte: %04x\n", mmbyte); 5902 pr_debug("MinByte: %04x\n", mmbyte);
5915 5903
5916 print_hex_dump_bytes("RTS PLCP:", DUMP_PREFIX_OFFSET, 5904 print_hex_dump_bytes("RTS PLCP:", DUMP_PREFIX_OFFSET,
5917 rtsph, sizeof(txh->RTSPhyHeader)); 5905 rtsph, sizeof(txh->RTSPhyHeader));
5918 print_hex_dump_bytes("RTS Frame:", DUMP_PREFIX_OFFSET, 5906 print_hex_dump_bytes("RTS Frame:", DUMP_PREFIX_OFFSET,
5919 (u8 *)&rts, sizeof(txh->rts_frame)); 5907 (u8 *)&rts, sizeof(txh->rts_frame));
5920 printk(KERN_DEBUG "\n"); 5908 pr_debug("\n");
5921} 5909}
5922#endif /* defined(BCMDBG) */ 5910#endif /* defined(DEBUG) */
5923 5911
5924#if defined(BCMDBG) 5912#if defined(DEBUG)
5925static int 5913static int
5926brcms_c_format_flags(const struct brcms_c_bit_desc *bd, u32 flags, char *buf, 5914brcms_c_format_flags(const struct brcms_c_bit_desc *bd, u32 flags, char *buf,
5927 int len) 5915 int len)
@@ -5975,9 +5963,9 @@ brcms_c_format_flags(const struct brcms_c_bit_desc *bd, u32 flags, char *buf,
5975 5963
5976 return (int)(p - buf); 5964 return (int)(p - buf);
5977} 5965}
5978#endif /* defined(BCMDBG) */ 5966#endif /* defined(DEBUG) */
5979 5967
5980#if defined(BCMDBG) 5968#if defined(DEBUG)
5981void brcms_c_print_rxh(struct d11rxhdr *rxh) 5969void brcms_c_print_rxh(struct d11rxhdr *rxh)
5982{ 5970{
5983 u16 len = rxh->RxFrameSize; 5971 u16 len = rxh->RxFrameSize;
@@ -5999,24 +5987,22 @@ void brcms_c_print_rxh(struct d11rxhdr *rxh)
5999 {0, NULL} 5987 {0, NULL}
6000 }; 5988 };
6001 5989
6002 printk(KERN_DEBUG "Raw RxDesc:\n"); 5990 brcmu_dbg_hex_dump(rxh, sizeof(struct d11rxhdr), "Raw RxDesc:\n");
6003 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, rxh,
6004 sizeof(struct d11rxhdr));
6005 5991
6006 brcms_c_format_flags(macstat_flags, macstatus1, flagstr, 64); 5992 brcms_c_format_flags(macstat_flags, macstatus1, flagstr, 64);
6007 5993
6008 snprintf(lenbuf, sizeof(lenbuf), "0x%x", len); 5994 snprintf(lenbuf, sizeof(lenbuf), "0x%x", len);
6009 5995
6010 printk(KERN_DEBUG "RxFrameSize: %6s (%d)%s\n", lenbuf, len, 5996 pr_debug("RxFrameSize: %6s (%d)%s\n", lenbuf, len,
6011 (rxh->PhyRxStatus_0 & PRXS0_SHORTH) ? " short preamble" : ""); 5997 (rxh->PhyRxStatus_0 & PRXS0_SHORTH) ? " short preamble" : "");
6012 printk(KERN_DEBUG "RxPHYStatus: %04x %04x %04x %04x\n", 5998 pr_debug("RxPHYStatus: %04x %04x %04x %04x\n",
6013 phystatus_0, phystatus_1, phystatus_2, phystatus_3); 5999 phystatus_0, phystatus_1, phystatus_2, phystatus_3);
6014 printk(KERN_DEBUG "RxMACStatus: %x %s\n", macstatus1, flagstr); 6000 pr_debug("RxMACStatus: %x %s\n", macstatus1, flagstr);
6015 printk(KERN_DEBUG "RXMACaggtype: %x\n", 6001 pr_debug("RXMACaggtype: %x\n",
6016 (macstatus2 & RXS_AGGTYPE_MASK)); 6002 (macstatus2 & RXS_AGGTYPE_MASK));
6017 printk(KERN_DEBUG "RxTSFTime: %04x\n", rxh->RxTSFTime); 6003 pr_debug("RxTSFTime: %04x\n", rxh->RxTSFTime);
6018} 6004}
6019#endif /* defined(BCMDBG) */ 6005#endif /* defined(DEBUG) */
6020 6006
6021u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate) 6007u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate)
6022{ 6008{
@@ -8354,7 +8340,7 @@ brcms_c_attach(struct brcms_info *wl, struct bcma_device *core, uint unit,
8354 wlc->wiphy = wl->wiphy; 8340 wlc->wiphy = wl->wiphy;
8355 pub = wlc->pub; 8341 pub = wlc->pub;
8356 8342
8357#if defined(BCMDBG) 8343#if defined(DEBUG)
8358 wlc_info_dbg = wlc; 8344 wlc_info_dbg = wlc;
8359#endif 8345#endif
8360 8346
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.h b/drivers/net/wireless/brcm80211/brcmsmac/main.h
index adb136ec1f04..8debc74c54e1 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h
@@ -648,10 +648,12 @@ extern void brcms_c_print_txstatus(struct tx_status *txs);
648extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo, 648extern int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,
649 uint *blocks); 649 uint *blocks);
650 650
651#if defined(BCMDBG) 651#if defined(DEBUG)
652extern void brcms_c_print_txdesc(struct d11txh *txh); 652extern void brcms_c_print_txdesc(struct d11txh *txh);
653#else 653#else
654#define brcms_c_print_txdesc(a) 654static inline void brcms_c_print_txdesc(struct d11txh *txh)
655{
656}
655#endif 657#endif
656 658
657extern int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config); 659extern int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c
index a16f1ab292fd..ec7450d2fbd6 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c
@@ -14,6 +14,8 @@
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
17#include <linux/kernel.h> 19#include <linux/kernel.h>
18#include <linux/delay.h> 20#include <linux/delay.h>
19#include <linux/cordic.h> 21#include <linux/cordic.h>
@@ -26434,8 +26436,7 @@ cal_try:
26434 } 26436 }
26435 26437
26436 if (bcmerror != 0) { 26438 if (bcmerror != 0) {
26437 printk(KERN_DEBUG "%s: Failed, cnt = %d\n", __func__, 26439 pr_debug("%s: Failed, cnt = %d\n", __func__, cal_retry);
26438 cal_retry);
26439 26440
26440 if (cal_retry < CAL_RETRY_CNT) { 26441 if (cal_retry < CAL_RETRY_CNT) {
26441 cal_retry++; 26442 cal_retry++;
diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c
index b7537f70a795..b45ab34cdfdc 100644
--- a/drivers/net/wireless/brcm80211/brcmutil/utils.c
+++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c
@@ -14,6 +14,8 @@
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
17#include <linux/netdevice.h> 19#include <linux/netdevice.h>
18#include <linux/module.h> 20#include <linux/module.h>
19 21
@@ -240,17 +242,35 @@ struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp,
240} 242}
241EXPORT_SYMBOL(brcmu_pktq_mdeq); 243EXPORT_SYMBOL(brcmu_pktq_mdeq);
242 244
243#if defined(BCMDBG) 245#if defined(DEBUG)
244/* pretty hex print a pkt buffer chain */ 246/* pretty hex print a pkt buffer chain */
245void brcmu_prpkt(const char *msg, struct sk_buff *p0) 247void brcmu_prpkt(const char *msg, struct sk_buff *p0)
246{ 248{
247 struct sk_buff *p; 249 struct sk_buff *p;
248 250
249 if (msg && (msg[0] != '\0')) 251 if (msg && (msg[0] != '\0'))
250 printk(KERN_DEBUG "%s:\n", msg); 252 pr_debug("%s:\n", msg);
251 253
252 for (p = p0; p; p = p->next) 254 for (p = p0; p; p = p->next)
253 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, p->data, p->len); 255 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, p->data, p->len);
254} 256}
255EXPORT_SYMBOL(brcmu_prpkt); 257EXPORT_SYMBOL(brcmu_prpkt);
256#endif /* defined(BCMDBG) */ 258
259void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
260{
261 struct va_format vaf;
262 va_list args;
263
264 va_start(args, fmt);
265
266 vaf.fmt = fmt;
267 vaf.va = &args;
268
269 pr_debug("%pV", &vaf);
270
271 va_end(args);
272
273 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data, size);
274}
275EXPORT_SYMBOL(brcmu_dbg_hex_dump);
276#endif /* defined(DEBUG) */
diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
index ad249a0b4730..477b92ad3d62 100644
--- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h
+++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
@@ -176,10 +176,21 @@ struct ipv4_addr;
176 176
177/* externs */ 177/* externs */
178/* format/print */ 178/* format/print */
179#ifdef BCMDBG 179#ifdef DEBUG
180extern void brcmu_prpkt(const char *msg, struct sk_buff *p0); 180extern void brcmu_prpkt(const char *msg, struct sk_buff *p0);
181#else 181#else
182#define brcmu_prpkt(a, b) 182#define brcmu_prpkt(a, b)
183#endif /* BCMDBG */ 183#endif /* DEBUG */
184
185#ifdef DEBUG
186extern __printf(3, 4)
187void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...);
188#else
189__printf(3, 4)
190static inline
191void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
192{
193}
194#endif
184 195
185#endif /* _BRCMU_UTILS_H_ */ 196#endif /* _BRCMU_UTILS_H_ */
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index a8bddd81b4d1..aa15cc4269a1 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -347,11 +347,9 @@ static int hfa384x_cmd(struct net_device *dev, u16 cmd, u16 param0,
347 return -EINTR; 347 return -EINTR;
348 348
349 entry = kzalloc(sizeof(*entry), GFP_ATOMIC); 349 entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
350 if (entry == NULL) { 350 if (entry == NULL)
351 printk(KERN_DEBUG "%s: hfa384x_cmd - kmalloc failed\n",
352 dev->name);
353 return -ENOMEM; 351 return -ENOMEM;
354 } 352
355 atomic_set(&entry->usecnt, 1); 353 atomic_set(&entry->usecnt, 1);
356 entry->type = CMD_SLEEP; 354 entry->type = CMD_SLEEP;
357 entry->cmd = cmd; 355 entry->cmd = cmd;
@@ -515,11 +513,9 @@ static int hfa384x_cmd_callback(struct net_device *dev, u16 cmd, u16 param0,
515 } 513 }
516 514
517 entry = kzalloc(sizeof(*entry), GFP_ATOMIC); 515 entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
518 if (entry == NULL) { 516 if (entry == NULL)
519 printk(KERN_DEBUG "%s: hfa384x_cmd_callback - kmalloc "
520 "failed\n", dev->name);
521 return -ENOMEM; 517 return -ENOMEM;
522 } 518
523 atomic_set(&entry->usecnt, 1); 519 atomic_set(&entry->usecnt, 1);
524 entry->type = CMD_CALLBACK; 520 entry->type = CMD_CALLBACK;
525 entry->cmd = cmd; 521 entry->cmd = cmd;
@@ -2978,11 +2974,9 @@ static int prism2_set_tim(struct net_device *dev, int aid, int set)
2978 local = iface->local; 2974 local = iface->local;
2979 2975
2980 new_entry = kzalloc(sizeof(*new_entry), GFP_ATOMIC); 2976 new_entry = kzalloc(sizeof(*new_entry), GFP_ATOMIC);
2981 if (new_entry == NULL) { 2977 if (new_entry == NULL)
2982 printk(KERN_DEBUG "%s: prism2_set_tim: kmalloc failed\n",
2983 local->dev->name);
2984 return -ENOMEM; 2978 return -ENOMEM;
2985 } 2979
2986 new_entry->aid = aid; 2980 new_entry->aid = aid;
2987 new_entry->set = set; 2981 new_entry->set = set;
2988 2982
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c
index a0e5c21d3657..e847737ccc9d 100644
--- a/drivers/net/wireless/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/ipw2x00/ipw2100.c
@@ -3464,11 +3464,8 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv)
3464 priv->msg_buffers = 3464 priv->msg_buffers =
3465 kmalloc(IPW_COMMAND_POOL_SIZE * sizeof(struct ipw2100_tx_packet), 3465 kmalloc(IPW_COMMAND_POOL_SIZE * sizeof(struct ipw2100_tx_packet),
3466 GFP_KERNEL); 3466 GFP_KERNEL);
3467 if (!priv->msg_buffers) { 3467 if (!priv->msg_buffers)
3468 printk(KERN_ERR DRV_NAME ": %s: PCI alloc failed for msg "
3469 "buffers.\n", priv->net_dev->name);
3470 return -ENOMEM; 3468 return -ENOMEM;
3471 }
3472 3469
3473 for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) { 3470 for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) {
3474 v = pci_alloc_consistent(priv->pci_dev, 3471 v = pci_alloc_consistent(priv->pci_dev,
diff --git a/drivers/net/wireless/ipw2x00/libipw_module.c b/drivers/net/wireless/ipw2x00/libipw_module.c
index d5ef696298ee..3adb24021a28 100644
--- a/drivers/net/wireless/ipw2x00/libipw_module.c
+++ b/drivers/net/wireless/ipw2x00/libipw_module.c
@@ -150,10 +150,9 @@ struct net_device *alloc_libipw(int sizeof_priv, int monitor)
150 LIBIPW_DEBUG_INFO("Initializing...\n"); 150 LIBIPW_DEBUG_INFO("Initializing...\n");
151 151
152 dev = alloc_etherdev(sizeof(struct libipw_device) + sizeof_priv); 152 dev = alloc_etherdev(sizeof(struct libipw_device) + sizeof_priv);
153 if (!dev) { 153 if (!dev)
154 LIBIPW_ERROR("Unable to allocate network device.\n");
155 goto failed; 154 goto failed;
156 } 155
157 ieee = netdev_priv(dev); 156 ieee = netdev_priv(dev);
158 157
159 ieee->dev = dev; 158 ieee->dev = dev;
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index 1ef7bfc2ab25..cc04cce11567 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c
index 094693328dbb..00db092d8cd0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-2000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-2000.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index b3a365fea7bb..47fd98b3652c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 54b753399e6e..ab62c018fcdb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
index 50ff849c9f67..6aa009827865 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h
index 10275ce92bde..9ed6683314a7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hw.h b/drivers/net/wireless/iwlwifi/iwl-agn-hw.h
index 123ef5e129d5..d0ec0abd3c89 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-hw.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index 64cf439035c3..a8f7689aaacf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * GPL LICENSE SUMMARY 3 * GPL LICENSE SUMMARY
4 * 4 *
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 5 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 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 8 * it under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 334b5ae8fdd4..b9ba404d15c1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
index 6675b3c816d9..203b1c13c491 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c
index b22b2976f899..f127f913e5a6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project, as well 5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portionhelp of the ieee80211 subsystem header files. 6 * as portionhelp of the ieee80211 subsystem header files.
@@ -1172,20 +1172,22 @@ int iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb,
1172 wake_up_all(&priv->shrd->notif_waitq); 1172 wake_up_all(&priv->shrd->notif_waitq);
1173 } 1173 }
1174 1174
1175 if (priv->pre_rx_handler) 1175 if (priv->pre_rx_handler &&
1176 priv->shrd->ucode_owner == IWL_OWNERSHIP_TM)
1176 priv->pre_rx_handler(priv, rxb); 1177 priv->pre_rx_handler(priv, rxb);
1177 1178 else {
1178 /* Based on type of command response or notification, 1179 /* Based on type of command response or notification,
1179 * handle those that need handling via function in 1180 * handle those that need handling via function in
1180 * rx_handlers table. See iwl_setup_rx_handlers() */ 1181 * rx_handlers table. See iwl_setup_rx_handlers() */
1181 if (priv->rx_handlers[pkt->hdr.cmd]) { 1182 if (priv->rx_handlers[pkt->hdr.cmd]) {
1182 priv->rx_handlers_stats[pkt->hdr.cmd]++; 1183 priv->rx_handlers_stats[pkt->hdr.cmd]++;
1183 err = priv->rx_handlers[pkt->hdr.cmd] (priv, rxb, cmd); 1184 err = priv->rx_handlers[pkt->hdr.cmd] (priv, rxb, cmd);
1184 } else { 1185 } else {
1185 /* No handling needed */ 1186 /* No handling needed */
1186 IWL_DEBUG_RX(priv, 1187 IWL_DEBUG_RX(priv,
1187 "No handler needed for %s, 0x%02x\n", 1188 "No handler needed for %s, 0x%02x\n",
1188 get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); 1189 get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
1190 }
1189 } 1191 }
1190 return err; 1192 return err;
1191} 1193}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
index 1c6659416621..8ca9570ec365 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
index 7353826095f1..d6aab00272b9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project, as well 5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files. 6 * as portions of the ieee80211 subsystem header files.
@@ -35,9 +35,12 @@
35#include "iwl-trans.h" 35#include "iwl-trans.h"
36 36
37/* priv->shrd->sta_lock must be held */ 37/* priv->shrd->sta_lock must be held */
38static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) 38static int iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
39{ 39{
40 40 if (sta_id >= IWLAGN_STATION_COUNT) {
41 IWL_ERR(priv, "invalid sta_id %u", sta_id);
42 return -EINVAL;
43 }
41 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) 44 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE))
42 IWL_ERR(priv, "ACTIVATE a non DRIVER active station id %u " 45 IWL_ERR(priv, "ACTIVATE a non DRIVER active station id %u "
43 "addr %pM\n", 46 "addr %pM\n",
@@ -53,6 +56,7 @@ static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
53 IWL_DEBUG_ASSOC(priv, "Added STA id %u addr %pM to uCode\n", 56 IWL_DEBUG_ASSOC(priv, "Added STA id %u addr %pM to uCode\n",
54 sta_id, priv->stations[sta_id].sta.sta.addr); 57 sta_id, priv->stations[sta_id].sta.sta.addr);
55 } 58 }
59 return 0;
56} 60}
57 61
58static int iwl_process_add_sta_resp(struct iwl_priv *priv, 62static int iwl_process_add_sta_resp(struct iwl_priv *priv,
@@ -77,8 +81,7 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv,
77 switch (pkt->u.add_sta.status) { 81 switch (pkt->u.add_sta.status) {
78 case ADD_STA_SUCCESS_MSK: 82 case ADD_STA_SUCCESS_MSK:
79 IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n"); 83 IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n");
80 iwl_sta_ucode_activate(priv, sta_id); 84 ret = iwl_sta_ucode_activate(priv, sta_id);
81 ret = 0;
82 break; 85 break;
83 case ADD_STA_NO_ROOM_IN_TABLE: 86 case ADD_STA_NO_ROOM_IN_TABLE:
84 IWL_ERR(priv, "Adding station %d failed, no room in table.\n", 87 IWL_ERR(priv, "Adding station %d failed, no room in table.\n",
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c
index b0dff7a753a5..56c6def015a4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project, as well 5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files. 6 * as portions of the ieee80211 subsystem header files.
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.h b/drivers/net/wireless/iwlwifi/iwl-agn-tt.h
index 7282a23e8f1c..86bbf47501c1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project, as well 5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files. 6 * as portions of the ieee80211 subsystem header files.
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index 63bbc60be28e..64f8db685dc5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * GPL LICENSE SUMMARY 3 * GPL LICENSE SUMMARY
4 * 4 *
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 5 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 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 8 * it under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index b5c7c5f0a753..90315c69cdf6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project, as well 5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files. 6 * as portions of the ieee80211 subsystem header files.
@@ -315,7 +315,7 @@ static void iwl_bg_statistics_periodic(unsigned long data)
315 315
316static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, 316static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base,
317 u32 start_idx, u32 num_events, 317 u32 start_idx, u32 num_events,
318 u32 mode) 318 u32 capacity, u32 mode)
319{ 319{
320 u32 i; 320 u32 i;
321 u32 ptr; /* SRAM byte address of log data */ 321 u32 ptr; /* SRAM byte address of log data */
@@ -339,6 +339,15 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base,
339 rmb(); 339 rmb();
340 340
341 /* 341 /*
342 * Refuse to read more than would have fit into the log from
343 * the current start_idx. This used to happen due to the race
344 * described below, but now WARN because the code below should
345 * prevent it from happening here.
346 */
347 if (WARN_ON(num_events > capacity - start_idx))
348 num_events = capacity - start_idx;
349
350 /*
342 * "time" is actually "data" for mode 0 (no timestamp). 351 * "time" is actually "data" for mode 0 (no timestamp).
343 * place event id # at far right for easier visual parsing. 352 * place event id # at far right for easier visual parsing.
344 */ 353 */
@@ -346,12 +355,11 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base,
346 ev = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); 355 ev = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT);
347 time = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); 356 time = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT);
348 if (mode == 0) { 357 if (mode == 0) {
349 trace_iwlwifi_dev_ucode_cont_event(priv, 358 trace_iwlwifi_dev_ucode_cont_event(priv, 0, time, ev);
350 0, time, ev);
351 } else { 359 } else {
352 data = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); 360 data = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT);
353 trace_iwlwifi_dev_ucode_cont_event(priv, 361 trace_iwlwifi_dev_ucode_cont_event(priv, time,
354 time, data, ev); 362 data, ev);
355 } 363 }
356 } 364 }
357 /* Allow device to power down */ 365 /* Allow device to power down */
@@ -362,53 +370,83 @@ static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base,
362static void iwl_continuous_event_trace(struct iwl_priv *priv) 370static void iwl_continuous_event_trace(struct iwl_priv *priv)
363{ 371{
364 u32 capacity; /* event log capacity in # entries */ 372 u32 capacity; /* event log capacity in # entries */
373 struct {
374 u32 capacity;
375 u32 mode;
376 u32 wrap_counter;
377 u32 write_counter;
378 } __packed read;
365 u32 base; /* SRAM byte address of event log header */ 379 u32 base; /* SRAM byte address of event log header */
366 u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */ 380 u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */
367 u32 num_wraps; /* # times uCode wrapped to top of log */ 381 u32 num_wraps; /* # times uCode wrapped to top of log */
368 u32 next_entry; /* index of next entry to be written by uCode */ 382 u32 next_entry; /* index of next entry to be written by uCode */
369 383
370 base = priv->shrd->device_pointers.error_event_table; 384 base = priv->shrd->device_pointers.log_event_table;
371 if (iwlagn_hw_valid_rtc_data_addr(base)) { 385 if (iwlagn_hw_valid_rtc_data_addr(base)) {
372 capacity = iwl_read_targ_mem(bus(priv), base); 386 iwl_read_targ_mem_words(bus(priv), base, &read, sizeof(read));
373 num_wraps = iwl_read_targ_mem(bus(priv), 387
374 base + (2 * sizeof(u32))); 388 capacity = read.capacity;
375 mode = iwl_read_targ_mem(bus(priv), base + (1 * sizeof(u32))); 389 mode = read.mode;
376 next_entry = iwl_read_targ_mem(bus(priv), 390 num_wraps = read.wrap_counter;
377 base + (3 * sizeof(u32))); 391 next_entry = read.write_counter;
378 } else 392 } else
379 return; 393 return;
380 394
395 /*
396 * Unfortunately, the uCode doesn't use temporary variables.
397 * Therefore, it can happen that we read next_entry == capacity,
398 * which really means next_entry == 0.
399 */
400 if (unlikely(next_entry == capacity))
401 next_entry = 0;
402 /*
403 * Additionally, the uCode increases the write pointer before
404 * the wraps counter, so if the write pointer is smaller than
405 * the old write pointer (wrap occurred) but we read that no
406 * wrap occurred, we actually read between the next_entry and
407 * num_wraps update (this does happen in practice!!) -- take
408 * that into account by increasing num_wraps.
409 */
410 if (unlikely(next_entry < priv->event_log.next_entry &&
411 num_wraps == priv->event_log.num_wraps))
412 num_wraps++;
413
381 if (num_wraps == priv->event_log.num_wraps) { 414 if (num_wraps == priv->event_log.num_wraps) {
382 iwl_print_cont_event_trace(priv, 415 iwl_print_cont_event_trace(
383 base, priv->event_log.next_entry, 416 priv, base, priv->event_log.next_entry,
384 next_entry - priv->event_log.next_entry, 417 next_entry - priv->event_log.next_entry,
385 mode); 418 capacity, mode);
419
386 priv->event_log.non_wraps_count++; 420 priv->event_log.non_wraps_count++;
387 } else { 421 } else {
388 if ((num_wraps - priv->event_log.num_wraps) > 1) 422 if (num_wraps - priv->event_log.num_wraps > 1)
389 priv->event_log.wraps_more_count++; 423 priv->event_log.wraps_more_count++;
390 else 424 else
391 priv->event_log.wraps_once_count++; 425 priv->event_log.wraps_once_count++;
426
392 trace_iwlwifi_dev_ucode_wrap_event(priv, 427 trace_iwlwifi_dev_ucode_wrap_event(priv,
393 num_wraps - priv->event_log.num_wraps, 428 num_wraps - priv->event_log.num_wraps,
394 next_entry, priv->event_log.next_entry); 429 next_entry, priv->event_log.next_entry);
430
395 if (next_entry < priv->event_log.next_entry) { 431 if (next_entry < priv->event_log.next_entry) {
396 iwl_print_cont_event_trace(priv, base, 432 iwl_print_cont_event_trace(
397 priv->event_log.next_entry, 433 priv, base, priv->event_log.next_entry,
398 capacity - priv->event_log.next_entry, 434 capacity - priv->event_log.next_entry,
399 mode); 435 capacity, mode);
400 436
401 iwl_print_cont_event_trace(priv, base, 0, 437 iwl_print_cont_event_trace(
402 next_entry, mode); 438 priv, base, 0, next_entry, capacity, mode);
403 } else { 439 } else {
404 iwl_print_cont_event_trace(priv, base, 440 iwl_print_cont_event_trace(
405 next_entry, capacity - next_entry, 441 priv, base, next_entry,
406 mode); 442 capacity - next_entry,
443 capacity, mode);
407 444
408 iwl_print_cont_event_trace(priv, base, 0, 445 iwl_print_cont_event_trace(
409 next_entry, mode); 446 priv, base, 0, next_entry, capacity, mode);
410 } 447 }
411 } 448 }
449
412 priv->event_log.num_wraps = num_wraps; 450 priv->event_log.num_wraps = num_wraps;
413 priv->event_log.next_entry = next_entry; 451 priv->event_log.next_entry = next_entry;
414} 452}
@@ -1219,6 +1257,11 @@ int iwl_alive_start(struct iwl_priv *priv)
1219 if (iwl_is_rfkill(priv->shrd)) 1257 if (iwl_is_rfkill(priv->shrd))
1220 return -ERFKILL; 1258 return -ERFKILL;
1221 1259
1260 if (priv->event_log.ucode_trace) {
1261 /* start collecting data now */
1262 mod_timer(&priv->ucode_trace, jiffies);
1263 }
1264
1222 /* download priority table before any calibration request */ 1265 /* download priority table before any calibration request */
1223 if (cfg(priv)->bt_params && 1266 if (cfg(priv)->bt_params &&
1224 cfg(priv)->bt_params->advanced_bt_coexist) { 1267 cfg(priv)->bt_params->advanced_bt_coexist) {
@@ -2054,7 +2097,7 @@ MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)");
2054 2097
2055module_param_named(led_mode, iwlagn_mod_params.led_mode, int, S_IRUGO); 2098module_param_named(led_mode, iwlagn_mod_params.led_mode, int, S_IRUGO);
2056MODULE_PARM_DESC(led_mode, "0=system default, " 2099MODULE_PARM_DESC(led_mode, "0=system default, "
2057 "1=On(RF On)/Off(RF Off), 2=blinking (default: 0)"); 2100 "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)");
2058 2101
2059module_param_named(power_save, iwlagn_mod_params.power_save, 2102module_param_named(power_save, iwlagn_mod_params.power_save,
2060 bool, S_IRUGO); 2103 bool, S_IRUGO);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index f84fb3c53563..39cbe1a1577c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h
index 940d5038b39c..941b9cb23442 100644
--- a/drivers/net/wireless/iwlwifi/iwl-bus.h
+++ b/drivers/net/wireless/iwlwifi/iwl-bus.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-cfg.h b/drivers/net/wireless/iwlwifi/iwl-cfg.h
index e1d78257e4a9..957bc00cdaf0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-cfg.h
+++ b/drivers/net/wireless/iwlwifi/iwl-cfg.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index f822ac447c3b..c20618d92268 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 7bcfa781e0b9..7d6eef96454a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * GPL LICENSE SUMMARY 3 * GPL LICENSE SUMMARY
4 * 4 *
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 5 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 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 8 * it under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 7bf76ab94dd2..63f29111da13 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h
index fbc3095c7b44..5f96ce105f08 100644
--- a/drivers/net/wireless/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/iwlwifi/iwl-csr.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index f8fc2393dd4c..6f7612781e03 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project. 5 * Portions of this file are derived from the ipw3945 project.
6 * 6 *
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 04a3343f4610..978a1d4c6a0a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * GPL LICENSE SUMMARY 3 * GPL LICENSE SUMMARY
4 * 4 *
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 5 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 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 8 * it under the terms of version 2 of the GNU General Public License as
@@ -2131,9 +2131,10 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
2131 2131
2132 if (trace) { 2132 if (trace) {
2133 priv->event_log.ucode_trace = true; 2133 priv->event_log.ucode_trace = true;
2134 /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */ 2134 if (iwl_is_alive(priv->shrd)) {
2135 mod_timer(&priv->ucode_trace, 2135 /* start collecting data now */
2136 jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD)); 2136 mod_timer(&priv->ucode_trace, jiffies);
2137 }
2137 } else { 2138 } else {
2138 priv->event_log.ucode_trace = false; 2139 priv->event_log.ucode_trace = false;
2139 del_timer_sync(&priv->ucode_trace); 2140 del_timer_sync(&priv->ucode_trace);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index e54a4d11e584..af846002150a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -661,7 +661,7 @@ struct traffic_stats {
661 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds 661 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
662 * to perform continuous uCode event logging operation if enabled 662 * to perform continuous uCode event logging operation if enabled
663 */ 663 */
664#define UCODE_TRACE_PERIOD (100) 664#define UCODE_TRACE_PERIOD (10)
665 665
666/* 666/*
667 * iwl_event_log: current uCode event log position 667 * iwl_event_log: current uCode event log position
diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.c b/drivers/net/wireless/iwlwifi/iwl-devtrace.c
index 2a2c8de64a04..91f45e71e0a2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-devtrace.c
+++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2009 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.h b/drivers/net/wireless/iwlwifi/iwl-devtrace.h
index 9b212a8f30bb..4d892211ce4c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-devtrace.h
+++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2009 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index c1eda9724f42..e27d9f55267b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index 9fa937ec35e3..13f2d3928ef8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-fh.h b/drivers/net/wireless/iwlwifi/iwl-fh.h
index 5bede9d7f955..90208094b8eb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-fh.h
+++ b/drivers/net/wireless/iwlwifi/iwl-fh.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.c b/drivers/net/wireless/iwlwifi/iwl-io.c
index d57ea6484bbe..83fdff381150 100644
--- a/drivers/net/wireless/iwlwifi/iwl-io.c
+++ b/drivers/net/wireless/iwlwifi/iwl-io.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project. 5 * Portions of this file are derived from the ipw3945 project.
6 * 6 *
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h
index aae2eeb331a8..427d065435c8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-io.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project. 5 * Portions of this file are derived from the ipw3945 project.
6 * 6 *
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c
index 14dcbfcdc0fd..8761438f1532 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-led.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -177,6 +177,10 @@ void iwl_leds_init(struct iwl_priv *priv)
177 int mode = iwlagn_mod_params.led_mode; 177 int mode = iwlagn_mod_params.led_mode;
178 int ret; 178 int ret;
179 179
180 if (mode == IWL_LED_DISABLE) {
181 IWL_INFO(priv, "Led disabled\n");
182 return;
183 }
180 if (mode == IWL_LED_DEFAULT) 184 if (mode == IWL_LED_DEFAULT)
181 mode = cfg(priv)->led_mode; 185 mode = cfg(priv)->led_mode;
182 186
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.h b/drivers/net/wireless/iwlwifi/iwl-led.h
index 2550b3c7dcbf..b02a853103d3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.h
+++ b/drivers/net/wireless/iwlwifi/iwl-led.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c
index f980e574e1f9..965d0475affd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c
+++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project, as well 5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files. 6 * as portions of the ieee80211 subsystem header files.
diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c
index fb30ea7ca96b..03702a2e913a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-pci.c
+++ b/drivers/net/wireless/iwlwifi/iwl-pci.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 2b188a6025b3..c7394ef2e490 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project, as well 5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files. 6 * as portions of the ieee80211 subsystem header files.
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.h b/drivers/net/wireless/iwlwifi/iwl-power.h
index 5f7b720cf1a4..07a19fce5fdc 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.h
+++ b/drivers/net/wireless/iwlwifi/iwl-power.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project, as well 5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files. 6 * as portions of the ieee80211 subsystem header files.
diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h
index bebdd828f324..a4d11016c3b4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-prph.h
+++ b/drivers/net/wireless/iwlwifi/iwl-prph.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index a6454726737e..7f2e3a1c80ef 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * GPL LICENSE SUMMARY 3 * GPL LICENSE SUMMARY
4 * 4 *
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 5 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 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 8 * it under the terms of version 2 of the GNU General Public License as
@@ -414,10 +414,25 @@ static u16 iwl_limit_dwell(struct iwl_priv *priv, u16 dwell_time)
414 for_each_context(priv, ctx) { 414 for_each_context(priv, ctx) {
415 u16 value; 415 u16 value;
416 416
417 if (!iwl_is_associated_ctx(ctx)) 417 switch (ctx->staging.dev_type) {
418 continue; 418 case RXON_DEV_TYPE_P2P:
419 if (ctx->staging.dev_type == RXON_DEV_TYPE_P2P) 419 /* no timing constraints */
420 continue; 420 continue;
421 case RXON_DEV_TYPE_ESS:
422 default:
423 /* timing constraints if associated */
424 if (!iwl_is_associated_ctx(ctx))
425 continue;
426 break;
427 case RXON_DEV_TYPE_CP:
428 case RXON_DEV_TYPE_2STA:
429 /*
430 * These seem to always have timers for TBTT
431 * active in uCode even when not associated yet.
432 */
433 break;
434 }
435
421 value = ctx->beacon_int; 436 value = ctx->beacon_int;
422 if (!value) 437 if (!value)
423 value = IWL_PASSIVE_DWELL_BASE; 438 value = IWL_PASSIVE_DWELL_BASE;
diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h
index dc55cc4a8108..04975b7b65b3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-shared.h
+++ b/drivers/net/wireless/iwlwifi/iwl-shared.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
@@ -102,7 +102,7 @@ struct iwl_trans_ops;
102 102
103#define DRV_NAME "iwlwifi" 103#define DRV_NAME "iwlwifi"
104#define IWLWIFI_VERSION "in-tree:" 104#define IWLWIFI_VERSION "in-tree:"
105#define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" 105#define DRV_COPYRIGHT "Copyright(c) 2003-2012 Intel Corporation"
106#define DRV_AUTHOR "<ilw@linux.intel.com>" 106#define DRV_AUTHOR "<ilw@linux.intel.com>"
107 107
108extern struct iwl_mod_params iwlagn_mod_params; 108extern struct iwl_mod_params iwlagn_mod_params;
@@ -264,11 +264,13 @@ enum iwl_pa_type {
264 * LED ON = RF ON 264 * LED ON = RF ON
265 * LED OFF = RF OFF 265 * LED OFF = RF OFF
266 * IWL_LED_BLINK: adjust led blink rate based on blink table 266 * IWL_LED_BLINK: adjust led blink rate based on blink table
267 * IWL_LED_DISABLE: led disabled
267 */ 268 */
268enum iwl_led_mode { 269enum iwl_led_mode {
269 IWL_LED_DEFAULT, 270 IWL_LED_DEFAULT,
270 IWL_LED_RF_STATE, 271 IWL_LED_RF_STATE,
271 IWL_LED_BLINK, 272 IWL_LED_BLINK,
273 IWL_LED_DISABLE,
272}; 274};
273 275
274/** 276/**
diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c
index 4a5cddd2d56b..a56a77b8f926 100644
--- a/drivers/net/wireless/iwlwifi/iwl-testmode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
@@ -115,6 +115,9 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = {
115 115
116 [IWL_TM_ATTR_FW_VERSION] = { .type = NLA_U32, }, 116 [IWL_TM_ATTR_FW_VERSION] = { .type = NLA_U32, },
117 [IWL_TM_ATTR_DEVICE_ID] = { .type = NLA_U32, }, 117 [IWL_TM_ATTR_DEVICE_ID] = { .type = NLA_U32, },
118 [IWL_TM_ATTR_FW_TYPE] = { .type = NLA_U32, },
119 [IWL_TM_ATTR_FW_INST_SIZE] = { .type = NLA_U32, },
120 [IWL_TM_ATTR_FW_DATA_SIZE] = { .type = NLA_U32, },
118}; 121};
119 122
120/* 123/*
@@ -299,7 +302,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb)
299 302
300 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { 303 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
301 case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: 304 case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32:
302 val32 = iwl_read32(bus(priv), ofs); 305 val32 = iwl_read_direct32(bus(priv), ofs);
303 IWL_INFO(priv, "32bit value to read 0x%x\n", val32); 306 IWL_INFO(priv, "32bit value to read 0x%x\n", val32);
304 307
305 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); 308 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
@@ -321,7 +324,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb)
321 } else { 324 } else {
322 val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); 325 val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]);
323 IWL_INFO(priv, "32bit value to write 0x%x\n", val32); 326 IWL_INFO(priv, "32bit value to write 0x%x\n", val32);
324 iwl_write32(bus(priv), ofs, val32); 327 iwl_write_direct32(bus(priv), ofs, val32);
325 } 328 }
326 break; 329 break;
327 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: 330 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8:
@@ -422,7 +425,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
422 struct sk_buff *skb; 425 struct sk_buff *skb;
423 unsigned char *rsp_data_ptr = NULL; 426 unsigned char *rsp_data_ptr = NULL;
424 int status = 0, rsp_data_len = 0; 427 int status = 0, rsp_data_len = 0;
425 u32 devid; 428 u32 devid, inst_size = 0, data_size = 0;
426 429
427 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { 430 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
428 case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: 431 case IWL_TM_CMD_APP2DEV_GET_DEVICENAME:
@@ -548,6 +551,41 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
548 "Error sending msg : %d\n", status); 551 "Error sending msg : %d\n", status);
549 break; 552 break;
550 553
554 case IWL_TM_CMD_APP2DEV_GET_FW_INFO:
555 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20 + 8);
556 if (!skb) {
557 IWL_DEBUG_INFO(priv, "Error allocating memory\n");
558 return -ENOMEM;
559 }
560 switch (priv->shrd->ucode_type) {
561 case IWL_UCODE_REGULAR:
562 inst_size = trans(priv)->ucode_rt.code.len;
563 data_size = trans(priv)->ucode_rt.data.len;
564 break;
565 case IWL_UCODE_INIT:
566 inst_size = trans(priv)->ucode_init.code.len;
567 data_size = trans(priv)->ucode_init.data.len;
568 break;
569 case IWL_UCODE_WOWLAN:
570 inst_size = trans(priv)->ucode_wowlan.code.len;
571 data_size = trans(priv)->ucode_wowlan.data.len;
572 break;
573 case IWL_UCODE_NONE:
574 IWL_DEBUG_INFO(priv, "The uCode has not been loaded\n");
575 break;
576 default:
577 IWL_DEBUG_INFO(priv, "Unsupported uCode type\n");
578 break;
579 }
580 NLA_PUT_U32(skb, IWL_TM_ATTR_FW_TYPE, priv->shrd->ucode_type);
581 NLA_PUT_U32(skb, IWL_TM_ATTR_FW_INST_SIZE, inst_size);
582 NLA_PUT_U32(skb, IWL_TM_ATTR_FW_DATA_SIZE, data_size);
583 status = cfg80211_testmode_reply(skb);
584 if (status < 0)
585 IWL_DEBUG_INFO(priv,
586 "Error sending msg : %d\n", status);
587 break;
588
551 default: 589 default:
552 IWL_DEBUG_INFO(priv, "Unknown testmode driver command ID\n"); 590 IWL_DEBUG_INFO(priv, "Unknown testmode driver command ID\n");
553 return -ENOSYS; 591 return -ENOSYS;
@@ -733,7 +771,7 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb)
733static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) 771static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb)
734{ 772{
735 struct iwl_priv *priv = hw->priv; 773 struct iwl_priv *priv = hw->priv;
736 u32 base, ofs, size, maxsize; 774 u32 ofs, size, maxsize;
737 775
738 if (priv->testmode_sram.sram_readed) 776 if (priv->testmode_sram.sram_readed)
739 return -EBUSY; 777 return -EBUSY;
@@ -759,25 +797,24 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb)
759 maxsize = trans(priv)->ucode_wowlan.data.len; 797 maxsize = trans(priv)->ucode_wowlan.data.len;
760 break; 798 break;
761 case IWL_UCODE_NONE: 799 case IWL_UCODE_NONE:
762 IWL_DEBUG_INFO(priv, "Error, uCode does not been loaded\n"); 800 IWL_ERR(priv, "Error, uCode does not been loaded\n");
763 return -ENOSYS; 801 return -ENOSYS;
764 default: 802 default:
765 IWL_DEBUG_INFO(priv, "Error, unsupported uCode type\n"); 803 IWL_ERR(priv, "Error, unsupported uCode type\n");
766 return -ENOSYS; 804 return -ENOSYS;
767 } 805 }
768 if ((ofs + size) > maxsize) { 806 if ((ofs + size) > (maxsize + SRAM_DATA_SEG_OFFSET)) {
769 IWL_DEBUG_INFO(priv, "Invalid offset/size: out of range\n"); 807 IWL_ERR(priv, "Invalid offset/size: out of range\n");
770 return -EINVAL; 808 return -EINVAL;
771 } 809 }
772 priv->testmode_sram.buff_size = (size / 4) * 4; 810 priv->testmode_sram.buff_size = (size / 4) * 4;
773 priv->testmode_sram.buff_addr = 811 priv->testmode_sram.buff_addr =
774 kmalloc(priv->testmode_sram.buff_size, GFP_KERNEL); 812 kmalloc(priv->testmode_sram.buff_size, GFP_KERNEL);
775 if (priv->testmode_sram.buff_addr == NULL) { 813 if (priv->testmode_sram.buff_addr == NULL) {
776 IWL_DEBUG_INFO(priv, "Error allocating memory\n"); 814 IWL_ERR(priv, "Error allocating memory\n");
777 return -ENOMEM; 815 return -ENOMEM;
778 } 816 }
779 base = 0x800000; 817 _iwl_read_targ_mem_words(bus(priv), ofs,
780 _iwl_read_targ_mem_words(bus(priv), base + ofs,
781 priv->testmode_sram.buff_addr, 818 priv->testmode_sram.buff_addr,
782 priv->testmode_sram.buff_size / 4); 819 priv->testmode_sram.buff_size / 4);
783 priv->testmode_sram.num_chunks = 820 priv->testmode_sram.num_chunks =
@@ -882,6 +919,7 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
882 case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: 919 case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW:
883 case IWL_TM_CMD_APP2DEV_GET_FW_VERSION: 920 case IWL_TM_CMD_APP2DEV_GET_FW_VERSION:
884 case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: 921 case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID:
922 case IWL_TM_CMD_APP2DEV_GET_FW_INFO:
885 IWL_DEBUG_INFO(priv, "testmode cmd to driver\n"); 923 IWL_DEBUG_INFO(priv, "testmode cmd to driver\n");
886 result = iwl_testmode_driver(hw, tb); 924 result = iwl_testmode_driver(hw, tb);
887 break; 925 break;
diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h
index 26138f110340..f97d06169b45 100644
--- a/drivers/net/wireless/iwlwifi/iwl-testmode.h
+++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
@@ -111,15 +111,17 @@
111 * 111 *
112 * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: 112 * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32:
113 * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: 113 * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32:
114 * commands from user applicaiton to indirectly access peripheral register 114 * commands from user application to indirectly access peripheral register
115 * 115 *
116 * @IWL_TM_CMD_APP2DEV_READ_SRAM: 116 * @IWL_TM_CMD_APP2DEV_READ_SRAM:
117 * @IWL_TM_CMD_APP2DEV_DUMP_SRAM: 117 * @IWL_TM_CMD_APP2DEV_DUMP_SRAM:
118 * commands from user applicaiton to read data in sram 118 * commands from user application to read data in sram
119 * 119 *
120 * @IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: load Weak On Wireless LAN uCode image 120 * @IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: load Wake On Wireless LAN uCode image
121 * @IWL_TM_CMD_APP2DEV_GET_FW_VERSION: retrieve uCode version 121 * @IWL_TM_CMD_APP2DEV_GET_FW_VERSION: retrieve uCode version
122 * @IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: retrieve ID information in device 122 * @IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: retrieve ID information in device
123 * @IWL_TM_CMD_APP2DEV_GET_FW_INFO:
124 * retrieve information of existing loaded uCode image
123 * 125 *
124 */ 126 */
125enum iwl_tm_cmd_t { 127enum iwl_tm_cmd_t {
@@ -147,7 +149,8 @@ enum iwl_tm_cmd_t {
147 IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW = 22, 149 IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW = 22,
148 IWL_TM_CMD_APP2DEV_GET_FW_VERSION = 23, 150 IWL_TM_CMD_APP2DEV_GET_FW_VERSION = 23,
149 IWL_TM_CMD_APP2DEV_GET_DEVICE_ID = 24, 151 IWL_TM_CMD_APP2DEV_GET_DEVICE_ID = 24,
150 IWL_TM_CMD_MAX = 25, 152 IWL_TM_CMD_APP2DEV_GET_FW_INFO = 25,
153 IWL_TM_CMD_MAX = 26,
151}; 154};
152 155
153/* 156/*
@@ -237,6 +240,15 @@ enum iwl_tm_cmd_t {
237 * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_DEVICE_ID, 240 * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_DEVICE_ID,
238 * IWL_TM_ATTR_DEVICE_ID for the device ID information 241 * IWL_TM_ATTR_DEVICE_ID for the device ID information
239 * 242 *
243 * @IWL_TM_ATTR_FW_TYPE:
244 * @IWL_TM_ATTR_FW_INST_SIZE:
245 * @IWL_TM_ATTR_FW_DATA_SIZE:
246 * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_FW_INFO,
247 * The mandatory fields are:
248 * IWL_TM_ATTR_FW_TYPE for the uCode type (INIT/RUNTIME/...)
249 * IWL_TM_ATTR_FW_INST_SIZE for the size of instruction section
250 * IWL_TM_ATTR_FW_DATA_SIZE for the size of data section
251 *
240 */ 252 */
241enum iwl_tm_attr_t { 253enum iwl_tm_attr_t {
242 IWL_TM_ATTR_NOT_APPLICABLE = 0, 254 IWL_TM_ATTR_NOT_APPLICABLE = 0,
@@ -259,7 +271,10 @@ enum iwl_tm_attr_t {
259 IWL_TM_ATTR_SRAM_DUMP = 17, 271 IWL_TM_ATTR_SRAM_DUMP = 17,
260 IWL_TM_ATTR_FW_VERSION = 18, 272 IWL_TM_ATTR_FW_VERSION = 18,
261 IWL_TM_ATTR_DEVICE_ID = 19, 273 IWL_TM_ATTR_DEVICE_ID = 19,
262 IWL_TM_ATTR_MAX = 20, 274 IWL_TM_ATTR_FW_TYPE = 20,
275 IWL_TM_ATTR_FW_INST_SIZE = 21,
276 IWL_TM_ATTR_FW_DATA_SIZE = 22,
277 IWL_TM_ATTR_MAX = 23,
263}; 278};
264 279
265/* uCode trace buffer */ 280/* uCode trace buffer */
@@ -271,4 +286,7 @@ enum iwl_tm_attr_t {
271/* Maximum data size of each dump it packet */ 286/* Maximum data size of each dump it packet */
272#define DUMP_CHUNK_SIZE (PAGE_SIZE - 1024) 287#define DUMP_CHUNK_SIZE (PAGE_SIZE - 1024)
273 288
289/* Address offset of data segment in SRAM */
290#define SRAM_DATA_SEG_OFFSET 0x800000
291
274#endif 292#endif
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h
index f6debf91d7b5..0ac9b4d30271 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project, as well 5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files. 6 * as portions of the ieee80211 subsystem header files.
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
index 65d1f05007be..2900db973aaa 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project, as well 5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files. 6 * as portions of the ieee80211 subsystem header files.
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c
index bd29568177e6..30814b55705e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 3 * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions of this file are derived from the ipw3945 project, as well 5 * Portions of this file are derived from the ipw3945 project, as well
6 * as portions of the ieee80211 subsystem header files. 6 * as portions of the ieee80211 subsystem header files.
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
index 324d06dfb690..3c64c4e5885b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.c b/drivers/net/wireless/iwlwifi/iwl-trans.c
index 1b20c4fb791b..506c062343b2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h
index e6bf3f554772..42a9f303f543 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c
index 36a1b5b25858..2edf0ef65a5b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * GPL LICENSE SUMMARY 3 * GPL LICENSE SUMMARY
4 * 4 *
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 5 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 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 8 * it under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/iwlwifi/iwl-wifi.h b/drivers/net/wireless/iwlwifi/iwl-wifi.h
index 18501101a530..7e6eb20823cf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-wifi.h
+++ b/drivers/net/wireless/iwlwifi/iwl-wifi.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * GPL LICENSE SUMMARY 6 * GPL LICENSE SUMMARY
7 * 7 *
8 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of version 2 of the GNU General Public License as
@@ -30,7 +30,7 @@
30 * 30 *
31 * BSD LICENSE 31 * BSD LICENSE
32 * 32 *
33 * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 33 * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved. 34 * All rights reserved.
35 * 35 *
36 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index 3f7bf4d912b6..234ee88dec95 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -815,10 +815,9 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
815 lbs_deb_enter(LBS_DEB_CS); 815 lbs_deb_enter(LBS_DEB_CS);
816 816
817 card = kzalloc(sizeof(struct if_cs_card), GFP_KERNEL); 817 card = kzalloc(sizeof(struct if_cs_card), GFP_KERNEL);
818 if (!card) { 818 if (!card)
819 pr_err("error in kzalloc\n");
820 goto out; 819 goto out;
821 } 820
822 card->p_dev = p_dev; 821 card->p_dev = p_dev;
823 p_dev->priv = card; 822 p_dev->priv = card;
824 823
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index b5fbbc7947df..74da5f1ea243 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -261,10 +261,8 @@ static int if_usb_probe(struct usb_interface *intf,
261 udev = interface_to_usbdev(intf); 261 udev = interface_to_usbdev(intf);
262 262
263 cardp = kzalloc(sizeof(struct if_usb_card), GFP_KERNEL); 263 cardp = kzalloc(sizeof(struct if_usb_card), GFP_KERNEL);
264 if (!cardp) { 264 if (!cardp)
265 pr_err("Out of memory allocating private data\n");
266 goto error; 265 goto error;
267 }
268 266
269 setup_timer(&cardp->fw_timeout, if_usb_fw_timeo, (unsigned long)cardp); 267 setup_timer(&cardp->fw_timeout, if_usb_fw_timeo, (unsigned long)cardp);
270 init_waitqueue_head(&cardp->fw_wq); 268 init_waitqueue_head(&cardp->fw_wq);
diff --git a/drivers/net/wireless/libertas_tf/if_usb.c b/drivers/net/wireless/libertas_tf/if_usb.c
index aff8b5743af0..7ced130f4f9e 100644
--- a/drivers/net/wireless/libertas_tf/if_usb.c
+++ b/drivers/net/wireless/libertas_tf/if_usb.c
@@ -153,10 +153,8 @@ static int if_usb_probe(struct usb_interface *intf,
153 udev = interface_to_usbdev(intf); 153 udev = interface_to_usbdev(intf);
154 154
155 cardp = kzalloc(sizeof(struct if_usb_card), GFP_KERNEL); 155 cardp = kzalloc(sizeof(struct if_usb_card), GFP_KERNEL);
156 if (!cardp) { 156 if (!cardp)
157 pr_err("Out of memory allocating private data.\n");
158 goto error; 157 goto error;
159 }
160 158
161 setup_timer(&cardp->fw_timeout, if_usb_fw_timeo, (unsigned long)cardp); 159 setup_timer(&cardp->fw_timeout, if_usb_fw_timeo, (unsigned long)cardp);
162 init_waitqueue_head(&cardp->fw_wq); 160 init_waitqueue_head(&cardp->fw_wq);
diff --git a/drivers/net/wireless/mwifiex/11n_aggr.c b/drivers/net/wireless/mwifiex/11n_aggr.c
index 079e5532e686..ea6832dc6677 100644
--- a/drivers/net/wireless/mwifiex/11n_aggr.c
+++ b/drivers/net/wireless/mwifiex/11n_aggr.c
@@ -182,7 +182,8 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
182 skb_reserve(skb_aggr, headroom + sizeof(struct txpd)); 182 skb_reserve(skb_aggr, headroom + sizeof(struct txpd));
183 tx_info_aggr = MWIFIEX_SKB_TXCB(skb_aggr); 183 tx_info_aggr = MWIFIEX_SKB_TXCB(skb_aggr);
184 184
185 tx_info_aggr->bss_index = tx_info_src->bss_index; 185 tx_info_aggr->bss_type = tx_info_src->bss_type;
186 tx_info_aggr->bss_num = tx_info_src->bss_num;
186 skb_aggr->priority = skb_src->priority; 187 skb_aggr->priority = skb_src->priority;
187 188
188 do { 189 do {
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index c3b6c4652cd6..6fef4925d13a 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -79,7 +79,7 @@ static int
79mwifiex_cfg80211_del_key(struct wiphy *wiphy, struct net_device *netdev, 79mwifiex_cfg80211_del_key(struct wiphy *wiphy, struct net_device *netdev,
80 u8 key_index, bool pairwise, const u8 *mac_addr) 80 u8 key_index, bool pairwise, const u8 *mac_addr)
81{ 81{
82 struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); 82 struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
83 83
84 if (mwifiex_set_encode(priv, NULL, 0, key_index, 1)) { 84 if (mwifiex_set_encode(priv, NULL, 0, key_index, 1)) {
85 wiphy_err(wiphy, "deleting the crypto keys\n"); 85 wiphy_err(wiphy, "deleting the crypto keys\n");
@@ -122,7 +122,7 @@ mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy,
122 struct net_device *dev, 122 struct net_device *dev,
123 bool enabled, int timeout) 123 bool enabled, int timeout)
124{ 124{
125 struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); 125 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
126 u32 ps_mode; 126 u32 ps_mode;
127 127
128 if (timeout) 128 if (timeout)
@@ -143,7 +143,7 @@ mwifiex_cfg80211_set_default_key(struct wiphy *wiphy, struct net_device *netdev,
143 u8 key_index, bool unicast, 143 u8 key_index, bool unicast,
144 bool multicast) 144 bool multicast)
145{ 145{
146 struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); 146 struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
147 147
148 /* Return if WEP key not configured */ 148 /* Return if WEP key not configured */
149 if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED) 149 if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED)
@@ -165,7 +165,7 @@ mwifiex_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev,
165 u8 key_index, bool pairwise, const u8 *mac_addr, 165 u8 key_index, bool pairwise, const u8 *mac_addr,
166 struct key_params *params) 166 struct key_params *params)
167{ 167{
168 struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); 168 struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
169 169
170 if (mwifiex_set_encode(priv, params->key, params->key_len, 170 if (mwifiex_set_encode(priv, params->key, params->key_len,
171 key_index, 0)) { 171 key_index, 0)) {
@@ -376,7 +376,7 @@ mwifiex_cfg80211_set_channel(struct wiphy *wiphy, struct net_device *dev,
376 struct ieee80211_channel *chan, 376 struct ieee80211_channel *chan,
377 enum nl80211_channel_type channel_type) 377 enum nl80211_channel_type channel_type)
378{ 378{
379 struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); 379 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
380 380
381 if (priv->media_connected) { 381 if (priv->media_connected) {
382 wiphy_err(wiphy, "This setting is valid only when station " 382 wiphy_err(wiphy, "This setting is valid only when station "
@@ -557,6 +557,23 @@ mwifiex_dump_station_info(struct mwifiex_private *priv,
557 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */ 557 /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
558 sinfo->txrate.legacy = rate.rate * 5; 558 sinfo->txrate.legacy = rate.rate * 5;
559 559
560 if (priv->bss_mode == NL80211_IFTYPE_STATION) {
561 sinfo->filled |= STATION_INFO_BSS_PARAM;
562 sinfo->bss_param.flags = 0;
563 if (priv->curr_bss_params.bss_descriptor.cap_info_bitmap &
564 WLAN_CAPABILITY_SHORT_PREAMBLE)
565 sinfo->bss_param.flags |=
566 BSS_PARAM_FLAGS_SHORT_PREAMBLE;
567 if (priv->curr_bss_params.bss_descriptor.cap_info_bitmap &
568 WLAN_CAPABILITY_SHORT_SLOT_TIME)
569 sinfo->bss_param.flags |=
570 BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
571 sinfo->bss_param.dtim_period =
572 priv->curr_bss_params.bss_descriptor.dtim_period;
573 sinfo->bss_param.beacon_interval =
574 priv->curr_bss_params.bss_descriptor.beacon_period;
575 }
576
560 return ret; 577 return ret;
561} 578}
562 579
@@ -1004,7 +1021,7 @@ static int
1004mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, 1021mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
1005 struct cfg80211_ibss_params *params) 1022 struct cfg80211_ibss_params *params)
1006{ 1023{
1007 struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); 1024 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
1008 int ret = 0; 1025 int ret = 0;
1009 1026
1010 if (priv->bss_mode != NL80211_IFTYPE_ADHOC) { 1027 if (priv->bss_mode != NL80211_IFTYPE_ADHOC) {
@@ -1042,7 +1059,7 @@ done:
1042static int 1059static int
1043mwifiex_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) 1060mwifiex_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
1044{ 1061{
1045 struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); 1062 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
1046 1063
1047 wiphy_dbg(wiphy, "info: disconnecting from essid %pM\n", 1064 wiphy_dbg(wiphy, "info: disconnecting from essid %pM\n",
1048 priv->cfg_bssid); 1065 priv->cfg_bssid);
@@ -1217,7 +1234,6 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy,
1217 priv->frame_type = MWIFIEX_DATA_FRAME_TYPE_ETH_II; 1234 priv->frame_type = MWIFIEX_DATA_FRAME_TYPE_ETH_II;
1218 priv->bss_priority = 0; 1235 priv->bss_priority = 0;
1219 priv->bss_role = MWIFIEX_BSS_ROLE_STA; 1236 priv->bss_role = MWIFIEX_BSS_ROLE_STA;
1220 priv->bss_index = 0;
1221 priv->bss_num = 0; 1237 priv->bss_num = 0;
1222 1238
1223 break; 1239 break;
@@ -1281,10 +1297,7 @@ EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf);
1281 */ 1297 */
1282int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev) 1298int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev)
1283{ 1299{
1284 struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); 1300 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
1285
1286 if (!priv || !dev)
1287 return 0;
1288 1301
1289#ifdef CONFIG_DEBUG_FS 1302#ifdef CONFIG_DEBUG_FS
1290 mwifiex_dev_debugfs_remove(priv); 1303 mwifiex_dev_debugfs_remove(priv);
diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c
index 6e0a3eaecf70..6623db69e157 100644
--- a/drivers/net/wireless/mwifiex/cmdevt.c
+++ b/drivers/net/wireless/mwifiex/cmdevt.c
@@ -391,7 +391,8 @@ int mwifiex_process_event(struct mwifiex_adapter *adapter)
391 391
392 if (skb) { 392 if (skb) {
393 rx_info = MWIFIEX_SKB_RXCB(skb); 393 rx_info = MWIFIEX_SKB_RXCB(skb);
394 rx_info->bss_index = priv->bss_index; 394 rx_info->bss_num = priv->bss_num;
395 rx_info->bss_type = priv->bss_type;
395 } 396 }
396 397
397 if (eventcause != EVENT_PS_SLEEP && eventcause != EVENT_PS_AWAKE) { 398 if (eventcause != EVENT_PS_SLEEP && eventcause != EVENT_PS_AWAKE) {
diff --git a/drivers/net/wireless/mwifiex/decl.h b/drivers/net/wireless/mwifiex/decl.h
index ae17ce02a3d0..3735c775495c 100644
--- a/drivers/net/wireless/mwifiex/decl.h
+++ b/drivers/net/wireless/mwifiex/decl.h
@@ -102,7 +102,8 @@ struct mwifiex_wait_queue {
102}; 102};
103 103
104struct mwifiex_rxinfo { 104struct mwifiex_rxinfo {
105 u8 bss_index; 105 u8 bss_num;
106 u8 bss_type;
106 struct sk_buff *parent; 107 struct sk_buff *parent;
107 u8 use_count; 108 u8 use_count;
108}; 109};
@@ -110,7 +111,8 @@ struct mwifiex_rxinfo {
110struct mwifiex_txinfo { 111struct mwifiex_txinfo {
111 u32 status_code; 112 u32 status_code;
112 u8 flags; 113 u8 flags;
113 u8 bss_index; 114 u8 bss_num;
115 u8 bss_type;
114}; 116};
115 117
116enum mwifiex_wmm_ac_e { 118enum mwifiex_wmm_ac_e {
diff --git a/drivers/net/wireless/mwifiex/init.c b/drivers/net/wireless/mwifiex/init.c
index 1d0ec57a0143..84fcb741a296 100644
--- a/drivers/net/wireless/mwifiex/init.c
+++ b/drivers/net/wireless/mwifiex/init.c
@@ -527,8 +527,9 @@ static void mwifiex_delete_bss_prio_tbl(struct mwifiex_private *priv)
527 cur = &adapter->bss_prio_tbl[i].bss_prio_cur; 527 cur = &adapter->bss_prio_tbl[i].bss_prio_cur;
528 lock = &adapter->bss_prio_tbl[i].bss_prio_lock; 528 lock = &adapter->bss_prio_tbl[i].bss_prio_lock;
529 dev_dbg(adapter->dev, "info: delete BSS priority table," 529 dev_dbg(adapter->dev, "info: delete BSS priority table,"
530 " index = %d, i = %d, head = %p, cur = %p\n", 530 " bss_type = %d, bss_num = %d, i = %d,"
531 priv->bss_index, i, head, *cur); 531 " head = %p, cur = %p\n",
532 priv->bss_type, priv->bss_num, i, head, *cur);
532 if (*cur) { 533 if (*cur) {
533 spin_lock_irqsave(lock, flags); 534 spin_lock_irqsave(lock, flags);
534 if (list_empty(head)) { 535 if (list_empty(head)) {
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index b728f54451e4..790a3796483c 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -424,8 +424,8 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
424 struct sk_buff *new_skb; 424 struct sk_buff *new_skb;
425 struct mwifiex_txinfo *tx_info; 425 struct mwifiex_txinfo *tx_info;
426 426
427 dev_dbg(priv->adapter->dev, "data: %lu BSS(%d): Data <= kernel\n", 427 dev_dbg(priv->adapter->dev, "data: %lu BSS(%d-%d): Data <= kernel\n",
428 jiffies, priv->bss_index); 428 jiffies, priv->bss_type, priv->bss_num);
429 429
430 if (priv->adapter->surprise_removed) { 430 if (priv->adapter->surprise_removed) {
431 kfree_skb(skb); 431 kfree_skb(skb);
@@ -458,10 +458,11 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
458 } 458 }
459 459
460 tx_info = MWIFIEX_SKB_TXCB(skb); 460 tx_info = MWIFIEX_SKB_TXCB(skb);
461 tx_info->bss_index = priv->bss_index; 461 tx_info->bss_num = priv->bss_num;
462 tx_info->bss_type = priv->bss_type;
462 mwifiex_fill_buffer(skb); 463 mwifiex_fill_buffer(skb);
463 464
464 mwifiex_wmm_add_buf_txqueue(priv->adapter, skb); 465 mwifiex_wmm_add_buf_txqueue(priv, skb);
465 atomic_inc(&priv->adapter->tx_pending); 466 atomic_inc(&priv->adapter->tx_pending);
466 467
467 if (atomic_read(&priv->adapter->tx_pending) >= MAX_TX_PENDING) { 468 if (atomic_read(&priv->adapter->tx_pending) >= MAX_TX_PENDING) {
@@ -531,8 +532,8 @@ mwifiex_tx_timeout(struct net_device *dev)
531{ 532{
532 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 533 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
533 534
534 dev_err(priv->adapter->dev, "%lu : Tx timeout, bss_index=%d\n", 535 dev_err(priv->adapter->dev, "%lu : Tx timeout, bss_type-num = %d-%d\n",
535 jiffies, priv->bss_index); 536 jiffies, priv->bss_type, priv->bss_num);
536 mwifiex_set_trans_start(dev); 537 mwifiex_set_trans_start(dev);
537 priv->num_tx_timeout++; 538 priv->num_tx_timeout++;
538} 539}
@@ -605,18 +606,6 @@ int is_command_pending(struct mwifiex_adapter *adapter)
605} 606}
606 607
607/* 608/*
608 * This function returns the correct private structure pointer based
609 * upon the BSS number.
610 */
611struct mwifiex_private *
612mwifiex_bss_index_to_priv(struct mwifiex_adapter *adapter, u8 bss_index)
613{
614 if (!adapter || (bss_index >= adapter->priv_num))
615 return NULL;
616 return adapter->priv[bss_index];
617}
618
619/*
620 * This is the main work queue function. 609 * This is the main work queue function.
621 * 610 *
622 * It handles the main process, which in turn handles the complete 611 * It handles the main process, which in turn handles the complete
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index 3186aa437f42..3dc0f721c1db 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -249,6 +249,7 @@ struct mwifiex_bssdescriptor {
249 u32 channel; 249 u32 channel;
250 u32 freq; 250 u32 freq;
251 u16 beacon_period; 251 u16 beacon_period;
252 u8 dtim_period;
252 u8 erp_flags; 253 u8 erp_flags;
253 u32 bss_mode; 254 u32 bss_mode;
254 u8 supported_rates[MWIFIEX_SUPPORTED_RATES]; 255 u8 supported_rates[MWIFIEX_SUPPORTED_RATES];
@@ -352,7 +353,6 @@ struct mwifiex_private;
352 353
353struct mwifiex_private { 354struct mwifiex_private {
354 struct mwifiex_adapter *adapter; 355 struct mwifiex_adapter *adapter;
355 u8 bss_index;
356 u8 bss_type; 356 u8 bss_type;
357 u8 bss_role; 357 u8 bss_role;
358 u8 bss_priority; 358 u8 bss_priority;
@@ -884,8 +884,6 @@ mwifiex_netdev_get_priv(struct net_device *dev)
884 return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev)); 884 return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
885} 885}
886 886
887struct mwifiex_private *mwifiex_bss_index_to_priv(struct mwifiex_adapter
888 *adapter, u8 bss_index);
889int mwifiex_init_shutdown_fw(struct mwifiex_private *priv, 887int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
890 u32 func_init_shutdown); 888 u32 func_init_shutdown);
891int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8); 889int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8);
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
index 405350940a45..f4fbad95d3e3 100644
--- a/drivers/net/wireless/mwifiex/pcie.c
+++ b/drivers/net/wireless/mwifiex/pcie.c
@@ -86,10 +86,8 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev,
86 pdev->vendor, pdev->device, pdev->revision); 86 pdev->vendor, pdev->device, pdev->revision);
87 87
88 card = kzalloc(sizeof(struct pcie_service_card), GFP_KERNEL); 88 card = kzalloc(sizeof(struct pcie_service_card), GFP_KERNEL);
89 if (!card) { 89 if (!card)
90 pr_err("%s: failed to alloc memory\n", __func__);
91 return -ENOMEM; 90 return -ENOMEM;
92 }
93 91
94 card->dev = pdev; 92 card->dev = pdev;
95 93
diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
index 6396d3318ead..135208596aff 100644
--- a/drivers/net/wireless/mwifiex/scan.c
+++ b/drivers/net/wireless/mwifiex/scan.c
@@ -1086,6 +1086,7 @@ mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
1086 struct ieee_types_vendor_specific *vendor_ie; 1086 struct ieee_types_vendor_specific *vendor_ie;
1087 const u8 wpa_oui[4] = { 0x00, 0x50, 0xf2, 0x01 }; 1087 const u8 wpa_oui[4] = { 0x00, 0x50, 0xf2, 0x01 };
1088 const u8 wmm_oui[4] = { 0x00, 0x50, 0xf2, 0x02 }; 1088 const u8 wmm_oui[4] = { 0x00, 0x50, 0xf2, 0x02 };
1089 struct ieee80211_tim_ie *tim_ie;
1089 1090
1090 found_data_rate_ie = false; 1091 found_data_rate_ie = false;
1091 rate_size = 0; 1092 rate_size = 0;
@@ -1258,6 +1259,11 @@ mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
1258 sizeof(struct ieee_types_header) - 1259 sizeof(struct ieee_types_header) -
1259 bss_entry->beacon_buf); 1260 bss_entry->beacon_buf);
1260 break; 1261 break;
1262 case WLAN_EID_TIM:
1263 tim_ie = (void *) (current_ptr +
1264 sizeof(struct ieee_types_header));
1265 bss_entry->dtim_period = tim_ie->dtim_period;
1266 break;
1261 default: 1267 default:
1262 break; 1268 break;
1263 } 1269 }
@@ -2001,7 +2007,7 @@ mwifiex_save_curr_bcn(struct mwifiex_private *priv)
2001 2007
2002 kfree(priv->curr_bcn_buf); 2008 kfree(priv->curr_bcn_buf);
2003 priv->curr_bcn_buf = kmalloc(curr_bss->beacon_buf_size, 2009 priv->curr_bcn_buf = kmalloc(curr_bss->beacon_buf_size,
2004 GFP_KERNEL); 2010 GFP_ATOMIC);
2005 if (!priv->curr_bcn_buf) { 2011 if (!priv->curr_bcn_buf) {
2006 dev_err(priv->adapter->dev, 2012 dev_err(priv->adapter->dev,
2007 "failed to alloc curr_bcn_buf\n"); 2013 "failed to alloc curr_bcn_buf\n");
diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c
index d39d8457f252..835902750231 100644
--- a/drivers/net/wireless/mwifiex/sdio.c
+++ b/drivers/net/wireless/mwifiex/sdio.c
@@ -70,10 +70,8 @@ mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
70 func->vendor, func->device, func->class, func->num); 70 func->vendor, func->device, func->class, func->num);
71 71
72 card = kzalloc(sizeof(struct sdio_mmc_card), GFP_KERNEL); 72 card = kzalloc(sizeof(struct sdio_mmc_card), GFP_KERNEL);
73 if (!card) { 73 if (!card)
74 pr_err("%s: failed to alloc memory\n", __func__);
75 return -ENOMEM; 74 return -ENOMEM;
76 }
77 75
78 card->func = func; 76 card->func = func;
79 77
diff --git a/drivers/net/wireless/mwifiex/sta_rx.c b/drivers/net/wireless/mwifiex/sta_rx.c
index 5e1ef7e5da4f..d7a5d7616f22 100644
--- a/drivers/net/wireless/mwifiex/sta_rx.c
+++ b/drivers/net/wireless/mwifiex/sta_rx.c
@@ -43,7 +43,8 @@ int mwifiex_process_rx_packet(struct mwifiex_adapter *adapter,
43{ 43{
44 int ret; 44 int ret;
45 struct mwifiex_rxinfo *rx_info = MWIFIEX_SKB_RXCB(skb); 45 struct mwifiex_rxinfo *rx_info = MWIFIEX_SKB_RXCB(skb);
46 struct mwifiex_private *priv = adapter->priv[rx_info->bss_index]; 46 struct mwifiex_private *priv = mwifiex_get_priv_by_id(adapter,
47 rx_info->bss_num, rx_info->bss_type);
47 struct rx_packet_hdr *rx_pkt_hdr; 48 struct rx_packet_hdr *rx_pkt_hdr;
48 struct rxpd *local_rx_pd; 49 struct rxpd *local_rx_pd;
49 int hdr_chop; 50 int hdr_chop;
@@ -124,7 +125,8 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter,
124 struct rx_packet_hdr *rx_pkt_hdr; 125 struct rx_packet_hdr *rx_pkt_hdr;
125 u8 ta[ETH_ALEN]; 126 u8 ta[ETH_ALEN];
126 u16 rx_pkt_type; 127 u16 rx_pkt_type;
127 struct mwifiex_private *priv = adapter->priv[rx_info->bss_index]; 128 struct mwifiex_private *priv = mwifiex_get_priv_by_id(adapter,
129 rx_info->bss_num, rx_info->bss_type);
128 130
129 if (!priv) 131 if (!priv)
130 return -1; 132 return -1;
diff --git a/drivers/net/wireless/mwifiex/sta_tx.c b/drivers/net/wireless/mwifiex/sta_tx.c
index d97facd70e88..94d31a94620a 100644
--- a/drivers/net/wireless/mwifiex/sta_tx.c
+++ b/drivers/net/wireless/mwifiex/sta_tx.c
@@ -136,7 +136,8 @@ int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags)
136 return -1; 136 return -1;
137 137
138 tx_info = MWIFIEX_SKB_TXCB(skb); 138 tx_info = MWIFIEX_SKB_TXCB(skb);
139 tx_info->bss_index = priv->bss_index; 139 tx_info->bss_num = priv->bss_num;
140 tx_info->bss_type = priv->bss_type;
140 skb_reserve(skb, sizeof(struct txpd) + INTF_HEADER_LEN); 141 skb_reserve(skb, sizeof(struct txpd) + INTF_HEADER_LEN);
141 skb_push(skb, sizeof(struct txpd)); 142 skb_push(skb, sizeof(struct txpd));
142 143
diff --git a/drivers/net/wireless/mwifiex/txrx.c b/drivers/net/wireless/mwifiex/txrx.c
index d9274a1b77ac..9a6eacc9d6f9 100644
--- a/drivers/net/wireless/mwifiex/txrx.c
+++ b/drivers/net/wireless/mwifiex/txrx.c
@@ -48,7 +48,8 @@ int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
48 if (!priv) 48 if (!priv)
49 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); 49 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
50 50
51 rx_info->bss_index = priv->bss_index; 51 rx_info->bss_num = priv->bss_num;
52 rx_info->bss_type = priv->bss_type;
52 53
53 return mwifiex_process_sta_rx_packet(adapter, skb); 54 return mwifiex_process_sta_rx_packet(adapter, skb);
54} 55}
@@ -130,7 +131,8 @@ int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
130 return 0; 131 return 0;
131 132
132 tx_info = MWIFIEX_SKB_TXCB(skb); 133 tx_info = MWIFIEX_SKB_TXCB(skb);
133 priv = mwifiex_bss_index_to_priv(adapter, tx_info->bss_index); 134 priv = mwifiex_get_priv_by_id(adapter, tx_info->bss_num,
135 tx_info->bss_type);
134 if (!priv) 136 if (!priv)
135 goto done; 137 goto done;
136 138
diff --git a/drivers/net/wireless/mwifiex/util.c b/drivers/net/wireless/mwifiex/util.c
index 06976f517f66..9c48f37069f7 100644
--- a/drivers/net/wireless/mwifiex/util.c
+++ b/drivers/net/wireless/mwifiex/util.c
@@ -159,7 +159,8 @@ int mwifiex_recv_packet(struct mwifiex_adapter *adapter, struct sk_buff *skb)
159 return -1; 159 return -1;
160 160
161 rx_info = MWIFIEX_SKB_RXCB(skb); 161 rx_info = MWIFIEX_SKB_RXCB(skb);
162 priv = mwifiex_bss_index_to_priv(adapter, rx_info->bss_index); 162 priv = mwifiex_get_priv_by_id(adapter, rx_info->bss_num,
163 rx_info->bss_type);
163 if (!priv) 164 if (!priv)
164 return -1; 165 return -1;
165 166
diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c
index 6c239c3c8249..75f79ef9f6cf 100644
--- a/drivers/net/wireless/mwifiex/wmm.c
+++ b/drivers/net/wireless/mwifiex/wmm.c
@@ -599,11 +599,10 @@ mwifiex_is_ralist_valid(struct mwifiex_private *priv,
599 * is queued at the list tail. 599 * is queued at the list tail.
600 */ 600 */
601void 601void
602mwifiex_wmm_add_buf_txqueue(struct mwifiex_adapter *adapter, 602mwifiex_wmm_add_buf_txqueue(struct mwifiex_private *priv,
603 struct sk_buff *skb) 603 struct sk_buff *skb)
604{ 604{
605 struct mwifiex_txinfo *tx_info = MWIFIEX_SKB_TXCB(skb); 605 struct mwifiex_adapter *adapter = priv->adapter;
606 struct mwifiex_private *priv = adapter->priv[tx_info->bss_index];
607 u32 tid; 606 u32 tid;
608 struct mwifiex_ra_list_tbl *ra_list; 607 struct mwifiex_ra_list_tbl *ra_list;
609 u8 ra[ETH_ALEN], tid_down; 608 u8 ra[ETH_ALEN], tid_down;
diff --git a/drivers/net/wireless/mwifiex/wmm.h b/drivers/net/wireless/mwifiex/wmm.h
index fcea1f68792f..ec839952d2e7 100644
--- a/drivers/net/wireless/mwifiex/wmm.h
+++ b/drivers/net/wireless/mwifiex/wmm.h
@@ -80,8 +80,8 @@ mwifiex_wmm_is_ra_list_empty(struct list_head *ra_list_hhead)
80 return true; 80 return true;
81} 81}
82 82
83void mwifiex_wmm_add_buf_txqueue(struct mwifiex_adapter *adapter, 83void mwifiex_wmm_add_buf_txqueue(struct mwifiex_private *priv,
84 struct sk_buff *skb); 84 struct sk_buff *skb);
85void mwifiex_ralist_add(struct mwifiex_private *priv, u8 *ra); 85void mwifiex_ralist_add(struct mwifiex_private *priv, u8 *ra);
86 86
87int mwifiex_wmm_lists_empty(struct mwifiex_adapter *adapter); 87int mwifiex_wmm_lists_empty(struct mwifiex_adapter *adapter);
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index dd5aeaff44ba..fd125473be7a 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -4093,7 +4093,7 @@ static int mwl8k_set_key(struct ieee80211_hw *hw,
4093 return -EOPNOTSUPP; 4093 return -EOPNOTSUPP;
4094 4094
4095 if (sta == NULL) 4095 if (sta == NULL)
4096 addr = hw->wiphy->perm_addr; 4096 addr = vif->addr;
4097 else 4097 else
4098 addr = sta->addr; 4098 addr = sta->addr;
4099 4099
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index 9fb77d0319f5..dd6c64ac406e 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -941,11 +941,9 @@ void __orinoco_ev_rx(struct net_device *dev, struct hermes *hw)
941 941
942 /* Add desc and skb to rx queue */ 942 /* Add desc and skb to rx queue */
943 rx_data = kzalloc(sizeof(*rx_data), GFP_ATOMIC); 943 rx_data = kzalloc(sizeof(*rx_data), GFP_ATOMIC);
944 if (!rx_data) { 944 if (!rx_data)
945 printk(KERN_WARNING "%s: Can't allocate RX packet\n",
946 dev->name);
947 goto drop; 945 goto drop;
948 } 946
949 rx_data->desc = desc; 947 rx_data->desc = desc;
950 rx_data->skb = skb; 948 rx_data->skb = skb;
951 list_add_tail(&rx_data->list, &priv->rx_list); 949 list_add_tail(&rx_data->list, &priv->rx_list);
diff --git a/drivers/net/wireless/orinoco/orinoco_usb.c b/drivers/net/wireless/orinoco/orinoco_usb.c
index ae8ce56670b6..f634d4582bfe 100644
--- a/drivers/net/wireless/orinoco/orinoco_usb.c
+++ b/drivers/net/wireless/orinoco/orinoco_usb.c
@@ -1754,11 +1754,6 @@ static struct usb_driver orinoco_driver = {
1754 .id_table = ezusb_table, 1754 .id_table = ezusb_table,
1755}; 1755};
1756 1756
1757/* Can't be declared "const" or the whole __initdata section will
1758 * become const */
1759static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
1760 " (Manuel Estrada Sainz)";
1761
1762module_usb_driver(orinoco_driver); 1757module_usb_driver(orinoco_driver);
1763 1758
1764MODULE_AUTHOR("Manuel Estrada Sainz"); 1759MODULE_AUTHOR("Manuel Estrada Sainz");
diff --git a/drivers/net/wireless/p54/main.c b/drivers/net/wireless/p54/main.c
index af2ca1a9c7d3..40f4eb7da7b2 100644
--- a/drivers/net/wireless/p54/main.c
+++ b/drivers/net/wireless/p54/main.c
@@ -228,6 +228,8 @@ static int p54_add_interface(struct ieee80211_hw *dev,
228{ 228{
229 struct p54_common *priv = dev->priv; 229 struct p54_common *priv = dev->priv;
230 230
231 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
232
231 mutex_lock(&priv->conf_mutex); 233 mutex_lock(&priv->conf_mutex);
232 if (priv->mode != NL80211_IFTYPE_MONITOR) { 234 if (priv->mode != NL80211_IFTYPE_MONITOR) {
233 mutex_unlock(&priv->conf_mutex); 235 mutex_unlock(&priv->conf_mutex);
@@ -734,7 +736,6 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
734 IEEE80211_HW_SIGNAL_DBM | 736 IEEE80211_HW_SIGNAL_DBM |
735 IEEE80211_HW_SUPPORTS_PS | 737 IEEE80211_HW_SUPPORTS_PS |
736 IEEE80211_HW_PS_NULLFUNC_STACK | 738 IEEE80211_HW_PS_NULLFUNC_STACK |
737 IEEE80211_HW_BEACON_FILTER |
738 IEEE80211_HW_REPORTS_TX_ACK_STATUS; 739 IEEE80211_HW_REPORTS_TX_ACK_STATUS;
739 740
740 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | 741 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
diff --git a/drivers/net/wireless/prism54/islpci_mgt.c b/drivers/net/wireless/prism54/islpci_mgt.c
index a5224f6160e4..851fa10241e1 100644
--- a/drivers/net/wireless/prism54/islpci_mgt.c
+++ b/drivers/net/wireless/prism54/islpci_mgt.c
@@ -192,11 +192,9 @@ islpci_mgt_transmit(struct net_device *ndev, int operation, unsigned long oid,
192 192
193 err = -ENOMEM; 193 err = -ENOMEM;
194 p = buf.mem = kmalloc(frag_len, GFP_KERNEL); 194 p = buf.mem = kmalloc(frag_len, GFP_KERNEL);
195 if (!buf.mem) { 195 if (!buf.mem)
196 printk(KERN_DEBUG "%s: cannot allocate mgmt frame\n",
197 ndev->name);
198 goto error; 196 goto error;
199 } 197
200 buf.size = frag_len; 198 buf.size = frag_len;
201 199
202 /* create the header directly in the fragment data area */ 200 /* create the header directly in the fragment data area */
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 7bef66def10c..dbe7ece862f2 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -412,18 +412,6 @@ int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
412 } 412 }
413 413
414 /* 414 /*
415 * Disable DMA, will be reenabled later when enabling
416 * the radio.
417 */
418 rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
419 rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
420 rt2x00_set_field32(&reg, WPDMA_GLO_CFG_TX_DMA_BUSY, 0);
421 rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0);
422 rt2x00_set_field32(&reg, WPDMA_GLO_CFG_RX_DMA_BUSY, 0);
423 rt2x00_set_field32(&reg, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1);
424 rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
425
426 /*
427 * Write firmware to the device. 415 * Write firmware to the device.
428 */ 416 */
429 rt2800_drv_write_firmware(rt2x00dev, data, len); 417 rt2800_drv_write_firmware(rt2x00dev, data, len);
@@ -444,10 +432,21 @@ int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
444 } 432 }
445 433
446 /* 434 /*
435 * Disable DMA, will be reenabled later when enabling
436 * the radio.
437 */
438 rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
439 rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
440 rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0);
441 rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
442
443 /*
447 * Initialize firmware. 444 * Initialize firmware.
448 */ 445 */
449 rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0); 446 rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0);
450 rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0); 447 rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
448 if (rt2x00_is_usb(rt2x00dev))
449 rt2800_register_write(rt2x00dev, H2M_INT_SRC, 0);
451 msleep(1); 450 msleep(1);
452 451
453 return 0; 452 return 0;
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index dc88baefa72e..4e985026985c 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -489,7 +489,7 @@ static int rt2800pci_init_registers(struct rt2x00_dev *rt2x00dev)
489 489
490 rt2x00pci_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003); 490 rt2x00pci_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003);
491 491
492 rt2x00pci_register_read(rt2x00dev, MAC_SYS_CTRL, &reg); 492 reg = 0;
493 rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_CSR, 1); 493 rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_CSR, 1);
494 rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_BBP, 1); 494 rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_BBP, 1);
495 rt2x00pci_register_write(rt2x00dev, MAC_SYS_CTRL, reg); 495 rt2x00pci_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index 262ee9eefb6f..f0074bcee7c9 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -226,9 +226,7 @@ static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)
226 rt2x00usb_register_read(rt2x00dev, PBF_SYS_CTRL, &reg); 226 rt2x00usb_register_read(rt2x00dev, PBF_SYS_CTRL, &reg);
227 rt2x00usb_register_write(rt2x00dev, PBF_SYS_CTRL, reg & ~0x00002000); 227 rt2x00usb_register_write(rt2x00dev, PBF_SYS_CTRL, reg & ~0x00002000);
228 228
229 rt2x00usb_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003); 229 reg = 0;
230
231 rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
232 rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_CSR, 1); 230 rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_CSR, 1);
233 rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_BBP, 1); 231 rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_BBP, 1);
234 rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg); 232 rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
diff --git a/drivers/net/wireless/rtlwifi/Kconfig b/drivers/net/wireless/rtlwifi/Kconfig
index d6c42e69bdbd..44b9c0a57702 100644
--- a/drivers/net/wireless/rtlwifi/Kconfig
+++ b/drivers/net/wireless/rtlwifi/Kconfig
@@ -49,6 +49,11 @@ config RTLWIFI
49 depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE 49 depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE
50 default m 50 default m
51 51
52config RTLWIFI_DEBUG
53 tristate "Additional debugging output"
54 depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE
55 default y
56
52config RTL8192C_COMMON 57config RTL8192C_COMMON
53 tristate 58 tristate
54 depends on RTL8192CE || RTL8192CU 59 depends on RTL8192CE || RTL8192CU
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
index 8d6eb0f56c03..df5655cc55c0 100644
--- a/drivers/net/wireless/rtlwifi/base.c
+++ b/drivers/net/wireless/rtlwifi/base.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -27,10 +27,6 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
32#include <linux/ip.h>
33#include <linux/module.h>
34#include "wifi.h" 30#include "wifi.h"
35#include "rc.h" 31#include "rc.h"
36#include "base.h" 32#include "base.h"
@@ -39,6 +35,9 @@
39#include "ps.h" 35#include "ps.h"
40#include "regd.h" 36#include "regd.h"
41 37
38#include <linux/ip.h>
39#include <linux/module.h>
40
42/* 41/*
43 *NOTICE!!!: This file will be very big, we hsould 42 *NOTICE!!!: This file will be very big, we hsould
44 *keep it clear under follwing roles: 43 *keep it clear under follwing roles:
@@ -211,7 +210,7 @@ static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw,
211 */ 210 */
212 if (get_rf_type(rtlphy) == RF_1T2R || get_rf_type(rtlphy) == RF_2T2R) { 211 if (get_rf_type(rtlphy) == RF_1T2R || get_rf_type(rtlphy) == RF_2T2R) {
213 212
214 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("1T2R or 2T2R\n")); 213 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "1T2R or 2T2R\n");
215 214
216 ht_cap->mcs.rx_mask[0] = 0xFF; 215 ht_cap->mcs.rx_mask[0] = 0xFF;
217 ht_cap->mcs.rx_mask[1] = 0xFF; 216 ht_cap->mcs.rx_mask[1] = 0xFF;
@@ -220,7 +219,7 @@ static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw,
220 ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15); 219 ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15);
221 } else if (get_rf_type(rtlphy) == RF_1T1R) { 220 } else if (get_rf_type(rtlphy) == RF_1T1R) {
222 221
223 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("1T1R\n")); 222 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "1T1R\n");
224 223
225 ht_cap->mcs.rx_mask[0] = 0xFF; 224 ht_cap->mcs.rx_mask[0] = 0xFF;
226 ht_cap->mcs.rx_mask[1] = 0x00; 225 ht_cap->mcs.rx_mask[1] = 0x00;
@@ -302,15 +301,13 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
302 /* <4> set mac->sband to wiphy->sband */ 301 /* <4> set mac->sband to wiphy->sband */
303 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = sband; 302 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = sband;
304 } else { 303 } else {
305 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, 304 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "Err BAND %d\n",
306 ("Err BAND %d\n", 305 rtlhal->current_bandtype);
307 rtlhal->current_bandtype));
308 } 306 }
309 } 307 }
310 /* <5> set hw caps */ 308 /* <5> set hw caps */
311 hw->flags = IEEE80211_HW_SIGNAL_DBM | 309 hw->flags = IEEE80211_HW_SIGNAL_DBM |
312 IEEE80211_HW_RX_INCLUDES_FCS | 310 IEEE80211_HW_RX_INCLUDES_FCS |
313 IEEE80211_HW_BEACON_FILTER |
314 IEEE80211_HW_AMPDU_AGGREGATION | 311 IEEE80211_HW_AMPDU_AGGREGATION |
315 IEEE80211_HW_CONNECTION_MONITOR | 312 IEEE80211_HW_CONNECTION_MONITOR |
316 /* IEEE80211_HW_SUPPORTS_CQM_RSSI | */ 313 /* IEEE80211_HW_SUPPORTS_CQM_RSSI | */
@@ -413,6 +410,7 @@ void rtl_init_rfkill(struct ieee80211_hw *hw)
413 410
414 wiphy_rfkill_start_polling(hw->wiphy); 411 wiphy_rfkill_start_polling(hw->wiphy);
415} 412}
413EXPORT_SYMBOL(rtl_init_rfkill);
416 414
417void rtl_deinit_rfkill(struct ieee80211_hw *hw) 415void rtl_deinit_rfkill(struct ieee80211_hw *hw)
418{ 416{
@@ -436,13 +434,13 @@ int rtl_init_core(struct ieee80211_hw *hw)
436 * mac80211 hw in _rtl_init_mac80211. 434 * mac80211 hw in _rtl_init_mac80211.
437 */ 435 */
438 if (rtl_regd_init(hw, rtl_reg_notifier)) { 436 if (rtl_regd_init(hw, rtl_reg_notifier)) {
439 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("REGD init failed\n")); 437 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "REGD init failed\n");
440 return 1; 438 return 1;
441 } else { 439 } else {
442 /* CRDA regd hint must after init CRDA */ 440 /* CRDA regd hint must after init CRDA */
443 if (regulatory_hint(hw->wiphy, rtlpriv->regd.alpha2)) { 441 if (regulatory_hint(hw->wiphy, rtlpriv->regd.alpha2)) {
444 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 442 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
445 ("regulatory_hint fail\n")); 443 "regulatory_hint fail\n");
446 } 444 }
447 } 445 }
448 446
@@ -922,17 +920,17 @@ bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
922 return false; 920 return false;
923 921
924 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, 922 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
925 ("%s ACT_ADDBAREQ From :%pM\n", 923 "%s ACT_ADDBAREQ From :%pM\n",
926 is_tx ? "Tx" : "Rx", hdr->addr2)); 924 is_tx ? "Tx" : "Rx", hdr->addr2);
927 break; 925 break;
928 case ACT_ADDBARSP: 926 case ACT_ADDBARSP:
929 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, 927 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
930 ("%s ACT_ADDBARSP From :%pM\n", 928 "%s ACT_ADDBARSP From :%pM\n",
931 is_tx ? "Tx" : "Rx", hdr->addr2)); 929 is_tx ? "Tx" : "Rx", hdr->addr2);
932 break; 930 break;
933 case ACT_DELBA: 931 case ACT_DELBA:
934 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, 932 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
935 ("ACT_ADDBADEL From :%pM\n", hdr->addr2)); 933 "ACT_ADDBADEL From :%pM\n", hdr->addr2);
936 break; 934 break;
937 } 935 }
938 break; 936 break;
@@ -975,8 +973,8 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
975 * 67 : UDP BOOTP server 973 * 67 : UDP BOOTP server
976 */ 974 */
977 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), 975 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV),
978 DBG_DMESG, ("dhcp %s !!\n", 976 DBG_DMESG, "dhcp %s !!\n",
979 (is_tx) ? "Tx" : "Rx")); 977 is_tx ? "Tx" : "Rx");
980 978
981 if (is_tx) { 979 if (is_tx) {
982 rtl_lps_leave(hw); 980 rtl_lps_leave(hw);
@@ -996,7 +994,7 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
996 return true; 994 return true;
997 } else if (ETH_P_PAE == ether_type) { 995 } else if (ETH_P_PAE == ether_type) {
998 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, 996 RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
999 ("802.1X %s EAPOL pkt!!\n", (is_tx) ? "Tx" : "Rx")); 997 "802.1X %s EAPOL pkt!!\n", is_tx ? "Tx" : "Rx");
1000 998
1001 if (is_tx) { 999 if (is_tx) {
1002 rtl_lps_leave(hw); 1000 rtl_lps_leave(hw);
@@ -1036,9 +1034,8 @@ int rtl_tx_agg_start(struct ieee80211_hw *hw,
1036 return -ENXIO; 1034 return -ENXIO;
1037 tid_data = &sta_entry->tids[tid]; 1035 tid_data = &sta_entry->tids[tid];
1038 1036
1039 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, 1037 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "on ra = %pM tid = %d seq:%d\n",
1040 ("on ra = %pM tid = %d seq:%d\n", sta->addr, tid, 1038 sta->addr, tid, tid_data->seq_number);
1041 tid_data->seq_number));
1042 1039
1043 *ssn = tid_data->seq_number; 1040 *ssn = tid_data->seq_number;
1044 tid_data->agg.agg_state = RTL_AGG_START; 1041 tid_data->agg.agg_state = RTL_AGG_START;
@@ -1059,12 +1056,12 @@ int rtl_tx_agg_stop(struct ieee80211_hw *hw,
1059 return -EINVAL; 1056 return -EINVAL;
1060 1057
1061 if (!sta->addr) { 1058 if (!sta->addr) {
1062 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("ra = NULL\n")); 1059 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "ra = NULL\n");
1063 return -EINVAL; 1060 return -EINVAL;
1064 } 1061 }
1065 1062
1066 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, 1063 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "on ra = %pM tid = %d\n",
1067 ("on ra = %pM tid = %d\n", sta->addr, tid)); 1064 sta->addr, tid);
1068 1065
1069 if (unlikely(tid >= MAX_TID_COUNT)) 1066 if (unlikely(tid >= MAX_TID_COUNT))
1070 return -EINVAL; 1067 return -EINVAL;
@@ -1087,12 +1084,12 @@ int rtl_tx_agg_oper(struct ieee80211_hw *hw,
1087 return -EINVAL; 1084 return -EINVAL;
1088 1085
1089 if (!sta->addr) { 1086 if (!sta->addr) {
1090 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("ra = NULL\n")); 1087 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "ra = NULL\n");
1091 return -EINVAL; 1088 return -EINVAL;
1092 } 1089 }
1093 1090
1094 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, 1091 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "on ra = %pM tid = %d\n",
1095 ("on ra = %pM tid = %d\n", sta->addr, tid)); 1092 sta->addr, tid);
1096 1093
1097 if (unlikely(tid >= MAX_TID_COUNT)) 1094 if (unlikely(tid >= MAX_TID_COUNT))
1098 return -EINVAL; 1095 return -EINVAL;
@@ -1474,29 +1471,29 @@ void rtl_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len)
1474 (memcmp(mac->bssid, ap5_6, 3) == 0) || 1471 (memcmp(mac->bssid, ap5_6, 3) == 0) ||
1475 vendor == PEER_ATH) { 1472 vendor == PEER_ATH) {
1476 vendor = PEER_ATH; 1473 vendor = PEER_ATH;
1477 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("=>ath find\n")); 1474 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>ath find\n");
1478 } else if ((memcmp(mac->bssid, ap4_4, 3) == 0) || 1475 } else if ((memcmp(mac->bssid, ap4_4, 3) == 0) ||
1479 (memcmp(mac->bssid, ap4_5, 3) == 0) || 1476 (memcmp(mac->bssid, ap4_5, 3) == 0) ||
1480 (memcmp(mac->bssid, ap4_1, 3) == 0) || 1477 (memcmp(mac->bssid, ap4_1, 3) == 0) ||
1481 (memcmp(mac->bssid, ap4_2, 3) == 0) || 1478 (memcmp(mac->bssid, ap4_2, 3) == 0) ||
1482 (memcmp(mac->bssid, ap4_3, 3) == 0) || 1479 (memcmp(mac->bssid, ap4_3, 3) == 0) ||
1483 vendor == PEER_RAL) { 1480 vendor == PEER_RAL) {
1484 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("=>ral findn\n")); 1481 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>ral find\n");
1485 vendor = PEER_RAL; 1482 vendor = PEER_RAL;
1486 } else if (memcmp(mac->bssid, ap6_1, 3) == 0 || 1483 } else if (memcmp(mac->bssid, ap6_1, 3) == 0 ||
1487 vendor == PEER_CISCO) { 1484 vendor == PEER_CISCO) {
1488 vendor = PEER_CISCO; 1485 vendor = PEER_CISCO;
1489 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("=>cisco find\n")); 1486 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>cisco find\n");
1490 } else if ((memcmp(mac->bssid, ap3_1, 3) == 0) || 1487 } else if ((memcmp(mac->bssid, ap3_1, 3) == 0) ||
1491 (memcmp(mac->bssid, ap3_2, 3) == 0) || 1488 (memcmp(mac->bssid, ap3_2, 3) == 0) ||
1492 (memcmp(mac->bssid, ap3_3, 3) == 0) || 1489 (memcmp(mac->bssid, ap3_3, 3) == 0) ||
1493 vendor == PEER_BROAD) { 1490 vendor == PEER_BROAD) {
1494 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("=>broad find\n")); 1491 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>broad find\n");
1495 vendor = PEER_BROAD; 1492 vendor = PEER_BROAD;
1496 } else if (memcmp(mac->bssid, ap7_1, 3) == 0 || 1493 } else if (memcmp(mac->bssid, ap7_1, 3) == 0 ||
1497 vendor == PEER_MARV) { 1494 vendor == PEER_MARV) {
1498 vendor = PEER_MARV; 1495 vendor = PEER_MARV;
1499 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("=>marv find\n")); 1496 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "=>marv find\n");
1500 } 1497 }
1501 1498
1502 mac->vendor = vendor; 1499 mac->vendor = vendor;
diff --git a/drivers/net/wireless/rtlwifi/base.h b/drivers/net/wireless/rtlwifi/base.h
index f66b5757f6b9..5a23a6d0f49d 100644
--- a/drivers/net/wireless/rtlwifi/base.h
+++ b/drivers/net/wireless/rtlwifi/base.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/cam.c b/drivers/net/wireless/rtlwifi/cam.c
index dc36d7461caa..5c7d57947d23 100644
--- a/drivers/net/wireless/rtlwifi/cam.c
+++ b/drivers/net/wireless/rtlwifi/cam.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -27,8 +27,6 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
32#include <linux/export.h> 30#include <linux/export.h>
33#include "wifi.h" 31#include "wifi.h"
34#include "cam.h" 32#include "cam.h"
@@ -55,10 +53,10 @@ static void rtl_cam_program_entry(struct ieee80211_hw *hw, u32 entry_no,
55 u8 entry_i; 53 u8 entry_i;
56 54
57 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 55 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
58 ("key_cont_128:\n %x:%x:%x:%x:%x:%x\n", 56 "key_cont_128:\n %x:%x:%x:%x:%x:%x\n",
59 key_cont_128[0], key_cont_128[1], 57 key_cont_128[0], key_cont_128[1],
60 key_cont_128[2], key_cont_128[3], 58 key_cont_128[2], key_cont_128[3],
61 key_cont_128[4], key_cont_128[5])); 59 key_cont_128[4], key_cont_128[5]);
62 60
63 for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { 61 for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
64 target_command = entry_i + CAM_CONTENT_COUNT * entry_no; 62 target_command = entry_i + CAM_CONTENT_COUNT * entry_no;
@@ -73,14 +71,12 @@ static void rtl_cam_program_entry(struct ieee80211_hw *hw, u32 entry_no,
73 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], 71 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
74 target_command); 72 target_command);
75 73
74 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "WRITE %x: %x\n",
75 rtlpriv->cfg->maps[WCAMI], target_content);
76 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 76 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
77 ("WRITE %x: %x\n", 77 "The Key ID is %d\n", entry_no);
78 rtlpriv->cfg->maps[WCAMI], target_content)); 78 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "WRITE %x: %x\n",
79 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 79 rtlpriv->cfg->maps[RWCAM], target_command);
80 ("The Key ID is %d\n", entry_no));
81 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
82 ("WRITE %x: %x\n",
83 rtlpriv->cfg->maps[RWCAM], target_command));
84 80
85 } else if (entry_i == 1) { 81 } else if (entry_i == 1) {
86 82
@@ -94,10 +90,10 @@ static void rtl_cam_program_entry(struct ieee80211_hw *hw, u32 entry_no,
94 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], 90 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM],
95 target_command); 91 target_command);
96 92
97 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 93 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "WRITE A4: %x\n",
98 ("WRITE A4: %x\n", target_content)); 94 target_content);
99 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 95 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "WRITE A0: %x\n",
100 ("WRITE A0: %x\n", target_command)); 96 target_command);
101 97
102 } else { 98 } else {
103 99
@@ -114,15 +110,15 @@ static void rtl_cam_program_entry(struct ieee80211_hw *hw, u32 entry_no,
114 target_command); 110 target_command);
115 udelay(100); 111 udelay(100);
116 112
117 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 113 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "WRITE A4: %x\n",
118 ("WRITE A4: %x\n", target_content)); 114 target_content);
119 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 115 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "WRITE A0: %x\n",
120 ("WRITE A0: %x\n", target_command)); 116 target_command);
121 } 117 }
122 } 118 }
123 119
124 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 120 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "after set key, usconfig:%x\n",
125 ("after set key, usconfig:%x\n", us_config)); 121 us_config);
126} 122}
127 123
128u8 rtl_cam_add_one_entry(struct ieee80211_hw *hw, u8 *mac_addr, 124u8 rtl_cam_add_one_entry(struct ieee80211_hw *hw, u8 *mac_addr,
@@ -133,14 +129,13 @@ u8 rtl_cam_add_one_entry(struct ieee80211_hw *hw, u8 *mac_addr,
133 struct rtl_priv *rtlpriv = rtl_priv(hw); 129 struct rtl_priv *rtlpriv = rtl_priv(hw);
134 130
135 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 131 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
136 ("EntryNo:%x, ulKeyId=%x, ulEncAlg=%x, " 132 "EntryNo:%x, ulKeyId=%x, ulEncAlg=%x, ulUseDK=%x MacAddr %pM\n",
137 "ulUseDK=%x MacAddr %pM\n", 133 ul_entry_idx, ul_key_id, ul_enc_alg,
138 ul_entry_idx, ul_key_id, ul_enc_alg, 134 ul_default_key, mac_addr);
139 ul_default_key, mac_addr));
140 135
141 if (ul_key_id == TOTAL_CAM_ENTRY) { 136 if (ul_key_id == TOTAL_CAM_ENTRY) {
142 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 137 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
143 ("<=== ulKeyId exceed!\n")); 138 "<=== ulKeyId exceed!\n");
144 return 0; 139 return 0;
145 } 140 }
146 141
@@ -153,7 +148,7 @@ u8 rtl_cam_add_one_entry(struct ieee80211_hw *hw, u8 *mac_addr,
153 rtl_cam_program_entry(hw, ul_entry_idx, mac_addr, 148 rtl_cam_program_entry(hw, ul_entry_idx, mac_addr,
154 (u8 *) key_content, us_config); 149 (u8 *) key_content, us_config);
155 150
156 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("<===\n")); 151 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "<===\n");
157 152
158 return 1; 153 return 1;
159 154
@@ -166,7 +161,7 @@ int rtl_cam_delete_one_entry(struct ieee80211_hw *hw,
166 u32 ul_command; 161 u32 ul_command;
167 struct rtl_priv *rtlpriv = rtl_priv(hw); 162 struct rtl_priv *rtlpriv = rtl_priv(hw);
168 163
169 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("key_idx:%d\n", ul_key_id)); 164 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "key_idx:%d\n", ul_key_id);
170 165
171 ul_command = ul_key_id * CAM_CONTENT_COUNT; 166 ul_command = ul_key_id * CAM_CONTENT_COUNT;
172 ul_command = ul_command | BIT(31) | BIT(16); 167 ul_command = ul_command | BIT(31) | BIT(16);
@@ -175,9 +170,9 @@ int rtl_cam_delete_one_entry(struct ieee80211_hw *hw,
175 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command); 170 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command);
176 171
177 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 172 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
178 ("rtl_cam_delete_one_entry(): WRITE A4: %x\n", 0)); 173 "rtl_cam_delete_one_entry(): WRITE A4: %x\n", 0);
179 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 174 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
180 ("rtl_cam_delete_one_entry(): WRITE A0: %x\n", ul_command)); 175 "rtl_cam_delete_one_entry(): WRITE A0: %x\n", ul_command);
181 176
182 return 0; 177 return 0;
183 178
@@ -229,9 +224,9 @@ void rtl_cam_mark_invalid(struct ieee80211_hw *hw, u8 uc_index)
229 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command); 224 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command);
230 225
231 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 226 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
232 ("rtl_cam_mark_invalid(): WRITE A4: %x\n", ul_content)); 227 "rtl_cam_mark_invalid(): WRITE A4: %x\n", ul_content);
233 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 228 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
234 ("rtl_cam_mark_invalid(): WRITE A0: %x\n", ul_command)); 229 "rtl_cam_mark_invalid(): WRITE A0: %x\n", ul_command);
235} 230}
236EXPORT_SYMBOL(rtl_cam_mark_invalid); 231EXPORT_SYMBOL(rtl_cam_mark_invalid);
237 232
@@ -279,11 +274,11 @@ void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index)
279 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command); 274 rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command);
280 275
281 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 276 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
282 ("rtl_cam_empty_entry(): WRITE A4: %x\n", 277 "rtl_cam_empty_entry(): WRITE A4: %x\n",
283 ul_content)); 278 ul_content);
284 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 279 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
285 ("rtl_cam_empty_entry(): WRITE A0: %x\n", 280 "rtl_cam_empty_entry(): WRITE A0: %x\n",
286 ul_command)); 281 ul_command);
287 } 282 }
288 283
289} 284}
@@ -297,8 +292,7 @@ u8 rtl_cam_get_free_entry(struct ieee80211_hw *hw, u8 *sta_addr)
297 u8 i, *addr; 292 u8 i, *addr;
298 293
299 if (NULL == sta_addr) { 294 if (NULL == sta_addr) {
300 RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG, 295 RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG, "sta_addr is NULL\n");
301 ("sta_addr is NULL.\n"));
302 return TOTAL_CAM_ENTRY; 296 return TOTAL_CAM_ENTRY;
303 } 297 }
304 /* Does STA already exist? */ 298 /* Does STA already exist? */
@@ -311,8 +305,8 @@ u8 rtl_cam_get_free_entry(struct ieee80211_hw *hw, u8 *sta_addr)
311 for (entry_idx = 4; entry_idx < TOTAL_CAM_ENTRY; entry_idx++) { 305 for (entry_idx = 4; entry_idx < TOTAL_CAM_ENTRY; entry_idx++) {
312 if ((bitmap & BIT(0)) == 0) { 306 if ((bitmap & BIT(0)) == 0) {
313 RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG, 307 RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG,
314 ("-----hwsec_cam_bitmap: 0x%x entry_idx=%d\n", 308 "-----hwsec_cam_bitmap: 0x%x entry_idx=%d\n",
315 rtlpriv->sec.hwsec_cam_bitmap, entry_idx)); 309 rtlpriv->sec.hwsec_cam_bitmap, entry_idx);
316 rtlpriv->sec.hwsec_cam_bitmap |= BIT(0) << entry_idx; 310 rtlpriv->sec.hwsec_cam_bitmap |= BIT(0) << entry_idx;
317 memcpy(rtlpriv->sec.hwsec_cam_sta_addr[entry_idx], 311 memcpy(rtlpriv->sec.hwsec_cam_sta_addr[entry_idx],
318 sta_addr, ETH_ALEN); 312 sta_addr, ETH_ALEN);
@@ -331,14 +325,13 @@ void rtl_cam_del_entry(struct ieee80211_hw *hw, u8 *sta_addr)
331 u8 i, *addr; 325 u8 i, *addr;
332 326
333 if (NULL == sta_addr) { 327 if (NULL == sta_addr) {
334 RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG, 328 RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG, "sta_addr is NULL\n");
335 ("sta_addr is NULL.\n"));
336 } 329 }
337 330
338 if ((sta_addr[0]|sta_addr[1]|sta_addr[2]|sta_addr[3]|\ 331 if ((sta_addr[0]|sta_addr[1]|sta_addr[2]|sta_addr[3]|\
339 sta_addr[4]|sta_addr[5]) == 0) { 332 sta_addr[4]|sta_addr[5]) == 0) {
340 RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG, 333 RT_TRACE(rtlpriv, COMP_SEC, DBG_EMERG,
341 ("sta_addr is 00:00:00:00:00:00.\n")); 334 "sta_addr is 00:00:00:00:00:00\n");
342 return; 335 return;
343 } 336 }
344 /* Does STA already exist? */ 337 /* Does STA already exist? */
diff --git a/drivers/net/wireless/rtlwifi/cam.h b/drivers/net/wireless/rtlwifi/cam.h
index c62da4eefc75..35e00086a520 100644
--- a/drivers/net/wireless/rtlwifi/cam.h
+++ b/drivers/net/wireless/rtlwifi/cam.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
index 3f0f056fae9c..f231b9180436 100644
--- a/drivers/net/wireless/rtlwifi/core.c
+++ b/drivers/net/wireless/rtlwifi/core.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -31,8 +31,50 @@
31#include "core.h" 31#include "core.h"
32#include "cam.h" 32#include "cam.h"
33#include "base.h" 33#include "base.h"
34#include "pci.h"
34#include "ps.h" 35#include "ps.h"
35 36
37#include <linux/export.h>
38
39void rtl_fw_cb(const struct firmware *firmware, void *context)
40{
41 struct ieee80211_hw *hw = context;
42 struct rtl_priv *rtlpriv = rtl_priv(hw);
43 int err;
44
45 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
46 "Firmware callback routine entered!\n");
47 complete(&rtlpriv->firmware_loading_complete);
48 if (!firmware) {
49 pr_err("Firmware %s not available\n", rtlpriv->cfg->fw_name);
50 rtlpriv->max_fw_size = 0;
51 return;
52 }
53 if (firmware->size > rtlpriv->max_fw_size) {
54 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
55 "Firmware is too big!\n");
56 release_firmware(firmware);
57 return;
58 }
59 memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size);
60 rtlpriv->rtlhal.fwsize = firmware->size;
61 release_firmware(firmware);
62
63 err = ieee80211_register_hw(hw);
64 if (err) {
65 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
66 "Can't register mac80211 hw\n");
67 return;
68 } else {
69 rtlpriv->mac80211.mac80211_registered = 1;
70 }
71 set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
72
73 /*init rfkill */
74 rtl_init_rfkill(hw);
75}
76EXPORT_SYMBOL(rtl_fw_cb);
77
36/*mutex for start & stop is must here. */ 78/*mutex for start & stop is must here. */
37static int rtl_op_start(struct ieee80211_hw *hw) 79static int rtl_op_start(struct ieee80211_hw *hw)
38{ 80{
@@ -112,9 +154,11 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
112 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 154 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
113 int err = 0; 155 int err = 0;
114 156
157 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
158
115 if (mac->vif) { 159 if (mac->vif) {
116 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 160 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
117 ("vif has been set!! mac->vif = 0x%p\n", mac->vif)); 161 "vif has been set!! mac->vif = 0x%p\n", mac->vif);
118 return -EOPNOTSUPP; 162 return -EOPNOTSUPP;
119 } 163 }
120 164
@@ -125,7 +169,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
125 case NL80211_IFTYPE_STATION: 169 case NL80211_IFTYPE_STATION:
126 if (mac->beacon_enabled == 1) { 170 if (mac->beacon_enabled == 1) {
127 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 171 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
128 ("NL80211_IFTYPE_STATION\n")); 172 "NL80211_IFTYPE_STATION\n");
129 mac->beacon_enabled = 0; 173 mac->beacon_enabled = 0;
130 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, 174 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
131 rtlpriv->cfg->maps 175 rtlpriv->cfg->maps
@@ -134,7 +178,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
134 break; 178 break;
135 case NL80211_IFTYPE_ADHOC: 179 case NL80211_IFTYPE_ADHOC:
136 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 180 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
137 ("NL80211_IFTYPE_ADHOC\n")); 181 "NL80211_IFTYPE_ADHOC\n");
138 182
139 mac->link_state = MAC80211_LINKED; 183 mac->link_state = MAC80211_LINKED;
140 rtlpriv->cfg->ops->set_bcn_reg(hw); 184 rtlpriv->cfg->ops->set_bcn_reg(hw);
@@ -148,7 +192,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
148 break; 192 break;
149 case NL80211_IFTYPE_AP: 193 case NL80211_IFTYPE_AP:
150 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 194 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
151 ("NL80211_IFTYPE_AP\n")); 195 "NL80211_IFTYPE_AP\n");
152 196
153 mac->link_state = MAC80211_LINKED; 197 mac->link_state = MAC80211_LINKED;
154 rtlpriv->cfg->ops->set_bcn_reg(hw); 198 rtlpriv->cfg->ops->set_bcn_reg(hw);
@@ -161,7 +205,7 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw,
161 break; 205 break;
162 default: 206 default:
163 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 207 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
164 ("operation mode %d is not support!\n", vif->type)); 208 "operation mode %d is not supported!\n", vif->type);
165 err = -EOPNOTSUPP; 209 err = -EOPNOTSUPP;
166 goto out; 210 goto out;
167 } 211 }
@@ -221,7 +265,7 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
221 mutex_lock(&rtlpriv->locks.conf_mutex); 265 mutex_lock(&rtlpriv->locks.conf_mutex);
222 if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /*BIT(2)*/ 266 if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /*BIT(2)*/
223 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 267 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
224 ("IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n")); 268 "IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n");
225 } 269 }
226 270
227 /*For IPS */ 271 /*For IPS */
@@ -252,10 +296,12 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
252 * because that will cause nullfunc send by mac80211 296 * because that will cause nullfunc send by mac80211
253 * fail, and cause pkt loss, we have tested that 5mA 297 * fail, and cause pkt loss, we have tested that 5mA
254 * is worked very well */ 298 * is worked very well */
255 if (!rtlpriv->psc.multi_buffered) 299 if (!rtlpriv->psc.multi_buffered) {
256 queue_delayed_work(rtlpriv->works.rtl_wq, 300 queue_delayed_work(rtlpriv->works.rtl_wq,
257 &rtlpriv->works.ps_work, 301 &rtlpriv->works.ps_work,
258 MSECS(5)); 302 MSECS(5));
303 pr_info("In section\n");
304 }
259 } else { 305 } else {
260 rtl_swlps_rf_awake(hw); 306 rtl_swlps_rf_awake(hw);
261 rtlpriv->psc.sw_ps_enabled = false; 307 rtlpriv->psc.sw_ps_enabled = false;
@@ -264,8 +310,8 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
264 310
265 if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) { 311 if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) {
266 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 312 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
267 ("IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n", 313 "IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n",
268 hw->conf.long_frame_max_tx_count)); 314 hw->conf.long_frame_max_tx_count);
269 mac->retry_long = hw->conf.long_frame_max_tx_count; 315 mac->retry_long = hw->conf.long_frame_max_tx_count;
270 mac->retry_short = hw->conf.long_frame_max_tx_count; 316 mac->retry_short = hw->conf.long_frame_max_tx_count;
271 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT, 317 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT,
@@ -320,7 +366,7 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed)
320 default: 366 default:
321 mac->bw_40 = false; 367 mac->bw_40 = false;
322 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 368 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
323 ("switch case not processed\n")); 369 "switch case not processed\n");
324 break; 370 break;
325 } 371 }
326 372
@@ -369,12 +415,12 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
369 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] | 415 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] |
370 rtlpriv->cfg->maps[MAC_RCR_AB]; 416 rtlpriv->cfg->maps[MAC_RCR_AB];
371 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 417 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
372 ("Enable receive multicast frame.\n")); 418 "Enable receive multicast frame\n");
373 } else { 419 } else {
374 mac->rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] | 420 mac->rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] |
375 rtlpriv->cfg->maps[MAC_RCR_AB]); 421 rtlpriv->cfg->maps[MAC_RCR_AB]);
376 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 422 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
377 ("Disable receive multicast frame.\n")); 423 "Disable receive multicast frame\n");
378 } 424 }
379 } 425 }
380 426
@@ -382,11 +428,11 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
382 if (*new_flags & FIF_FCSFAIL) { 428 if (*new_flags & FIF_FCSFAIL) {
383 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32]; 429 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32];
384 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 430 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
385 ("Enable receive FCS error frame.\n")); 431 "Enable receive FCS error frame\n");
386 } else { 432 } else {
387 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32]; 433 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32];
388 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 434 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
389 ("Disable receive FCS error frame.\n")); 435 "Disable receive FCS error frame\n");
390 } 436 }
391 } 437 }
392 438
@@ -409,11 +455,11 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
409 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF]; 455 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF];
410 456
411 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 457 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
412 ("Enable receive control frame.\n")); 458 "Enable receive control frame\n");
413 } else { 459 } else {
414 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF]; 460 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF];
415 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 461 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
416 ("Disable receive control frame.\n")); 462 "Disable receive control frame\n");
417 } 463 }
418 } 464 }
419 465
@@ -421,11 +467,11 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
421 if (*new_flags & FIF_OTHER_BSS) { 467 if (*new_flags & FIF_OTHER_BSS) {
422 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP]; 468 mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP];
423 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 469 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
424 ("Enable receive other BSS's frame.\n")); 470 "Enable receive other BSS's frame\n");
425 } else { 471 } else {
426 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP]; 472 mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP];
427 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 473 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
428 ("Disable receive other BSS's frame.\n")); 474 "Disable receive other BSS's frame\n");
429 } 475 }
430 } 476 }
431} 477}
@@ -456,7 +502,7 @@ static int rtl_op_sta_add(struct ieee80211_hw *hw,
456 sta_entry->wireless_mode = WIRELESS_MODE_G; 502 sta_entry->wireless_mode = WIRELESS_MODE_G;
457 503
458 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 504 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
459 ("Add sta addr is %pM\n", sta->addr)); 505 "Add sta addr is %pM\n", sta->addr);
460 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); 506 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
461 } 507 }
462 return 0; 508 return 0;
@@ -469,7 +515,7 @@ static int rtl_op_sta_remove(struct ieee80211_hw *hw,
469 struct rtl_sta_info *sta_entry; 515 struct rtl_sta_info *sta_entry;
470 if (sta) { 516 if (sta) {
471 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 517 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
472 ("Remove sta addr is %pM\n", sta->addr)); 518 "Remove sta addr is %pM\n", sta->addr);
473 sta_entry = (struct rtl_sta_info *) sta->drv_priv; 519 sta_entry = (struct rtl_sta_info *) sta->drv_priv;
474 sta_entry->wireless_mode = 0; 520 sta_entry->wireless_mode = 0;
475 sta_entry->ratr_index = 0; 521 sta_entry->ratr_index = 0;
@@ -514,7 +560,7 @@ static int rtl_op_conf_tx(struct ieee80211_hw *hw,
514 560
515 if (queue >= AC_MAX) { 561 if (queue >= AC_MAX) {
516 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 562 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
517 ("queue number %d is incorrect!\n", queue)); 563 "queue number %d is incorrect!\n", queue);
518 return -EINVAL; 564 return -EINVAL;
519 } 565 }
520 566
@@ -547,7 +593,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
547 bss_conf->enable_beacon)) { 593 bss_conf->enable_beacon)) {
548 if (mac->beacon_enabled == 0) { 594 if (mac->beacon_enabled == 0) {
549 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 595 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
550 ("BSS_CHANGED_BEACON_ENABLED\n")); 596 "BSS_CHANGED_BEACON_ENABLED\n");
551 597
552 /*start hw beacon interrupt. */ 598 /*start hw beacon interrupt. */
553 /*rtlpriv->cfg->ops->set_bcn_reg(hw); */ 599 /*rtlpriv->cfg->ops->set_bcn_reg(hw); */
@@ -565,7 +611,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
565 !bss_conf->enable_beacon)) { 611 !bss_conf->enable_beacon)) {
566 if (mac->beacon_enabled == 1) { 612 if (mac->beacon_enabled == 1) {
567 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 613 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
568 ("ADHOC DISABLE BEACON\n")); 614 "ADHOC DISABLE BEACON\n");
569 615
570 mac->beacon_enabled = 0; 616 mac->beacon_enabled = 0;
571 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, 617 rtlpriv->cfg->ops->update_interrupt_mask(hw, 0,
@@ -575,7 +621,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
575 } 621 }
576 if (changed & BSS_CHANGED_BEACON_INT) { 622 if (changed & BSS_CHANGED_BEACON_INT) {
577 RT_TRACE(rtlpriv, COMP_BEACON, DBG_TRACE, 623 RT_TRACE(rtlpriv, COMP_BEACON, DBG_TRACE,
578 ("BSS_CHANGED_BEACON_INT\n")); 624 "BSS_CHANGED_BEACON_INT\n");
579 mac->beacon_interval = bss_conf->beacon_int; 625 mac->beacon_interval = bss_conf->beacon_int;
580 rtlpriv->cfg->ops->set_bcn_intv(hw); 626 rtlpriv->cfg->ops->set_bcn_intv(hw);
581 } 627 }
@@ -604,7 +650,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
604 if (mac->opmode == NL80211_IFTYPE_STATION && sta) 650 if (mac->opmode == NL80211_IFTYPE_STATION && sta)
605 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); 651 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0);
606 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 652 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
607 ("BSS_CHANGED_ASSOC\n")); 653 "BSS_CHANGED_ASSOC\n");
608 } else { 654 } else {
609 if (mac->link_state == MAC80211_LINKED) 655 if (mac->link_state == MAC80211_LINKED)
610 rtl_lps_leave(hw); 656 rtl_lps_leave(hw);
@@ -619,20 +665,20 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
619 mac->vendor = PEER_UNKNOWN; 665 mac->vendor = PEER_UNKNOWN;
620 666
621 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 667 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG,
622 ("BSS_CHANGED_UN_ASSOC\n")); 668 "BSS_CHANGED_UN_ASSOC\n");
623 } 669 }
624 } 670 }
625 671
626 if (changed & BSS_CHANGED_ERP_CTS_PROT) { 672 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
627 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, 673 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
628 ("BSS_CHANGED_ERP_CTS_PROT\n")); 674 "BSS_CHANGED_ERP_CTS_PROT\n");
629 mac->use_cts_protect = bss_conf->use_cts_prot; 675 mac->use_cts_protect = bss_conf->use_cts_prot;
630 } 676 }
631 677
632 if (changed & BSS_CHANGED_ERP_PREAMBLE) { 678 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
633 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, 679 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
634 ("BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n", 680 "BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n",
635 bss_conf->use_short_preamble)); 681 bss_conf->use_short_preamble);
636 682
637 mac->short_preamble = bss_conf->use_short_preamble; 683 mac->short_preamble = bss_conf->use_short_preamble;
638 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE, 684 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE,
@@ -641,7 +687,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
641 687
642 if (changed & BSS_CHANGED_ERP_SLOT) { 688 if (changed & BSS_CHANGED_ERP_SLOT) {
643 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, 689 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
644 ("BSS_CHANGED_ERP_SLOT\n")); 690 "BSS_CHANGED_ERP_SLOT\n");
645 691
646 if (bss_conf->use_short_slot) 692 if (bss_conf->use_short_slot)
647 mac->slot_time = RTL_SLOT_TIME_9; 693 mac->slot_time = RTL_SLOT_TIME_9;
@@ -653,8 +699,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
653 } 699 }
654 700
655 if (changed & BSS_CHANGED_HT) { 701 if (changed & BSS_CHANGED_HT) {
656 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, 702 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, "BSS_CHANGED_HT\n");
657 ("BSS_CHANGED_HT\n"));
658 rcu_read_lock(); 703 rcu_read_lock();
659 sta = get_sta(hw, vif, bss_conf->bssid); 704 sta = get_sta(hw, vif, bss_conf->bssid);
660 if (sta) { 705 if (sta) {
@@ -683,8 +728,8 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
683 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID, 728 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID,
684 (u8 *) bss_conf->bssid); 729 (u8 *) bss_conf->bssid);
685 730
686 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, 731 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, "%pM\n",
687 ("%pM\n", bss_conf->bssid)); 732 bss_conf->bssid);
688 733
689 mac->vendor = PEER_UNKNOWN; 734 mac->vendor = PEER_UNKNOWN;
690 memcpy(mac->bssid, bss_conf->bssid, 6); 735 memcpy(mac->bssid, bss_conf->bssid, 6);
@@ -831,30 +876,30 @@ static int rtl_op_ampdu_action(struct ieee80211_hw *hw,
831 switch (action) { 876 switch (action) {
832 case IEEE80211_AMPDU_TX_START: 877 case IEEE80211_AMPDU_TX_START:
833 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, 878 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
834 ("IEEE80211_AMPDU_TX_START: TID:%d\n", tid)); 879 "IEEE80211_AMPDU_TX_START: TID:%d\n", tid);
835 return rtl_tx_agg_start(hw, sta, tid, ssn); 880 return rtl_tx_agg_start(hw, sta, tid, ssn);
836 break; 881 break;
837 case IEEE80211_AMPDU_TX_STOP: 882 case IEEE80211_AMPDU_TX_STOP:
838 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, 883 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
839 ("IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid)); 884 "IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid);
840 return rtl_tx_agg_stop(hw, sta, tid); 885 return rtl_tx_agg_stop(hw, sta, tid);
841 break; 886 break;
842 case IEEE80211_AMPDU_TX_OPERATIONAL: 887 case IEEE80211_AMPDU_TX_OPERATIONAL:
843 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, 888 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
844 ("IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid)); 889 "IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid);
845 rtl_tx_agg_oper(hw, sta, tid); 890 rtl_tx_agg_oper(hw, sta, tid);
846 break; 891 break;
847 case IEEE80211_AMPDU_RX_START: 892 case IEEE80211_AMPDU_RX_START:
848 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, 893 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
849 ("IEEE80211_AMPDU_RX_START:TID:%d\n", tid)); 894 "IEEE80211_AMPDU_RX_START:TID:%d\n", tid);
850 break; 895 break;
851 case IEEE80211_AMPDU_RX_STOP: 896 case IEEE80211_AMPDU_RX_STOP:
852 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, 897 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE,
853 ("IEEE80211_AMPDU_RX_STOP:TID:%d\n", tid)); 898 "IEEE80211_AMPDU_RX_STOP:TID:%d\n", tid);
854 break; 899 break;
855 default: 900 default:
856 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 901 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
857 ("IEEE80211_AMPDU_ERR!!!!:\n")); 902 "IEEE80211_AMPDU_ERR!!!!:\n");
858 return -EOPNOTSUPP; 903 return -EOPNOTSUPP;
859 } 904 }
860 return 0; 905 return 0;
@@ -867,7 +912,7 @@ static void rtl_op_sw_scan_start(struct ieee80211_hw *hw)
867 912
868 mac->act_scanning = true; 913 mac->act_scanning = true;
869 914
870 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("\n")); 915 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
871 916
872 if (mac->link_state == MAC80211_LINKED) { 917 if (mac->link_state == MAC80211_LINKED) {
873 rtl_lps_leave(hw); 918 rtl_lps_leave(hw);
@@ -888,7 +933,7 @@ static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw)
888 struct rtl_priv *rtlpriv = rtl_priv(hw); 933 struct rtl_priv *rtlpriv = rtl_priv(hw);
889 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 934 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
890 935
891 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, ("\n")); 936 RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
892 mac->act_scanning = false; 937 mac->act_scanning = false;
893 /* Dual mac */ 938 /* Dual mac */
894 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false; 939 rtlpriv->rtlhal.load_imrandiqk_setting_for2g = false;
@@ -921,13 +966,13 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
921 966
922 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { 967 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
923 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 968 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
924 ("not open hw encryption\n")); 969 "not open hw encryption\n");
925 return -ENOSPC; /*User disabled HW-crypto */ 970 return -ENOSPC; /*User disabled HW-crypto */
926 } 971 }
927 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 972 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
928 ("%s hardware based encryption for keyidx: %d, mac: %pM\n", 973 "%s hardware based encryption for keyidx: %d, mac: %pM\n",
929 cmd == SET_KEY ? "Using" : "Disabling", key->keyidx, 974 cmd == SET_KEY ? "Using" : "Disabling", key->keyidx,
930 sta ? sta->addr : bcast_addr)); 975 sta ? sta->addr : bcast_addr);
931 rtlpriv->sec.being_setkey = true; 976 rtlpriv->sec.being_setkey = true;
932 rtl_ips_nic_on(hw); 977 rtl_ips_nic_on(hw);
933 mutex_lock(&rtlpriv->locks.conf_mutex); 978 mutex_lock(&rtlpriv->locks.conf_mutex);
@@ -936,24 +981,23 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
936 switch (key->cipher) { 981 switch (key->cipher) {
937 case WLAN_CIPHER_SUITE_WEP40: 982 case WLAN_CIPHER_SUITE_WEP40:
938 key_type = WEP40_ENCRYPTION; 983 key_type = WEP40_ENCRYPTION;
939 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("alg:WEP40\n")); 984 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP40\n");
940 break; 985 break;
941 case WLAN_CIPHER_SUITE_WEP104: 986 case WLAN_CIPHER_SUITE_WEP104:
942 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 987 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:WEP104\n");
943 ("alg:WEP104\n"));
944 key_type = WEP104_ENCRYPTION; 988 key_type = WEP104_ENCRYPTION;
945 break; 989 break;
946 case WLAN_CIPHER_SUITE_TKIP: 990 case WLAN_CIPHER_SUITE_TKIP:
947 key_type = TKIP_ENCRYPTION; 991 key_type = TKIP_ENCRYPTION;
948 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("alg:TKIP\n")); 992 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:TKIP\n");
949 break; 993 break;
950 case WLAN_CIPHER_SUITE_CCMP: 994 case WLAN_CIPHER_SUITE_CCMP:
951 key_type = AESCCMP_ENCRYPTION; 995 key_type = AESCCMP_ENCRYPTION;
952 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("alg:CCMP\n")); 996 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "alg:CCMP\n");
953 break; 997 break;
954 default: 998 default:
955 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 999 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "alg_err:%x!!!!\n",
956 ("alg_err:%x!!!!:\n", key->cipher)); 1000 key->cipher);
957 goto out_unlock; 1001 goto out_unlock;
958 } 1002 }
959 if (key_type == WEP40_ENCRYPTION || 1003 if (key_type == WEP40_ENCRYPTION ||
@@ -995,8 +1039,8 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
995 wep_only = true; 1039 wep_only = true;
996 rtlpriv->sec.pairwise_enc_algorithm = key_type; 1040 rtlpriv->sec.pairwise_enc_algorithm = key_type;
997 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 1041 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
998 ("set enable_hw_sec, key_type:%x(OPEN:0 WEP40:1" 1042 "set enable_hw_sec, key_type:%x(OPEN:0 WEP40:1 TKIP:2 AES:4 WEP104:5)\n",
999 " TKIP:2 AES:4 WEP104:5)\n", key_type)); 1043 key_type);
1000 rtlpriv->cfg->ops->enable_hw_sec(hw); 1044 rtlpriv->cfg->ops->enable_hw_sec(hw);
1001 } 1045 }
1002 } 1046 }
@@ -1005,7 +1049,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1005 case SET_KEY: 1049 case SET_KEY:
1006 if (wep_only) { 1050 if (wep_only) {
1007 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 1051 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1008 ("set WEP(group/pairwise) key\n")); 1052 "set WEP(group/pairwise) key\n");
1009 /* Pairwise key with an assigned MAC address. */ 1053 /* Pairwise key with an assigned MAC address. */
1010 rtlpriv->sec.pairwise_enc_algorithm = key_type; 1054 rtlpriv->sec.pairwise_enc_algorithm = key_type;
1011 rtlpriv->sec.group_enc_algorithm = key_type; 1055 rtlpriv->sec.group_enc_algorithm = key_type;
@@ -1016,7 +1060,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1016 memcpy(mac_addr, zero_addr, ETH_ALEN); 1060 memcpy(mac_addr, zero_addr, ETH_ALEN);
1017 } else if (group_key) { /* group key */ 1061 } else if (group_key) { /* group key */
1018 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 1062 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1019 ("set group key\n")); 1063 "set group key\n");
1020 /* group key */ 1064 /* group key */
1021 rtlpriv->sec.group_enc_algorithm = key_type; 1065 rtlpriv->sec.group_enc_algorithm = key_type;
1022 /*set local buf about group key. */ 1066 /*set local buf about group key. */
@@ -1026,10 +1070,10 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1026 memcpy(mac_addr, bcast_addr, ETH_ALEN); 1070 memcpy(mac_addr, bcast_addr, ETH_ALEN);
1027 } else { /* pairwise key */ 1071 } else { /* pairwise key */
1028 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 1072 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1029 ("set pairwise key\n")); 1073 "set pairwise key\n");
1030 if (!sta) { 1074 if (!sta) {
1031 RT_ASSERT(false, ("pairwise key withnot" 1075 RT_ASSERT(false,
1032 "mac_addr\n")); 1076 "pairwise key without mac_addr\n");
1033 1077
1034 err = -EOPNOTSUPP; 1078 err = -EOPNOTSUPP;
1035 goto out_unlock; 1079 goto out_unlock;
@@ -1056,7 +1100,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1056 break; 1100 break;
1057 case DISABLE_KEY: 1101 case DISABLE_KEY:
1058 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 1102 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1059 ("disable key delete one entry\n")); 1103 "disable key delete one entry\n");
1060 /*set local buf about wep key. */ 1104 /*set local buf about wep key. */
1061 if (mac->opmode == NL80211_IFTYPE_AP) { 1105 if (mac->opmode == NL80211_IFTYPE_AP) {
1062 if (sta) 1106 if (sta)
@@ -1077,7 +1121,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1077 break; 1121 break;
1078 default: 1122 default:
1079 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1123 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1080 ("cmd_err:%x!!!!:\n", cmd)); 1124 "cmd_err:%x!!!!\n", cmd);
1081 } 1125 }
1082out_unlock: 1126out_unlock:
1083 mutex_unlock(&rtlpriv->locks.conf_mutex); 1127 mutex_unlock(&rtlpriv->locks.conf_mutex);
@@ -1106,8 +1150,8 @@ static void rtl_op_rfkill_poll(struct ieee80211_hw *hw)
1106 rtlpriv->rfkill.rfkill_state = radio_state; 1150 rtlpriv->rfkill.rfkill_state = radio_state;
1107 1151
1108 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 1152 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
1109 (KERN_INFO "wireless radio switch turned %s\n", 1153 "wireless radio switch turned %s\n",
1110 radio_state ? "on" : "off")); 1154 radio_state ? "on" : "off");
1111 1155
1112 blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1; 1156 blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1;
1113 wiphy_rfkill_set_hw_state(hw->wiphy, blocked); 1157 wiphy_rfkill_set_hw_state(hw->wiphy, blocked);
diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h
index f02824a3b747..2fe46a1b4f1f 100644
--- a/drivers/net/wireless/rtlwifi/core.h
+++ b/drivers/net/wireless/rtlwifi/core.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * Tmis program is free software; you can redistribute it and/or modify it 5 * Tmis program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -30,8 +30,6 @@
30#ifndef __RTL_CORE_H__ 30#ifndef __RTL_CORE_H__
31#define __RTL_CORE_H__ 31#define __RTL_CORE_H__
32 32
33#include <net/mac80211.h>
34
35#define RTL_SUPPORTED_FILTERS \ 33#define RTL_SUPPORTED_FILTERS \
36 (FIF_PROMISC_IN_BSS | \ 34 (FIF_PROMISC_IN_BSS | \
37 FIF_ALLMULTI | FIF_CONTROL | \ 35 FIF_ALLMULTI | FIF_CONTROL | \
@@ -42,4 +40,6 @@
42#define RTL_SUPPORTED_CTRL_FILTER 0xFF 40#define RTL_SUPPORTED_CTRL_FILTER 0xFF
43 41
44extern const struct ieee80211_ops rtl_ops; 42extern const struct ieee80211_ops rtl_ops;
43void rtl_fw_cb(const struct firmware *firmware, void *context);
44
45#endif 45#endif
diff --git a/drivers/net/wireless/rtlwifi/debug.c b/drivers/net/wireless/rtlwifi/debug.c
index 1b5cb7153a52..bdda9b2fffe1 100644
--- a/drivers/net/wireless/rtlwifi/debug.c
+++ b/drivers/net/wireless/rtlwifi/debug.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * Tmis program is free software; you can redistribute it and/or modify it 5 * Tmis program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -28,6 +28,8 @@
28 28
29#include "wifi.h" 29#include "wifi.h"
30 30
31#include <linux/moduleparam.h>
32
31void rtl_dbgp_flag_init(struct ieee80211_hw *hw) 33void rtl_dbgp_flag_init(struct ieee80211_hw *hw)
32{ 34{
33 struct rtl_priv *rtlpriv = rtl_priv(hw); 35 struct rtl_priv *rtlpriv = rtl_priv(hw);
diff --git a/drivers/net/wireless/rtlwifi/debug.h b/drivers/net/wireless/rtlwifi/debug.h
index 160dd0685213..07493d2957f2 100644
--- a/drivers/net/wireless/rtlwifi/debug.h
+++ b/drivers/net/wireless/rtlwifi/debug.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * Tmis program is free software; you can redistribute it and/or modify it 5 * Tmis program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -156,53 +156,78 @@ enum dbgp_flag_e {
156 DBGP_TYPE_MAX 156 DBGP_TYPE_MAX
157}; 157};
158 158
159#define RT_ASSERT(_exp, fmt) \ 159#ifdef CONFIG_RTLWIFI_DEBUG
160 do { \ 160
161 if (!(_exp)) { \ 161#define RT_ASSERT(_exp, fmt, ...) \
162 printk(KERN_DEBUG "%s:%s(): ", KBUILD_MODNAME, \ 162do { \
163 __func__); \ 163 if (!(_exp)) { \
164 printk fmt; \ 164 printk(KERN_DEBUG KBUILD_MODNAME ":%s(): " fmt, \
165 } \ 165 __func__, ##__VA_ARGS__); \
166 } while (0); 166 } \
167 167} while (0)
168#define RT_TRACE(rtlpriv, comp, level, fmt)\ 168
169 do { \ 169#define RT_TRACE(rtlpriv, comp, level, fmt, ...) \
170 if (unlikely(((comp) & rtlpriv->dbg.global_debugcomponents) && \ 170do { \
171 ((level) <= rtlpriv->dbg.global_debuglevel))) {\ 171 if (unlikely(((comp) & rtlpriv->dbg.global_debugcomponents) && \
172 printk(KERN_DEBUG "%s:%s():<%lx-%x> ", KBUILD_MODNAME, \ 172 ((level) <= rtlpriv->dbg.global_debuglevel))) { \
173 __func__, in_interrupt(), in_atomic()); \ 173 printk(KERN_DEBUG KBUILD_MODNAME ":%s():<%lx-%x> " fmt, \
174 printk fmt; \ 174 __func__, in_interrupt(), in_atomic(), \
175 } \ 175 ##__VA_ARGS__); \
176 } while (0); 176 } \
177 177} while (0)
178#define RTPRINT(rtlpriv, dbgtype, dbgflag, printstr) \ 178
179 do { \ 179#define RTPRINT(rtlpriv, dbgtype, dbgflag, fmt, ...) \
180 if (unlikely(rtlpriv->dbg.dbgp_type[dbgtype] & dbgflag)) { \ 180do { \
181 printk(KERN_DEBUG "%s: ", KBUILD_MODNAME); \ 181 if (unlikely(rtlpriv->dbg.dbgp_type[dbgtype] & dbgflag)) { \
182 printk printstr; \ 182 printk(KERN_DEBUG KBUILD_MODNAME ": " fmt, \
183 } \ 183 ##__VA_ARGS__); \
184 } while (0); 184 } \
185 185} while (0)
186#define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata, \ 186
187 _hexdatalen) \ 187#define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata, \
188 do {\ 188 _hexdatalen) \
189 if (unlikely(((_comp) & rtlpriv->dbg.global_debugcomponents) &&\ 189do { \
190 (_level <= rtlpriv->dbg.global_debuglevel))) { \ 190 if (unlikely(((_comp) & rtlpriv->dbg.global_debugcomponents) && \
191 int __i; \ 191 (_level <= rtlpriv->dbg.global_debuglevel))) { \
192 u8* ptr = (u8 *)_hexdata; \ 192 printk(KERN_DEBUG "%s: In process \"%s\" (pid %i): %s\n", \
193 printk(KERN_DEBUG "%s: ", KBUILD_MODNAME); \ 193 KBUILD_MODNAME, current->comm, current->pid, \
194 printk("In process \"%s\" (pid %i):", current->comm,\ 194 _titlestring); \
195 current->pid); \ 195 print_hex_dump_bytes("", DUMP_PREFIX_NONE, \
196 printk(_titlestring); \ 196 _hexdata, _hexdatalen); \
197 for (__i = 0; __i < (int)_hexdatalen; __i++) { \ 197 } \
198 printk("%02X%s", ptr[__i], (((__i + 1) % 4)\ 198} while (0)
199 == 0) ? " " : " ");\ 199
200 if (((__i + 1) % 16) == 0) \ 200#else
201 printk("\n"); \ 201
202 } \ 202struct rtl_priv;
203 printk(KERN_DEBUG "\n"); \ 203
204 } \ 204__printf(2, 3)
205 } while (0); 205static inline void RT_ASSERT(int exp, const char *fmt, ...)
206{
207}
208
209__printf(4, 5)
210static inline void RT_TRACE(struct rtl_priv *rtlpriv,
211 int comp, int level,
212 const char *fmt, ...)
213{
214}
215
216__printf(4, 5)
217static inline void RTPRINT(struct rtl_priv *rtlpriv,
218 int dbgtype, int dbgflag,
219 const char *fmt, ...)
220{
221}
222
223static inline void RT_PRINT_DATA(struct rtl_priv *rtlpriv,
224 int comp, int level,
225 const char *titlestring,
226 const void *hexdata, size_t hexdatalen)
227{
228}
229
230#endif
206 231
207void rtl_dbgp_flag_init(struct ieee80211_hw *hw); 232void rtl_dbgp_flag_init(struct ieee80211_hw *hw);
208#endif 233#endif
diff --git a/drivers/net/wireless/rtlwifi/efuse.c b/drivers/net/wireless/rtlwifi/efuse.c
index ed1058b71587..b24cbe6e16d8 100644
--- a/drivers/net/wireless/rtlwifi/efuse.c
+++ b/drivers/net/wireless/rtlwifi/efuse.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * Tmis program is free software; you can redistribute it and/or modify it 5 * Tmis program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -162,8 +162,8 @@ void efuse_write_1byte(struct ieee80211_hw *hw, u16 address, u8 value)
162 const u32 efuse_len = 162 const u32 efuse_len =
163 rtlpriv->cfg->maps[EFUSE_REAL_CONTENT_SIZE]; 163 rtlpriv->cfg->maps[EFUSE_REAL_CONTENT_SIZE];
164 164
165 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, 165 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, "Addr=%x Data =%x\n",
166 ("Addr=%x Data =%x\n", address, value)); 166 address, value);
167 167
168 if (address < efuse_len) { 168 if (address < efuse_len) {
169 rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL], value); 169 rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL], value);
@@ -252,8 +252,8 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
252 252
253 if ((_offset + _size_byte) > rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]) { 253 if ((_offset + _size_byte) > rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]) {
254 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, 254 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD,
255 ("read_efuse(): Invalid offset(%#x) with read " 255 "read_efuse(): Invalid offset(%#x) with read bytes(%#x)!!\n",
256 "bytes(%#x)!!\n", _offset, _size_byte)); 256 _offset, _size_byte);
257 return; 257 return;
258 } 258 }
259 259
@@ -280,7 +280,7 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
280 if (*rtemp8 != 0xFF) { 280 if (*rtemp8 != 0xFF) {
281 efuse_utilized++; 281 efuse_utilized++;
282 RTPRINT(rtlpriv, FEEPROM, EFUSE_READ_ALL, 282 RTPRINT(rtlpriv, FEEPROM, EFUSE_READ_ALL,
283 ("Addr=%d\n", efuse_addr)); 283 "Addr=%d\n", efuse_addr);
284 efuse_addr++; 284 efuse_addr++;
285 } 285 }
286 286
@@ -290,13 +290,13 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
290 if (offset < efuse_max_section) { 290 if (offset < efuse_max_section) {
291 wren = (*rtemp8 & 0x0f); 291 wren = (*rtemp8 & 0x0f);
292 RTPRINT(rtlpriv, FEEPROM, EFUSE_READ_ALL, 292 RTPRINT(rtlpriv, FEEPROM, EFUSE_READ_ALL,
293 ("offset-%d Worden=%x\n", offset, wren)); 293 "offset-%d Worden=%x\n", offset, wren);
294 294
295 for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { 295 for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) {
296 if (!(wren & 0x01)) { 296 if (!(wren & 0x01)) {
297 RTPRINT(rtlpriv, FEEPROM, 297 RTPRINT(rtlpriv, FEEPROM,
298 EFUSE_READ_ALL, ("Addr=%d\n", 298 EFUSE_READ_ALL,
299 efuse_addr)); 299 "Addr=%d\n", efuse_addr);
300 300
301 read_efuse_byte(hw, efuse_addr, rtemp8); 301 read_efuse_byte(hw, efuse_addr, rtemp8);
302 efuse_addr++; 302 efuse_addr++;
@@ -308,8 +308,8 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
308 break; 308 break;
309 309
310 RTPRINT(rtlpriv, FEEPROM, 310 RTPRINT(rtlpriv, FEEPROM,
311 EFUSE_READ_ALL, ("Addr=%d\n", 311 EFUSE_READ_ALL,
312 efuse_addr)); 312 "Addr=%d\n", efuse_addr);
313 313
314 read_efuse_byte(hw, efuse_addr, rtemp8); 314 read_efuse_byte(hw, efuse_addr, rtemp8);
315 efuse_addr++; 315 efuse_addr++;
@@ -326,7 +326,7 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
326 } 326 }
327 327
328 RTPRINT(rtlpriv, FEEPROM, EFUSE_READ_ALL, 328 RTPRINT(rtlpriv, FEEPROM, EFUSE_READ_ALL,
329 ("Addr=%d\n", efuse_addr)); 329 "Addr=%d\n", efuse_addr);
330 read_efuse_byte(hw, efuse_addr, rtemp8); 330 read_efuse_byte(hw, efuse_addr, rtemp8);
331 if (*rtemp8 != 0xFF && (efuse_addr < efuse_len)) { 331 if (*rtemp8 != 0xFF && (efuse_addr < efuse_len)) {
332 efuse_utilized++; 332 efuse_utilized++;
@@ -395,9 +395,8 @@ bool efuse_shadow_update_chk(struct ieee80211_hw *hw)
395 result = false; 395 result = false;
396 396
397 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, 397 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD,
398 ("efuse_shadow_update_chk(): totalbytes(%#x), " 398 "efuse_shadow_update_chk(): totalbytes(%#x), hdr_num(%#x), words_need(%#x), efuse_used(%d)\n",
399 "hdr_num(%#x), words_need(%#x), efuse_used(%d)\n", 399 totalbytes, hdr_num, words_need, efuse_used);
400 totalbytes, hdr_num, words_need, efuse_used));
401 400
402 return result; 401 return result;
403} 402}
@@ -434,7 +433,7 @@ bool efuse_shadow_update(struct ieee80211_hw *hw)
434 u8 word_en = 0x0F; 433 u8 word_en = 0x0F;
435 u8 first_pg = false; 434 u8 first_pg = false;
436 435
437 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, ("--->\n")); 436 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, "--->\n");
438 437
439 if (!efuse_shadow_update_chk(hw)) { 438 if (!efuse_shadow_update_chk(hw)) {
440 efuse_read_all_map(hw, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0]); 439 efuse_read_all_map(hw, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0]);
@@ -443,7 +442,7 @@ bool efuse_shadow_update(struct ieee80211_hw *hw)
443 rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]); 442 rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]);
444 443
445 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, 444 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD,
446 ("<---efuse out of capacity!!\n")); 445 "<---efuse out of capacity!!\n");
447 return false; 446 return false;
448 } 447 }
449 efuse_power_switch(hw, true, true); 448 efuse_power_switch(hw, true, true);
@@ -478,12 +477,12 @@ bool efuse_shadow_update(struct ieee80211_hw *hw)
478 &rtlefuse->efuse_map[EFUSE_MODIFY_MAP][base], 477 &rtlefuse->efuse_map[EFUSE_MODIFY_MAP][base],
479 8); 478 8);
480 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_LOUD, 479 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_LOUD,
481 ("U-efuse\n"), tmpdata, 8); 480 "U-efuse", tmpdata, 8);
482 481
483 if (!efuse_pg_packet_write(hw, (u8) offset, word_en, 482 if (!efuse_pg_packet_write(hw, (u8) offset, word_en,
484 tmpdata)) { 483 tmpdata)) {
485 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 484 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
486 ("PG section(%#x) fail!!\n", offset)); 485 "PG section(%#x) fail!!\n", offset);
487 break; 486 break;
488 } 487 }
489 } 488 }
@@ -497,7 +496,7 @@ bool efuse_shadow_update(struct ieee80211_hw *hw)
497 &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], 496 &rtlefuse->efuse_map[EFUSE_INIT_MAP][0],
498 rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]); 497 rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]);
499 498
500 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, ("<---\n")); 499 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, "<---\n");
501 return true; 500 return true;
502} 501}
503 502
@@ -634,8 +633,8 @@ static int efuse_one_byte_write(struct ieee80211_hw *hw, u16 addr, u8 data)
634 struct rtl_priv *rtlpriv = rtl_priv(hw); 633 struct rtl_priv *rtlpriv = rtl_priv(hw);
635 u8 tmpidx = 0; 634 u8 tmpidx = 0;
636 635
637 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, 636 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, "Addr = %x Data=%x\n",
638 ("Addr = %x Data=%x\n", addr, data)); 637 addr, data);
639 638
640 rtl_write_byte(rtlpriv, 639 rtl_write_byte(rtlpriv,
641 rtlpriv->cfg->maps[EFUSE_CTRL] + 1, (u8) (addr & 0xff)); 640 rtlpriv->cfg->maps[EFUSE_CTRL] + 1, (u8) (addr & 0xff));
@@ -851,7 +850,7 @@ static void efuse_write_data_case1(struct ieee80211_hw *hw, u16 *efuse_addr,
851 } 850 }
852 } 851 }
853 } 852 }
854 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, ("efuse PG_STATE_HEADER-1\n")); 853 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, "efuse PG_STATE_HEADER-1\n");
855} 854}
856 855
857static void efuse_write_data_case2(struct ieee80211_hw *hw, u16 *efuse_addr, 856static void efuse_write_data_case2(struct ieee80211_hw *hw, u16 *efuse_addr,
@@ -916,7 +915,7 @@ static void efuse_write_data_case2(struct ieee80211_hw *hw, u16 *efuse_addr,
916 } 915 }
917 916
918 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, 917 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG,
919 ("efuse PG_STATE_HEADER-2\n")); 918 "efuse PG_STATE_HEADER-2\n");
920 } 919 }
921} 920}
922 921
@@ -936,7 +935,7 @@ static int efuse_pg_packet_write(struct ieee80211_hw *hw,
936 if (efuse_get_current_size(hw) >= 935 if (efuse_get_current_size(hw) >=
937 (EFUSE_MAX_SIZE - EFUSE_OOB_PROTECT_BYTES)) { 936 (EFUSE_MAX_SIZE - EFUSE_OOB_PROTECT_BYTES)) {
938 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, 937 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG,
939 ("efuse_pg_packet_write error\n")); 938 "efuse_pg_packet_write error\n");
940 return false; 939 return false;
941 } 940 }
942 941
@@ -948,7 +947,7 @@ static int efuse_pg_packet_write(struct ieee80211_hw *hw,
948 efuse_word_enable_data_read(word_en, data, target_pkt.data); 947 efuse_word_enable_data_read(word_en, data, target_pkt.data);
949 target_word_cnts = efuse_calculate_word_cnts(target_pkt.word_en); 948 target_word_cnts = efuse_calculate_word_cnts(target_pkt.word_en);
950 949
951 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, ("efuse Power ON\n")); 950 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, "efuse Power ON\n");
952 951
953 while (continual && (efuse_addr < 952 while (continual && (efuse_addr <
954 (EFUSE_MAX_SIZE - EFUSE_OOB_PROTECT_BYTES))) { 953 (EFUSE_MAX_SIZE - EFUSE_OOB_PROTECT_BYTES))) {
@@ -956,7 +955,7 @@ static int efuse_pg_packet_write(struct ieee80211_hw *hw,
956 if (write_state == PG_STATE_HEADER) { 955 if (write_state == PG_STATE_HEADER) {
957 badworden = 0x0F; 956 badworden = 0x0F;
958 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, 957 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG,
959 ("efuse PG_STATE_HEADER\n")); 958 "efuse PG_STATE_HEADER\n");
960 959
961 if (efuse_one_byte_read(hw, efuse_addr, &efuse_data) && 960 if (efuse_one_byte_read(hw, efuse_addr, &efuse_data) &&
962 (efuse_data != 0xFF)) 961 (efuse_data != 0xFF))
@@ -976,7 +975,7 @@ static int efuse_pg_packet_write(struct ieee80211_hw *hw,
976 975
977 } else if (write_state == PG_STATE_DATA) { 976 } else if (write_state == PG_STATE_DATA) {
978 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, 977 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG,
979 ("efuse PG_STATE_DATA\n")); 978 "efuse PG_STATE_DATA\n");
980 badworden = 979 badworden =
981 efuse_word_enable_data_write(hw, efuse_addr + 1, 980 efuse_word_enable_data_write(hw, efuse_addr + 1,
982 target_pkt.word_en, 981 target_pkt.word_en,
@@ -999,14 +998,14 @@ static int efuse_pg_packet_write(struct ieee80211_hw *hw,
999 result = false; 998 result = false;
1000 } 999 }
1001 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, 1000 RTPRINT(rtlpriv, FEEPROM, EFUSE_PG,
1002 ("efuse PG_STATE_HEADER-3\n")); 1001 "efuse PG_STATE_HEADER-3\n");
1003 } 1002 }
1004 } 1003 }
1005 } 1004 }
1006 1005
1007 if (efuse_addr >= (EFUSE_MAX_SIZE - EFUSE_OOB_PROTECT_BYTES)) { 1006 if (efuse_addr >= (EFUSE_MAX_SIZE - EFUSE_OOB_PROTECT_BYTES)) {
1008 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, 1007 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD,
1009 ("efuse_addr(%#x) Out of size!!\n", efuse_addr)); 1008 "efuse_addr(%#x) Out of size!!\n", efuse_addr);
1010 } 1009 }
1011 1010
1012 return true; 1011 return true;
@@ -1046,8 +1045,8 @@ static u8 efuse_word_enable_data_write(struct ieee80211_hw *hw,
1046 u8 tmpdata[8]; 1045 u8 tmpdata[8];
1047 1046
1048 memset(tmpdata, 0xff, PGPKT_DATA_SIZE); 1047 memset(tmpdata, 0xff, PGPKT_DATA_SIZE);
1049 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, 1048 RT_TRACE(rtlpriv, COMP_EFUSE, DBG_LOUD, "word_en = %x efuse_addr=%x\n",
1050 ("word_en = %x efuse_addr=%x\n", word_en, efuse_addr)); 1049 word_en, efuse_addr);
1051 1050
1052 if (!(word_en & BIT(0))) { 1051 if (!(word_en & BIT(0))) {
1053 tmpaddr = start_addr; 1052 tmpaddr = start_addr;
diff --git a/drivers/net/wireless/rtlwifi/efuse.h b/drivers/net/wireless/rtlwifi/efuse.h
index 164dabaa7615..2bdea9a8699e 100644
--- a/drivers/net/wireless/rtlwifi/efuse.h
+++ b/drivers/net/wireless/rtlwifi/efuse.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 39e0907a3c4e..5cb2199435d2 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -27,13 +27,13 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#include <linux/export.h>
31#include "core.h"
32#include "wifi.h" 30#include "wifi.h"
31#include "core.h"
33#include "pci.h" 32#include "pci.h"
34#include "base.h" 33#include "base.h"
35#include "ps.h" 34#include "ps.h"
36#include "efuse.h" 35#include "efuse.h"
36#include <linux/export.h>
37 37
38static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = { 38static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = {
39 PCI_VENDOR_ID_INTEL, 39 PCI_VENDOR_ID_INTEL,
@@ -170,7 +170,7 @@ static void _rtl_pci_update_default_setting(struct ieee80211_hw *hw)
170 break; 170 break;
171 default: 171 default:
172 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 172 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
173 ("switch case not process\n")); 173 "switch case not processed\n");
174 break; 174 break;
175 } 175 }
176 176
@@ -232,7 +232,7 @@ static void rtl_pci_disable_aspm(struct ieee80211_hw *hw)
232 232
233 if (pcibridge_vendor == PCI_BRIDGE_VENDOR_UNKNOWN) { 233 if (pcibridge_vendor == PCI_BRIDGE_VENDOR_UNKNOWN) {
234 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, 234 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
235 ("PCI(Bridge) UNKNOWN.\n")); 235 "PCI(Bridge) UNKNOWN\n");
236 236
237 return; 237 return;
238 } 238 }
@@ -286,7 +286,7 @@ static void rtl_pci_enable_aspm(struct ieee80211_hw *hw)
286 286
287 if (pcibridge_vendor == PCI_BRIDGE_VENDOR_UNKNOWN) { 287 if (pcibridge_vendor == PCI_BRIDGE_VENDOR_UNKNOWN) {
288 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, 288 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
289 ("PCI(Bridge) UNKNOWN.\n")); 289 "PCI(Bridge) UNKNOWN\n");
290 return; 290 return;
291 } 291 }
292 292
@@ -303,11 +303,10 @@ static void rtl_pci_enable_aspm(struct ieee80211_hw *hw)
303 u_pcibridge_aspmsetting); 303 u_pcibridge_aspmsetting);
304 304
305 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 305 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
306 ("PlatformEnableASPM():PciBridge busnumber[%x], " 306 "PlatformEnableASPM():PciBridge busnumber[%x], DevNumbe[%x], funcnumber[%x], Write reg[%x] = %x\n",
307 "DevNumbe[%x], funcnumber[%x], Write reg[%x] = %x\n", 307 pcibridge_busnum, pcibridge_devnum, pcibridge_funcnum,
308 pcibridge_busnum, pcibridge_devnum, pcibridge_funcnum, 308 (pcipriv->ndis_adapter.pcibridge_pciehdr_offset + 0x10),
309 (pcipriv->ndis_adapter.pcibridge_pciehdr_offset + 0x10), 309 u_pcibridge_aspmsetting);
310 u_pcibridge_aspmsetting));
311 310
312 udelay(50); 311 udelay(50);
313 312
@@ -382,9 +381,8 @@ static void rtl_pci_parse_configuration(struct pci_dev *pdev,
382 pci_read_config_byte(pdev, pos + PCI_EXP_LNKCTL, &linkctrl_reg); 381 pci_read_config_byte(pdev, pos + PCI_EXP_LNKCTL, &linkctrl_reg);
383 pcipriv->ndis_adapter.linkctrl_reg = linkctrl_reg; 382 pcipriv->ndis_adapter.linkctrl_reg = linkctrl_reg;
384 383
385 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 384 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Link Control Register =%x\n",
386 ("Link Control Register =%x\n", 385 pcipriv->ndis_adapter.linkctrl_reg);
387 pcipriv->ndis_adapter.linkctrl_reg));
388 386
389 pci_read_config_byte(pdev, 0x98, &tmp); 387 pci_read_config_byte(pdev, 0x98, &tmp);
390 tmp |= BIT(4); 388 tmp |= BIT(4);
@@ -551,11 +549,10 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio)
551 skb_pull(skb, EM_HDR_LEN); 549 skb_pull(skb, EM_HDR_LEN);
552 550
553 RT_TRACE(rtlpriv, (COMP_INTR | COMP_SEND), DBG_TRACE, 551 RT_TRACE(rtlpriv, (COMP_INTR | COMP_SEND), DBG_TRACE,
554 ("new ring->idx:%d, " 552 "new ring->idx:%d, free: skb_queue_len:%d, free: seq:%x\n",
555 "free: skb_queue_len:%d, free: seq:%x\n", 553 ring->idx,
556 ring->idx, 554 skb_queue_len(&ring->queue),
557 skb_queue_len(&ring->queue), 555 *(u16 *) (skb->data + 22));
558 *(u16 *) (skb->data + 22)));
559 556
560 if (prio == TXCMD_QUEUE) { 557 if (prio == TXCMD_QUEUE) {
561 dev_kfree_skb(skb); 558 dev_kfree_skb(skb);
@@ -593,11 +590,9 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio)
593 == 2) { 590 == 2) {
594 591
595 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 592 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
596 ("more desc left, wake" 593 "more desc left, wake skb_queue@%d, ring->idx = %d, skb_queue_len = 0x%d\n",
597 "skb_queue@%d,ring->idx = %d," 594 prio, ring->idx,
598 "skb_queue_len = 0x%d\n", 595 skb_queue_len(&ring->queue));
599 prio, ring->idx,
600 skb_queue_len(&ring->queue)));
601 596
602 ieee80211_wake_queue(hw, 597 ieee80211_wake_queue(hw,
603 skb_get_queue_mapping 598 skb_get_queue_mapping
@@ -657,6 +652,8 @@ static void _rtl_receive_one(struct ieee80211_hw *hw, struct sk_buff *skb,
657 return; 652 return;
658 653
659 uskb = dev_alloc_skb(skb->len + 128); 654 uskb = dev_alloc_skb(skb->len + 128);
655 if (!uskb)
656 return; /* exit if allocation failed */
660 memcpy(IEEE80211_SKB_RXCB(uskb), &rx_status, sizeof(rx_status)); 657 memcpy(IEEE80211_SKB_RXCB(uskb), &rx_status, sizeof(rx_status));
661 pdata = (u8 *)skb_put(uskb, skb->len); 658 pdata = (u8 *)skb_put(uskb, skb->len);
662 memcpy(pdata, skb->data, skb->len); 659 memcpy(pdata, skb->data, skb->len);
@@ -709,9 +706,8 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
709 706
710 new_skb = dev_alloc_skb(rtlpci->rxbuffersize); 707 new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
711 if (unlikely(!new_skb)) { 708 if (unlikely(!new_skb)) {
712 RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV), 709 RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV), DBG_DMESG,
713 DBG_DMESG, 710 "can't alloc skb for rx\n");
714 ("can't alloc skb for rx\n"));
715 goto done; 711 goto done;
716 } 712 }
717 713
@@ -796,38 +792,37 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id)
796 /*<1> beacon related */ 792 /*<1> beacon related */
797 if (inta & rtlpriv->cfg->maps[RTL_IMR_TBDOK]) { 793 if (inta & rtlpriv->cfg->maps[RTL_IMR_TBDOK]) {
798 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 794 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
799 ("beacon ok interrupt!\n")); 795 "beacon ok interrupt!\n");
800 } 796 }
801 797
802 if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_TBDER])) { 798 if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_TBDER])) {
803 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 799 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
804 ("beacon err interrupt!\n")); 800 "beacon err interrupt!\n");
805 } 801 }
806 802
807 if (inta & rtlpriv->cfg->maps[RTL_IMR_BDOK]) { 803 if (inta & rtlpriv->cfg->maps[RTL_IMR_BDOK]) {
808 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 804 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, "beacon interrupt!\n");
809 ("beacon interrupt!\n"));
810 } 805 }
811 806
812 if (inta & rtlpriv->cfg->maps[RTL_IMR_BcnInt]) { 807 if (inta & rtlpriv->cfg->maps[RTL_IMR_BcnInt]) {
813 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 808 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
814 ("prepare beacon for interrupt!\n")); 809 "prepare beacon for interrupt!\n");
815 tasklet_schedule(&rtlpriv->works.irq_prepare_bcn_tasklet); 810 tasklet_schedule(&rtlpriv->works.irq_prepare_bcn_tasklet);
816 } 811 }
817 812
818 /*<3> Tx related */ 813 /*<3> Tx related */
819 if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_TXFOVW])) 814 if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_TXFOVW]))
820 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, ("IMR_TXFOVW!\n")); 815 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, "IMR_TXFOVW!\n");
821 816
822 if (inta & rtlpriv->cfg->maps[RTL_IMR_MGNTDOK]) { 817 if (inta & rtlpriv->cfg->maps[RTL_IMR_MGNTDOK]) {
823 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 818 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
824 ("Manage ok interrupt!\n")); 819 "Manage ok interrupt!\n");
825 _rtl_pci_tx_isr(hw, MGNT_QUEUE); 820 _rtl_pci_tx_isr(hw, MGNT_QUEUE);
826 } 821 }
827 822
828 if (inta & rtlpriv->cfg->maps[RTL_IMR_HIGHDOK]) { 823 if (inta & rtlpriv->cfg->maps[RTL_IMR_HIGHDOK]) {
829 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 824 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
830 ("HIGH_QUEUE ok interrupt!\n")); 825 "HIGH_QUEUE ok interrupt!\n");
831 _rtl_pci_tx_isr(hw, HIGH_QUEUE); 826 _rtl_pci_tx_isr(hw, HIGH_QUEUE);
832 } 827 }
833 828
@@ -835,7 +830,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id)
835 rtlpriv->link_info.num_tx_inperiod++; 830 rtlpriv->link_info.num_tx_inperiod++;
836 831
837 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 832 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
838 ("BK Tx OK interrupt!\n")); 833 "BK Tx OK interrupt!\n");
839 _rtl_pci_tx_isr(hw, BK_QUEUE); 834 _rtl_pci_tx_isr(hw, BK_QUEUE);
840 } 835 }
841 836
@@ -843,7 +838,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id)
843 rtlpriv->link_info.num_tx_inperiod++; 838 rtlpriv->link_info.num_tx_inperiod++;
844 839
845 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 840 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
846 ("BE TX OK interrupt!\n")); 841 "BE TX OK interrupt!\n");
847 _rtl_pci_tx_isr(hw, BE_QUEUE); 842 _rtl_pci_tx_isr(hw, BE_QUEUE);
848 } 843 }
849 844
@@ -851,7 +846,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id)
851 rtlpriv->link_info.num_tx_inperiod++; 846 rtlpriv->link_info.num_tx_inperiod++;
852 847
853 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 848 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
854 ("VI TX OK interrupt!\n")); 849 "VI TX OK interrupt!\n");
855 _rtl_pci_tx_isr(hw, VI_QUEUE); 850 _rtl_pci_tx_isr(hw, VI_QUEUE);
856 } 851 }
857 852
@@ -859,7 +854,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id)
859 rtlpriv->link_info.num_tx_inperiod++; 854 rtlpriv->link_info.num_tx_inperiod++;
860 855
861 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 856 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
862 ("Vo TX OK interrupt!\n")); 857 "Vo TX OK interrupt!\n");
863 _rtl_pci_tx_isr(hw, VO_QUEUE); 858 _rtl_pci_tx_isr(hw, VO_QUEUE);
864 } 859 }
865 860
@@ -868,25 +863,25 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id)
868 rtlpriv->link_info.num_tx_inperiod++; 863 rtlpriv->link_info.num_tx_inperiod++;
869 864
870 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, 865 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE,
871 ("CMD TX OK interrupt!\n")); 866 "CMD TX OK interrupt!\n");
872 _rtl_pci_tx_isr(hw, TXCMD_QUEUE); 867 _rtl_pci_tx_isr(hw, TXCMD_QUEUE);
873 } 868 }
874 } 869 }
875 870
876 /*<2> Rx related */ 871 /*<2> Rx related */
877 if (inta & rtlpriv->cfg->maps[RTL_IMR_ROK]) { 872 if (inta & rtlpriv->cfg->maps[RTL_IMR_ROK]) {
878 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, ("Rx ok interrupt!\n")); 873 RT_TRACE(rtlpriv, COMP_INTR, DBG_TRACE, "Rx ok interrupt!\n");
879 _rtl_pci_rx_interrupt(hw); 874 _rtl_pci_rx_interrupt(hw);
880 } 875 }
881 876
882 if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_RDU])) { 877 if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_RDU])) {
883 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 878 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
884 ("rx descriptor unavailable!\n")); 879 "rx descriptor unavailable!\n");
885 _rtl_pci_rx_interrupt(hw); 880 _rtl_pci_rx_interrupt(hw);
886 } 881 }
887 882
888 if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_RXFOVW])) { 883 if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_RXFOVW])) {
889 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, ("rx overflow !\n")); 884 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, "rx overflow !\n");
890 _rtl_pci_rx_interrupt(hw); 885 _rtl_pci_rx_interrupt(hw);
891 } 886 }
892 887
@@ -1028,7 +1023,7 @@ static int _rtl_pci_init_tx_ring(struct ieee80211_hw *hw,
1028 1023
1029 if (!ring || (unsigned long)ring & 0xFF) { 1024 if (!ring || (unsigned long)ring & 0xFF) {
1030 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1025 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1031 ("Cannot allocate TX ring (prio = %d)\n", prio)); 1026 "Cannot allocate TX ring (prio = %d)\n", prio);
1032 return -ENOMEM; 1027 return -ENOMEM;
1033 } 1028 }
1034 1029
@@ -1039,8 +1034,8 @@ static int _rtl_pci_init_tx_ring(struct ieee80211_hw *hw,
1039 rtlpci->tx_ring[prio].entries = entries; 1034 rtlpci->tx_ring[prio].entries = entries;
1040 skb_queue_head_init(&rtlpci->tx_ring[prio].queue); 1035 skb_queue_head_init(&rtlpci->tx_ring[prio].queue);
1041 1036
1042 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1037 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "queue:%d, ring_addr:%p\n",
1043 ("queue:%d, ring_addr:%p\n", prio, ring)); 1038 prio, ring);
1044 1039
1045 for (i = 0; i < entries; i++) { 1040 for (i = 0; i < entries; i++) {
1046 nextdescaddress = (u32) dma + 1041 nextdescaddress = (u32) dma +
@@ -1078,7 +1073,7 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw)
1078 if (!rtlpci->rx_ring[rx_queue_idx].desc || 1073 if (!rtlpci->rx_ring[rx_queue_idx].desc ||
1079 (unsigned long)rtlpci->rx_ring[rx_queue_idx].desc & 0xFF) { 1074 (unsigned long)rtlpci->rx_ring[rx_queue_idx].desc & 0xFF) {
1080 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1075 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1081 ("Cannot allocate RX ring\n")); 1076 "Cannot allocate RX ring\n");
1082 return -ENOMEM; 1077 return -ENOMEM;
1083 } 1078 }
1084 1079
@@ -1355,7 +1350,7 @@ static int rtl_pci_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
1355 u8 temp_one = 1; 1350 u8 temp_one = 1;
1356 1351
1357 if (ieee80211_is_auth(fc)) { 1352 if (ieee80211_is_auth(fc)) {
1358 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, ("MAC80211_LINKING\n")); 1353 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "MAC80211_LINKING\n");
1359 rtl_ips_nic_on(hw); 1354 rtl_ips_nic_on(hw);
1360 } 1355 }
1361 1356
@@ -1388,10 +1383,9 @@ static int rtl_pci_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
1388 1383
1389 if ((own == 1) && (hw_queue != BEACON_QUEUE)) { 1384 if ((own == 1) && (hw_queue != BEACON_QUEUE)) {
1390 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1385 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1391 ("No more TX desc@%d, ring->idx = %d," 1386 "No more TX desc@%d, ring->idx = %d, idx = %d, skb_queue_len = 0x%d\n",
1392 "idx = %d, skb_queue_len = 0x%d\n", 1387 hw_queue, ring->idx, idx,
1393 hw_queue, ring->idx, idx, 1388 skb_queue_len(&ring->queue));
1394 skb_queue_len(&ring->queue)));
1395 1389
1396 spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); 1390 spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags);
1397 return skb->len; 1391 return skb->len;
@@ -1426,11 +1420,9 @@ static int rtl_pci_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
1426 hw_queue != BEACON_QUEUE) { 1420 hw_queue != BEACON_QUEUE) {
1427 1421
1428 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 1422 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
1429 ("less desc left, stop skb_queue@%d, " 1423 "less desc left, stop skb_queue@%d, ring->idx = %d, idx = %d, skb_queue_len = 0x%d\n",
1430 "ring->idx = %d," 1424 hw_queue, ring->idx, idx,
1431 "idx = %d, skb_queue_len = 0x%d\n", 1425 skb_queue_len(&ring->queue));
1432 hw_queue, ring->idx, idx,
1433 skb_queue_len(&ring->queue)));
1434 1426
1435 ieee80211_stop_queue(hw, skb_get_queue_mapping(skb)); 1427 ieee80211_stop_queue(hw, skb_get_queue_mapping(skb));
1436 } 1428 }
@@ -1497,7 +1489,7 @@ static int rtl_pci_init(struct ieee80211_hw *hw, struct pci_dev *pdev)
1497 err = _rtl_pci_init_trx_ring(hw); 1489 err = _rtl_pci_init_trx_ring(hw);
1498 if (err) { 1490 if (err) {
1499 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1491 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1500 ("tx ring initialization failed")); 1492 "tx ring initialization failed\n");
1501 return err; 1493 return err;
1502 } 1494 }
1503 1495
@@ -1519,12 +1511,12 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
1519 err = rtlpriv->cfg->ops->hw_init(hw); 1511 err = rtlpriv->cfg->ops->hw_init(hw);
1520 if (err) { 1512 if (err) {
1521 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1513 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1522 ("Failed to config hardware!\n")); 1514 "Failed to config hardware!\n");
1523 return err; 1515 return err;
1524 } 1516 }
1525 1517
1526 rtlpriv->cfg->ops->enable_interrupt(hw); 1518 rtlpriv->cfg->ops->enable_interrupt(hw);
1527 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("enable_interrupt OK\n")); 1519 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "enable_interrupt OK\n");
1528 1520
1529 rtl_init_rx_config(hw); 1521 rtl_init_rx_config(hw);
1530 1522
@@ -1535,7 +1527,7 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
1535 1527
1536 rtlpci->up_first_time = false; 1528 rtlpci->up_first_time = false;
1537 1529
1538 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("OK\n")); 1530 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "OK\n");
1539 return 0; 1531 return 0;
1540} 1532}
1541 1533
@@ -1573,6 +1565,9 @@ static void rtl_pci_stop(struct ieee80211_hw *hw)
1573 1565
1574 rtlpci->driver_is_goingto_unload = true; 1566 rtlpci->driver_is_goingto_unload = true;
1575 rtlpriv->cfg->ops->hw_disable(hw); 1567 rtlpriv->cfg->ops->hw_disable(hw);
1568 /* some things are not needed if firmware not available */
1569 if (!rtlpriv->max_fw_size)
1570 return;
1576 rtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_OFF); 1571 rtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_OFF);
1577 1572
1578 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags); 1573 spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags);
@@ -1622,20 +1617,20 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
1622 switch (revisionid) { 1617 switch (revisionid) {
1623 case RTL_PCI_REVISION_ID_8192PCIE: 1618 case RTL_PCI_REVISION_ID_8192PCIE:
1624 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1619 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1625 ("8192 PCI-E is found - " 1620 "8192 PCI-E is found - vid/did=%x/%x\n",
1626 "vid/did=%x/%x\n", venderid, deviceid)); 1621 venderid, deviceid);
1627 rtlhal->hw_type = HARDWARE_TYPE_RTL8192E; 1622 rtlhal->hw_type = HARDWARE_TYPE_RTL8192E;
1628 break; 1623 break;
1629 case RTL_PCI_REVISION_ID_8192SE: 1624 case RTL_PCI_REVISION_ID_8192SE:
1630 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1625 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1631 ("8192SE is found - " 1626 "8192SE is found - vid/did=%x/%x\n",
1632 "vid/did=%x/%x\n", venderid, deviceid)); 1627 venderid, deviceid);
1633 rtlhal->hw_type = HARDWARE_TYPE_RTL8192SE; 1628 rtlhal->hw_type = HARDWARE_TYPE_RTL8192SE;
1634 break; 1629 break;
1635 default: 1630 default:
1636 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1631 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1637 ("Err: Unknown device - " 1632 "Err: Unknown device - vid/did=%x/%x\n",
1638 "vid/did=%x/%x\n", venderid, deviceid)); 1633 venderid, deviceid);
1639 rtlhal->hw_type = HARDWARE_TYPE_RTL8192SE; 1634 rtlhal->hw_type = HARDWARE_TYPE_RTL8192SE;
1640 break; 1635 break;
1641 1636
@@ -1646,18 +1641,18 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
1646 deviceid == RTL_PCI_8188CE_DID) { 1641 deviceid == RTL_PCI_8188CE_DID) {
1647 rtlhal->hw_type = HARDWARE_TYPE_RTL8192CE; 1642 rtlhal->hw_type = HARDWARE_TYPE_RTL8192CE;
1648 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1643 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1649 ("8192C PCI-E is found - " 1644 "8192C PCI-E is found - vid/did=%x/%x\n",
1650 "vid/did=%x/%x\n", venderid, deviceid)); 1645 venderid, deviceid);
1651 } else if (deviceid == RTL_PCI_8192DE_DID || 1646 } else if (deviceid == RTL_PCI_8192DE_DID ||
1652 deviceid == RTL_PCI_8192DE_DID2) { 1647 deviceid == RTL_PCI_8192DE_DID2) {
1653 rtlhal->hw_type = HARDWARE_TYPE_RTL8192DE; 1648 rtlhal->hw_type = HARDWARE_TYPE_RTL8192DE;
1654 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1649 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1655 ("8192D PCI-E is found - " 1650 "8192D PCI-E is found - vid/did=%x/%x\n",
1656 "vid/did=%x/%x\n", venderid, deviceid)); 1651 venderid, deviceid);
1657 } else { 1652 } else {
1658 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1653 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1659 ("Err: Unknown device -" 1654 "Err: Unknown device - vid/did=%x/%x\n",
1660 " vid/did=%x/%x\n", venderid, deviceid)); 1655 venderid, deviceid);
1661 1656
1662 rtlhal->hw_type = RTL_DEFAULT_HARDWARE_TYPE; 1657 rtlhal->hw_type = RTL_DEFAULT_HARDWARE_TYPE;
1663 } 1658 }
@@ -1665,19 +1660,18 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
1665 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE) { 1660 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE) {
1666 if (revisionid == 0 || revisionid == 1) { 1661 if (revisionid == 0 || revisionid == 1) {
1667 if (revisionid == 0) { 1662 if (revisionid == 0) {
1668 RT_TRACE(rtlpriv, COMP_INIT, 1663 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1669 DBG_LOUD, ("Find 92DE MAC0.\n")); 1664 "Find 92DE MAC0\n");
1670 rtlhal->interfaceindex = 0; 1665 rtlhal->interfaceindex = 0;
1671 } else if (revisionid == 1) { 1666 } else if (revisionid == 1) {
1672 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1667 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1673 ("Find 92DE MAC1.\n")); 1668 "Find 92DE MAC1\n");
1674 rtlhal->interfaceindex = 1; 1669 rtlhal->interfaceindex = 1;
1675 } 1670 }
1676 } else { 1671 } else {
1677 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1672 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1678 ("Unknown device - " 1673 "Unknown device - VendorID/DeviceID=%x/%x, Revision=%x\n",
1679 "VendorID/DeviceID=%x/%x, Revision=%x\n", 1674 venderid, deviceid, revisionid);
1680 venderid, deviceid, revisionid));
1681 rtlhal->interfaceindex = 0; 1675 rtlhal->interfaceindex = 0;
1682 } 1676 }
1683 } 1677 }
@@ -1693,8 +1687,8 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
1693 if (bridge_pdev->vendor == pcibridge_vendors[tmp]) { 1687 if (bridge_pdev->vendor == pcibridge_vendors[tmp]) {
1694 pcipriv->ndis_adapter.pcibridge_vendor = tmp; 1688 pcipriv->ndis_adapter.pcibridge_vendor = tmp;
1695 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1689 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1696 ("Pci Bridge Vendor is found index:" 1690 "Pci Bridge Vendor is found index: %d\n",
1697 " %d\n", tmp)); 1691 tmp);
1698 break; 1692 break;
1699 } 1693 }
1700 } 1694 }
@@ -1723,23 +1717,21 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
1723 } 1717 }
1724 1718
1725 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1719 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1726 ("pcidev busnumber:devnumber:funcnumber:" 1720 "pcidev busnumber:devnumber:funcnumber:vendor:link_ctl %d:%d:%d:%x:%x\n",
1727 "vendor:link_ctl %d:%d:%d:%x:%x\n", 1721 pcipriv->ndis_adapter.busnumber,
1728 pcipriv->ndis_adapter.busnumber, 1722 pcipriv->ndis_adapter.devnumber,
1729 pcipriv->ndis_adapter.devnumber, 1723 pcipriv->ndis_adapter.funcnumber,
1730 pcipriv->ndis_adapter.funcnumber, 1724 pdev->vendor, pcipriv->ndis_adapter.linkctrl_reg);
1731 pdev->vendor, pcipriv->ndis_adapter.linkctrl_reg));
1732 1725
1733 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1726 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1734 ("pci_bridge busnumber:devnumber:funcnumber:vendor:" 1727 "pci_bridge busnumber:devnumber:funcnumber:vendor:pcie_cap:link_ctl_reg:amd %d:%d:%d:%x:%x:%x:%x\n",
1735 "pcie_cap:link_ctl_reg:amd %d:%d:%d:%x:%x:%x:%x\n", 1728 pcipriv->ndis_adapter.pcibridge_busnum,
1736 pcipriv->ndis_adapter.pcibridge_busnum, 1729 pcipriv->ndis_adapter.pcibridge_devnum,
1737 pcipriv->ndis_adapter.pcibridge_devnum, 1730 pcipriv->ndis_adapter.pcibridge_funcnum,
1738 pcipriv->ndis_adapter.pcibridge_funcnum, 1731 pcibridge_vendors[pcipriv->ndis_adapter.pcibridge_vendor],
1739 pcibridge_vendors[pcipriv->ndis_adapter.pcibridge_vendor], 1732 pcipriv->ndis_adapter.pcibridge_pciehdr_offset,
1740 pcipriv->ndis_adapter.pcibridge_pciehdr_offset, 1733 pcipriv->ndis_adapter.pcibridge_linkctrlreg,
1741 pcipriv->ndis_adapter.pcibridge_linkctrlreg, 1734 pcipriv->ndis_adapter.amd_l1_patch);
1742 pcipriv->ndis_adapter.amd_l1_patch));
1743 1735
1744 rtl_pci_parse_configuration(pdev, hw); 1736 rtl_pci_parse_configuration(pdev, hw);
1745 1737
@@ -1759,16 +1751,15 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
1759 1751
1760 err = pci_enable_device(pdev); 1752 err = pci_enable_device(pdev);
1761 if (err) { 1753 if (err) {
1762 RT_ASSERT(false, 1754 RT_ASSERT(false, "%s : Cannot enable new PCI device\n",
1763 ("%s : Cannot enable new PCI device\n", 1755 pci_name(pdev));
1764 pci_name(pdev)));
1765 return err; 1756 return err;
1766 } 1757 }
1767 1758
1768 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { 1759 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
1769 if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { 1760 if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
1770 RT_ASSERT(false, ("Unable to obtain 32bit DMA " 1761 RT_ASSERT(false,
1771 "for consistent allocations\n")); 1762 "Unable to obtain 32bit DMA for consistent allocations\n");
1772 pci_disable_device(pdev); 1763 pci_disable_device(pdev);
1773 return -ENOMEM; 1764 return -ENOMEM;
1774 } 1765 }
@@ -1780,7 +1771,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
1780 sizeof(struct rtl_priv), &rtl_ops); 1771 sizeof(struct rtl_priv), &rtl_ops);
1781 if (!hw) { 1772 if (!hw) {
1782 RT_ASSERT(false, 1773 RT_ASSERT(false,
1783 ("%s : ieee80211 alloc failed\n", pci_name(pdev))); 1774 "%s : ieee80211 alloc failed\n", pci_name(pdev));
1784 err = -ENOMEM; 1775 err = -ENOMEM;
1785 goto fail1; 1776 goto fail1;
1786 } 1777 }
@@ -1791,6 +1782,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
1791 rtlpriv = hw->priv; 1782 rtlpriv = hw->priv;
1792 pcipriv = (void *)rtlpriv->priv; 1783 pcipriv = (void *)rtlpriv->priv;
1793 pcipriv->dev.pdev = pdev; 1784 pcipriv->dev.pdev = pdev;
1785 init_completion(&rtlpriv->firmware_loading_complete);
1794 1786
1795 /* init cfg & intf_ops */ 1787 /* init cfg & intf_ops */
1796 rtlpriv->rtlhal.interface = INTF_PCI; 1788 rtlpriv->rtlhal.interface = INTF_PCI;
@@ -1810,8 +1802,8 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
1810 /* MEM map */ 1802 /* MEM map */
1811 err = pci_request_regions(pdev, KBUILD_MODNAME); 1803 err = pci_request_regions(pdev, KBUILD_MODNAME);
1812 if (err) { 1804 if (err) {
1813 RT_ASSERT(false, ("Can't obtain PCI resources\n")); 1805 RT_ASSERT(false, "Can't obtain PCI resources\n");
1814 return err; 1806 goto fail2;
1815 } 1807 }
1816 1808
1817 pmem_start = pci_resource_start(pdev, rtlpriv->cfg->bar_id); 1809 pmem_start = pci_resource_start(pdev, rtlpriv->cfg->bar_id);
@@ -1823,15 +1815,14 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
1823 (unsigned long)pci_iomap(pdev, 1815 (unsigned long)pci_iomap(pdev,
1824 rtlpriv->cfg->bar_id, pmem_len); 1816 rtlpriv->cfg->bar_id, pmem_len);
1825 if (rtlpriv->io.pci_mem_start == 0) { 1817 if (rtlpriv->io.pci_mem_start == 0) {
1826 RT_ASSERT(false, ("Can't map PCI mem\n")); 1818 RT_ASSERT(false, "Can't map PCI mem\n");
1827 goto fail2; 1819 goto fail2;
1828 } 1820 }
1829 1821
1830 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1822 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1831 ("mem mapped space: start: 0x%08lx len:%08lx " 1823 "mem mapped space: start: 0x%08lx len:%08lx flags:%08lx, after map:0x%08lx\n",
1832 "flags:%08lx, after map:0x%08lx\n", 1824 pmem_start, pmem_len, pmem_flags,
1833 pmem_start, pmem_len, pmem_flags, 1825 rtlpriv->io.pci_mem_start);
1834 rtlpriv->io.pci_mem_start));
1835 1826
1836 /* Disable Clk Request */ 1827 /* Disable Clk Request */
1837 pci_write_config_byte(pdev, 0x81, 0); 1828 pci_write_config_byte(pdev, 0x81, 0);
@@ -1851,8 +1842,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
1851 rtlpriv->cfg->ops->read_eeprom_info(hw); 1842 rtlpriv->cfg->ops->read_eeprom_info(hw);
1852 1843
1853 if (rtlpriv->cfg->ops->init_sw_vars(hw)) { 1844 if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
1854 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1845 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't init_sw_vars\n");
1855 ("Can't init_sw_vars.\n"));
1856 goto fail3; 1846 goto fail3;
1857 } 1847 }
1858 1848
@@ -1865,63 +1855,48 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
1865 err = rtl_init_core(hw); 1855 err = rtl_init_core(hw);
1866 if (err) { 1856 if (err) {
1867 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1857 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1868 ("Can't allocate sw for mac80211.\n")); 1858 "Can't allocate sw for mac80211\n");
1869 goto fail3; 1859 goto fail3;
1870 } 1860 }
1871 1861
1872 /* Init PCI sw */ 1862 /* Init PCI sw */
1873 err = !rtl_pci_init(hw, pdev); 1863 err = !rtl_pci_init(hw, pdev);
1874 if (err) { 1864 if (err) {
1875 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1865 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Failed to init PCI\n");
1876 ("Failed to init PCI.\n"));
1877 goto fail3; 1866 goto fail3;
1878 } 1867 }
1879 1868
1880 err = ieee80211_register_hw(hw);
1881 if (err) {
1882 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1883 ("Can't register mac80211 hw.\n"));
1884 goto fail3;
1885 } else {
1886 rtlpriv->mac80211.mac80211_registered = 1;
1887 }
1888
1889 err = sysfs_create_group(&pdev->dev.kobj, &rtl_attribute_group); 1869 err = sysfs_create_group(&pdev->dev.kobj, &rtl_attribute_group);
1890 if (err) { 1870 if (err) {
1891 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1871 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1892 ("failed to create sysfs device attributes\n")); 1872 "failed to create sysfs device attributes\n");
1893 goto fail3; 1873 goto fail3;
1894 } 1874 }
1895 1875
1896 /*init rfkill */
1897 rtl_init_rfkill(hw);
1898
1899 rtlpci = rtl_pcidev(pcipriv); 1876 rtlpci = rtl_pcidev(pcipriv);
1900 err = request_irq(rtlpci->pdev->irq, &_rtl_pci_interrupt, 1877 err = request_irq(rtlpci->pdev->irq, &_rtl_pci_interrupt,
1901 IRQF_SHARED, KBUILD_MODNAME, hw); 1878 IRQF_SHARED, KBUILD_MODNAME, hw);
1902 if (err) { 1879 if (err) {
1903 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1880 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1904 ("%s: failed to register IRQ handler\n", 1881 "%s: failed to register IRQ handler\n",
1905 wiphy_name(hw->wiphy))); 1882 wiphy_name(hw->wiphy));
1906 goto fail3; 1883 goto fail3;
1907 } else {
1908 rtlpci->irq_alloc = 1;
1909 } 1884 }
1885 rtlpci->irq_alloc = 1;
1910 1886
1911 set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
1912 return 0; 1887 return 0;
1913 1888
1914fail3: 1889fail3:
1915 pci_set_drvdata(pdev, NULL); 1890 pci_set_drvdata(pdev, NULL);
1916 rtl_deinit_core(hw); 1891 rtl_deinit_core(hw);
1917 _rtl_pci_io_handler_release(hw); 1892 _rtl_pci_io_handler_release(hw);
1918 ieee80211_free_hw(hw);
1919 1893
1920 if (rtlpriv->io.pci_mem_start != 0) 1894 if (rtlpriv->io.pci_mem_start != 0)
1921 pci_iounmap(pdev, (void __iomem *)rtlpriv->io.pci_mem_start); 1895 pci_iounmap(pdev, (void __iomem *)rtlpriv->io.pci_mem_start);
1922 1896
1923fail2: 1897fail2:
1924 pci_release_regions(pdev); 1898 pci_release_regions(pdev);
1899 complete(&rtlpriv->firmware_loading_complete);
1925 1900
1926fail1: 1901fail1:
1927 1902
@@ -1940,6 +1915,8 @@ void rtl_pci_disconnect(struct pci_dev *pdev)
1940 struct rtl_pci *rtlpci = rtl_pcidev(pcipriv); 1915 struct rtl_pci *rtlpci = rtl_pcidev(pcipriv);
1941 struct rtl_mac *rtlmac = rtl_mac(rtlpriv); 1916 struct rtl_mac *rtlmac = rtl_mac(rtlpriv);
1942 1917
1918 /* just in case driver is removed before firmware callback */
1919 wait_for_completion(&rtlpriv->firmware_loading_complete);
1943 clear_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status); 1920 clear_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
1944 1921
1945 sysfs_remove_group(&pdev->dev.kobj, &rtl_attribute_group); 1922 sysfs_remove_group(&pdev->dev.kobj, &rtl_attribute_group);
diff --git a/drivers/net/wireless/rtlwifi/pci.h b/drivers/net/wireless/rtlwifi/pci.h
index ebe0b42c0518..241448fc9ed5 100644
--- a/drivers/net/wireless/rtlwifi/pci.h
+++ b/drivers/net/wireless/rtlwifi/pci.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -239,7 +239,6 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
239void rtl_pci_disconnect(struct pci_dev *pdev); 239void rtl_pci_disconnect(struct pci_dev *pdev);
240int rtl_pci_suspend(struct device *dev); 240int rtl_pci_suspend(struct device *dev);
241int rtl_pci_resume(struct device *dev); 241int rtl_pci_resume(struct device *dev);
242
243static inline u8 pci_read8_sync(struct rtl_priv *rtlpriv, u32 addr) 242static inline u8 pci_read8_sync(struct rtl_priv *rtlpriv, u32 addr)
244{ 243{
245 return readb((u8 __iomem *) rtlpriv->io.pci_mem_start + addr); 244 return readb((u8 __iomem *) rtlpriv->io.pci_mem_start + addr);
diff --git a/drivers/net/wireless/rtlwifi/ps.c b/drivers/net/wireless/rtlwifi/ps.c
index 130fdd99d573..15f86eaa1cd6 100644
--- a/drivers/net/wireless/rtlwifi/ps.c
+++ b/drivers/net/wireless/rtlwifi/ps.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -44,10 +44,11 @@ bool rtl_ps_enable_nic(struct ieee80211_hw *hw)
44 44
45 if (is_hal_stop(rtlhal)) 45 if (is_hal_stop(rtlhal))
46 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 46 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
47 ("Driver is already down!\n")); 47 "Driver is already down!\n");
48 48
49 /*<2> Enable Adapter */ 49 /*<2> Enable Adapter */
50 rtlpriv->cfg->ops->hw_init(hw); 50 if (rtlpriv->cfg->ops->hw_init(hw))
51 return 1;
51 RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); 52 RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
52 53
53 /*<3> Enable Interrupt */ 54 /*<3> Enable Interrupt */
@@ -120,7 +121,7 @@ bool rtl_ps_set_rf_state(struct ieee80211_hw *hw,
120 121
121 default: 122 default:
122 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 123 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
123 ("switch case not process\n")); 124 "switch case not processed\n");
124 break; 125 break;
125 } 126 }
126 127
@@ -176,7 +177,7 @@ void rtl_ips_nic_off_wq_callback(void *data)
176 177
177 if (mac->opmode != NL80211_IFTYPE_STATION) { 178 if (mac->opmode != NL80211_IFTYPE_STATION) {
178 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 179 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
179 ("not station return\n")); 180 "not station return\n");
180 return; 181 return;
181 } 182 }
182 183
@@ -207,7 +208,7 @@ void rtl_ips_nic_off_wq_callback(void *data)
207 (mac->link_state == MAC80211_NOLINK) && 208 (mac->link_state == MAC80211_NOLINK) &&
208 !mac->act_scanning) { 209 !mac->act_scanning) {
209 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, 210 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
210 ("IPSEnter(): Turn off RF.\n")); 211 "IPSEnter(): Turn off RF\n");
211 212
212 ppsc->inactive_pwrstate = ERFOFF; 213 ppsc->inactive_pwrstate = ERFOFF;
213 ppsc->in_powersavemode = true; 214 ppsc->in_powersavemode = true;
@@ -280,8 +281,7 @@ static bool rtl_get_fwlps_doze(struct ieee80211_hw *hw)
280 281
281 if (ps_timediff < 2000) { 282 if (ps_timediff < 2000) {
282 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 283 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
283 ("Delay enter Fw LPS for DHCP, ARP," 284 "Delay enter Fw LPS for DHCP, ARP, or EAPOL exchanging state\n");
284 " or EAPOL exchanging state.\n"));
285 return false; 285 return false;
286 } 286 }
287 287
@@ -328,8 +328,8 @@ static void rtl_lps_set_psmode(struct ieee80211_hw *hw, u8 rt_psmode)
328 bool fw_current_inps; 328 bool fw_current_inps;
329 if (ppsc->dot11_psmode == EACTIVE) { 329 if (ppsc->dot11_psmode == EACTIVE) {
330 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 330 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
331 ("FW LPS leave ps_mode:%x\n", 331 "FW LPS leave ps_mode:%x\n",
332 FW_PS_ACTIVE_MODE)); 332 FW_PS_ACTIVE_MODE);
333 333
334 rpwm_val = 0x0C; /* RF on */ 334 rpwm_val = 0x0C; /* RF on */
335 fw_pwrmode = FW_PS_ACTIVE_MODE; 335 fw_pwrmode = FW_PS_ACTIVE_MODE;
@@ -347,8 +347,8 @@ static void rtl_lps_set_psmode(struct ieee80211_hw *hw, u8 rt_psmode)
347 } else { 347 } else {
348 if (rtl_get_fwlps_doze(hw)) { 348 if (rtl_get_fwlps_doze(hw)) {
349 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 349 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
350 ("FW LPS enter ps_mode:%x\n", 350 "FW LPS enter ps_mode:%x\n",
351 ppsc->fwctrl_psmode)); 351 ppsc->fwctrl_psmode);
352 352
353 rpwm_val = 0x02; /* RF off */ 353 rpwm_val = 0x02; /* RF off */
354 fw_current_inps = true; 354 fw_current_inps = true;
@@ -402,7 +402,7 @@ void rtl_lps_enter(struct ieee80211_hw *hw)
402 if (mac->cnt_after_linked >= 2) { 402 if (mac->cnt_after_linked >= 2) {
403 if (ppsc->dot11_psmode == EACTIVE) { 403 if (ppsc->dot11_psmode == EACTIVE) {
404 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 404 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
405 ("Enter 802.11 power save mode...\n")); 405 "Enter 802.11 power save mode...\n");
406 406
407 rtl_lps_set_psmode(hw, EAUTOPS); 407 rtl_lps_set_psmode(hw, EAUTOPS);
408 } 408 }
@@ -434,7 +434,7 @@ void rtl_lps_leave(struct ieee80211_hw *hw)
434 } 434 }
435 435
436 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 436 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
437 ("Busy Traffic,Leave 802.11 power save..\n")); 437 "Busy Traffic,Leave 802.11 power save..\n");
438 438
439 rtl_lps_set_psmode(hw, EACTIVE); 439 rtl_lps_set_psmode(hw, EACTIVE);
440 } 440 }
@@ -518,8 +518,8 @@ void rtl_swlps_beacon(struct ieee80211_hw *hw, void *data, unsigned int len)
518 queue_delayed_work(rtlpriv->works.rtl_wq, 518 queue_delayed_work(rtlpriv->works.rtl_wq,
519 &rtlpriv->works.ps_work, MSECS(5)); 519 &rtlpriv->works.ps_work, MSECS(5));
520 } else { 520 } else {
521 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, ("u_bufferd: %x, " 521 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
522 "m_buffered: %x\n", u_buffed, m_buffed)); 522 "u_bufferd: %x, m_buffered: %x\n", u_buffed, m_buffed);
523 } 523 }
524} 524}
525 525
@@ -607,8 +607,8 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw)
607 * sleep = dtim_period, that meaons, we should 607 * sleep = dtim_period, that meaons, we should
608 * awake before every dtim */ 608 * awake before every dtim */
609 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, 609 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
610 ("dtim_counter:%x will sleep :%d" 610 "dtim_counter:%x will sleep :%d beacon_intv\n",
611 " beacon_intv\n", rtlpriv->psc.dtim_counter, sleep_intv)); 611 rtlpriv->psc.dtim_counter, sleep_intv);
612 612
613 /* we tested that 40ms is enough for sw & hw sw delay */ 613 /* we tested that 40ms is enough for sw & hw sw delay */
614 queue_delayed_work(rtlpriv->works.rtl_wq, &rtlpriv->works.ps_rfon_wq, 614 queue_delayed_work(rtlpriv->works.rtl_wq, &rtlpriv->works.ps_rfon_wq,
diff --git a/drivers/net/wireless/rtlwifi/ps.h b/drivers/net/wireless/rtlwifi/ps.h
index 84628e6041c7..1357856998c2 100644
--- a/drivers/net/wireless/rtlwifi/ps.h
+++ b/drivers/net/wireless/rtlwifi/ps.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rc.c b/drivers/net/wireless/rtlwifi/rc.c
index 539df66dce0a..c66f08a0524a 100644
--- a/drivers/net/wireless/rtlwifi/rc.c
+++ b/drivers/net/wireless/rtlwifi/rc.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -251,7 +251,7 @@ static void *rtl_rate_alloc_sta(void *ppriv,
251 rate_priv = kzalloc(sizeof(struct rtl_rate_priv), gfp); 251 rate_priv = kzalloc(sizeof(struct rtl_rate_priv), gfp);
252 if (!rate_priv) { 252 if (!rate_priv) {
253 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 253 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
254 ("Unable to allocate private rc structure\n")); 254 "Unable to allocate private rc structure\n");
255 return NULL; 255 return NULL;
256 } 256 }
257 257
diff --git a/drivers/net/wireless/rtlwifi/rc.h b/drivers/net/wireless/rtlwifi/rc.h
index 4afa2c20adcf..4d6176160610 100644
--- a/drivers/net/wireless/rtlwifi/rc.h
+++ b/drivers/net/wireless/rtlwifi/rc.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/regd.c b/drivers/net/wireless/rtlwifi/regd.c
index 9fedb1f70919..c1608cddc529 100644
--- a/drivers/net/wireless/rtlwifi/regd.c
+++ b/drivers/net/wireless/rtlwifi/regd.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -398,13 +398,11 @@ int rtl_regd_init(struct ieee80211_hw *hw,
398 rtlpriv->regd.country_code = rtlpriv->efuse.channel_plan; 398 rtlpriv->regd.country_code = rtlpriv->efuse.channel_plan;
399 399
400 RT_TRACE(rtlpriv, COMP_REGD, DBG_TRACE, 400 RT_TRACE(rtlpriv, COMP_REGD, DBG_TRACE,
401 (KERN_DEBUG "rtl: EEPROM regdomain: 0x%0x\n", 401 "rtl: EEPROM regdomain: 0x%0x\n", rtlpriv->regd.country_code);
402 rtlpriv->regd.country_code));
403 402
404 if (rtlpriv->regd.country_code >= COUNTRY_CODE_MAX) { 403 if (rtlpriv->regd.country_code >= COUNTRY_CODE_MAX) {
405 RT_TRACE(rtlpriv, COMP_REGD, DBG_DMESG, 404 RT_TRACE(rtlpriv, COMP_REGD, DBG_DMESG,
406 (KERN_DEBUG "rtl: EEPROM indicates invalid contry code" 405 "rtl: EEPROM indicates invalid contry code, world wide 13 should be used\n");
407 "world wide 13 should be used\n"));
408 406
409 rtlpriv->regd.country_code = COUNTRY_CODE_WORLD_WIDE_13; 407 rtlpriv->regd.country_code = COUNTRY_CODE_WORLD_WIDE_13;
410 } 408 }
@@ -420,8 +418,8 @@ int rtl_regd_init(struct ieee80211_hw *hw,
420 } 418 }
421 419
422 RT_TRACE(rtlpriv, COMP_REGD, DBG_TRACE, 420 RT_TRACE(rtlpriv, COMP_REGD, DBG_TRACE,
423 (KERN_DEBUG "rtl: Country alpha2 being used: %c%c\n", 421 "rtl: Country alpha2 being used: %c%c\n",
424 rtlpriv->regd.alpha2[0], rtlpriv->regd.alpha2[1])); 422 rtlpriv->regd.alpha2[0], rtlpriv->regd.alpha2[1]);
425 423
426 _rtl_regd_init_wiphy(&rtlpriv->regd, wiphy, reg_notifier); 424 _rtl_regd_init_wiphy(&rtlpriv->regd, wiphy, reg_notifier);
427 425
@@ -433,7 +431,7 @@ int rtl_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request)
433 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); 431 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
434 struct rtl_priv *rtlpriv = rtl_priv(hw); 432 struct rtl_priv *rtlpriv = rtl_priv(hw);
435 433
436 RT_TRACE(rtlpriv, COMP_REGD, DBG_LOUD, ("\n")); 434 RT_TRACE(rtlpriv, COMP_REGD, DBG_LOUD, "\n");
437 435
438 return _rtl_reg_notifier_apply(wiphy, request, &rtlpriv->regd); 436 return _rtl_reg_notifier_apply(wiphy, request, &rtlpriv->regd);
439} 437}
diff --git a/drivers/net/wireless/rtlwifi/regd.h b/drivers/net/wireless/rtlwifi/regd.h
index d23118938fac..70ef2f418a44 100644
--- a/drivers/net/wireless/rtlwifi/regd.h
+++ b/drivers/net/wireless/rtlwifi/regd.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
index 72a98cab6f69..cb5535cf3ae2 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -246,16 +246,15 @@ static void rtl92c_dm_false_alarm_counter_statistics(struct ieee80211_hw *hw)
246 rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 2); 246 rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 2);
247 247
248 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, 248 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
249 ("cnt_parity_fail = %d, cnt_rate_illegal = %d, " 249 "cnt_parity_fail = %d, cnt_rate_illegal = %d, cnt_crc8_fail = %d, cnt_mcs_fail = %d\n",
250 "cnt_crc8_fail = %d, cnt_mcs_fail = %d\n", 250 falsealm_cnt->cnt_parity_fail,
251 falsealm_cnt->cnt_parity_fail, 251 falsealm_cnt->cnt_rate_illegal,
252 falsealm_cnt->cnt_rate_illegal, 252 falsealm_cnt->cnt_crc8_fail, falsealm_cnt->cnt_mcs_fail);
253 falsealm_cnt->cnt_crc8_fail, falsealm_cnt->cnt_mcs_fail));
254 253
255 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, 254 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
256 ("cnt_ofdm_fail = %x, cnt_cck_fail = %x, cnt_all = %x\n", 255 "cnt_ofdm_fail = %x, cnt_cck_fail = %x, cnt_all = %x\n",
257 falsealm_cnt->cnt_ofdm_fail, 256 falsealm_cnt->cnt_ofdm_fail,
258 falsealm_cnt->cnt_cck_fail, falsealm_cnt->cnt_all)); 257 falsealm_cnt->cnt_cck_fail, falsealm_cnt->cnt_all);
259} 258}
260 259
261static void rtl92c_dm_ctrl_initgain_by_fa(struct ieee80211_hw *hw) 260static void rtl92c_dm_ctrl_initgain_by_fa(struct ieee80211_hw *hw)
@@ -313,8 +312,8 @@ static void rtl92c_dm_ctrl_initgain_by_rssi(struct ieee80211_hw *hw)
313 dm_digtable.backoff_val; 312 dm_digtable.backoff_val;
314 313
315 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, 314 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
316 ("rssi_val_min = %x backoff_val %x\n", 315 "rssi_val_min = %x backoff_val %x\n",
317 dm_digtable.rssi_val_min, dm_digtable.backoff_val)); 316 dm_digtable.rssi_val_min, dm_digtable.backoff_val);
318 317
319 rtl92c_dm_write_dig(hw); 318 rtl92c_dm_write_dig(hw);
320} 319}
@@ -364,10 +363,9 @@ static void rtl92c_dm_initial_gain_multi_sta(struct ieee80211_hw *hw)
364 } 363 }
365 364
366 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, 365 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
367 ("curmultista_connectstate = " 366 "curmultista_connectstate = %x dig_ext_port_stage %x\n",
368 "%x dig_ext_port_stage %x\n", 367 dm_digtable.curmultista_connectstate,
369 dm_digtable.curmultista_connectstate, 368 dm_digtable.dig_ext_port_stage);
370 dm_digtable.dig_ext_port_stage));
371} 369}
372 370
373static void rtl92c_dm_initial_gain_sta(struct ieee80211_hw *hw) 371static void rtl92c_dm_initial_gain_sta(struct ieee80211_hw *hw)
@@ -375,10 +373,9 @@ static void rtl92c_dm_initial_gain_sta(struct ieee80211_hw *hw)
375 struct rtl_priv *rtlpriv = rtl_priv(hw); 373 struct rtl_priv *rtlpriv = rtl_priv(hw);
376 374
377 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, 375 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
378 ("presta_connectstate = %x," 376 "presta_connectstate = %x, cursta_connectctate = %x\n",
379 " cursta_connectctate = %x\n", 377 dm_digtable.presta_connectstate,
380 dm_digtable.presta_connectstate, 378 dm_digtable.cursta_connectctate);
381 dm_digtable.cursta_connectctate));
382 379
383 if (dm_digtable.presta_connectstate == dm_digtable.cursta_connectctate 380 if (dm_digtable.presta_connectstate == dm_digtable.cursta_connectctate
384 || dm_digtable.cursta_connectctate == DIG_STA_BEFORE_CONNECT 381 || dm_digtable.cursta_connectctate == DIG_STA_BEFORE_CONNECT
@@ -464,11 +461,11 @@ static void rtl92c_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw)
464 dm_digtable.pre_cck_pd_state = dm_digtable.cur_cck_pd_state; 461 dm_digtable.pre_cck_pd_state = dm_digtable.cur_cck_pd_state;
465 } 462 }
466 463
467 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, 464 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, "CCKPDStage=%x\n",
468 ("CCKPDStage=%x\n", dm_digtable.cur_cck_pd_state)); 465 dm_digtable.cur_cck_pd_state);
469 466
470 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, 467 RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, "is92C=%x\n",
471 ("is92C=%x\n", IS_92C_SERIAL(rtlhal->version))); 468 IS_92C_SERIAL(rtlhal->version));
472} 469}
473 470
474static void rtl92c_dm_ctrl_initgain_by_twoport(struct ieee80211_hw *hw) 471static void rtl92c_dm_ctrl_initgain_by_twoport(struct ieee80211_hw *hw)
@@ -519,10 +516,9 @@ void rtl92c_dm_write_dig(struct ieee80211_hw *hw)
519 struct rtl_priv *rtlpriv = rtl_priv(hw); 516 struct rtl_priv *rtlpriv = rtl_priv(hw);
520 517
521 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, 518 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
522 ("cur_igvalue = 0x%x, " 519 "cur_igvalue = 0x%x, pre_igvalue = 0x%x, backoff_val = %d\n",
523 "pre_igvalue = 0x%x, backoff_val = %d\n", 520 dm_digtable.cur_igvalue, dm_digtable.pre_igvalue,
524 dm_digtable.cur_igvalue, dm_digtable.pre_igvalue, 521 dm_digtable.backoff_val);
525 dm_digtable.backoff_val));
526 522
527 if (dm_digtable.pre_igvalue != dm_digtable.cur_igvalue) { 523 if (dm_digtable.pre_igvalue != dm_digtable.cur_igvalue) {
528 rtl_set_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f, 524 rtl_set_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f,
@@ -676,15 +672,14 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
676 672
677 rtlpriv->dm.txpower_trackinginit = true; 673 rtlpriv->dm.txpower_trackinginit = true;
678 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 674 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
679 ("rtl92c_dm_txpower_tracking_callback_thermalmeter\n")); 675 "rtl92c_dm_txpower_tracking_callback_thermalmeter\n");
680 676
681 thermalvalue = (u8) rtl_get_rfreg(hw, RF90_PATH_A, RF_T_METER, 0x1f); 677 thermalvalue = (u8) rtl_get_rfreg(hw, RF90_PATH_A, RF_T_METER, 0x1f);
682 678
683 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 679 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
684 ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x " 680 "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermalmeter 0x%x\n",
685 "eeprom_thermalmeter 0x%x\n", 681 thermalvalue, rtlpriv->dm.thermalvalue,
686 thermalvalue, rtlpriv->dm.thermalvalue, 682 rtlefuse->eeprom_thermalmeter);
687 rtlefuse->eeprom_thermalmeter));
688 683
689 rtl92c_phy_ap_calibrate(hw, (thermalvalue - 684 rtl92c_phy_ap_calibrate(hw, (thermalvalue -
690 rtlefuse->eeprom_thermalmeter)); 685 rtlefuse->eeprom_thermalmeter));
@@ -702,10 +697,9 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
702 ofdm_index_old[0] = (u8) i; 697 ofdm_index_old[0] = (u8) i;
703 698
704 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 699 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
705 ("Initial pathA ele_d reg0x%x = 0x%lx, " 700 "Initial pathA ele_d reg0x%x = 0x%lx, ofdm_index=0x%x\n",
706 "ofdm_index=0x%x\n",
707 ROFDM0_XATXIQIMBALANCE, 701 ROFDM0_XATXIQIMBALANCE,
708 ele_d, ofdm_index_old[0])); 702 ele_d, ofdm_index_old[0]);
709 break; 703 break;
710 } 704 }
711 } 705 }
@@ -719,11 +713,10 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
719 MASKOFDM_D)) { 713 MASKOFDM_D)) {
720 714
721 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, 715 RT_TRACE(rtlpriv, COMP_POWER_TRACKING,
722 DBG_LOUD, 716 DBG_LOUD,
723 ("Initial pathB ele_d reg0x%x = " 717 "Initial pathB ele_d reg0x%x = 0x%lx, ofdm_index=0x%x\n",
724 "0x%lx, ofdm_index=0x%x\n", 718 ROFDM0_XBTXIQIMBALANCE, ele_d,
725 ROFDM0_XBTXIQIMBALANCE, ele_d, 719 ofdm_index_old[1]);
726 ofdm_index_old[1]));
727 break; 720 break;
728 } 721 }
729 } 722 }
@@ -741,11 +734,10 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
741 734
742 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, 735 RT_TRACE(rtlpriv, COMP_POWER_TRACKING,
743 DBG_LOUD, 736 DBG_LOUD,
744 ("Initial reg0x%x = 0x%lx, " 737 "Initial reg0x%x = 0x%lx, cck_index=0x%x, ch 14 %d\n",
745 "cck_index=0x%x, ch 14 %d\n", 738 RCCK0_TXFILTER2, temp_cck,
746 RCCK0_TXFILTER2, temp_cck, 739 cck_index_old,
747 cck_index_old, 740 rtlpriv->dm.cck_inch14);
748 rtlpriv->dm.cck_inch14));
749 break; 741 break;
750 } 742 }
751 } else { 743 } else {
@@ -757,11 +749,10 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
757 749
758 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, 750 RT_TRACE(rtlpriv, COMP_POWER_TRACKING,
759 DBG_LOUD, 751 DBG_LOUD,
760 ("Initial reg0x%x = 0x%lx, " 752 "Initial reg0x%x = 0x%lx, cck_index=0x%x, ch14 %d\n",
761 "cck_index=0x%x, ch14 %d\n", 753 RCCK0_TXFILTER2, temp_cck,
762 RCCK0_TXFILTER2, temp_cck, 754 cck_index_old,
763 cck_index_old, 755 rtlpriv->dm.cck_inch14);
764 rtlpriv->dm.cck_inch14));
765 break; 756 break;
766 } 757 }
767 } 758 }
@@ -790,12 +781,10 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
790 (rtlpriv->dm.thermalvalue_iqk - thermalvalue); 781 (rtlpriv->dm.thermalvalue_iqk - thermalvalue);
791 782
792 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 783 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
793 ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x " 784 "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermalmeter 0x%x delta 0x%x delta_lck 0x%x delta_iqk 0x%x\n",
794 "eeprom_thermalmeter 0x%x delta 0x%x "
795 "delta_lck 0x%x delta_iqk 0x%x\n",
796 thermalvalue, rtlpriv->dm.thermalvalue, 785 thermalvalue, rtlpriv->dm.thermalvalue,
797 rtlefuse->eeprom_thermalmeter, delta, delta_lck, 786 rtlefuse->eeprom_thermalmeter, delta, delta_lck,
798 delta_iqk)); 787 delta_iqk);
799 788
800 if (delta_lck > 1) { 789 if (delta_lck > 1) {
801 rtlpriv->dm.thermalvalue_lck = thermalvalue; 790 rtlpriv->dm.thermalvalue_lck = thermalvalue;
@@ -815,18 +804,15 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
815 804
816 if (is2t) { 805 if (is2t) {
817 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 806 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
818 ("temp OFDM_A_index=0x%x, " 807 "temp OFDM_A_index=0x%x, OFDM_B_index=0x%x, cck_index=0x%x\n",
819 "OFDM_B_index=0x%x," 808 rtlpriv->dm.ofdm_index[0],
820 "cck_index=0x%x\n", 809 rtlpriv->dm.ofdm_index[1],
821 rtlpriv->dm.ofdm_index[0], 810 rtlpriv->dm.cck_index);
822 rtlpriv->dm.ofdm_index[1],
823 rtlpriv->dm.cck_index));
824 } else { 811 } else {
825 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 812 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
826 ("temp OFDM_A_index=0x%x," 813 "temp OFDM_A_index=0x%x, cck_index=0x%x\n",
827 "cck_index=0x%x\n", 814 rtlpriv->dm.ofdm_index[0],
828 rtlpriv->dm.ofdm_index[0], 815 rtlpriv->dm.cck_index);
829 rtlpriv->dm.cck_index));
830 } 816 }
831 817
832 if (thermalvalue > rtlefuse->eeprom_thermalmeter) { 818 if (thermalvalue > rtlefuse->eeprom_thermalmeter) {
@@ -918,16 +904,13 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
918 904
919 if (is2t) { 905 if (is2t) {
920 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 906 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
921 ("new OFDM_A_index=0x%x, " 907 "new OFDM_A_index=0x%x, OFDM_B_index=0x%x, cck_index=0x%x\n",
922 "OFDM_B_index=0x%x," 908 ofdm_index[0], ofdm_index[1],
923 "cck_index=0x%x\n", 909 cck_index);
924 ofdm_index[0], ofdm_index[1],
925 cck_index));
926 } else { 910 } else {
927 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 911 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
928 ("new OFDM_A_index=0x%x," 912 "new OFDM_A_index=0x%x, cck_index=0x%x\n",
929 "cck_index=0x%x\n", 913 ofdm_index[0], cck_index);
930 ofdm_index[0], cck_index));
931 } 914 }
932 } 915 }
933 916
@@ -1085,7 +1068,7 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw
1085 rtlpriv->dm.thermalvalue = thermalvalue; 1068 rtlpriv->dm.thermalvalue = thermalvalue;
1086 } 1069 }
1087 1070
1088 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, ("<===\n")); 1071 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "<===\n");
1089 1072
1090} 1073}
1091 1074
@@ -1098,8 +1081,8 @@ static void rtl92c_dm_initialize_txpower_tracking_thermalmeter(
1098 rtlpriv->dm.txpower_trackinginit = false; 1081 rtlpriv->dm.txpower_trackinginit = false;
1099 1082
1100 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1083 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1101 ("pMgntInfo->txpower_tracking = %d\n", 1084 "pMgntInfo->txpower_tracking = %d\n",
1102 rtlpriv->dm.txpower_tracking)); 1085 rtlpriv->dm.txpower_tracking);
1103} 1086}
1104 1087
1105static void rtl92c_dm_initialize_txpower_tracking(struct ieee80211_hw *hw) 1088static void rtl92c_dm_initialize_txpower_tracking(struct ieee80211_hw *hw)
@@ -1125,12 +1108,12 @@ static void rtl92c_dm_check_txpower_tracking_thermal_meter(
1125 rtl_set_rfreg(hw, RF90_PATH_A, RF_T_METER, RFREG_OFFSET_MASK, 1108 rtl_set_rfreg(hw, RF90_PATH_A, RF_T_METER, RFREG_OFFSET_MASK,
1126 0x60); 1109 0x60);
1127 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1110 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1128 ("Trigger 92S Thermal Meter!!\n")); 1111 "Trigger 92S Thermal Meter!!\n");
1129 tm_trigger = 1; 1112 tm_trigger = 1;
1130 return; 1113 return;
1131 } else { 1114 } else {
1132 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1115 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1133 ("Schedule TxPowerTracking direct call!!\n")); 1116 "Schedule TxPowerTracking direct call!!\n");
1134 rtl92c_dm_txpower_tracking_directcall(hw); 1117 rtl92c_dm_txpower_tracking_directcall(hw);
1135 tm_trigger = 0; 1118 tm_trigger = 0;
1136 } 1119 }
@@ -1169,13 +1152,13 @@ static void rtl92c_dm_refresh_rate_adaptive_mask(struct ieee80211_hw *hw)
1169 1152
1170 if (is_hal_stop(rtlhal)) { 1153 if (is_hal_stop(rtlhal)) {
1171 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, 1154 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
1172 ("<---- driver is going to unload\n")); 1155 "<---- driver is going to unload\n");
1173 return; 1156 return;
1174 } 1157 }
1175 1158
1176 if (!rtlpriv->dm.useramask) { 1159 if (!rtlpriv->dm.useramask) {
1177 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, 1160 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
1178 ("<---- driver does not control rate adaptive mask\n")); 1161 "<---- driver does not control rate adaptive mask\n");
1179 return; 1162 return;
1180 } 1163 }
1181 1164
@@ -1210,14 +1193,13 @@ static void rtl92c_dm_refresh_rate_adaptive_mask(struct ieee80211_hw *hw)
1210 p_ra->ratr_state = DM_RATR_STA_LOW; 1193 p_ra->ratr_state = DM_RATR_STA_LOW;
1211 1194
1212 if (p_ra->pre_ratr_state != p_ra->ratr_state) { 1195 if (p_ra->pre_ratr_state != p_ra->ratr_state) {
1196 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, "RSSI = %ld\n",
1197 rtlpriv->dm.undecorated_smoothed_pwdb);
1213 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, 1198 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
1214 ("RSSI = %ld\n", 1199 "RSSI_LEVEL = %d\n", p_ra->ratr_state);
1215 rtlpriv->dm.undecorated_smoothed_pwdb));
1216 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, 1200 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
1217 ("RSSI_LEVEL = %d\n", p_ra->ratr_state)); 1201 "PreState = %d, CurState = %d\n",
1218 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, 1202 p_ra->pre_ratr_state, p_ra->ratr_state);
1219 ("PreState = %d, CurState = %d\n",
1220 p_ra->pre_ratr_state, p_ra->ratr_state));
1221 1203
1222 rcu_read_lock(); 1204 rcu_read_lock();
1223 sta = ieee80211_find_sta(mac->vif, mac->bssid); 1205 sta = ieee80211_find_sta(mac->vif, mac->bssid);
@@ -1316,8 +1298,7 @@ static void rtl92c_dm_dynamic_bb_powersaving(struct ieee80211_hw *hw)
1316 if (((mac->link_state == MAC80211_NOLINK)) && 1298 if (((mac->link_state == MAC80211_NOLINK)) &&
1317 (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) { 1299 (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) {
1318 dm_pstable.rssi_val_min = 0; 1300 dm_pstable.rssi_val_min = 0;
1319 RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, 1301 RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, "Not connected to any\n");
1320 ("Not connected to any\n"));
1321 } 1302 }
1322 1303
1323 if (mac->link_state == MAC80211_LINKED) { 1304 if (mac->link_state == MAC80211_LINKED) {
@@ -1325,22 +1306,22 @@ static void rtl92c_dm_dynamic_bb_powersaving(struct ieee80211_hw *hw)
1325 dm_pstable.rssi_val_min = 1306 dm_pstable.rssi_val_min =
1326 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; 1307 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb;
1327 RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, 1308 RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD,
1328 ("AP Client PWDB = 0x%lx\n", 1309 "AP Client PWDB = 0x%lx\n",
1329 dm_pstable.rssi_val_min)); 1310 dm_pstable.rssi_val_min);
1330 } else { 1311 } else {
1331 dm_pstable.rssi_val_min = 1312 dm_pstable.rssi_val_min =
1332 rtlpriv->dm.undecorated_smoothed_pwdb; 1313 rtlpriv->dm.undecorated_smoothed_pwdb;
1333 RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, 1314 RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD,
1334 ("STA Default Port PWDB = 0x%lx\n", 1315 "STA Default Port PWDB = 0x%lx\n",
1335 dm_pstable.rssi_val_min)); 1316 dm_pstable.rssi_val_min);
1336 } 1317 }
1337 } else { 1318 } else {
1338 dm_pstable.rssi_val_min = 1319 dm_pstable.rssi_val_min =
1339 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; 1320 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb;
1340 1321
1341 RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, 1322 RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD,
1342 ("AP Ext Port PWDB = 0x%lx\n", 1323 "AP Ext Port PWDB = 0x%lx\n",
1343 dm_pstable.rssi_val_min)); 1324 dm_pstable.rssi_val_min);
1344 } 1325 }
1345 1326
1346 if (IS_92C_SERIAL(rtlhal->version)) 1327 if (IS_92C_SERIAL(rtlhal->version))
@@ -1381,7 +1362,7 @@ void rtl92c_dm_dynamic_txpower(struct ieee80211_hw *hw)
1381 if ((mac->link_state < MAC80211_LINKED) && 1362 if ((mac->link_state < MAC80211_LINKED) &&
1382 (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) { 1363 (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) {
1383 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, 1364 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
1384 ("Not connected to any\n")); 1365 "Not connected to any\n");
1385 1366
1386 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; 1367 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL;
1387 1368
@@ -1394,28 +1375,28 @@ void rtl92c_dm_dynamic_txpower(struct ieee80211_hw *hw)
1394 undecorated_smoothed_pwdb = 1375 undecorated_smoothed_pwdb =
1395 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; 1376 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb;
1396 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 1377 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
1397 ("AP Client PWDB = 0x%lx\n", 1378 "AP Client PWDB = 0x%lx\n",
1398 undecorated_smoothed_pwdb)); 1379 undecorated_smoothed_pwdb);
1399 } else { 1380 } else {
1400 undecorated_smoothed_pwdb = 1381 undecorated_smoothed_pwdb =
1401 rtlpriv->dm.undecorated_smoothed_pwdb; 1382 rtlpriv->dm.undecorated_smoothed_pwdb;
1402 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 1383 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
1403 ("STA Default Port PWDB = 0x%lx\n", 1384 "STA Default Port PWDB = 0x%lx\n",
1404 undecorated_smoothed_pwdb)); 1385 undecorated_smoothed_pwdb);
1405 } 1386 }
1406 } else { 1387 } else {
1407 undecorated_smoothed_pwdb = 1388 undecorated_smoothed_pwdb =
1408 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; 1389 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb;
1409 1390
1410 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 1391 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
1411 ("AP Ext Port PWDB = 0x%lx\n", 1392 "AP Ext Port PWDB = 0x%lx\n",
1412 undecorated_smoothed_pwdb)); 1393 undecorated_smoothed_pwdb);
1413 } 1394 }
1414 1395
1415 if (undecorated_smoothed_pwdb >= TX_POWER_NEAR_FIELD_THRESH_LVL2) { 1396 if (undecorated_smoothed_pwdb >= TX_POWER_NEAR_FIELD_THRESH_LVL2) {
1416 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; 1397 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1;
1417 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 1398 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
1418 ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n")); 1399 "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n");
1419 } else if ((undecorated_smoothed_pwdb < 1400 } else if ((undecorated_smoothed_pwdb <
1420 (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) && 1401 (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) &&
1421 (undecorated_smoothed_pwdb >= 1402 (undecorated_smoothed_pwdb >=
@@ -1423,18 +1404,18 @@ void rtl92c_dm_dynamic_txpower(struct ieee80211_hw *hw)
1423 1404
1424 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; 1405 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1;
1425 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 1406 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
1426 ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n")); 1407 "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n");
1427 } else if (undecorated_smoothed_pwdb < 1408 } else if (undecorated_smoothed_pwdb <
1428 (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) { 1409 (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) {
1429 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; 1410 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL;
1430 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 1411 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
1431 ("TXHIGHPWRLEVEL_NORMAL\n")); 1412 "TXHIGHPWRLEVEL_NORMAL\n");
1432 } 1413 }
1433 1414
1434 if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) { 1415 if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) {
1435 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 1416 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
1436 ("PHY_SetTxPowerLevel8192S() Channel = %d\n", 1417 "PHY_SetTxPowerLevel8192S() Channel = %d\n",
1437 rtlphy->current_channel)); 1418 rtlphy->current_channel);
1438 rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel); 1419 rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel);
1439 } 1420 }
1440 1421
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
index b9736d3e9a39..2178e3761883 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c
index 931d97979b04..c20b3c30f62e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -27,16 +27,13 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
32#include <linux/firmware.h>
33#include <linux/export.h>
34#include "../wifi.h" 30#include "../wifi.h"
35#include "../pci.h" 31#include "../pci.h"
36#include "../base.h" 32#include "../base.h"
37#include "../rtl8192ce/reg.h" 33#include "../rtl8192ce/reg.h"
38#include "../rtl8192ce/def.h" 34#include "../rtl8192ce/def.h"
39#include "fw_common.h" 35#include "fw_common.h"
36#include <linux/export.h>
40 37
41static void _rtl92c_enable_fw_download(struct ieee80211_hw *hw, bool enable) 38static void _rtl92c_enable_fw_download(struct ieee80211_hw *hw, bool enable)
42{ 39{
@@ -172,7 +169,7 @@ static void _rtl92c_write_fw(struct ieee80211_hw *hw,
172 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 169 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
173 u8 *bufferPtr = (u8 *) buffer; 170 u8 *bufferPtr = (u8 *) buffer;
174 171
175 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, ("FW size is %d bytes,\n", size)); 172 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, "FW size is %d bytes\n", size);
176 173
177 if (IS_CHIP_VER_B(version)) { 174 if (IS_CHIP_VER_B(version)) {
178 u32 pageNums, remainSize; 175 u32 pageNums, remainSize;
@@ -186,7 +183,7 @@ static void _rtl92c_write_fw(struct ieee80211_hw *hw,
186 183
187 if (pageNums > 4) { 184 if (pageNums > 4) {
188 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 185 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
189 ("Page numbers should not greater then 4\n")); 186 "Page numbers should not greater then 4\n");
190 } 187 }
191 188
192 for (page = 0; page < pageNums; page++) { 189 for (page = 0; page < pageNums; page++) {
@@ -219,13 +216,12 @@ static int _rtl92c_fw_free_to_go(struct ieee80211_hw *hw)
219 216
220 if (counter >= FW_8192C_POLLING_TIMEOUT_COUNT) { 217 if (counter >= FW_8192C_POLLING_TIMEOUT_COUNT) {
221 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 218 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
222 ("chksum report faill ! REG_MCUFWDL:0x%08x .\n", 219 "chksum report faill ! REG_MCUFWDL:0x%08x\n", value32);
223 value32));
224 return -EIO; 220 return -EIO;
225 } 221 }
226 222
227 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, 223 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
228 ("Checksum report OK ! REG_MCUFWDL:0x%08x .\n", value32)); 224 "Checksum report OK ! REG_MCUFWDL:0x%08x\n", value32);
229 225
230 value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL); 226 value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL);
231 value32 |= MCUFWDL_RDY; 227 value32 |= MCUFWDL_RDY;
@@ -238,9 +234,8 @@ static int _rtl92c_fw_free_to_go(struct ieee80211_hw *hw)
238 value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL); 234 value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL);
239 if (value32 & WINTINI_RDY) { 235 if (value32 & WINTINI_RDY) {
240 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, 236 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
241 ("Polling FW ready success!!" 237 "Polling FW ready success!! REG_MCUFWDL:0x%08x\n",
242 " REG_MCUFWDL:0x%08x .\n", 238 value32);
243 value32));
244 return 0; 239 return 0;
245 } 240 }
246 241
@@ -249,7 +244,7 @@ static int _rtl92c_fw_free_to_go(struct ieee80211_hw *hw)
249 } while (counter++ < FW_8192C_POLLING_TIMEOUT_COUNT); 244 } while (counter++ < FW_8192C_POLLING_TIMEOUT_COUNT);
250 245
251 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 246 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
252 ("Polling FW ready fail!! REG_MCUFWDL:0x%08x .\n", value32)); 247 "Polling FW ready fail!! REG_MCUFWDL:0x%08x\n", value32);
253 return -EIO; 248 return -EIO;
254} 249}
255 250
@@ -262,20 +257,19 @@ int rtl92c_download_fw(struct ieee80211_hw *hw)
262 u32 fwsize; 257 u32 fwsize;
263 enum version_8192c version = rtlhal->version; 258 enum version_8192c version = rtlhal->version;
264 259
265 if (!rtlhal->pfirmware) 260 if (rtlpriv->max_fw_size == 0 || !rtlhal->pfirmware)
266 return 1; 261 return 1;
267 262
268 pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name);
269 pfwheader = (struct rtl92c_firmware_header *)rtlhal->pfirmware; 263 pfwheader = (struct rtl92c_firmware_header *)rtlhal->pfirmware;
270 pfwdata = (u8 *) rtlhal->pfirmware; 264 pfwdata = (u8 *) rtlhal->pfirmware;
271 fwsize = rtlhal->fwsize; 265 fwsize = rtlhal->fwsize;
272 266
273 if (IS_FW_HEADER_EXIST(pfwheader)) { 267 if (IS_FW_HEADER_EXIST(pfwheader)) {
274 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, 268 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
275 ("Firmware Version(%d), Signature(%#x),Size(%d)\n", 269 "Firmware Version(%d), Signature(%#x),Size(%d)\n",
276 le16_to_cpu(pfwheader->version), 270 le16_to_cpu(pfwheader->version),
277 le16_to_cpu(pfwheader->signature), 271 le16_to_cpu(pfwheader->signature),
278 (uint)sizeof(struct rtl92c_firmware_header))); 272 (uint)sizeof(struct rtl92c_firmware_header));
279 273
280 pfwdata = pfwdata + sizeof(struct rtl92c_firmware_header); 274 pfwdata = pfwdata + sizeof(struct rtl92c_firmware_header);
281 fwsize = fwsize - sizeof(struct rtl92c_firmware_header); 275 fwsize = fwsize - sizeof(struct rtl92c_firmware_header);
@@ -287,10 +281,10 @@ int rtl92c_download_fw(struct ieee80211_hw *hw)
287 281
288 if (_rtl92c_fw_free_to_go(hw)) { 282 if (_rtl92c_fw_free_to_go(hw)) {
289 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 283 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
290 ("Firmware is not ready to run!\n")); 284 "Firmware is not ready to run!\n");
291 } else { 285 } else {
292 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, 286 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
293 ("Firmware is ready to run!\n")); 287 "Firmware is ready to run!\n");
294 } 288 }
295 289
296 return 0; 290 return 0;
@@ -328,22 +322,22 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,
328 unsigned long flag; 322 unsigned long flag;
329 u8 idx; 323 u8 idx;
330 324
331 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("come in\n")); 325 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "come in\n");
332 326
333 while (true) { 327 while (true) {
334 spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); 328 spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag);
335 if (rtlhal->h2c_setinprogress) { 329 if (rtlhal->h2c_setinprogress) {
336 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 330 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
337 ("H2C set in progress! Wait to set.." 331 "H2C set in progress! Wait to set..element_id(%d)\n",
338 "element_id(%d).\n", element_id)); 332 element_id);
339 333
340 while (rtlhal->h2c_setinprogress) { 334 while (rtlhal->h2c_setinprogress) {
341 spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, 335 spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock,
342 flag); 336 flag);
343 h2c_waitcounter++; 337 h2c_waitcounter++;
344 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 338 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
345 ("Wait 100 us (%d times)...\n", 339 "Wait 100 us (%d times)...\n",
346 h2c_waitcounter)); 340 h2c_waitcounter);
347 udelay(100); 341 udelay(100);
348 342
349 if (h2c_waitcounter > 1000) 343 if (h2c_waitcounter > 1000)
@@ -363,8 +357,7 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,
363 wait_writeh2c_limmit--; 357 wait_writeh2c_limmit--;
364 if (wait_writeh2c_limmit == 0) { 358 if (wait_writeh2c_limmit == 0) {
365 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 359 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
366 ("Write H2C fail because no trigger " 360 "Write H2C fail because no trigger for FW INT!\n");
367 "for FW INT!\n"));
368 break; 361 break;
369 } 362 }
370 363
@@ -388,7 +381,7 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,
388 break; 381 break;
389 default: 382 default:
390 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 383 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
391 ("switch case not process\n")); 384 "switch case not processed\n");
392 break; 385 break;
393 } 386 }
394 387
@@ -398,8 +391,8 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,
398 wait_h2c_limmit--; 391 wait_h2c_limmit--;
399 if (wait_h2c_limmit == 0) { 392 if (wait_h2c_limmit == 0) {
400 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 393 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
401 ("Wating too long for FW read " 394 "Waiting too long for FW read clear HMEBox(%d)!\n",
402 "clear HMEBox(%d)!\n", boxnum)); 395 boxnum);
403 break; 396 break;
404 } 397 }
405 398
@@ -408,14 +401,14 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,
408 isfw_read = _rtl92c_check_fw_read_last_h2c(hw, boxnum); 401 isfw_read = _rtl92c_check_fw_read_last_h2c(hw, boxnum);
409 u1b_tmp = rtl_read_byte(rtlpriv, 0x1BF); 402 u1b_tmp = rtl_read_byte(rtlpriv, 0x1BF);
410 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 403 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
411 ("Wating for FW read clear HMEBox(%d)!!! " 404 "Waiting for FW read clear HMEBox(%d)!!! 0x1BF = %2x\n",
412 "0x1BF = %2x\n", boxnum, u1b_tmp)); 405 boxnum, u1b_tmp);
413 } 406 }
414 407
415 if (!isfw_read) { 408 if (!isfw_read) {
416 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 409 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
417 ("Write H2C register BOX[%d] fail!!!!! " 410 "Write H2C register BOX[%d] fail!!!!! Fw do not read\n",
418 "Fw do not read.\n", boxnum)); 411 boxnum);
419 break; 412 break;
420 } 413 }
421 414
@@ -423,8 +416,8 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,
423 memset(boxextcontent, 0, sizeof(boxextcontent)); 416 memset(boxextcontent, 0, sizeof(boxextcontent));
424 boxcontent[0] = element_id; 417 boxcontent[0] = element_id;
425 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 418 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
426 ("Write element_id box_reg(%4x) = %2x\n", 419 "Write element_id box_reg(%4x) = %2x\n",
427 box_reg, element_id)); 420 box_reg, element_id);
428 421
429 switch (cmd_len) { 422 switch (cmd_len) {
430 case 1: 423 case 1:
@@ -493,7 +486,7 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,
493 break; 486 break;
494 default: 487 default:
495 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 488 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
496 ("switch case not process\n")); 489 "switch case not processed\n");
497 break; 490 break;
498 } 491 }
499 492
@@ -504,29 +497,22 @@ static void _rtl92c_fill_h2c_command(struct ieee80211_hw *hw,
504 rtlhal->last_hmeboxnum = 0; 497 rtlhal->last_hmeboxnum = 0;
505 498
506 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 499 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
507 ("pHalData->last_hmeboxnum = %d\n", 500 "pHalData->last_hmeboxnum = %d\n",
508 rtlhal->last_hmeboxnum)); 501 rtlhal->last_hmeboxnum);
509 } 502 }
510 503
511 spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); 504 spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag);
512 rtlhal->h2c_setinprogress = false; 505 rtlhal->h2c_setinprogress = false;
513 spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); 506 spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag);
514 507
515 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("go out\n")); 508 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "go out\n");
516} 509}
517 510
518void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw, 511void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw,
519 u8 element_id, u32 cmd_len, u8 *p_cmdbuffer) 512 u8 element_id, u32 cmd_len, u8 *p_cmdbuffer)
520{ 513{
521 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
522 u32 tmp_cmdbuf[2]; 514 u32 tmp_cmdbuf[2];
523 515
524 if (rtlhal->fw_ready == false) {
525 RT_ASSERT(false, ("return H2C cmd because of Fw "
526 "download fail!!!\n"));
527 return;
528 }
529
530 memset(tmp_cmdbuf, 0, 8); 516 memset(tmp_cmdbuf, 0, 8);
531 memcpy(tmp_cmdbuf, p_cmdbuffer, cmd_len); 517 memcpy(tmp_cmdbuf, p_cmdbuffer, cmd_len);
532 _rtl92c_fill_h2c_command(hw, element_id, cmd_len, (u8 *)&tmp_cmdbuf); 518 _rtl92c_fill_h2c_command(hw, element_id, cmd_len, (u8 *)&tmp_cmdbuf);
@@ -547,7 +533,7 @@ void rtl92c_firmware_selfreset(struct ieee80211_hw *hw)
547 while (u1b_tmp & BIT(2)) { 533 while (u1b_tmp & BIT(2)) {
548 delay--; 534 delay--;
549 if (delay == 0) { 535 if (delay == 0) {
550 RT_ASSERT(false, ("8051 reset fail.\n")); 536 RT_ASSERT(false, "8051 reset fail\n");
551 break; 537 break;
552 } 538 }
553 udelay(50); 539 udelay(50);
@@ -562,7 +548,7 @@ void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode)
562 u8 u1_h2c_set_pwrmode[3] = {0}; 548 u8 u1_h2c_set_pwrmode[3] = {0};
563 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 549 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
564 550
565 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("FW LPS mode = %d\n", mode)); 551 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "FW LPS mode = %d\n", mode);
566 552
567 SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, mode); 553 SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, mode);
568 SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, 1); 554 SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, 1);
@@ -570,7 +556,7 @@ void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode)
570 ppsc->reg_max_lps_awakeintvl); 556 ppsc->reg_max_lps_awakeintvl);
571 557
572 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, 558 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
573 "rtl92c_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode\n", 559 "rtl92c_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode",
574 u1_h2c_set_pwrmode, 3); 560 u1_h2c_set_pwrmode, 3);
575 rtl92c_fill_h2c_cmd(hw, H2C_SETPWRMODE, 3, u1_h2c_set_pwrmode); 561 rtl92c_fill_h2c_cmd(hw, H2C_SETPWRMODE, 3, u1_h2c_set_pwrmode);
576 562
@@ -780,14 +766,16 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished)
780 totalpacketlen = TOTAL_RESERVED_PKT_LEN; 766 totalpacketlen = TOTAL_RESERVED_PKT_LEN;
781 767
782 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, 768 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD,
783 "rtl92c_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", 769 "rtl92c_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL",
784 &reserved_page_packet[0], totalpacketlen); 770 &reserved_page_packet[0], totalpacketlen);
785 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, 771 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
786 "rtl92c_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", 772 "rtl92c_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL",
787 u1RsvdPageLoc, 3); 773 u1RsvdPageLoc, 3);
788 774
789 775
790 skb = dev_alloc_skb(totalpacketlen); 776 skb = dev_alloc_skb(totalpacketlen);
777 if (!skb)
778 return;
791 memcpy((u8 *) skb_put(skb, totalpacketlen), 779 memcpy((u8 *) skb_put(skb, totalpacketlen),
792 &reserved_page_packet, totalpacketlen); 780 &reserved_page_packet, totalpacketlen);
793 781
@@ -798,15 +786,14 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished)
798 786
799 if (dlok) { 787 if (dlok) {
800 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 788 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
801 ("Set RSVD page location to Fw.\n")); 789 "Set RSVD page location to Fw\n");
802 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, 790 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
803 "H2C_RSVDPAGE:\n", 791 "H2C_RSVDPAGE", u1RsvdPageLoc, 3);
804 u1RsvdPageLoc, 3);
805 rtl92c_fill_h2c_cmd(hw, H2C_RSVDPAGE, 792 rtl92c_fill_h2c_cmd(hw, H2C_RSVDPAGE,
806 sizeof(u1RsvdPageLoc), u1RsvdPageLoc); 793 sizeof(u1RsvdPageLoc), u1RsvdPageLoc);
807 } else 794 } else
808 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 795 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
809 ("Set RSVD page location to Fw FAIL!!!!!!.\n")); 796 "Set RSVD page location to Fw FAIL!!!!!!\n");
810} 797}
811EXPORT_SYMBOL(rtl92c_set_fw_rsvdpagepkt); 798EXPORT_SYMBOL(rtl92c_set_fw_rsvdpagepkt);
812 799
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
index cec5a3a1cc53..780ea5b1e24c 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/main.c b/drivers/net/wireless/rtlwifi/rtl8192c/main.c
index 605ff191aeb7..918b1d129e77 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/main.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/main.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -27,8 +27,8 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#include <linux/module.h>
31#include "../wifi.h" 30#include "../wifi.h"
31#include <linux/module.h>
32 32
33 33
34MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>"); 34MODULE_AUTHOR("lizhaoming <chaoming_li@realsil.com.cn>");
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
index 1f07558debf2..22e998dd2f32 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -42,16 +42,15 @@ u32 rtl92c_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
42 struct rtl_priv *rtlpriv = rtl_priv(hw); 42 struct rtl_priv *rtlpriv = rtl_priv(hw);
43 u32 returnvalue, originalvalue, bitshift; 43 u32 returnvalue, originalvalue, bitshift;
44 44
45 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " 45 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "regaddr(%#x), bitmask(%#x)\n",
46 "bitmask(%#x)\n", regaddr, 46 regaddr, bitmask);
47 bitmask));
48 originalvalue = rtl_read_dword(rtlpriv, regaddr); 47 originalvalue = rtl_read_dword(rtlpriv, regaddr);
49 bitshift = _rtl92c_phy_calculate_bit_shift(bitmask); 48 bitshift = _rtl92c_phy_calculate_bit_shift(bitmask);
50 returnvalue = (originalvalue & bitmask) >> bitshift; 49 returnvalue = (originalvalue & bitmask) >> bitshift;
51 50
52 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("BBR MASK=0x%x " 51 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
53 "Addr[0x%x]=0x%x\n", bitmask, 52 "BBR MASK=0x%x Addr[0x%x]=0x%x\n",
54 regaddr, originalvalue)); 53 bitmask, regaddr, originalvalue);
55 54
56 return returnvalue; 55 return returnvalue;
57 56
@@ -64,9 +63,9 @@ void rtl92c_phy_set_bb_reg(struct ieee80211_hw *hw,
64 struct rtl_priv *rtlpriv = rtl_priv(hw); 63 struct rtl_priv *rtlpriv = rtl_priv(hw);
65 u32 originalvalue, bitshift; 64 u32 originalvalue, bitshift;
66 65
67 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," 66 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
68 " data(%#x)\n", regaddr, bitmask, 67 "regaddr(%#x), bitmask(%#x), data(%#x)\n",
69 data)); 68 regaddr, bitmask, data);
70 69
71 if (bitmask != MASKDWORD) { 70 if (bitmask != MASKDWORD) {
72 originalvalue = rtl_read_dword(rtlpriv, regaddr); 71 originalvalue = rtl_read_dword(rtlpriv, regaddr);
@@ -76,9 +75,9 @@ void rtl92c_phy_set_bb_reg(struct ieee80211_hw *hw,
76 75
77 rtl_write_dword(rtlpriv, regaddr, data); 76 rtl_write_dword(rtlpriv, regaddr, data);
78 77
79 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," 78 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
80 " data(%#x)\n", regaddr, bitmask, 79 "regaddr(%#x), bitmask(%#x), data(%#x)\n",
81 data)); 80 regaddr, bitmask, data);
82 81
83} 82}
84EXPORT_SYMBOL(rtl92c_phy_set_bb_reg); 83EXPORT_SYMBOL(rtl92c_phy_set_bb_reg);
@@ -86,7 +85,7 @@ EXPORT_SYMBOL(rtl92c_phy_set_bb_reg);
86u32 _rtl92c_phy_fw_rf_serial_read(struct ieee80211_hw *hw, 85u32 _rtl92c_phy_fw_rf_serial_read(struct ieee80211_hw *hw,
87 enum radio_path rfpath, u32 offset) 86 enum radio_path rfpath, u32 offset)
88{ 87{
89 RT_ASSERT(false, ("deprecated!\n")); 88 RT_ASSERT(false, "deprecated!\n");
90 return 0; 89 return 0;
91 90
92} 91}
@@ -96,7 +95,7 @@ void _rtl92c_phy_fw_rf_serial_write(struct ieee80211_hw *hw,
96 enum radio_path rfpath, u32 offset, 95 enum radio_path rfpath, u32 offset,
97 u32 data) 96 u32 data)
98{ 97{
99 RT_ASSERT(false, ("deprecated!\n")); 98 RT_ASSERT(false, "deprecated!\n");
100} 99}
101EXPORT_SYMBOL(_rtl92c_phy_fw_rf_serial_write); 100EXPORT_SYMBOL(_rtl92c_phy_fw_rf_serial_write);
102 101
@@ -114,7 +113,7 @@ u32 _rtl92c_phy_rf_serial_read(struct ieee80211_hw *hw,
114 offset &= 0x3f; 113 offset &= 0x3f;
115 newoffset = offset; 114 newoffset = offset;
116 if (RT_CANNOT_IO(hw)) { 115 if (RT_CANNOT_IO(hw)) {
117 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("return all one\n")); 116 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "return all one\n");
118 return 0xFFFFFFFF; 117 return 0xFFFFFFFF;
119 } 118 }
120 tmplong = rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, MASKDWORD); 119 tmplong = rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, MASKDWORD);
@@ -144,9 +143,8 @@ u32 _rtl92c_phy_rf_serial_read(struct ieee80211_hw *hw,
144 else 143 else
145 retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readback, 144 retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readback,
146 BLSSIREADBACKDATA); 145 BLSSIREADBACKDATA);
147 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFR-%d Addr[0x%x]=0x%x\n", 146 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "RFR-%d Addr[0x%x]=0x%x\n",
148 rfpath, pphyreg->rflssi_readback, 147 rfpath, pphyreg->rflssi_readback, retvalue);
149 retvalue));
150 return retvalue; 148 return retvalue;
151} 149}
152EXPORT_SYMBOL(_rtl92c_phy_rf_serial_read); 150EXPORT_SYMBOL(_rtl92c_phy_rf_serial_read);
@@ -162,16 +160,15 @@ void _rtl92c_phy_rf_serial_write(struct ieee80211_hw *hw,
162 struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; 160 struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath];
163 161
164 if (RT_CANNOT_IO(hw)) { 162 if (RT_CANNOT_IO(hw)) {
165 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("stop\n")); 163 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "stop\n");
166 return; 164 return;
167 } 165 }
168 offset &= 0x3f; 166 offset &= 0x3f;
169 newoffset = offset; 167 newoffset = offset;
170 data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff; 168 data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff;
171 rtl_set_bbreg(hw, pphyreg->rf3wire_offset, MASKDWORD, data_and_addr); 169 rtl_set_bbreg(hw, pphyreg->rf3wire_offset, MASKDWORD, data_and_addr);
172 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFW-%d Addr[0x%x]=0x%x\n", 170 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "RFW-%d Addr[0x%x]=0x%x\n",
173 rfpath, pphyreg->rf3wire_offset, 171 rfpath, pphyreg->rf3wire_offset, data_and_addr);
174 data_and_addr));
175} 172}
176EXPORT_SYMBOL(_rtl92c_phy_rf_serial_write); 173EXPORT_SYMBOL(_rtl92c_phy_rf_serial_write);
177 174
@@ -216,16 +213,16 @@ bool _rtl92c_phy_bb8192c_config_parafile(struct ieee80211_hw *hw)
216 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); 213 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
217 bool rtstatus; 214 bool rtstatus;
218 215
219 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("==>\n")); 216 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "==>\n");
220 rtstatus = rtlpriv->cfg->ops->config_bb_with_headerfile(hw, 217 rtstatus = rtlpriv->cfg->ops->config_bb_with_headerfile(hw,
221 BASEBAND_CONFIG_PHY_REG); 218 BASEBAND_CONFIG_PHY_REG);
222 if (rtstatus != true) { 219 if (rtstatus != true) {
223 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Write BB Reg Fail!!")); 220 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Write BB Reg Fail!!\n");
224 return false; 221 return false;
225 } 222 }
226 if (rtlphy->rf_type == RF_1T2R) { 223 if (rtlphy->rf_type == RF_1T2R) {
227 _rtl92c_phy_bb_config_1t(hw); 224 _rtl92c_phy_bb_config_1t(hw);
228 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Config to 1T!!\n")); 225 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Config to 1T!!\n");
229 } 226 }
230 if (rtlefuse->autoload_failflag == false) { 227 if (rtlefuse->autoload_failflag == false) {
231 rtlphy->pwrgroup_cnt = 0; 228 rtlphy->pwrgroup_cnt = 0;
@@ -233,13 +230,13 @@ bool _rtl92c_phy_bb8192c_config_parafile(struct ieee80211_hw *hw)
233 BASEBAND_CONFIG_PHY_REG); 230 BASEBAND_CONFIG_PHY_REG);
234 } 231 }
235 if (rtstatus != true) { 232 if (rtstatus != true) {
236 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("BB_PG Reg Fail!!")); 233 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "BB_PG Reg Fail!!\n");
237 return false; 234 return false;
238 } 235 }
239 rtstatus = rtlpriv->cfg->ops->config_bb_with_headerfile(hw, 236 rtstatus = rtlpriv->cfg->ops->config_bb_with_headerfile(hw,
240 BASEBAND_CONFIG_AGC_TAB); 237 BASEBAND_CONFIG_AGC_TAB);
241 if (rtstatus != true) { 238 if (rtstatus != true) {
242 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("AGC Table Fail\n")); 239 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "AGC Table Fail\n");
243 return false; 240 return false;
244 } 241 }
245 rtlphy->cck_high_power = (bool) (rtl_get_bbreg(hw, 242 rtlphy->cck_high_power = (bool) (rtl_get_bbreg(hw,
@@ -260,114 +257,114 @@ void _rtl92c_store_pwrIndex_diffrate_offset(struct ieee80211_hw *hw,
260 if (regaddr == RTXAGC_A_RATE18_06) { 257 if (regaddr == RTXAGC_A_RATE18_06) {
261 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][0] = data; 258 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][0] = data;
262 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 259 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
263 ("MCSTxPowerLevelOriginalOffset[%d][0] = 0x%x\n", 260 "MCSTxPowerLevelOriginalOffset[%d][0] = 0x%x\n",
264 rtlphy->pwrgroup_cnt, 261 rtlphy->pwrgroup_cnt,
265 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][0])); 262 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][0]);
266 } 263 }
267 if (regaddr == RTXAGC_A_RATE54_24) { 264 if (regaddr == RTXAGC_A_RATE54_24) {
268 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][1] = data; 265 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][1] = data;
269 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 266 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
270 ("MCSTxPowerLevelOriginalOffset[%d][1] = 0x%x\n", 267 "MCSTxPowerLevelOriginalOffset[%d][1] = 0x%x\n",
271 rtlphy->pwrgroup_cnt, 268 rtlphy->pwrgroup_cnt,
272 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][1])); 269 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][1]);
273 } 270 }
274 if (regaddr == RTXAGC_A_CCK1_MCS32) { 271 if (regaddr == RTXAGC_A_CCK1_MCS32) {
275 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][6] = data; 272 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][6] = data;
276 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 273 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
277 ("MCSTxPowerLevelOriginalOffset[%d][6] = 0x%x\n", 274 "MCSTxPowerLevelOriginalOffset[%d][6] = 0x%x\n",
278 rtlphy->pwrgroup_cnt, 275 rtlphy->pwrgroup_cnt,
279 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][6])); 276 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][6]);
280 } 277 }
281 if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) { 278 if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) {
282 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][7] = data; 279 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][7] = data;
283 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 280 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
284 ("MCSTxPowerLevelOriginalOffset[%d][7] = 0x%x\n", 281 "MCSTxPowerLevelOriginalOffset[%d][7] = 0x%x\n",
285 rtlphy->pwrgroup_cnt, 282 rtlphy->pwrgroup_cnt,
286 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][7])); 283 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][7]);
287 } 284 }
288 if (regaddr == RTXAGC_A_MCS03_MCS00) { 285 if (regaddr == RTXAGC_A_MCS03_MCS00) {
289 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][2] = data; 286 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][2] = data;
290 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 287 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
291 ("MCSTxPowerLevelOriginalOffset[%d][2] = 0x%x\n", 288 "MCSTxPowerLevelOriginalOffset[%d][2] = 0x%x\n",
292 rtlphy->pwrgroup_cnt, 289 rtlphy->pwrgroup_cnt,
293 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][2])); 290 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][2]);
294 } 291 }
295 if (regaddr == RTXAGC_A_MCS07_MCS04) { 292 if (regaddr == RTXAGC_A_MCS07_MCS04) {
296 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][3] = data; 293 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][3] = data;
297 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 294 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
298 ("MCSTxPowerLevelOriginalOffset[%d][3] = 0x%x\n", 295 "MCSTxPowerLevelOriginalOffset[%d][3] = 0x%x\n",
299 rtlphy->pwrgroup_cnt, 296 rtlphy->pwrgroup_cnt,
300 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][3])); 297 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][3]);
301 } 298 }
302 if (regaddr == RTXAGC_A_MCS11_MCS08) { 299 if (regaddr == RTXAGC_A_MCS11_MCS08) {
303 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][4] = data; 300 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][4] = data;
304 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 301 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
305 ("MCSTxPowerLevelOriginalOffset[%d][4] = 0x%x\n", 302 "MCSTxPowerLevelOriginalOffset[%d][4] = 0x%x\n",
306 rtlphy->pwrgroup_cnt, 303 rtlphy->pwrgroup_cnt,
307 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][4])); 304 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][4]);
308 } 305 }
309 if (regaddr == RTXAGC_A_MCS15_MCS12) { 306 if (regaddr == RTXAGC_A_MCS15_MCS12) {
310 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][5] = data; 307 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][5] = data;
311 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 308 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
312 ("MCSTxPowerLevelOriginalOffset[%d][5] = 0x%x\n", 309 "MCSTxPowerLevelOriginalOffset[%d][5] = 0x%x\n",
313 rtlphy->pwrgroup_cnt, 310 rtlphy->pwrgroup_cnt,
314 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][5])); 311 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][5]);
315 } 312 }
316 if (regaddr == RTXAGC_B_RATE18_06) { 313 if (regaddr == RTXAGC_B_RATE18_06) {
317 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][8] = data; 314 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][8] = data;
318 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 315 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
319 ("MCSTxPowerLevelOriginalOffset[%d][8] = 0x%x\n", 316 "MCSTxPowerLevelOriginalOffset[%d][8] = 0x%x\n",
320 rtlphy->pwrgroup_cnt, 317 rtlphy->pwrgroup_cnt,
321 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][8])); 318 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][8]);
322 } 319 }
323 if (regaddr == RTXAGC_B_RATE54_24) { 320 if (regaddr == RTXAGC_B_RATE54_24) {
324 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][9] = data; 321 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][9] = data;
325 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 322 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
326 ("MCSTxPowerLevelOriginalOffset[%d][9] = 0x%x\n", 323 "MCSTxPowerLevelOriginalOffset[%d][9] = 0x%x\n",
327 rtlphy->pwrgroup_cnt, 324 rtlphy->pwrgroup_cnt,
328 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][9])); 325 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][9]);
329 } 326 }
330 if (regaddr == RTXAGC_B_CCK1_55_MCS32) { 327 if (regaddr == RTXAGC_B_CCK1_55_MCS32) {
331 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][14] = data; 328 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][14] = data;
332 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 329 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
333 ("MCSTxPowerLevelOriginalOffset[%d][14] = 0x%x\n", 330 "MCSTxPowerLevelOriginalOffset[%d][14] = 0x%x\n",
334 rtlphy->pwrgroup_cnt, 331 rtlphy->pwrgroup_cnt,
335 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][14])); 332 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][14]);
336 } 333 }
337 if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) { 334 if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) {
338 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][15] = data; 335 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][15] = data;
339 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 336 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
340 ("MCSTxPowerLevelOriginalOffset[%d][15] = 0x%x\n", 337 "MCSTxPowerLevelOriginalOffset[%d][15] = 0x%x\n",
341 rtlphy->pwrgroup_cnt, 338 rtlphy->pwrgroup_cnt,
342 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][15])); 339 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][15]);
343 } 340 }
344 if (regaddr == RTXAGC_B_MCS03_MCS00) { 341 if (regaddr == RTXAGC_B_MCS03_MCS00) {
345 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][10] = data; 342 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][10] = data;
346 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 343 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
347 ("MCSTxPowerLevelOriginalOffset[%d][10] = 0x%x\n", 344 "MCSTxPowerLevelOriginalOffset[%d][10] = 0x%x\n",
348 rtlphy->pwrgroup_cnt, 345 rtlphy->pwrgroup_cnt,
349 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][10])); 346 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][10]);
350 } 347 }
351 if (regaddr == RTXAGC_B_MCS07_MCS04) { 348 if (regaddr == RTXAGC_B_MCS07_MCS04) {
352 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][11] = data; 349 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][11] = data;
353 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 350 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
354 ("MCSTxPowerLevelOriginalOffset[%d][11] = 0x%x\n", 351 "MCSTxPowerLevelOriginalOffset[%d][11] = 0x%x\n",
355 rtlphy->pwrgroup_cnt, 352 rtlphy->pwrgroup_cnt,
356 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][11])); 353 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][11]);
357 } 354 }
358 if (regaddr == RTXAGC_B_MCS11_MCS08) { 355 if (regaddr == RTXAGC_B_MCS11_MCS08) {
359 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][12] = data; 356 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][12] = data;
360 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 357 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
361 ("MCSTxPowerLevelOriginalOffset[%d][12] = 0x%x\n", 358 "MCSTxPowerLevelOriginalOffset[%d][12] = 0x%x\n",
362 rtlphy->pwrgroup_cnt, 359 rtlphy->pwrgroup_cnt,
363 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][12])); 360 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][12]);
364 } 361 }
365 if (regaddr == RTXAGC_B_MCS15_MCS12) { 362 if (regaddr == RTXAGC_B_MCS15_MCS12) {
366 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][13] = data; 363 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][13] = data;
367 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 364 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
368 ("MCSTxPowerLevelOriginalOffset[%d][13] = 0x%x\n", 365 "MCSTxPowerLevelOriginalOffset[%d][13] = 0x%x\n",
369 rtlphy->pwrgroup_cnt, 366 rtlphy->pwrgroup_cnt,
370 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][13])); 367 rtlphy->MCS_TXPWR[rtlphy->pwrgroup_cnt][13]);
371 368
372 rtlphy->pwrgroup_cnt++; 369 rtlphy->pwrgroup_cnt++;
373 } 370 }
@@ -389,12 +386,11 @@ void rtl92c_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw)
389 (u8) rtl_get_bbreg(hw, ROFDM0_XDAGCCORE1, MASKBYTE0); 386 (u8) rtl_get_bbreg(hw, ROFDM0_XDAGCCORE1, MASKBYTE0);
390 387
391 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 388 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
392 ("Default initial gain (c50=0x%x, " 389 "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x\n",
393 "c58=0x%x, c60=0x%x, c68=0x%x\n", 390 rtlphy->default_initialgain[0],
394 rtlphy->default_initialgain[0], 391 rtlphy->default_initialgain[1],
395 rtlphy->default_initialgain[1], 392 rtlphy->default_initialgain[2],
396 rtlphy->default_initialgain[2], 393 rtlphy->default_initialgain[3]);
397 rtlphy->default_initialgain[3]));
398 394
399 rtlphy->framesync = (u8) rtl_get_bbreg(hw, 395 rtlphy->framesync = (u8) rtl_get_bbreg(hw,
400 ROFDM0_RXDETECTOR3, MASKBYTE0); 396 ROFDM0_RXDETECTOR3, MASKBYTE0);
@@ -402,8 +398,8 @@ void rtl92c_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw)
402 ROFDM0_RXDETECTOR2, MASKDWORD); 398 ROFDM0_RXDETECTOR2, MASKDWORD);
403 399
404 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 400 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
405 ("Default framesync (0x%x) = 0x%x\n", 401 "Default framesync (0x%x) = 0x%x\n",
406 ROFDM0_RXDETECTOR3, rtlphy->framesync)); 402 ROFDM0_RXDETECTOR3, rtlphy->framesync);
407} 403}
408 404
409void _rtl92c_phy_init_bb_rf_register_definition(struct ieee80211_hw *hw) 405void _rtl92c_phy_init_bb_rf_register_definition(struct ieee80211_hw *hw)
@@ -615,8 +611,8 @@ bool rtl92c_phy_update_txpower_dbm(struct ieee80211_hw *hw, long power_indbm)
615 else 611 else
616 ofdmtxpwridx = 0; 612 ofdmtxpwridx = 0;
617 RT_TRACE(rtlpriv, COMP_TXAGC, DBG_TRACE, 613 RT_TRACE(rtlpriv, COMP_TXAGC, DBG_TRACE,
618 ("%lx dBm, ccktxpwridx = %d, ofdmtxpwridx = %d\n", 614 "%lx dBm, ccktxpwridx = %d, ofdmtxpwridx = %d\n",
619 power_indbm, ccktxpwridx, ofdmtxpwridx)); 615 power_indbm, ccktxpwridx, ofdmtxpwridx);
620 for (idx = 0; idx < 14; idx++) { 616 for (idx = 0; idx < 14; idx++) {
621 for (rf_path = 0; rf_path < 2; rf_path++) { 617 for (rf_path = 0; rf_path < 2; rf_path++) {
622 rtlefuse->txpwrlevel_cck[rf_path][idx] = ccktxpwridx; 618 rtlefuse->txpwrlevel_cck[rf_path][idx] = ccktxpwridx;
@@ -710,7 +706,7 @@ void rtl92c_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation)
710 break; 706 break;
711 default: 707 default:
712 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 708 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
713 ("Unknown Scan Backup operation.\n")); 709 "Unknown Scan Backup operation\n");
714 break; 710 break;
715 } 711 }
716 } 712 }
@@ -732,7 +728,7 @@ void rtl92c_phy_set_bw_mode(struct ieee80211_hw *hw,
732 rtlpriv->cfg->ops->phy_set_bw_mode_callback(hw); 728 rtlpriv->cfg->ops->phy_set_bw_mode_callback(hw);
733 } else { 729 } else {
734 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 730 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
735 ("FALSE driver sleep or unload\n")); 731 "FALSE driver sleep or unload\n");
736 rtlphy->set_bwmode_inprogress = false; 732 rtlphy->set_bwmode_inprogress = false;
737 rtlphy->current_chan_bw = tmp_bw; 733 rtlphy->current_chan_bw = tmp_bw;
738 } 734 }
@@ -747,7 +743,7 @@ void rtl92c_phy_sw_chnl_callback(struct ieee80211_hw *hw)
747 u32 delay; 743 u32 delay;
748 744
749 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, 745 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE,
750 ("switch to channel%d\n", rtlphy->current_channel)); 746 "switch to channel%d\n", rtlphy->current_channel);
751 if (is_hal_stop(rtlhal)) 747 if (is_hal_stop(rtlhal))
752 return; 748 return;
753 do { 749 do {
@@ -765,7 +761,7 @@ void rtl92c_phy_sw_chnl_callback(struct ieee80211_hw *hw)
765 } 761 }
766 break; 762 break;
767 } while (true); 763 } while (true);
768 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); 764 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n");
769} 765}
770EXPORT_SYMBOL(rtl92c_phy_sw_chnl_callback); 766EXPORT_SYMBOL(rtl92c_phy_sw_chnl_callback);
771 767
@@ -780,19 +776,18 @@ u8 rtl92c_phy_sw_chnl(struct ieee80211_hw *hw)
780 if (rtlphy->set_bwmode_inprogress) 776 if (rtlphy->set_bwmode_inprogress)
781 return 0; 777 return 0;
782 RT_ASSERT((rtlphy->current_channel <= 14), 778 RT_ASSERT((rtlphy->current_channel <= 14),
783 ("WIRELESS_MODE_G but channel>14")); 779 "WIRELESS_MODE_G but channel>14\n");
784 rtlphy->sw_chnl_inprogress = true; 780 rtlphy->sw_chnl_inprogress = true;
785 rtlphy->sw_chnl_stage = 0; 781 rtlphy->sw_chnl_stage = 0;
786 rtlphy->sw_chnl_step = 0; 782 rtlphy->sw_chnl_step = 0;
787 if (!(is_hal_stop(rtlhal)) && !(RT_CANNOT_IO(hw))) { 783 if (!(is_hal_stop(rtlhal)) && !(RT_CANNOT_IO(hw))) {
788 rtl92c_phy_sw_chnl_callback(hw); 784 rtl92c_phy_sw_chnl_callback(hw);
789 RT_TRACE(rtlpriv, COMP_CHAN, DBG_LOUD, 785 RT_TRACE(rtlpriv, COMP_CHAN, DBG_LOUD,
790 ("sw_chnl_inprogress false schdule workitem\n")); 786 "sw_chnl_inprogress false schdule workitem\n");
791 rtlphy->sw_chnl_inprogress = false; 787 rtlphy->sw_chnl_inprogress = false;
792 } else { 788 } else {
793 RT_TRACE(rtlpriv, COMP_CHAN, DBG_LOUD, 789 RT_TRACE(rtlpriv, COMP_CHAN, DBG_LOUD,
794 ("sw_chnl_inprogress false driver sleep or" 790 "sw_chnl_inprogress false driver sleep or unload\n");
795 " unload\n"));
796 rtlphy->sw_chnl_inprogress = false; 791 rtlphy->sw_chnl_inprogress = false;
797 } 792 }
798 return 1; 793 return 1;
@@ -807,7 +802,7 @@ static bool _rtl92c_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable,
807 struct swchnlcmd *pcmd; 802 struct swchnlcmd *pcmd;
808 803
809 if (cmdtable == NULL) { 804 if (cmdtable == NULL) {
810 RT_ASSERT(false, ("cmdtable cannot be NULL.\n")); 805 RT_ASSERT(false, "cmdtable cannot be NULL\n");
811 return false; 806 return false;
812 } 807 }
813 808
@@ -853,7 +848,7 @@ bool _rtl92c_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
853 rfdependcmdcnt = 0; 848 rfdependcmdcnt = 0;
854 849
855 RT_ASSERT((channel >= 1 && channel <= 14), 850 RT_ASSERT((channel >= 1 && channel <= 14),
856 ("illegal channel for Zebra: %d\n", channel)); 851 "invalid channel for Zebra: %d\n", channel);
857 852
858 _rtl92c_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++, 853 _rtl92c_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++,
859 MAX_RFDEPENDCMD_CNT, CMDID_RF_WRITEREG, 854 MAX_RFDEPENDCMD_CNT, CMDID_RF_WRITEREG,
@@ -916,7 +911,7 @@ bool _rtl92c_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
916 break; 911 break;
917 default: 912 default:
918 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 913 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
919 ("switch case not process\n")); 914 "switch case not processed\n");
920 break; 915 break;
921 } 916 }
922 917
@@ -1920,23 +1915,23 @@ bool rtl92c_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype)
1920 bool postprocessing = false; 1915 bool postprocessing = false;
1921 1916
1922 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, 1917 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE,
1923 ("-->IO Cmd(%#x), set_io_inprogress(%d)\n", 1918 "-->IO Cmd(%#x), set_io_inprogress(%d)\n",
1924 iotype, rtlphy->set_io_inprogress)); 1919 iotype, rtlphy->set_io_inprogress);
1925 do { 1920 do {
1926 switch (iotype) { 1921 switch (iotype) {
1927 case IO_CMD_RESUME_DM_BY_SCAN: 1922 case IO_CMD_RESUME_DM_BY_SCAN:
1928 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, 1923 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE,
1929 ("[IO CMD] Resume DM after scan.\n")); 1924 "[IO CMD] Resume DM after scan\n");
1930 postprocessing = true; 1925 postprocessing = true;
1931 break; 1926 break;
1932 case IO_CMD_PAUSE_DM_BY_SCAN: 1927 case IO_CMD_PAUSE_DM_BY_SCAN:
1933 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, 1928 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE,
1934 ("[IO CMD] Pause DM before scan.\n")); 1929 "[IO CMD] Pause DM before scan\n");
1935 postprocessing = true; 1930 postprocessing = true;
1936 break; 1931 break;
1937 default: 1932 default:
1938 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1933 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1939 ("switch case not process\n")); 1934 "switch case not processed\n");
1940 break; 1935 break;
1941 } 1936 }
1942 } while (false); 1937 } while (false);
@@ -1947,7 +1942,7 @@ bool rtl92c_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype)
1947 return false; 1942 return false;
1948 } 1943 }
1949 rtl92c_phy_set_io(hw); 1944 rtl92c_phy_set_io(hw);
1950 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, ("<--IO Type(%#x)\n", iotype)); 1945 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, "<--IO Type(%#x)\n", iotype);
1951 return true; 1946 return true;
1952} 1947}
1953EXPORT_SYMBOL(rtl92c_phy_set_io_cmd); 1948EXPORT_SYMBOL(rtl92c_phy_set_io_cmd);
@@ -1958,8 +1953,8 @@ void rtl92c_phy_set_io(struct ieee80211_hw *hw)
1958 struct rtl_phy *rtlphy = &(rtlpriv->phy); 1953 struct rtl_phy *rtlphy = &(rtlpriv->phy);
1959 1954
1960 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, 1955 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE,
1961 ("--->Cmd(%#x), set_io_inprogress(%d)\n", 1956 "--->Cmd(%#x), set_io_inprogress(%d)\n",
1962 rtlphy->current_io_type, rtlphy->set_io_inprogress)); 1957 rtlphy->current_io_type, rtlphy->set_io_inprogress);
1963 switch (rtlphy->current_io_type) { 1958 switch (rtlphy->current_io_type) {
1964 case IO_CMD_RESUME_DM_BY_SCAN: 1959 case IO_CMD_RESUME_DM_BY_SCAN:
1965 dm_digtable.cur_igvalue = rtlphy->initgain_backup.xaagccore1; 1960 dm_digtable.cur_igvalue = rtlphy->initgain_backup.xaagccore1;
@@ -1973,12 +1968,12 @@ void rtl92c_phy_set_io(struct ieee80211_hw *hw)
1973 break; 1968 break;
1974 default: 1969 default:
1975 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1970 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1976 ("switch case not process\n")); 1971 "switch case not processed\n");
1977 break; 1972 break;
1978 } 1973 }
1979 rtlphy->set_io_inprogress = false; 1974 rtlphy->set_io_inprogress = false;
1980 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, 1975 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, "<---(%#x)\n",
1981 ("<---(%#x)\n", rtlphy->current_io_type)); 1976 rtlphy->current_io_type);
1982} 1977}
1983EXPORT_SYMBOL(rtl92c_phy_set_io); 1978EXPORT_SYMBOL(rtl92c_phy_set_io);
1984 1979
@@ -2018,7 +2013,7 @@ void _rtl92c_phy_set_rf_sleep(struct ieee80211_hw *hw)
2018 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); 2013 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3);
2019 rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00); 2014 rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00);
2020 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, 2015 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
2021 ("Switch RF timeout !!!.\n")); 2016 "Switch RF timeout !!!\n");
2022 return; 2017 return;
2023 } 2018 }
2024 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); 2019 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h
index 9a264c0d6127..cec10d696492 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
index 9fc804d89d65..04c3aef8a4f6 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c
index 2df33e53e15a..27b3af880d96 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -54,7 +54,7 @@ void rtl92ce_dm_dynamic_txpower(struct ieee80211_hw *hw)
54 if ((mac->link_state < MAC80211_LINKED) && 54 if ((mac->link_state < MAC80211_LINKED) &&
55 (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) { 55 (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) {
56 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, 56 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
57 ("Not connected to any\n")); 57 "Not connected to any\n");
58 58
59 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; 59 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL;
60 60
@@ -67,28 +67,28 @@ void rtl92ce_dm_dynamic_txpower(struct ieee80211_hw *hw)
67 undecorated_smoothed_pwdb = 67 undecorated_smoothed_pwdb =
68 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; 68 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb;
69 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 69 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
70 ("AP Client PWDB = 0x%lx\n", 70 "AP Client PWDB = 0x%lx\n",
71 undecorated_smoothed_pwdb)); 71 undecorated_smoothed_pwdb);
72 } else { 72 } else {
73 undecorated_smoothed_pwdb = 73 undecorated_smoothed_pwdb =
74 rtlpriv->dm.undecorated_smoothed_pwdb; 74 rtlpriv->dm.undecorated_smoothed_pwdb;
75 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 75 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
76 ("STA Default Port PWDB = 0x%lx\n", 76 "STA Default Port PWDB = 0x%lx\n",
77 undecorated_smoothed_pwdb)); 77 undecorated_smoothed_pwdb);
78 } 78 }
79 } else { 79 } else {
80 undecorated_smoothed_pwdb = 80 undecorated_smoothed_pwdb =
81 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; 81 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb;
82 82
83 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 83 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
84 ("AP Ext Port PWDB = 0x%lx\n", 84 "AP Ext Port PWDB = 0x%lx\n",
85 undecorated_smoothed_pwdb)); 85 undecorated_smoothed_pwdb);
86 } 86 }
87 87
88 if (undecorated_smoothed_pwdb >= TX_POWER_NEAR_FIELD_THRESH_LVL2) { 88 if (undecorated_smoothed_pwdb >= TX_POWER_NEAR_FIELD_THRESH_LVL2) {
89 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; 89 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1;
90 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 90 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
91 ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n")); 91 "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n");
92 } else if ((undecorated_smoothed_pwdb < 92 } else if ((undecorated_smoothed_pwdb <
93 (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) && 93 (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) &&
94 (undecorated_smoothed_pwdb >= 94 (undecorated_smoothed_pwdb >=
@@ -96,18 +96,18 @@ void rtl92ce_dm_dynamic_txpower(struct ieee80211_hw *hw)
96 96
97 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; 97 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1;
98 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 98 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
99 ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n")); 99 "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n");
100 } else if (undecorated_smoothed_pwdb < 100 } else if (undecorated_smoothed_pwdb <
101 (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) { 101 (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) {
102 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; 102 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL;
103 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 103 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
104 ("TXHIGHPWRLEVEL_NORMAL\n")); 104 "TXHIGHPWRLEVEL_NORMAL\n");
105 } 105 }
106 106
107 if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) { 107 if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) {
108 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 108 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
109 ("PHY_SetTxPowerLevel8192S() Channel = %d\n", 109 "PHY_SetTxPowerLevel8192S() Channel = %d\n",
110 rtlphy->current_channel)); 110 rtlphy->current_channel);
111 rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel); 111 rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel);
112 } 112 }
113 113
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h
index 07dd9552e82f..26747fa86005 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
index a3deaefa788c..48c7b5d3fc5b 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -141,7 +141,7 @@ void rtl92ce_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
141 } 141 }
142 default: 142 default:
143 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 143 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
144 ("switch case not process\n")); 144 "switch case not processed\n");
145 break; 145 break;
146 } 146 }
147} 147}
@@ -207,7 +207,7 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
207 u8 e_aci; 207 u8 e_aci;
208 208
209 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 209 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
210 ("HW_VAR_SLOT_TIME %x\n", val[0])); 210 "HW_VAR_SLOT_TIME %x\n", val[0]);
211 211
212 rtl_write_byte(rtlpriv, REG_SLOT, val[0]); 212 rtl_write_byte(rtlpriv, REG_SLOT, val[0]);
213 213
@@ -246,8 +246,8 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
246 *val = min_spacing_to_set; 246 *val = min_spacing_to_set;
247 247
248 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 248 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
249 ("Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", 249 "Set HW_VAR_AMPDU_MIN_SPACE: %#x\n",
250 mac->min_space_cfg)); 250 mac->min_space_cfg);
251 251
252 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, 252 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE,
253 mac->min_space_cfg); 253 mac->min_space_cfg);
@@ -261,8 +261,8 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
261 mac->min_space_cfg |= (density_to_set << 3); 261 mac->min_space_cfg |= (density_to_set << 3);
262 262
263 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 263 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
264 ("Set HW_VAR_SHORTGI_DENSITY: %#x\n", 264 "Set HW_VAR_SHORTGI_DENSITY: %#x\n",
265 mac->min_space_cfg)); 265 mac->min_space_cfg);
266 266
267 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, 267 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE,
268 mac->min_space_cfg); 268 mac->min_space_cfg);
@@ -310,8 +310,8 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
310 } 310 }
311 311
312 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 312 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
313 ("Set HW_VAR_AMPDU_FACTOR: %#x\n", 313 "Set HW_VAR_AMPDU_FACTOR: %#x\n",
314 factor_toset)); 314 factor_toset);
315 } 315 }
316 break; 316 break;
317 } 317 }
@@ -348,8 +348,8 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
348 break; 348 break;
349 default: 349 default:
350 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 350 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
351 ("HW_VAR_ACM_CTRL acm set " 351 "HW_VAR_ACM_CTRL acm set failed: eACI is %d\n",
352 "failed: eACI is %d\n", acm)); 352 acm);
353 break; 353 break;
354 } 354 }
355 } else { 355 } else {
@@ -365,14 +365,14 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
365 break; 365 break;
366 default: 366 default:
367 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 367 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
368 ("switch case not process\n")); 368 "switch case not processed\n");
369 break; 369 break;
370 } 370 }
371 } 371 }
372 372
373 RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE, 373 RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE,
374 ("SetHwReg8190pci(): [HW_VAR_ACM_CTRL] " 374 "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n",
375 "Write 0x%X\n", acm_ctrl)); 375 acm_ctrl);
376 rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl); 376 rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl);
377 break; 377 break;
378 } 378 }
@@ -507,8 +507,8 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
507 507
508 } 508 }
509 default: 509 default:
510 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("switch case " 510 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
511 "not process\n")); 511 "switch case not processed\n");
512 break; 512 break;
513 } 513 }
514} 514}
@@ -530,8 +530,8 @@ static bool _rtl92ce_llt_write(struct ieee80211_hw *hw, u32 address, u32 data)
530 530
531 if (count > POLLING_LLT_THRESHOLD) { 531 if (count > POLLING_LLT_THRESHOLD) {
532 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 532 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
533 ("Failed to polling write LLT done at " 533 "Failed to polling write LLT done at address %d!\n",
534 "address %d!\n", address)); 534 address);
535 status = false; 535 status = false;
536 break; 536 break;
537 } 537 }
@@ -669,18 +669,15 @@ static bool _rtl92ce_init_mac(struct ieee80211_hw *hw)
669 udelay(2); 669 udelay(2);
670 670
671 retry = 0; 671 retry = 0;
672 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("reg0xec:%x:%x\n", 672 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "reg0xec:%x:%x\n",
673 rtl_read_dword(rtlpriv, 0xEC), 673 rtl_read_dword(rtlpriv, 0xEC), bytetmp);
674 bytetmp));
675 674
676 while ((bytetmp & BIT(0)) && retry < 1000) { 675 while ((bytetmp & BIT(0)) && retry < 1000) {
677 retry++; 676 retry++;
678 udelay(50); 677 udelay(50);
679 bytetmp = rtl_read_byte(rtlpriv, REG_APS_FSMCO + 1); 678 bytetmp = rtl_read_byte(rtlpriv, REG_APS_FSMCO + 1);
680 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("reg0xec:%x:%x\n", 679 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "reg0xec:%x:%x\n",
681 rtl_read_dword(rtlpriv, 680 rtl_read_dword(rtlpriv, 0xEC), bytetmp);
682 0xEC),
683 bytetmp));
684 udelay(50); 681 udelay(50);
685 } 682 }
686 683
@@ -864,13 +861,13 @@ void rtl92ce_enable_hw_security_config(struct ieee80211_hw *hw)
864 u8 sec_reg_value; 861 u8 sec_reg_value;
865 862
866 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 863 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
867 ("PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n", 864 "PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n",
868 rtlpriv->sec.pairwise_enc_algorithm, 865 rtlpriv->sec.pairwise_enc_algorithm,
869 rtlpriv->sec.group_enc_algorithm)); 866 rtlpriv->sec.group_enc_algorithm);
870 867
871 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { 868 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
872 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("not open " 869 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
873 "hw encryption\n")); 870 "not open hw encryption\n");
874 return; 871 return;
875 } 872 }
876 873
@@ -886,7 +883,7 @@ void rtl92ce_enable_hw_security_config(struct ieee80211_hw *hw)
886 rtl_write_byte(rtlpriv, REG_CR + 1, 0x02); 883 rtl_write_byte(rtlpriv, REG_CR + 1, 0x02);
887 884
888 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 885 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
889 ("The SECR-value %x\n", sec_reg_value)); 886 "The SECR-value %x\n", sec_reg_value);
890 887
891 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value); 888 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value);
892 889
@@ -910,7 +907,7 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw)
910 rtlpriv->intf_ops->disable_aspm(hw); 907 rtlpriv->intf_ops->disable_aspm(hw);
911 rtstatus = _rtl92ce_init_mac(hw); 908 rtstatus = _rtl92ce_init_mac(hw);
912 if (rtstatus != true) { 909 if (rtstatus != true) {
913 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Init MAC failed\n")); 910 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Init MAC failed\n");
914 err = 1; 911 err = 1;
915 return err; 912 return err;
916 } 913 }
@@ -918,13 +915,9 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw)
918 err = rtl92c_download_fw(hw); 915 err = rtl92c_download_fw(hw);
919 if (err) { 916 if (err) {
920 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 917 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
921 ("Failed to download FW. Init HW " 918 "Failed to download FW. Init HW without FW now..\n");
922 "without FW now..\n"));
923 err = 1; 919 err = 1;
924 rtlhal->fw_ready = false;
925 return err; 920 return err;
926 } else {
927 rtlhal->fw_ready = true;
928 } 921 }
929 922
930 rtlhal->last_hmeboxnum = 0; 923 rtlhal->last_hmeboxnum = 0;
@@ -968,12 +961,12 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw)
968 tmp_u1b = efuse_read_1byte(hw, 0x1FA); 961 tmp_u1b = efuse_read_1byte(hw, 0x1FA);
969 if (!(tmp_u1b & BIT(0))) { 962 if (!(tmp_u1b & BIT(0))) {
970 rtl_set_rfreg(hw, RF90_PATH_A, 0x15, 0x0F, 0x05); 963 rtl_set_rfreg(hw, RF90_PATH_A, 0x15, 0x0F, 0x05);
971 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("PA BIAS path A\n")); 964 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "PA BIAS path A\n");
972 } 965 }
973 966
974 if (!(tmp_u1b & BIT(1)) && is92c) { 967 if (!(tmp_u1b & BIT(1)) && is92c) {
975 rtl_set_rfreg(hw, RF90_PATH_B, 0x15, 0x0F, 0x05); 968 rtl_set_rfreg(hw, RF90_PATH_B, 0x15, 0x0F, 0x05);
976 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("PA BIAS path B\n")); 969 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "PA BIAS path B\n");
977 } 970 }
978 971
979 if (!(tmp_u1b & BIT(4))) { 972 if (!(tmp_u1b & BIT(4))) {
@@ -982,7 +975,7 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw)
982 rtl_write_byte(rtlpriv, 0x16, tmp_u1b | 0x80); 975 rtl_write_byte(rtlpriv, 0x16, tmp_u1b | 0x80);
983 udelay(10); 976 udelay(10);
984 rtl_write_byte(rtlpriv, 0x16, tmp_u1b | 0x90); 977 rtl_write_byte(rtlpriv, 0x16, tmp_u1b | 0x90);
985 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("under 1.5V\n")); 978 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "under 1.5V\n");
986 } 979 }
987 rtl92c_dm_init(hw); 980 rtl92c_dm_init(hw);
988 rtlpci->being_init_adapter = false; 981 rtlpci->being_init_adapter = false;
@@ -995,6 +988,7 @@ static enum version_8192c _rtl92ce_read_chip_version(struct ieee80211_hw *hw)
995 struct rtl_phy *rtlphy = &(rtlpriv->phy); 988 struct rtl_phy *rtlphy = &(rtlpriv->phy);
996 enum version_8192c version = VERSION_UNKNOWN; 989 enum version_8192c version = VERSION_UNKNOWN;
997 u32 value32; 990 u32 value32;
991 const char *versionid;
998 992
999 value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG); 993 value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG);
1000 if (value32 & TRP_VAUX_EN) { 994 if (value32 & TRP_VAUX_EN) {
@@ -1007,27 +1001,25 @@ static enum version_8192c _rtl92ce_read_chip_version(struct ieee80211_hw *hw)
1007 1001
1008 switch (version) { 1002 switch (version) {
1009 case VERSION_B_CHIP_92C: 1003 case VERSION_B_CHIP_92C:
1010 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1004 versionid = "B_CHIP_92C";
1011 ("Chip Version ID: VERSION_B_CHIP_92C.\n"));
1012 break; 1005 break;
1013 case VERSION_B_CHIP_88C: 1006 case VERSION_B_CHIP_88C:
1014 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1007 versionid = "B_CHIP_88C";
1015 ("Chip Version ID: VERSION_B_CHIP_88C.\n"));
1016 break; 1008 break;
1017 case VERSION_A_CHIP_92C: 1009 case VERSION_A_CHIP_92C:
1018 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1010 versionid = "A_CHIP_92C";
1019 ("Chip Version ID: VERSION_A_CHIP_92C.\n"));
1020 break; 1011 break;
1021 case VERSION_A_CHIP_88C: 1012 case VERSION_A_CHIP_88C:
1022 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1013 versionid = "A_CHIP_88C";
1023 ("Chip Version ID: VERSION_A_CHIP_88C.\n"));
1024 break; 1014 break;
1025 default: 1015 default:
1026 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1016 versionid = "Unknown. Bug?";
1027 ("Chip Version ID: Unknown. Bug?\n"));
1028 break; 1017 break;
1029 } 1018 }
1030 1019
1020 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1021 "Chip Version ID: %s\n", versionid);
1022
1031 switch (version & 0x3) { 1023 switch (version & 0x3) {
1032 case CHIP_88C: 1024 case CHIP_88C:
1033 rtlphy->rf_type = RF_1T1R; 1025 rtlphy->rf_type = RF_1T1R;
@@ -1041,13 +1033,12 @@ static enum version_8192c _rtl92ce_read_chip_version(struct ieee80211_hw *hw)
1041 default: 1033 default:
1042 rtlphy->rf_type = RF_1T1R; 1034 rtlphy->rf_type = RF_1T1R;
1043 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1035 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1044 ("ERROR RF_Type is set!!")); 1036 "ERROR RF_Type is set!!\n");
1045 break; 1037 break;
1046 } 1038 }
1047 1039
1048 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1040 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Chip RF Type: %s\n",
1049 ("Chip RF Type: %s\n", (rtlphy->rf_type == RF_2T2R) ? 1041 rtlphy->rf_type == RF_2T2R ? "RF_2T2R" : "RF_1T1R");
1050 "RF_2T2R" : "RF_1T1R"));
1051 1042
1052 return version; 1043 return version;
1053} 1044}
@@ -1069,8 +1060,8 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
1069 _rtl92ce_disable_bcn_sub_func(hw); 1060 _rtl92ce_disable_bcn_sub_func(hw);
1070 } else { 1061 } else {
1071 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1062 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1072 ("Set HW_VAR_MEDIA_STATUS: " 1063 "Set HW_VAR_MEDIA_STATUS: No such media status(%x)\n",
1073 "No such media status(%x).\n", type)); 1064 type);
1074 } 1065 }
1075 1066
1076 switch (type) { 1067 switch (type) {
@@ -1078,27 +1069,27 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
1078 bt_msr |= MSR_NOLINK; 1069 bt_msr |= MSR_NOLINK;
1079 ledaction = LED_CTL_LINK; 1070 ledaction = LED_CTL_LINK;
1080 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1071 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1081 ("Set Network type to NO LINK!\n")); 1072 "Set Network type to NO LINK!\n");
1082 break; 1073 break;
1083 case NL80211_IFTYPE_ADHOC: 1074 case NL80211_IFTYPE_ADHOC:
1084 bt_msr |= MSR_ADHOC; 1075 bt_msr |= MSR_ADHOC;
1085 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1076 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1086 ("Set Network type to Ad Hoc!\n")); 1077 "Set Network type to Ad Hoc!\n");
1087 break; 1078 break;
1088 case NL80211_IFTYPE_STATION: 1079 case NL80211_IFTYPE_STATION:
1089 bt_msr |= MSR_INFRA; 1080 bt_msr |= MSR_INFRA;
1090 ledaction = LED_CTL_LINK; 1081 ledaction = LED_CTL_LINK;
1091 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1082 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1092 ("Set Network type to STA!\n")); 1083 "Set Network type to STA!\n");
1093 break; 1084 break;
1094 case NL80211_IFTYPE_AP: 1085 case NL80211_IFTYPE_AP:
1095 bt_msr |= MSR_AP; 1086 bt_msr |= MSR_AP;
1096 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1087 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1097 ("Set Network type to AP!\n")); 1088 "Set Network type to AP!\n");
1098 break; 1089 break;
1099 default: 1090 default:
1100 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1091 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1101 ("Network type %d not support!\n", type)); 1092 "Network type %d not supported!\n", type);
1102 return 1; 1093 return 1;
1103 break; 1094 break;
1104 1095
@@ -1171,7 +1162,7 @@ void rtl92ce_set_qos(struct ieee80211_hw *hw, int aci)
1171 rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, 0x2f3222); 1162 rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, 0x2f3222);
1172 break; 1163 break;
1173 default: 1164 default:
1174 RT_ASSERT(false, ("invalid aci: %d !\n", aci)); 1165 RT_ASSERT(false, "invalid aci: %d !\n", aci);
1175 break; 1166 break;
1176 } 1167 }
1177} 1168}
@@ -1199,7 +1190,6 @@ static void _rtl92ce_poweroff_adapter(struct ieee80211_hw *hw)
1199{ 1190{
1200 struct rtl_priv *rtlpriv = rtl_priv(hw); 1191 struct rtl_priv *rtlpriv = rtl_priv(hw);
1201 struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); 1192 struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw);
1202 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1203 u8 u1b_tmp; 1193 u8 u1b_tmp;
1204 u32 u4b_tmp; 1194 u32 u4b_tmp;
1205 1195
@@ -1210,7 +1200,7 @@ static void _rtl92ce_poweroff_adapter(struct ieee80211_hw *hw)
1210 rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x40); 1200 rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x40);
1211 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); 1201 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2);
1212 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE0); 1202 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE0);
1213 if ((rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(7)) && rtlhal->fw_ready) 1203 if (rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(7))
1214 rtl92c_firmware_selfreset(hw); 1204 rtl92c_firmware_selfreset(hw);
1215 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, 0x51); 1205 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, 0x51);
1216 rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00); 1206 rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00);
@@ -1300,7 +1290,7 @@ void rtl92ce_set_beacon_interval(struct ieee80211_hw *hw)
1300 u16 bcn_interval = mac->beacon_interval; 1290 u16 bcn_interval = mac->beacon_interval;
1301 1291
1302 RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG, 1292 RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG,
1303 ("beacon_interval:%d\n", bcn_interval)); 1293 "beacon_interval:%d\n", bcn_interval);
1304 rtl92ce_disable_interrupt(hw); 1294 rtl92ce_disable_interrupt(hw);
1305 rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval); 1295 rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval);
1306 rtl92ce_enable_interrupt(hw); 1296 rtl92ce_enable_interrupt(hw);
@@ -1312,8 +1302,8 @@ void rtl92ce_update_interrupt_mask(struct ieee80211_hw *hw,
1312 struct rtl_priv *rtlpriv = rtl_priv(hw); 1302 struct rtl_priv *rtlpriv = rtl_priv(hw);
1313 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1303 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1314 1304
1315 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, 1305 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, "add_msr:%x, rm_msr:%x\n",
1316 ("add_msr:%x, rm_msr:%x\n", add_msr, rm_msr)); 1306 add_msr, rm_msr);
1317 1307
1318 if (add_msr) 1308 if (add_msr)
1319 rtlpci->irq_mask[0] |= add_msr; 1309 rtlpci->irq_mask[0] |= add_msr;
@@ -1367,25 +1357,24 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
1367 for (rf_path = 0; rf_path < 2; rf_path++) 1357 for (rf_path = 0; rf_path < 2; rf_path++)
1368 for (i = 0; i < 3; i++) 1358 for (i = 0; i < 3; i++)
1369 RTPRINT(rtlpriv, FINIT, INIT_EEPROM, 1359 RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
1370 ("RF(%d) EEPROM CCK Area(%d) = 0x%x\n", rf_path, 1360 "RF(%d) EEPROM CCK Area(%d) = 0x%x\n",
1371 i, 1361 rf_path, i,
1372 rtlefuse-> 1362 rtlefuse->
1373 eeprom_chnlarea_txpwr_cck[rf_path][i])); 1363 eeprom_chnlarea_txpwr_cck[rf_path][i]);
1374 for (rf_path = 0; rf_path < 2; rf_path++) 1364 for (rf_path = 0; rf_path < 2; rf_path++)
1375 for (i = 0; i < 3; i++) 1365 for (i = 0; i < 3; i++)
1376 RTPRINT(rtlpriv, FINIT, INIT_EEPROM, 1366 RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
1377 ("RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n", 1367 "RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n",
1378 rf_path, i, 1368 rf_path, i,
1379 rtlefuse-> 1369 rtlefuse->
1380 eeprom_chnlarea_txpwr_ht40_1s[rf_path][i])); 1370 eeprom_chnlarea_txpwr_ht40_1s[rf_path][i]);
1381 for (rf_path = 0; rf_path < 2; rf_path++) 1371 for (rf_path = 0; rf_path < 2; rf_path++)
1382 for (i = 0; i < 3; i++) 1372 for (i = 0; i < 3; i++)
1383 RTPRINT(rtlpriv, FINIT, INIT_EEPROM, 1373 RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
1384 ("RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n", 1374 "RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n",
1385 rf_path, i, 1375 rf_path, i,
1386 rtlefuse-> 1376 rtlefuse->
1387 eeprom_chnlarea_txpwr_ht40_2sdiif[rf_path] 1377 eeprom_chnlarea_txpwr_ht40_2sdiif[rf_path][i]);
1388 [i]));
1389 1378
1390 for (rf_path = 0; rf_path < 2; rf_path++) { 1379 for (rf_path = 0; rf_path < 2; rf_path++) {
1391 for (i = 0; i < 14; i++) { 1380 for (i = 0; i < 14; i++) {
@@ -1416,11 +1405,11 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
1416 1405
1417 for (i = 0; i < 14; i++) { 1406 for (i = 0; i < 14; i++) {
1418 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1407 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1419 ("RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = " 1408 "RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = [0x%x / 0x%x / 0x%x]\n",
1420 "[0x%x / 0x%x / 0x%x]\n", rf_path, i, 1409 rf_path, i,
1421 rtlefuse->txpwrlevel_cck[rf_path][i], 1410 rtlefuse->txpwrlevel_cck[rf_path][i],
1422 rtlefuse->txpwrlevel_ht40_1s[rf_path][i], 1411 rtlefuse->txpwrlevel_ht40_1s[rf_path][i],
1423 rtlefuse->txpwrlevel_ht40_2s[rf_path][i])); 1412 rtlefuse->txpwrlevel_ht40_2s[rf_path][i]);
1424 } 1413 }
1425 } 1414 }
1426 1415
@@ -1457,13 +1446,13 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
1457 } 1446 }
1458 1447
1459 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1448 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1460 ("RF-%d pwrgroup_ht20[%d] = 0x%x\n", 1449 "RF-%d pwrgroup_ht20[%d] = 0x%x\n",
1461 rf_path, i, 1450 rf_path, i,
1462 rtlefuse->pwrgroup_ht20[rf_path][i])); 1451 rtlefuse->pwrgroup_ht20[rf_path][i]);
1463 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1452 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1464 ("RF-%d pwrgroup_ht40[%d] = 0x%x\n", 1453 "RF-%d pwrgroup_ht40[%d] = 0x%x\n",
1465 rf_path, i, 1454 rf_path, i,
1466 rtlefuse->pwrgroup_ht40[rf_path][i])); 1455 rtlefuse->pwrgroup_ht40[rf_path][i]);
1467 } 1456 }
1468 } 1457 }
1469 1458
@@ -1502,27 +1491,27 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
1502 1491
1503 for (i = 0; i < 14; i++) 1492 for (i = 0; i < 14; i++)
1504 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1493 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1505 ("RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", i, 1494 "RF-A Ht20 to HT40 Diff[%d] = 0x%x\n",
1506 rtlefuse->txpwr_ht20diff[RF90_PATH_A][i])); 1495 i, rtlefuse->txpwr_ht20diff[RF90_PATH_A][i]);
1507 for (i = 0; i < 14; i++) 1496 for (i = 0; i < 14; i++)
1508 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1497 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1509 ("RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", i, 1498 "RF-A Legacy to Ht40 Diff[%d] = 0x%x\n",
1510 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i])); 1499 i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i]);
1511 for (i = 0; i < 14; i++) 1500 for (i = 0; i < 14; i++)
1512 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1501 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1513 ("RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", i, 1502 "RF-B Ht20 to HT40 Diff[%d] = 0x%x\n",
1514 rtlefuse->txpwr_ht20diff[RF90_PATH_B][i])); 1503 i, rtlefuse->txpwr_ht20diff[RF90_PATH_B][i]);
1515 for (i = 0; i < 14; i++) 1504 for (i = 0; i < 14; i++)
1516 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1505 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1517 ("RF-B Legacy to HT40 Diff[%d] = 0x%x\n", i, 1506 "RF-B Legacy to HT40 Diff[%d] = 0x%x\n",
1518 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i])); 1507 i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i]);
1519 1508
1520 if (!autoload_fail) 1509 if (!autoload_fail)
1521 rtlefuse->eeprom_regulatory = (hwinfo[RF_OPTION1] & 0x7); 1510 rtlefuse->eeprom_regulatory = (hwinfo[RF_OPTION1] & 0x7);
1522 else 1511 else
1523 rtlefuse->eeprom_regulatory = 0; 1512 rtlefuse->eeprom_regulatory = 0;
1524 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1513 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1525 ("eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory)); 1514 "eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory);
1526 1515
1527 if (!autoload_fail) { 1516 if (!autoload_fail) {
1528 rtlefuse->eeprom_tssi[RF90_PATH_A] = hwinfo[EEPROM_TSSI_A]; 1517 rtlefuse->eeprom_tssi[RF90_PATH_A] = hwinfo[EEPROM_TSSI_A];
@@ -1531,10 +1520,9 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
1531 rtlefuse->eeprom_tssi[RF90_PATH_A] = EEPROM_DEFAULT_TSSI; 1520 rtlefuse->eeprom_tssi[RF90_PATH_A] = EEPROM_DEFAULT_TSSI;
1532 rtlefuse->eeprom_tssi[RF90_PATH_B] = EEPROM_DEFAULT_TSSI; 1521 rtlefuse->eeprom_tssi[RF90_PATH_B] = EEPROM_DEFAULT_TSSI;
1533 } 1522 }
1534 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1523 RTPRINT(rtlpriv, FINIT, INIT_TxPower, "TSSI_A = 0x%x, TSSI_B = 0x%x\n",
1535 ("TSSI_A = 0x%x, TSSI_B = 0x%x\n", 1524 rtlefuse->eeprom_tssi[RF90_PATH_A],
1536 rtlefuse->eeprom_tssi[RF90_PATH_A], 1525 rtlefuse->eeprom_tssi[RF90_PATH_B]);
1537 rtlefuse->eeprom_tssi[RF90_PATH_B]));
1538 1526
1539 if (!autoload_fail) 1527 if (!autoload_fail)
1540 tempval = hwinfo[EEPROM_THERMAL_METER]; 1528 tempval = hwinfo[EEPROM_THERMAL_METER];
@@ -1547,7 +1535,7 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
1547 1535
1548 rtlefuse->thermalmeter[0] = rtlefuse->eeprom_thermalmeter; 1536 rtlefuse->thermalmeter[0] = rtlefuse->eeprom_thermalmeter;
1549 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1537 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1550 ("thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter)); 1538 "thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter);
1551} 1539}
1552 1540
1553static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw) 1541static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw)
@@ -1567,19 +1555,19 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw)
1567 HWSET_MAX_SIZE); 1555 HWSET_MAX_SIZE);
1568 } else if (rtlefuse->epromtype == EEPROM_93C46) { 1556 } else if (rtlefuse->epromtype == EEPROM_93C46) {
1569 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1557 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1570 ("RTL819X Not boot from eeprom, check it !!")); 1558 "RTL819X Not boot from eeprom, check it !!");
1571 } 1559 }
1572 1560
1573 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, ("MAP\n"), 1561 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP",
1574 hwinfo, HWSET_MAX_SIZE); 1562 hwinfo, HWSET_MAX_SIZE);
1575 1563
1576 eeprom_id = *((u16 *)&hwinfo[0]); 1564 eeprom_id = *((u16 *)&hwinfo[0]);
1577 if (eeprom_id != RTL8190_EEPROM_ID) { 1565 if (eeprom_id != RTL8190_EEPROM_ID) {
1578 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1566 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1579 ("EEPROM ID(%#x) is invalid!!\n", eeprom_id)); 1567 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
1580 rtlefuse->autoload_failflag = true; 1568 rtlefuse->autoload_failflag = true;
1581 } else { 1569 } else {
1582 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); 1570 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
1583 rtlefuse->autoload_failflag = false; 1571 rtlefuse->autoload_failflag = false;
1584 } 1572 }
1585 1573
@@ -1591,8 +1579,7 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw)
1591 *((u16 *) (&rtlefuse->dev_addr[i])) = usvalue; 1579 *((u16 *) (&rtlefuse->dev_addr[i])) = usvalue;
1592 } 1580 }
1593 1581
1594 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1582 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%pM\n", rtlefuse->dev_addr);
1595 ("%pM\n", rtlefuse->dev_addr));
1596 1583
1597 _rtl92ce_read_txpower_info_from_hwpg(hw, 1584 _rtl92ce_read_txpower_info_from_hwpg(hw,
1598 rtlefuse->autoload_failflag, 1585 rtlefuse->autoload_failflag,
@@ -1608,7 +1595,7 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw)
1608 rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID]; 1595 rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID];
1609 1596
1610 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1597 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1611 ("EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid)); 1598 "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid);
1612 1599
1613 /* set channel paln to world wide 13 */ 1600 /* set channel paln to world wide 13 */
1614 rtlefuse->channel_plan = COUNTRY_CODE_WORLD_WIDE_13; 1601 rtlefuse->channel_plan = COUNTRY_CODE_WORLD_WIDE_13;
@@ -1662,7 +1649,7 @@ static void _rtl92ce_hal_customized_behavior(struct ieee80211_hw *hw)
1662 break; 1649 break;
1663 } 1650 }
1664 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1651 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1665 ("RT Customized ID: 0x%02X\n", rtlhal->oem_id)); 1652 "RT Customized ID: 0x%02X\n", rtlhal->oem_id);
1666} 1653}
1667 1654
1668void rtl92ce_read_eeprom_info(struct ieee80211_hw *hw) 1655void rtl92ce_read_eeprom_info(struct ieee80211_hw *hw)
@@ -1679,22 +1666,22 @@ void rtl92ce_read_eeprom_info(struct ieee80211_hw *hw)
1679 else 1666 else
1680 rtlpriv->dm.rfpath_rxenable[0] = 1667 rtlpriv->dm.rfpath_rxenable[0] =
1681 rtlpriv->dm.rfpath_rxenable[1] = true; 1668 rtlpriv->dm.rfpath_rxenable[1] = true;
1682 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("VersionID = 0x%4x\n", 1669 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "VersionID = 0x%4x\n",
1683 rtlhal->version)); 1670 rtlhal->version);
1684 tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR); 1671 tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR);
1685 if (tmp_u1b & BIT(4)) { 1672 if (tmp_u1b & BIT(4)) {
1686 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EEPROM\n")); 1673 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EEPROM\n");
1687 rtlefuse->epromtype = EEPROM_93C46; 1674 rtlefuse->epromtype = EEPROM_93C46;
1688 } else { 1675 } else {
1689 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EFUSE\n")); 1676 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EFUSE\n");
1690 rtlefuse->epromtype = EEPROM_BOOT_EFUSE; 1677 rtlefuse->epromtype = EEPROM_BOOT_EFUSE;
1691 } 1678 }
1692 if (tmp_u1b & BIT(5)) { 1679 if (tmp_u1b & BIT(5)) {
1693 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); 1680 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
1694 rtlefuse->autoload_failflag = false; 1681 rtlefuse->autoload_failflag = false;
1695 _rtl92ce_read_adapter_info(hw); 1682 _rtl92ce_read_adapter_info(hw);
1696 } else { 1683 } else {
1697 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Autoload ERR!!\n")); 1684 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Autoload ERR!!\n");
1698 } 1685 }
1699 _rtl92ce_hal_customized_behavior(hw); 1686 _rtl92ce_hal_customized_behavior(hw);
1700} 1687}
@@ -1790,8 +1777,8 @@ static void rtl92ce_update_hal_rate_table(struct ieee80211_hw *hw,
1790 1777
1791 rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value); 1778 rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value);
1792 1779
1793 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, 1780 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "%x\n",
1794 ("%x\n", rtl_read_dword(rtlpriv, REG_ARFR0))); 1781 rtl_read_dword(rtlpriv, REG_ARFR0));
1795} 1782}
1796 1783
1797static void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw, 1784static void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw,
@@ -1919,16 +1906,15 @@ static void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw,
1919 break; 1906 break;
1920 } 1907 }
1921 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, 1908 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG,
1922 ("ratr_bitmap :%x\n", ratr_bitmap)); 1909 "ratr_bitmap :%x\n", ratr_bitmap);
1923 *(u32 *)&rate_mask = EF4BYTE((ratr_bitmap & 0x0fffffff) | 1910 *(u32 *)&rate_mask = EF4BYTE((ratr_bitmap & 0x0fffffff) |
1924 (ratr_index << 28)); 1911 (ratr_index << 28));
1925 rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80; 1912 rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80;
1926 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, ("Rate_index:%x, " 1913 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG,
1927 "ratr_val:%x, %x:%x:%x:%x:%x\n", 1914 "Rate_index:%x, ratr_val:%x, %x:%x:%x:%x:%x\n",
1928 ratr_index, ratr_bitmap, 1915 ratr_index, ratr_bitmap,
1929 rate_mask[0], rate_mask[1], 1916 rate_mask[0], rate_mask[1], rate_mask[2], rate_mask[3],
1930 rate_mask[2], rate_mask[3], 1917 rate_mask[4]);
1931 rate_mask[4]));
1932 rtl92c_fill_h2c_cmd(hw, H2C_RA_MASK, 5, rate_mask); 1918 rtl92c_fill_h2c_cmd(hw, H2C_RA_MASK, 5, rate_mask);
1933 1919
1934 if (macid != 0) 1920 if (macid != 0)
@@ -1994,7 +1980,7 @@ bool rtl92ce_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid)
1994 1980
1995 if ((ppsc->hwradiooff) && (e_rfpowerstate_toset == ERFON)) { 1981 if ((ppsc->hwradiooff) && (e_rfpowerstate_toset == ERFON)) {
1996 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 1982 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
1997 ("GPIOChangeRF - HW Radio ON, RF ON\n")); 1983 "GPIOChangeRF - HW Radio ON, RF ON\n");
1998 1984
1999 e_rfpowerstate_toset = ERFON; 1985 e_rfpowerstate_toset = ERFON;
2000 ppsc->hwradiooff = false; 1986 ppsc->hwradiooff = false;
@@ -2002,7 +1988,7 @@ bool rtl92ce_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid)
2002 } else if ((ppsc->hwradiooff == false) 1988 } else if ((ppsc->hwradiooff == false)
2003 && (e_rfpowerstate_toset == ERFOFF)) { 1989 && (e_rfpowerstate_toset == ERFOFF)) {
2004 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 1990 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
2005 ("GPIOChangeRF - HW Radio OFF, RF OFF\n")); 1991 "GPIOChangeRF - HW Radio OFF, RF OFF\n");
2006 1992
2007 e_rfpowerstate_toset = ERFOFF; 1993 e_rfpowerstate_toset = ERFOFF;
2008 ppsc->hwradiooff = true; 1994 ppsc->hwradiooff = true;
@@ -2053,7 +2039,7 @@ void rtl92ce_set_key(struct ieee80211_hw *hw, u32 key_index,
2053 u8 cam_offset = 0; 2039 u8 cam_offset = 0;
2054 u8 clear_number = 5; 2040 u8 clear_number = 5;
2055 2041
2056 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("clear_all\n")); 2042 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "clear_all\n");
2057 2043
2058 for (idx = 0; idx < clear_number; idx++) { 2044 for (idx = 0; idx < clear_number; idx++) {
2059 rtl_cam_mark_invalid(hw, cam_offset + idx); 2045 rtl_cam_mark_invalid(hw, cam_offset + idx);
@@ -2081,8 +2067,8 @@ void rtl92ce_set_key(struct ieee80211_hw *hw, u32 key_index,
2081 enc_algo = CAM_AES; 2067 enc_algo = CAM_AES;
2082 break; 2068 break;
2083 default: 2069 default:
2084 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("switch case " 2070 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2085 "not process\n")); 2071 "switch case not processed\n");
2086 enc_algo = CAM_TKIP; 2072 enc_algo = CAM_TKIP;
2087 break; 2073 break;
2088 } 2074 }
@@ -2100,9 +2086,8 @@ void rtl92ce_set_key(struct ieee80211_hw *hw, u32 key_index,
2100 p_macaddr); 2086 p_macaddr);
2101 if (entry_id >= TOTAL_CAM_ENTRY) { 2087 if (entry_id >= TOTAL_CAM_ENTRY) {
2102 RT_TRACE(rtlpriv, COMP_SEC, 2088 RT_TRACE(rtlpriv, COMP_SEC,
2103 DBG_EMERG, 2089 DBG_EMERG,
2104 ("Can not find free hw" 2090 "Can not find free hw security cam entry\n");
2105 " security cam entry\n"));
2106 return; 2091 return;
2107 } 2092 }
2108 } else { 2093 } else {
@@ -2116,31 +2101,31 @@ void rtl92ce_set_key(struct ieee80211_hw *hw, u32 key_index,
2116 2101
2117 if (rtlpriv->sec.key_len[key_index] == 0) { 2102 if (rtlpriv->sec.key_len[key_index] == 0) {
2118 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2103 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2119 ("delete one entry, entry_id is %d\n", 2104 "delete one entry, entry_id is %d\n",
2120 entry_id)); 2105 entry_id);
2121 if (mac->opmode == NL80211_IFTYPE_AP) 2106 if (mac->opmode == NL80211_IFTYPE_AP)
2122 rtl_cam_del_entry(hw, p_macaddr); 2107 rtl_cam_del_entry(hw, p_macaddr);
2123 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id); 2108 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id);
2124 } else { 2109 } else {
2125 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 2110 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
2126 ("The insert KEY length is %d\n", 2111 "The insert KEY length is %d\n",
2127 rtlpriv->sec.key_len[PAIRWISE_KEYIDX])); 2112 rtlpriv->sec.key_len[PAIRWISE_KEYIDX]);
2128 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 2113 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
2129 ("The insert KEY is %x %x\n", 2114 "The insert KEY is %x %x\n",
2130 rtlpriv->sec.key_buf[0][0], 2115 rtlpriv->sec.key_buf[0][0],
2131 rtlpriv->sec.key_buf[0][1])); 2116 rtlpriv->sec.key_buf[0][1]);
2132 2117
2133 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2118 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2134 ("add one entry\n")); 2119 "add one entry\n");
2135 if (is_pairwise) { 2120 if (is_pairwise) {
2136 RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD, 2121 RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD,
2137 "Pairwiase Key content :", 2122 "Pairwise Key content",
2138 rtlpriv->sec.pairwise_key, 2123 rtlpriv->sec.pairwise_key,
2139 rtlpriv->sec. 2124 rtlpriv->sec.
2140 key_len[PAIRWISE_KEYIDX]); 2125 key_len[PAIRWISE_KEYIDX]);
2141 2126
2142 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2127 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2143 ("set Pairwiase key\n")); 2128 "set Pairwise key\n");
2144 2129
2145 rtl_cam_add_one_entry(hw, macaddr, key_index, 2130 rtl_cam_add_one_entry(hw, macaddr, key_index,
2146 entry_id, enc_algo, 2131 entry_id, enc_algo,
@@ -2149,7 +2134,7 @@ void rtl92ce_set_key(struct ieee80211_hw *hw, u32 key_index,
2149 key_buf[key_index]); 2134 key_buf[key_index]);
2150 } else { 2135 } else {
2151 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2136 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2152 ("set group key\n")); 2137 "set group key\n");
2153 2138
2154 if (mac->opmode == NL80211_IFTYPE_ADHOC) { 2139 if (mac->opmode == NL80211_IFTYPE_ADHOC) {
2155 rtl_cam_add_one_entry(hw, 2140 rtl_cam_add_one_entry(hw,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.h b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.h
index 07dbe3e340a5..52a3aea9b3de 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/led.c b/drivers/net/wireless/rtlwifi/rtl8192ce/led.c
index 28a1a707d09c..8283e9b27639 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/led.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/led.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -45,8 +45,8 @@ void rtl92ce_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
45 u8 ledcfg; 45 u8 ledcfg;
46 struct rtl_priv *rtlpriv = rtl_priv(hw); 46 struct rtl_priv *rtlpriv = rtl_priv(hw);
47 47
48 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, 48 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n",
49 ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); 49 REG_LEDCFG2, pled->ledpin);
50 50
51 ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); 51 ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2);
52 52
@@ -62,7 +62,7 @@ void rtl92ce_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
62 break; 62 break;
63 default: 63 default:
64 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 64 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
65 ("switch case not process\n")); 65 "switch case not processed\n");
66 break; 66 break;
67 } 67 }
68 pled->ledon = true; 68 pled->ledon = true;
@@ -74,8 +74,8 @@ void rtl92ce_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
74 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); 74 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
75 u8 ledcfg; 75 u8 ledcfg;
76 76
77 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, 77 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n",
78 ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); 78 REG_LEDCFG2, pled->ledpin);
79 79
80 ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); 80 ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2);
81 81
@@ -97,7 +97,7 @@ void rtl92ce_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
97 break; 97 break;
98 default: 98 default:
99 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 99 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
100 ("switch case not process\n")); 100 "switch case not processed\n");
101 break; 101 break;
102 } 102 }
103 pled->ledon = false; 103 pled->ledon = false;
@@ -145,7 +145,7 @@ void rtl92ce_led_control(struct ieee80211_hw *hw,
145 ledaction == LED_CTL_POWER_ON)) { 145 ledaction == LED_CTL_POWER_ON)) {
146 return; 146 return;
147 } 147 }
148 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, ("ledaction %d.\n", 148 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "ledaction %d\n",
149 ledaction)); 149 ledaction);
150 _rtl92ce_sw_led_control(hw, ledaction); 150 _rtl92ce_sw_led_control(hw, ledaction);
151} 151}
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/led.h b/drivers/net/wireless/rtlwifi/rtl8192ce/led.h
index 7dfccea2095b..c5761066d383 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/led.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/led.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c
index 3b585aadabfc..c64daf25566a 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -47,9 +47,9 @@ u32 rtl92c_phy_query_rf_reg(struct ieee80211_hw *hw,
47 u32 original_value, readback_value, bitshift; 47 u32 original_value, readback_value, bitshift;
48 struct rtl_phy *rtlphy = &(rtlpriv->phy); 48 struct rtl_phy *rtlphy = &(rtlpriv->phy);
49 49
50 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " 50 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
51 "rfpath(%#x), bitmask(%#x)\n", 51 "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
52 regaddr, rfpath, bitmask)); 52 regaddr, rfpath, bitmask);
53 53
54 spin_lock(&rtlpriv->locks.rf_lock); 54 spin_lock(&rtlpriv->locks.rf_lock);
55 55
@@ -67,9 +67,8 @@ u32 rtl92c_phy_query_rf_reg(struct ieee80211_hw *hw,
67 spin_unlock(&rtlpriv->locks.rf_lock); 67 spin_unlock(&rtlpriv->locks.rf_lock);
68 68
69 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, 69 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
70 ("regaddr(%#x), rfpath(%#x), " 70 "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n",
71 "bitmask(%#x), original_value(%#x)\n", 71 regaddr, rfpath, bitmask, original_value);
72 regaddr, rfpath, bitmask, original_value));
73 72
74 return readback_value; 73 return readback_value;
75} 74}
@@ -121,8 +120,8 @@ void rtl92ce_phy_set_rf_reg(struct ieee80211_hw *hw,
121 u32 original_value, bitshift; 120 u32 original_value, bitshift;
122 121
123 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, 122 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
124 ("regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", 123 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
125 regaddr, bitmask, data, rfpath)); 124 regaddr, bitmask, data, rfpath);
126 125
127 spin_lock(&rtlpriv->locks.rf_lock); 126 spin_lock(&rtlpriv->locks.rf_lock);
128 127
@@ -153,10 +152,9 @@ void rtl92ce_phy_set_rf_reg(struct ieee80211_hw *hw,
153 152
154 spin_unlock(&rtlpriv->locks.rf_lock); 153 spin_unlock(&rtlpriv->locks.rf_lock);
155 154
156 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " 155 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
157 "bitmask(%#x), data(%#x), " 156 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
158 "rfpath(%#x)\n", regaddr, 157 regaddr, bitmask, data, rfpath);
159 bitmask, data, rfpath));
160} 158}
161 159
162static bool _rtl92c_phy_config_mac_with_headerfile(struct ieee80211_hw *hw) 160static bool _rtl92c_phy_config_mac_with_headerfile(struct ieee80211_hw *hw)
@@ -166,11 +164,10 @@ static bool _rtl92c_phy_config_mac_with_headerfile(struct ieee80211_hw *hw)
166 u32 arraylength; 164 u32 arraylength;
167 u32 *ptrarray; 165 u32 *ptrarray;
168 166
169 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Read Rtl819XMACPHY_Array\n")); 167 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Read Rtl819XMACPHY_Array\n");
170 arraylength = MAC_2T_ARRAYLENGTH; 168 arraylength = MAC_2T_ARRAYLENGTH;
171 ptrarray = RTL8192CEMAC_2T_ARRAY; 169 ptrarray = RTL8192CEMAC_2T_ARRAY;
172 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 170 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Img:RTL8192CEMAC_2T_ARRAY\n");
173 ("Img:RTL8192CEMAC_2T_ARRAY\n"));
174 for (i = 0; i < arraylength; i = i + 2) 171 for (i = 0; i < arraylength; i = i + 2)
175 rtl_write_byte(rtlpriv, ptrarray[i], (u8) ptrarray[i + 1]); 172 rtl_write_byte(rtlpriv, ptrarray[i], (u8) ptrarray[i + 1]);
176 return true; 173 return true;
@@ -215,10 +212,9 @@ bool _rtl92ce_phy_config_bb_with_headerfile(struct ieee80211_hw *hw,
215 phy_regarray_table[i + 1]); 212 phy_regarray_table[i + 1]);
216 udelay(1); 213 udelay(1);
217 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 214 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
218 ("The phy_regarray_table[0] is %x" 215 "The phy_regarray_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n",
219 " Rtl819XPHY_REGArray[1] is %x\n", 216 phy_regarray_table[i],
220 phy_regarray_table[i], 217 phy_regarray_table[i + 1]);
221 phy_regarray_table[i + 1]));
222 } 218 }
223 } else if (configtype == BASEBAND_CONFIG_AGC_TAB) { 219 } else if (configtype == BASEBAND_CONFIG_AGC_TAB) {
224 for (i = 0; i < agctab_arraylen; i = i + 2) { 220 for (i = 0; i < agctab_arraylen; i = i + 2) {
@@ -226,10 +222,9 @@ bool _rtl92ce_phy_config_bb_with_headerfile(struct ieee80211_hw *hw,
226 agctab_array_table[i + 1]); 222 agctab_array_table[i + 1]);
227 udelay(1); 223 udelay(1);
228 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 224 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
229 ("The agctab_array_table[0] is " 225 "The agctab_array_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n",
230 "%x Rtl819XPHY_REGArray[1] is %x\n", 226 agctab_array_table[i],
231 agctab_array_table[i], 227 agctab_array_table[i + 1]);
232 agctab_array_table[i + 1]));
233 } 228 }
234 } 229 }
235 return true; 230 return true;
@@ -269,7 +264,7 @@ bool _rtl92ce_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw,
269 } else { 264 } else {
270 265
271 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, 266 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
272 ("configtype != BaseBand_Config_PHY_REG\n")); 267 "configtype != BaseBand_Config_PHY_REG\n");
273 } 268 }
274 return true; 269 return true;
275} 270}
@@ -291,20 +286,20 @@ bool rtl92c_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
291 radiob_arraylen = RADIOB_2TARRAYLENGTH; 286 radiob_arraylen = RADIOB_2TARRAYLENGTH;
292 radiob_array_table = RTL8192CE_RADIOB_2TARRAY; 287 radiob_array_table = RTL8192CE_RADIOB_2TARRAY;
293 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 288 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
294 ("Radio_A:RTL8192CERADIOA_2TARRAY\n")); 289 "Radio_A:RTL8192CERADIOA_2TARRAY\n");
295 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 290 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
296 ("Radio_B:RTL8192CE_RADIOB_2TARRAY\n")); 291 "Radio_B:RTL8192CE_RADIOB_2TARRAY\n");
297 } else { 292 } else {
298 radioa_arraylen = RADIOA_1TARRAYLENGTH; 293 radioa_arraylen = RADIOA_1TARRAYLENGTH;
299 radioa_array_table = RTL8192CE_RADIOA_1TARRAY; 294 radioa_array_table = RTL8192CE_RADIOA_1TARRAY;
300 radiob_arraylen = RADIOB_1TARRAYLENGTH; 295 radiob_arraylen = RADIOB_1TARRAYLENGTH;
301 radiob_array_table = RTL8192CE_RADIOB_1TARRAY; 296 radiob_array_table = RTL8192CE_RADIOB_1TARRAY;
302 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 297 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
303 ("Radio_A:RTL8192CE_RADIOA_1TARRAY\n")); 298 "Radio_A:RTL8192CE_RADIOA_1TARRAY\n");
304 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 299 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
305 ("Radio_B:RTL8192CE_RADIOB_1TARRAY\n")); 300 "Radio_B:RTL8192CE_RADIOB_1TARRAY\n");
306 } 301 }
307 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Radio No %x\n", rfpath)); 302 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Radio No %x\n", rfpath);
308 switch (rfpath) { 303 switch (rfpath) {
309 case RF90_PATH_A: 304 case RF90_PATH_A:
310 for (i = 0; i < radioa_arraylen; i = i + 2) { 305 for (i = 0; i < radioa_arraylen; i = i + 2) {
@@ -352,11 +347,11 @@ bool rtl92c_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
352 break; 347 break;
353 case RF90_PATH_C: 348 case RF90_PATH_C:
354 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 349 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
355 ("switch case not process\n")); 350 "switch case not processed\n");
356 break; 351 break;
357 case RF90_PATH_D: 352 case RF90_PATH_D:
358 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 353 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
359 ("switch case not process\n")); 354 "switch case not processed\n");
360 break; 355 break;
361 } 356 }
362 return true; 357 return true;
@@ -371,10 +366,9 @@ void rtl92ce_phy_set_bw_mode_callback(struct ieee80211_hw *hw)
371 u8 reg_bw_opmode; 366 u8 reg_bw_opmode;
372 u8 reg_prsr_rsc; 367 u8 reg_prsr_rsc;
373 368
374 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, 369 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "Switch to %s bandwidth\n",
375 ("Switch to %s bandwidth\n", 370 rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ?
376 rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? 371 "20MHz" : "40MHz");
377 "20MHz" : "40MHz"))
378 372
379 if (is_hal_stop(rtlhal)) { 373 if (is_hal_stop(rtlhal)) {
380 rtlphy->set_bwmode_inprogress = false; 374 rtlphy->set_bwmode_inprogress = false;
@@ -398,7 +392,7 @@ void rtl92ce_phy_set_bw_mode_callback(struct ieee80211_hw *hw)
398 break; 392 break;
399 default: 393 default:
400 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 394 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
401 ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); 395 "unknown bandwidth: %#X\n", rtlphy->current_chan_bw);
402 break; 396 break;
403 } 397 }
404 398
@@ -423,12 +417,12 @@ void rtl92ce_phy_set_bw_mode_callback(struct ieee80211_hw *hw)
423 break; 417 break;
424 default: 418 default:
425 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 419 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
426 ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); 420 "unknown bandwidth: %#X\n", rtlphy->current_chan_bw);
427 break; 421 break;
428 } 422 }
429 rtl92ce_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw); 423 rtl92ce_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw);
430 rtlphy->set_bwmode_inprogress = false; 424 rtlphy->set_bwmode_inprogress = false;
431 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); 425 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n");
432} 426}
433 427
434void _rtl92ce_phy_lc_calibrate(struct ieee80211_hw *hw, bool is2t) 428void _rtl92ce_phy_lc_calibrate(struct ieee80211_hw *hw, bool is2t)
@@ -499,7 +493,7 @@ static void _rtl92ce_phy_set_rf_sleep(struct ieee80211_hw *hw)
499 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); 493 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3);
500 rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00); 494 rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00);
501 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, 495 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
502 ("Switch RF timeout !!!.\n")); 496 "Switch RF timeout !!!\n");
503 return; 497 return;
504 } 498 }
505 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); 499 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2);
@@ -526,7 +520,7 @@ static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw,
526 do { 520 do {
527 InitializeCount++; 521 InitializeCount++;
528 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 522 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
529 ("IPS Set eRf nic enable\n")); 523 "IPS Set eRf nic enable\n");
530 rtstatus = rtl_ps_enable_nic(hw); 524 rtstatus = rtl_ps_enable_nic(hw);
531 } while ((rtstatus != true) 525 } while ((rtstatus != true)
532 && (InitializeCount < 10)); 526 && (InitializeCount < 10));
@@ -534,10 +528,10 @@ static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw,
534 RT_RF_OFF_LEVL_HALT_NIC); 528 RT_RF_OFF_LEVL_HALT_NIC);
535 } else { 529 } else {
536 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 530 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
537 ("Set ERFON sleeped:%d ms\n", 531 "Set ERFON sleeped:%d ms\n",
538 jiffies_to_msecs(jiffies - 532 jiffies_to_msecs(jiffies -
539 ppsc-> 533 ppsc->
540 last_sleep_jiffies))); 534 last_sleep_jiffies));
541 ppsc->last_awake_jiffies = jiffies; 535 ppsc->last_awake_jiffies = jiffies;
542 rtl92ce_phy_set_rf_on(hw); 536 rtl92ce_phy_set_rf_on(hw);
543 } 537 }
@@ -553,7 +547,7 @@ static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw,
553 case ERFOFF:{ 547 case ERFOFF:{
554 if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) { 548 if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) {
555 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 549 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
556 ("IPS Set eRf nic disable\n")); 550 "IPS Set eRf nic disable\n");
557 rtl_ps_disable_nic(hw); 551 rtl_ps_disable_nic(hw);
558 RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); 552 RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
559 } else { 553 } else {
@@ -578,35 +572,33 @@ static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw,
578 continue; 572 continue;
579 } else { 573 } else {
580 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 574 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
581 ("eRf Off/Sleep: %d times " 575 "eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n",
582 "TcbBusyQueue[%d] =%d before " 576 i + 1, queue_id,
583 "doze!\n", (i + 1), queue_id, 577 skb_queue_len(&ring->queue));
584 skb_queue_len(&ring->queue)));
585 578
586 udelay(10); 579 udelay(10);
587 i++; 580 i++;
588 } 581 }
589 if (i >= MAX_DOZE_WAITING_TIMES_9x) { 582 if (i >= MAX_DOZE_WAITING_TIMES_9x) {
590 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 583 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
591 ("\n ERFSLEEP: %d times " 584 "ERFSLEEP: %d times TcbBusyQueue[%d] = %d !\n",
592 "TcbBusyQueue[%d] = %d !\n", 585 MAX_DOZE_WAITING_TIMES_9x,
593 MAX_DOZE_WAITING_TIMES_9x, 586 queue_id,
594 queue_id, 587 skb_queue_len(&ring->queue));
595 skb_queue_len(&ring->queue)));
596 break; 588 break;
597 } 589 }
598 } 590 }
599 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 591 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
600 ("Set ERFSLEEP awaked:%d ms\n", 592 "Set ERFSLEEP awaked:%d ms\n",
601 jiffies_to_msecs(jiffies - 593 jiffies_to_msecs(jiffies -
602 ppsc->last_awake_jiffies))); 594 ppsc->last_awake_jiffies));
603 ppsc->last_sleep_jiffies = jiffies; 595 ppsc->last_sleep_jiffies = jiffies;
604 _rtl92ce_phy_set_rf_sleep(hw); 596 _rtl92ce_phy_set_rf_sleep(hw);
605 break; 597 break;
606 } 598 }
607 default: 599 default:
608 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 600 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
609 ("switch case not process\n")); 601 "switch case not processed\n");
610 bresult = false; 602 bresult = false;
611 break; 603 break;
612 } 604 }
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h
index be2c92adef33..d5e3b704f930 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h b/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h
index ba5ff0411f0a..43806d9d1e13 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c
index d3b01e6023ba..69d720dd9c38 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -56,7 +56,7 @@ void rtl92ce_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, u8 bandwidth)
56 break; 56 break;
57 default: 57 default:
58 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 58 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
59 ("unknown bandwidth: %#X\n", bandwidth)); 59 "unknown bandwidth: %#X\n", bandwidth);
60 break; 60 break;
61 } 61 }
62} 62}
@@ -123,8 +123,8 @@ void rtl92ce_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw,
123 rtl_set_bbreg(hw, RTXAGC_A_CCK1_MCS32, MASKBYTE1, tmpval); 123 rtl_set_bbreg(hw, RTXAGC_A_CCK1_MCS32, MASKBYTE1, tmpval);
124 124
125 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 125 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
126 ("CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, 126 "CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n",
127 RTXAGC_A_CCK1_MCS32)); 127 tmpval, RTXAGC_A_CCK1_MCS32);
128 128
129 tmpval = tx_agc[RF90_PATH_A] >> 8; 129 tmpval = tx_agc[RF90_PATH_A] >> 8;
130 130
@@ -133,22 +133,22 @@ void rtl92ce_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw,
133 rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); 133 rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval);
134 134
135 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 135 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
136 ("CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, 136 "CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n",
137 RTXAGC_B_CCK11_A_CCK2_11)); 137 tmpval, RTXAGC_B_CCK11_A_CCK2_11);
138 138
139 tmpval = tx_agc[RF90_PATH_B] >> 24; 139 tmpval = tx_agc[RF90_PATH_B] >> 24;
140 rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, MASKBYTE0, tmpval); 140 rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, MASKBYTE0, tmpval);
141 141
142 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 142 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
143 ("CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, 143 "CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n",
144 RTXAGC_B_CCK11_A_CCK2_11)); 144 tmpval, RTXAGC_B_CCK11_A_CCK2_11);
145 145
146 tmpval = tx_agc[RF90_PATH_B] & 0x00ffffff; 146 tmpval = tx_agc[RF90_PATH_B] & 0x00ffffff;
147 rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, 0xffffff00, tmpval); 147 rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, 0xffffff00, tmpval);
148 148
149 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 149 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
150 ("CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, 150 "CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n",
151 RTXAGC_B_CCK1_55_MCS32)); 151 tmpval, RTXAGC_B_CCK1_55_MCS32);
152} 152}
153 153
154static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw, 154static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw,
@@ -171,8 +171,8 @@ static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw,
171 (powerBase0 << 8) | powerBase0; 171 (powerBase0 << 8) | powerBase0;
172 *(ofdmbase + i) = powerBase0; 172 *(ofdmbase + i) = powerBase0;
173 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 173 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
174 (" [OFDM power base index rf(%c) = 0x%x]\n", 174 " [OFDM power base index rf(%c) = 0x%x]\n",
175 ((i == 0) ? 'A' : 'B'), *(ofdmbase + i))); 175 i == 0 ? 'A' : 'B', *(ofdmbase + i));
176 } 176 }
177 177
178 for (i = 0; i < 2; i++) { 178 for (i = 0; i < 2; i++) {
@@ -187,8 +187,8 @@ static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw,
187 *(mcsbase + i) = powerBase1; 187 *(mcsbase + i) = powerBase1;
188 188
189 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 189 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
190 (" [MCS power base index rf(%c) = 0x%x]\n", 190 " [MCS power base index rf(%c) = 0x%x]\n",
191 ((i == 0) ? 'A' : 'B'), *(mcsbase + i))); 191 i == 0 ? 'A' : 'B', *(mcsbase + i));
192 } 192 }
193} 193}
194 194
@@ -215,9 +215,8 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
215 + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); 215 + ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
216 216
217 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 217 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
218 ("RTK better performance, " 218 "RTK better performance, writeVal(%c) = 0x%x\n",
219 "writeVal(%c) = 0x%x\n", 219 rf == 0 ? 'A' : 'B', writeVal);
220 ((rf == 0) ? 'A' : 'B'), writeVal));
221 break; 220 break;
222 case 1: 221 case 1:
223 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { 222 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) {
@@ -225,9 +224,8 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
225 powerBase1[rf]); 224 powerBase1[rf]);
226 225
227 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 226 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
228 ("Realtek regulatory, 40MHz, " 227 "Realtek regulatory, 40MHz, writeVal(%c) = 0x%x\n",
229 "writeVal(%c) = 0x%x\n", 228 rf == 0 ? 'A' : 'B', writeVal);
230 ((rf == 0) ? 'A' : 'B'), writeVal));
231 } else { 229 } else {
232 if (rtlphy->pwrgroup_cnt == 1) 230 if (rtlphy->pwrgroup_cnt == 1)
233 chnlgroup = 0; 231 chnlgroup = 0;
@@ -249,9 +247,8 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
249 powerBase1[rf]); 247 powerBase1[rf]);
250 248
251 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 249 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
252 ("Realtek regulatory, 20MHz, " 250 "Realtek regulatory, 20MHz, writeVal(%c) = 0x%x\n",
253 "writeVal(%c) = 0x%x\n", 251 rf == 0 ? 'A' : 'B', writeVal);
254 ((rf == 0) ? 'A' : 'B'), writeVal));
255 } 252 }
256 break; 253 break;
257 case 2: 254 case 2:
@@ -259,27 +256,24 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
259 ((index < 2) ? powerBase0[rf] : powerBase1[rf]); 256 ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
260 257
261 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 258 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
262 ("Better regulatory, " 259 "Better regulatory, writeVal(%c) = 0x%x\n",
263 "writeVal(%c) = 0x%x\n", 260 rf == 0 ? 'A' : 'B', writeVal);
264 ((rf == 0) ? 'A' : 'B'), writeVal));
265 break; 261 break;
266 case 3: 262 case 3:
267 chnlgroup = 0; 263 chnlgroup = 0;
268 264
269 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { 265 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) {
270 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 266 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
271 ("customer's limit, 40MHz " 267 "customer's limit, 40MHz rf(%c) = 0x%x\n",
272 "rf(%c) = 0x%x\n", 268 rf == 0 ? 'A' : 'B',
273 ((rf == 0) ? 'A' : 'B'), 269 rtlefuse->pwrgroup_ht40[rf][channel -
274 rtlefuse->pwrgroup_ht40[rf][channel - 270 1]);
275 1]));
276 } else { 271 } else {
277 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 272 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
278 ("customer's limit, 20MHz " 273 "customer's limit, 20MHz rf(%c) = 0x%x\n",
279 "rf(%c) = 0x%x\n", 274 rf == 0 ? 'A' : 'B',
280 ((rf == 0) ? 'A' : 'B'), 275 rtlefuse->pwrgroup_ht20[rf][channel -
281 rtlefuse->pwrgroup_ht20[rf][channel - 276 1]);
282 1]));
283 } 277 }
284 for (i = 0; i < 4; i++) { 278 for (i = 0; i < 4; i++) {
285 pwr_diff_limit[i] = 279 pwr_diff_limit[i] =
@@ -311,15 +305,15 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
311 (pwr_diff_limit[1] << 8) | (pwr_diff_limit[0]); 305 (pwr_diff_limit[1] << 8) | (pwr_diff_limit[0]);
312 306
313 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 307 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
314 ("Customer's limit rf(%c) = 0x%x\n", 308 "Customer's limit rf(%c) = 0x%x\n",
315 ((rf == 0) ? 'A' : 'B'), customer_limit)); 309 rf == 0 ? 'A' : 'B', customer_limit);
316 310
317 writeVal = customer_limit + 311 writeVal = customer_limit +
318 ((index < 2) ? powerBase0[rf] : powerBase1[rf]); 312 ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
319 313
320 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 314 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
321 ("Customer, writeVal rf(%c)= 0x%x\n", 315 "Customer, writeVal rf(%c)= 0x%x\n",
322 ((rf == 0) ? 'A' : 'B'), writeVal)); 316 rf == 0 ? 'A' : 'B', writeVal);
323 break; 317 break;
324 default: 318 default:
325 chnlgroup = 0; 319 chnlgroup = 0;
@@ -329,9 +323,8 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
329 + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); 323 + ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
330 324
331 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 325 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
332 ("RTK better performance, writeVal " 326 "RTK better performance, writeVal rf(%c) = 0x%x\n",
333 "rf(%c) = 0x%x\n", 327 rf == 0 ? 'A' : 'B', writeVal);
334 ((rf == 0) ? 'A' : 'B'), writeVal));
335 break; 328 break;
336 } 329 }
337 330
@@ -383,7 +376,7 @@ static void _rtl92c_write_ofdm_power_reg(struct ieee80211_hw *hw,
383 rtl_set_bbreg(hw, regoffset, MASKDWORD, writeVal); 376 rtl_set_bbreg(hw, regoffset, MASKDWORD, writeVal);
384 377
385 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 378 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
386 ("Set 0x%x = %08x\n", regoffset, writeVal)); 379 "Set 0x%x = %08x\n", regoffset, writeVal);
387 380
388 if (((get_rf_type(rtlphy) == RF_2T2R) && 381 if (((get_rf_type(rtlphy) == RF_2T2R) &&
389 (regoffset == RTXAGC_A_MCS15_MCS12 || 382 (regoffset == RTXAGC_A_MCS15_MCS12 ||
@@ -512,12 +505,12 @@ static bool _rtl92ce_phy_rf6052_config_parafile(struct ieee80211_hw *hw)
512 505
513 if (rtstatus != true) { 506 if (rtstatus != true) {
514 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 507 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
515 ("Radio[%d] Fail!!", rfpath)); 508 "Radio[%d] Fail!!\n", rfpath);
516 return false; 509 return false;
517 } 510 }
518 511
519 } 512 }
520 513
521 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("<---\n")); 514 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "<---\n");
522 return rtstatus; 515 return rtstatus;
523} 516}
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.h b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.h
index 39ff03685986..6c8d56efceae 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/rf.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/rf.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
index 89ef6982ce50..2c3b73366cd2 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -27,9 +27,6 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#include <linux/vmalloc.h>
31#include <linux/module.h>
32
33#include "../wifi.h" 30#include "../wifi.h"
34#include "../core.h" 31#include "../core.h"
35#include "../pci.h" 32#include "../pci.h"
@@ -43,6 +40,8 @@
43#include "trx.h" 40#include "trx.h"
44#include "led.h" 41#include "led.h"
45 42
43#include <linux/module.h>
44
46static void rtl92c_init_aspm_vars(struct ieee80211_hw *hw) 45static void rtl92c_init_aspm_vars(struct ieee80211_hw *hw)
47{ 46{
48 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 47 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
@@ -92,9 +91,7 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
92 int err; 91 int err;
93 struct rtl_priv *rtlpriv = rtl_priv(hw); 92 struct rtl_priv *rtlpriv = rtl_priv(hw);
94 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 93 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
95 const struct firmware *firmware;
96 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 94 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
97 char *fw_name = NULL;
98 95
99 rtl8192ce_bt_reg_init(hw); 96 rtl8192ce_bt_reg_init(hw);
100 97
@@ -159,33 +156,27 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
159 rtlpriv->rtlhal.pfirmware = vzalloc(0x4000); 156 rtlpriv->rtlhal.pfirmware = vzalloc(0x4000);
160 if (!rtlpriv->rtlhal.pfirmware) { 157 if (!rtlpriv->rtlhal.pfirmware) {
161 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 158 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
162 ("Can't alloc buffer for fw.\n")); 159 "Can't alloc buffer for fw\n");
163 return 1; 160 return 1;
164 } 161 }
165 162
166 /* request fw */ 163 /* request fw */
167 if (IS_VENDOR_UMC_A_CUT(rtlhal->version) && 164 if (IS_VENDOR_UMC_A_CUT(rtlhal->version) &&
168 !IS_92C_SERIAL(rtlhal->version)) 165 !IS_92C_SERIAL(rtlhal->version))
169 fw_name = "rtlwifi/rtl8192cfwU.bin"; 166 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU.bin";
170 else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version)) 167 else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version))
171 fw_name = "rtlwifi/rtl8192cfwU_B.bin"; 168 rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU_B.bin";
172 else 169
173 fw_name = rtlpriv->cfg->fw_name; 170 rtlpriv->max_fw_size = 0x4000;
174 err = request_firmware(&firmware, fw_name, rtlpriv->io.dev); 171 pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name);
172 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name,
173 rtlpriv->io.dev, GFP_KERNEL, hw,
174 rtl_fw_cb);
175 if (err) { 175 if (err) {
176 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 176 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
177 ("Failed to request firmware!\n")); 177 "Failed to request firmware!\n");
178 return 1;
179 }
180 if (firmware->size > 0x4000) {
181 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
182 ("Firmware is too big!\n"));
183 release_firmware(firmware);
184 return 1; 178 return 1;
185 } 179 }
186 memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size);
187 rtlpriv->rtlhal.fwsize = firmware->size;
188 release_firmware(firmware);
189 180
190 return 0; 181 return 0;
191} 182}
@@ -404,7 +395,7 @@ static int __init rtl92ce_module_init(void)
404 395
405 ret = pci_register_driver(&rtl92ce_driver); 396 ret = pci_register_driver(&rtl92ce_driver);
406 if (ret) 397 if (ret)
407 RT_ASSERT(false, (": No device found\n")); 398 RT_ASSERT(false, "No device found\n");
408 399
409 return ret; 400 return ret;
410} 401}
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.h b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.h
index b7dc3263e433..d2367a5d0cf5 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/table.c b/drivers/net/wireless/rtlwifi/rtl8192ce/table.c
index ba938b91aa6f..752f943a84ae 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/table.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/table.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/table.h b/drivers/net/wireless/rtlwifi/rtl8192ce/table.h
index 3a6e8b6aeee0..8b79161f71be 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/table.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/table.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
index 4fb5ae24dee0..37b13636a778 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -725,7 +725,7 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw,
725 if (ieee80211_is_data_qos(fc)) { 725 if (ieee80211_is_data_qos(fc)) {
726 if (mac->rdg_en) { 726 if (mac->rdg_en) {
727 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, 727 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
728 ("Enable RDG function.\n")); 728 "Enable RDG function\n");
729 SET_TX_DESC_RDG_ENABLE(pdesc, 1); 729 SET_TX_DESC_RDG_ENABLE(pdesc, 1);
730 SET_TX_DESC_HTC(pdesc, 1); 730 SET_TX_DESC_HTC(pdesc, 1);
731 } 731 }
@@ -763,7 +763,7 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw,
763 SET_TX_DESC_BMC(pdesc, 1); 763 SET_TX_DESC_BMC(pdesc, 1);
764 } 764 }
765 765
766 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, ("\n")); 766 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "\n");
767} 767}
768 768
769void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw, 769void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw,
@@ -821,8 +821,7 @@ void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw,
821 } 821 }
822 822
823 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, 823 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD,
824 "H2C Tx Cmd Content\n", 824 "H2C Tx Cmd Content", pdesc, TX_DESC_SIZE);
825 pdesc, TX_DESC_SIZE);
826} 825}
827 826
828void rtl92ce_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val) 827void rtl92ce_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val)
@@ -837,8 +836,8 @@ void rtl92ce_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val)
837 SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *) val); 836 SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *) val);
838 break; 837 break;
839 default: 838 default:
840 RT_ASSERT(false, ("ERR txdesc :%d" 839 RT_ASSERT(false, "ERR txdesc :%d not process\n",
841 " not process\n", desc_name)); 840 desc_name);
842 break; 841 break;
843 } 842 }
844 } else { 843 } else {
@@ -857,8 +856,8 @@ void rtl92ce_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val)
857 SET_RX_DESC_EOR(pdesc, 1); 856 SET_RX_DESC_EOR(pdesc, 1);
858 break; 857 break;
859 default: 858 default:
860 RT_ASSERT(false, ("ERR rxdesc :%d " 859 RT_ASSERT(false, "ERR rxdesc :%d not process\n",
861 "not process\n", desc_name)); 860 desc_name);
862 break; 861 break;
863 } 862 }
864 } 863 }
@@ -877,8 +876,8 @@ u32 rtl92ce_get_desc(u8 *p_desc, bool istx, u8 desc_name)
877 ret = GET_TX_DESC_TX_BUFFER_ADDRESS(p_desc); 876 ret = GET_TX_DESC_TX_BUFFER_ADDRESS(p_desc);
878 break; 877 break;
879 default: 878 default:
880 RT_ASSERT(false, ("ERR txdesc :%d " 879 RT_ASSERT(false, "ERR txdesc :%d not process\n",
881 "not process\n", desc_name)); 880 desc_name);
882 break; 881 break;
883 } 882 }
884 } else { 883 } else {
@@ -891,8 +890,8 @@ u32 rtl92ce_get_desc(u8 *p_desc, bool istx, u8 desc_name)
891 ret = GET_RX_DESC_PKT_LEN(pdesc); 890 ret = GET_RX_DESC_PKT_LEN(pdesc);
892 break; 891 break;
893 default: 892 default:
894 RT_ASSERT(false, ("ERR rxdesc :%d " 893 RT_ASSERT(false, "ERR rxdesc :%d not process\n",
895 "not process\n", desc_name)); 894 desc_name);
896 break; 895 break;
897 } 896 }
898 } 897 }
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h
index c8977a50ca36..efb9ab270403 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/def.h b/drivers/net/wireless/rtlwifi/rtl8192cu/def.h
index d097efb1e717..f916555e6311 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/def.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c
index f311baee668d..6fd39eaf361e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -52,7 +52,7 @@ void rtl92cu_dm_dynamic_txpower(struct ieee80211_hw *hw)
52 if ((mac->link_state < MAC80211_LINKED) && 52 if ((mac->link_state < MAC80211_LINKED) &&
53 (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) { 53 (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) {
54 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, 54 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
55 ("Not connected to any\n")); 55 "Not connected to any\n");
56 56
57 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; 57 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL;
58 58
@@ -65,28 +65,28 @@ void rtl92cu_dm_dynamic_txpower(struct ieee80211_hw *hw)
65 undecorated_smoothed_pwdb = 65 undecorated_smoothed_pwdb =
66 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; 66 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb;
67 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 67 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
68 ("AP Client PWDB = 0x%lx\n", 68 "AP Client PWDB = 0x%lx\n",
69 undecorated_smoothed_pwdb)); 69 undecorated_smoothed_pwdb);
70 } else { 70 } else {
71 undecorated_smoothed_pwdb = 71 undecorated_smoothed_pwdb =
72 rtlpriv->dm.undecorated_smoothed_pwdb; 72 rtlpriv->dm.undecorated_smoothed_pwdb;
73 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 73 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
74 ("STA Default Port PWDB = 0x%lx\n", 74 "STA Default Port PWDB = 0x%lx\n",
75 undecorated_smoothed_pwdb)); 75 undecorated_smoothed_pwdb);
76 } 76 }
77 } else { 77 } else {
78 undecorated_smoothed_pwdb = 78 undecorated_smoothed_pwdb =
79 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; 79 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb;
80 80
81 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 81 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
82 ("AP Ext Port PWDB = 0x%lx\n", 82 "AP Ext Port PWDB = 0x%lx\n",
83 undecorated_smoothed_pwdb)); 83 undecorated_smoothed_pwdb);
84 } 84 }
85 85
86 if (undecorated_smoothed_pwdb >= TX_POWER_NEAR_FIELD_THRESH_LVL2) { 86 if (undecorated_smoothed_pwdb >= TX_POWER_NEAR_FIELD_THRESH_LVL2) {
87 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; 87 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1;
88 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 88 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
89 ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n")); 89 "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n");
90 } else if ((undecorated_smoothed_pwdb < 90 } else if ((undecorated_smoothed_pwdb <
91 (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) && 91 (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) &&
92 (undecorated_smoothed_pwdb >= 92 (undecorated_smoothed_pwdb >=
@@ -94,18 +94,18 @@ void rtl92cu_dm_dynamic_txpower(struct ieee80211_hw *hw)
94 94
95 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; 95 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1;
96 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 96 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
97 ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n")); 97 "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n");
98 } else if (undecorated_smoothed_pwdb < 98 } else if (undecorated_smoothed_pwdb <
99 (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) { 99 (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) {
100 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; 100 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL;
101 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 101 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
102 ("TXHIGHPWRLEVEL_NORMAL\n")); 102 "TXHIGHPWRLEVEL_NORMAL\n");
103 } 103 }
104 104
105 if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) { 105 if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) {
106 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 106 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
107 ("PHY_SetTxPowerLevel8192S() Channel = %d\n", 107 "PHY_SetTxPowerLevel8192S() Channel = %d\n",
108 rtlphy->current_channel)); 108 rtlphy->current_channel);
109 rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel); 109 rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel);
110 } 110 }
111 111
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h
index 7f966c666b5a..d947e7d350bb 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
index 124cf633861c..0c74d4f2eeb4 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. 3 * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -27,8 +27,6 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
32#include "../wifi.h" 30#include "../wifi.h"
33#include "../efuse.h" 31#include "../efuse.h"
34#include "../base.h" 32#include "../base.h"
@@ -162,24 +160,24 @@ static void _rtl92cu_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
162 for (rf_path = 0; rf_path < 2; rf_path++) 160 for (rf_path = 0; rf_path < 2; rf_path++)
163 for (i = 0; i < 3; i++) 161 for (i = 0; i < 3; i++)
164 RTPRINT(rtlpriv, FINIT, INIT_EEPROM, 162 RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
165 ("RF(%d) EEPROM CCK Area(%d) = 0x%x\n", rf_path, 163 "RF(%d) EEPROM CCK Area(%d) = 0x%x\n",
166 i, rtlefuse-> 164 rf_path, i,
167 eeprom_chnlarea_txpwr_cck[rf_path][i])); 165 rtlefuse->
166 eeprom_chnlarea_txpwr_cck[rf_path][i]);
168 for (rf_path = 0; rf_path < 2; rf_path++) 167 for (rf_path = 0; rf_path < 2; rf_path++)
169 for (i = 0; i < 3; i++) 168 for (i = 0; i < 3; i++)
170 RTPRINT(rtlpriv, FINIT, INIT_EEPROM, 169 RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
171 ("RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n", 170 "RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n",
172 rf_path, i, 171 rf_path, i,
173 rtlefuse-> 172 rtlefuse->
174 eeprom_chnlarea_txpwr_ht40_1s[rf_path][i])); 173 eeprom_chnlarea_txpwr_ht40_1s[rf_path][i]);
175 for (rf_path = 0; rf_path < 2; rf_path++) 174 for (rf_path = 0; rf_path < 2; rf_path++)
176 for (i = 0; i < 3; i++) 175 for (i = 0; i < 3; i++)
177 RTPRINT(rtlpriv, FINIT, INIT_EEPROM, 176 RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
178 ("RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n", 177 "RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n",
179 rf_path, i, 178 rf_path, i,
180 rtlefuse-> 179 rtlefuse->
181 eeprom_chnlarea_txpwr_ht40_2sdiif[rf_path] 180 eeprom_chnlarea_txpwr_ht40_2sdiif[rf_path][i]);
182 [i]));
183 for (rf_path = 0; rf_path < 2; rf_path++) { 181 for (rf_path = 0; rf_path < 2; rf_path++) {
184 for (i = 0; i < 14; i++) { 182 for (i = 0; i < 14; i++) {
185 index = _rtl92c_get_chnl_group((u8) i); 183 index = _rtl92c_get_chnl_group((u8) i);
@@ -205,11 +203,10 @@ static void _rtl92cu_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
205 } 203 }
206 for (i = 0; i < 14; i++) { 204 for (i = 0; i < 14; i++) {
207 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 205 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
208 ("RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = " 206 "RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = [0x%x / 0x%x / 0x%x]\n", rf_path, i,
209 "[0x%x / 0x%x / 0x%x]\n", rf_path, i, 207 rtlefuse->txpwrlevel_cck[rf_path][i],
210 rtlefuse->txpwrlevel_cck[rf_path][i], 208 rtlefuse->txpwrlevel_ht40_1s[rf_path][i],
211 rtlefuse->txpwrlevel_ht40_1s[rf_path][i], 209 rtlefuse->txpwrlevel_ht40_2s[rf_path][i]);
212 rtlefuse->txpwrlevel_ht40_2s[rf_path][i]));
213 } 210 }
214 } 211 }
215 for (i = 0; i < 3; i++) { 212 for (i = 0; i < 3; i++) {
@@ -242,13 +239,13 @@ static void _rtl92cu_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
242 & 0xf0) >> 4); 239 & 0xf0) >> 4);
243 } 240 }
244 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 241 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
245 ("RF-%d pwrgroup_ht20[%d] = 0x%x\n", 242 "RF-%d pwrgroup_ht20[%d] = 0x%x\n",
246 rf_path, i, 243 rf_path, i,
247 rtlefuse->pwrgroup_ht20[rf_path][i])); 244 rtlefuse->pwrgroup_ht20[rf_path][i]);
248 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 245 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
249 ("RF-%d pwrgroup_ht40[%d] = 0x%x\n", 246 "RF-%d pwrgroup_ht40[%d] = 0x%x\n",
250 rf_path, i, 247 rf_path, i,
251 rtlefuse->pwrgroup_ht40[rf_path][i])); 248 rtlefuse->pwrgroup_ht40[rf_path][i]);
252 } 249 }
253 } 250 }
254 for (i = 0; i < 14; i++) { 251 for (i = 0; i < 14; i++) {
@@ -277,26 +274,26 @@ static void _rtl92cu_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
277 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][7]; 274 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][7];
278 for (i = 0; i < 14; i++) 275 for (i = 0; i < 14; i++)
279 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 276 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
280 ("RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", i, 277 "RF-A Ht20 to HT40 Diff[%d] = 0x%x\n",
281 rtlefuse->txpwr_ht20diff[RF90_PATH_A][i])); 278 i, rtlefuse->txpwr_ht20diff[RF90_PATH_A][i]);
282 for (i = 0; i < 14; i++) 279 for (i = 0; i < 14; i++)
283 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 280 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
284 ("RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", i, 281 "RF-A Legacy to Ht40 Diff[%d] = 0x%x\n",
285 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i])); 282 i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i]);
286 for (i = 0; i < 14; i++) 283 for (i = 0; i < 14; i++)
287 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 284 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
288 ("RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", i, 285 "RF-B Ht20 to HT40 Diff[%d] = 0x%x\n",
289 rtlefuse->txpwr_ht20diff[RF90_PATH_B][i])); 286 i, rtlefuse->txpwr_ht20diff[RF90_PATH_B][i]);
290 for (i = 0; i < 14; i++) 287 for (i = 0; i < 14; i++)
291 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 288 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
292 ("RF-B Legacy to HT40 Diff[%d] = 0x%x\n", i, 289 "RF-B Legacy to HT40 Diff[%d] = 0x%x\n",
293 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i])); 290 i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i]);
294 if (!autoload_fail) 291 if (!autoload_fail)
295 rtlefuse->eeprom_regulatory = (hwinfo[RF_OPTION1] & 0x7); 292 rtlefuse->eeprom_regulatory = (hwinfo[RF_OPTION1] & 0x7);
296 else 293 else
297 rtlefuse->eeprom_regulatory = 0; 294 rtlefuse->eeprom_regulatory = 0;
298 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 295 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
299 ("eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory)); 296 "eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory);
300 if (!autoload_fail) { 297 if (!autoload_fail) {
301 rtlefuse->eeprom_tssi[RF90_PATH_A] = hwinfo[EEPROM_TSSI_A]; 298 rtlefuse->eeprom_tssi[RF90_PATH_A] = hwinfo[EEPROM_TSSI_A];
302 rtlefuse->eeprom_tssi[RF90_PATH_B] = hwinfo[EEPROM_TSSI_B]; 299 rtlefuse->eeprom_tssi[RF90_PATH_B] = hwinfo[EEPROM_TSSI_B];
@@ -305,9 +302,9 @@ static void _rtl92cu_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
305 rtlefuse->eeprom_tssi[RF90_PATH_B] = EEPROM_DEFAULT_TSSI; 302 rtlefuse->eeprom_tssi[RF90_PATH_B] = EEPROM_DEFAULT_TSSI;
306 } 303 }
307 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 304 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
308 ("TSSI_A = 0x%x, TSSI_B = 0x%x\n", 305 "TSSI_A = 0x%x, TSSI_B = 0x%x\n",
309 rtlefuse->eeprom_tssi[RF90_PATH_A], 306 rtlefuse->eeprom_tssi[RF90_PATH_A],
310 rtlefuse->eeprom_tssi[RF90_PATH_B])); 307 rtlefuse->eeprom_tssi[RF90_PATH_B]);
311 if (!autoload_fail) 308 if (!autoload_fail)
312 tempval = hwinfo[EEPROM_THERMAL_METER]; 309 tempval = hwinfo[EEPROM_THERMAL_METER];
313 else 310 else
@@ -320,7 +317,7 @@ static void _rtl92cu_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
320 rtlefuse->apk_thermalmeterignore = true; 317 rtlefuse->apk_thermalmeterignore = true;
321 rtlefuse->thermalmeter[0] = rtlefuse->eeprom_thermalmeter; 318 rtlefuse->thermalmeter[0] = rtlefuse->eeprom_thermalmeter;
322 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 319 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
323 ("thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter)); 320 "thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter);
324} 321}
325 322
326static void _rtl92cu_read_board_type(struct ieee80211_hw *hw, u8 *contents) 323static void _rtl92cu_read_board_type(struct ieee80211_hw *hw, u8 *contents)
@@ -340,144 +337,8 @@ static void _rtl92cu_read_board_type(struct ieee80211_hw *hw, u8 *contents)
340 if (IS_HIGHT_PA(rtlefuse->board_type)) 337 if (IS_HIGHT_PA(rtlefuse->board_type))
341 rtlefuse->external_pa = 1; 338 rtlefuse->external_pa = 1;
342 pr_info("Board Type %x\n", rtlefuse->board_type); 339 pr_info("Board Type %x\n", rtlefuse->board_type);
343
344#ifdef CONFIG_ANTENNA_DIVERSITY
345 /* Antenna Diversity setting. */
346 if (registry_par->antdiv_cfg == 2) /* 2: From Efuse */
347 rtl_efuse->antenna_cfg = (contents[EEPROM_RF_OPT1]&0x18)>>3;
348 else
349 rtl_efuse->antenna_cfg = registry_par->antdiv_cfg; /* 0:OFF, */
350
351 pr_info("Antenna Config %x\n", rtl_efuse->antenna_cfg);
352#endif
353}
354
355#ifdef CONFIG_BT_COEXIST
356static void _update_bt_param(_adapter *padapter)
357{
358 struct btcoexist_priv *pbtpriv = &(padapter->halpriv.bt_coexist);
359 struct registry_priv *registry_par = &padapter->registrypriv;
360 if (2 != registry_par->bt_iso) {
361 /* 0:Low, 1:High, 2:From Efuse */
362 pbtpriv->BT_Ant_isolation = registry_par->bt_iso;
363 }
364 if (registry_par->bt_sco == 1) {
365 /* 0:Idle, 1:None-SCO, 2:SCO, 3:From Counter, 4.Busy,
366 * 5.OtherBusy */
367 pbtpriv->BT_Service = BT_OtherAction;
368 } else if (registry_par->bt_sco == 2) {
369 pbtpriv->BT_Service = BT_SCO;
370 } else if (registry_par->bt_sco == 4) {
371 pbtpriv->BT_Service = BT_Busy;
372 } else if (registry_par->bt_sco == 5) {
373 pbtpriv->BT_Service = BT_OtherBusy;
374 } else {
375 pbtpriv->BT_Service = BT_Idle;
376 }
377 pbtpriv->BT_Ampdu = registry_par->bt_ampdu;
378 pbtpriv->bCOBT = _TRUE;
379 pbtpriv->BtEdcaUL = 0;
380 pbtpriv->BtEdcaDL = 0;
381 pbtpriv->BtRssiState = 0xff;
382 pbtpriv->bInitSet = _FALSE;
383 pbtpriv->bBTBusyTraffic = _FALSE;
384 pbtpriv->bBTTrafficModeSet = _FALSE;
385 pbtpriv->bBTNonTrafficModeSet = _FALSE;
386 pbtpriv->CurrentState = 0;
387 pbtpriv->PreviousState = 0;
388 pr_info("BT Coexistance = %s\n",
389 (pbtpriv->BT_Coexist == _TRUE) ? "enable" : "disable");
390 if (pbtpriv->BT_Coexist) {
391 if (pbtpriv->BT_Ant_Num == Ant_x2)
392 pr_info("BlueTooth BT_Ant_Num = Antx2\n");
393 else if (pbtpriv->BT_Ant_Num == Ant_x1)
394 pr_info("BlueTooth BT_Ant_Num = Antx1\n");
395 switch (pbtpriv->BT_CoexistType) {
396 case BT_2Wire:
397 pr_info("BlueTooth BT_CoexistType = BT_2Wire\n");
398 break;
399 case BT_ISSC_3Wire:
400 pr_info("BlueTooth BT_CoexistType = BT_ISSC_3Wire\n");
401 break;
402 case BT_Accel:
403 pr_info("BlueTooth BT_CoexistType = BT_Accel\n");
404 break;
405 case BT_CSR_BC4:
406 pr_info("BlueTooth BT_CoexistType = BT_CSR_BC4\n");
407 break;
408 case BT_CSR_BC8:
409 pr_info("BlueTooth BT_CoexistType = BT_CSR_BC8\n");
410 break;
411 case BT_RTL8756:
412 pr_info("BlueTooth BT_CoexistType = BT_RTL8756\n");
413 break;
414 default:
415 pr_info("BlueTooth BT_CoexistType = Unknown\n");
416 break;
417 }
418 pr_info("BlueTooth BT_Ant_isolation = %d\n",
419 pbtpriv->BT_Ant_isolation);
420 switch (pbtpriv->BT_Service) {
421 case BT_OtherAction:
422 pr_info("BlueTooth BT_Service = BT_OtherAction\n");
423 break;
424 case BT_SCO:
425 pr_info("BlueTooth BT_Service = BT_SCO\n");
426 break;
427 case BT_Busy:
428 pr_info("BlueTooth BT_Service = BT_Busy\n");
429 break;
430 case BT_OtherBusy:
431 pr_info("BlueTooth BT_Service = BT_OtherBusy\n");
432 break;
433 default:
434 pr_info("BlueTooth BT_Service = BT_Idle\n");
435 break;
436 }
437 pr_info("BT_RadioSharedType = 0x%x\n",
438 pbtpriv->BT_RadioSharedType);
439 }
440} 340}
441 341
442#define GET_BT_COEXIST(priv) (&priv->bt_coexist)
443
444static void _rtl92cu_read_bluetooth_coexistInfo(struct ieee80211_hw *hw,
445 u8 *contents,
446 bool bautoloadfailed);
447{
448 HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
449 bool isNormal = IS_NORMAL_CHIP(pHalData->VersionID);
450 struct btcoexist_priv *pbtpriv = &pHalData->bt_coexist;
451 u8 rf_opt4;
452
453 _rtw_memset(pbtpriv, 0, sizeof(struct btcoexist_priv));
454 if (AutoloadFail) {
455 pbtpriv->BT_Coexist = _FALSE;
456 pbtpriv->BT_CoexistType = BT_2Wire;
457 pbtpriv->BT_Ant_Num = Ant_x2;
458 pbtpriv->BT_Ant_isolation = 0;
459 pbtpriv->BT_RadioSharedType = BT_Radio_Shared;
460 return;
461 }
462 if (isNormal) {
463 if (pHalData->BoardType == BOARD_USB_COMBO)
464 pbtpriv->BT_Coexist = _TRUE;
465 else
466 pbtpriv->BT_Coexist = ((PROMContent[EEPROM_RF_OPT3] &
467 0x20) >> 5); /* bit[5] */
468 rf_opt4 = PROMContent[EEPROM_RF_OPT4];
469 pbtpriv->BT_CoexistType = ((rf_opt4&0xe)>>1); /* bit [3:1] */
470 pbtpriv->BT_Ant_Num = (rf_opt4&0x1); /* bit [0] */
471 pbtpriv->BT_Ant_isolation = ((rf_opt4&0x10)>>4); /* bit [4] */
472 pbtpriv->BT_RadioSharedType = ((rf_opt4&0x20)>>5); /* bit [5] */
473 } else {
474 pbtpriv->BT_Coexist = (PROMContent[EEPROM_RF_OPT4] >> 4) ?
475 _TRUE : _FALSE;
476 }
477 _update_bt_param(Adapter);
478}
479#endif
480
481static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw) 342static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw)
482{ 343{
483 struct rtl_priv *rtlpriv = rtl_priv(hw); 344 struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -494,17 +355,17 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw)
494 HWSET_MAX_SIZE); 355 HWSET_MAX_SIZE);
495 } else if (rtlefuse->epromtype == EEPROM_93C46) { 356 } else if (rtlefuse->epromtype == EEPROM_93C46) {
496 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 357 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
497 ("RTL819X Not boot from eeprom, check it !!")); 358 "RTL819X Not boot from eeprom, check it !!\n");
498 } 359 }
499 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_LOUD, ("MAP\n"), 360 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_LOUD, "MAP",
500 hwinfo, HWSET_MAX_SIZE); 361 hwinfo, HWSET_MAX_SIZE);
501 eeprom_id = le16_to_cpu(*((__le16 *)&hwinfo[0])); 362 eeprom_id = le16_to_cpu(*((__le16 *)&hwinfo[0]));
502 if (eeprom_id != RTL8190_EEPROM_ID) { 363 if (eeprom_id != RTL8190_EEPROM_ID) {
503 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 364 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
504 ("EEPROM ID(%#x) is invalid!!\n", eeprom_id)); 365 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
505 rtlefuse->autoload_failflag = true; 366 rtlefuse->autoload_failflag = true;
506 } else { 367 } else {
507 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); 368 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
508 rtlefuse->autoload_failflag = false; 369 rtlefuse->autoload_failflag = false;
509 } 370 }
510 if (rtlefuse->autoload_failflag) 371 if (rtlefuse->autoload_failflag)
@@ -518,16 +379,15 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw)
518 rtlefuse->autoload_failflag, hwinfo); 379 rtlefuse->autoload_failflag, hwinfo);
519 rtlefuse->eeprom_vid = le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_VID]); 380 rtlefuse->eeprom_vid = le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_VID]);
520 rtlefuse->eeprom_did = le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_DID]); 381 rtlefuse->eeprom_did = le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_DID]);
521 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 382 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, " VID = 0x%02x PID = 0x%02x\n",
522 (" VID = 0x%02x PID = 0x%02x\n", 383 rtlefuse->eeprom_vid, rtlefuse->eeprom_did);
523 rtlefuse->eeprom_vid, rtlefuse->eeprom_did));
524 rtlefuse->eeprom_channelplan = *(u8 *)&hwinfo[EEPROM_CHANNELPLAN]; 384 rtlefuse->eeprom_channelplan = *(u8 *)&hwinfo[EEPROM_CHANNELPLAN];
525 rtlefuse->eeprom_version = 385 rtlefuse->eeprom_version =
526 le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_VERSION]); 386 le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_VERSION]);
527 rtlefuse->txpwr_fromeprom = true; 387 rtlefuse->txpwr_fromeprom = true;
528 rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID]; 388 rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID];
529 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 389 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "EEPROM Customer ID: 0x%2x\n",
530 ("EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid)); 390 rtlefuse->eeprom_oemid);
531 if (rtlhal->oem_id == RT_CID_DEFAULT) { 391 if (rtlhal->oem_id == RT_CID_DEFAULT) {
532 switch (rtlefuse->eeprom_oemid) { 392 switch (rtlefuse->eeprom_oemid) {
533 case EEPROM_CID_DEFAULT: 393 case EEPROM_CID_DEFAULT:
@@ -554,10 +414,6 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw)
554 } 414 }
555 } 415 }
556 _rtl92cu_read_board_type(hw, hwinfo); 416 _rtl92cu_read_board_type(hw, hwinfo);
557#ifdef CONFIG_BT_COEXIST
558 _rtl92cu_read_bluetooth_coexistInfo(hw, hwinfo,
559 rtlefuse->autoload_failflag);
560#endif
561} 417}
562 418
563static void _rtl92cu_hal_customized_behavior(struct ieee80211_hw *hw) 419static void _rtl92cu_hal_customized_behavior(struct ieee80211_hw *hw)
@@ -579,8 +435,8 @@ static void _rtl92cu_hal_customized_behavior(struct ieee80211_hw *hw)
579 default: 435 default:
580 break; 436 break;
581 } 437 }
582 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 438 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "RT Customized ID: 0x%02X\n",
583 ("RT Customized ID: 0x%02X\n", rtlhal->oem_id)); 439 rtlhal->oem_id);
584} 440}
585 441
586void rtl92cu_read_eeprom_info(struct ieee80211_hw *hw) 442void rtl92cu_read_eeprom_info(struct ieee80211_hw *hw)
@@ -596,11 +452,11 @@ void rtl92cu_read_eeprom_info(struct ieee80211_hw *hw)
596 tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR); 452 tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR);
597 rtlefuse->epromtype = (tmp_u1b & BOOT_FROM_EEPROM) ? 453 rtlefuse->epromtype = (tmp_u1b & BOOT_FROM_EEPROM) ?
598 EEPROM_93C46 : EEPROM_BOOT_EFUSE; 454 EEPROM_93C46 : EEPROM_BOOT_EFUSE;
599 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from %s\n", 455 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from %s\n",
600 (tmp_u1b & BOOT_FROM_EEPROM) ? "EERROM" : "EFUSE")); 456 tmp_u1b & BOOT_FROM_EEPROM ? "EERROM" : "EFUSE");
601 rtlefuse->autoload_failflag = (tmp_u1b & EEPROM_EN) ? false : true; 457 rtlefuse->autoload_failflag = (tmp_u1b & EEPROM_EN) ? false : true;
602 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload %s\n", 458 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload %s\n",
603 (tmp_u1b & EEPROM_EN) ? "OK!!" : "ERR!!")); 459 tmp_u1b & EEPROM_EN ? "OK!!" : "ERR!!");
604 _rtl92cu_read_adapter_info(hw); 460 _rtl92cu_read_adapter_info(hw);
605 _rtl92cu_hal_customized_behavior(hw); 461 _rtl92cu_hal_customized_behavior(hw);
606 return; 462 return;
@@ -618,13 +474,12 @@ static int _rtl92cu_init_power_on(struct ieee80211_hw *hw)
618 do { 474 do {
619 if (rtl_read_byte(rtlpriv, REG_APS_FSMCO) & PFM_ALDN) { 475 if (rtl_read_byte(rtlpriv, REG_APS_FSMCO) & PFM_ALDN) {
620 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 476 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
621 ("Autoload Done!\n")); 477 "Autoload Done!\n");
622 break; 478 break;
623 } 479 }
624 if (pollingCount++ > 100) { 480 if (pollingCount++ > 100) {
625 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, 481 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG,
626 ("Failed to polling REG_APS_FSMCO[PFM_ALDN]" 482 "Failed to polling REG_APS_FSMCO[PFM_ALDN] done!\n");
627 " done!\n"));
628 return -ENODEV; 483 return -ENODEV;
629 } 484 }
630 } while (true); 485 } while (true);
@@ -639,8 +494,8 @@ static int _rtl92cu_init_power_on(struct ieee80211_hw *hw)
639 value8 |= LDV12_EN; 494 value8 |= LDV12_EN;
640 rtl_write_byte(rtlpriv, REG_LDOV12D_CTRL, value8); 495 rtl_write_byte(rtlpriv, REG_LDOV12D_CTRL, value8);
641 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 496 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
642 (" power-on :REG_LDOV12D_CTRL Reg0x21:0x%02x.\n", 497 " power-on :REG_LDOV12D_CTRL Reg0x21:0x%02x\n",
643 value8)); 498 value8);
644 udelay(100); 499 udelay(100);
645 value8 = rtl_read_byte(rtlpriv, REG_SYS_ISO_CTRL); 500 value8 = rtl_read_byte(rtlpriv, REG_SYS_ISO_CTRL);
646 value8 &= ~ISO_MD2PP; 501 value8 &= ~ISO_MD2PP;
@@ -658,8 +513,7 @@ static int _rtl92cu_init_power_on(struct ieee80211_hw *hw)
658 } 513 }
659 if (pollingCount++ > 100) { 514 if (pollingCount++ > 100) {
660 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, 515 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG,
661 ("Failed to polling REG_APS_FSMCO[APFM_ONMAC]" 516 "Failed to polling REG_APS_FSMCO[APFM_ONMAC] done!\n");
662 " done!\n"));
663 return -ENODEV; 517 return -ENODEV;
664 } 518 }
665 } while (true); 519 } while (true);
@@ -877,8 +731,8 @@ static void _rtl92cu_init_chipN_three_out_ep_priority(struct ieee80211_hw *hw,
877 hiQ = QUEUE_HIGH; 731 hiQ = QUEUE_HIGH;
878 } 732 }
879 _rtl92c_init_chipN_reg_priority(hw, beQ, bkQ, viQ, voQ, mgtQ, hiQ); 733 _rtl92c_init_chipN_reg_priority(hw, beQ, bkQ, viQ, voQ, mgtQ, hiQ);
880 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, 734 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "Tx queue select :0x%02x..\n",
881 ("Tx queue select :0x%02x..\n", queue_sel)); 735 queue_sel);
882} 736}
883 737
884static void _rtl92cu_init_chipN_queue_priority(struct ieee80211_hw *hw, 738static void _rtl92cu_init_chipN_queue_priority(struct ieee80211_hw *hw,
@@ -937,8 +791,8 @@ static void _rtl92cu_init_chipT_queue_priority(struct ieee80211_hw *hw,
937 break; 791 break;
938 } 792 }
939 rtl_write_byte(rtlpriv, (REG_TRXDMA_CTRL+1), hq_sele); 793 rtl_write_byte(rtlpriv, (REG_TRXDMA_CTRL+1), hq_sele);
940 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, 794 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "Tx queue select :0x%02x..\n",
941 ("Tx queue select :0x%02x..\n", hq_sele)); 795 hq_sele);
942} 796}
943 797
944static void _rtl92cu_init_queue_priority(struct ieee80211_hw *hw, 798static void _rtl92cu_init_queue_priority(struct ieee80211_hw *hw,
@@ -998,7 +852,7 @@ static int _rtl92cu_init_mac(struct ieee80211_hw *hw)
998 852
999 if (err) { 853 if (err) {
1000 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 854 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1001 ("Failed to init power on!\n")); 855 "Failed to init power on!\n");
1002 return err; 856 return err;
1003 } 857 }
1004 if (!wmm_enable) { 858 if (!wmm_enable) {
@@ -1010,7 +864,7 @@ static int _rtl92cu_init_mac(struct ieee80211_hw *hw)
1010 } 864 }
1011 if (false == rtl92c_init_llt_table(hw, boundary)) { 865 if (false == rtl92c_init_llt_table(hw, boundary)) {
1012 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 866 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1013 ("Failed to init LLT Table!\n")); 867 "Failed to init LLT Table!\n");
1014 return -EINVAL; 868 return -EINVAL;
1015 } 869 }
1016 _rtl92cu_init_queue_reserved_page(hw, wmm_enable, out_ep_nums, 870 _rtl92cu_init_queue_reserved_page(hw, wmm_enable, out_ep_nums,
@@ -1043,12 +897,12 @@ void rtl92cu_enable_hw_security_config(struct ieee80211_hw *hw)
1043 struct rtl_hal *rtlhal = rtl_hal(rtlpriv); 897 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
1044 898
1045 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 899 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1046 ("PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n", 900 "PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n",
1047 rtlpriv->sec.pairwise_enc_algorithm, 901 rtlpriv->sec.pairwise_enc_algorithm,
1048 rtlpriv->sec.group_enc_algorithm)); 902 rtlpriv->sec.group_enc_algorithm);
1049 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { 903 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
1050 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 904 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
1051 ("not open sw encryption\n")); 905 "not open sw encryption\n");
1052 return; 906 return;
1053 } 907 }
1054 sec_reg_value = SCR_TxEncEnable | SCR_RxDecEnable; 908 sec_reg_value = SCR_TxEncEnable | SCR_RxDecEnable;
@@ -1059,8 +913,8 @@ void rtl92cu_enable_hw_security_config(struct ieee80211_hw *hw)
1059 if (IS_NORMAL_CHIP(rtlhal->version)) 913 if (IS_NORMAL_CHIP(rtlhal->version))
1060 sec_reg_value |= (SCR_RXBCUSEDK | SCR_TXBCUSEDK); 914 sec_reg_value |= (SCR_RXBCUSEDK | SCR_TXBCUSEDK);
1061 rtl_write_byte(rtlpriv, REG_CR + 1, 0x02); 915 rtl_write_byte(rtlpriv, REG_CR + 1, 0x02);
1062 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 916 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "The SECR-value %x\n",
1063 ("The SECR-value %x\n", sec_reg_value)); 917 sec_reg_value);
1064 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value); 918 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value);
1065} 919}
1066 920
@@ -1111,34 +965,6 @@ static void _InitPABias(struct ieee80211_hw *hw)
1111 } 965 }
1112} 966}
1113 967
1114static void _InitAntenna_Selection(struct ieee80211_hw *hw)
1115{
1116#ifdef CONFIG_ANTENNA_DIVERSITY
1117 struct rtl_priv *rtlpriv = rtl_priv(hw);
1118 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1119 struct rtl_phy *rtlphy = &(rtlpriv->phy);
1120
1121 if (pHalData->AntDivCfg == 0)
1122 return;
1123
1124 if (rtlphy->rf_type == RF_1T1R) {
1125 rtl_write_dword(rtlpriv, REG_LEDCFG0,
1126 rtl_read_dword(rtlpriv,
1127 REG_LEDCFG0)|BIT(23));
1128 rtl_set_bbreg(hw, rFPGA0_XAB_RFPARAMETER, BIT(13), 0x01);
1129 if (rtl_get_bbreg(hw, RFPGA0_XA_RFINTERFACEOE, 0x300) ==
1130 Antenna_A)
1131 pHalData->CurAntenna = Antenna_A;
1132 else
1133 pHalData->CurAntenna = Antenna_B;
1134 }
1135#endif
1136}
1137
1138static void _dump_registers(struct ieee80211_hw *hw)
1139{
1140}
1141
1142static void _update_mac_setting(struct ieee80211_hw *hw) 968static void _update_mac_setting(struct ieee80211_hw *hw)
1143{ 969{
1144 struct rtl_priv *rtlpriv = rtl_priv(hw); 970 struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -1163,18 +989,15 @@ int rtl92cu_hw_init(struct ieee80211_hw *hw)
1163 rtlhal->hw_type = HARDWARE_TYPE_RTL8192CU; 989 rtlhal->hw_type = HARDWARE_TYPE_RTL8192CU;
1164 err = _rtl92cu_init_mac(hw); 990 err = _rtl92cu_init_mac(hw);
1165 if (err) { 991 if (err) {
1166 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("init mac failed!\n")); 992 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "init mac failed!\n");
1167 return err; 993 return err;
1168 } 994 }
1169 err = rtl92c_download_fw(hw); 995 err = rtl92c_download_fw(hw);
1170 if (err) { 996 if (err) {
1171 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 997 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1172 ("Failed to download FW. Init HW without FW now..\n")); 998 "Failed to download FW. Init HW without FW now..\n");
1173 err = 1; 999 err = 1;
1174 rtlhal->fw_ready = false;
1175 return err; 1000 return err;
1176 } else {
1177 rtlhal->fw_ready = true;
1178 } 1001 }
1179 rtlhal->last_hmeboxnum = 0; /* h2c */ 1002 rtlhal->last_hmeboxnum = 0; /* h2c */
1180 _rtl92cu_phy_param_tab_init(hw); 1003 _rtl92cu_phy_param_tab_init(hw);
@@ -1209,10 +1032,8 @@ int rtl92cu_hw_init(struct ieee80211_hw *hw)
1209 } 1032 }
1210 _rtl92cu_hw_configure(hw); 1033 _rtl92cu_hw_configure(hw);
1211 _InitPABias(hw); 1034 _InitPABias(hw);
1212 _InitAntenna_Selection(hw);
1213 _update_mac_setting(hw); 1035 _update_mac_setting(hw);
1214 rtl92c_dm_init(hw); 1036 rtl92c_dm_init(hw);
1215 _dump_registers(hw);
1216 return err; 1037 return err;
1217} 1038}
1218 1039
@@ -1270,24 +1091,21 @@ static void _ResetDigitalProcedure1(struct ieee80211_hw *hw, bool bWithoutHWSM)
1270 if (rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(1)) { 1091 if (rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(1)) {
1271 /* reset MCU ready status */ 1092 /* reset MCU ready status */
1272 rtl_write_byte(rtlpriv, REG_MCUFWDL, 0); 1093 rtl_write_byte(rtlpriv, REG_MCUFWDL, 0);
1273 if (rtlhal->fw_ready) { 1094 /* 8051 reset by self */
1274 /* 8051 reset by self */ 1095 rtl_write_byte(rtlpriv, REG_HMETFR+3, 0x20);
1275 rtl_write_byte(rtlpriv, REG_HMETFR+3, 0x20); 1096 while ((retry_cnts++ < 100) &&
1276 while ((retry_cnts++ < 100) && 1097 (FEN_CPUEN & rtl_read_word(rtlpriv,
1277 (FEN_CPUEN & rtl_read_word(rtlpriv, 1098 REG_SYS_FUNC_EN))) {
1278 REG_SYS_FUNC_EN))) { 1099 udelay(50);
1279 udelay(50); 1100 }
1280 } 1101 if (retry_cnts >= 100) {
1281 if (retry_cnts >= 100) { 1102 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1282 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1103 "#####=> 8051 reset failed!.........................\n");
1283 ("#####=> 8051 reset failed!.." 1104 /* if 8051 reset fail, reset MAC. */
1284 ".......................\n");); 1105 rtl_write_byte(rtlpriv,
1285 /* if 8051 reset fail, reset MAC. */ 1106 REG_SYS_FUNC_EN + 1,
1286 rtl_write_byte(rtlpriv, 1107 0x50);
1287 REG_SYS_FUNC_EN + 1, 1108 udelay(100);
1288 0x50);
1289 udelay(100);
1290 }
1291 } 1109 }
1292 } 1110 }
1293 /* Reset MAC and Enable 8051 */ 1111 /* Reset MAC and Enable 8051 */
@@ -1495,35 +1313,36 @@ static int _rtl92cu_set_media_status(struct ieee80211_hw *hw,
1495 _rtl92cu_resume_tx_beacon(hw); 1313 _rtl92cu_resume_tx_beacon(hw);
1496 _rtl92cu_disable_bcn_sub_func(hw); 1314 _rtl92cu_disable_bcn_sub_func(hw);
1497 } else { 1315 } else {
1498 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, ("Set HW_VAR_MEDIA_" 1316 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1499 "STATUS:No such media status(%x).\n", type)); 1317 "Set HW_VAR_MEDIA_STATUS:No such media status(%x)\n",
1318 type);
1500 } 1319 }
1501 switch (type) { 1320 switch (type) {
1502 case NL80211_IFTYPE_UNSPECIFIED: 1321 case NL80211_IFTYPE_UNSPECIFIED:
1503 bt_msr |= MSR_NOLINK; 1322 bt_msr |= MSR_NOLINK;
1504 ledaction = LED_CTL_LINK; 1323 ledaction = LED_CTL_LINK;
1505 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1324 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1506 ("Set Network type to NO LINK!\n")); 1325 "Set Network type to NO LINK!\n");
1507 break; 1326 break;
1508 case NL80211_IFTYPE_ADHOC: 1327 case NL80211_IFTYPE_ADHOC:
1509 bt_msr |= MSR_ADHOC; 1328 bt_msr |= MSR_ADHOC;
1510 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1329 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1511 ("Set Network type to Ad Hoc!\n")); 1330 "Set Network type to Ad Hoc!\n");
1512 break; 1331 break;
1513 case NL80211_IFTYPE_STATION: 1332 case NL80211_IFTYPE_STATION:
1514 bt_msr |= MSR_INFRA; 1333 bt_msr |= MSR_INFRA;
1515 ledaction = LED_CTL_LINK; 1334 ledaction = LED_CTL_LINK;
1516 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1335 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1517 ("Set Network type to STA!\n")); 1336 "Set Network type to STA!\n");
1518 break; 1337 break;
1519 case NL80211_IFTYPE_AP: 1338 case NL80211_IFTYPE_AP:
1520 bt_msr |= MSR_AP; 1339 bt_msr |= MSR_AP;
1521 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1340 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1522 ("Set Network type to AP!\n")); 1341 "Set Network type to AP!\n");
1523 break; 1342 break;
1524 default: 1343 default:
1525 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1344 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1526 ("Network type %d not support!\n", type)); 1345 "Network type %d not supported!\n", type);
1527 goto error_out; 1346 goto error_out;
1528 } 1347 }
1529 rtl_write_byte(rtlpriv, (MSR), bt_msr); 1348 rtl_write_byte(rtlpriv, (MSR), bt_msr);
@@ -1684,8 +1503,8 @@ void rtl92cu_set_beacon_related_registers(struct ieee80211_hw *hw)
1684 value32 |= TSFRST; 1503 value32 |= TSFRST;
1685 rtl_write_dword(rtlpriv, REG_TCR, value32); 1504 rtl_write_dword(rtlpriv, REG_TCR, value32);
1686 RT_TRACE(rtlpriv, COMP_INIT|COMP_BEACON, DBG_LOUD, 1505 RT_TRACE(rtlpriv, COMP_INIT|COMP_BEACON, DBG_LOUD,
1687 ("SetBeaconRelatedRegisters8192CUsb(): Set TCR(%x)\n", 1506 "SetBeaconRelatedRegisters8192CUsb(): Set TCR(%x)\n",
1688 value32)); 1507 value32);
1689 /* TODO: Modify later (Find the right parameters) 1508 /* TODO: Modify later (Find the right parameters)
1690 * NOTE: Fix test chip's bug (about contention windows's randomness) */ 1509 * NOTE: Fix test chip's bug (about contention windows's randomness) */
1691 if ((mac->opmode == NL80211_IFTYPE_ADHOC) || 1510 if ((mac->opmode == NL80211_IFTYPE_ADHOC) ||
@@ -1702,8 +1521,8 @@ void rtl92cu_set_beacon_interval(struct ieee80211_hw *hw)
1702 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 1521 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1703 u16 bcn_interval = mac->beacon_interval; 1522 u16 bcn_interval = mac->beacon_interval;
1704 1523
1705 RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG, 1524 RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG, "beacon_interval:%d\n",
1706 ("beacon_interval:%d\n", bcn_interval)); 1525 bcn_interval);
1707 rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval); 1526 rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval);
1708} 1527}
1709 1528
@@ -1767,7 +1586,7 @@ void rtl92cu_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1767 break; 1586 break;
1768 default: 1587 default:
1769 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1588 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1770 ("switch case not process\n")); 1589 "switch case not processed\n");
1771 break; 1590 break;
1772 } 1591 }
1773} 1592}
@@ -1827,8 +1646,7 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1827 rtl_write_byte(rtlpriv, REG_MAC_SPEC_SIFS + 1, val[0]); 1646 rtl_write_byte(rtlpriv, REG_MAC_SPEC_SIFS + 1, val[0]);
1828 rtl_write_byte(rtlpriv, REG_R2T_SIFS+1, val[0]); 1647 rtl_write_byte(rtlpriv, REG_R2T_SIFS+1, val[0]);
1829 rtl_write_byte(rtlpriv, REG_T2T_SIFS+1, val[0]); 1648 rtl_write_byte(rtlpriv, REG_T2T_SIFS+1, val[0]);
1830 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 1649 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, "HW_VAR_SIFS\n");
1831 ("HW_VAR_SIFS\n"));
1832 break; 1650 break;
1833 } 1651 }
1834 case HW_VAR_SLOT_TIME:{ 1652 case HW_VAR_SLOT_TIME:{
@@ -1837,7 +1655,7 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1837 1655
1838 rtl_write_byte(rtlpriv, REG_SLOT, val[0]); 1656 rtl_write_byte(rtlpriv, REG_SLOT, val[0]);
1839 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 1657 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
1840 ("HW_VAR_SLOT_TIME %x\n", val[0])); 1658 "HW_VAR_SLOT_TIME %x\n", val[0]);
1841 if (QOS_MODE) { 1659 if (QOS_MODE) {
1842 for (e_aci = 0; e_aci < AC_MAX; e_aci++) 1660 for (e_aci = 0; e_aci < AC_MAX; e_aci++)
1843 rtlpriv->cfg->ops->set_hw_reg(hw, 1661 rtlpriv->cfg->ops->set_hw_reg(hw,
@@ -1901,8 +1719,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1901 min_spacing_to_set); 1719 min_spacing_to_set);
1902 *val = min_spacing_to_set; 1720 *val = min_spacing_to_set;
1903 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 1721 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
1904 ("Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", 1722 "Set HW_VAR_AMPDU_MIN_SPACE: %#x\n",
1905 mac->min_space_cfg)); 1723 mac->min_space_cfg);
1906 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, 1724 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE,
1907 mac->min_space_cfg); 1725 mac->min_space_cfg);
1908 } 1726 }
@@ -1916,8 +1734,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1916 mac->min_space_cfg &= 0x07; 1734 mac->min_space_cfg &= 0x07;
1917 mac->min_space_cfg |= (density_to_set << 3); 1735 mac->min_space_cfg |= (density_to_set << 3);
1918 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 1736 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
1919 ("Set HW_VAR_SHORTGI_DENSITY: %#x\n", 1737 "Set HW_VAR_SHORTGI_DENSITY: %#x\n",
1920 mac->min_space_cfg)); 1738 mac->min_space_cfg);
1921 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, 1739 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE,
1922 mac->min_space_cfg); 1740 mac->min_space_cfg);
1923 break; 1741 break;
@@ -1950,8 +1768,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1950 p_regtoset[index]); 1768 p_regtoset[index]);
1951 } 1769 }
1952 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 1770 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
1953 ("Set HW_VAR_AMPDU_FACTOR: %#x\n", 1771 "Set HW_VAR_AMPDU_FACTOR: %#x\n",
1954 factor_toset)); 1772 factor_toset);
1955 } 1773 }
1956 break; 1774 break;
1957 } 1775 }
@@ -1969,8 +1787,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1969 AC_PARAM_ECW_MAX_OFFSET); 1787 AC_PARAM_ECW_MAX_OFFSET);
1970 u4b_ac_param |= (u32) tx_op << AC_PARAM_TXOP_OFFSET; 1788 u4b_ac_param |= (u32) tx_op << AC_PARAM_TXOP_OFFSET;
1971 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 1789 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
1972 ("queue:%x, ac_param:%x\n", e_aci, 1790 "queue:%x, ac_param:%x\n",
1973 u4b_ac_param)); 1791 e_aci, u4b_ac_param);
1974 switch (e_aci) { 1792 switch (e_aci) {
1975 case AC1_BK: 1793 case AC1_BK:
1976 rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM, 1794 rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM,
@@ -1989,8 +1807,9 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1989 u4b_ac_param); 1807 u4b_ac_param);
1990 break; 1808 break;
1991 default: 1809 default:
1992 RT_ASSERT(false, ("SetHwReg8185(): invalid" 1810 RT_ASSERT(false,
1993 " aci: %d !\n", e_aci)); 1811 "SetHwReg8185(): invalid aci: %d !\n",
1812 e_aci);
1994 break; 1813 break;
1995 } 1814 }
1996 if (rtlusb->acm_method != eAcmWay2_SW) 1815 if (rtlusb->acm_method != eAcmWay2_SW)
@@ -2020,8 +1839,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
2020 break; 1839 break;
2021 default: 1840 default:
2022 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1841 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
2023 ("HW_VAR_ACM_CTRL acm set " 1842 "HW_VAR_ACM_CTRL acm set failed: eACI is %d\n",
2024 "failed: eACI is %d\n", acm)); 1843 acm);
2025 break; 1844 break;
2026 } 1845 }
2027 } else { 1846 } else {
@@ -2037,13 +1856,13 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
2037 break; 1856 break;
2038 default: 1857 default:
2039 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1858 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2040 ("switch case not process\n")); 1859 "switch case not processed\n");
2041 break; 1860 break;
2042 } 1861 }
2043 } 1862 }
2044 RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE, 1863 RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE,
2045 ("SetHwReg8190pci(): [HW_VAR_ACM_CTRL] " 1864 "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n",
2046 "Write 0x%X\n", acm_ctrl)); 1865 acm_ctrl);
2047 rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl); 1866 rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl);
2048 break; 1867 break;
2049 } 1868 }
@@ -2051,7 +1870,7 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
2051 rtl_write_dword(rtlpriv, REG_RCR, ((u32 *) (val))[0]); 1870 rtl_write_dword(rtlpriv, REG_RCR, ((u32 *) (val))[0]);
2052 mac->rx_conf = ((u32 *) (val))[0]; 1871 mac->rx_conf = ((u32 *) (val))[0];
2053 RT_TRACE(rtlpriv, COMP_RECV, DBG_DMESG, 1872 RT_TRACE(rtlpriv, COMP_RECV, DBG_DMESG,
2054 ("### Set RCR(0x%08x) ###\n", mac->rx_conf)); 1873 "### Set RCR(0x%08x) ###\n", mac->rx_conf);
2055 break; 1874 break;
2056 } 1875 }
2057 case HW_VAR_RETRY_LIMIT:{ 1876 case HW_VAR_RETRY_LIMIT:{
@@ -2060,8 +1879,9 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
2060 rtl_write_word(rtlpriv, REG_RL, 1879 rtl_write_word(rtlpriv, REG_RL,
2061 retry_limit << RETRY_LIMIT_SHORT_SHIFT | 1880 retry_limit << RETRY_LIMIT_SHORT_SHIFT |
2062 retry_limit << RETRY_LIMIT_LONG_SHIFT); 1881 retry_limit << RETRY_LIMIT_LONG_SHIFT);
2063 RT_TRACE(rtlpriv, COMP_MLME, DBG_DMESG, ("Set HW_VAR_R" 1882 RT_TRACE(rtlpriv, COMP_MLME, DBG_DMESG,
2064 "ETRY_LIMIT(0x%08x)\n", retry_limit)); 1883 "Set HW_VAR_RETRY_LIMIT(0x%08x)\n",
1884 retry_limit);
2065 break; 1885 break;
2066 } 1886 }
2067 case HW_VAR_DUAL_TSF_RST: 1887 case HW_VAR_DUAL_TSF_RST:
@@ -2165,8 +1985,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
2165 rtl_write_word(rtlpriv, REG_RXFLTMAP2, *(u16 *)val); 1985 rtl_write_word(rtlpriv, REG_RXFLTMAP2, *(u16 *)val);
2166 break; 1986 break;
2167 default: 1987 default:
2168 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("switch case " 1988 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2169 "not process\n")); 1989 "switch case not processed\n");
2170 break; 1990 break;
2171 } 1991 }
2172} 1992}
@@ -2239,8 +2059,8 @@ void rtl92cu_update_hal_rate_table(struct ieee80211_hw *hw,
2239 (shortgi_rate << 4) | (shortgi_rate); 2059 (shortgi_rate << 4) | (shortgi_rate);
2240 } 2060 }
2241 rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value); 2061 rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value);
2242 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, ("%x\n", rtl_read_dword(rtlpriv, 2062 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "%x\n",
2243 REG_ARFR0))); 2063 rtl_read_dword(rtlpriv, REG_ARFR0));
2244} 2064}
2245 2065
2246void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level) 2066void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level)
@@ -2344,17 +2164,16 @@ void rtl92cu_update_hal_rate_mask(struct ieee80211_hw *hw, u8 rssi_level)
2344 ratr_bitmap &= 0x0f0ff0ff; 2164 ratr_bitmap &= 0x0f0ff0ff;
2345 break; 2165 break;
2346 } 2166 }
2347 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, ("ratr_bitmap :%x\n", 2167 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "ratr_bitmap :%x\n",
2348 ratr_bitmap)); 2168 ratr_bitmap);
2349 *(u32 *)&rate_mask = ((ratr_bitmap & 0x0fffffff) | 2169 *(u32 *)&rate_mask = ((ratr_bitmap & 0x0fffffff) |
2350 ratr_index << 28); 2170 ratr_index << 28);
2351 rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80; 2171 rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80;
2352 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, ("Rate_index:%x, " 2172 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG,
2353 "ratr_val:%x, %x:%x:%x:%x:%x\n", 2173 "Rate_index:%x, ratr_val:%x, %x:%x:%x:%x:%x\n",
2354 ratr_index, ratr_bitmap, 2174 ratr_index, ratr_bitmap,
2355 rate_mask[0], rate_mask[1], 2175 rate_mask[0], rate_mask[1], rate_mask[2], rate_mask[3],
2356 rate_mask[2], rate_mask[3], 2176 rate_mask[4]);
2357 rate_mask[4]));
2358 rtl92c_fill_h2c_cmd(hw, H2C_RA_MASK, 5, rate_mask); 2177 rtl92c_fill_h2c_cmd(hw, H2C_RA_MASK, 5, rate_mask);
2359} 2178}
2360 2179
@@ -2404,7 +2223,7 @@ bool rtl92cu_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 * valid)
2404 e_rfpowerstate_toset = (u1tmp & BIT(7)) ? 2223 e_rfpowerstate_toset = (u1tmp & BIT(7)) ?
2405 ERFOFF : ERFON; 2224 ERFOFF : ERFON;
2406 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, 2225 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
2407 ("pwrdown, 0x5c(BIT7)=%02x\n", u1tmp)); 2226 "pwrdown, 0x5c(BIT7)=%02x\n", u1tmp);
2408 } else { 2227 } else {
2409 rtl_write_byte(rtlpriv, REG_MAC_PINMUX_CFG, 2228 rtl_write_byte(rtlpriv, REG_MAC_PINMUX_CFG,
2410 rtl_read_byte(rtlpriv, 2229 rtl_read_byte(rtlpriv,
@@ -2413,27 +2232,26 @@ bool rtl92cu_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 * valid)
2413 e_rfpowerstate_toset = (u1tmp & BIT(3)) ? 2232 e_rfpowerstate_toset = (u1tmp & BIT(3)) ?
2414 ERFON : ERFOFF; 2233 ERFON : ERFOFF;
2415 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, 2234 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
2416 ("GPIO_IN=%02x\n", u1tmp)); 2235 "GPIO_IN=%02x\n", u1tmp);
2417 } 2236 }
2418 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("N-SS RF =%x\n", 2237 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "N-SS RF =%x\n",
2419 e_rfpowerstate_toset)); 2238 e_rfpowerstate_toset);
2420 } 2239 }
2421 if ((ppsc->hwradiooff) && (e_rfpowerstate_toset == ERFON)) { 2240 if ((ppsc->hwradiooff) && (e_rfpowerstate_toset == ERFON)) {
2422 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("GPIOChangeRF - HW " 2241 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
2423 "Radio ON, RF ON\n")); 2242 "GPIOChangeRF - HW Radio ON, RF ON\n");
2424 ppsc->hwradiooff = false; 2243 ppsc->hwradiooff = false;
2425 actuallyset = true; 2244 actuallyset = true;
2426 } else if ((!ppsc->hwradiooff) && (e_rfpowerstate_toset == 2245 } else if ((!ppsc->hwradiooff) && (e_rfpowerstate_toset ==
2427 ERFOFF)) { 2246 ERFOFF)) {
2428 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("GPIOChangeRF - HW" 2247 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
2429 " Radio OFF\n")); 2248 "GPIOChangeRF - HW Radio OFF\n");
2430 ppsc->hwradiooff = true; 2249 ppsc->hwradiooff = true;
2431 actuallyset = true; 2250 actuallyset = true;
2432 } else { 2251 } else {
2433 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD , 2252 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
2434 ("pHalData->bHwRadioOff and eRfPowerStateToSet do not" 2253 "pHalData->bHwRadioOff and eRfPowerStateToSet do not match: pHalData->bHwRadioOff %x, eRfPowerStateToSet %x\n",
2435 " match: pHalData->bHwRadioOff %x, eRfPowerStateToSet " 2254 ppsc->hwradiooff, e_rfpowerstate_toset);
2436 "%x\n", ppsc->hwradiooff, e_rfpowerstate_toset));
2437 } 2255 }
2438 if (actuallyset) { 2256 if (actuallyset) {
2439 ppsc->hwradiooff = true; 2257 ppsc->hwradiooff = true;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h
index 32f85cba106a..f41a3aa4a26f 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/led.c b/drivers/net/wireless/rtlwifi/rtl8192cu/led.c
index 2ff9d8314e7b..75a2deb23af1 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/led.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/led.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. 3 * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -47,8 +47,8 @@ void rtl92cu_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
47 u8 ledcfg; 47 u8 ledcfg;
48 struct rtl_priv *rtlpriv = rtl_priv(hw); 48 struct rtl_priv *rtlpriv = rtl_priv(hw);
49 49
50 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, 50 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n",
51 ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); 51 REG_LEDCFG2, pled->ledpin);
52 ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); 52 ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2);
53 switch (pled->ledpin) { 53 switch (pled->ledpin) {
54 case LED_PIN_GPIO0: 54 case LED_PIN_GPIO0:
@@ -62,7 +62,7 @@ void rtl92cu_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
62 break; 62 break;
63 default: 63 default:
64 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 64 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
65 ("switch case not process\n")); 65 "switch case not processed\n");
66 break; 66 break;
67 } 67 }
68 pled->ledon = true; 68 pled->ledon = true;
@@ -74,8 +74,8 @@ void rtl92cu_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
74 struct rtl_usb_priv *usbpriv = rtl_usbpriv(hw); 74 struct rtl_usb_priv *usbpriv = rtl_usbpriv(hw);
75 u8 ledcfg; 75 u8 ledcfg;
76 76
77 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, 77 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n",
78 ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); 78 REG_LEDCFG2, pled->ledpin);
79 ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); 79 ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2);
80 switch (pled->ledpin) { 80 switch (pled->ledpin) {
81 case LED_PIN_GPIO0: 81 case LED_PIN_GPIO0:
@@ -95,7 +95,7 @@ void rtl92cu_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
95 break; 95 break;
96 default: 96 default:
97 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 97 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
98 ("switch case not process\n")); 98 "switch case not processed\n");
99 break; 99 break;
100 } 100 }
101 pled->ledon = false; 101 pled->ledon = false;
@@ -136,7 +136,6 @@ void rtl92cu_led_control(struct ieee80211_hw *hw,
136 ledaction == LED_CTL_POWER_ON)) { 136 ledaction == LED_CTL_POWER_ON)) {
137 return; 137 return;
138 } 138 }
139 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, ("ledaction %d,\n", 139 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "ledaction %d\n", ledaction);
140 ledaction));
141 _rtl92cu_sw_led_control(hw, ledaction); 140 _rtl92cu_sw_led_control(hw, ledaction);
142} 141}
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/led.h b/drivers/net/wireless/rtlwifi/rtl8192cu/led.h
index decaee4d1eb1..0f372278b7af 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/led.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/led.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. 3 * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
index 9e0c8fcdf90f..025bdc2eba44 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. 3 * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -27,10 +27,6 @@
27 * 27 *
28****************************************************************************/ 28****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
32#include <linux/module.h>
33
34#include "../wifi.h" 30#include "../wifi.h"
35#include "../pci.h" 31#include "../pci.h"
36#include "../usb.h" 32#include "../usb.h"
@@ -44,6 +40,8 @@
44#include "mac.h" 40#include "mac.h"
45#include "trx.h" 41#include "trx.h"
46 42
43#include <linux/module.h>
44
47/* macro to shorten lines */ 45/* macro to shorten lines */
48 46
49#define LINK_Q ui_link_quality 47#define LINK_Q ui_link_quality
@@ -57,6 +55,7 @@ void rtl92c_read_chip_version(struct ieee80211_hw *hw)
57 struct rtl_phy *rtlphy = &(rtlpriv->phy); 55 struct rtl_phy *rtlphy = &(rtlpriv->phy);
58 struct rtl_hal *rtlhal = rtl_hal(rtlpriv); 56 struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
59 enum version_8192c chip_version = VERSION_UNKNOWN; 57 enum version_8192c chip_version = VERSION_UNKNOWN;
58 const char *versionid;
60 u32 value32; 59 u32 value32;
61 60
62 value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG); 61 value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG);
@@ -84,88 +83,69 @@ void rtl92c_read_chip_version(struct ieee80211_hw *hw)
84 } 83 }
85 } 84 }
86 rtlhal->version = (enum version_8192c)chip_version; 85 rtlhal->version = (enum version_8192c)chip_version;
87 pr_info("rtl8192cu: Chip version 0x%x\n", chip_version); 86 pr_info("Chip version 0x%x\n", chip_version);
88 switch (rtlhal->version) { 87 switch (rtlhal->version) {
89 case VERSION_NORMAL_TSMC_CHIP_92C_1T2R: 88 case VERSION_NORMAL_TSMC_CHIP_92C_1T2R:
90 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 89 versionid = "NORMAL_B_CHIP_92C";
91 ("Chip Version ID: VERSION_B_CHIP_92C.\n"));
92 break; 90 break;
93 case VERSION_NORMAL_TSMC_CHIP_92C: 91 case VERSION_NORMAL_TSMC_CHIP_92C:
94 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 92 versionid = "NORMAL_TSMC_CHIP_92C";
95 ("Chip Version ID: VERSION_NORMAL_TSMC_CHIP_92C.\n"));
96 break; 93 break;
97 case VERSION_NORMAL_TSMC_CHIP_88C: 94 case VERSION_NORMAL_TSMC_CHIP_88C:
98 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 95 versionid = "NORMAL_TSMC_CHIP_88C";
99 ("Chip Version ID: VERSION_NORMAL_TSMC_CHIP_88C.\n"));
100 break; 96 break;
101 case VERSION_NORMAL_UMC_CHIP_92C_1T2R_A_CUT: 97 case VERSION_NORMAL_UMC_CHIP_92C_1T2R_A_CUT:
102 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 98 versionid = "NORMAL_UMC_CHIP_i92C_1T2R_A_CUT";
103 ("Chip Version ID: VERSION_NORMAL_UMC_CHIP_i"
104 "92C_1T2R_A_CUT.\n"));
105 break; 99 break;
106 case VERSION_NORMAL_UMC_CHIP_92C_A_CUT: 100 case VERSION_NORMAL_UMC_CHIP_92C_A_CUT:
107 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 101 versionid = "NORMAL_UMC_CHIP_92C_A_CUT";
108 ("Chip Version ID: VERSION_NORMAL_UMC_CHIP_"
109 "92C_A_CUT.\n"));
110 break; 102 break;
111 case VERSION_NORMAL_UMC_CHIP_88C_A_CUT: 103 case VERSION_NORMAL_UMC_CHIP_88C_A_CUT:
112 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 104 versionid = "NORMAL_UMC_CHIP_88C_A_CUT";
113 ("Chip Version ID: VERSION_NORMAL_UMC_CHIP"
114 "_88C_A_CUT.\n"));
115 break; 105 break;
116 case VERSION_NORMAL_UMC_CHIP_92C_1T2R_B_CUT: 106 case VERSION_NORMAL_UMC_CHIP_92C_1T2R_B_CUT:
117 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 107 versionid = "NORMAL_UMC_CHIP_92C_1T2R_B_CUT";
118 ("Chip Version ID: VERSION_NORMAL_UMC_CHIP"
119 "_92C_1T2R_B_CUT.\n"));
120 break; 108 break;
121 case VERSION_NORMAL_UMC_CHIP_92C_B_CUT: 109 case VERSION_NORMAL_UMC_CHIP_92C_B_CUT:
122 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 110 versionid = "NORMAL_UMC_CHIP_92C_B_CUT";
123 ("Chip Version ID: VERSION_NORMAL_UMC_CHIP"
124 "_92C_B_CUT.\n"));
125 break; 111 break;
126 case VERSION_NORMAL_UMC_CHIP_88C_B_CUT: 112 case VERSION_NORMAL_UMC_CHIP_88C_B_CUT:
127 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 113 versionid = "NORMAL_UMC_CHIP_88C_B_CUT";
128 ("Chip Version ID: VERSION_NORMAL_UMC_CHIP"
129 "_88C_B_CUT.\n"));
130 break; 114 break;
131 case VERSION_NORMA_UMC_CHIP_8723_1T1R_A_CUT: 115 case VERSION_NORMA_UMC_CHIP_8723_1T1R_A_CUT:
132 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 116 versionid = "NORMAL_UMC_CHIP_8723_1T1R_A_CUT";
133 ("Chip Version ID: VERSION_NORMA_UMC_CHIP"
134 "_8723_1T1R_A_CUT.\n"));
135 break; 117 break;
136 case VERSION_NORMA_UMC_CHIP_8723_1T1R_B_CUT: 118 case VERSION_NORMA_UMC_CHIP_8723_1T1R_B_CUT:
137 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 119 versionid = "NORMAL_UMC_CHIP_8723_1T1R_B_CUT";
138 ("Chip Version ID: VERSION_NORMA_UMC_CHIP"
139 "_8723_1T1R_B_CUT.\n"));
140 break; 120 break;
141 case VERSION_TEST_CHIP_92C: 121 case VERSION_TEST_CHIP_92C:
142 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 122 versionid = "TEST_CHIP_92C";
143 ("Chip Version ID: VERSION_TEST_CHIP_92C.\n"));
144 break; 123 break;
145 case VERSION_TEST_CHIP_88C: 124 case VERSION_TEST_CHIP_88C:
146 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 125 versionid = "TEST_CHIP_88C";
147 ("Chip Version ID: VERSION_TEST_CHIP_88C.\n"));
148 break; 126 break;
149 default: 127 default:
150 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 128 versionid = "UNKNOWN";
151 ("Chip Version ID: ???????????????.\n"));
152 break; 129 break;
153 } 130 }
131 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
132 "Chip Version ID: %s\n", versionid);
133
154 if (IS_92C_SERIAL(rtlhal->version)) 134 if (IS_92C_SERIAL(rtlhal->version))
155 rtlphy->rf_type = 135 rtlphy->rf_type =
156 (IS_92C_1T2R(rtlhal->version)) ? RF_1T2R : RF_2T2R; 136 (IS_92C_1T2R(rtlhal->version)) ? RF_1T2R : RF_2T2R;
157 else 137 else
158 rtlphy->rf_type = RF_1T1R; 138 rtlphy->rf_type = RF_1T1R;
159 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 139 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
160 ("Chip RF Type: %s\n", (rtlphy->rf_type == RF_2T2R) ? 140 "Chip RF Type: %s\n",
161 "RF_2T2R" : "RF_1T1R")); 141 rtlphy->rf_type == RF_2T2R ? "RF_2T2R" : "RF_1T1R");
162 if (get_rf_type(rtlphy) == RF_1T1R) 142 if (get_rf_type(rtlphy) == RF_1T1R)
163 rtlpriv->dm.rfpath_rxenable[0] = true; 143 rtlpriv->dm.rfpath_rxenable[0] = true;
164 else 144 else
165 rtlpriv->dm.rfpath_rxenable[0] = 145 rtlpriv->dm.rfpath_rxenable[0] =
166 rtlpriv->dm.rfpath_rxenable[1] = true; 146 rtlpriv->dm.rfpath_rxenable[1] = true;
167 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("VersionID = 0x%4x\n", 147 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "VersionID = 0x%4x\n",
168 rtlhal->version)); 148 rtlhal->version);
169} 149}
170 150
171/** 151/**
@@ -192,9 +172,8 @@ bool rtl92c_llt_write(struct ieee80211_hw *hw, u32 address, u32 data)
192 break; 172 break;
193 if (count > POLLING_LLT_THRESHOLD) { 173 if (count > POLLING_LLT_THRESHOLD) {
194 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 174 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
195 ("Failed to polling write LLT done at" 175 "Failed to polling write LLT done at address %d! _LLT_OP_VALUE(%x)\n",
196 " address %d! _LLT_OP_VALUE(%x)\n", 176 address, _LLT_OP_VALUE(value));
197 address, _LLT_OP_VALUE(value)));
198 status = false; 177 status = false;
199 break; 178 break;
200 } 179 }
@@ -272,7 +251,7 @@ void rtl92c_set_key(struct ieee80211_hw *hw, u32 key_index,
272 u8 cam_offset = 0; 251 u8 cam_offset = 0;
273 u8 clear_number = 5; 252 u8 clear_number = 5;
274 253
275 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("clear_all\n")); 254 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "clear_all\n");
276 for (idx = 0; idx < clear_number; idx++) { 255 for (idx = 0; idx < clear_number; idx++) {
277 rtl_cam_mark_invalid(hw, cam_offset + idx); 256 rtl_cam_mark_invalid(hw, cam_offset + idx);
278 rtl_cam_empty_entry(hw, cam_offset + idx); 257 rtl_cam_empty_entry(hw, cam_offset + idx);
@@ -298,7 +277,7 @@ void rtl92c_set_key(struct ieee80211_hw *hw, u32 key_index,
298 break; 277 break;
299 default: 278 default:
300 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 279 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
301 ("iillegal switch case\n")); 280 "illegal switch case\n");
302 enc_algo = CAM_TKIP; 281 enc_algo = CAM_TKIP;
303 break; 282 break;
304 } 283 }
@@ -317,26 +296,26 @@ void rtl92c_set_key(struct ieee80211_hw *hw, u32 key_index,
317 } 296 }
318 if (rtlpriv->sec.key_len[key_index] == 0) { 297 if (rtlpriv->sec.key_len[key_index] == 0) {
319 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 298 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
320 ("delete one entry\n")); 299 "delete one entry\n");
321 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id); 300 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id);
322 } else { 301 } else {
323 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 302 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
324 ("The insert KEY length is %d\n", 303 "The insert KEY length is %d\n",
325 rtlpriv->sec.key_len[PAIRWISE_KEYIDX])); 304 rtlpriv->sec.key_len[PAIRWISE_KEYIDX]);
326 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 305 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
327 ("The insert KEY is %x %x\n", 306 "The insert KEY is %x %x\n",
328 rtlpriv->sec.key_buf[0][0], 307 rtlpriv->sec.key_buf[0][0],
329 rtlpriv->sec.key_buf[0][1])); 308 rtlpriv->sec.key_buf[0][1]);
330 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 309 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
331 ("add one entry\n")); 310 "add one entry\n");
332 if (is_pairwise) { 311 if (is_pairwise) {
333 RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD, 312 RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD,
334 "Pairwiase Key content :", 313 "Pairwise Key content",
335 rtlpriv->sec.pairwise_key, 314 rtlpriv->sec.pairwise_key,
336 rtlpriv->sec. 315 rtlpriv->sec.
337 key_len[PAIRWISE_KEYIDX]); 316 key_len[PAIRWISE_KEYIDX]);
338 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 317 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
339 ("set Pairwiase key\n")); 318 "set Pairwise key\n");
340 319
341 rtl_cam_add_one_entry(hw, macaddr, key_index, 320 rtl_cam_add_one_entry(hw, macaddr, key_index,
342 entry_id, enc_algo, 321 entry_id, enc_algo,
@@ -345,7 +324,7 @@ void rtl92c_set_key(struct ieee80211_hw *hw, u32 key_index,
345 key_buf[key_index]); 324 key_buf[key_index]);
346 } else { 325 } else {
347 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 326 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
348 ("set group key\n")); 327 "set group key\n");
349 if (mac->opmode == NL80211_IFTYPE_ADHOC) { 328 if (mac->opmode == NL80211_IFTYPE_ADHOC) {
350 rtl_cam_add_one_entry(hw, 329 rtl_cam_add_one_entry(hw,
351 rtlefuse->dev_addr, 330 rtlefuse->dev_addr,
@@ -421,8 +400,8 @@ void rtl92c_set_qos(struct ieee80211_hw *hw, int aci)
421 AC_PARAM_ECW_MAX_OFFSET; 400 AC_PARAM_ECW_MAX_OFFSET;
422 u4b_ac_param |= (u32) le16_to_cpu(mac->ac[aci].tx_op) << 401 u4b_ac_param |= (u32) le16_to_cpu(mac->ac[aci].tx_op) <<
423 AC_PARAM_TXOP_OFFSET; 402 AC_PARAM_TXOP_OFFSET;
424 RT_TRACE(rtlpriv, COMP_QOS, DBG_LOUD, 403 RT_TRACE(rtlpriv, COMP_QOS, DBG_LOUD, "queue:%x, ac_param:%x\n",
425 ("queue:%x, ac_param:%x\n", aci, u4b_ac_param)); 404 aci, u4b_ac_param);
426 switch (aci) { 405 switch (aci) {
427 case AC1_BK: 406 case AC1_BK:
428 rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM, u4b_ac_param); 407 rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM, u4b_ac_param);
@@ -437,7 +416,7 @@ void rtl92c_set_qos(struct ieee80211_hw *hw, int aci)
437 rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, u4b_ac_param); 416 rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, u4b_ac_param);
438 break; 417 break;
439 default: 418 default:
440 RT_ASSERT(false, ("invalid aci: %d !\n", aci)); 419 RT_ASSERT(false, "invalid aci: %d !\n", aci);
441 break; 420 break;
442 } 421 }
443} 422}
@@ -453,14 +432,14 @@ void rtl92c_set_mac_addr(struct ieee80211_hw *hw, const u8 *addr)
453 for (i = 0 ; i < ETH_ALEN ; i++) 432 for (i = 0 ; i < ETH_ALEN ; i++)
454 rtl_write_byte(rtlpriv, (REG_MACID + i), *(addr+i)); 433 rtl_write_byte(rtlpriv, (REG_MACID + i), *(addr+i));
455 434
456 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, ("MAC Address: %02X-%02X-%02X-" 435 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG,
457 "%02X-%02X-%02X\n", 436 "MAC Address: %02X-%02X-%02X-%02X-%02X-%02X\n",
458 rtl_read_byte(rtlpriv, REG_MACID), 437 rtl_read_byte(rtlpriv, REG_MACID),
459 rtl_read_byte(rtlpriv, REG_MACID+1), 438 rtl_read_byte(rtlpriv, REG_MACID+1),
460 rtl_read_byte(rtlpriv, REG_MACID+2), 439 rtl_read_byte(rtlpriv, REG_MACID+2),
461 rtl_read_byte(rtlpriv, REG_MACID+3), 440 rtl_read_byte(rtlpriv, REG_MACID+3),
462 rtl_read_byte(rtlpriv, REG_MACID+4), 441 rtl_read_byte(rtlpriv, REG_MACID+4),
463 rtl_read_byte(rtlpriv, REG_MACID+5))); 442 rtl_read_byte(rtlpriv, REG_MACID+5));
464} 443}
465 444
466void rtl92c_init_driver_info_size(struct ieee80211_hw *hw, u8 size) 445void rtl92c_init_driver_info_size(struct ieee80211_hw *hw, u8 size)
@@ -478,26 +457,26 @@ int rtl92c_set_network_type(struct ieee80211_hw *hw, enum nl80211_iftype type)
478 case NL80211_IFTYPE_UNSPECIFIED: 457 case NL80211_IFTYPE_UNSPECIFIED:
479 value = NT_NO_LINK; 458 value = NT_NO_LINK;
480 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 459 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
481 ("Set Network type to NO LINK!\n")); 460 "Set Network type to NO LINK!\n");
482 break; 461 break;
483 case NL80211_IFTYPE_ADHOC: 462 case NL80211_IFTYPE_ADHOC:
484 value = NT_LINK_AD_HOC; 463 value = NT_LINK_AD_HOC;
485 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 464 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
486 ("Set Network type to Ad Hoc!\n")); 465 "Set Network type to Ad Hoc!\n");
487 break; 466 break;
488 case NL80211_IFTYPE_STATION: 467 case NL80211_IFTYPE_STATION:
489 value = NT_LINK_AP; 468 value = NT_LINK_AP;
490 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 469 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
491 ("Set Network type to STA!\n")); 470 "Set Network type to STA!\n");
492 break; 471 break;
493 case NL80211_IFTYPE_AP: 472 case NL80211_IFTYPE_AP:
494 value = NT_AS_AP; 473 value = NT_AS_AP;
495 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 474 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
496 ("Set Network type to AP!\n")); 475 "Set Network type to AP!\n");
497 break; 476 break;
498 default: 477 default:
499 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 478 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
500 ("Network type %d not support!\n", type)); 479 "Network type %d not supported!\n", type);
501 return -EOPNOTSUPP; 480 return -EOPNOTSUPP;
502 } 481 }
503 rtl_write_byte(rtlpriv, (REG_CR + 2), value); 482 rtl_write_byte(rtlpriv, (REG_CR + 2), value);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.h b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.h
index 626d88e88e26..bf53652e4edd 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. 3 * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c
index e49cf2244c75..8ac3bcca4d41 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -44,9 +44,9 @@ u32 rtl92cu_phy_query_rf_reg(struct ieee80211_hw *hw,
44 u32 original_value, readback_value, bitshift; 44 u32 original_value, readback_value, bitshift;
45 struct rtl_phy *rtlphy = &(rtlpriv->phy); 45 struct rtl_phy *rtlphy = &(rtlpriv->phy);
46 46
47 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " 47 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
48 "rfpath(%#x), bitmask(%#x)\n", 48 "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
49 regaddr, rfpath, bitmask)); 49 regaddr, rfpath, bitmask);
50 if (rtlphy->rf_mode != RF_OP_BY_FW) { 50 if (rtlphy->rf_mode != RF_OP_BY_FW) {
51 original_value = _rtl92c_phy_rf_serial_read(hw, 51 original_value = _rtl92c_phy_rf_serial_read(hw,
52 rfpath, regaddr); 52 rfpath, regaddr);
@@ -57,9 +57,8 @@ u32 rtl92cu_phy_query_rf_reg(struct ieee80211_hw *hw,
57 bitshift = _rtl92c_phy_calculate_bit_shift(bitmask); 57 bitshift = _rtl92c_phy_calculate_bit_shift(bitmask);
58 readback_value = (original_value & bitmask) >> bitshift; 58 readback_value = (original_value & bitmask) >> bitshift;
59 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, 59 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
60 ("regaddr(%#x), rfpath(%#x), " 60 "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n",
61 "bitmask(%#x), original_value(%#x)\n", 61 regaddr, rfpath, bitmask, original_value);
62 regaddr, rfpath, bitmask, original_value));
63 return readback_value; 62 return readback_value;
64} 63}
65 64
@@ -72,8 +71,8 @@ void rtl92cu_phy_set_rf_reg(struct ieee80211_hw *hw,
72 u32 original_value, bitshift; 71 u32 original_value, bitshift;
73 72
74 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, 73 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
75 ("regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", 74 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
76 regaddr, bitmask, data, rfpath)); 75 regaddr, bitmask, data, rfpath);
77 if (rtlphy->rf_mode != RF_OP_BY_FW) { 76 if (rtlphy->rf_mode != RF_OP_BY_FW) {
78 if (bitmask != RFREG_OFFSET_MASK) { 77 if (bitmask != RFREG_OFFSET_MASK) {
79 original_value = _rtl92c_phy_rf_serial_read(hw, 78 original_value = _rtl92c_phy_rf_serial_read(hw,
@@ -97,9 +96,9 @@ void rtl92cu_phy_set_rf_reg(struct ieee80211_hw *hw,
97 } 96 }
98 _rtl92c_phy_fw_rf_serial_write(hw, rfpath, regaddr, data); 97 _rtl92c_phy_fw_rf_serial_write(hw, rfpath, regaddr, data);
99 } 98 }
100 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " 99 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
101 "bitmask(%#x), data(%#x), rfpath(%#x)\n", 100 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
102 regaddr, bitmask, data, rfpath)); 101 regaddr, bitmask, data, rfpath);
103} 102}
104 103
105bool rtl92cu_phy_mac_config(struct ieee80211_hw *hw) 104bool rtl92cu_phy_mac_config(struct ieee80211_hw *hw)
@@ -152,11 +151,10 @@ bool _rtl92cu_phy_config_mac_with_headerfile(struct ieee80211_hw *hw)
152 u32 arraylength; 151 u32 arraylength;
153 u32 *ptrarray; 152 u32 *ptrarray;
154 153
155 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Read Rtl819XMACPHY_Array\n")); 154 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Read Rtl819XMACPHY_Array\n");
156 arraylength = rtlphy->hwparam_tables[MAC_REG].length ; 155 arraylength = rtlphy->hwparam_tables[MAC_REG].length ;
157 ptrarray = rtlphy->hwparam_tables[MAC_REG].pdata; 156 ptrarray = rtlphy->hwparam_tables[MAC_REG].pdata;
158 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 157 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Img:RTL8192CEMAC_2T_ARRAY\n");
159 ("Img:RTL8192CEMAC_2T_ARRAY\n"));
160 for (i = 0; i < arraylength; i = i + 2) 158 for (i = 0; i < arraylength; i = i + 2)
161 rtl_write_byte(rtlpriv, ptrarray[i], (u8) ptrarray[i + 1]); 159 rtl_write_byte(rtlpriv, ptrarray[i], (u8) ptrarray[i + 1]);
162 return true; 160 return true;
@@ -202,10 +200,9 @@ bool _rtl92cu_phy_config_bb_with_headerfile(struct ieee80211_hw *hw,
202 phy_regarray_table[i + 1]); 200 phy_regarray_table[i + 1]);
203 udelay(1); 201 udelay(1);
204 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 202 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
205 ("The phy_regarray_table[0] is %x" 203 "The phy_regarray_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n",
206 " Rtl819XPHY_REGArray[1] is %x\n", 204 phy_regarray_table[i],
207 phy_regarray_table[i], 205 phy_regarray_table[i + 1]);
208 phy_regarray_table[i + 1]));
209 } 206 }
210 } else if (configtype == BASEBAND_CONFIG_AGC_TAB) { 207 } else if (configtype == BASEBAND_CONFIG_AGC_TAB) {
211 for (i = 0; i < agctab_arraylen; i = i + 2) { 208 for (i = 0; i < agctab_arraylen; i = i + 2) {
@@ -213,10 +210,9 @@ bool _rtl92cu_phy_config_bb_with_headerfile(struct ieee80211_hw *hw,
213 agctab_array_table[i + 1]); 210 agctab_array_table[i + 1]);
214 udelay(1); 211 udelay(1);
215 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 212 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
216 ("The agctab_array_table[0] is " 213 "The agctab_array_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n",
217 "%x Rtl819XPHY_REGArray[1] is %x\n", 214 agctab_array_table[i],
218 agctab_array_table[i], 215 agctab_array_table[i + 1]);
219 agctab_array_table[i + 1]));
220 } 216 }
221 } 217 }
222 return true; 218 return true;
@@ -255,7 +251,7 @@ bool _rtl92cu_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw,
255 } 251 }
256 } else { 252 } else {
257 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, 253 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
258 ("configtype != BaseBand_Config_PHY_REG\n")); 254 "configtype != BaseBand_Config_PHY_REG\n");
259 } 255 }
260 return true; 256 return true;
261} 257}
@@ -277,20 +273,20 @@ bool rtl92cu_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
277 radiob_arraylen = rtlphy->hwparam_tables[RADIOB_2T].length; 273 radiob_arraylen = rtlphy->hwparam_tables[RADIOB_2T].length;
278 radiob_array_table = rtlphy->hwparam_tables[RADIOB_2T].pdata; 274 radiob_array_table = rtlphy->hwparam_tables[RADIOB_2T].pdata;
279 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 275 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
280 ("Radio_A:RTL8192CERADIOA_2TARRAY\n")); 276 "Radio_A:RTL8192CERADIOA_2TARRAY\n");
281 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 277 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
282 ("Radio_B:RTL8192CE_RADIOB_2TARRAY\n")); 278 "Radio_B:RTL8192CE_RADIOB_2TARRAY\n");
283 } else { 279 } else {
284 radioa_arraylen = rtlphy->hwparam_tables[RADIOA_1T].length; 280 radioa_arraylen = rtlphy->hwparam_tables[RADIOA_1T].length;
285 radioa_array_table = rtlphy->hwparam_tables[RADIOA_1T].pdata; 281 radioa_array_table = rtlphy->hwparam_tables[RADIOA_1T].pdata;
286 radiob_arraylen = rtlphy->hwparam_tables[RADIOB_1T].length; 282 radiob_arraylen = rtlphy->hwparam_tables[RADIOB_1T].length;
287 radiob_array_table = rtlphy->hwparam_tables[RADIOB_1T].pdata; 283 radiob_array_table = rtlphy->hwparam_tables[RADIOB_1T].pdata;
288 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 284 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
289 ("Radio_A:RTL8192CE_RADIOA_1TARRAY\n")); 285 "Radio_A:RTL8192CE_RADIOA_1TARRAY\n");
290 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 286 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
291 ("Radio_B:RTL8192CE_RADIOB_1TARRAY\n")); 287 "Radio_B:RTL8192CE_RADIOB_1TARRAY\n");
292 } 288 }
293 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Radio No %x\n", rfpath)); 289 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Radio No %x\n", rfpath);
294 switch (rfpath) { 290 switch (rfpath) {
295 case RF90_PATH_A: 291 case RF90_PATH_A:
296 for (i = 0; i < radioa_arraylen; i = i + 2) { 292 for (i = 0; i < radioa_arraylen; i = i + 2) {
@@ -338,11 +334,11 @@ bool rtl92cu_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
338 break; 334 break;
339 case RF90_PATH_C: 335 case RF90_PATH_C:
340 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 336 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
341 ("switch case not process\n")); 337 "switch case not processed\n");
342 break; 338 break;
343 case RF90_PATH_D: 339 case RF90_PATH_D:
344 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 340 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
345 ("switch case not process\n")); 341 "switch case not processed\n");
346 break; 342 break;
347 } 343 }
348 return true; 344 return true;
@@ -357,10 +353,9 @@ void rtl92cu_phy_set_bw_mode_callback(struct ieee80211_hw *hw)
357 u8 reg_bw_opmode; 353 u8 reg_bw_opmode;
358 u8 reg_prsr_rsc; 354 u8 reg_prsr_rsc;
359 355
360 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, 356 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "Switch to %s bandwidth\n",
361 ("Switch to %s bandwidth\n", 357 rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ?
362 rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? 358 "20MHz" : "40MHz");
363 "20MHz" : "40MHz"))
364 if (is_hal_stop(rtlhal)) { 359 if (is_hal_stop(rtlhal)) {
365 rtlphy->set_bwmode_inprogress = false; 360 rtlphy->set_bwmode_inprogress = false;
366 return; 361 return;
@@ -381,7 +376,7 @@ void rtl92cu_phy_set_bw_mode_callback(struct ieee80211_hw *hw)
381 break; 376 break;
382 default: 377 default:
383 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 378 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
384 ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); 379 "unknown bandwidth: %#X\n", rtlphy->current_chan_bw);
385 break; 380 break;
386 } 381 }
387 switch (rtlphy->current_chan_bw) { 382 switch (rtlphy->current_chan_bw) {
@@ -403,12 +398,12 @@ void rtl92cu_phy_set_bw_mode_callback(struct ieee80211_hw *hw)
403 break; 398 break;
404 default: 399 default:
405 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 400 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
406 ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); 401 "unknown bandwidth: %#X\n", rtlphy->current_chan_bw);
407 break; 402 break;
408 } 403 }
409 rtl92cu_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw); 404 rtl92cu_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw);
410 rtlphy->set_bwmode_inprogress = false; 405 rtlphy->set_bwmode_inprogress = false;
411 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); 406 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n");
412} 407}
413 408
414void rtl92cu_bb_block_on(struct ieee80211_hw *hw) 409void rtl92cu_bb_block_on(struct ieee80211_hw *hw)
@@ -480,7 +475,7 @@ static bool _rtl92cu_phy_set_rf_power_state(struct ieee80211_hw *hw,
480 do { 475 do {
481 InitializeCount++; 476 InitializeCount++;
482 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 477 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
483 ("IPS Set eRf nic enable\n")); 478 "IPS Set eRf nic enable\n");
484 rtstatus = rtl_ps_enable_nic(hw); 479 rtstatus = rtl_ps_enable_nic(hw);
485 } while ((rtstatus != true) 480 } while ((rtstatus != true)
486 && (InitializeCount < 10)); 481 && (InitializeCount < 10));
@@ -488,10 +483,9 @@ static bool _rtl92cu_phy_set_rf_power_state(struct ieee80211_hw *hw,
488 RT_RF_OFF_LEVL_HALT_NIC); 483 RT_RF_OFF_LEVL_HALT_NIC);
489 } else { 484 } else {
490 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 485 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
491 ("Set ERFON sleeped:%d ms\n", 486 "Set ERFON sleeped:%d ms\n",
492 jiffies_to_msecs(jiffies - 487 jiffies_to_msecs(jiffies -
493 ppsc-> 488 ppsc->last_sleep_jiffies));
494 last_sleep_jiffies)));
495 ppsc->last_awake_jiffies = jiffies; 489 ppsc->last_awake_jiffies = jiffies;
496 rtl92ce_phy_set_rf_on(hw); 490 rtl92ce_phy_set_rf_on(hw);
497 } 491 }
@@ -513,27 +507,25 @@ static bool _rtl92cu_phy_set_rf_power_state(struct ieee80211_hw *hw,
513 continue; 507 continue;
514 } else { 508 } else {
515 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 509 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
516 ("eRf Off/Sleep: %d times " 510 "eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n",
517 "TcbBusyQueue[%d] " 511 i + 1,
518 "=%d before doze!\n", (i + 1), 512 queue_id,
519 queue_id, 513 skb_queue_len(&ring->queue));
520 skb_queue_len(&ring->queue)));
521 udelay(10); 514 udelay(10);
522 i++; 515 i++;
523 } 516 }
524 if (i >= MAX_DOZE_WAITING_TIMES_9x) { 517 if (i >= MAX_DOZE_WAITING_TIMES_9x) {
525 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 518 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
526 ("\nERFOFF: %d times " 519 "ERFOFF: %d times TcbBusyQueue[%d] = %d !\n",
527 "TcbBusyQueue[%d] = %d !\n", 520 MAX_DOZE_WAITING_TIMES_9x,
528 MAX_DOZE_WAITING_TIMES_9x, 521 queue_id,
529 queue_id, 522 skb_queue_len(&ring->queue));
530 skb_queue_len(&ring->queue)));
531 break; 523 break;
532 } 524 }
533 } 525 }
534 if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) { 526 if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) {
535 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 527 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
536 ("IPS Set eRf nic disable\n")); 528 "IPS Set eRf nic disable\n");
537 rtl_ps_disable_nic(hw); 529 rtl_ps_disable_nic(hw);
538 RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); 530 RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
539 } else { 531 } else {
@@ -557,33 +549,30 @@ static bool _rtl92cu_phy_set_rf_power_state(struct ieee80211_hw *hw,
557 continue; 549 continue;
558 } else { 550 } else {
559 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 551 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
560 ("eRf Off/Sleep: %d times " 552 "eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n",
561 "TcbBusyQueue[%d] =%d before " 553 i + 1, queue_id,
562 "doze!\n", (i + 1), queue_id, 554 skb_queue_len(&ring->queue));
563 skb_queue_len(&ring->queue)));
564 udelay(10); 555 udelay(10);
565 i++; 556 i++;
566 } 557 }
567 if (i >= MAX_DOZE_WAITING_TIMES_9x) { 558 if (i >= MAX_DOZE_WAITING_TIMES_9x) {
568 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 559 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
569 ("\n ERFSLEEP: %d times " 560 "ERFSLEEP: %d times TcbBusyQueue[%d] = %d !\n",
570 "TcbBusyQueue[%d] = %d !\n", 561 MAX_DOZE_WAITING_TIMES_9x,
571 MAX_DOZE_WAITING_TIMES_9x, 562 queue_id,
572 queue_id, 563 skb_queue_len(&ring->queue));
573 skb_queue_len(&ring->queue)));
574 break; 564 break;
575 } 565 }
576 } 566 }
577 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 567 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
578 ("Set ERFSLEEP awaked:%d ms\n", 568 "Set ERFSLEEP awaked:%d ms\n",
579 jiffies_to_msecs(jiffies - 569 jiffies_to_msecs(jiffies - ppsc->last_awake_jiffies));
580 ppsc->last_awake_jiffies)));
581 ppsc->last_sleep_jiffies = jiffies; 570 ppsc->last_sleep_jiffies = jiffies;
582 _rtl92c_phy_set_rf_sleep(hw); 571 _rtl92c_phy_set_rf_sleep(hw);
583 break; 572 break;
584 default: 573 default:
585 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 574 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
586 ("switch case not process\n")); 575 "switch case not processed\n");
587 bresult = false; 576 bresult = false;
588 break; 577 break;
589 } 578 }
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.h b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.h
index ff81a61729d7..42b068660483 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/reg.h b/drivers/net/wireless/rtlwifi/rtl8192cu/reg.h
index 7f1be614c998..8b81465c629b 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/reg.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/reg.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
index 1e851aae58db..780c0d98a836 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -56,7 +56,7 @@ void rtl92cu_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, u8 bandwidth)
56 break; 56 break;
57 default: 57 default:
58 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 58 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
59 ("unknown bandwidth: %#X\n", bandwidth)); 59 "unknown bandwidth: %#X\n", bandwidth);
60 break; 60 break;
61 } 61 }
62} 62}
@@ -140,26 +140,26 @@ void rtl92cu_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw,
140 rtl_set_bbreg(hw, RTXAGC_A_CCK1_MCS32, MASKBYTE1, tmpval); 140 rtl_set_bbreg(hw, RTXAGC_A_CCK1_MCS32, MASKBYTE1, tmpval);
141 141
142 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 142 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
143 ("CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, 143 "CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n",
144 RTXAGC_A_CCK1_MCS32)); 144 tmpval, RTXAGC_A_CCK1_MCS32);
145 145
146 tmpval = tx_agc[RF90_PATH_A] >> 8; 146 tmpval = tx_agc[RF90_PATH_A] >> 8;
147 if (mac->mode == WIRELESS_MODE_B) 147 if (mac->mode == WIRELESS_MODE_B)
148 tmpval = tmpval & 0xff00ffff; 148 tmpval = tmpval & 0xff00ffff;
149 rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); 149 rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval);
150 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 150 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
151 ("CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, 151 "CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n",
152 RTXAGC_B_CCK11_A_CCK2_11)); 152 tmpval, RTXAGC_B_CCK11_A_CCK2_11);
153 tmpval = tx_agc[RF90_PATH_B] >> 24; 153 tmpval = tx_agc[RF90_PATH_B] >> 24;
154 rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, MASKBYTE0, tmpval); 154 rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, MASKBYTE0, tmpval);
155 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 155 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
156 ("CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, 156 "CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n",
157 RTXAGC_B_CCK11_A_CCK2_11)); 157 tmpval, RTXAGC_B_CCK11_A_CCK2_11);
158 tmpval = tx_agc[RF90_PATH_B] & 0x00ffffff; 158 tmpval = tx_agc[RF90_PATH_B] & 0x00ffffff;
159 rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, 0xffffff00, tmpval); 159 rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, 0xffffff00, tmpval);
160 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 160 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
161 ("CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, 161 "CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n",
162 RTXAGC_B_CCK1_55_MCS32)); 162 tmpval, RTXAGC_B_CCK1_55_MCS32);
163} 163}
164 164
165static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw, 165static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw,
@@ -181,8 +181,8 @@ static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw,
181 (powerBase0 << 8) | powerBase0; 181 (powerBase0 << 8) | powerBase0;
182 *(ofdmbase + i) = powerBase0; 182 *(ofdmbase + i) = powerBase0;
183 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 183 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
184 (" [OFDM power base index rf(%c) = 0x%x]\n", 184 " [OFDM power base index rf(%c) = 0x%x]\n",
185 ((i == 0) ? 'A' : 'B'), *(ofdmbase + i))); 185 i == 0 ? 'A' : 'B', *(ofdmbase + i));
186 } 186 }
187 for (i = 0; i < 2; i++) { 187 for (i = 0; i < 2; i++) {
188 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20) { 188 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20) {
@@ -194,8 +194,8 @@ static void rtl92c_phy_get_power_base(struct ieee80211_hw *hw,
194 (powerBase1 << 16) | (powerBase1 << 8) | powerBase1; 194 (powerBase1 << 16) | (powerBase1 << 8) | powerBase1;
195 *(mcsbase + i) = powerBase1; 195 *(mcsbase + i) = powerBase1;
196 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 196 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
197 (" [MCS power base index rf(%c) = 0x%x]\n", 197 " [MCS power base index rf(%c) = 0x%x]\n",
198 ((i == 0) ? 'A' : 'B'), *(mcsbase + i))); 198 i == 0 ? 'A' : 'B', *(mcsbase + i));
199 } 199 }
200} 200}
201 201
@@ -219,8 +219,8 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
219 [chnlgroup][index + (rf ? 8 : 0)] 219 [chnlgroup][index + (rf ? 8 : 0)]
220 + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); 220 + ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
221 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 221 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
222 ("RTK better performance,writeVal(%c) = 0x%x\n", 222 "RTK better performance,writeVal(%c) = 0x%x\n",
223 ((rf == 0) ? 'A' : 'B'), writeVal)); 223 rf == 0 ? 'A' : 'B', writeVal);
224 break; 224 break;
225 case 1: 225 case 1:
226 if (rtlphy->pwrgroup_cnt == 1) 226 if (rtlphy->pwrgroup_cnt == 1)
@@ -244,32 +244,31 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
244 ((index < 2) ? powerBase0[rf] : 244 ((index < 2) ? powerBase0[rf] :
245 powerBase1[rf]); 245 powerBase1[rf]);
246 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 246 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
247 ("Realtek regulatory, 20MHz, " 247 "Realtek regulatory, 20MHz, writeVal(%c) = 0x%x\n",
248 "writeVal(%c) = 0x%x\n", 248 rf == 0 ? 'A' : 'B', writeVal);
249 ((rf == 0) ? 'A' : 'B'), writeVal));
250 break; 249 break;
251 case 2: 250 case 2:
252 writeVal = ((index < 2) ? powerBase0[rf] : 251 writeVal = ((index < 2) ? powerBase0[rf] :
253 powerBase1[rf]); 252 powerBase1[rf]);
254 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 253 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
255 ("Better regulatory,writeVal(%c) = 0x%x\n", 254 "Better regulatory,writeVal(%c) = 0x%x\n",
256 ((rf == 0) ? 'A' : 'B'), writeVal)); 255 rf == 0 ? 'A' : 'B', writeVal);
257 break; 256 break;
258 case 3: 257 case 3:
259 chnlgroup = 0; 258 chnlgroup = 0;
260 if (rtlphy->current_chan_bw == 259 if (rtlphy->current_chan_bw ==
261 HT_CHANNEL_WIDTH_20_40) { 260 HT_CHANNEL_WIDTH_20_40) {
262 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 261 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
263 ("customer's limit, 40MHzrf(%c) = " 262 "customer's limit, 40MHzrf(%c) = 0x%x\n",
264 "0x%x\n", ((rf == 0) ? 'A' : 'B'), 263 rf == 0 ? 'A' : 'B',
265 rtlefuse->pwrgroup_ht40[rf] 264 rtlefuse->pwrgroup_ht40[rf]
266 [channel - 1])); 265 [channel - 1]);
267 } else { 266 } else {
268 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 267 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
269 ("customer's limit, 20MHz rf(%c) = " 268 "customer's limit, 20MHz rf(%c) = 0x%x\n",
270 "0x%x\n", ((rf == 0) ? 'A' : 'B'), 269 rf == 0 ? 'A' : 'B',
271 rtlefuse->pwrgroup_ht20[rf] 270 rtlefuse->pwrgroup_ht20[rf]
272 [channel - 1])); 271 [channel - 1]);
273 } 272 }
274 for (i = 0; i < 4; i++) { 273 for (i = 0; i < 4; i++) {
275 pwr_diff_limit[i] = 274 pwr_diff_limit[i] =
@@ -297,22 +296,22 @@ static void _rtl92c_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
297 (pwr_diff_limit[2] << 16) | 296 (pwr_diff_limit[2] << 16) |
298 (pwr_diff_limit[1] << 8) | (pwr_diff_limit[0]); 297 (pwr_diff_limit[1] << 8) | (pwr_diff_limit[0]);
299 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 298 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
300 ("Customer's limit rf(%c) = 0x%x\n", 299 "Customer's limit rf(%c) = 0x%x\n",
301 ((rf == 0) ? 'A' : 'B'), customer_limit)); 300 rf == 0 ? 'A' : 'B', customer_limit);
302 writeVal = customer_limit + ((index < 2) ? 301 writeVal = customer_limit + ((index < 2) ?
303 powerBase0[rf] : powerBase1[rf]); 302 powerBase0[rf] : powerBase1[rf]);
304 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 303 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
305 ("Customer, writeVal rf(%c)= 0x%x\n", 304 "Customer, writeVal rf(%c)= 0x%x\n",
306 ((rf == 0) ? 'A' : 'B'), writeVal)); 305 rf == 0 ? 'A' : 'B', writeVal);
307 break; 306 break;
308 default: 307 default:
309 chnlgroup = 0; 308 chnlgroup = 0;
310 writeVal = rtlphy->mcs_txpwrlevel_origoffset[chnlgroup] 309 writeVal = rtlphy->mcs_txpwrlevel_origoffset[chnlgroup]
311 [index + (rf ? 8 : 0)] + ((index < 2) ? 310 [index + (rf ? 8 : 0)] + ((index < 2) ?
312 powerBase0[rf] : powerBase1[rf]); 311 powerBase0[rf] : powerBase1[rf]);
313 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, ("RTK better " 312 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
314 "performance, writeValrf(%c) = 0x%x\n", 313 "RTK better performance, writeValrf(%c) = 0x%x\n",
315 ((rf == 0) ? 'A' : 'B'), writeVal)); 314 rf == 0 ? 'A' : 'B', writeVal);
316 break; 315 break;
317 } 316 }
318 if (rtlpriv->dm.dynamic_txhighpower_lvl == 317 if (rtlpriv->dm.dynamic_txhighpower_lvl ==
@@ -365,7 +364,7 @@ static void _rtl92c_write_ofdm_power_reg(struct ieee80211_hw *hw,
365 regoffset = regoffset_b[index]; 364 regoffset = regoffset_b[index];
366 rtl_set_bbreg(hw, regoffset, MASKDWORD, writeVal); 365 rtl_set_bbreg(hw, regoffset, MASKDWORD, writeVal);
367 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 366 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
368 ("Set 0x%x = %08x\n", regoffset, writeVal)); 367 "Set 0x%x = %08x\n", regoffset, writeVal);
369 if (((get_rf_type(rtlphy) == RF_2T2R) && 368 if (((get_rf_type(rtlphy) == RF_2T2R) &&
370 (regoffset == RTXAGC_A_MCS15_MCS12 || 369 (regoffset == RTXAGC_A_MCS15_MCS12 ||
371 regoffset == RTXAGC_B_MCS15_MCS12)) || 370 regoffset == RTXAGC_B_MCS15_MCS12)) ||
@@ -482,11 +481,11 @@ static bool _rtl92c_phy_rf6052_config_parafile(struct ieee80211_hw *hw)
482 } 481 }
483 if (rtstatus != true) { 482 if (rtstatus != true) {
484 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 483 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
485 ("Radio[%d] Fail!!", rfpath)); 484 "Radio[%d] Fail!!", rfpath);
486 goto phy_rf_cfg_fail; 485 goto phy_rf_cfg_fail;
487 } 486 }
488 } 487 }
489 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("<---\n")); 488 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "<---\n");
490 return rtstatus; 489 return rtstatus;
491phy_rf_cfg_fail: 490phy_rf_cfg_fail:
492 return rtstatus; 491 return rtstatus;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.h b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.h
index 500a2094b6bb..090fd33a158d 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
index 6d2ca773bbc7..82c85286ab2e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. 3 * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -41,7 +41,6 @@
41#include "trx.h" 41#include "trx.h"
42#include "led.h" 42#include "led.h"
43#include "hw.h" 43#include "hw.h"
44#include <linux/vmalloc.h>
45#include <linux/module.h> 44#include <linux/module.h>
46 45
47MODULE_AUTHOR("Georgia <georgia@realtek.com>"); 46MODULE_AUTHOR("Georgia <georgia@realtek.com>");
@@ -54,7 +53,6 @@ MODULE_FIRMWARE("rtlwifi/rtl8192cufw.bin");
54static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw) 53static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw)
55{ 54{
56 struct rtl_priv *rtlpriv = rtl_priv(hw); 55 struct rtl_priv *rtlpriv = rtl_priv(hw);
57 const struct firmware *firmware;
58 int err; 56 int err;
59 57
60 rtlpriv->dm.dm_initialgain_enable = true; 58 rtlpriv->dm.dm_initialgain_enable = true;
@@ -62,29 +60,21 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw)
62 rtlpriv->dm.disable_framebursting = false; 60 rtlpriv->dm.disable_framebursting = false;
63 rtlpriv->dm.thermalvalue = 0; 61 rtlpriv->dm.thermalvalue = 0;
64 rtlpriv->dbg.global_debuglevel = rtlpriv->cfg->mod_params->debug; 62 rtlpriv->dbg.global_debuglevel = rtlpriv->cfg->mod_params->debug;
65 rtlpriv->rtlhal.pfirmware = vmalloc(0x4000); 63
64 /* for firmware buf */
65 rtlpriv->rtlhal.pfirmware = vzalloc(0x4000);
66 if (!rtlpriv->rtlhal.pfirmware) { 66 if (!rtlpriv->rtlhal.pfirmware) {
67 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 67 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
68 ("Can't alloc buffer for fw.\n")); 68 "Can't alloc buffer for fw\n");
69 return 1; 69 return 1;
70 } 70 }
71 /* request fw */ 71
72 err = request_firmware(&firmware, rtlpriv->cfg->fw_name, 72 pr_info("Loading firmware %s\n", rtlpriv->cfg->fw_name);
73 rtlpriv->io.dev); 73 rtlpriv->max_fw_size = 0x4000;
74 if (err) { 74 err = request_firmware_nowait(THIS_MODULE, 1,
75 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 75 rtlpriv->cfg->fw_name, rtlpriv->io.dev,
76 ("Failed to request firmware!\n")); 76 GFP_KERNEL, hw, rtl_fw_cb);
77 return 1; 77
78 }
79 if (firmware->size > 0x4000) {
80 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
81 ("Firmware is too big!\n"));
82 release_firmware(firmware);
83 return 1;
84 }
85 memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size);
86 rtlpriv->rtlhal.fwsize = firmware->size;
87 release_firmware(firmware);
88 78
89 return 0; 79 return 0;
90} 80}
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h
index 43b1177924ab..a1310abd0d54 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. 3 * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/table.c b/drivers/net/wireless/rtlwifi/rtl8192cu/table.c
index d57ef5e88a9e..966be519edb8 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/table.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/table.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/table.h b/drivers/net/wireless/rtlwifi/rtl8192cu/table.h
index c3d5cd826cfa..4b020e9e30b1 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/table.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/table.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. 3 * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
index b3cc7b949992..21bc827c5fa6 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. 3 * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -108,7 +108,7 @@ static void _TwoOutEpMapping(struct ieee80211_hw *hw, bool bIsChipB,
108 108
109 if (bwificfg) { /* for WMM */ 109 if (bwificfg) { /* for WMM */
110 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 110 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
111 ("USB Chip-B & WMM Setting.....\n")); 111 "USB Chip-B & WMM Setting.....\n");
112 ep_map->ep_mapping[RTL_TXQ_BE] = 2; 112 ep_map->ep_mapping[RTL_TXQ_BE] = 2;
113 ep_map->ep_mapping[RTL_TXQ_BK] = 3; 113 ep_map->ep_mapping[RTL_TXQ_BK] = 3;
114 ep_map->ep_mapping[RTL_TXQ_VI] = 3; 114 ep_map->ep_mapping[RTL_TXQ_VI] = 3;
@@ -118,7 +118,7 @@ static void _TwoOutEpMapping(struct ieee80211_hw *hw, bool bIsChipB,
118 ep_map->ep_mapping[RTL_TXQ_HI] = 2; 118 ep_map->ep_mapping[RTL_TXQ_HI] = 2;
119 } else { /* typical setting */ 119 } else { /* typical setting */
120 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 120 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
121 ("USB typical Setting.....\n")); 121 "USB typical Setting.....\n");
122 ep_map->ep_mapping[RTL_TXQ_BE] = 3; 122 ep_map->ep_mapping[RTL_TXQ_BE] = 3;
123 ep_map->ep_mapping[RTL_TXQ_BK] = 3; 123 ep_map->ep_mapping[RTL_TXQ_BK] = 3;
124 ep_map->ep_mapping[RTL_TXQ_VI] = 2; 124 ep_map->ep_mapping[RTL_TXQ_VI] = 2;
@@ -135,7 +135,7 @@ static void _ThreeOutEpMapping(struct ieee80211_hw *hw, bool bwificfg,
135 struct rtl_priv *rtlpriv = rtl_priv(hw); 135 struct rtl_priv *rtlpriv = rtl_priv(hw);
136 if (bwificfg) { /* for WMM */ 136 if (bwificfg) { /* for WMM */
137 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 137 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
138 ("USB 3EP Setting for WMM.....\n")); 138 "USB 3EP Setting for WMM.....\n");
139 ep_map->ep_mapping[RTL_TXQ_BE] = 5; 139 ep_map->ep_mapping[RTL_TXQ_BE] = 5;
140 ep_map->ep_mapping[RTL_TXQ_BK] = 3; 140 ep_map->ep_mapping[RTL_TXQ_BK] = 3;
141 ep_map->ep_mapping[RTL_TXQ_VI] = 3; 141 ep_map->ep_mapping[RTL_TXQ_VI] = 3;
@@ -145,7 +145,7 @@ static void _ThreeOutEpMapping(struct ieee80211_hw *hw, bool bwificfg,
145 ep_map->ep_mapping[RTL_TXQ_HI] = 2; 145 ep_map->ep_mapping[RTL_TXQ_HI] = 2;
146 } else { /* typical setting */ 146 } else { /* typical setting */
147 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 147 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
148 ("USB 3EP Setting for typical.....\n")); 148 "USB 3EP Setting for typical.....\n");
149 ep_map->ep_mapping[RTL_TXQ_BE] = 5; 149 ep_map->ep_mapping[RTL_TXQ_BE] = 5;
150 ep_map->ep_mapping[RTL_TXQ_BK] = 5; 150 ep_map->ep_mapping[RTL_TXQ_BK] = 5;
151 ep_map->ep_mapping[RTL_TXQ_VI] = 3; 151 ep_map->ep_mapping[RTL_TXQ_VI] = 3;
@@ -244,8 +244,8 @@ u16 rtl8192cu_mq_to_hwq(__le16 fc, u16 mac80211_queue_index)
244 break; 244 break;
245 default: 245 default:
246 hw_queue_index = RTL_TXQ_BE; 246 hw_queue_index = RTL_TXQ_BE;
247 RT_ASSERT(false, ("QSLT_BE queue, skb_queue:%d\n", 247 RT_ASSERT(false, "QSLT_BE queue, skb_queue:%d\n",
248 mac80211_queue_index)); 248 mac80211_queue_index);
249 break; 249 break;
250 } 250 }
251out: 251out:
@@ -270,23 +270,23 @@ static enum rtl_desc_qsel _rtl8192cu_mq_to_descq(struct ieee80211_hw *hw,
270 case 0: /* VO */ 270 case 0: /* VO */
271 qsel = QSLT_VO; 271 qsel = QSLT_VO;
272 RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG, 272 RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG,
273 ("VO queue, set qsel = 0x%x\n", QSLT_VO)); 273 "VO queue, set qsel = 0x%x\n", QSLT_VO);
274 break; 274 break;
275 case 1: /* VI */ 275 case 1: /* VI */
276 qsel = QSLT_VI; 276 qsel = QSLT_VI;
277 RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG, 277 RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG,
278 ("VI queue, set qsel = 0x%x\n", QSLT_VI)); 278 "VI queue, set qsel = 0x%x\n", QSLT_VI);
279 break; 279 break;
280 case 3: /* BK */ 280 case 3: /* BK */
281 qsel = QSLT_BK; 281 qsel = QSLT_BK;
282 RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG, 282 RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG,
283 ("BK queue, set qsel = 0x%x\n", QSLT_BK)); 283 "BK queue, set qsel = 0x%x\n", QSLT_BK);
284 break; 284 break;
285 case 2: /* BE */ 285 case 2: /* BE */
286 default: 286 default:
287 qsel = QSLT_BE; 287 qsel = QSLT_BE;
288 RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG, 288 RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG,
289 ("BE queue, set qsel = 0x%x\n", QSLT_BE)); 289 "BE queue, set qsel = 0x%x\n", QSLT_BE);
290 break; 290 break;
291 } 291 }
292out: 292out:
@@ -422,17 +422,17 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
422 bv = ieee80211_is_probe_resp(fc); 422 bv = ieee80211_is_probe_resp(fc);
423 if (bv) 423 if (bv)
424 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 424 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
425 ("Got probe response frame.\n")); 425 "Got probe response frame\n");
426 if (ieee80211_is_beacon(fc)) 426 if (ieee80211_is_beacon(fc))
427 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 427 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Got beacon frame\n");
428 ("Got beacon frame.\n"));
429 if (ieee80211_is_data(fc)) 428 if (ieee80211_is_data(fc))
430 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Got data frame.\n")); 429 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Got data frame\n");
431 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 430 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
432 ("Fram: fc = 0x%X addr1 = 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:" 431 "Fram: fc = 0x%X addr1 = 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X\n",
433 "0x%02X\n", fc, (u32)hdr->addr1[0], (u32)hdr->addr1[1], 432 fc,
434 (u32)hdr->addr1[2], (u32)hdr->addr1[3], (u32)hdr->addr1[4], 433 (u32)hdr->addr1[0], (u32)hdr->addr1[1],
435 (u32)hdr->addr1[5])); 434 (u32)hdr->addr1[2], (u32)hdr->addr1[3],
435 (u32)hdr->addr1[4], (u32)hdr->addr1[5]);
436 memcpy(IEEE80211_SKB_RXCB(skb), rx_status, sizeof(*rx_status)); 436 memcpy(IEEE80211_SKB_RXCB(skb), rx_status, sizeof(*rx_status));
437 ieee80211_rx_irqsafe(hw, skb); 437 ieee80211_rx_irqsafe(hw, skb);
438} 438}
@@ -594,7 +594,7 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
594 if (ieee80211_is_data_qos(fc)) { 594 if (ieee80211_is_data_qos(fc)) {
595 if (mac->rdg_en) { 595 if (mac->rdg_en) {
596 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, 596 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
597 ("Enable RDG function.\n")); 597 "Enable RDG function\n");
598 SET_TX_DESC_RDG_ENABLE(txdesc, 1); 598 SET_TX_DESC_RDG_ENABLE(txdesc, 1);
599 SET_TX_DESC_HTC(txdesc, 1); 599 SET_TX_DESC_HTC(txdesc, 1);
600 } 600 }
@@ -620,7 +620,7 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
620 SET_TX_DESC_BMC(txdesc, 1); 620 SET_TX_DESC_BMC(txdesc, 1);
621 _rtl_fill_usb_tx_desc(txdesc); 621 _rtl_fill_usb_tx_desc(txdesc);
622 _rtl_tx_desc_checksum(txdesc); 622 _rtl_tx_desc_checksum(txdesc);
623 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, (" %s ==>\n", __func__)); 623 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "==>\n");
624} 624}
625 625
626void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 * pDesc, 626void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 * pDesc,
@@ -677,7 +677,7 @@ void rtl92cu_tx_fill_cmddesc(struct ieee80211_hw *hw,
677 SET_TX_DESC_HWSEQ_EN(pdesc, 1); 677 SET_TX_DESC_HWSEQ_EN(pdesc, 1);
678 SET_TX_DESC_PKT_ID(pdesc, 8); 678 SET_TX_DESC_PKT_ID(pdesc, 8);
679 } 679 }
680 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, "H2C Tx Cmd Content\n", 680 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, "H2C Tx Cmd Content",
681 pdesc, RTL_TX_DESC_SIZE); 681 pdesc, RTL_TX_DESC_SIZE);
682} 682}
683 683
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.h b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.h
index 53de5f66e242..332b06e78b00 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. All rights reserved. 3 * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/def.h b/drivers/net/wireless/rtlwifi/rtl8192de/def.h
index 946304771748..eafdf76ed64d 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/def.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
index 3cd0736fe8e1..181ed6fc90e6 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -246,23 +246,21 @@ static void rtl92d_dm_false_alarm_counter_statistics(struct ieee80211_hw *hw)
246 rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 2); 246 rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 2);
247 rtl92d_release_cckandrw_pagea_ctl(hw, &flag); 247 rtl92d_release_cckandrw_pagea_ctl(hw, &flag);
248 } 248 }
249 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("Cnt_Fast_Fsync_fail = %x, " 249 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
250 "Cnt_SB_Search_fail = %x\n", 250 "Cnt_Fast_Fsync_fail = %x, Cnt_SB_Search_fail = %x\n",
251 falsealm_cnt->cnt_fast_fsync_fail, 251 falsealm_cnt->cnt_fast_fsync_fail,
252 falsealm_cnt->cnt_sb_search_fail)); 252 falsealm_cnt->cnt_sb_search_fail);
253 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("Cnt_Parity_Fail = %x, " 253 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
254 "Cnt_Rate_Illegal = %x, Cnt_Crc8_fail = %x, " 254 "Cnt_Parity_Fail = %x, Cnt_Rate_Illegal = %x, Cnt_Crc8_fail = %x, Cnt_Mcs_fail = %x\n",
255 "Cnt_Mcs_fail = %x\n",
256 falsealm_cnt->cnt_parity_fail, 255 falsealm_cnt->cnt_parity_fail,
257 falsealm_cnt->cnt_rate_illegal, 256 falsealm_cnt->cnt_rate_illegal,
258 falsealm_cnt->cnt_crc8_fail, 257 falsealm_cnt->cnt_crc8_fail,
259 falsealm_cnt->cnt_mcs_fail)); 258 falsealm_cnt->cnt_mcs_fail);
260 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, 259 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
261 ("Cnt_Ofdm_fail = %x, " "Cnt_Cck_fail = %x, " 260 "Cnt_Ofdm_fail = %x, Cnt_Cck_fail = %x, Cnt_all = %x\n",
262 "Cnt_all = %x\n",
263 falsealm_cnt->cnt_ofdm_fail, 261 falsealm_cnt->cnt_ofdm_fail,
264 falsealm_cnt->cnt_cck_fail, 262 falsealm_cnt->cnt_cck_fail,
265 falsealm_cnt->cnt_all)); 263 falsealm_cnt->cnt_all);
266} 264}
267 265
268static void rtl92d_dm_find_minimum_rssi(struct ieee80211_hw *hw) 266static void rtl92d_dm_find_minimum_rssi(struct ieee80211_hw *hw)
@@ -275,7 +273,7 @@ static void rtl92d_dm_find_minimum_rssi(struct ieee80211_hw *hw)
275 (rtlpriv->dm.UNDEC_SM_PWDB == 0)) { 273 (rtlpriv->dm.UNDEC_SM_PWDB == 0)) {
276 de_digtable.min_undecorated_pwdb_for_dm = 0; 274 de_digtable.min_undecorated_pwdb_for_dm = 0;
277 RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD, 275 RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD,
278 ("Not connected to any\n")); 276 "Not connected to any\n");
279 } 277 }
280 if (mac->link_state >= MAC80211_LINKED) { 278 if (mac->link_state >= MAC80211_LINKED) {
281 if (mac->opmode == NL80211_IFTYPE_AP || 279 if (mac->opmode == NL80211_IFTYPE_AP ||
@@ -283,25 +281,25 @@ static void rtl92d_dm_find_minimum_rssi(struct ieee80211_hw *hw)
283 de_digtable.min_undecorated_pwdb_for_dm = 281 de_digtable.min_undecorated_pwdb_for_dm =
284 rtlpriv->dm.UNDEC_SM_PWDB; 282 rtlpriv->dm.UNDEC_SM_PWDB;
285 RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD, 283 RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD,
286 ("AP Client PWDB = 0x%lx\n", 284 "AP Client PWDB = 0x%lx\n",
287 rtlpriv->dm.UNDEC_SM_PWDB)); 285 rtlpriv->dm.UNDEC_SM_PWDB);
288 } else { 286 } else {
289 de_digtable.min_undecorated_pwdb_for_dm = 287 de_digtable.min_undecorated_pwdb_for_dm =
290 rtlpriv->dm.undecorated_smoothed_pwdb; 288 rtlpriv->dm.undecorated_smoothed_pwdb;
291 RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD, 289 RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD,
292 ("STA Default Port PWDB = 0x%x\n", 290 "STA Default Port PWDB = 0x%x\n",
293 de_digtable.min_undecorated_pwdb_for_dm)); 291 de_digtable.min_undecorated_pwdb_for_dm);
294 } 292 }
295 } else { 293 } else {
296 de_digtable.min_undecorated_pwdb_for_dm = 294 de_digtable.min_undecorated_pwdb_for_dm =
297 rtlpriv->dm.UNDEC_SM_PWDB; 295 rtlpriv->dm.UNDEC_SM_PWDB;
298 RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD, 296 RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD,
299 ("AP Ext Port or disconnet PWDB = 0x%x\n", 297 "AP Ext Port or disconnet PWDB = 0x%x\n",
300 de_digtable.min_undecorated_pwdb_for_dm)); 298 de_digtable.min_undecorated_pwdb_for_dm);
301 } 299 }
302 300
303 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("MinUndecoratedPWDBForDM =%d\n", 301 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "MinUndecoratedPWDBForDM =%d\n",
304 de_digtable.min_undecorated_pwdb_for_dm)); 302 de_digtable.min_undecorated_pwdb_for_dm);
305} 303}
306 304
307static void rtl92d_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw) 305static void rtl92d_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw)
@@ -340,14 +338,14 @@ static void rtl92d_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw)
340 } 338 }
341 de_digtable.pre_cck_pd_state = de_digtable.cur_cck_pd_state; 339 de_digtable.pre_cck_pd_state = de_digtable.cur_cck_pd_state;
342 } 340 }
343 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("CurSTAConnectState=%s\n", 341 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "CurSTAConnectState=%s\n",
344 (de_digtable.cursta_connectctate == DIG_STA_CONNECT ? 342 de_digtable.cursta_connectctate == DIG_STA_CONNECT ?
345 "DIG_STA_CONNECT " : "DIG_STA_DISCONNECT"))); 343 "DIG_STA_CONNECT " : "DIG_STA_DISCONNECT");
346 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("CCKPDStage=%s\n", 344 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "CCKPDStage=%s\n",
347 (de_digtable.cur_cck_pd_state == CCK_PD_STAGE_LOWRSSI ? 345 de_digtable.cur_cck_pd_state == CCK_PD_STAGE_LOWRSSI ?
348 "Low RSSI " : "High RSSI "))); 346 "Low RSSI " : "High RSSI ");
349 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("is92d single phy =%x\n", 347 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "is92d single phy =%x\n",
350 IS_92D_SINGLEPHY(rtlpriv->rtlhal.version))); 348 IS_92D_SINGLEPHY(rtlpriv->rtlhal.version));
351 349
352} 350}
353 351
@@ -355,12 +353,12 @@ void rtl92d_dm_write_dig(struct ieee80211_hw *hw)
355{ 353{
356 struct rtl_priv *rtlpriv = rtl_priv(hw); 354 struct rtl_priv *rtlpriv = rtl_priv(hw);
357 355
358 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("cur_igvalue = 0x%x, " 356 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
359 "pre_igvalue = 0x%x, backoff_val = %d\n", 357 "cur_igvalue = 0x%x, pre_igvalue = 0x%x, backoff_val = %d\n",
360 de_digtable.cur_igvalue, de_digtable.pre_igvalue, 358 de_digtable.cur_igvalue, de_digtable.pre_igvalue,
361 de_digtable.backoff_val)); 359 de_digtable.backoff_val);
362 if (de_digtable.dig_enable_flag == false) { 360 if (de_digtable.dig_enable_flag == false) {
363 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("DIG is disabled\n")); 361 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "DIG is disabled\n");
364 de_digtable.pre_igvalue = 0x17; 362 de_digtable.pre_igvalue = 0x17;
365 return; 363 return;
366 } 364 }
@@ -377,22 +375,21 @@ static void rtl92d_early_mode_enabled(struct rtl_priv *rtlpriv)
377{ 375{
378 if ((rtlpriv->mac80211.link_state >= MAC80211_LINKED) && 376 if ((rtlpriv->mac80211.link_state >= MAC80211_LINKED) &&
379 (rtlpriv->mac80211.vendor == PEER_CISCO)) { 377 (rtlpriv->mac80211.vendor == PEER_CISCO)) {
380 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, 378 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "IOT_PEER = CISCO\n");
381 ("IOT_PEER = CISCO\n"));
382 if (de_digtable.last_min_undecorated_pwdb_for_dm >= 50 379 if (de_digtable.last_min_undecorated_pwdb_for_dm >= 50
383 && de_digtable.min_undecorated_pwdb_for_dm < 50) { 380 && de_digtable.min_undecorated_pwdb_for_dm < 50) {
384 rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL, 0x00); 381 rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL, 0x00);
385 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, 382 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
386 ("Early Mode Off\n")); 383 "Early Mode Off\n");
387 } else if (de_digtable.last_min_undecorated_pwdb_for_dm <= 55 && 384 } else if (de_digtable.last_min_undecorated_pwdb_for_dm <= 55 &&
388 de_digtable.min_undecorated_pwdb_for_dm > 55) { 385 de_digtable.min_undecorated_pwdb_for_dm > 55) {
389 rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL, 0x0f); 386 rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL, 0x0f);
390 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, 387 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
391 ("Early Mode On\n")); 388 "Early Mode On\n");
392 } 389 }
393 } else if (!(rtl_read_byte(rtlpriv, REG_EARLY_MODE_CONTROL) & 0xf)) { 390 } else if (!(rtl_read_byte(rtlpriv, REG_EARLY_MODE_CONTROL) & 0xf)) {
394 rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL, 0x0f); 391 rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL, 0x0f);
395 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("Early Mode On\n")); 392 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "Early Mode On\n");
396 } 393 }
397} 394}
398 395
@@ -402,7 +399,7 @@ static void rtl92d_dm_dig(struct ieee80211_hw *hw)
402 u8 value_igi = de_digtable.cur_igvalue; 399 u8 value_igi = de_digtable.cur_igvalue;
403 struct false_alarm_statistics *falsealm_cnt = &(rtlpriv->falsealm_cnt); 400 struct false_alarm_statistics *falsealm_cnt = &(rtlpriv->falsealm_cnt);
404 401
405 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("==>\n")); 402 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "==>\n");
406 if (rtlpriv->rtlhal.earlymode_enable) { 403 if (rtlpriv->rtlhal.earlymode_enable) {
407 rtl92d_early_mode_enabled(rtlpriv); 404 rtl92d_early_mode_enabled(rtlpriv);
408 de_digtable.last_min_undecorated_pwdb_for_dm = 405 de_digtable.last_min_undecorated_pwdb_for_dm =
@@ -421,7 +418,7 @@ static void rtl92d_dm_dig(struct ieee80211_hw *hw)
421 /* Not STA mode return tmp */ 418 /* Not STA mode return tmp */
422 if (rtlpriv->mac80211.opmode != NL80211_IFTYPE_STATION) 419 if (rtlpriv->mac80211.opmode != NL80211_IFTYPE_STATION)
423 return; 420 return;
424 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("progress\n")); 421 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "progress\n");
425 /* Decide the current status and if modify initial gain or not */ 422 /* Decide the current status and if modify initial gain or not */
426 if (rtlpriv->mac80211.link_state >= MAC80211_LINKED) 423 if (rtlpriv->mac80211.link_state >= MAC80211_LINKED)
427 de_digtable.cursta_connectctate = DIG_STA_CONNECT; 424 de_digtable.cursta_connectctate = DIG_STA_CONNECT;
@@ -438,16 +435,16 @@ static void rtl92d_dm_dig(struct ieee80211_hw *hw)
438 else if (falsealm_cnt->cnt_all >= DM_DIG_FA_TH2) 435 else if (falsealm_cnt->cnt_all >= DM_DIG_FA_TH2)
439 value_igi += 2; 436 value_igi += 2;
440 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, 437 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
441 ("dm_DIG() Before: large_fa_hit=%d, forbidden_igi=%x\n", 438 "dm_DIG() Before: large_fa_hit=%d, forbidden_igi=%x\n",
442 de_digtable.large_fa_hit, de_digtable.forbidden_igi)); 439 de_digtable.large_fa_hit, de_digtable.forbidden_igi);
443 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, 440 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
444 ("dm_DIG() Before: Recover_cnt=%d, rx_gain_range_min=%x\n", 441 "dm_DIG() Before: Recover_cnt=%d, rx_gain_range_min=%x\n",
445 de_digtable.recover_cnt, de_digtable.rx_gain_range_min)); 442 de_digtable.recover_cnt, de_digtable.rx_gain_range_min);
446 443
447 /* deal with abnorally large false alarm */ 444 /* deal with abnorally large false alarm */
448 if (falsealm_cnt->cnt_all > 10000) { 445 if (falsealm_cnt->cnt_all > 10000) {
449 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, 446 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
450 ("dm_DIG(): Abnornally false alarm case.\n")); 447 "dm_DIG(): Abnormally false alarm case\n");
451 448
452 de_digtable.large_fa_hit++; 449 de_digtable.large_fa_hit++;
453 if (de_digtable.forbidden_igi < de_digtable.cur_igvalue) { 450 if (de_digtable.forbidden_igi < de_digtable.cur_igvalue) {
@@ -486,11 +483,11 @@ static void rtl92d_dm_dig(struct ieee80211_hw *hw)
486 } 483 }
487 } 484 }
488 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, 485 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
489 ("dm_DIG() After: large_fa_hit=%d, forbidden_igi=%x\n", 486 "dm_DIG() After: large_fa_hit=%d, forbidden_igi=%x\n",
490 de_digtable.large_fa_hit, de_digtable.forbidden_igi)); 487 de_digtable.large_fa_hit, de_digtable.forbidden_igi);
491 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, 488 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
492 ("dm_DIG() After: recover_cnt=%d, rx_gain_range_min=%x\n", 489 "dm_DIG() After: recover_cnt=%d, rx_gain_range_min=%x\n",
493 de_digtable.recover_cnt, de_digtable.rx_gain_range_min)); 490 de_digtable.recover_cnt, de_digtable.rx_gain_range_min);
494 491
495 if (value_igi > DM_DIG_MAX) 492 if (value_igi > DM_DIG_MAX)
496 value_igi = DM_DIG_MAX; 493 value_igi = DM_DIG_MAX;
@@ -500,7 +497,7 @@ static void rtl92d_dm_dig(struct ieee80211_hw *hw)
500 rtl92d_dm_write_dig(hw); 497 rtl92d_dm_write_dig(hw);
501 if (rtlpriv->rtlhal.current_bandtype != BAND_ON_5G) 498 if (rtlpriv->rtlhal.current_bandtype != BAND_ON_5G)
502 rtl92d_dm_cck_packet_detection_thresh(hw); 499 rtl92d_dm_cck_packet_detection_thresh(hw);
503 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("<<==\n")); 500 RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "<<==\n");
504} 501}
505 502
506static void rtl92d_dm_init_dynamic_txpower(struct ieee80211_hw *hw) 503static void rtl92d_dm_init_dynamic_txpower(struct ieee80211_hw *hw)
@@ -528,7 +525,7 @@ static void rtl92d_dm_dynamic_txpower(struct ieee80211_hw *hw)
528 if ((mac->link_state < MAC80211_LINKED) && 525 if ((mac->link_state < MAC80211_LINKED) &&
529 (rtlpriv->dm.UNDEC_SM_PWDB == 0)) { 526 (rtlpriv->dm.UNDEC_SM_PWDB == 0)) {
530 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, 527 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
531 ("Not connected to any\n")); 528 "Not connected to any\n");
532 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; 529 rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL;
533 rtlpriv->dm.last_dtp_lvl = TXHIGHPWRLEVEL_NORMAL; 530 rtlpriv->dm.last_dtp_lvl = TXHIGHPWRLEVEL_NORMAL;
534 return; 531 return;
@@ -538,40 +535,40 @@ static void rtl92d_dm_dynamic_txpower(struct ieee80211_hw *hw)
538 undecorated_smoothed_pwdb = 535 undecorated_smoothed_pwdb =
539 rtlpriv->dm.UNDEC_SM_PWDB; 536 rtlpriv->dm.UNDEC_SM_PWDB;
540 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 537 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
541 ("IBSS Client PWDB = 0x%lx\n", 538 "IBSS Client PWDB = 0x%lx\n",
542 undecorated_smoothed_pwdb)); 539 undecorated_smoothed_pwdb);
543 } else { 540 } else {
544 undecorated_smoothed_pwdb = 541 undecorated_smoothed_pwdb =
545 rtlpriv->dm.undecorated_smoothed_pwdb; 542 rtlpriv->dm.undecorated_smoothed_pwdb;
546 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 543 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
547 ("STA Default Port PWDB = 0x%lx\n", 544 "STA Default Port PWDB = 0x%lx\n",
548 undecorated_smoothed_pwdb)); 545 undecorated_smoothed_pwdb);
549 } 546 }
550 } else { 547 } else {
551 undecorated_smoothed_pwdb = 548 undecorated_smoothed_pwdb =
552 rtlpriv->dm.UNDEC_SM_PWDB; 549 rtlpriv->dm.UNDEC_SM_PWDB;
553 550
554 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 551 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
555 ("AP Ext Port PWDB = 0x%lx\n", 552 "AP Ext Port PWDB = 0x%lx\n",
556 undecorated_smoothed_pwdb)); 553 undecorated_smoothed_pwdb);
557 } 554 }
558 if (rtlhal->current_bandtype == BAND_ON_5G) { 555 if (rtlhal->current_bandtype == BAND_ON_5G) {
559 if (undecorated_smoothed_pwdb >= 0x33) { 556 if (undecorated_smoothed_pwdb >= 0x33) {
560 rtlpriv->dm.dynamic_txhighpower_lvl = 557 rtlpriv->dm.dynamic_txhighpower_lvl =
561 TXHIGHPWRLEVEL_LEVEL2; 558 TXHIGHPWRLEVEL_LEVEL2;
562 RT_TRACE(rtlpriv, COMP_HIPWR, DBG_LOUD, 559 RT_TRACE(rtlpriv, COMP_HIPWR, DBG_LOUD,
563 ("5G:TxHighPwrLevel_Level2 (TxPwr=0x0)\n")); 560 "5G:TxHighPwrLevel_Level2 (TxPwr=0x0)\n");
564 } else if ((undecorated_smoothed_pwdb < 0x33) 561 } else if ((undecorated_smoothed_pwdb < 0x33)
565 && (undecorated_smoothed_pwdb >= 0x2b)) { 562 && (undecorated_smoothed_pwdb >= 0x2b)) {
566 rtlpriv->dm.dynamic_txhighpower_lvl = 563 rtlpriv->dm.dynamic_txhighpower_lvl =
567 TXHIGHPWRLEVEL_LEVEL1; 564 TXHIGHPWRLEVEL_LEVEL1;
568 RT_TRACE(rtlpriv, COMP_HIPWR, DBG_LOUD, 565 RT_TRACE(rtlpriv, COMP_HIPWR, DBG_LOUD,
569 ("5G:TxHighPwrLevel_Level1 (TxPwr=0x10)\n")); 566 "5G:TxHighPwrLevel_Level1 (TxPwr=0x10)\n");
570 } else if (undecorated_smoothed_pwdb < 0x2b) { 567 } else if (undecorated_smoothed_pwdb < 0x2b) {
571 rtlpriv->dm.dynamic_txhighpower_lvl = 568 rtlpriv->dm.dynamic_txhighpower_lvl =
572 TXHIGHPWRLEVEL_NORMAL; 569 TXHIGHPWRLEVEL_NORMAL;
573 RT_TRACE(rtlpriv, COMP_HIPWR, DBG_LOUD, 570 RT_TRACE(rtlpriv, COMP_HIPWR, DBG_LOUD,
574 ("5G:TxHighPwrLevel_Normal\n")); 571 "5G:TxHighPwrLevel_Normal\n");
575 } 572 }
576 } else { 573 } else {
577 if (undecorated_smoothed_pwdb >= 574 if (undecorated_smoothed_pwdb >=
@@ -579,7 +576,7 @@ static void rtl92d_dm_dynamic_txpower(struct ieee80211_hw *hw)
579 rtlpriv->dm.dynamic_txhighpower_lvl = 576 rtlpriv->dm.dynamic_txhighpower_lvl =
580 TXHIGHPWRLEVEL_LEVEL2; 577 TXHIGHPWRLEVEL_LEVEL2;
581 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 578 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
582 ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n")); 579 "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n");
583 } else 580 } else
584 if ((undecorated_smoothed_pwdb < 581 if ((undecorated_smoothed_pwdb <
585 (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) 582 (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3))
@@ -589,19 +586,19 @@ static void rtl92d_dm_dynamic_txpower(struct ieee80211_hw *hw)
589 rtlpriv->dm.dynamic_txhighpower_lvl = 586 rtlpriv->dm.dynamic_txhighpower_lvl =
590 TXHIGHPWRLEVEL_LEVEL1; 587 TXHIGHPWRLEVEL_LEVEL1;
591 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 588 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
592 ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n")); 589 "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n");
593 } else if (undecorated_smoothed_pwdb < 590 } else if (undecorated_smoothed_pwdb <
594 (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) { 591 (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) {
595 rtlpriv->dm.dynamic_txhighpower_lvl = 592 rtlpriv->dm.dynamic_txhighpower_lvl =
596 TXHIGHPWRLEVEL_NORMAL; 593 TXHIGHPWRLEVEL_NORMAL;
597 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 594 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
598 ("TXHIGHPWRLEVEL_NORMAL\n")); 595 "TXHIGHPWRLEVEL_NORMAL\n");
599 } 596 }
600 } 597 }
601 if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) { 598 if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) {
602 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 599 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
603 ("PHY_SetTxPowerLevel8192S() Channel = %d\n", 600 "PHY_SetTxPowerLevel8192S() Channel = %d\n",
604 rtlphy->current_channel)); 601 rtlphy->current_channel);
605 rtl92d_phy_set_txpower_level(hw, rtlphy->current_channel); 602 rtl92d_phy_set_txpower_level(hw, rtlphy->current_channel);
606 } 603 }
607 rtlpriv->dm.last_dtp_lvl = rtlpriv->dm.dynamic_txhighpower_lvl; 604 rtlpriv->dm.last_dtp_lvl = rtlpriv->dm.dynamic_txhighpower_lvl;
@@ -717,7 +714,7 @@ static void rtl92d_dm_rxgain_tracking_thermalmeter(struct ieee80211_hw *hw)
717 u4tmp = (index_mapping[(rtlpriv->efuse.eeprom_thermalmeter - 714 u4tmp = (index_mapping[(rtlpriv->efuse.eeprom_thermalmeter -
718 rtlpriv->dm.thermalvalue_rxgain)]) << 12; 715 rtlpriv->dm.thermalvalue_rxgain)]) << 12;
719 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 716 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
720 ("===> Rx Gain %x\n", u4tmp)); 717 "===> Rx Gain %x\n", u4tmp);
721 for (i = RF90_PATH_A; i < rtlpriv->phy.num_total_rfpath; i++) 718 for (i = RF90_PATH_A; i < rtlpriv->phy.num_total_rfpath; i++)
722 rtl_set_rfreg(hw, i, 0x3C, BRFREGOFFSETMASK, 719 rtl_set_rfreg(hw, i, 0x3C, BRFREGOFFSETMASK,
723 (rtlpriv->phy.reg_rf3c[i] & (~(0xF000))) | u4tmp); 720 (rtlpriv->phy.reg_rf3c[i] & (~(0xF000))) | u4tmp);
@@ -741,27 +738,22 @@ static void rtl92d_bandtype_2_4G(struct ieee80211_hw *hw, long *temp_cckg,
741 if (!memcmp((void *)&temp_cck, 738 if (!memcmp((void *)&temp_cck,
742 (void *)&cckswing_table_ch14[i][2], 4)) { 739 (void *)&cckswing_table_ch14[i][2], 4)) {
743 *cck_index_old = (u8) i; 740 *cck_index_old = (u8) i;
744 RT_TRACE(rtlpriv, 741 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
745 COMP_POWER_TRACKING, 742 "Initial reg0x%x = 0x%lx, cck_index=0x%x, ch 14 %d\n",
746 DBG_LOUD, 743 RCCK0_TXFILTER2, temp_cck,
747 ("Initial reg0x%x = 0x%lx, " 744 *cck_index_old,
748 "cck_index=0x%x, ch 14 %d\n", 745 rtlpriv->dm.cck_inch14);
749 RCCK0_TXFILTER2,
750 temp_cck, *cck_index_old,
751 rtlpriv->dm.cck_inch14));
752 break; 746 break;
753 } 747 }
754 } else { 748 } else {
755 if (!memcmp((void *) &temp_cck, 749 if (!memcmp((void *) &temp_cck,
756 &cckswing_table_ch1ch13[i][2], 4)) { 750 &cckswing_table_ch1ch13[i][2], 4)) {
757 *cck_index_old = (u8) i; 751 *cck_index_old = (u8) i;
758 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, 752 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
759 DBG_LOUD, 753 "Initial reg0x%x = 0x%lx, cck_index = 0x%x, ch14 %d\n",
760 ("Initial reg0x%x = 0x%lx, " 754 RCCK0_TXFILTER2, temp_cck,
761 "cck_index = 0x%x, ch14 %d\n", 755 *cck_index_old,
762 RCCK0_TXFILTER2, 756 rtlpriv->dm.cck_inch14);
763 temp_cck, *cck_index_old,
764 rtlpriv->dm.cck_inch14));
765 break; 757 break;
766 } 758 }
767 } 759 }
@@ -884,12 +876,12 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter(
884 }; 876 };
885 877
886 rtlpriv->dm.txpower_trackinginit = true; 878 rtlpriv->dm.txpower_trackinginit = true;
887 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, ("\n")); 879 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "\n");
888 thermalvalue = (u8) rtl_get_rfreg(hw, RF90_PATH_A, RF_T_METER, 0xf800); 880 thermalvalue = (u8) rtl_get_rfreg(hw, RF90_PATH_A, RF_T_METER, 0xf800);
889 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 881 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
890 ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x " 882 "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermalmeter 0x%x\n",
891 "eeprom_thermalmeter 0x%x\n", thermalvalue, 883 thermalvalue,
892 rtlpriv->dm.thermalvalue, rtlefuse->eeprom_thermalmeter)); 884 rtlpriv->dm.thermalvalue, rtlefuse->eeprom_thermalmeter);
893 rtl92d_phy_ap_calibrate(hw, (thermalvalue - 885 rtl92d_phy_ap_calibrate(hw, (thermalvalue -
894 rtlefuse->eeprom_thermalmeter)); 886 rtlefuse->eeprom_thermalmeter));
895 if (is2t) 887 if (is2t)
@@ -904,10 +896,9 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter(
904 ofdm_index_old[0] = (u8) i; 896 ofdm_index_old[0] = (u8) i;
905 897
906 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 898 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
907 ("Initial pathA ele_d reg0x%x = 0x%lx," 899 "Initial pathA ele_d reg0x%x = 0x%lx, ofdm_index=0x%x\n",
908 " ofdm_index=0x%x\n",
909 ROFDM0_XATxIQIMBALANCE, 900 ROFDM0_XATxIQIMBALANCE,
910 ele_d, ofdm_index_old[0])); 901 ele_d, ofdm_index_old[0]);
911 break; 902 break;
912 } 903 }
913 } 904 }
@@ -920,11 +911,9 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter(
920 ofdm_index_old[1] = (u8) i; 911 ofdm_index_old[1] = (u8) i;
921 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, 912 RT_TRACE(rtlpriv, COMP_POWER_TRACKING,
922 DBG_LOUD, 913 DBG_LOUD,
923 ("Initial pathB ele_d reg " 914 "Initial pathB ele_d reg 0x%x = 0x%lx, ofdm_index = 0x%x\n",
924 "0x%x = 0x%lx, ofdm_index "
925 "= 0x%x\n",
926 ROFDM0_XBTxIQIMBALANCE, ele_d, 915 ROFDM0_XBTxIQIMBALANCE, ele_d,
927 ofdm_index_old[1])); 916 ofdm_index_old[1]);
928 break; 917 break;
929 } 918 }
930 } 919 }
@@ -952,7 +941,7 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter(
952 rtlpriv->dm.ofdm_index[i] = ofdm_index_old[i]; 941 rtlpriv->dm.ofdm_index[i] = ofdm_index_old[i];
953 rtlpriv->dm.cck_index = cck_index_old; 942 rtlpriv->dm.cck_index = cck_index_old;
954 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 943 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
955 ("reload ofdm index for band switch\n")); 944 "reload ofdm index for band switch\n");
956 } 945 }
957 rtlpriv->dm.thermalvalue_avg 946 rtlpriv->dm.thermalvalue_avg
958 [rtlpriv->dm.thermalvalue_avg_index] = thermalvalue; 947 [rtlpriv->dm.thermalvalue_avg_index] = thermalvalue;
@@ -995,12 +984,10 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter(
995 (thermalvalue - rtlpriv->dm.thermalvalue_rxgain) : 984 (thermalvalue - rtlpriv->dm.thermalvalue_rxgain) :
996 (rtlpriv->dm.thermalvalue_rxgain - thermalvalue); 985 (rtlpriv->dm.thermalvalue_rxgain - thermalvalue);
997 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 986 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
998 ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x" 987 "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermalmeter 0x%x delta 0x%x delta_lck 0x%x delta_iqk 0x%x\n",
999 " eeprom_thermalmeter 0x%x delta 0x%x " 988 thermalvalue, rtlpriv->dm.thermalvalue,
1000 "delta_lck 0x%x delta_iqk 0x%x\n", 989 rtlefuse->eeprom_thermalmeter, delta, delta_lck,
1001 thermalvalue, rtlpriv->dm.thermalvalue, 990 delta_iqk);
1002 rtlefuse->eeprom_thermalmeter, delta, delta_lck,
1003 delta_iqk));
1004 if ((delta_lck > rtlefuse->delta_lck) && 991 if ((delta_lck > rtlefuse->delta_lck) &&
1005 (rtlefuse->delta_lck != 0)) { 992 (rtlefuse->delta_lck != 0)) {
1006 rtlpriv->dm.thermalvalue_lck = thermalvalue; 993 rtlpriv->dm.thermalvalue_lck = thermalvalue;
@@ -1036,17 +1023,15 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter(
1036 } 1023 }
1037 if (is2t) { 1024 if (is2t) {
1038 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1025 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1039 ("temp OFDM_A_index=0x%x, OFDM_B_index" 1026 "temp OFDM_A_index=0x%x, OFDM_B_index = 0x%x,cck_index=0x%x\n",
1040 " = 0x%x,cck_index=0x%x\n", 1027 rtlpriv->dm.ofdm_index[0],
1041 rtlpriv->dm.ofdm_index[0], 1028 rtlpriv->dm.ofdm_index[1],
1042 rtlpriv->dm.ofdm_index[1], 1029 rtlpriv->dm.cck_index);
1043 rtlpriv->dm.cck_index));
1044 } else { 1030 } else {
1045 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1031 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1046 ("temp OFDM_A_index=0x%x,cck_index = " 1032 "temp OFDM_A_index=0x%x,cck_index = 0x%x\n",
1047 "0x%x\n", 1033 rtlpriv->dm.ofdm_index[0],
1048 rtlpriv->dm.ofdm_index[0], 1034 rtlpriv->dm.cck_index);
1049 rtlpriv->dm.cck_index));
1050 } 1035 }
1051 for (i = 0; i < rf; i++) { 1036 for (i = 0; i < rf; i++) {
1052 if (ofdm_index[i] > OFDM_TABLE_SIZE_92D - 1) 1037 if (ofdm_index[i] > OFDM_TABLE_SIZE_92D - 1)
@@ -1070,15 +1055,13 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter(
1070 } 1055 }
1071 if (is2t) { 1056 if (is2t) {
1072 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1057 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1073 ("new OFDM_A_index=0x%x, OFDM_B_index " 1058 "new OFDM_A_index=0x%x, OFDM_B_index = 0x%x, cck_index=0x%x\n",
1074 "= 0x%x, cck_index=0x%x\n",
1075 ofdm_index[0], ofdm_index[1], 1059 ofdm_index[0], ofdm_index[1],
1076 cck_index)); 1060 cck_index);
1077 } else { 1061 } else {
1078 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1062 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1079 ("new OFDM_A_index=0x%x,cck_index = " 1063 "new OFDM_A_index=0x%x,cck_index = 0x%x\n",
1080 "0x%x\n", 1064 ofdm_index[0], cck_index);
1081 ofdm_index[0], cck_index));
1082 } 1065 }
1083 ele_d = (ofdmswing_table[(u8) ofdm_index[0]] & 1066 ele_d = (ofdmswing_table[(u8) ofdm_index[0]] &
1084 0xFFC00000) >> 22; 1067 0xFFC00000) >> 22;
@@ -1124,12 +1107,10 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter(
1124 } 1107 }
1125 1108
1126 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1109 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1127 ("TxPwrTracking for interface %d path A: X =" 1110 "TxPwrTracking for interface %d path A: X = 0x%lx, Y = 0x%lx ele_A = 0x%lx ele_C = 0x%lx ele_D = 0x%lx 0xe94 = 0x%lx 0xe9c = 0x%lx\n",
1128 " 0x%lx, Y = 0x%lx ele_A = 0x%lx ele_C = " 1111 rtlhal->interfaceindex,
1129 "0x%lx ele_D = 0x%lx 0xe94 = 0x%lx 0xe9c = "
1130 "0x%lx\n", rtlhal->interfaceindex,
1131 val_x, val_y, ele_a, ele_c, ele_d, 1112 val_x, val_y, ele_a, ele_c, ele_d,
1132 val_x, val_y)); 1113 val_x, val_y);
1133 1114
1134 if (rtlhal->current_bandtype == BAND_ON_2_4G) { 1115 if (rtlhal->current_bandtype == BAND_ON_2_4G) {
1135 /* Adjust CCK according to IQK result */ 1116 /* Adjust CCK according to IQK result */
@@ -1232,20 +1213,16 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter(
1232 BIT(28), 0x00); 1213 BIT(28), 0x00);
1233 } 1214 }
1234 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1215 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1235 ("TxPwrTracking path B: X = 0x%lx, " 1216 "TxPwrTracking path B: X = 0x%lx, Y = 0x%lx ele_A = 0x%lx ele_C = 0x%lx ele_D = 0x%lx 0xeb4 = 0x%lx 0xebc = 0x%lx\n",
1236 "Y = 0x%lx ele_A = 0x%lx ele_C = 0x" 1217 val_x, val_y, ele_a, ele_c,
1237 "%lx ele_D = 0x%lx 0xeb4 = 0x%lx " 1218 ele_d, val_x, val_y);
1238 "0xebc = 0x%lx\n",
1239 val_x, val_y, ele_a, ele_c,
1240 ele_d, val_x, val_y));
1241 } 1219 }
1242 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1220 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1243 ("TxPwrTracking 0xc80 = 0x%x, 0xc94 = " 1221 "TxPwrTracking 0xc80 = 0x%x, 0xc94 = 0x%x RF 0x24 = 0x%x\n",
1244 "0x%x RF 0x24 = 0x%x\n",
1245 rtl_get_bbreg(hw, 0xc80, BMASKDWORD), 1222 rtl_get_bbreg(hw, 0xc80, BMASKDWORD),
1246 rtl_get_bbreg(hw, 0xc94, BMASKDWORD), 1223 rtl_get_bbreg(hw, 0xc94, BMASKDWORD),
1247 rtl_get_rfreg(hw, RF90_PATH_A, 0x24, 1224 rtl_get_rfreg(hw, RF90_PATH_A, 0x24,
1248 BRFREGOFFSETMASK))); 1225 BRFREGOFFSETMASK));
1249 } 1226 }
1250 if ((delta_iqk > rtlefuse->delta_iqk) && 1227 if ((delta_iqk > rtlefuse->delta_iqk) &&
1251 (rtlefuse->delta_iqk != 0)) { 1228 (rtlefuse->delta_iqk != 0)) {
@@ -1262,7 +1239,7 @@ static void rtl92d_dm_txpower_tracking_callback_thermalmeter(
1262 rtlpriv->dm.thermalvalue = thermalvalue; 1239 rtlpriv->dm.thermalvalue = thermalvalue;
1263 } 1240 }
1264 1241
1265 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, ("<===\n")); 1242 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "<===\n");
1266} 1243}
1267 1244
1268static void rtl92d_dm_initialize_txpower_tracking(struct ieee80211_hw *hw) 1245static void rtl92d_dm_initialize_txpower_tracking(struct ieee80211_hw *hw)
@@ -1273,8 +1250,8 @@ static void rtl92d_dm_initialize_txpower_tracking(struct ieee80211_hw *hw)
1273 rtlpriv->dm.txpower_trackinginit = false; 1250 rtlpriv->dm.txpower_trackinginit = false;
1274 rtlpriv->dm.txpower_track_control = true; 1251 rtlpriv->dm.txpower_track_control = true;
1275 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1252 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1276 ("pMgntInfo->txpower_tracking = %d\n", 1253 "pMgntInfo->txpower_tracking = %d\n",
1277 rtlpriv->dm.txpower_tracking)); 1254 rtlpriv->dm.txpower_tracking);
1278} 1255}
1279 1256
1280void rtl92d_dm_check_txpower_tracking_thermal_meter(struct ieee80211_hw *hw) 1257void rtl92d_dm_check_txpower_tracking_thermal_meter(struct ieee80211_hw *hw)
@@ -1289,12 +1266,12 @@ void rtl92d_dm_check_txpower_tracking_thermal_meter(struct ieee80211_hw *hw)
1289 rtl_set_rfreg(hw, RF90_PATH_A, RF_T_METER, BIT(17) | 1266 rtl_set_rfreg(hw, RF90_PATH_A, RF_T_METER, BIT(17) |
1290 BIT(16), 0x03); 1267 BIT(16), 0x03);
1291 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1268 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1292 ("Trigger 92S Thermal Meter!!\n")); 1269 "Trigger 92S Thermal Meter!!\n");
1293 tm_trigger = 1; 1270 tm_trigger = 1;
1294 return; 1271 return;
1295 } else { 1272 } else {
1296 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 1273 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
1297 ("Schedule TxPowerTracking direct call!!\n")); 1274 "Schedule TxPowerTracking direct call!!\n");
1298 rtl92d_dm_txpower_tracking_callback_thermalmeter(hw); 1275 rtl92d_dm_txpower_tracking_callback_thermalmeter(hw);
1299 tm_trigger = 0; 1276 tm_trigger = 0;
1300 } 1277 }
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.h b/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
index 69354657f0f5..91030ec8ac3e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
index 82f060bdbc0b..f548a8d0068d 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -124,14 +124,14 @@ static void _rtl92d_write_fw(struct ieee80211_hw *hw,
124 u32 pagenums, remainSize; 124 u32 pagenums, remainSize;
125 u32 page, offset; 125 u32 page, offset;
126 126
127 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, ("FW size is %d bytes,\n", size)); 127 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, "FW size is %d bytes,\n", size);
128 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE) 128 if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE)
129 _rtl92d_fill_dummy(bufferPtr, &size); 129 _rtl92d_fill_dummy(bufferPtr, &size);
130 pagenums = size / FW_8192D_PAGE_SIZE; 130 pagenums = size / FW_8192D_PAGE_SIZE;
131 remainSize = size % FW_8192D_PAGE_SIZE; 131 remainSize = size % FW_8192D_PAGE_SIZE;
132 if (pagenums > 8) { 132 if (pagenums > 8) {
133 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 133 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
134 ("Page numbers should not greater then 8\n")); 134 "Page numbers should not greater then 8\n");
135 } 135 }
136 for (page = 0; page < pagenums; page++) { 136 for (page = 0; page < pagenums; page++) {
137 offset = page * FW_8192D_PAGE_SIZE; 137 offset = page * FW_8192D_PAGE_SIZE;
@@ -158,12 +158,12 @@ static int _rtl92d_fw_free_to_go(struct ieee80211_hw *hw)
158 (!(value32 & FWDL_ChkSum_rpt))); 158 (!(value32 & FWDL_ChkSum_rpt)));
159 if (counter >= FW_8192D_POLLING_TIMEOUT_COUNT) { 159 if (counter >= FW_8192D_POLLING_TIMEOUT_COUNT) {
160 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 160 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
161 ("chksum report faill ! REG_MCUFWDL:0x%08x .\n", 161 "chksum report faill ! REG_MCUFWDL:0x%08x\n",
162 value32)); 162 value32);
163 return -EIO; 163 return -EIO;
164 } 164 }
165 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, 165 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE,
166 ("Checksum report OK ! REG_MCUFWDL:0x%08x .\n", value32)); 166 "Checksum report OK ! REG_MCUFWDL:0x%08x\n", value32);
167 value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL); 167 value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL);
168 value32 |= MCUFWDL_RDY; 168 value32 |= MCUFWDL_RDY;
169 rtl_write_dword(rtlpriv, REG_MCUFWDL, value32); 169 rtl_write_dword(rtlpriv, REG_MCUFWDL, value32);
@@ -186,9 +186,9 @@ void rtl92d_firmware_selfreset(struct ieee80211_hw *hw)
186 udelay(50); 186 udelay(50);
187 u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); 187 u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
188 } 188 }
189 RT_ASSERT((delay > 0), ("8051 reset failed!\n")); 189 RT_ASSERT((delay > 0), "8051 reset failed!\n");
190 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, 190 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
191 ("=====> 8051 reset success (%d) .\n", delay)); 191 "=====> 8051 reset success (%d)\n", delay);
192} 192}
193 193
194static int _rtl92d_fw_init(struct ieee80211_hw *hw) 194static int _rtl92d_fw_init(struct ieee80211_hw *hw)
@@ -197,7 +197,7 @@ static int _rtl92d_fw_init(struct ieee80211_hw *hw)
197 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 197 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
198 u32 counter; 198 u32 counter;
199 199
200 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, ("FW already have download\n")); 200 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, "FW already have download\n");
201 /* polling for FW ready */ 201 /* polling for FW ready */
202 counter = 0; 202 counter = 0;
203 do { 203 do {
@@ -205,10 +205,9 @@ static int _rtl92d_fw_init(struct ieee80211_hw *hw)
205 if (rtl_read_byte(rtlpriv, FW_MAC0_READY) & 205 if (rtl_read_byte(rtlpriv, FW_MAC0_READY) &
206 MAC0_READY) { 206 MAC0_READY) {
207 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, 207 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
208 ("Polling FW ready success!! " 208 "Polling FW ready success!! REG_MCUFWDL: 0x%x\n",
209 "REG_MCUFWDL: 0x%x .\n",
210 rtl_read_byte(rtlpriv, 209 rtl_read_byte(rtlpriv,
211 FW_MAC0_READY))); 210 FW_MAC0_READY));
212 return 0; 211 return 0;
213 } 212 }
214 udelay(5); 213 udelay(5);
@@ -216,10 +215,9 @@ static int _rtl92d_fw_init(struct ieee80211_hw *hw)
216 if (rtl_read_byte(rtlpriv, FW_MAC1_READY) & 215 if (rtl_read_byte(rtlpriv, FW_MAC1_READY) &
217 MAC1_READY) { 216 MAC1_READY) {
218 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, 217 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
219 ("Polling FW ready success!! " 218 "Polling FW ready success!! REG_MCUFWDL: 0x%x\n",
220 "REG_MCUFWDL: 0x%x .\n",
221 rtl_read_byte(rtlpriv, 219 rtl_read_byte(rtlpriv,
222 FW_MAC1_READY))); 220 FW_MAC1_READY));
223 return 0; 221 return 0;
224 } 222 }
225 udelay(5); 223 udelay(5);
@@ -228,18 +226,16 @@ static int _rtl92d_fw_init(struct ieee80211_hw *hw)
228 226
229 if (rtlhal->interfaceindex == 0) { 227 if (rtlhal->interfaceindex == 0) {
230 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, 228 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
231 ("Polling FW ready fail!! MAC0 FW init not ready: " 229 "Polling FW ready fail!! MAC0 FW init not ready: 0x%x\n",
232 "0x%x .\n", 230 rtl_read_byte(rtlpriv, FW_MAC0_READY));
233 rtl_read_byte(rtlpriv, FW_MAC0_READY)));
234 } else { 231 } else {
235 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, 232 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
236 ("Polling FW ready fail!! MAC1 FW init not ready: " 233 "Polling FW ready fail!! MAC1 FW init not ready: 0x%x\n",
237 "0x%x .\n", 234 rtl_read_byte(rtlpriv, FW_MAC1_READY));
238 rtl_read_byte(rtlpriv, FW_MAC1_READY)));
239 } 235 }
240 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, 236 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
241 ("Polling FW ready fail!! REG_MCUFWDL:0x%08ul .\n", 237 "Polling FW ready fail!! REG_MCUFWDL:0x%08ul\n",
242 rtl_read_dword(rtlpriv, REG_MCUFWDL))); 238 rtl_read_dword(rtlpriv, REG_MCUFWDL));
243 return -1; 239 return -1;
244} 240}
245 241
@@ -257,20 +253,20 @@ int rtl92d_download_fw(struct ieee80211_hw *hw)
257 bool fw_downloaded = false, fwdl_in_process = false; 253 bool fw_downloaded = false, fwdl_in_process = false;
258 unsigned long flags; 254 unsigned long flags;
259 255
260 if (!rtlhal->pfirmware) 256 if (rtlpriv->max_fw_size == 0 || !rtlhal->pfirmware)
261 return 1; 257 return 1;
262 fwsize = rtlhal->fwsize; 258 fwsize = rtlhal->fwsize;
263 pfwheader = (u8 *) rtlhal->pfirmware; 259 pfwheader = (u8 *) rtlhal->pfirmware;
264 pfwdata = (u8 *) rtlhal->pfirmware; 260 pfwdata = (u8 *) rtlhal->pfirmware;
265 rtlhal->fw_version = (u16) GET_FIRMWARE_HDR_VERSION(pfwheader); 261 rtlhal->fw_version = (u16) GET_FIRMWARE_HDR_VERSION(pfwheader);
266 rtlhal->fw_subversion = (u16) GET_FIRMWARE_HDR_SUB_VER(pfwheader); 262 rtlhal->fw_subversion = (u16) GET_FIRMWARE_HDR_SUB_VER(pfwheader);
267 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, (" FirmwareVersion(%d)," 263 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
268 "FirmwareSubVersion(%d), Signature(%#x)\n", 264 "FirmwareVersion(%d), FirmwareSubVersion(%d), Signature(%#x)\n",
269 rtlhal->fw_version, rtlhal->fw_subversion, 265 rtlhal->fw_version, rtlhal->fw_subversion,
270 GET_FIRMWARE_HDR_SIGNATURE(pfwheader))); 266 GET_FIRMWARE_HDR_SIGNATURE(pfwheader));
271 if (IS_FW_HEADER_EXIST(pfwheader)) { 267 if (IS_FW_HEADER_EXIST(pfwheader)) {
272 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 268 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
273 ("Shift 32 bytes for FW header!!\n")); 269 "Shift 32 bytes for FW header!!\n");
274 pfwdata = pfwdata + 32; 270 pfwdata = pfwdata + 32;
275 fwsize = fwsize - 32; 271 fwsize = fwsize - 32;
276 } 272 }
@@ -302,8 +298,7 @@ int rtl92d_download_fw(struct ieee80211_hw *hw)
302 break; 298 break;
303 else 299 else
304 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, 300 RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG,
305 ("Wait for another mac " 301 "Wait for another mac download fw\n");
306 "download fw\n"));
307 } 302 }
308 spin_lock_irqsave(&globalmutex_for_fwdownload, flags); 303 spin_lock_irqsave(&globalmutex_for_fwdownload, flags);
309 value = rtl_read_byte(rtlpriv, 0x1f); 304 value = rtl_read_byte(rtlpriv, 0x1f);
@@ -337,11 +332,10 @@ int rtl92d_download_fw(struct ieee80211_hw *hw)
337 spin_unlock_irqrestore(&globalmutex_for_fwdownload, flags); 332 spin_unlock_irqrestore(&globalmutex_for_fwdownload, flags);
338 if (err) { 333 if (err) {
339 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 334 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
340 ("fw is not ready to run!\n")); 335 "fw is not ready to run!\n");
341 goto exit; 336 goto exit;
342 } else { 337 } else {
343 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, 338 RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, "fw is ready to run!\n");
344 ("fw is ready to run!\n"));
345 } 339 }
346exit: 340exit:
347 err = _rtl92d_fw_init(hw); 341 err = _rtl92d_fw_init(hw);
@@ -381,24 +375,24 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw,
381 375
382 if (ppsc->rfpwr_state == ERFOFF || ppsc->inactive_pwrstate == ERFOFF) { 376 if (ppsc->rfpwr_state == ERFOFF || ppsc->inactive_pwrstate == ERFOFF) {
383 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 377 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
384 ("Return as RF is off!!!\n")); 378 "Return as RF is off!!!\n");
385 return; 379 return;
386 } 380 }
387 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("come in\n")); 381 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "come in\n");
388 while (true) { 382 while (true) {
389 spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); 383 spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag);
390 if (rtlhal->h2c_setinprogress) { 384 if (rtlhal->h2c_setinprogress) {
391 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 385 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
392 ("H2C set in progress! Wait to set.." 386 "H2C set in progress! Wait to set..element_id(%d)\n",
393 "element_id(%d).\n", element_id)); 387 element_id);
394 388
395 while (rtlhal->h2c_setinprogress) { 389 while (rtlhal->h2c_setinprogress) {
396 spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, 390 spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock,
397 flag); 391 flag);
398 h2c_waitcounter++; 392 h2c_waitcounter++;
399 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 393 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
400 ("Wait 100 us (%d times)...\n", 394 "Wait 100 us (%d times)...\n",
401 h2c_waitcounter)); 395 h2c_waitcounter);
402 udelay(100); 396 udelay(100);
403 397
404 if (h2c_waitcounter > 1000) 398 if (h2c_waitcounter > 1000)
@@ -418,8 +412,7 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw,
418 wait_writeh2c_limmit--; 412 wait_writeh2c_limmit--;
419 if (wait_writeh2c_limmit == 0) { 413 if (wait_writeh2c_limmit == 0) {
420 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 414 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
421 ("Write H2C fail because no trigger " 415 "Write H2C fail because no trigger for FW INT!\n");
422 "for FW INT!\n"));
423 break; 416 break;
424 } 417 }
425 boxnum = rtlhal->last_hmeboxnum; 418 boxnum = rtlhal->last_hmeboxnum;
@@ -442,7 +435,7 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw,
442 break; 435 break;
443 default: 436 default:
444 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 437 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
445 ("switch case not process\n")); 438 "switch case not processed\n");
446 break; 439 break;
447 } 440 }
448 isfw_read = _rtl92d_check_fw_read_last_h2c(hw, boxnum); 441 isfw_read = _rtl92d_check_fw_read_last_h2c(hw, boxnum);
@@ -450,29 +443,29 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw,
450 wait_h2c_limmit--; 443 wait_h2c_limmit--;
451 if (wait_h2c_limmit == 0) { 444 if (wait_h2c_limmit == 0) {
452 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 445 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
453 ("Wating too long for FW read " 446 "Waiting too long for FW read clear HMEBox(%d)!\n",
454 "clear HMEBox(%d)!\n", boxnum)); 447 boxnum);
455 break; 448 break;
456 } 449 }
457 udelay(10); 450 udelay(10);
458 isfw_read = _rtl92d_check_fw_read_last_h2c(hw, boxnum); 451 isfw_read = _rtl92d_check_fw_read_last_h2c(hw, boxnum);
459 u1b_tmp = rtl_read_byte(rtlpriv, 0x1BF); 452 u1b_tmp = rtl_read_byte(rtlpriv, 0x1BF);
460 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 453 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
461 ("Wating for FW read clear HMEBox(%d)!!! " 454 "Waiting for FW read clear HMEBox(%d)!!! 0x1BF = %2x\n",
462 "0x1BF = %2x\n", boxnum, u1b_tmp)); 455 boxnum, u1b_tmp);
463 } 456 }
464 if (!isfw_read) { 457 if (!isfw_read) {
465 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 458 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
466 ("Write H2C register BOX[%d] fail!!!!! " 459 "Write H2C register BOX[%d] fail!!!!! Fw do not read.\n",
467 "Fw do not read.\n", boxnum)); 460 boxnum);
468 break; 461 break;
469 } 462 }
470 memset(boxcontent, 0, sizeof(boxcontent)); 463 memset(boxcontent, 0, sizeof(boxcontent));
471 memset(boxextcontent, 0, sizeof(boxextcontent)); 464 memset(boxextcontent, 0, sizeof(boxextcontent));
472 boxcontent[0] = element_id; 465 boxcontent[0] = element_id;
473 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 466 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
474 ("Write element_id box_reg(%4x) = %2x\n", 467 "Write element_id box_reg(%4x) = %2x\n",
475 box_reg, element_id)); 468 box_reg, element_id);
476 switch (cmd_len) { 469 switch (cmd_len) {
477 case 1: 470 case 1:
478 boxcontent[0] &= ~(BIT(7)); 471 boxcontent[0] &= ~(BIT(7));
@@ -519,7 +512,7 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw,
519 break; 512 break;
520 default: 513 default:
521 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 514 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
522 ("switch case not process\n")); 515 "switch case not processed\n");
523 break; 516 break;
524 } 517 }
525 bwrite_sucess = true; 518 bwrite_sucess = true;
@@ -527,26 +520,20 @@ static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw,
527 if (rtlhal->last_hmeboxnum == 4) 520 if (rtlhal->last_hmeboxnum == 4)
528 rtlhal->last_hmeboxnum = 0; 521 rtlhal->last_hmeboxnum = 0;
529 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 522 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
530 ("pHalData->last_hmeboxnum = %d\n", 523 "pHalData->last_hmeboxnum = %d\n",
531 rtlhal->last_hmeboxnum)); 524 rtlhal->last_hmeboxnum);
532 } 525 }
533 spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); 526 spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag);
534 rtlhal->h2c_setinprogress = false; 527 rtlhal->h2c_setinprogress = false;
535 spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); 528 spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag);
536 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("go out\n")); 529 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "go out\n");
537} 530}
538 531
539void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw, 532void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw,
540 u8 element_id, u32 cmd_len, u8 *cmdbuffer) 533 u8 element_id, u32 cmd_len, u8 *cmdbuffer)
541{ 534{
542 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
543 u32 tmp_cmdbuf[2]; 535 u32 tmp_cmdbuf[2];
544 536
545 if (rtlhal->fw_ready == false) {
546 RT_ASSERT(false, ("return H2C cmd because of Fw "
547 "download fail!!!\n"));
548 return;
549 }
550 memset(tmp_cmdbuf, 0, 8); 537 memset(tmp_cmdbuf, 0, 8);
551 memcpy(tmp_cmdbuf, cmdbuffer, cmd_len); 538 memcpy(tmp_cmdbuf, cmdbuffer, cmd_len);
552 _rtl92d_fill_h2c_command(hw, element_id, cmd_len, (u8 *)&tmp_cmdbuf); 539 _rtl92d_fill_h2c_command(hw, element_id, cmd_len, (u8 *)&tmp_cmdbuf);
@@ -559,13 +546,13 @@ void rtl92d_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode)
559 u8 u1_h2c_set_pwrmode[3] = { 0 }; 546 u8 u1_h2c_set_pwrmode[3] = { 0 };
560 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); 547 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
561 548
562 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("FW LPS mode = %d\n", mode)); 549 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "FW LPS mode = %d\n", mode);
563 SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, mode); 550 SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, mode);
564 SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, 1); 551 SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, 1);
565 SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(u1_h2c_set_pwrmode, 552 SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(u1_h2c_set_pwrmode,
566 ppsc->reg_max_lps_awakeintvl); 553 ppsc->reg_max_lps_awakeintvl);
567 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, 554 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
568 "rtl92d_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode\n", 555 "rtl92d_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode",
569 u1_h2c_set_pwrmode, 3); 556 u1_h2c_set_pwrmode, 3);
570 rtl92d_fill_h2c_cmd(hw, H2C_SETPWRMODE, 3, u1_h2c_set_pwrmode); 557 rtl92d_fill_h2c_cmd(hw, H2C_SETPWRMODE, 3, u1_h2c_set_pwrmode);
571} 558}
@@ -757,28 +744,32 @@ void rtl92d_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished)
757 SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1RsvdPageLoc, PROBERSP_PG); 744 SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1RsvdPageLoc, PROBERSP_PG);
758 totalpacketlen = TOTAL_RESERVED_PKT_LEN; 745 totalpacketlen = TOTAL_RESERVED_PKT_LEN;
759 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, 746 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD,
760 "rtl92d_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", 747 "rtl92d_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL",
761 &reserved_page_packet[0], totalpacketlen); 748 &reserved_page_packet[0], totalpacketlen);
762 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, 749 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
763 "rtl92d_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", 750 "rtl92d_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL",
764 u1RsvdPageLoc, 3); 751 u1RsvdPageLoc, 3);
765 skb = dev_alloc_skb(totalpacketlen); 752 skb = dev_alloc_skb(totalpacketlen);
766 memcpy((u8 *) skb_put(skb, totalpacketlen), &reserved_page_packet, 753 if (!skb) {
767 totalpacketlen); 754 dlok = false;
768 rtstatus = _rtl92d_cmd_send_packet(hw, skb); 755 } else {
756 memcpy((u8 *) skb_put(skb, totalpacketlen),
757 &reserved_page_packet, totalpacketlen);
758 rtstatus = _rtl92d_cmd_send_packet(hw, skb);
769 759
770 if (rtstatus) 760 if (rtstatus)
771 dlok = true; 761 dlok = true;
762 }
772 if (dlok) { 763 if (dlok) {
773 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 764 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
774 ("Set RSVD page location to Fw.\n")); 765 "Set RSVD page location to Fw\n");
775 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, 766 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
776 "H2C_RSVDPAGE:\n", u1RsvdPageLoc, 3); 767 "H2C_RSVDPAGE", u1RsvdPageLoc, 3);
777 rtl92d_fill_h2c_cmd(hw, H2C_RSVDPAGE, 768 rtl92d_fill_h2c_cmd(hw, H2C_RSVDPAGE,
778 sizeof(u1RsvdPageLoc), u1RsvdPageLoc); 769 sizeof(u1RsvdPageLoc), u1RsvdPageLoc);
779 } else 770 } else
780 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 771 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
781 ("Set RSVD page location to Fw FAIL!!!!!!.\n")); 772 "Set RSVD page location to Fw FAIL!!!!!!\n");
782} 773}
783 774
784void rtl92d_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus) 775void rtl92d_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus)
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.h b/drivers/net/wireless/rtlwifi/rtl8192de/fw.h
index 0c4d489eaa48..1ffacdda734c 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
index 9d89d7ccdafb..7d877125db29 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -166,7 +166,7 @@ void rtl92de_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
166 break; 166 break;
167 default: 167 default:
168 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 168 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
169 ("switch case not process\n")); 169 "switch case not processed\n");
170 break; 170 break;
171 } 171 }
172} 172}
@@ -230,7 +230,7 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
230 u8 e_aci; 230 u8 e_aci;
231 231
232 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 232 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
233 ("HW_VAR_SLOT_TIME %x\n", val[0])); 233 "HW_VAR_SLOT_TIME %x\n", val[0]);
234 rtl_write_byte(rtlpriv, REG_SLOT, val[0]); 234 rtl_write_byte(rtlpriv, REG_SLOT, val[0]);
235 for (e_aci = 0; e_aci < AC_MAX; e_aci++) 235 for (e_aci = 0; e_aci < AC_MAX; e_aci++)
236 rtlpriv->cfg->ops->set_hw_reg(hw, 236 rtlpriv->cfg->ops->set_hw_reg(hw,
@@ -261,8 +261,8 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
261 min_spacing_to_set); 261 min_spacing_to_set);
262 *val = min_spacing_to_set; 262 *val = min_spacing_to_set;
263 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 263 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
264 ("Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", 264 "Set HW_VAR_AMPDU_MIN_SPACE: %#x\n",
265 mac->min_space_cfg)); 265 mac->min_space_cfg);
266 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, 266 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE,
267 mac->min_space_cfg); 267 mac->min_space_cfg);
268 } 268 }
@@ -275,8 +275,8 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
275 mac->min_space_cfg = rtlpriv->rtlhal.minspace_cfg; 275 mac->min_space_cfg = rtlpriv->rtlhal.minspace_cfg;
276 mac->min_space_cfg |= (density_to_set << 3); 276 mac->min_space_cfg |= (density_to_set << 3);
277 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 277 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
278 ("Set HW_VAR_SHORTGI_DENSITY: %#x\n", 278 "Set HW_VAR_SHORTGI_DENSITY: %#x\n",
279 mac->min_space_cfg)); 279 mac->min_space_cfg);
280 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, 280 rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE,
281 mac->min_space_cfg); 281 mac->min_space_cfg);
282 break; 282 break;
@@ -310,8 +310,8 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
310 } 310 }
311 rtl_write_dword(rtlpriv, REG_AGGLEN_LMT, regtoSet); 311 rtl_write_dword(rtlpriv, REG_AGGLEN_LMT, regtoSet);
312 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 312 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
313 ("Set HW_VAR_AMPDU_FACTOR: %#x\n", 313 "Set HW_VAR_AMPDU_FACTOR: %#x\n",
314 factor_toset)); 314 factor_toset);
315 } 315 }
316 break; 316 break;
317 } 317 }
@@ -344,8 +344,8 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
344 break; 344 break;
345 default: 345 default:
346 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 346 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
347 ("HW_VAR_ACM_CTRL acm set " 347 "HW_VAR_ACM_CTRL acm set failed: eACI is %d\n",
348 "failed: eACI is %d\n", acm)); 348 acm);
349 break; 349 break;
350 } 350 }
351 } else { 351 } else {
@@ -361,13 +361,13 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
361 break; 361 break;
362 default: 362 default:
363 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 363 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
364 ("switch case not process\n")); 364 "switch case not processed\n");
365 break; 365 break;
366 } 366 }
367 } 367 }
368 RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE, 368 RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE,
369 ("SetHwReg8190pci(): [HW_VAR_ACM_CTRL] " 369 "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n",
370 "Write 0x%X\n", acm_ctrl)); 370 acm_ctrl);
371 rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl); 371 rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl);
372 break; 372 break;
373 } 373 }
@@ -502,7 +502,7 @@ void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
502 } 502 }
503 default: 503 default:
504 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 504 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
505 ("switch case not process\n")); 505 "switch case not processed\n");
506 break; 506 break;
507 } 507 }
508} 508}
@@ -522,8 +522,8 @@ static bool _rtl92de_llt_write(struct ieee80211_hw *hw, u32 address, u32 data)
522 break; 522 break;
523 if (count > POLLING_LLT_THRESHOLD) { 523 if (count > POLLING_LLT_THRESHOLD) {
524 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 524 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
525 ("Failed to polling write LLT done at " 525 "Failed to polling write LLT done at address %d!\n",
526 "address %d!\n", address)); 526 address);
527 status = false; 527 status = false;
528 break; 528 break;
529 } 529 }
@@ -879,12 +879,12 @@ void rtl92de_enable_hw_security_config(struct ieee80211_hw *hw)
879 u8 sec_reg_value; 879 u8 sec_reg_value;
880 880
881 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 881 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
882 ("PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n", 882 "PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n",
883 rtlpriv->sec.pairwise_enc_algorithm, 883 rtlpriv->sec.pairwise_enc_algorithm,
884 rtlpriv->sec.group_enc_algorithm)); 884 rtlpriv->sec.group_enc_algorithm);
885 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { 885 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
886 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 886 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
887 ("not open hw encryption\n")); 887 "not open hw encryption\n");
888 return; 888 return;
889 } 889 }
890 sec_reg_value = SCR_TXENCENABLE | SCR_RXENCENABLE; 890 sec_reg_value = SCR_TXENCENABLE | SCR_RXENCENABLE;
@@ -895,7 +895,7 @@ void rtl92de_enable_hw_security_config(struct ieee80211_hw *hw)
895 sec_reg_value |= (SCR_RXBCUSEDK | SCR_TXBCUSEDK); 895 sec_reg_value |= (SCR_RXBCUSEDK | SCR_TXBCUSEDK);
896 rtl_write_byte(rtlpriv, REG_CR + 1, 0x02); 896 rtl_write_byte(rtlpriv, REG_CR + 1, 0x02);
897 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 897 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
898 ("The SECR-value %x\n", sec_reg_value)); 898 "The SECR-value %x\n", sec_reg_value);
899 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value); 899 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value);
900} 900}
901 901
@@ -921,7 +921,7 @@ int rtl92de_hw_init(struct ieee80211_hw *hw)
921 /* rtlpriv->intf_ops->disable_aspm(hw); */ 921 /* rtlpriv->intf_ops->disable_aspm(hw); */
922 rtstatus = _rtl92de_init_mac(hw); 922 rtstatus = _rtl92de_init_mac(hw);
923 if (rtstatus != true) { 923 if (rtstatus != true) {
924 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Init MAC failed\n")); 924 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Init MAC failed\n");
925 err = 1; 925 err = 1;
926 spin_unlock_irqrestore(&globalmutex_for_power_and_efuse, flags); 926 spin_unlock_irqrestore(&globalmutex_for_power_and_efuse, flags);
927 return err; 927 return err;
@@ -930,12 +930,8 @@ int rtl92de_hw_init(struct ieee80211_hw *hw)
930 spin_unlock_irqrestore(&globalmutex_for_power_and_efuse, flags); 930 spin_unlock_irqrestore(&globalmutex_for_power_and_efuse, flags);
931 if (err) { 931 if (err) {
932 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 932 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
933 ("Failed to download FW. Init HW " 933 "Failed to download FW. Init HW without FW..\n");
934 "without FW..\n"));
935 rtlhal->fw_ready = false;
936 return 1; 934 return 1;
937 } else {
938 rtlhal->fw_ready = true;
939 } 935 }
940 rtlhal->last_hmeboxnum = 0; 936 rtlhal->last_hmeboxnum = 0;
941 rtlpriv->psc.fw_current_inpsmode = false; 937 rtlpriv->psc.fw_current_inpsmode = false;
@@ -946,7 +942,7 @@ int rtl92de_hw_init(struct ieee80211_hw *hw)
946 942
947 if (rtlhal->earlymode_enable) { 943 if (rtlhal->earlymode_enable) {
948 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 944 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
949 ("EarlyMode Enabled!!!\n")); 945 "EarlyMode Enabled!!!\n");
950 946
951 tmp_u1b = rtl_read_byte(rtlpriv, 0x4d0); 947 tmp_u1b = rtl_read_byte(rtlpriv, 0x4d0);
952 tmp_u1b = tmp_u1b | 0x1f; 948 tmp_u1b = tmp_u1b | 0x1f;
@@ -1064,10 +1060,10 @@ static enum version_8192d _rtl92de_read_chip_version(struct ieee80211_hw *hw)
1064 value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG); 1060 value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG);
1065 if (!(value32 & 0x000f0000)) { 1061 if (!(value32 & 0x000f0000)) {
1066 version = VERSION_TEST_CHIP_92D_SINGLEPHY; 1062 version = VERSION_TEST_CHIP_92D_SINGLEPHY;
1067 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("TEST CHIP!!!\n")); 1063 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "TEST CHIP!!!\n");
1068 } else { 1064 } else {
1069 version = VERSION_NORMAL_CHIP_92D_SINGLEPHY; 1065 version = VERSION_NORMAL_CHIP_92D_SINGLEPHY;
1070 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Normal CHIP!!!\n")); 1066 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Normal CHIP!!!\n");
1071 } 1067 }
1072 return version; 1068 return version;
1073} 1069}
@@ -1092,8 +1088,8 @@ static int _rtl92de_set_media_status(struct ieee80211_hw *hw,
1092 _rtl92de_disable_bcn_sub_func(hw); 1088 _rtl92de_disable_bcn_sub_func(hw);
1093 } else { 1089 } else {
1094 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1090 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1095 ("Set HW_VAR_MEDIA_STATUS: No such media " 1091 "Set HW_VAR_MEDIA_STATUS: No such media status(%x)\n",
1096 "status(%x).\n", type)); 1092 type);
1097 } 1093 }
1098 bcnfunc_enable = rtl_read_byte(rtlpriv, REG_BCN_CTRL); 1094 bcnfunc_enable = rtl_read_byte(rtlpriv, REG_BCN_CTRL);
1099 switch (type) { 1095 switch (type) {
@@ -1102,30 +1098,30 @@ static int _rtl92de_set_media_status(struct ieee80211_hw *hw,
1102 ledaction = LED_CTL_LINK; 1098 ledaction = LED_CTL_LINK;
1103 bcnfunc_enable &= 0xF7; 1099 bcnfunc_enable &= 0xF7;
1104 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1100 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1105 ("Set Network type to NO LINK!\n")); 1101 "Set Network type to NO LINK!\n");
1106 break; 1102 break;
1107 case NL80211_IFTYPE_ADHOC: 1103 case NL80211_IFTYPE_ADHOC:
1108 bt_msr |= MSR_ADHOC; 1104 bt_msr |= MSR_ADHOC;
1109 bcnfunc_enable |= 0x08; 1105 bcnfunc_enable |= 0x08;
1110 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1106 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1111 ("Set Network type to Ad Hoc!\n")); 1107 "Set Network type to Ad Hoc!\n");
1112 break; 1108 break;
1113 case NL80211_IFTYPE_STATION: 1109 case NL80211_IFTYPE_STATION:
1114 bt_msr |= MSR_INFRA; 1110 bt_msr |= MSR_INFRA;
1115 ledaction = LED_CTL_LINK; 1111 ledaction = LED_CTL_LINK;
1116 bcnfunc_enable &= 0xF7; 1112 bcnfunc_enable &= 0xF7;
1117 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1113 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1118 ("Set Network type to STA!\n")); 1114 "Set Network type to STA!\n");
1119 break; 1115 break;
1120 case NL80211_IFTYPE_AP: 1116 case NL80211_IFTYPE_AP:
1121 bt_msr |= MSR_AP; 1117 bt_msr |= MSR_AP;
1122 bcnfunc_enable |= 0x08; 1118 bcnfunc_enable |= 0x08;
1123 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1119 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1124 ("Set Network type to AP!\n")); 1120 "Set Network type to AP!\n");
1125 break; 1121 break;
1126 default: 1122 default:
1127 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1123 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1128 ("Network type %d not support!\n", type)); 1124 "Network type %d not supported!\n", type);
1129 return 1; 1125 return 1;
1130 break; 1126 break;
1131 1127
@@ -1189,7 +1185,7 @@ void rtl92d_linked_set_reg(struct ieee80211_hw *hw)
1189 indexforchannel = rtl92d_get_rightchnlplace_for_iqk(channel); 1185 indexforchannel = rtl92d_get_rightchnlplace_for_iqk(channel);
1190 if (!rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done) { 1186 if (!rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done) {
1191 RT_TRACE(rtlpriv, COMP_SCAN | COMP_INIT, DBG_DMESG, 1187 RT_TRACE(rtlpriv, COMP_SCAN | COMP_INIT, DBG_DMESG,
1192 ("Do IQK for channel:%d.\n", channel)); 1188 "Do IQK for channel:%d\n", channel);
1193 rtl92d_phy_iq_calibrate(hw); 1189 rtl92d_phy_iq_calibrate(hw);
1194 } 1190 }
1195} 1191}
@@ -1214,7 +1210,7 @@ void rtl92de_set_qos(struct ieee80211_hw *hw, int aci)
1214 rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, 0x2f3222); 1210 rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, 0x2f3222);
1215 break; 1211 break;
1216 default: 1212 default:
1217 RT_ASSERT(false, ("invalid aci: %d !\n", aci)); 1213 RT_ASSERT(false, "invalid aci: %d !\n", aci);
1218 break; 1214 break;
1219 } 1215 }
1220} 1216}
@@ -1305,8 +1301,8 @@ static void _rtl92de_poweroff_adapter(struct ieee80211_hw *hw)
1305 rtl_write_byte(rtlpriv, REG_APS_FSMCO + 1, 0x10); 1301 rtl_write_byte(rtlpriv, REG_APS_FSMCO + 1, 0x10);
1306 1302
1307 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1303 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1308 ("In PowerOff,reg0x%x=%X\n", REG_SPS0_CTRL, 1304 "In PowerOff,reg0x%x=%X\n",
1309 rtl_read_byte(rtlpriv, REG_SPS0_CTRL))); 1305 REG_SPS0_CTRL, rtl_read_byte(rtlpriv, REG_SPS0_CTRL));
1310 /* r. Note: for PCIe interface, PON will not turn */ 1306 /* r. Note: for PCIe interface, PON will not turn */
1311 /* off m-bias and BandGap in PCIe suspend mode. */ 1307 /* off m-bias and BandGap in PCIe suspend mode. */
1312 1308
@@ -1319,7 +1315,7 @@ static void _rtl92de_poweroff_adapter(struct ieee80211_hw *hw)
1319 spin_unlock_irqrestore(&globalmutex_power, flags); 1315 spin_unlock_irqrestore(&globalmutex_power, flags);
1320 } 1316 }
1321 1317
1322 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("<=======\n")); 1318 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "<=======\n");
1323} 1319}
1324 1320
1325void rtl92de_card_disable(struct ieee80211_hw *hw) 1321void rtl92de_card_disable(struct ieee80211_hw *hw)
@@ -1377,7 +1373,7 @@ void rtl92de_card_disable(struct ieee80211_hw *hw)
1377 rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG + 1, 0xff); 1373 rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG + 1, 0xff);
1378 udelay(50); 1374 udelay(50);
1379 rtl_write_byte(rtlpriv, REG_CR, 0x0); 1375 rtl_write_byte(rtlpriv, REG_CR, 0x0);
1380 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("==> Do power off.......\n")); 1376 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "==> Do power off.......\n");
1381 if (rtl92d_phy_check_poweroff(hw)) 1377 if (rtl92d_phy_check_poweroff(hw))
1382 _rtl92de_poweroff_adapter(hw); 1378 _rtl92de_poweroff_adapter(hw);
1383 return; 1379 return;
@@ -1425,7 +1421,7 @@ void rtl92de_set_beacon_interval(struct ieee80211_hw *hw)
1425 u16 bcn_interval = mac->beacon_interval; 1421 u16 bcn_interval = mac->beacon_interval;
1426 1422
1427 RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG, 1423 RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG,
1428 ("beacon_interval:%d\n", bcn_interval)); 1424 "beacon_interval:%d\n", bcn_interval);
1429 /* rtl92de_disable_interrupt(hw); */ 1425 /* rtl92de_disable_interrupt(hw); */
1430 rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval); 1426 rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval);
1431 /* rtl92de_enable_interrupt(hw); */ 1427 /* rtl92de_enable_interrupt(hw); */
@@ -1437,8 +1433,8 @@ void rtl92de_update_interrupt_mask(struct ieee80211_hw *hw,
1437 struct rtl_priv *rtlpriv = rtl_priv(hw); 1433 struct rtl_priv *rtlpriv = rtl_priv(hw);
1438 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1434 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1439 1435
1440 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, 1436 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, "add_msr:%x, rm_msr:%x\n",
1441 ("add_msr:%x, rm_msr:%x\n", add_msr, rm_msr)); 1437 add_msr, rm_msr);
1442 if (add_msr) 1438 if (add_msr)
1443 rtlpci->irq_mask[0] |= add_msr; 1439 rtlpci->irq_mask[0] |= add_msr;
1444 if (rm_msr) 1440 if (rm_msr)
@@ -1615,9 +1611,9 @@ static void _rtl92de_read_txpower_info(struct ieee80211_hw *hw,
1615 rtlefuse->internal_pa_5g[1] = 1611 rtlefuse->internal_pa_5g[1] =
1616 !((hwinfo[EEPROM_TSSI_B_5G] & BIT(6)) >> 6); 1612 !((hwinfo[EEPROM_TSSI_B_5G] & BIT(6)) >> 6);
1617 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1613 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
1618 ("Is D cut,Internal PA0 %d Internal PA1 %d\n", 1614 "Is D cut,Internal PA0 %d Internal PA1 %d\n",
1619 rtlefuse->internal_pa_5g[0], 1615 rtlefuse->internal_pa_5g[0],
1620 rtlefuse->internal_pa_5g[1])) 1616 rtlefuse->internal_pa_5g[1]);
1621 } 1617 }
1622 rtlefuse->eeprom_c9 = hwinfo[EEPROM_RF_OPT6]; 1618 rtlefuse->eeprom_c9 = hwinfo[EEPROM_RF_OPT6];
1623 rtlefuse->eeprom_cc = hwinfo[EEPROM_RF_OPT7]; 1619 rtlefuse->eeprom_cc = hwinfo[EEPROM_RF_OPT7];
@@ -1667,14 +1663,14 @@ static void _rtl92de_read_txpower_info(struct ieee80211_hw *hw,
1667 if (rtlefuse->eeprom_c9 == 0xFF) 1663 if (rtlefuse->eeprom_c9 == 0xFF)
1668 rtlefuse->eeprom_c9 = 0x00; 1664 rtlefuse->eeprom_c9 = 0x00;
1669 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, 1665 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD,
1670 ("EEPROMRegulatory = 0x%x\n", rtlefuse->eeprom_regulatory)); 1666 "EEPROMRegulatory = 0x%x\n", rtlefuse->eeprom_regulatory);
1671 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, 1667 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD,
1672 ("ThermalMeter = 0x%x\n", rtlefuse->eeprom_thermalmeter)); 1668 "ThermalMeter = 0x%x\n", rtlefuse->eeprom_thermalmeter);
1673 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, 1669 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD,
1674 ("CrystalCap = 0x%x\n", rtlefuse->crystalcap)); 1670 "CrystalCap = 0x%x\n", rtlefuse->crystalcap);
1675 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, 1671 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD,
1676 ("Delta_IQK = 0x%x Delta_LCK = 0x%x\n", rtlefuse->delta_iqk, 1672 "Delta_IQK = 0x%x Delta_LCK = 0x%x\n",
1677 rtlefuse->delta_lck)); 1673 rtlefuse->delta_iqk, rtlefuse->delta_lck);
1678 1674
1679 for (rfPath = 0; rfPath < RF6052_MAX_PATH; rfPath++) { 1675 for (rfPath = 0; rfPath < RF6052_MAX_PATH; rfPath++) {
1680 for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) { 1676 for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) {
@@ -1710,11 +1706,11 @@ static void _rtl92de_read_macphymode_from_prom(struct ieee80211_hw *hw,
1710 if (macphy_crvalue & BIT(3)) { 1706 if (macphy_crvalue & BIT(3)) {
1711 rtlhal->macphymode = SINGLEMAC_SINGLEPHY; 1707 rtlhal->macphymode = SINGLEMAC_SINGLEPHY;
1712 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1708 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1713 ("MacPhyMode SINGLEMAC_SINGLEPHY\n")); 1709 "MacPhyMode SINGLEMAC_SINGLEPHY\n");
1714 } else { 1710 } else {
1715 rtlhal->macphymode = DUALMAC_DUALPHY; 1711 rtlhal->macphymode = DUALMAC_DUALPHY;
1716 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1712 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1717 ("MacPhyMode DUALMAC_DUALPHY\n")); 1713 "MacPhyMode DUALMAC_DUALPHY\n");
1718 } 1714 }
1719} 1715}
1720 1716
@@ -1741,15 +1737,15 @@ static void _rtl92de_efuse_update_chip_version(struct ieee80211_hw *hw)
1741 switch (chipvalue) { 1737 switch (chipvalue) {
1742 case 0xAA55: 1738 case 0xAA55:
1743 chipver |= CHIP_92D_C_CUT; 1739 chipver |= CHIP_92D_C_CUT;
1744 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("C-CUT!!!\n")); 1740 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "C-CUT!!!\n");
1745 break; 1741 break;
1746 case 0x9966: 1742 case 0x9966:
1747 chipver |= CHIP_92D_D_CUT; 1743 chipver |= CHIP_92D_D_CUT;
1748 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("D-CUT!!!\n")); 1744 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "D-CUT!!!\n");
1749 break; 1745 break;
1750 default: 1746 default:
1751 chipver |= CHIP_92D_D_CUT; 1747 chipver |= CHIP_92D_D_CUT;
1752 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, ("Unkown CUT!\n")); 1748 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "Unkown CUT!\n");
1753 break; 1749 break;
1754 } 1750 }
1755 rtlpriv->rtlhal.version = chipver; 1751 rtlpriv->rtlhal.version = chipver;
@@ -1775,23 +1771,23 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw)
1775 HWSET_MAX_SIZE); 1771 HWSET_MAX_SIZE);
1776 } else if (rtlefuse->epromtype == EEPROM_93C46) { 1772 } else if (rtlefuse->epromtype == EEPROM_93C46) {
1777 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1773 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1778 ("RTL819X Not boot from eeprom, check it !!")); 1774 "RTL819X Not boot from eeprom, check it !!\n");
1779 } 1775 }
1780 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, ("MAP\n"), 1776 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP",
1781 hwinfo, HWSET_MAX_SIZE); 1777 hwinfo, HWSET_MAX_SIZE);
1782 1778
1783 eeprom_id = *((u16 *)&hwinfo[0]); 1779 eeprom_id = *((u16 *)&hwinfo[0]);
1784 if (eeprom_id != RTL8190_EEPROM_ID) { 1780 if (eeprom_id != RTL8190_EEPROM_ID) {
1785 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1781 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1786 ("EEPROM ID(%#x) is invalid!!\n", eeprom_id)); 1782 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
1787 rtlefuse->autoload_failflag = true; 1783 rtlefuse->autoload_failflag = true;
1788 } else { 1784 } else {
1789 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); 1785 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
1790 rtlefuse->autoload_failflag = false; 1786 rtlefuse->autoload_failflag = false;
1791 } 1787 }
1792 if (rtlefuse->autoload_failflag) { 1788 if (rtlefuse->autoload_failflag) {
1793 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1789 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1794 ("RTL819X Not boot from eeprom, check it !!")); 1790 "RTL819X Not boot from eeprom, check it !!\n");
1795 return; 1791 return;
1796 } 1792 }
1797 rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID]; 1793 rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID];
@@ -1802,16 +1798,15 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw)
1802 rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID]; 1798 rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID];
1803 rtlefuse->eeprom_svid = *(u16 *)&hwinfo[EEPROM_SVID]; 1799 rtlefuse->eeprom_svid = *(u16 *)&hwinfo[EEPROM_SVID];
1804 rtlefuse->eeprom_smid = *(u16 *)&hwinfo[EEPROM_SMID]; 1800 rtlefuse->eeprom_smid = *(u16 *)&hwinfo[EEPROM_SMID];
1801 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "EEPROMId = 0x%4x\n", eeprom_id);
1805 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1802 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1806 ("EEPROMId = 0x%4x\n", eeprom_id)); 1803 "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid);
1807 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1808 ("EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid));
1809 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1804 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1810 ("EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did)); 1805 "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did);
1811 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1806 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1812 ("EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid)); 1807 "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid);
1813 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1808 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1814 ("EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid)); 1809 "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid);
1815 1810
1816 /* Read Permanent MAC address */ 1811 /* Read Permanent MAC address */
1817 if (rtlhal->interfaceindex == 0) { 1812 if (rtlhal->interfaceindex == 0) {
@@ -1827,8 +1822,7 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw)
1827 } 1822 }
1828 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, 1823 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR,
1829 rtlefuse->dev_addr); 1824 rtlefuse->dev_addr);
1830 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1825 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%pM\n", rtlefuse->dev_addr);
1831 ("%pM\n", rtlefuse->dev_addr));
1832 _rtl92de_read_txpower_info(hw, rtlefuse->autoload_failflag, hwinfo); 1826 _rtl92de_read_txpower_info(hw, rtlefuse->autoload_failflag, hwinfo);
1833 1827
1834 /* Read Channel Plan */ 1828 /* Read Channel Plan */
@@ -1849,7 +1843,7 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw)
1849 rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION]; 1843 rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION];
1850 rtlefuse->txpwr_fromeprom = true; 1844 rtlefuse->txpwr_fromeprom = true;
1851 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1845 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1852 ("EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid)); 1846 "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid);
1853} 1847}
1854 1848
1855void rtl92de_read_eeprom_info(struct ieee80211_hw *hw) 1849void rtl92de_read_eeprom_info(struct ieee80211_hw *hw)
@@ -1863,19 +1857,19 @@ void rtl92de_read_eeprom_info(struct ieee80211_hw *hw)
1863 tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR); 1857 tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR);
1864 rtlefuse->autoload_status = tmp_u1b; 1858 rtlefuse->autoload_status = tmp_u1b;
1865 if (tmp_u1b & BIT(4)) { 1859 if (tmp_u1b & BIT(4)) {
1866 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EEPROM\n")); 1860 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EEPROM\n");
1867 rtlefuse->epromtype = EEPROM_93C46; 1861 rtlefuse->epromtype = EEPROM_93C46;
1868 } else { 1862 } else {
1869 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EFUSE\n")); 1863 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EFUSE\n");
1870 rtlefuse->epromtype = EEPROM_BOOT_EFUSE; 1864 rtlefuse->epromtype = EEPROM_BOOT_EFUSE;
1871 } 1865 }
1872 if (tmp_u1b & BIT(5)) { 1866 if (tmp_u1b & BIT(5)) {
1873 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); 1867 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
1874 1868
1875 rtlefuse->autoload_failflag = false; 1869 rtlefuse->autoload_failflag = false;
1876 _rtl92de_read_adapter_info(hw); 1870 _rtl92de_read_adapter_info(hw);
1877 } else { 1871 } else {
1878 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Autoload ERR!!\n")); 1872 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Autoload ERR!!\n");
1879 } 1873 }
1880 return; 1874 return;
1881} 1875}
@@ -1958,8 +1952,8 @@ static void rtl92de_update_hal_rate_table(struct ieee80211_hw *hw,
1958 (shortgi_rate << 4) | (shortgi_rate); 1952 (shortgi_rate << 4) | (shortgi_rate);
1959 } 1953 }
1960 rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value); 1954 rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value);
1961 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, 1955 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "%x\n",
1962 ("%x\n", rtl_read_dword(rtlpriv, REG_ARFR0))); 1956 rtl_read_dword(rtlpriv, REG_ARFR0));
1963} 1957}
1964 1958
1965static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw, 1959static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw,
@@ -2092,8 +2086,8 @@ static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw,
2092 value[0] = (ratr_bitmap & 0x0fffffff) | (ratr_index << 28); 2086 value[0] = (ratr_bitmap & 0x0fffffff) | (ratr_index << 28);
2093 value[1] = macid | (shortgi ? 0x20 : 0x00) | 0x80; 2087 value[1] = macid | (shortgi ? 0x20 : 0x00) | 0x80;
2094 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, 2088 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG,
2095 ("ratr_bitmap :%x value0:%x value1:%x\n", 2089 "ratr_bitmap :%x value0:%x value1:%x\n",
2096 ratr_bitmap, value[0], value[1])); 2090 ratr_bitmap, value[0], value[1]);
2097 rtl92d_fill_h2c_cmd(hw, H2C_RA_MASK, 5, (u8 *) value); 2091 rtl92d_fill_h2c_cmd(hw, H2C_RA_MASK, 5, (u8 *) value);
2098 if (macid != 0) 2092 if (macid != 0)
2099 sta_entry->ratr_index = ratr_index; 2093 sta_entry->ratr_index = ratr_index;
@@ -2153,14 +2147,14 @@ bool rtl92de_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid)
2153 e_rfpowerstate_toset = (u1tmp & BIT(3)) ? ERFON : ERFOFF; 2147 e_rfpowerstate_toset = (u1tmp & BIT(3)) ? ERFON : ERFOFF;
2154 if (ppsc->hwradiooff && (e_rfpowerstate_toset == ERFON)) { 2148 if (ppsc->hwradiooff && (e_rfpowerstate_toset == ERFON)) {
2155 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 2149 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
2156 ("GPIOChangeRF - HW Radio ON, RF ON\n")); 2150 "GPIOChangeRF - HW Radio ON, RF ON\n");
2157 e_rfpowerstate_toset = ERFON; 2151 e_rfpowerstate_toset = ERFON;
2158 ppsc->hwradiooff = false; 2152 ppsc->hwradiooff = false;
2159 actuallyset = true; 2153 actuallyset = true;
2160 } else if ((ppsc->hwradiooff == false) 2154 } else if ((ppsc->hwradiooff == false)
2161 && (e_rfpowerstate_toset == ERFOFF)) { 2155 && (e_rfpowerstate_toset == ERFOFF)) {
2162 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 2156 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
2163 ("GPIOChangeRF - HW Radio OFF, RF OFF\n")); 2157 "GPIOChangeRF - HW Radio OFF, RF OFF\n");
2164 e_rfpowerstate_toset = ERFOFF; 2158 e_rfpowerstate_toset = ERFOFF;
2165 ppsc->hwradiooff = true; 2159 ppsc->hwradiooff = true;
2166 actuallyset = true; 2160 actuallyset = true;
@@ -2204,7 +2198,7 @@ void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index,
2204 u8 idx; 2198 u8 idx;
2205 u8 cam_offset = 0; 2199 u8 cam_offset = 0;
2206 u8 clear_number = 5; 2200 u8 clear_number = 5;
2207 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("clear_all\n")); 2201 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "clear_all\n");
2208 for (idx = 0; idx < clear_number; idx++) { 2202 for (idx = 0; idx < clear_number; idx++) {
2209 rtl_cam_mark_invalid(hw, cam_offset + idx); 2203 rtl_cam_mark_invalid(hw, cam_offset + idx);
2210 rtl_cam_empty_entry(hw, cam_offset + idx); 2204 rtl_cam_empty_entry(hw, cam_offset + idx);
@@ -2230,8 +2224,8 @@ void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index,
2230 enc_algo = CAM_AES; 2224 enc_algo = CAM_AES;
2231 break; 2225 break;
2232 default: 2226 default:
2233 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("switch case " 2227 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2234 "not process\n")); 2228 "switch case not processed\n");
2235 enc_algo = CAM_TKIP; 2229 enc_algo = CAM_TKIP;
2236 break; 2230 break;
2237 } 2231 }
@@ -2248,9 +2242,8 @@ void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index,
2248 p_macaddr); 2242 p_macaddr);
2249 if (entry_id >= TOTAL_CAM_ENTRY) { 2243 if (entry_id >= TOTAL_CAM_ENTRY) {
2250 RT_TRACE(rtlpriv, COMP_SEC, 2244 RT_TRACE(rtlpriv, COMP_SEC,
2251 DBG_EMERG, ("Can not " 2245 DBG_EMERG,
2252 "find free hw security" 2246 "Can not find free hw security cam entry\n");
2253 " cam entry\n"));
2254 return; 2247 return;
2255 } 2248 }
2256 } else { 2249 } else {
@@ -2262,29 +2255,29 @@ void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index,
2262 } 2255 }
2263 if (rtlpriv->sec.key_len[key_index] == 0) { 2256 if (rtlpriv->sec.key_len[key_index] == 0) {
2264 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2257 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2265 ("delete one entry, entry_id is %d\n", 2258 "delete one entry, entry_id is %d\n",
2266 entry_id)); 2259 entry_id);
2267 if (mac->opmode == NL80211_IFTYPE_AP) 2260 if (mac->opmode == NL80211_IFTYPE_AP)
2268 rtl_cam_del_entry(hw, p_macaddr); 2261 rtl_cam_del_entry(hw, p_macaddr);
2269 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id); 2262 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id);
2270 } else { 2263 } else {
2271 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 2264 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
2272 ("The insert KEY length is %d\n", 2265 "The insert KEY length is %d\n",
2273 rtlpriv->sec.key_len[PAIRWISE_KEYIDX])); 2266 rtlpriv->sec.key_len[PAIRWISE_KEYIDX]);
2274 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 2267 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
2275 ("The insert KEY is %x %x\n", 2268 "The insert KEY is %x %x\n",
2276 rtlpriv->sec.key_buf[0][0], 2269 rtlpriv->sec.key_buf[0][0],
2277 rtlpriv->sec.key_buf[0][1])); 2270 rtlpriv->sec.key_buf[0][1]);
2278 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2271 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2279 ("add one entry\n")); 2272 "add one entry\n");
2280 if (is_pairwise) { 2273 if (is_pairwise) {
2281 RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD, 2274 RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD,
2282 "Pairwiase Key content :", 2275 "Pairwise Key content",
2283 rtlpriv->sec.pairwise_key, 2276 rtlpriv->sec.pairwise_key,
2284 rtlpriv-> 2277 rtlpriv->
2285 sec.key_len[PAIRWISE_KEYIDX]); 2278 sec.key_len[PAIRWISE_KEYIDX]);
2286 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2279 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2287 ("set Pairwiase key\n")); 2280 "set Pairwise key\n");
2288 rtl_cam_add_one_entry(hw, macaddr, key_index, 2281 rtl_cam_add_one_entry(hw, macaddr, key_index,
2289 entry_id, enc_algo, 2282 entry_id, enc_algo,
2290 CAM_CONFIG_NO_USEDK, 2283 CAM_CONFIG_NO_USEDK,
@@ -2292,7 +2285,7 @@ void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index,
2292 sec.key_buf[key_index]); 2285 sec.key_buf[key_index]);
2293 } else { 2286 } else {
2294 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2287 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2295 ("set group key\n")); 2288 "set group key\n");
2296 if (mac->opmode == NL80211_IFTYPE_ADHOC) { 2289 if (mac->opmode == NL80211_IFTYPE_ADHOC) {
2297 rtl_cam_add_one_entry(hw, 2290 rtl_cam_add_one_entry(hw,
2298 rtlefuse->dev_addr, 2291 rtlefuse->dev_addr,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.h b/drivers/net/wireless/rtlwifi/rtl8192de/hw.h
index ad44ffa520e6..7c9f7a2f1e42 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/led.c b/drivers/net/wireless/rtlwifi/rtl8192de/led.c
index f1552f4df658..76a57ae4af3e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/led.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/led.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -45,8 +45,8 @@ void rtl92de_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
45 u8 ledcfg; 45 u8 ledcfg;
46 struct rtl_priv *rtlpriv = rtl_priv(hw); 46 struct rtl_priv *rtlpriv = rtl_priv(hw);
47 47
48 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, 48 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n",
49 ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); 49 REG_LEDCFG2, pled->ledpin);
50 50
51 switch (pled->ledpin) { 51 switch (pled->ledpin) {
52 case LED_PIN_GPIO0: 52 case LED_PIN_GPIO0:
@@ -71,7 +71,7 @@ void rtl92de_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
71 break; 71 break;
72 default: 72 default:
73 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 73 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
74 ("switch case not process\n")); 74 "switch case not processed\n");
75 break; 75 break;
76 } 76 }
77 pled->ledon = true; 77 pled->ledon = true;
@@ -83,8 +83,8 @@ void rtl92de_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
83 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); 83 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
84 u8 ledcfg; 84 u8 ledcfg;
85 85
86 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, 86 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n",
87 ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); 87 REG_LEDCFG2, pled->ledpin);
88 88
89 ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); 89 ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2);
90 90
@@ -106,7 +106,7 @@ void rtl92de_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
106 break; 106 break;
107 default: 107 default:
108 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 108 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
109 ("switch case not process\n")); 109 "switch case not processed\n");
110 break; 110 break;
111 } 111 }
112 pled->ledon = false; 112 pled->ledon = false;
@@ -153,7 +153,7 @@ void rtl92de_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction)
153 ledaction == LED_CTL_POWER_ON)) { 153 ledaction == LED_CTL_POWER_ON)) {
154 return; 154 return;
155 } 155 }
156 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, ("ledaction %d,\n", ledaction)); 156 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "ledaction %d,\n", ledaction);
157 157
158 _rtl92ce_sw_led_control(hw, ledaction); 158 _rtl92ce_sw_led_control(hw, ledaction);
159} 159}
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/led.h b/drivers/net/wireless/rtlwifi/rtl8192de/led.h
index 57f4a3c583d4..a29df30c3025 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/led.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/led.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
index 0883349e1c83..9581a19c2548 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -204,8 +204,8 @@ u32 rtl92d_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
204 u32 returnvalue, originalvalue, bitshift; 204 u32 returnvalue, originalvalue, bitshift;
205 u8 dbi_direct; 205 u8 dbi_direct;
206 206
207 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " 207 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "regaddr(%#x), bitmask(%#x)\n",
208 "bitmask(%#x)\n", regaddr, bitmask)); 208 regaddr, bitmask);
209 if (rtlhal->during_mac1init_radioa || rtlhal->during_mac0init_radiob) { 209 if (rtlhal->during_mac1init_radioa || rtlhal->during_mac0init_radiob) {
210 /* mac1 use phy0 read radio_b. */ 210 /* mac1 use phy0 read radio_b. */
211 /* mac0 use phy1 read radio_b. */ 211 /* mac0 use phy1 read radio_b. */
@@ -220,8 +220,9 @@ u32 rtl92d_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
220 } 220 }
221 bitshift = _rtl92d_phy_calculate_bit_shift(bitmask); 221 bitshift = _rtl92d_phy_calculate_bit_shift(bitmask);
222 returnvalue = (originalvalue & bitmask) >> bitshift; 222 returnvalue = (originalvalue & bitmask) >> bitshift;
223 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("BBR MASK=0x%x " 223 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
224 "Addr[0x%x]=0x%x\n", bitmask, regaddr, originalvalue)); 224 "BBR MASK=0x%x Addr[0x%x]=0x%x\n",
225 bitmask, regaddr, originalvalue);
225 return returnvalue; 226 return returnvalue;
226} 227}
227 228
@@ -233,8 +234,9 @@ void rtl92d_phy_set_bb_reg(struct ieee80211_hw *hw,
233 u8 dbi_direct = 0; 234 u8 dbi_direct = 0;
234 u32 originalvalue, bitshift; 235 u32 originalvalue, bitshift;
235 236
236 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," 237 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
237 " data(%#x)\n", regaddr, bitmask, data)); 238 "regaddr(%#x), bitmask(%#x), data(%#x)\n",
239 regaddr, bitmask, data);
238 if (rtlhal->during_mac1init_radioa) 240 if (rtlhal->during_mac1init_radioa)
239 dbi_direct = BIT(3); 241 dbi_direct = BIT(3);
240 else if (rtlhal->during_mac0init_radiob) 242 else if (rtlhal->during_mac0init_radiob)
@@ -255,8 +257,9 @@ void rtl92d_phy_set_bb_reg(struct ieee80211_hw *hw,
255 rtl92de_write_dword_dbi(hw, (u16) regaddr, data, dbi_direct); 257 rtl92de_write_dword_dbi(hw, (u16) regaddr, data, dbi_direct);
256 else 258 else
257 rtl_write_dword(rtlpriv, regaddr, data); 259 rtl_write_dword(rtlpriv, regaddr, data);
258 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," 260 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
259 " data(%#x)\n", regaddr, bitmask, data)); 261 "regaddr(%#x), bitmask(%#x), data(%#x)\n",
262 regaddr, bitmask, data);
260} 263}
261 264
262static u32 _rtl92d_phy_rf_serial_read(struct ieee80211_hw *hw, 265static u32 _rtl92d_phy_rf_serial_read(struct ieee80211_hw *hw,
@@ -300,8 +303,8 @@ static u32 _rtl92d_phy_rf_serial_read(struct ieee80211_hw *hw,
300 else 303 else
301 retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readback, 304 retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readback,
302 BLSSIREADBACKDATA); 305 BLSSIREADBACKDATA);
303 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFR-%d Addr[0x%x] = 0x%x\n", 306 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "RFR-%d Addr[0x%x] = 0x%x\n",
304 rfpath, pphyreg->rflssi_readback, retvalue)); 307 rfpath, pphyreg->rflssi_readback, retvalue);
305 return retvalue; 308 return retvalue;
306} 309}
307 310
@@ -319,8 +322,8 @@ static void _rtl92d_phy_rf_serial_write(struct ieee80211_hw *hw,
319 /* T65 RF */ 322 /* T65 RF */
320 data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff; 323 data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff;
321 rtl_set_bbreg(hw, pphyreg->rf3wire_offset, BMASKDWORD, data_and_addr); 324 rtl_set_bbreg(hw, pphyreg->rf3wire_offset, BMASKDWORD, data_and_addr);
322 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFW-%d Addr[0x%x]=0x%x\n", 325 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "RFW-%d Addr[0x%x]=0x%x\n",
323 rfpath, pphyreg->rf3wire_offset, data_and_addr)); 326 rfpath, pphyreg->rf3wire_offset, data_and_addr);
324} 327}
325 328
326u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, 329u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw,
@@ -330,17 +333,17 @@ u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw,
330 u32 original_value, readback_value, bitshift; 333 u32 original_value, readback_value, bitshift;
331 unsigned long flags; 334 unsigned long flags;
332 335
333 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " 336 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
334 "rfpath(%#x), bitmask(%#x)\n", 337 "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
335 regaddr, rfpath, bitmask)); 338 regaddr, rfpath, bitmask);
336 spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags); 339 spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags);
337 original_value = _rtl92d_phy_rf_serial_read(hw, rfpath, regaddr); 340 original_value = _rtl92d_phy_rf_serial_read(hw, rfpath, regaddr);
338 bitshift = _rtl92d_phy_calculate_bit_shift(bitmask); 341 bitshift = _rtl92d_phy_calculate_bit_shift(bitmask);
339 readback_value = (original_value & bitmask) >> bitshift; 342 readback_value = (original_value & bitmask) >> bitshift;
340 spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags); 343 spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags);
341 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), rfpath(%#x), " 344 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
342 "bitmask(%#x), original_value(%#x)\n", 345 "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n",
343 regaddr, rfpath, bitmask, original_value)); 346 regaddr, rfpath, bitmask, original_value);
344 return readback_value; 347 return readback_value;
345} 348}
346 349
@@ -353,8 +356,8 @@ void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
353 unsigned long flags; 356 unsigned long flags;
354 357
355 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, 358 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
356 ("regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", 359 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
357 regaddr, bitmask, data, rfpath)); 360 regaddr, bitmask, data, rfpath);
358 if (bitmask == 0) 361 if (bitmask == 0)
359 return; 362 return;
360 spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags); 363 spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags);
@@ -369,9 +372,9 @@ void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
369 _rtl92d_phy_rf_serial_write(hw, rfpath, regaddr, data); 372 _rtl92d_phy_rf_serial_write(hw, rfpath, regaddr, data);
370 } 373 }
371 spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags); 374 spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags);
372 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " 375 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
373 "bitmask(%#x), data(%#x), rfpath(%#x)\n", 376 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
374 regaddr, bitmask, data, rfpath)); 377 regaddr, bitmask, data, rfpath);
375} 378}
376 379
377bool rtl92d_phy_mac_config(struct ieee80211_hw *hw) 380bool rtl92d_phy_mac_config(struct ieee80211_hw *hw)
@@ -381,10 +384,10 @@ bool rtl92d_phy_mac_config(struct ieee80211_hw *hw)
381 u32 arraylength; 384 u32 arraylength;
382 u32 *ptrarray; 385 u32 *ptrarray;
383 386
384 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Read Rtl819XMACPHY_Array\n")); 387 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Read Rtl819XMACPHY_Array\n");
385 arraylength = MAC_2T_ARRAYLENGTH; 388 arraylength = MAC_2T_ARRAYLENGTH;
386 ptrarray = rtl8192de_mac_2tarray; 389 ptrarray = rtl8192de_mac_2tarray;
387 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Img:Rtl819XMAC_Array\n")); 390 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Img:Rtl819XMAC_Array\n");
388 for (i = 0; i < arraylength; i = i + 2) 391 for (i = 0; i < arraylength; i = i + 2)
389 rtl_write_byte(rtlpriv, ptrarray[i], (u8) ptrarray[i + 1]); 392 rtl_write_byte(rtlpriv, ptrarray[i], (u8) ptrarray[i + 1]);
390 if (rtlpriv->rtlhal.macphymode == SINGLEMAC_SINGLEPHY) { 393 if (rtlpriv->rtlhal.macphymode == SINGLEMAC_SINGLEPHY) {
@@ -561,25 +564,25 @@ static bool _rtl92d_phy_config_bb_with_headerfile(struct ieee80211_hw *hw,
561 agctab_arraylen = AGCTAB_ARRAYLENGTH; 564 agctab_arraylen = AGCTAB_ARRAYLENGTH;
562 agctab_array_table = rtl8192de_agctab_array; 565 agctab_array_table = rtl8192de_agctab_array;
563 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 566 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
564 (" ===> phy:MAC0, Rtl819XAGCTAB_Array\n")); 567 " ===> phy:MAC0, Rtl819XAGCTAB_Array\n");
565 } else { 568 } else {
566 if (rtlhal->current_bandtype == BAND_ON_2_4G) { 569 if (rtlhal->current_bandtype == BAND_ON_2_4G) {
567 agctab_arraylen = AGCTAB_2G_ARRAYLENGTH; 570 agctab_arraylen = AGCTAB_2G_ARRAYLENGTH;
568 agctab_array_table = rtl8192de_agctab_2garray; 571 agctab_array_table = rtl8192de_agctab_2garray;
569 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 572 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
570 (" ===> phy:MAC1, Rtl819XAGCTAB_2GArray\n")); 573 " ===> phy:MAC1, Rtl819XAGCTAB_2GArray\n");
571 } else { 574 } else {
572 agctab_5garraylen = AGCTAB_5G_ARRAYLENGTH; 575 agctab_5garraylen = AGCTAB_5G_ARRAYLENGTH;
573 agctab_5garray_table = rtl8192de_agctab_5garray; 576 agctab_5garray_table = rtl8192de_agctab_5garray;
574 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 577 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
575 (" ===> phy:MAC1, Rtl819XAGCTAB_5GArray\n")); 578 " ===> phy:MAC1, Rtl819XAGCTAB_5GArray\n");
576 579
577 } 580 }
578 } 581 }
579 phy_reg_arraylen = PHY_REG_2T_ARRAYLENGTH; 582 phy_reg_arraylen = PHY_REG_2T_ARRAYLENGTH;
580 phy_regarray_table = rtl8192de_phy_reg_2tarray; 583 phy_regarray_table = rtl8192de_phy_reg_2tarray;
581 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 584 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
582 (" ===> phy:Rtl819XPHY_REG_Array_PG\n")); 585 " ===> phy:Rtl819XPHY_REG_Array_PG\n");
583 if (configtype == BASEBAND_CONFIG_PHY_REG) { 586 if (configtype == BASEBAND_CONFIG_PHY_REG) {
584 for (i = 0; i < phy_reg_arraylen; i = i + 2) { 587 for (i = 0; i < phy_reg_arraylen; i = i + 2) {
585 if (phy_regarray_table[i] == 0xfe) 588 if (phy_regarray_table[i] == 0xfe)
@@ -598,10 +601,9 @@ static bool _rtl92d_phy_config_bb_with_headerfile(struct ieee80211_hw *hw,
598 phy_regarray_table[i + 1]); 601 phy_regarray_table[i + 1]);
599 udelay(1); 602 udelay(1);
600 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 603 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
601 ("The phy_regarray_table[0] is %x" 604 "The phy_regarray_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n",
602 " Rtl819XPHY_REGArray[1] is %x\n", 605 phy_regarray_table[i],
603 phy_regarray_table[i], 606 phy_regarray_table[i + 1]);
604 phy_regarray_table[i + 1]));
605 } 607 }
606 } else if (configtype == BASEBAND_CONFIG_AGC_TAB) { 608 } else if (configtype == BASEBAND_CONFIG_AGC_TAB) {
607 if (rtlhal->interfaceindex == 0) { 609 if (rtlhal->interfaceindex == 0) {
@@ -613,15 +615,12 @@ static bool _rtl92d_phy_config_bb_with_headerfile(struct ieee80211_hw *hw,
613 * setting. */ 615 * setting. */
614 udelay(1); 616 udelay(1);
615 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 617 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
616 ("The Rtl819XAGCTAB_Array_" 618 "The Rtl819XAGCTAB_Array_Table[0] is %ul Rtl819XPHY_REGArray[1] is %ul\n",
617 "Table[0] is %ul "
618 "Rtl819XPHY_REGArray[1] is %ul\n",
619 agctab_array_table[i], 619 agctab_array_table[i],
620 agctab_array_table[i + 1])); 620 agctab_array_table[i + 1]);
621 } 621 }
622 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 622 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
623 ("Normal Chip, MAC0, load " 623 "Normal Chip, MAC0, load Rtl819XAGCTAB_Array\n");
624 "Rtl819XAGCTAB_Array\n"));
625 } else { 624 } else {
626 if (rtlhal->current_bandtype == BAND_ON_2_4G) { 625 if (rtlhal->current_bandtype == BAND_ON_2_4G) {
627 for (i = 0; i < agctab_arraylen; i = i + 2) { 626 for (i = 0; i < agctab_arraylen; i = i + 2) {
@@ -632,14 +631,12 @@ static bool _rtl92d_phy_config_bb_with_headerfile(struct ieee80211_hw *hw,
632 * setting. */ 631 * setting. */
633 udelay(1); 632 udelay(1);
634 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 633 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
635 ("The Rtl819XAGCTAB_Array_" 634 "The Rtl819XAGCTAB_Array_Table[0] is %ul Rtl819XPHY_REGArray[1] is %ul\n",
636 "Table[0] is %ul Rtl819XPHY_"
637 "REGArray[1] is %ul\n",
638 agctab_array_table[i], 635 agctab_array_table[i],
639 agctab_array_table[i + 1])); 636 agctab_array_table[i + 1]);
640 } 637 }
641 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 638 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
642 ("Load Rtl819XAGCTAB_2GArray\n")); 639 "Load Rtl819XAGCTAB_2GArray\n");
643 } else { 640 } else {
644 for (i = 0; i < agctab_5garraylen; i = i + 2) { 641 for (i = 0; i < agctab_5garraylen; i = i + 2) {
645 rtl_set_bbreg(hw, 642 rtl_set_bbreg(hw,
@@ -650,14 +647,12 @@ static bool _rtl92d_phy_config_bb_with_headerfile(struct ieee80211_hw *hw,
650 * setting. */ 647 * setting. */
651 udelay(1); 648 udelay(1);
652 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 649 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
653 ("The Rtl819XAGCTAB_5GArray_" 650 "The Rtl819XAGCTAB_5GArray_Table[0] is %ul Rtl819XPHY_REGArray[1] is %ul\n",
654 "Table[0] is %ul Rtl819XPHY_"
655 "REGArray[1] is %ul\n",
656 agctab_5garray_table[i], 651 agctab_5garray_table[i],
657 agctab_5garray_table[i + 1])); 652 agctab_5garray_table[i + 1]);
658 } 653 }
659 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 654 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
660 ("Load Rtl819XAGCTAB_5GArray\n")); 655 "Load Rtl819XAGCTAB_5GArray\n");
661 } 656 }
662 } 657 }
663 } 658 }
@@ -675,145 +670,145 @@ static void _rtl92d_store_pwrindex_diffrate_offset(struct ieee80211_hw *hw,
675 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][0] = 670 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][0] =
676 data; 671 data;
677 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 672 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
678 ("MCSTxPowerLevelOriginalOffset[%d][0] = 0x%ulx\n", 673 "MCSTxPowerLevelOriginalOffset[%d][0] = 0x%ulx\n",
679 rtlphy->pwrgroup_cnt, 674 rtlphy->pwrgroup_cnt,
680 rtlphy->mcs_txpwrlevel_origoffset 675 rtlphy->mcs_txpwrlevel_origoffset
681 [rtlphy->pwrgroup_cnt][0])); 676 [rtlphy->pwrgroup_cnt][0]);
682 } 677 }
683 if (regaddr == RTXAGC_A_RATE54_24) { 678 if (regaddr == RTXAGC_A_RATE54_24) {
684 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][1] = 679 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][1] =
685 data; 680 data;
686 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 681 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
687 ("MCSTxPowerLevelOriginalOffset[%d][1] = 0x%ulx\n", 682 "MCSTxPowerLevelOriginalOffset[%d][1] = 0x%ulx\n",
688 rtlphy->pwrgroup_cnt, 683 rtlphy->pwrgroup_cnt,
689 rtlphy->mcs_txpwrlevel_origoffset 684 rtlphy->mcs_txpwrlevel_origoffset
690 [rtlphy->pwrgroup_cnt][1])); 685 [rtlphy->pwrgroup_cnt][1]);
691 } 686 }
692 if (regaddr == RTXAGC_A_CCK1_MCS32) { 687 if (regaddr == RTXAGC_A_CCK1_MCS32) {
693 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][6] = 688 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][6] =
694 data; 689 data;
695 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 690 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
696 ("MCSTxPowerLevelOriginalOffset[%d][6] = 0x%ulx\n", 691 "MCSTxPowerLevelOriginalOffset[%d][6] = 0x%ulx\n",
697 rtlphy->pwrgroup_cnt, 692 rtlphy->pwrgroup_cnt,
698 rtlphy->mcs_txpwrlevel_origoffset 693 rtlphy->mcs_txpwrlevel_origoffset
699 [rtlphy->pwrgroup_cnt][6])); 694 [rtlphy->pwrgroup_cnt][6]);
700 } 695 }
701 if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) { 696 if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) {
702 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][7] = 697 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][7] =
703 data; 698 data;
704 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 699 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
705 ("MCSTxPowerLevelOriginalOffset[%d][7] = 0x%ulx\n", 700 "MCSTxPowerLevelOriginalOffset[%d][7] = 0x%ulx\n",
706 rtlphy->pwrgroup_cnt, 701 rtlphy->pwrgroup_cnt,
707 rtlphy->mcs_txpwrlevel_origoffset 702 rtlphy->mcs_txpwrlevel_origoffset
708 [rtlphy->pwrgroup_cnt][7])); 703 [rtlphy->pwrgroup_cnt][7]);
709 } 704 }
710 if (regaddr == RTXAGC_A_MCS03_MCS00) { 705 if (regaddr == RTXAGC_A_MCS03_MCS00) {
711 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][2] = 706 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][2] =
712 data; 707 data;
713 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 708 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
714 ("MCSTxPowerLevelOriginalOffset[%d][2] = 0x%ulx\n", 709 "MCSTxPowerLevelOriginalOffset[%d][2] = 0x%ulx\n",
715 rtlphy->pwrgroup_cnt, 710 rtlphy->pwrgroup_cnt,
716 rtlphy->mcs_txpwrlevel_origoffset 711 rtlphy->mcs_txpwrlevel_origoffset
717 [rtlphy->pwrgroup_cnt][2])); 712 [rtlphy->pwrgroup_cnt][2]);
718 } 713 }
719 if (regaddr == RTXAGC_A_MCS07_MCS04) { 714 if (regaddr == RTXAGC_A_MCS07_MCS04) {
720 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][3] = 715 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][3] =
721 data; 716 data;
722 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 717 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
723 ("MCSTxPowerLevelOriginalOffset[%d][3] = 0x%ulx\n", 718 "MCSTxPowerLevelOriginalOffset[%d][3] = 0x%ulx\n",
724 rtlphy->pwrgroup_cnt, 719 rtlphy->pwrgroup_cnt,
725 rtlphy->mcs_txpwrlevel_origoffset 720 rtlphy->mcs_txpwrlevel_origoffset
726 [rtlphy->pwrgroup_cnt][3])); 721 [rtlphy->pwrgroup_cnt][3]);
727 } 722 }
728 if (regaddr == RTXAGC_A_MCS11_MCS08) { 723 if (regaddr == RTXAGC_A_MCS11_MCS08) {
729 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][4] = 724 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][4] =
730 data; 725 data;
731 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 726 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
732 ("MCSTxPowerLevelOriginalOffset[%d][4] = 0x%ulx\n", 727 "MCSTxPowerLevelOriginalOffset[%d][4] = 0x%ulx\n",
733 rtlphy->pwrgroup_cnt, 728 rtlphy->pwrgroup_cnt,
734 rtlphy->mcs_txpwrlevel_origoffset 729 rtlphy->mcs_txpwrlevel_origoffset
735 [rtlphy->pwrgroup_cnt][4])); 730 [rtlphy->pwrgroup_cnt][4]);
736 } 731 }
737 if (regaddr == RTXAGC_A_MCS15_MCS12) { 732 if (regaddr == RTXAGC_A_MCS15_MCS12) {
738 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][5] = 733 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][5] =
739 data; 734 data;
740 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 735 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
741 ("MCSTxPowerLevelOriginalOffset[%d][5] = 0x%ulx\n", 736 "MCSTxPowerLevelOriginalOffset[%d][5] = 0x%ulx\n",
742 rtlphy->pwrgroup_cnt, 737 rtlphy->pwrgroup_cnt,
743 rtlphy->mcs_txpwrlevel_origoffset 738 rtlphy->mcs_txpwrlevel_origoffset
744 [rtlphy->pwrgroup_cnt][5])); 739 [rtlphy->pwrgroup_cnt][5]);
745 } 740 }
746 if (regaddr == RTXAGC_B_RATE18_06) { 741 if (regaddr == RTXAGC_B_RATE18_06) {
747 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][8] = 742 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][8] =
748 data; 743 data;
749 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 744 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
750 ("MCSTxPowerLevelOriginalOffset[%d][8] = 0x%ulx\n", 745 "MCSTxPowerLevelOriginalOffset[%d][8] = 0x%ulx\n",
751 rtlphy->pwrgroup_cnt, 746 rtlphy->pwrgroup_cnt,
752 rtlphy->mcs_txpwrlevel_origoffset 747 rtlphy->mcs_txpwrlevel_origoffset
753 [rtlphy->pwrgroup_cnt][8])); 748 [rtlphy->pwrgroup_cnt][8]);
754 } 749 }
755 if (regaddr == RTXAGC_B_RATE54_24) { 750 if (regaddr == RTXAGC_B_RATE54_24) {
756 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][9] = 751 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][9] =
757 data; 752 data;
758 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 753 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
759 ("MCSTxPowerLevelOriginalOffset[%d][9] = 0x%ulx\n", 754 "MCSTxPowerLevelOriginalOffset[%d][9] = 0x%ulx\n",
760 rtlphy->pwrgroup_cnt, 755 rtlphy->pwrgroup_cnt,
761 rtlphy->mcs_txpwrlevel_origoffset 756 rtlphy->mcs_txpwrlevel_origoffset
762 [rtlphy->pwrgroup_cnt][9])); 757 [rtlphy->pwrgroup_cnt][9]);
763 } 758 }
764 if (regaddr == RTXAGC_B_CCK1_55_MCS32) { 759 if (regaddr == RTXAGC_B_CCK1_55_MCS32) {
765 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][14] = 760 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][14] =
766 data; 761 data;
767 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 762 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
768 ("MCSTxPowerLevelOriginalOffset[%d][14] = 0x%ulx\n", 763 "MCSTxPowerLevelOriginalOffset[%d][14] = 0x%ulx\n",
769 rtlphy->pwrgroup_cnt, 764 rtlphy->pwrgroup_cnt,
770 rtlphy->mcs_txpwrlevel_origoffset 765 rtlphy->mcs_txpwrlevel_origoffset
771 [rtlphy->pwrgroup_cnt][14])); 766 [rtlphy->pwrgroup_cnt][14]);
772 } 767 }
773 if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) { 768 if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) {
774 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][15] = 769 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][15] =
775 data; 770 data;
776 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 771 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
777 ("MCSTxPowerLevelOriginalOffset[%d][15] = 0x%ulx\n", 772 "MCSTxPowerLevelOriginalOffset[%d][15] = 0x%ulx\n",
778 rtlphy->pwrgroup_cnt, 773 rtlphy->pwrgroup_cnt,
779 rtlphy->mcs_txpwrlevel_origoffset 774 rtlphy->mcs_txpwrlevel_origoffset
780 [rtlphy->pwrgroup_cnt][15])); 775 [rtlphy->pwrgroup_cnt][15]);
781 } 776 }
782 if (regaddr == RTXAGC_B_MCS03_MCS00) { 777 if (regaddr == RTXAGC_B_MCS03_MCS00) {
783 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][10] = 778 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][10] =
784 data; 779 data;
785 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 780 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
786 ("MCSTxPowerLevelOriginalOffset[%d][10] = 0x%ulx\n", 781 "MCSTxPowerLevelOriginalOffset[%d][10] = 0x%ulx\n",
787 rtlphy->pwrgroup_cnt, 782 rtlphy->pwrgroup_cnt,
788 rtlphy->mcs_txpwrlevel_origoffset 783 rtlphy->mcs_txpwrlevel_origoffset
789 [rtlphy->pwrgroup_cnt][10])); 784 [rtlphy->pwrgroup_cnt][10]);
790 } 785 }
791 if (regaddr == RTXAGC_B_MCS07_MCS04) { 786 if (regaddr == RTXAGC_B_MCS07_MCS04) {
792 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][11] = 787 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][11] =
793 data; 788 data;
794 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 789 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
795 ("MCSTxPowerLevelOriginalOffset[%d][11] = 0x%ulx\n", 790 "MCSTxPowerLevelOriginalOffset[%d][11] = 0x%ulx\n",
796 rtlphy->pwrgroup_cnt, 791 rtlphy->pwrgroup_cnt,
797 rtlphy->mcs_txpwrlevel_origoffset 792 rtlphy->mcs_txpwrlevel_origoffset
798 [rtlphy->pwrgroup_cnt][11])); 793 [rtlphy->pwrgroup_cnt][11]);
799 } 794 }
800 if (regaddr == RTXAGC_B_MCS11_MCS08) { 795 if (regaddr == RTXAGC_B_MCS11_MCS08) {
801 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][12] = 796 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][12] =
802 data; 797 data;
803 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 798 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
804 ("MCSTxPowerLevelOriginalOffset[%d][12] = 0x%ulx\n", 799 "MCSTxPowerLevelOriginalOffset[%d][12] = 0x%ulx\n",
805 rtlphy->pwrgroup_cnt, 800 rtlphy->pwrgroup_cnt,
806 rtlphy->mcs_txpwrlevel_origoffset 801 rtlphy->mcs_txpwrlevel_origoffset
807 [rtlphy->pwrgroup_cnt][12])); 802 [rtlphy->pwrgroup_cnt][12]);
808 } 803 }
809 if (regaddr == RTXAGC_B_MCS15_MCS12) { 804 if (regaddr == RTXAGC_B_MCS15_MCS12) {
810 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][13] = 805 rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][13] =
811 data; 806 data;
812 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 807 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
813 ("MCSTxPowerLevelOriginalOffset[%d][13] = 0x%ulx\n", 808 "MCSTxPowerLevelOriginalOffset[%d][13] = 0x%ulx\n",
814 rtlphy->pwrgroup_cnt, 809 rtlphy->pwrgroup_cnt,
815 rtlphy->mcs_txpwrlevel_origoffset 810 rtlphy->mcs_txpwrlevel_origoffset
816 [rtlphy->pwrgroup_cnt][13])); 811 [rtlphy->pwrgroup_cnt][13]);
817 rtlphy->pwrgroup_cnt++; 812 rtlphy->pwrgroup_cnt++;
818 } 813 }
819} 814}
@@ -849,7 +844,7 @@ static bool _rtl92d_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw,
849 } 844 }
850 } else { 845 } else {
851 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, 846 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
852 ("configtype != BaseBand_Config_PHY_REG\n")); 847 "configtype != BaseBand_Config_PHY_REG\n");
853 } 848 }
854 return true; 849 return true;
855} 850}
@@ -861,17 +856,17 @@ static bool _rtl92d_phy_bb_config(struct ieee80211_hw *hw)
861 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); 856 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
862 bool rtstatus = true; 857 bool rtstatus = true;
863 858
864 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("==>\n")); 859 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "==>\n");
865 rtstatus = _rtl92d_phy_config_bb_with_headerfile(hw, 860 rtstatus = _rtl92d_phy_config_bb_with_headerfile(hw,
866 BASEBAND_CONFIG_PHY_REG); 861 BASEBAND_CONFIG_PHY_REG);
867 if (rtstatus != true) { 862 if (rtstatus != true) {
868 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Write BB Reg Fail!!")); 863 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Write BB Reg Fail!!\n");
869 return false; 864 return false;
870 } 865 }
871 866
872 /* if (rtlphy->rf_type == RF_1T2R) { 867 /* if (rtlphy->rf_type == RF_1T2R) {
873 * _rtl92c_phy_bb_config_1t(hw); 868 * _rtl92c_phy_bb_config_1t(hw);
874 * RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Config to 1T!!\n")); 869 * RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Config to 1T!!\n");
875 *} */ 870 *} */
876 871
877 if (rtlefuse->autoload_failflag == false) { 872 if (rtlefuse->autoload_failflag == false) {
@@ -880,13 +875,13 @@ static bool _rtl92d_phy_bb_config(struct ieee80211_hw *hw)
880 BASEBAND_CONFIG_PHY_REG); 875 BASEBAND_CONFIG_PHY_REG);
881 } 876 }
882 if (rtstatus != true) { 877 if (rtstatus != true) {
883 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("BB_PG Reg Fail!!")); 878 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "BB_PG Reg Fail!!\n");
884 return false; 879 return false;
885 } 880 }
886 rtstatus = _rtl92d_phy_config_bb_with_headerfile(hw, 881 rtstatus = _rtl92d_phy_config_bb_with_headerfile(hw,
887 BASEBAND_CONFIG_AGC_TAB); 882 BASEBAND_CONFIG_AGC_TAB);
888 if (rtstatus != true) { 883 if (rtstatus != true) {
889 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("AGC Table Fail\n")); 884 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "AGC Table Fail\n");
890 return false; 885 return false;
891 } 886 }
892 rtlphy->cck_high_power = (bool) (rtl_get_bbreg(hw, 887 rtlphy->cck_high_power = (bool) (rtl_get_bbreg(hw,
@@ -951,19 +946,17 @@ bool rtl92d_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
951 radiob_array_table = rtl8192de_radiob_2t_int_paarray; 946 radiob_array_table = rtl8192de_radiob_2t_int_paarray;
952 } 947 }
953 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 948 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
954 ("PHY_ConfigRFWithHeaderFile() " 949 "PHY_ConfigRFWithHeaderFile() Radio_A:Rtl819XRadioA_1TArray\n");
955 "Radio_A:Rtl819XRadioA_1TArray\n"));
956 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 950 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
957 ("PHY_ConfigRFWithHeaderFile() " 951 "PHY_ConfigRFWithHeaderFile() Radio_B:Rtl819XRadioB_1TArray\n");
958 "Radio_B:Rtl819XRadioB_1TArray\n")); 952 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "Radio No %x\n", rfpath);
959 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Radio No %x\n", rfpath));
960 953
961 /* this only happens when DMDP, mac0 start on 2.4G, 954 /* this only happens when DMDP, mac0 start on 2.4G,
962 * mac1 start on 5G, mac 0 has to set phy0&phy1 955 * mac1 start on 5G, mac 0 has to set phy0&phy1
963 * pathA or mac1 has to set phy0&phy1 pathA */ 956 * pathA or mac1 has to set phy0&phy1 pathA */
964 if ((content == radiob_txt) && (rfpath == RF90_PATH_A)) { 957 if ((content == radiob_txt) && (rfpath == RF90_PATH_A)) {
965 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 958 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
966 (" ===> althougth Path A, we load radiob.txt\n")); 959 " ===> althougth Path A, we load radiob.txt\n");
967 radioa_arraylen = radiob_arraylen; 960 radioa_arraylen = radiob_arraylen;
968 radioa_array_table = radiob_array_table; 961 radioa_array_table = radiob_array_table;
969 } 962 }
@@ -1022,11 +1015,11 @@ bool rtl92d_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
1022 break; 1015 break;
1023 case RF90_PATH_C: 1016 case RF90_PATH_C:
1024 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1017 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1025 ("switch case not process\n")); 1018 "switch case not processed\n");
1026 break; 1019 break;
1027 case RF90_PATH_D: 1020 case RF90_PATH_D:
1028 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1021 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1029 ("switch case not process\n")); 1022 "switch case not processed\n");
1030 break; 1023 break;
1031 } 1024 }
1032 return true; 1025 return true;
@@ -1046,19 +1039,18 @@ void rtl92d_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw)
1046 rtlphy->default_initialgain[3] = 1039 rtlphy->default_initialgain[3] =
1047 (u8) rtl_get_bbreg(hw, ROFDM0_XDAGCCORE1, BMASKBYTE0); 1040 (u8) rtl_get_bbreg(hw, ROFDM0_XDAGCCORE1, BMASKBYTE0);
1048 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1041 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1049 ("Default initial gain (c50=0x%x, " 1042 "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x\n",
1050 "c58=0x%x, c60=0x%x, c68=0x%x\n", 1043 rtlphy->default_initialgain[0],
1051 rtlphy->default_initialgain[0], 1044 rtlphy->default_initialgain[1],
1052 rtlphy->default_initialgain[1], 1045 rtlphy->default_initialgain[2],
1053 rtlphy->default_initialgain[2], 1046 rtlphy->default_initialgain[3]);
1054 rtlphy->default_initialgain[3]));
1055 rtlphy->framesync = (u8)rtl_get_bbreg(hw, ROFDM0_RXDETECTOR3, 1047 rtlphy->framesync = (u8)rtl_get_bbreg(hw, ROFDM0_RXDETECTOR3,
1056 BMASKBYTE0); 1048 BMASKBYTE0);
1057 rtlphy->framesync_c34 = rtl_get_bbreg(hw, ROFDM0_RXDETECTOR2, 1049 rtlphy->framesync_c34 = rtl_get_bbreg(hw, ROFDM0_RXDETECTOR2,
1058 BMASKDWORD); 1050 BMASKDWORD);
1059 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1051 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1060 ("Default framesync (0x%x) = 0x%x\n", 1052 "Default framesync (0x%x) = 0x%x\n",
1061 ROFDM0_RXDETECTOR3, rtlphy->framesync)); 1053 ROFDM0_RXDETECTOR3, rtlphy->framesync);
1062} 1054}
1063 1055
1064static void _rtl92d_get_txpower_index(struct ieee80211_hw *hw, u8 channel, 1056static void _rtl92d_get_txpower_index(struct ieee80211_hw *hw, u8 channel,
@@ -1172,7 +1164,7 @@ void rtl92d_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation)
1172 break; 1164 break;
1173 default: 1165 default:
1174 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1166 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1175 ("Unknown Scan Backup operation.\n")); 1167 "Unknown Scan Backup operation\n");
1176 break; 1168 break;
1177 } 1169 }
1178 } 1170 }
@@ -1193,14 +1185,13 @@ void rtl92d_phy_set_bw_mode(struct ieee80211_hw *hw,
1193 return; 1185 return;
1194 if ((is_hal_stop(rtlhal)) || (RT_CANNOT_IO(hw))) { 1186 if ((is_hal_stop(rtlhal)) || (RT_CANNOT_IO(hw))) {
1195 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1187 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1196 ("FALSE driver sleep or unload\n")); 1188 "FALSE driver sleep or unload\n");
1197 return; 1189 return;
1198 } 1190 }
1199 rtlphy->set_bwmode_inprogress = true; 1191 rtlphy->set_bwmode_inprogress = true;
1200 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, 1192 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "Switch to %s bandwidth\n",
1201 ("Switch to %s bandwidth\n", 1193 rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ?
1202 rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? 1194 "20MHz" : "40MHz");
1203 "20MHz" : "40MHz"));
1204 reg_bw_opmode = rtl_read_byte(rtlpriv, REG_BWOPMODE); 1195 reg_bw_opmode = rtl_read_byte(rtlpriv, REG_BWOPMODE);
1205 reg_prsr_rsc = rtl_read_byte(rtlpriv, REG_RRSR + 2); 1196 reg_prsr_rsc = rtl_read_byte(rtlpriv, REG_RRSR + 2);
1206 switch (rtlphy->current_chan_bw) { 1197 switch (rtlphy->current_chan_bw) {
@@ -1218,7 +1209,7 @@ void rtl92d_phy_set_bw_mode(struct ieee80211_hw *hw,
1218 break; 1209 break;
1219 default: 1210 default:
1220 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1211 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1221 ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); 1212 "unknown bandwidth: %#X\n", rtlphy->current_chan_bw);
1222 break; 1213 break;
1223 } 1214 }
1224 switch (rtlphy->current_chan_bw) { 1215 switch (rtlphy->current_chan_bw) {
@@ -1250,13 +1241,13 @@ void rtl92d_phy_set_bw_mode(struct ieee80211_hw *hw,
1250 break; 1241 break;
1251 default: 1242 default:
1252 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1243 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1253 ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); 1244 "unknown bandwidth: %#X\n", rtlphy->current_chan_bw);
1254 break; 1245 break;
1255 1246
1256 } 1247 }
1257 rtl92d_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw); 1248 rtl92d_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw);
1258 rtlphy->set_bwmode_inprogress = false; 1249 rtlphy->set_bwmode_inprogress = false;
1259 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); 1250 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n");
1260} 1251}
1261 1252
1262static void _rtl92d_phy_stop_trx_before_changeband(struct ieee80211_hw *hw) 1253static void _rtl92d_phy_stop_trx_before_changeband(struct ieee80211_hw *hw)
@@ -1273,7 +1264,7 @@ static void rtl92d_phy_switch_wirelessband(struct ieee80211_hw *hw, u8 band)
1273 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 1264 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
1274 u8 value8; 1265 u8 value8;
1275 1266
1276 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("==>\n")); 1267 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "==>\n");
1277 rtlhal->bandset = band; 1268 rtlhal->bandset = band;
1278 rtlhal->current_bandtype = band; 1269 rtlhal->current_bandtype = band;
1279 if (IS_92D_SINGLEPHY(rtlhal->version)) 1270 if (IS_92D_SINGLEPHY(rtlhal->version))
@@ -1283,13 +1274,13 @@ static void rtl92d_phy_switch_wirelessband(struct ieee80211_hw *hw, u8 band)
1283 /* reconfig BB/RF according to wireless mode */ 1274 /* reconfig BB/RF according to wireless mode */
1284 if (rtlhal->current_bandtype == BAND_ON_2_4G) { 1275 if (rtlhal->current_bandtype == BAND_ON_2_4G) {
1285 /* BB & RF Config */ 1276 /* BB & RF Config */
1286 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, ("====>2.4G\n")); 1277 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "====>2.4G\n");
1287 if (rtlhal->interfaceindex == 1) 1278 if (rtlhal->interfaceindex == 1)
1288 _rtl92d_phy_config_bb_with_headerfile(hw, 1279 _rtl92d_phy_config_bb_with_headerfile(hw,
1289 BASEBAND_CONFIG_AGC_TAB); 1280 BASEBAND_CONFIG_AGC_TAB);
1290 } else { 1281 } else {
1291 /* 5G band */ 1282 /* 5G band */
1292 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, ("====>5G\n")); 1283 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "====>5G\n");
1293 if (rtlhal->interfaceindex == 1) 1284 if (rtlhal->interfaceindex == 1)
1294 _rtl92d_phy_config_bb_with_headerfile(hw, 1285 _rtl92d_phy_config_bb_with_headerfile(hw,
1295 BASEBAND_CONFIG_AGC_TAB); 1286 BASEBAND_CONFIG_AGC_TAB);
@@ -1317,7 +1308,7 @@ static void rtl92d_phy_switch_wirelessband(struct ieee80211_hw *hw, u8 band)
1317 0 ? REG_MAC0 : REG_MAC1), value8); 1308 0 ? REG_MAC0 : REG_MAC1), value8);
1318 } 1309 }
1319 mdelay(1); 1310 mdelay(1);
1320 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("<==Switch Band OK.\n")); 1311 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "<==Switch Band OK\n");
1321} 1312}
1322 1313
1323static void _rtl92d_phy_reload_imr_setting(struct ieee80211_hw *hw, 1314static void _rtl92d_phy_reload_imr_setting(struct ieee80211_hw *hw,
@@ -1329,9 +1320,9 @@ static void _rtl92d_phy_reload_imr_setting(struct ieee80211_hw *hw,
1329 u8 group, i; 1320 u8 group, i;
1330 unsigned long flag = 0; 1321 unsigned long flag = 0;
1331 1322
1332 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>path %d\n", rfpath)); 1323 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>path %d\n", rfpath);
1333 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G) { 1324 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G) {
1334 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>5G\n")); 1325 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>5G\n");
1335 rtl_set_bbreg(hw, RFPGA0_RFMOD, BIT(25) | BIT(24), 0); 1326 rtl_set_bbreg(hw, RFPGA0_RFMOD, BIT(25) | BIT(24), 0);
1336 rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, 0x00f00000, 0xf); 1327 rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, 0x00f00000, 0xf);
1337 /* fc area 0xd2c */ 1328 /* fc area 0xd2c */
@@ -1353,14 +1344,13 @@ static void _rtl92d_phy_reload_imr_setting(struct ieee80211_hw *hw,
1353 } else { 1344 } else {
1354 /* G band. */ 1345 /* G band. */
1355 RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD, 1346 RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD,
1356 ("Load RF IMR parameters for G band. IMR already " 1347 "Load RF IMR parameters for G band. IMR already setting %d\n",
1357 "setting %d\n", 1348 rtlpriv->rtlhal.load_imrandiqk_setting_for2g);
1358 rtlpriv->rtlhal.load_imrandiqk_setting_for2g)); 1349 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>2.4G\n");
1359 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>2.4G\n"));
1360 if (!rtlpriv->rtlhal.load_imrandiqk_setting_for2g) { 1350 if (!rtlpriv->rtlhal.load_imrandiqk_setting_for2g) {
1361 RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD, 1351 RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD,
1362 ("Load RF IMR parameters " 1352 "Load RF IMR parameters for G band. %d\n",
1363 "for G band. %d\n", rfpath)); 1353 rfpath);
1364 rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag); 1354 rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag);
1365 rtl_set_bbreg(hw, RFPGA0_RFMOD, BIT(25) | BIT(24), 0); 1355 rtl_set_bbreg(hw, RFPGA0_RFMOD, BIT(25) | BIT(24), 0);
1366 rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, 1356 rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4,
@@ -1378,7 +1368,7 @@ static void _rtl92d_phy_reload_imr_setting(struct ieee80211_hw *hw,
1378 rtl92d_release_cckandrw_pagea_ctl(hw, &flag); 1368 rtl92d_release_cckandrw_pagea_ctl(hw, &flag);
1379 } 1369 }
1380 } 1370 }
1381 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("<====\n")); 1371 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "<====\n");
1382} 1372}
1383 1373
1384static void _rtl92d_phy_enable_rf_env(struct ieee80211_hw *hw, 1374static void _rtl92d_phy_enable_rf_env(struct ieee80211_hw *hw,
@@ -1388,7 +1378,7 @@ static void _rtl92d_phy_enable_rf_env(struct ieee80211_hw *hw,
1388 struct rtl_phy *rtlphy = &(rtlpriv->phy); 1378 struct rtl_phy *rtlphy = &(rtlpriv->phy);
1389 struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; 1379 struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath];
1390 1380
1391 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("====>\n")); 1381 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "====>\n");
1392 /*----Store original RFENV control type----*/ 1382 /*----Store original RFENV control type----*/
1393 switch (rfpath) { 1383 switch (rfpath) {
1394 case RF90_PATH_A: 1384 case RF90_PATH_A:
@@ -1414,7 +1404,7 @@ static void _rtl92d_phy_enable_rf_env(struct ieee80211_hw *hw,
1414 /*Set 0 to 12 bits for 8255 */ 1404 /*Set 0 to 12 bits for 8255 */
1415 rtl_set_bbreg(hw, pphyreg->rfhssi_para2, B3WIREDATALENGTH, 0x0); 1405 rtl_set_bbreg(hw, pphyreg->rfhssi_para2, B3WIREDATALENGTH, 0x0);
1416 udelay(1); 1406 udelay(1);
1417 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("<====\n")); 1407 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "<====\n");
1418} 1408}
1419 1409
1420static void _rtl92d_phy_restore_rf_env(struct ieee80211_hw *hw, u8 rfpath, 1410static void _rtl92d_phy_restore_rf_env(struct ieee80211_hw *hw, u8 rfpath,
@@ -1424,7 +1414,7 @@ static void _rtl92d_phy_restore_rf_env(struct ieee80211_hw *hw, u8 rfpath,
1424 struct rtl_phy *rtlphy = &(rtlpriv->phy); 1414 struct rtl_phy *rtlphy = &(rtlpriv->phy);
1425 struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; 1415 struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath];
1426 1416
1427 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("=====>\n")); 1417 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "=====>\n");
1428 /*----Restore RFENV control type----*/ ; 1418 /*----Restore RFENV control type----*/ ;
1429 switch (rfpath) { 1419 switch (rfpath) {
1430 case RF90_PATH_A: 1420 case RF90_PATH_A:
@@ -1437,7 +1427,7 @@ static void _rtl92d_phy_restore_rf_env(struct ieee80211_hw *hw, u8 rfpath,
1437 *pu4_regval); 1427 *pu4_regval);
1438 break; 1428 break;
1439 } 1429 }
1440 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("<=====\n")); 1430 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "<=====\n");
1441} 1431}
1442 1432
1443static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel) 1433static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel)
@@ -1451,13 +1441,13 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel)
1451 bool need_pwr_down = false, internal_pa = false; 1441 bool need_pwr_down = false, internal_pa = false;
1452 u32 u4regvalue, mask = 0x1C000, value = 0, u4tmp, u4tmp2; 1442 u32 u4regvalue, mask = 0x1C000, value = 0, u4tmp, u4tmp2;
1453 1443
1454 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>\n")); 1444 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>\n");
1455 /* config path A for 5G */ 1445 /* config path A for 5G */
1456 if (rtlhal->current_bandtype == BAND_ON_5G) { 1446 if (rtlhal->current_bandtype == BAND_ON_5G) {
1457 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>5G\n")); 1447 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>5G\n");
1458 u4tmp = curveindex_5g[channel - 1]; 1448 u4tmp = curveindex_5g[channel - 1];
1459 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("ver 1 set RF-A, 5G, " 1449 RTPRINT(rtlpriv, FINIT, INIT_IQK,
1460 "0x28 = 0x%x !!\n", u4tmp)); 1450 "ver 1 set RF-A, 5G, 0x28 = 0x%x !!\n", u4tmp);
1461 for (i = 0; i < RF_CHNL_NUM_5G; i++) { 1451 for (i = 0; i < RF_CHNL_NUM_5G; i++) {
1462 if (channel == rf_chnl_5g[i] && channel <= 140) 1452 if (channel == rf_chnl_5g[i] && channel <= 140)
1463 index = 0; 1453 index = 0;
@@ -1503,12 +1493,13 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel)
1503 rf_reg_pram_c_5g[index][i]); 1493 rf_reg_pram_c_5g[index][i]);
1504 } 1494 }
1505 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, 1495 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
1506 ("offset 0x%x value 0x%x " 1496 "offset 0x%x value 0x%x path %d index %d readback 0x%x\n",
1507 "path %d index %d readback 0x%x\n", 1497 rf_reg_for_c_cut_5g[i],
1508 rf_reg_for_c_cut_5g[i], 1498 rf_reg_pram_c_5g[index][i],
1509 rf_reg_pram_c_5g[index][i], path, 1499 path, index,
1510 index, rtl_get_rfreg(hw, (enum radio_path)path, 1500 rtl_get_rfreg(hw, (enum radio_path)path,
1511 rf_reg_for_c_cut_5g[i], BRFREGOFFSETMASK))); 1501 rf_reg_for_c_cut_5g[i],
1502 BRFREGOFFSETMASK));
1512 } 1503 }
1513 if (need_pwr_down) 1504 if (need_pwr_down)
1514 _rtl92d_phy_restore_rf_env(hw, path, &u4regvalue); 1505 _rtl92d_phy_restore_rf_env(hw, path, &u4regvalue);
@@ -1541,11 +1532,10 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel)
1541 BRFREGOFFSETMASK, 1532 BRFREGOFFSETMASK,
1542 rf_pram_c_5g_int_pa[index][i]); 1533 rf_pram_c_5g_int_pa[index][i]);
1543 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, 1534 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD,
1544 ("offset 0x%x value 0x%x " 1535 "offset 0x%x value 0x%x path %d index %d\n",
1545 "path %d index %d\n",
1546 rf_for_c_cut_5g_internal_pa[i], 1536 rf_for_c_cut_5g_internal_pa[i],
1547 rf_pram_c_5g_int_pa[index][i], 1537 rf_pram_c_5g_int_pa[index][i],
1548 rfpath, index)); 1538 rfpath, index);
1549 } 1539 }
1550 } else { 1540 } else {
1551 rtl_set_rfreg(hw, (enum radio_path)rfpath, 0x0B, 1541 rtl_set_rfreg(hw, (enum radio_path)rfpath, 0x0B,
@@ -1553,10 +1543,10 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel)
1553 } 1543 }
1554 } 1544 }
1555 } else if (rtlhal->current_bandtype == BAND_ON_2_4G) { 1545 } else if (rtlhal->current_bandtype == BAND_ON_2_4G) {
1556 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>2.4G\n")); 1546 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "====>2.4G\n");
1557 u4tmp = curveindex_2g[channel - 1]; 1547 u4tmp = curveindex_2g[channel - 1];
1558 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("ver 3 set RF-B, 2G, " 1548 RTPRINT(rtlpriv, FINIT, INIT_IQK,
1559 "0x28 = 0x%x !!\n", u4tmp)); 1549 "ver 3 set RF-B, 2G, 0x28 = 0x%x !!\n", u4tmp);
1560 if (channel == 1 || channel == 2 || channel == 4 || channel == 9 1550 if (channel == 1 || channel == 2 || channel == 4 || channel == 9
1561 || channel == 10 || channel == 11 || channel == 12) 1551 || channel == 10 || channel == 11 || channel == 12)
1562 index = 0; 1552 index = 0;
@@ -1590,18 +1580,17 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel)
1590 rf_reg_param_for_c_cut_2g 1580 rf_reg_param_for_c_cut_2g
1591 [index][i]); 1581 [index][i]);
1592 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, 1582 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
1593 ("offset 0x%x value 0x%x mak 0x%x path %d " 1583 "offset 0x%x value 0x%x mak 0x%x path %d index %d readback 0x%x\n",
1594 "index %d readback 0x%x\n", 1584 rf_reg_for_c_cut_2g[i],
1595 rf_reg_for_c_cut_2g[i], 1585 rf_reg_param_for_c_cut_2g[index][i],
1596 rf_reg_param_for_c_cut_2g[index][i], 1586 rf_reg_mask_for_c_cut_2g[i], path, index,
1597 rf_reg_mask_for_c_cut_2g[i], path, index, 1587 rtl_get_rfreg(hw, (enum radio_path)path,
1598 rtl_get_rfreg(hw, (enum radio_path)path, 1588 rf_reg_for_c_cut_2g[i],
1599 rf_reg_for_c_cut_2g[i], 1589 BRFREGOFFSETMASK));
1600 BRFREGOFFSETMASK)));
1601 } 1590 }
1602 RTPRINT(rtlpriv, FINIT, INIT_IQK, 1591 RTPRINT(rtlpriv, FINIT, INIT_IQK,
1603 ("cosa ver 3 set RF-B, 2G, 0x28 = 0x%x !!\n", 1592 "cosa ver 3 set RF-B, 2G, 0x28 = 0x%x !!\n",
1604 rf_syn_g4_for_c_cut_2g | (u4tmp << 11))); 1593 rf_syn_g4_for_c_cut_2g | (u4tmp << 11));
1605 1594
1606 rtl_set_rfreg(hw, (enum radio_path)path, RF_SYN_G4, 1595 rtl_set_rfreg(hw, (enum radio_path)path, RF_SYN_G4,
1607 BRFREGOFFSETMASK, 1596 BRFREGOFFSETMASK,
@@ -1611,7 +1600,7 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel)
1611 if (rtlhal->during_mac0init_radiob) 1600 if (rtlhal->during_mac0init_radiob)
1612 rtl92d_phy_powerdown_anotherphy(hw, true); 1601 rtl92d_phy_powerdown_anotherphy(hw, true);
1613 } 1602 }
1614 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("<====\n")); 1603 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "<====\n");
1615} 1604}
1616 1605
1617u8 rtl92d_get_rightchnlplace_for_iqk(u8 chnl) 1606u8 rtl92d_get_rightchnlplace_for_iqk(u8 chnl)
@@ -1648,9 +1637,9 @@ static u8 _rtl92d_phy_patha_iqk(struct ieee80211_hw *hw, bool configpathb)
1648 u32 regeac, rege94, rege9c, regea4; 1637 u32 regeac, rege94, rege9c, regea4;
1649 u8 result = 0; 1638 u8 result = 0;
1650 1639
1651 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK!\n")); 1640 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path A IQK!\n");
1652 /* path-A IQK setting */ 1641 /* path-A IQK setting */
1653 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path-A IQK setting!\n")); 1642 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path-A IQK setting!\n");
1654 if (rtlhal->interfaceindex == 0) { 1643 if (rtlhal->interfaceindex == 0) {
1655 rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x10008c1f); 1644 rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x10008c1f);
1656 rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x10008c1f); 1645 rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x10008c1f);
@@ -1668,26 +1657,26 @@ static u8 _rtl92d_phy_patha_iqk(struct ieee80211_hw *hw, bool configpathb)
1668 rtl_set_bbreg(hw, 0xe5c, BMASKDWORD, 0x28160206); 1657 rtl_set_bbreg(hw, 0xe5c, BMASKDWORD, 0x28160206);
1669 } 1658 }
1670 /* LO calibration setting */ 1659 /* LO calibration setting */
1671 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("LO calibration setting!\n")); 1660 RTPRINT(rtlpriv, FINIT, INIT_IQK, "LO calibration setting!\n");
1672 rtl_set_bbreg(hw, 0xe4c, BMASKDWORD, 0x00462911); 1661 rtl_set_bbreg(hw, 0xe4c, BMASKDWORD, 0x00462911);
1673 /* One shot, path A LOK & IQK */ 1662 /* One shot, path A LOK & IQK */
1674 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("One shot, path A LOK & IQK!\n")); 1663 RTPRINT(rtlpriv, FINIT, INIT_IQK, "One shot, path A LOK & IQK!\n");
1675 rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf9000000); 1664 rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf9000000);
1676 rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf8000000); 1665 rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf8000000);
1677 /* delay x ms */ 1666 /* delay x ms */
1678 RTPRINT(rtlpriv, FINIT, INIT_IQK, 1667 RTPRINT(rtlpriv, FINIT, INIT_IQK,
1679 ("Delay %d ms for One shot, path A LOK & IQK.\n", 1668 "Delay %d ms for One shot, path A LOK & IQK\n",
1680 IQK_DELAY_TIME)); 1669 IQK_DELAY_TIME);
1681 mdelay(IQK_DELAY_TIME); 1670 mdelay(IQK_DELAY_TIME);
1682 /* Check failed */ 1671 /* Check failed */
1683 regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD); 1672 regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD);
1684 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeac = 0x%x\n", regeac)); 1673 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xeac = 0x%x\n", regeac);
1685 rege94 = rtl_get_bbreg(hw, 0xe94, BMASKDWORD); 1674 rege94 = rtl_get_bbreg(hw, 0xe94, BMASKDWORD);
1686 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xe94 = 0x%x\n", rege94)); 1675 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xe94 = 0x%x\n", rege94);
1687 rege9c = rtl_get_bbreg(hw, 0xe9c, BMASKDWORD); 1676 rege9c = rtl_get_bbreg(hw, 0xe9c, BMASKDWORD);
1688 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xe9c = 0x%x\n", rege9c)); 1677 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xe9c = 0x%x\n", rege9c);
1689 regea4 = rtl_get_bbreg(hw, 0xea4, BMASKDWORD); 1678 regea4 = rtl_get_bbreg(hw, 0xea4, BMASKDWORD);
1690 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xea4 = 0x%x\n", regea4)); 1679 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xea4 = 0x%x\n", regea4);
1691 if (!(regeac & BIT(28)) && (((rege94 & 0x03FF0000) >> 16) != 0x142) && 1680 if (!(regeac & BIT(28)) && (((rege94 & 0x03FF0000) >> 16) != 0x142) &&
1692 (((rege9c & 0x03FF0000) >> 16) != 0x42)) 1681 (((rege9c & 0x03FF0000) >> 16) != 0x42))
1693 result |= 0x01; 1682 result |= 0x01;
@@ -1698,7 +1687,7 @@ static u8 _rtl92d_phy_patha_iqk(struct ieee80211_hw *hw, bool configpathb)
1698 (((regeac & 0x03FF0000) >> 16) != 0x36)) 1687 (((regeac & 0x03FF0000) >> 16) != 0x36))
1699 result |= 0x02; 1688 result |= 0x02;
1700 else 1689 else
1701 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A Rx IQK fail!!\n")); 1690 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path A Rx IQK fail!!\n");
1702 return result; 1691 return result;
1703} 1692}
1704 1693
@@ -1719,9 +1708,9 @@ static u8 _rtl92d_phy_patha_iqk_5g_normal(struct ieee80211_hw *hw,
1719 TxOKBit = BIT(31); 1708 TxOKBit = BIT(31);
1720 RxOKBit = BIT(30); 1709 RxOKBit = BIT(30);
1721 } 1710 }
1722 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK!\n")); 1711 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path A IQK!\n");
1723 /* path-A IQK setting */ 1712 /* path-A IQK setting */
1724 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path-A IQK setting!\n")); 1713 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path-A IQK setting!\n");
1725 rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x18008c1f); 1714 rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x18008c1f);
1726 rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x18008c1f); 1715 rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x18008c1f);
1727 rtl_set_bbreg(hw, 0xe38, BMASKDWORD, 0x82140307); 1716 rtl_set_bbreg(hw, 0xe38, BMASKDWORD, 0x82140307);
@@ -1734,7 +1723,7 @@ static u8 _rtl92d_phy_patha_iqk_5g_normal(struct ieee80211_hw *hw,
1734 rtl_set_bbreg(hw, 0xe5c, BMASKDWORD, 0x68110000); 1723 rtl_set_bbreg(hw, 0xe5c, BMASKDWORD, 0x68110000);
1735 } 1724 }
1736 /* LO calibration setting */ 1725 /* LO calibration setting */
1737 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("LO calibration setting!\n")); 1726 RTPRINT(rtlpriv, FINIT, INIT_IQK, "LO calibration setting!\n");
1738 rtl_set_bbreg(hw, 0xe4c, BMASKDWORD, 0x00462911); 1727 rtl_set_bbreg(hw, 0xe4c, BMASKDWORD, 0x00462911);
1739 /* path-A PA on */ 1728 /* path-A PA on */
1740 rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, BMASKDWORD, 0x07000f60); 1729 rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, BMASKDWORD, 0x07000f60);
@@ -1742,29 +1731,29 @@ static u8 _rtl92d_phy_patha_iqk_5g_normal(struct ieee80211_hw *hw,
1742 for (i = 0; i < retrycount; i++) { 1731 for (i = 0; i < retrycount; i++) {
1743 /* One shot, path A LOK & IQK */ 1732 /* One shot, path A LOK & IQK */
1744 RTPRINT(rtlpriv, FINIT, INIT_IQK, 1733 RTPRINT(rtlpriv, FINIT, INIT_IQK,
1745 ("One shot, path A LOK & IQK!\n")); 1734 "One shot, path A LOK & IQK!\n");
1746 rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf9000000); 1735 rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf9000000);
1747 rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf8000000); 1736 rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf8000000);
1748 /* delay x ms */ 1737 /* delay x ms */
1749 RTPRINT(rtlpriv, FINIT, INIT_IQK, 1738 RTPRINT(rtlpriv, FINIT, INIT_IQK,
1750 ("Delay %d ms for One shot, path A LOK & IQK.\n", 1739 "Delay %d ms for One shot, path A LOK & IQK.\n",
1751 IQK_DELAY_TIME)); 1740 IQK_DELAY_TIME);
1752 mdelay(IQK_DELAY_TIME * 10); 1741 mdelay(IQK_DELAY_TIME * 10);
1753 /* Check failed */ 1742 /* Check failed */
1754 regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD); 1743 regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD);
1755 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeac = 0x%x\n", regeac)); 1744 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xeac = 0x%x\n", regeac);
1756 rege94 = rtl_get_bbreg(hw, 0xe94, BMASKDWORD); 1745 rege94 = rtl_get_bbreg(hw, 0xe94, BMASKDWORD);
1757 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xe94 = 0x%x\n", rege94)); 1746 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xe94 = 0x%x\n", rege94);
1758 rege9c = rtl_get_bbreg(hw, 0xe9c, BMASKDWORD); 1747 rege9c = rtl_get_bbreg(hw, 0xe9c, BMASKDWORD);
1759 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xe9c = 0x%x\n", rege9c)); 1748 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xe9c = 0x%x\n", rege9c);
1760 regea4 = rtl_get_bbreg(hw, 0xea4, BMASKDWORD); 1749 regea4 = rtl_get_bbreg(hw, 0xea4, BMASKDWORD);
1761 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xea4 = 0x%x\n", regea4)); 1750 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xea4 = 0x%x\n", regea4);
1762 if (!(regeac & TxOKBit) && 1751 if (!(regeac & TxOKBit) &&
1763 (((rege94 & 0x03FF0000) >> 16) != 0x142)) { 1752 (((rege94 & 0x03FF0000) >> 16) != 0x142)) {
1764 result |= 0x01; 1753 result |= 0x01;
1765 } else { /* if Tx not OK, ignore Rx */ 1754 } else { /* if Tx not OK, ignore Rx */
1766 RTPRINT(rtlpriv, FINIT, INIT_IQK, 1755 RTPRINT(rtlpriv, FINIT, INIT_IQK,
1767 ("Path A Tx IQK fail!!\n")); 1756 "Path A Tx IQK fail!!\n");
1768 continue; 1757 continue;
1769 } 1758 }
1770 1759
@@ -1775,7 +1764,7 @@ static u8 _rtl92d_phy_patha_iqk_5g_normal(struct ieee80211_hw *hw,
1775 break; 1764 break;
1776 } else { 1765 } else {
1777 RTPRINT(rtlpriv, FINIT, INIT_IQK, 1766 RTPRINT(rtlpriv, FINIT, INIT_IQK,
1778 ("Path A Rx IQK fail!!\n")); 1767 "Path A Rx IQK fail!!\n");
1779 } 1768 }
1780 } 1769 }
1781 /* path A PA off */ 1770 /* path A PA off */
@@ -1793,27 +1782,26 @@ static u8 _rtl92d_phy_pathb_iqk(struct ieee80211_hw *hw)
1793 u32 regeac, regeb4, regebc, regec4, regecc; 1782 u32 regeac, regeb4, regebc, regec4, regecc;
1794 u8 result = 0; 1783 u8 result = 0;
1795 1784
1796 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path B IQK!\n")); 1785 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path B IQK!\n");
1797 /* One shot, path B LOK & IQK */ 1786 /* One shot, path B LOK & IQK */
1798 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("One shot, path A LOK & IQK!\n")); 1787 RTPRINT(rtlpriv, FINIT, INIT_IQK, "One shot, path A LOK & IQK!\n");
1799 rtl_set_bbreg(hw, 0xe60, BMASKDWORD, 0x00000002); 1788 rtl_set_bbreg(hw, 0xe60, BMASKDWORD, 0x00000002);
1800 rtl_set_bbreg(hw, 0xe60, BMASKDWORD, 0x00000000); 1789 rtl_set_bbreg(hw, 0xe60, BMASKDWORD, 0x00000000);
1801 /* delay x ms */ 1790 /* delay x ms */
1802 RTPRINT(rtlpriv, FINIT, INIT_IQK, 1791 RTPRINT(rtlpriv, FINIT, INIT_IQK,
1803 ("Delay %d ms for One shot, path B LOK & IQK.\n", 1792 "Delay %d ms for One shot, path B LOK & IQK\n", IQK_DELAY_TIME);
1804 IQK_DELAY_TIME));
1805 mdelay(IQK_DELAY_TIME); 1793 mdelay(IQK_DELAY_TIME);
1806 /* Check failed */ 1794 /* Check failed */
1807 regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD); 1795 regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD);
1808 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeac = 0x%x\n", regeac)); 1796 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xeac = 0x%x\n", regeac);
1809 regeb4 = rtl_get_bbreg(hw, 0xeb4, BMASKDWORD); 1797 regeb4 = rtl_get_bbreg(hw, 0xeb4, BMASKDWORD);
1810 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeb4 = 0x%x\n", regeb4)); 1798 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xeb4 = 0x%x\n", regeb4);
1811 regebc = rtl_get_bbreg(hw, 0xebc, BMASKDWORD); 1799 regebc = rtl_get_bbreg(hw, 0xebc, BMASKDWORD);
1812 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xebc = 0x%x\n", regebc)); 1800 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xebc = 0x%x\n", regebc);
1813 regec4 = rtl_get_bbreg(hw, 0xec4, BMASKDWORD); 1801 regec4 = rtl_get_bbreg(hw, 0xec4, BMASKDWORD);
1814 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xec4 = 0x%x\n", regec4)); 1802 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xec4 = 0x%x\n", regec4);
1815 regecc = rtl_get_bbreg(hw, 0xecc, BMASKDWORD); 1803 regecc = rtl_get_bbreg(hw, 0xecc, BMASKDWORD);
1816 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xecc = 0x%x\n", regecc)); 1804 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xecc = 0x%x\n", regecc);
1817 if (!(regeac & BIT(31)) && (((regeb4 & 0x03FF0000) >> 16) != 0x142) && 1805 if (!(regeac & BIT(31)) && (((regeb4 & 0x03FF0000) >> 16) != 0x142) &&
1818 (((regebc & 0x03FF0000) >> 16) != 0x42)) 1806 (((regebc & 0x03FF0000) >> 16) != 0x42))
1819 result |= 0x01; 1807 result |= 0x01;
@@ -1823,7 +1811,7 @@ static u8 _rtl92d_phy_pathb_iqk(struct ieee80211_hw *hw)
1823 (((regecc & 0x03FF0000) >> 16) != 0x36)) 1811 (((regecc & 0x03FF0000) >> 16) != 0x36))
1824 result |= 0x02; 1812 result |= 0x02;
1825 else 1813 else
1826 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path B Rx IQK fail!!\n")); 1814 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path B Rx IQK fail!!\n");
1827 return result; 1815 return result;
1828} 1816}
1829 1817
@@ -1837,9 +1825,9 @@ static u8 _rtl92d_phy_pathb_iqk_5g_normal(struct ieee80211_hw *hw)
1837 u8 i; 1825 u8 i;
1838 u8 retrycount = 2; 1826 u8 retrycount = 2;
1839 1827
1840 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path B IQK!\n")); 1828 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path B IQK!\n");
1841 /* path-A IQK setting */ 1829 /* path-A IQK setting */
1842 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path-A IQK setting!\n")); 1830 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path-A IQK setting!\n");
1843 rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x18008c1f); 1831 rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x18008c1f);
1844 rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x18008c1f); 1832 rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x18008c1f);
1845 rtl_set_bbreg(hw, 0xe38, BMASKDWORD, 0x82110000); 1833 rtl_set_bbreg(hw, 0xe38, BMASKDWORD, 0x82110000);
@@ -1852,7 +1840,7 @@ static u8 _rtl92d_phy_pathb_iqk_5g_normal(struct ieee80211_hw *hw)
1852 rtl_set_bbreg(hw, 0xe5c, BMASKDWORD, 0x68160960); 1840 rtl_set_bbreg(hw, 0xe5c, BMASKDWORD, 0x68160960);
1853 1841
1854 /* LO calibration setting */ 1842 /* LO calibration setting */
1855 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("LO calibration setting!\n")); 1843 RTPRINT(rtlpriv, FINIT, INIT_IQK, "LO calibration setting!\n");
1856 rtl_set_bbreg(hw, 0xe4c, BMASKDWORD, 0x00462911); 1844 rtl_set_bbreg(hw, 0xe4c, BMASKDWORD, 0x00462911);
1857 1845
1858 /* path-B PA on */ 1846 /* path-B PA on */
@@ -1862,26 +1850,26 @@ static u8 _rtl92d_phy_pathb_iqk_5g_normal(struct ieee80211_hw *hw)
1862 for (i = 0; i < retrycount; i++) { 1850 for (i = 0; i < retrycount; i++) {
1863 /* One shot, path B LOK & IQK */ 1851 /* One shot, path B LOK & IQK */
1864 RTPRINT(rtlpriv, FINIT, INIT_IQK, 1852 RTPRINT(rtlpriv, FINIT, INIT_IQK,
1865 ("One shot, path A LOK & IQK!\n")); 1853 "One shot, path A LOK & IQK!\n");
1866 rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xfa000000); 1854 rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xfa000000);
1867 rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf8000000); 1855 rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf8000000);
1868 1856
1869 /* delay x ms */ 1857 /* delay x ms */
1870 RTPRINT(rtlpriv, FINIT, INIT_IQK, 1858 RTPRINT(rtlpriv, FINIT, INIT_IQK,
1871 ("Delay %d ms for One shot, path B LOK & IQK.\n", 10)); 1859 "Delay %d ms for One shot, path B LOK & IQK.\n", 10);
1872 mdelay(IQK_DELAY_TIME * 10); 1860 mdelay(IQK_DELAY_TIME * 10);
1873 1861
1874 /* Check failed */ 1862 /* Check failed */
1875 regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD); 1863 regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD);
1876 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeac = 0x%x\n", regeac)); 1864 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xeac = 0x%x\n", regeac);
1877 regeb4 = rtl_get_bbreg(hw, 0xeb4, BMASKDWORD); 1865 regeb4 = rtl_get_bbreg(hw, 0xeb4, BMASKDWORD);
1878 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeb4 = 0x%x\n", regeb4)); 1866 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xeb4 = 0x%x\n", regeb4);
1879 regebc = rtl_get_bbreg(hw, 0xebc, BMASKDWORD); 1867 regebc = rtl_get_bbreg(hw, 0xebc, BMASKDWORD);
1880 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xebc = 0x%x\n", regebc)); 1868 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xebc = 0x%x\n", regebc);
1881 regec4 = rtl_get_bbreg(hw, 0xec4, BMASKDWORD); 1869 regec4 = rtl_get_bbreg(hw, 0xec4, BMASKDWORD);
1882 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xec4 = 0x%x\n", regec4)); 1870 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xec4 = 0x%x\n", regec4);
1883 regecc = rtl_get_bbreg(hw, 0xecc, BMASKDWORD); 1871 regecc = rtl_get_bbreg(hw, 0xecc, BMASKDWORD);
1884 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xecc = 0x%x\n", regecc)); 1872 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xecc = 0x%x\n", regecc);
1885 if (!(regeac & BIT(31)) && 1873 if (!(regeac & BIT(31)) &&
1886 (((regeb4 & 0x03FF0000) >> 16) != 0x142)) 1874 (((regeb4 & 0x03FF0000) >> 16) != 0x142))
1887 result |= 0x01; 1875 result |= 0x01;
@@ -1893,7 +1881,7 @@ static u8 _rtl92d_phy_pathb_iqk_5g_normal(struct ieee80211_hw *hw)
1893 break; 1881 break;
1894 } else { 1882 } else {
1895 RTPRINT(rtlpriv, FINIT, INIT_IQK, 1883 RTPRINT(rtlpriv, FINIT, INIT_IQK,
1896 ("Path B Rx IQK fail!!\n")); 1884 "Path B Rx IQK fail!!\n");
1897 } 1885 }
1898 } 1886 }
1899 1887
@@ -1912,7 +1900,7 @@ static void _rtl92d_phy_save_adda_registers(struct ieee80211_hw *hw,
1912 struct rtl_priv *rtlpriv = rtl_priv(hw); 1900 struct rtl_priv *rtlpriv = rtl_priv(hw);
1913 u32 i; 1901 u32 i;
1914 1902
1915 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Save ADDA parameters.\n")); 1903 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Save ADDA parameters.\n");
1916 for (i = 0; i < regnum; i++) 1904 for (i = 0; i < regnum; i++)
1917 adda_backup[i] = rtl_get_bbreg(hw, adda_reg[i], BMASKDWORD); 1905 adda_backup[i] = rtl_get_bbreg(hw, adda_reg[i], BMASKDWORD);
1918} 1906}
@@ -1923,7 +1911,7 @@ static void _rtl92d_phy_save_mac_registers(struct ieee80211_hw *hw,
1923 struct rtl_priv *rtlpriv = rtl_priv(hw); 1911 struct rtl_priv *rtlpriv = rtl_priv(hw);
1924 u32 i; 1912 u32 i;
1925 1913
1926 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Save MAC parameters.\n")); 1914 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Save MAC parameters.\n");
1927 for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) 1915 for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++)
1928 macbackup[i] = rtl_read_byte(rtlpriv, macreg[i]); 1916 macbackup[i] = rtl_read_byte(rtlpriv, macreg[i]);
1929 macbackup[i] = rtl_read_dword(rtlpriv, macreg[i]); 1917 macbackup[i] = rtl_read_dword(rtlpriv, macreg[i]);
@@ -1937,7 +1925,7 @@ static void _rtl92d_phy_reload_adda_registers(struct ieee80211_hw *hw,
1937 u32 i; 1925 u32 i;
1938 1926
1939 RTPRINT(rtlpriv, FINIT, INIT_IQK, 1927 RTPRINT(rtlpriv, FINIT, INIT_IQK,
1940 ("Reload ADDA power saving parameters !\n")); 1928 "Reload ADDA power saving parameters !\n");
1941 for (i = 0; i < regnum; i++) 1929 for (i = 0; i < regnum; i++)
1942 rtl_set_bbreg(hw, adda_reg[i], BMASKDWORD, adda_backup[i]); 1930 rtl_set_bbreg(hw, adda_reg[i], BMASKDWORD, adda_backup[i]);
1943} 1931}
@@ -1948,7 +1936,7 @@ static void _rtl92d_phy_reload_mac_registers(struct ieee80211_hw *hw,
1948 struct rtl_priv *rtlpriv = rtl_priv(hw); 1936 struct rtl_priv *rtlpriv = rtl_priv(hw);
1949 u32 i; 1937 u32 i;
1950 1938
1951 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Reload MAC parameters !\n")); 1939 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Reload MAC parameters !\n");
1952 for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) 1940 for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++)
1953 rtl_write_byte(rtlpriv, macreg[i], (u8) macbackup[i]); 1941 rtl_write_byte(rtlpriv, macreg[i], (u8) macbackup[i]);
1954 rtl_write_byte(rtlpriv, macreg[i], macbackup[i]); 1942 rtl_write_byte(rtlpriv, macreg[i], macbackup[i]);
@@ -1961,7 +1949,7 @@ static void _rtl92d_phy_path_adda_on(struct ieee80211_hw *hw,
1961 u32 pathon; 1949 u32 pathon;
1962 u32 i; 1950 u32 i;
1963 1951
1964 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("ADDA ON.\n")); 1952 RTPRINT(rtlpriv, FINIT, INIT_IQK, "ADDA ON.\n");
1965 pathon = patha_on ? 0x04db25a4 : 0x0b1b25a4; 1953 pathon = patha_on ? 0x04db25a4 : 0x0b1b25a4;
1966 if (patha_on) 1954 if (patha_on)
1967 pathon = rtlpriv->rtlhal.interfaceindex == 0 ? 1955 pathon = rtlpriv->rtlhal.interfaceindex == 0 ?
@@ -1976,7 +1964,7 @@ static void _rtl92d_phy_mac_setting_calibration(struct ieee80211_hw *hw,
1976 struct rtl_priv *rtlpriv = rtl_priv(hw); 1964 struct rtl_priv *rtlpriv = rtl_priv(hw);
1977 u32 i; 1965 u32 i;
1978 1966
1979 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("MAC settings for Calibration.\n")); 1967 RTPRINT(rtlpriv, FINIT, INIT_IQK, "MAC settings for Calibration.\n");
1980 rtl_write_byte(rtlpriv, macreg[0], 0x3F); 1968 rtl_write_byte(rtlpriv, macreg[0], 0x3F);
1981 1969
1982 for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) 1970 for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++)
@@ -1988,7 +1976,7 @@ static void _rtl92d_phy_mac_setting_calibration(struct ieee80211_hw *hw,
1988static void _rtl92d_phy_patha_standby(struct ieee80211_hw *hw) 1976static void _rtl92d_phy_patha_standby(struct ieee80211_hw *hw)
1989{ 1977{
1990 struct rtl_priv *rtlpriv = rtl_priv(hw); 1978 struct rtl_priv *rtlpriv = rtl_priv(hw);
1991 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path-A standby mode!\n")); 1979 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path-A standby mode!\n");
1992 1980
1993 rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0x0); 1981 rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0x0);
1994 rtl_set_bbreg(hw, RFPGA0_XA_LSSIPARAMETER, BMASKDWORD, 0x00010000); 1982 rtl_set_bbreg(hw, RFPGA0_XA_LSSIPARAMETER, BMASKDWORD, 0x00010000);
@@ -2001,7 +1989,7 @@ static void _rtl92d_phy_pimode_switch(struct ieee80211_hw *hw, bool pi_mode)
2001 u32 mode; 1989 u32 mode;
2002 1990
2003 RTPRINT(rtlpriv, FINIT, INIT_IQK, 1991 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2004 ("BB Switch to %s mode!\n", (pi_mode ? "PI" : "SI"))); 1992 "BB Switch to %s mode!\n", pi_mode ? "PI" : "SI");
2005 mode = pi_mode ? 0x01000100 : 0x01000000; 1993 mode = pi_mode ? 0x01000100 : 0x01000000;
2006 rtl_set_bbreg(hw, 0x820, BMASKDWORD, mode); 1994 rtl_set_bbreg(hw, 0x820, BMASKDWORD, mode);
2007 rtl_set_bbreg(hw, 0x828, BMASKDWORD, mode); 1995 rtl_set_bbreg(hw, 0x828, BMASKDWORD, mode);
@@ -2033,12 +2021,12 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8],
2033 const u32 retrycount = 2; 2021 const u32 retrycount = 2;
2034 u32 bbvalue; 2022 u32 bbvalue;
2035 2023
2036 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQK for 2.4G :Start!!!\n")); 2024 RTPRINT(rtlpriv, FINIT, INIT_IQK, "IQK for 2.4G :Start!!!\n");
2037 if (t == 0) { 2025 if (t == 0) {
2038 bbvalue = rtl_get_bbreg(hw, RFPGA0_RFMOD, BMASKDWORD); 2026 bbvalue = rtl_get_bbreg(hw, RFPGA0_RFMOD, BMASKDWORD);
2039 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("==>0x%08x\n", bbvalue)); 2027 RTPRINT(rtlpriv, FINIT, INIT_IQK, "==>0x%08x\n", bbvalue);
2040 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQ Calibration for %s\n", 2028 RTPRINT(rtlpriv, FINIT, INIT_IQK, "IQ Calibration for %s\n",
2041 (is2t ? "2T2R" : "1T1R"))); 2029 is2t ? "2T2R" : "1T1R");
2042 2030
2043 /* Save ADDA parameters, turn Path A ADDA on */ 2031 /* Save ADDA parameters, turn Path A ADDA on */
2044 _rtl92d_phy_save_adda_registers(hw, adda_reg, 2032 _rtl92d_phy_save_adda_registers(hw, adda_reg,
@@ -2076,7 +2064,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8],
2076 if (is2t) 2064 if (is2t)
2077 rtl_set_bbreg(hw, 0xb6c, BMASKDWORD, 0x0f600000); 2065 rtl_set_bbreg(hw, 0xb6c, BMASKDWORD, 0x0f600000);
2078 /* IQ calibration setting */ 2066 /* IQ calibration setting */
2079 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQK setting!\n")); 2067 RTPRINT(rtlpriv, FINIT, INIT_IQK, "IQK setting!\n");
2080 rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0x80800000); 2068 rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0x80800000);
2081 rtl_set_bbreg(hw, 0xe40, BMASKDWORD, 0x01007c00); 2069 rtl_set_bbreg(hw, 0xe40, BMASKDWORD, 0x01007c00);
2082 rtl_set_bbreg(hw, 0xe44, BMASKDWORD, 0x01004800); 2070 rtl_set_bbreg(hw, 0xe44, BMASKDWORD, 0x01004800);
@@ -2084,7 +2072,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8],
2084 patha_ok = _rtl92d_phy_patha_iqk(hw, is2t); 2072 patha_ok = _rtl92d_phy_patha_iqk(hw, is2t);
2085 if (patha_ok == 0x03) { 2073 if (patha_ok == 0x03) {
2086 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2074 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2087 ("Path A IQK Success!!\n")); 2075 "Path A IQK Success!!\n");
2088 result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) & 2076 result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) &
2089 0x3FF0000) >> 16; 2077 0x3FF0000) >> 16;
2090 result[t][1] = (rtl_get_bbreg(hw, 0xe9c, BMASKDWORD) & 2078 result[t][1] = (rtl_get_bbreg(hw, 0xe9c, BMASKDWORD) &
@@ -2097,7 +2085,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8],
2097 } else if (i == (retrycount - 1) && patha_ok == 0x01) { 2085 } else if (i == (retrycount - 1) && patha_ok == 0x01) {
2098 /* Tx IQK OK */ 2086 /* Tx IQK OK */
2099 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2087 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2100 ("Path A IQK Only Tx Success!!\n")); 2088 "Path A IQK Only Tx Success!!\n");
2101 2089
2102 result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) & 2090 result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) &
2103 0x3FF0000) >> 16; 2091 0x3FF0000) >> 16;
@@ -2106,7 +2094,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8],
2106 } 2094 }
2107 } 2095 }
2108 if (0x00 == patha_ok) 2096 if (0x00 == patha_ok)
2109 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK failed!!\n")); 2097 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path A IQK failed!!\n");
2110 if (is2t) { 2098 if (is2t) {
2111 _rtl92d_phy_patha_standby(hw); 2099 _rtl92d_phy_patha_standby(hw);
2112 /* Turn Path B ADDA on */ 2100 /* Turn Path B ADDA on */
@@ -2115,7 +2103,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8],
2115 pathb_ok = _rtl92d_phy_pathb_iqk(hw); 2103 pathb_ok = _rtl92d_phy_pathb_iqk(hw);
2116 if (pathb_ok == 0x03) { 2104 if (pathb_ok == 0x03) {
2117 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2105 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2118 ("Path B IQK Success!!\n")); 2106 "Path B IQK Success!!\n");
2119 result[t][4] = (rtl_get_bbreg(hw, 0xeb4, 2107 result[t][4] = (rtl_get_bbreg(hw, 0xeb4,
2120 BMASKDWORD) & 0x3FF0000) >> 16; 2108 BMASKDWORD) & 0x3FF0000) >> 16;
2121 result[t][5] = (rtl_get_bbreg(hw, 0xebc, 2109 result[t][5] = (rtl_get_bbreg(hw, 0xebc,
@@ -2128,7 +2116,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8],
2128 } else if (i == (retrycount - 1) && pathb_ok == 0x01) { 2116 } else if (i == (retrycount - 1) && pathb_ok == 0x01) {
2129 /* Tx IQK OK */ 2117 /* Tx IQK OK */
2130 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2118 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2131 ("Path B Only Tx IQK Success!!\n")); 2119 "Path B Only Tx IQK Success!!\n");
2132 result[t][4] = (rtl_get_bbreg(hw, 0xeb4, 2120 result[t][4] = (rtl_get_bbreg(hw, 0xeb4,
2133 BMASKDWORD) & 0x3FF0000) >> 16; 2121 BMASKDWORD) & 0x3FF0000) >> 16;
2134 result[t][5] = (rtl_get_bbreg(hw, 0xebc, 2122 result[t][5] = (rtl_get_bbreg(hw, 0xebc,
@@ -2137,12 +2125,12 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8],
2137 } 2125 }
2138 if (0x00 == pathb_ok) 2126 if (0x00 == pathb_ok)
2139 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2127 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2140 ("Path B IQK failed!!\n")); 2128 "Path B IQK failed!!\n");
2141 } 2129 }
2142 2130
2143 /* Back to BB mode, load original value */ 2131 /* Back to BB mode, load original value */
2144 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2132 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2145 ("IQK:Back to BB mode, load original value!\n")); 2133 "IQK:Back to BB mode, load original value!\n");
2146 2134
2147 rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0); 2135 rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0);
2148 if (t != 0) { 2136 if (t != 0) {
@@ -2167,7 +2155,7 @@ static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8],
2167 rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x01008c00); 2155 rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x01008c00);
2168 rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x01008c00); 2156 rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x01008c00);
2169 } 2157 }
2170 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("<==\n")); 2158 RTPRINT(rtlpriv, FINIT, INIT_IQK, "<==\n");
2171} 2159}
2172 2160
2173static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw, 2161static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw,
@@ -2199,13 +2187,13 @@ static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw,
2199 /* Note: IQ calibration must be performed after loading 2187 /* Note: IQ calibration must be performed after loading
2200 * PHY_REG.txt , and radio_a, radio_b.txt */ 2188 * PHY_REG.txt , and radio_a, radio_b.txt */
2201 2189
2202 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQK for 5G NORMAL:Start!!!\n")); 2190 RTPRINT(rtlpriv, FINIT, INIT_IQK, "IQK for 5G NORMAL:Start!!!\n");
2203 mdelay(IQK_DELAY_TIME * 20); 2191 mdelay(IQK_DELAY_TIME * 20);
2204 if (t == 0) { 2192 if (t == 0) {
2205 bbvalue = rtl_get_bbreg(hw, RFPGA0_RFMOD, BMASKDWORD); 2193 bbvalue = rtl_get_bbreg(hw, RFPGA0_RFMOD, BMASKDWORD);
2206 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("==>0x%08x\n", bbvalue)); 2194 RTPRINT(rtlpriv, FINIT, INIT_IQK, "==>0x%08x\n", bbvalue);
2207 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQ Calibration for %s\n", 2195 RTPRINT(rtlpriv, FINIT, INIT_IQK, "IQ Calibration for %s\n",
2208 (is2t ? "2T2R" : "1T1R"))); 2196 is2t ? "2T2R" : "1T1R");
2209 /* Save ADDA parameters, turn Path A ADDA on */ 2197 /* Save ADDA parameters, turn Path A ADDA on */
2210 _rtl92d_phy_save_adda_registers(hw, adda_reg, 2198 _rtl92d_phy_save_adda_registers(hw, adda_reg,
2211 rtlphy->adda_backup, 2199 rtlphy->adda_backup,
@@ -2242,13 +2230,13 @@ static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw,
2242 if (is2t) 2230 if (is2t)
2243 rtl_set_bbreg(hw, 0xb6c, BMASKDWORD, 0x0f600000); 2231 rtl_set_bbreg(hw, 0xb6c, BMASKDWORD, 0x0f600000);
2244 /* IQ calibration setting */ 2232 /* IQ calibration setting */
2245 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQK setting!\n")); 2233 RTPRINT(rtlpriv, FINIT, INIT_IQK, "IQK setting!\n");
2246 rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0x80800000); 2234 rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0x80800000);
2247 rtl_set_bbreg(hw, 0xe40, BMASKDWORD, 0x10007c00); 2235 rtl_set_bbreg(hw, 0xe40, BMASKDWORD, 0x10007c00);
2248 rtl_set_bbreg(hw, 0xe44, BMASKDWORD, 0x01004800); 2236 rtl_set_bbreg(hw, 0xe44, BMASKDWORD, 0x01004800);
2249 patha_ok = _rtl92d_phy_patha_iqk_5g_normal(hw, is2t); 2237 patha_ok = _rtl92d_phy_patha_iqk_5g_normal(hw, is2t);
2250 if (patha_ok == 0x03) { 2238 if (patha_ok == 0x03) {
2251 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK Success!!\n")); 2239 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path A IQK Success!!\n");
2252 result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) & 2240 result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) &
2253 0x3FF0000) >> 16; 2241 0x3FF0000) >> 16;
2254 result[t][1] = (rtl_get_bbreg(hw, 0xe9c, BMASKDWORD) & 2242 result[t][1] = (rtl_get_bbreg(hw, 0xe9c, BMASKDWORD) &
@@ -2259,14 +2247,14 @@ static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw,
2259 0x3FF0000) >> 16; 2247 0x3FF0000) >> 16;
2260 } else if (patha_ok == 0x01) { /* Tx IQK OK */ 2248 } else if (patha_ok == 0x01) { /* Tx IQK OK */
2261 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2249 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2262 ("Path A IQK Only Tx Success!!\n")); 2250 "Path A IQK Only Tx Success!!\n");
2263 2251
2264 result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) & 2252 result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) &
2265 0x3FF0000) >> 16; 2253 0x3FF0000) >> 16;
2266 result[t][1] = (rtl_get_bbreg(hw, 0xe9c, BMASKDWORD) & 2254 result[t][1] = (rtl_get_bbreg(hw, 0xe9c, BMASKDWORD) &
2267 0x3FF0000) >> 16; 2255 0x3FF0000) >> 16;
2268 } else { 2256 } else {
2269 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK Fail!!\n")); 2257 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path A IQK Fail!!\n");
2270 } 2258 }
2271 if (is2t) { 2259 if (is2t) {
2272 /* _rtl92d_phy_patha_standby(hw); */ 2260 /* _rtl92d_phy_patha_standby(hw); */
@@ -2275,7 +2263,7 @@ static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw,
2275 pathb_ok = _rtl92d_phy_pathb_iqk_5g_normal(hw); 2263 pathb_ok = _rtl92d_phy_pathb_iqk_5g_normal(hw);
2276 if (pathb_ok == 0x03) { 2264 if (pathb_ok == 0x03) {
2277 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2265 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2278 ("Path B IQK Success!!\n")); 2266 "Path B IQK Success!!\n");
2279 result[t][4] = (rtl_get_bbreg(hw, 0xeb4, BMASKDWORD) & 2267 result[t][4] = (rtl_get_bbreg(hw, 0xeb4, BMASKDWORD) &
2280 0x3FF0000) >> 16; 2268 0x3FF0000) >> 16;
2281 result[t][5] = (rtl_get_bbreg(hw, 0xebc, BMASKDWORD) & 2269 result[t][5] = (rtl_get_bbreg(hw, 0xebc, BMASKDWORD) &
@@ -2286,20 +2274,20 @@ static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw,
2286 0x3FF0000) >> 16; 2274 0x3FF0000) >> 16;
2287 } else if (pathb_ok == 0x01) { /* Tx IQK OK */ 2275 } else if (pathb_ok == 0x01) { /* Tx IQK OK */
2288 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2276 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2289 ("Path B Only Tx IQK Success!!\n")); 2277 "Path B Only Tx IQK Success!!\n");
2290 result[t][4] = (rtl_get_bbreg(hw, 0xeb4, BMASKDWORD) & 2278 result[t][4] = (rtl_get_bbreg(hw, 0xeb4, BMASKDWORD) &
2291 0x3FF0000) >> 16; 2279 0x3FF0000) >> 16;
2292 result[t][5] = (rtl_get_bbreg(hw, 0xebc, BMASKDWORD) & 2280 result[t][5] = (rtl_get_bbreg(hw, 0xebc, BMASKDWORD) &
2293 0x3FF0000) >> 16; 2281 0x3FF0000) >> 16;
2294 } else { 2282 } else {
2295 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2283 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2296 ("Path B IQK failed!!\n")); 2284 "Path B IQK failed!!\n");
2297 } 2285 }
2298 } 2286 }
2299 2287
2300 /* Back to BB mode, load original value */ 2288 /* Back to BB mode, load original value */
2301 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2289 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2302 ("IQK:Back to BB mode, load original value!\n")); 2290 "IQK:Back to BB mode, load original value!\n");
2303 rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0); 2291 rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0);
2304 if (t != 0) { 2292 if (t != 0) {
2305 if (is2t) 2293 if (is2t)
@@ -2321,7 +2309,7 @@ static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw,
2321 rtlphy->adda_backup, 2309 rtlphy->adda_backup,
2322 IQK_ADDA_REG_NUM); 2310 IQK_ADDA_REG_NUM);
2323 } 2311 }
2324 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("<==\n")); 2312 RTPRINT(rtlpriv, FINIT, INIT_IQK, "<==\n");
2325} 2313}
2326 2314
2327static bool _rtl92d_phy_simularity_compare(struct ieee80211_hw *hw, 2315static bool _rtl92d_phy_simularity_compare(struct ieee80211_hw *hw,
@@ -2395,8 +2383,7 @@ static void _rtl92d_phy_patha_fill_iqk_matrix(struct ieee80211_hw *hw,
2395 rtlhal->macphymode == DUALMAC_DUALPHY; 2383 rtlhal->macphymode == DUALMAC_DUALPHY;
2396 2384
2397 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2385 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2398 ("Path A IQ Calibration %s !\n", 2386 "Path A IQ Calibration %s !\n", iqk_ok ? "Success" : "Failed");
2399 (iqk_ok) ? "Success" : "Failed"));
2400 if (final_candidate == 0xFF) { 2387 if (final_candidate == 0xFF) {
2401 return; 2388 return;
2402 } else if (iqk_ok) { 2389 } else if (iqk_ok) {
@@ -2406,8 +2393,9 @@ static void _rtl92d_phy_patha_fill_iqk_matrix(struct ieee80211_hw *hw,
2406 if ((val_x & 0x00000200) != 0) 2393 if ((val_x & 0x00000200) != 0)
2407 val_x = val_x | 0xFFFFFC00; 2394 val_x = val_x | 0xFFFFFC00;
2408 tx0_a = (val_x * oldval_0) >> 8; 2395 tx0_a = (val_x * oldval_0) >> 8;
2409 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("X = 0x%x, tx0_a = 0x%x," 2396 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2410 " oldval_0 0x%x\n", val_x, tx0_a, oldval_0)); 2397 "X = 0x%x, tx0_a = 0x%x, oldval_0 0x%x\n",
2398 val_x, tx0_a, oldval_0);
2411 rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, 0x3FF, tx0_a); 2399 rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, 0x3FF, tx0_a);
2412 rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(24), 2400 rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(24),
2413 ((val_x * oldval_0 >> 7) & 0x1)); 2401 ((val_x * oldval_0 >> 7) & 0x1));
@@ -2419,8 +2407,9 @@ static void _rtl92d_phy_patha_fill_iqk_matrix(struct ieee80211_hw *hw,
2419 rtlhal->current_bandtype == BAND_ON_5G) 2407 rtlhal->current_bandtype == BAND_ON_5G)
2420 val_y += 3; 2408 val_y += 3;
2421 tx0_c = (val_y * oldval_0) >> 8; 2409 tx0_c = (val_y * oldval_0) >> 8;
2422 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Y = 0x%lx, tx0_c = 0x%lx\n", 2410 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2423 val_y, tx0_c)); 2411 "Y = 0x%lx, tx0_c = 0x%lx\n",
2412 val_y, tx0_c);
2424 rtl_set_bbreg(hw, ROFDM0_XCTxAFE, 0xF0000000, 2413 rtl_set_bbreg(hw, ROFDM0_XCTxAFE, 0xF0000000,
2425 ((tx0_c & 0x3C0) >> 6)); 2414 ((tx0_c & 0x3C0) >> 6));
2426 rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, 0x003F0000, 2415 rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, 0x003F0000,
@@ -2428,11 +2417,11 @@ static void _rtl92d_phy_patha_fill_iqk_matrix(struct ieee80211_hw *hw,
2428 if (is2t) 2417 if (is2t)
2429 rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(26), 2418 rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(26),
2430 ((val_y * oldval_0 >> 7) & 0x1)); 2419 ((val_y * oldval_0 >> 7) & 0x1));
2431 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xC80 = 0x%x\n", 2420 RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xC80 = 0x%x\n",
2432 rtl_get_bbreg(hw, ROFDM0_XATxIQIMBALANCE, 2421 rtl_get_bbreg(hw, ROFDM0_XATxIQIMBALANCE,
2433 BMASKDWORD))); 2422 BMASKDWORD));
2434 if (txonly) { 2423 if (txonly) {
2435 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("only Tx OK\n")); 2424 RTPRINT(rtlpriv, FINIT, INIT_IQK, "only Tx OK\n");
2436 return; 2425 return;
2437 } 2426 }
2438 reg = result[final_candidate][2]; 2427 reg = result[final_candidate][2];
@@ -2452,8 +2441,8 @@ static void _rtl92d_phy_pathb_fill_iqk_matrix(struct ieee80211_hw *hw,
2452 u32 oldval_1, val_x, tx1_a, reg; 2441 u32 oldval_1, val_x, tx1_a, reg;
2453 long val_y, tx1_c; 2442 long val_y, tx1_c;
2454 2443
2455 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path B IQ Calibration %s !\n", 2444 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Path B IQ Calibration %s !\n",
2456 (iqk_ok) ? "Success" : "Failed")); 2445 iqk_ok ? "Success" : "Failed");
2457 if (final_candidate == 0xFF) { 2446 if (final_candidate == 0xFF) {
2458 return; 2447 return;
2459 } else if (iqk_ok) { 2448 } else if (iqk_ok) {
@@ -2463,8 +2452,8 @@ static void _rtl92d_phy_pathb_fill_iqk_matrix(struct ieee80211_hw *hw,
2463 if ((val_x & 0x00000200) != 0) 2452 if ((val_x & 0x00000200) != 0)
2464 val_x = val_x | 0xFFFFFC00; 2453 val_x = val_x | 0xFFFFFC00;
2465 tx1_a = (val_x * oldval_1) >> 8; 2454 tx1_a = (val_x * oldval_1) >> 8;
2466 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("X = 0x%x, tx1_a = 0x%x\n", 2455 RTPRINT(rtlpriv, FINIT, INIT_IQK, "X = 0x%x, tx1_a = 0x%x\n",
2467 val_x, tx1_a)); 2456 val_x, tx1_a);
2468 rtl_set_bbreg(hw, ROFDM0_XBTxIQIMBALANCE, 0x3FF, tx1_a); 2457 rtl_set_bbreg(hw, ROFDM0_XBTxIQIMBALANCE, 0x3FF, tx1_a);
2469 rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(28), 2458 rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(28),
2470 ((val_x * oldval_1 >> 7) & 0x1)); 2459 ((val_x * oldval_1 >> 7) & 0x1));
@@ -2474,8 +2463,8 @@ static void _rtl92d_phy_pathb_fill_iqk_matrix(struct ieee80211_hw *hw,
2474 if (rtlhal->current_bandtype == BAND_ON_5G) 2463 if (rtlhal->current_bandtype == BAND_ON_5G)
2475 val_y += 3; 2464 val_y += 3;
2476 tx1_c = (val_y * oldval_1) >> 8; 2465 tx1_c = (val_y * oldval_1) >> 8;
2477 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Y = 0x%lx, tx1_c = 0x%lx\n", 2466 RTPRINT(rtlpriv, FINIT, INIT_IQK, "Y = 0x%lx, tx1_c = 0x%lx\n",
2478 val_y, tx1_c)); 2467 val_y, tx1_c);
2479 rtl_set_bbreg(hw, ROFDM0_XDTxAFE, 0xF0000000, 2468 rtl_set_bbreg(hw, ROFDM0_XDTxAFE, 0xF0000000,
2480 ((tx1_c & 0x3C0) >> 6)); 2469 ((tx1_c & 0x3C0) >> 6));
2481 rtl_set_bbreg(hw, ROFDM0_XBTxIQIMBALANCE, 0x003F0000, 2470 rtl_set_bbreg(hw, ROFDM0_XBTxIQIMBALANCE, 0x003F0000,
@@ -2507,7 +2496,7 @@ void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw)
2507 unsigned long flag = 0; 2496 unsigned long flag = 0;
2508 2497
2509 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2498 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2510 ("IQK:Start!!!channel %d\n", rtlphy->current_channel)); 2499 "IQK:Start!!!channel %d\n", rtlphy->current_channel);
2511 for (i = 0; i < 8; i++) { 2500 for (i = 0; i < 8; i++) {
2512 result[0][i] = 0; 2501 result[0][i] = 0;
2513 result[1][i] = 0; 2502 result[1][i] = 0;
@@ -2521,7 +2510,7 @@ void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw)
2521 is23simular = false; 2510 is23simular = false;
2522 is13simular = false; 2511 is13simular = false;
2523 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2512 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2524 ("IQK !!!currentband %d\n", rtlhal->current_bandtype)); 2513 "IQK !!!currentband %d\n", rtlhal->current_bandtype);
2525 rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag); 2514 rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag);
2526 for (i = 0; i < 3; i++) { 2515 for (i = 0; i < 3; i++) {
2527 if (rtlhal->current_bandtype == BAND_ON_5G) { 2516 if (rtlhal->current_bandtype == BAND_ON_5G) {
@@ -2573,10 +2562,9 @@ void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw)
2573 regec4 = result[i][6]; 2562 regec4 = result[i][6];
2574 regecc = result[i][7]; 2563 regecc = result[i][7];
2575 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2564 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2576 ("IQK: rege94=%lx rege9c=%lx regea4=%lx regeac=%lx " 2565 "IQK: rege94=%lx rege9c=%lx regea4=%lx regeac=%lx regeb4=%lx regebc=%lx regec4=%lx regecc=%lx\n",
2577 "regeb4=%lx regebc=%lx regec4=%lx regecc=%lx\n ",
2578 rege94, rege9c, regea4, regeac, regeb4, regebc, regec4, 2566 rege94, rege9c, regea4, regeac, regeb4, regebc, regec4,
2579 regecc)); 2567 regecc);
2580 } 2568 }
2581 if (final_candidate != 0xff) { 2569 if (final_candidate != 0xff) {
2582 rtlphy->reg_e94 = rege94 = result[final_candidate][0]; 2570 rtlphy->reg_e94 = rege94 = result[final_candidate][0];
@@ -2588,12 +2576,11 @@ void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw)
2588 regec4 = result[final_candidate][6]; 2576 regec4 = result[final_candidate][6];
2589 regecc = result[final_candidate][7]; 2577 regecc = result[final_candidate][7];
2590 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2578 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2591 ("IQK: final_candidate is %x\n", final_candidate)); 2579 "IQK: final_candidate is %x\n", final_candidate);
2592 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2580 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2593 ("IQK: rege94=%lx rege9c=%lx regea4=%lx regeac=%lx " 2581 "IQK: rege94=%lx rege9c=%lx regea4=%lx regeac=%lx regeb4=%lx regebc=%lx regec4=%lx regecc=%lx\n",
2594 "regeb4=%lx regebc=%lx regec4=%lx regecc=%lx\n ",
2595 rege94, rege9c, regea4, regeac, regeb4, regebc, regec4, 2582 rege94, rege9c, regea4, regeac, regeb4, regebc, regec4,
2596 regecc)); 2583 regecc);
2597 patha_ok = pathb_ok = true; 2584 patha_ok = pathb_ok = true;
2598 } else { 2585 } else {
2599 rtlphy->reg_e94 = rtlphy->reg_eb4 = 0x100; /* X default value */ 2586 rtlphy->reg_e94 = rtlphy->reg_eb4 = 0x100; /* X default value */
@@ -2618,7 +2605,7 @@ void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw)
2618 true; 2605 true;
2619 2606
2620 RT_TRACE(rtlpriv, COMP_SCAN | COMP_MLME, DBG_LOUD, 2607 RT_TRACE(rtlpriv, COMP_SCAN | COMP_MLME, DBG_LOUD,
2621 ("\nIQK OK indexforchannel %d.\n", indexforchannel)); 2608 "IQK OK indexforchannel %d\n", indexforchannel);
2622 } 2609 }
2623} 2610}
2624 2611
@@ -2629,17 +2616,17 @@ void rtl92d_phy_reload_iqk_setting(struct ieee80211_hw *hw, u8 channel)
2629 struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); 2616 struct rtl_hal *rtlhal = &(rtlpriv->rtlhal);
2630 u8 indexforchannel; 2617 u8 indexforchannel;
2631 2618
2632 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("channel %d\n", channel)); 2619 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "channel %d\n", channel);
2633 /*------Do IQK for normal chip and test chip 5G band------- */ 2620 /*------Do IQK for normal chip and test chip 5G band------- */
2634 indexforchannel = rtl92d_get_rightchnlplace_for_iqk(channel); 2621 indexforchannel = rtl92d_get_rightchnlplace_for_iqk(channel);
2635 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 2622 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "indexforchannel %d done %d\n",
2636 ("indexforchannel %d done %d\n", indexforchannel, 2623 indexforchannel,
2637 rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done)); 2624 rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done);
2638 if (0 && !rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done && 2625 if (0 && !rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done &&
2639 rtlphy->need_iqk) { 2626 rtlphy->need_iqk) {
2640 /* Re Do IQK. */ 2627 /* Re Do IQK. */
2641 RT_TRACE(rtlpriv, COMP_SCAN | COMP_INIT, DBG_LOUD, 2628 RT_TRACE(rtlpriv, COMP_SCAN | COMP_INIT, DBG_LOUD,
2642 ("Do IQK Matrix reg for channel:%d....\n", channel)); 2629 "Do IQK Matrix reg for channel:%d....\n", channel);
2643 rtl92d_phy_iq_calibrate(hw); 2630 rtl92d_phy_iq_calibrate(hw);
2644 } else { 2631 } else {
2645 /* Just load the value. */ 2632 /* Just load the value. */
@@ -2647,8 +2634,8 @@ void rtl92d_phy_reload_iqk_setting(struct ieee80211_hw *hw, u8 channel)
2647 if (((!rtlhal->load_imrandiqk_setting_for2g) && 2634 if (((!rtlhal->load_imrandiqk_setting_for2g) &&
2648 indexforchannel == 0) || indexforchannel > 0) { 2635 indexforchannel == 0) || indexforchannel > 0) {
2649 RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD, 2636 RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD,
2650 ("Just Read IQK Matrix reg for channel:%d" 2637 "Just Read IQK Matrix reg for channel:%d....\n",
2651 "....\n", channel)); 2638 channel);
2652 if ((rtlphy->iqk_matrix_regsetting[indexforchannel]. 2639 if ((rtlphy->iqk_matrix_regsetting[indexforchannel].
2653 value[0] != NULL) 2640 value[0] != NULL)
2654 /*&&(regea4 != 0) */) 2641 /*&&(regea4 != 0) */)
@@ -2672,7 +2659,7 @@ void rtl92d_phy_reload_iqk_setting(struct ieee80211_hw *hw, u8 channel)
2672 } 2659 }
2673 } 2660 }
2674 rtlphy->need_iqk = false; 2661 rtlphy->need_iqk = false;
2675 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("<====\n")); 2662 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "<====\n");
2676} 2663}
2677 2664
2678static u32 _rtl92d_phy_get_abs(u32 val1, u32 val2) 2665static u32 _rtl92d_phy_get_abs(u32 val1, u32 val2)
@@ -2727,8 +2714,8 @@ static void _rtl92d_phy_calc_curvindex(struct ieee80211_hw *hw,
2727 } 2714 }
2728 } 2715 }
2729 smallest_abs_val = 0xffffffff; 2716 smallest_abs_val = 0xffffffff;
2730 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("curveindex[%d] = %x\n", i, 2717 RTPRINT(rtlpriv, FINIT, INIT_IQK, "curveindex[%d] = %x\n",
2731 curveindex[i])); 2718 i, curveindex[i]);
2732 } 2719 }
2733} 2720}
2734 2721
@@ -2743,14 +2730,14 @@ static void _rtl92d_phy_reload_lck_setting(struct ieee80211_hw *hw,
2743 u32 u4tmp = 0, u4regvalue = 0; 2730 u32 u4tmp = 0, u4regvalue = 0;
2744 bool bneed_powerdown_radio = false; 2731 bool bneed_powerdown_radio = false;
2745 2732
2746 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("path %d\n", erfpath)); 2733 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "path %d\n", erfpath);
2747 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("band type = %d\n", 2734 RTPRINT(rtlpriv, FINIT, INIT_IQK, "band type = %d\n",
2748 rtlpriv->rtlhal.current_bandtype)); 2735 rtlpriv->rtlhal.current_bandtype);
2749 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("channel = %d\n", channel)); 2736 RTPRINT(rtlpriv, FINIT, INIT_IQK, "channel = %d\n", channel);
2750 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G) {/* Path-A for 5G */ 2737 if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G) {/* Path-A for 5G */
2751 u4tmp = curveindex_5g[channel-1]; 2738 u4tmp = curveindex_5g[channel-1];
2752 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2739 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2753 ("ver 1 set RF-A, 5G, 0x28 = 0x%ulx !!\n", u4tmp)); 2740 "ver 1 set RF-A, 5G, 0x28 = 0x%ulx !!\n", u4tmp);
2754 if (rtlpriv->rtlhal.macphymode == DUALMAC_DUALPHY && 2741 if (rtlpriv->rtlhal.macphymode == DUALMAC_DUALPHY &&
2755 rtlpriv->rtlhal.interfaceindex == 1) { 2742 rtlpriv->rtlhal.interfaceindex == 1) {
2756 bneed_powerdown_radio = 2743 bneed_powerdown_radio =
@@ -2769,7 +2756,7 @@ static void _rtl92d_phy_reload_lck_setting(struct ieee80211_hw *hw,
2769 } else if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G) { 2756 } else if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G) {
2770 u4tmp = curveindex_2g[channel-1]; 2757 u4tmp = curveindex_2g[channel-1];
2771 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2758 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2772 ("ver 3 set RF-B, 2G, 0x28 = 0x%ulx !!\n", u4tmp)); 2759 "ver 3 set RF-B, 2G, 0x28 = 0x%ulx !!\n", u4tmp);
2773 if (rtlpriv->rtlhal.macphymode == DUALMAC_DUALPHY && 2760 if (rtlpriv->rtlhal.macphymode == DUALMAC_DUALPHY &&
2774 rtlpriv->rtlhal.interfaceindex == 0) { 2761 rtlpriv->rtlhal.interfaceindex == 0) {
2775 bneed_powerdown_radio = 2762 bneed_powerdown_radio =
@@ -2781,14 +2768,14 @@ static void _rtl92d_phy_reload_lck_setting(struct ieee80211_hw *hw,
2781 } 2768 }
2782 rtl_set_rfreg(hw, erfpath, RF_SYN_G4, 0x3f800, u4tmp); 2769 rtl_set_rfreg(hw, erfpath, RF_SYN_G4, 0x3f800, u4tmp);
2783 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2770 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2784 ("ver 3 set RF-B, 2G, 0x28 = 0x%ulx !!\n", 2771 "ver 3 set RF-B, 2G, 0x28 = 0x%ulx !!\n",
2785 rtl_get_rfreg(hw, erfpath, RF_SYN_G4, 0x3f800))); 2772 rtl_get_rfreg(hw, erfpath, RF_SYN_G4, 0x3f800));
2786 if (bneed_powerdown_radio) 2773 if (bneed_powerdown_radio)
2787 _rtl92d_phy_restore_rf_env(hw, erfpath, &u4regvalue); 2774 _rtl92d_phy_restore_rf_env(hw, erfpath, &u4regvalue);
2788 if (rtlpriv->rtlhal.during_mac0init_radiob) 2775 if (rtlpriv->rtlhal.during_mac0init_radiob)
2789 rtl92d_phy_powerdown_anotherphy(hw, true); 2776 rtl92d_phy_powerdown_anotherphy(hw, true);
2790 } 2777 }
2791 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("<====\n")); 2778 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "<====\n");
2792} 2779}
2793 2780
2794static void _rtl92d_phy_lc_calibrate_sw(struct ieee80211_hw *hw, bool is2t) 2781static void _rtl92d_phy_lc_calibrate_sw(struct ieee80211_hw *hw, bool is2t)
@@ -2836,20 +2823,20 @@ static void _rtl92d_phy_lc_calibrate_sw(struct ieee80211_hw *hw, bool is2t)
2836 RF_SYN_G6, BRFREGOFFSETMASK); 2823 RF_SYN_G6, BRFREGOFFSETMASK);
2837 } 2824 }
2838 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2825 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2839 ("PHY_LCK finish delay for %d ms=2\n", timecount)); 2826 "PHY_LCK finish delay for %d ms=2\n", timecount);
2840 u4tmp = rtl_get_rfreg(hw, index, RF_SYN_G4, BRFREGOFFSETMASK); 2827 u4tmp = rtl_get_rfreg(hw, index, RF_SYN_G4, BRFREGOFFSETMASK);
2841 if (index == 0 && rtlhal->interfaceindex == 0) { 2828 if (index == 0 && rtlhal->interfaceindex == 0) {
2842 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2829 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2843 ("path-A / 5G LCK\n")); 2830 "path-A / 5G LCK\n");
2844 } else { 2831 } else {
2845 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2832 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2846 ("path-B / 2.4G LCK\n")); 2833 "path-B / 2.4G LCK\n");
2847 } 2834 }
2848 memset(&curvecount_val[0], 0, CV_CURVE_CNT * 2); 2835 memset(&curvecount_val[0], 0, CV_CURVE_CNT * 2);
2849 /* Set LC calibration off */ 2836 /* Set LC calibration off */
2850 rtl_set_rfreg(hw, (enum radio_path)index, RF_CHNLBW, 2837 rtl_set_rfreg(hw, (enum radio_path)index, RF_CHNLBW,
2851 0x08000, 0x0); 2838 0x08000, 0x0);
2852 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("set RF 0x18[15] = 0\n")); 2839 RTPRINT(rtlpriv, FINIT, INIT_IQK, "set RF 0x18[15] = 0\n");
2853 /* save Curve-counting number */ 2840 /* save Curve-counting number */
2854 for (i = 0; i < CV_CURVE_CNT; i++) { 2841 for (i = 0; i < CV_CURVE_CNT; i++) {
2855 u32 readval = 0, readval2 = 0; 2842 u32 readval = 0, readval2 = 0;
@@ -2899,7 +2886,7 @@ static void _rtl92d_phy_lc_calibrate(struct ieee80211_hw *hw, bool is2t)
2899{ 2886{
2900 struct rtl_priv *rtlpriv = rtl_priv(hw); 2887 struct rtl_priv *rtlpriv = rtl_priv(hw);
2901 2888
2902 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("cosa PHY_LCK ver=2\n")); 2889 RTPRINT(rtlpriv, FINIT, INIT_IQK, "cosa PHY_LCK ver=2\n");
2903 _rtl92d_phy_lc_calibrate_sw(hw, is2t); 2890 _rtl92d_phy_lc_calibrate_sw(hw, is2t);
2904} 2891}
2905 2892
@@ -2917,8 +2904,8 @@ void rtl92d_phy_lc_calibrate(struct ieee80211_hw *hw)
2917 2904
2918 rtlphy->lck_inprogress = true; 2905 rtlphy->lck_inprogress = true;
2919 RTPRINT(rtlpriv, FINIT, INIT_IQK, 2906 RTPRINT(rtlpriv, FINIT, INIT_IQK,
2920 ("LCK:Start!!! currentband %x delay %d ms\n", 2907 "LCK:Start!!! currentband %x delay %d ms\n",
2921 rtlhal->current_bandtype, timecount)); 2908 rtlhal->current_bandtype, timecount);
2922 if (IS_92D_SINGLEPHY(rtlhal->version)) { 2909 if (IS_92D_SINGLEPHY(rtlhal->version)) {
2923 _rtl92d_phy_lc_calibrate(hw, true); 2910 _rtl92d_phy_lc_calibrate(hw, true);
2924 } else { 2911 } else {
@@ -2926,7 +2913,7 @@ void rtl92d_phy_lc_calibrate(struct ieee80211_hw *hw)
2926 _rtl92d_phy_lc_calibrate(hw, false); 2913 _rtl92d_phy_lc_calibrate(hw, false);
2927 } 2914 }
2928 rtlphy->lck_inprogress = false; 2915 rtlphy->lck_inprogress = false;
2929 RTPRINT(rtlpriv, FINIT, INIT_IQK, ("LCK:Finish!!!\n")); 2916 RTPRINT(rtlpriv, FINIT, INIT_IQK, "LCK:Finish!!!\n");
2930} 2917}
2931 2918
2932void rtl92d_phy_ap_calibrate(struct ieee80211_hw *hw, char delta) 2919void rtl92d_phy_ap_calibrate(struct ieee80211_hw *hw, char delta)
@@ -2941,7 +2928,7 @@ static bool _rtl92d_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable,
2941 struct swchnlcmd *pcmd; 2928 struct swchnlcmd *pcmd;
2942 2929
2943 if (cmdtable == NULL) { 2930 if (cmdtable == NULL) {
2944 RT_ASSERT(false, ("cmdtable cannot be NULL.\n")); 2931 RT_ASSERT(false, "cmdtable cannot be NULL\n");
2945 return false; 2932 return false;
2946 } 2933 }
2947 if (cmdtableidx >= cmdtablesz) 2934 if (cmdtableidx >= cmdtablesz)
@@ -2962,10 +2949,10 @@ void rtl92d_phy_reset_iqk_result(struct ieee80211_hw *hw)
2962 u8 i; 2949 u8 i;
2963 2950
2964 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 2951 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
2965 ("settings regs %d default regs %d\n", 2952 "settings regs %d default regs %d\n",
2966 (int)(sizeof(rtlphy->iqk_matrix_regsetting) / 2953 (int)(sizeof(rtlphy->iqk_matrix_regsetting) /
2967 sizeof(struct iqk_matrix_regs)), 2954 sizeof(struct iqk_matrix_regs)),
2968 IQK_MATRIX_REG_NUM)); 2955 IQK_MATRIX_REG_NUM);
2969 /* 0xe94, 0xe9c, 0xea4, 0xeac, 0xeb4, 0xebc, 0xec4, 0xecc */ 2956 /* 0xe94, 0xe9c, 0xea4, 0xeac, 0xeb4, 0xebc, 0xec4, 0xecc */
2970 for (i = 0; i < IQK_MATRIX_SETTINGS_NUM; i++) { 2957 for (i = 0; i < IQK_MATRIX_SETTINGS_NUM; i++) {
2971 rtlphy->iqk_matrix_regsetting[i].value[0][0] = 0x100; 2958 rtlphy->iqk_matrix_regsetting[i].value[0][0] = 0x100;
@@ -3084,7 +3071,7 @@ static bool _rtl92d_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
3084 break; 3071 break;
3085 default: 3072 default:
3086 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 3073 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
3087 ("switch case not process\n")); 3074 "switch case not processed\n");
3088 break; 3075 break;
3089 } 3076 }
3090 break; 3077 break;
@@ -3111,7 +3098,7 @@ u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw)
3111 3098
3112 if ((is_hal_stop(rtlhal)) || (RT_CANNOT_IO(hw))) { 3099 if ((is_hal_stop(rtlhal)) || (RT_CANNOT_IO(hw))) {
3113 RT_TRACE(rtlpriv, COMP_CHAN, DBG_LOUD, 3100 RT_TRACE(rtlpriv, COMP_CHAN, DBG_LOUD,
3114 ("sw_chnl_inprogress false driver sleep or unload\n")); 3101 "sw_chnl_inprogress false driver sleep or unload\n");
3115 return 0; 3102 return 0;
3116 } 3103 }
3117 while (rtlphy->lck_inprogress && timecount < timeout) { 3104 while (rtlphy->lck_inprogress && timecount < timeout) {
@@ -3133,19 +3120,18 @@ u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw)
3133 * 5G and 2.4G band. */ 3120 * 5G and 2.4G band. */
3134 if (channel <= 14) 3121 if (channel <= 14)
3135 return 0; 3122 return 0;
3136 RT_ASSERT((channel > 14), ("5G but channel<=14")); 3123 RT_ASSERT((channel > 14), "5G but channel<=14\n");
3137 break; 3124 break;
3138 case BAND_ON_2_4G: 3125 case BAND_ON_2_4G:
3139 /* Get first channel error when change between 3126 /* Get first channel error when change between
3140 * 5G and 2.4G band. */ 3127 * 5G and 2.4G band. */
3141 if (channel > 14) 3128 if (channel > 14)
3142 return 0; 3129 return 0;
3143 RT_ASSERT((channel <= 14), ("2G but channel>14")); 3130 RT_ASSERT((channel <= 14), "2G but channel>14\n");
3144 break; 3131 break;
3145 default: 3132 default:
3146 RT_ASSERT(false, 3133 RT_ASSERT(false, "Invalid WirelessMode(%#x)!!\n",
3147 ("Invalid WirelessMode(%#x)!!\n", 3134 rtlpriv->mac80211.mode);
3148 rtlpriv->mac80211.mode));
3149 break; 3135 break;
3150 } 3136 }
3151 rtlphy->sw_chnl_inprogress = true; 3137 rtlphy->sw_chnl_inprogress = true;
@@ -3154,7 +3140,7 @@ u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw)
3154 rtlphy->sw_chnl_stage = 0; 3140 rtlphy->sw_chnl_stage = 0;
3155 rtlphy->sw_chnl_step = 0; 3141 rtlphy->sw_chnl_step = 0;
3156 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, 3142 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE,
3157 ("switch to channel%d\n", rtlphy->current_channel)); 3143 "switch to channel%d\n", rtlphy->current_channel);
3158 3144
3159 do { 3145 do {
3160 if (!rtlphy->sw_chnl_inprogress) 3146 if (!rtlphy->sw_chnl_inprogress)
@@ -3171,7 +3157,7 @@ u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw)
3171 } 3157 }
3172 break; 3158 break;
3173 } while (true); 3159 } while (true);
3174 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); 3160 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n");
3175 rtlphy->sw_chnl_inprogress = false; 3161 rtlphy->sw_chnl_inprogress = false;
3176 return 1; 3162 return 1;
3177} 3163}
@@ -3182,8 +3168,8 @@ static void rtl92d_phy_set_io(struct ieee80211_hw *hw)
3182 struct rtl_phy *rtlphy = &(rtlpriv->phy); 3168 struct rtl_phy *rtlphy = &(rtlpriv->phy);
3183 3169
3184 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, 3170 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE,
3185 ("--->Cmd(%#x), set_io_inprogress(%d)\n", 3171 "--->Cmd(%#x), set_io_inprogress(%d)\n",
3186 rtlphy->current_io_type, rtlphy->set_io_inprogress)); 3172 rtlphy->current_io_type, rtlphy->set_io_inprogress);
3187 switch (rtlphy->current_io_type) { 3173 switch (rtlphy->current_io_type) {
3188 case IO_CMD_RESUME_DM_BY_SCAN: 3174 case IO_CMD_RESUME_DM_BY_SCAN:
3189 de_digtable.cur_igvalue = rtlphy->initgain_backup.xaagccore1; 3175 de_digtable.cur_igvalue = rtlphy->initgain_backup.xaagccore1;
@@ -3197,12 +3183,12 @@ static void rtl92d_phy_set_io(struct ieee80211_hw *hw)
3197 break; 3183 break;
3198 default: 3184 default:
3199 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 3185 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
3200 ("switch case not process\n")); 3186 "switch case not processed\n");
3201 break; 3187 break;
3202 } 3188 }
3203 rtlphy->set_io_inprogress = false; 3189 rtlphy->set_io_inprogress = false;
3204 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, 3190 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, "<---(%#x)\n",
3205 ("<---(%#x)\n", rtlphy->current_io_type)); 3191 rtlphy->current_io_type);
3206} 3192}
3207 3193
3208bool rtl92d_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype) 3194bool rtl92d_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype)
@@ -3212,23 +3198,23 @@ bool rtl92d_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype)
3212 bool postprocessing = false; 3198 bool postprocessing = false;
3213 3199
3214 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, 3200 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE,
3215 ("-->IO Cmd(%#x), set_io_inprogress(%d)\n", 3201 "-->IO Cmd(%#x), set_io_inprogress(%d)\n",
3216 iotype, rtlphy->set_io_inprogress)); 3202 iotype, rtlphy->set_io_inprogress);
3217 do { 3203 do {
3218 switch (iotype) { 3204 switch (iotype) {
3219 case IO_CMD_RESUME_DM_BY_SCAN: 3205 case IO_CMD_RESUME_DM_BY_SCAN:
3220 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, 3206 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE,
3221 ("[IO CMD] Resume DM after scan.\n")); 3207 "[IO CMD] Resume DM after scan\n");
3222 postprocessing = true; 3208 postprocessing = true;
3223 break; 3209 break;
3224 case IO_CMD_PAUSE_DM_BY_SCAN: 3210 case IO_CMD_PAUSE_DM_BY_SCAN:
3225 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, 3211 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE,
3226 ("[IO CMD] Pause DM before scan.\n")); 3212 "[IO CMD] Pause DM before scan\n");
3227 postprocessing = true; 3213 postprocessing = true;
3228 break; 3214 break;
3229 default: 3215 default:
3230 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 3216 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
3231 ("switch case not process\n")); 3217 "switch case not processed\n");
3232 break; 3218 break;
3233 } 3219 }
3234 } while (false); 3220 } while (false);
@@ -3239,7 +3225,7 @@ bool rtl92d_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype)
3239 return false; 3225 return false;
3240 } 3226 }
3241 rtl92d_phy_set_io(hw); 3227 rtl92d_phy_set_io(hw);
3242 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, ("<--IO Type(%#x)\n", iotype)); 3228 RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, "<--IO Type(%#x)\n", iotype);
3243 return true; 3229 return true;
3244} 3230}
3245 3231
@@ -3297,7 +3283,7 @@ static void _rtl92d_phy_set_rfsleep(struct ieee80211_hw *hw)
3297 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); 3283 rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3);
3298 rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00); 3284 rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00);
3299 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 3285 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
3300 ("Fail !!! Switch RF timeout.\n")); 3286 "Fail !!! Switch RF timeout\n");
3301 return; 3287 return;
3302 } 3288 }
3303 /* e. For PCIE: SYS_FUNC_EN 0x02[7:0] = 0xE2 reset BB TRX function */ 3289 /* e. For PCIE: SYS_FUNC_EN 0x02[7:0] = 0xE2 reset BB TRX function */
@@ -3332,7 +3318,7 @@ bool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw,
3332 do { 3318 do {
3333 InitializeCount++; 3319 InitializeCount++;
3334 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 3320 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
3335 ("IPS Set eRf nic enable\n")); 3321 "IPS Set eRf nic enable\n");
3336 rtstatus = rtl_ps_enable_nic(hw); 3322 rtstatus = rtl_ps_enable_nic(hw);
3337 } while ((rtstatus != true) && 3323 } while ((rtstatus != true) &&
3338 (InitializeCount < 10)); 3324 (InitializeCount < 10));
@@ -3341,11 +3327,10 @@ bool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw,
3341 RT_RF_OFF_LEVL_HALT_NIC); 3327 RT_RF_OFF_LEVL_HALT_NIC);
3342 } else { 3328 } else {
3343 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, 3329 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
3344 ("awake, sleeped:%d ms state_" 3330 "awake, sleeped:%d ms state_inap:%x\n",
3345 "inap:%x\n",
3346 jiffies_to_msecs(jiffies - 3331 jiffies_to_msecs(jiffies -
3347 ppsc->last_sleep_jiffies), 3332 ppsc->last_sleep_jiffies),
3348 rtlpriv->psc.state_inap)); 3333 rtlpriv->psc.state_inap);
3349 ppsc->last_awake_jiffies = jiffies; 3334 ppsc->last_awake_jiffies = jiffies;
3350 _rtl92d_phy_set_rfon(hw); 3335 _rtl92d_phy_set_rfon(hw);
3351 } 3336 }
@@ -3360,7 +3345,7 @@ bool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw,
3360 case ERFOFF: 3345 case ERFOFF:
3361 if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) { 3346 if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) {
3362 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 3347 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
3363 ("IPS Set eRf nic disable\n")); 3348 "IPS Set eRf nic disable\n");
3364 rtl_ps_disable_nic(hw); 3349 rtl_ps_disable_nic(hw);
3365 RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); 3350 RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
3366 } else { 3351 } else {
@@ -3385,41 +3370,40 @@ bool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw,
3385 continue; 3370 continue;
3386 } else if (rtlpci->pdev->current_state != PCI_D0) { 3371 } else if (rtlpci->pdev->current_state != PCI_D0) {
3387 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 3372 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
3388 ("eRf Off/Sleep: %d times TcbBusyQueu" 3373 "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 but lower power state!\n",
3389 "e[%d] !=0 but lower power state!\n", 3374 i + 1, queue_id);
3390 (i + 1), queue_id));
3391 break; 3375 break;
3392 } else { 3376 } else {
3393 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 3377 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
3394 ("eRf Off/Sleep: %d times TcbBusyQueu" 3378 "eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n",
3395 "e[%d] =%d " 3379 i + 1, queue_id,
3396 "before doze!\n", (i + 1), queue_id, 3380 skb_queue_len(&ring->queue));
3397 skb_queue_len(&ring->queue)));
3398 udelay(10); 3381 udelay(10);
3399 i++; 3382 i++;
3400 } 3383 }
3401 3384
3402 if (i >= MAX_DOZE_WAITING_TIMES_9x) { 3385 if (i >= MAX_DOZE_WAITING_TIMES_9x) {
3403 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 3386 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
3404 ("\nERFOFF: %d times TcbBusyQueue[%d] " 3387 "ERFOFF: %d times TcbBusyQueue[%d] = %d !\n",
3405 "= %d !\n", 3388 MAX_DOZE_WAITING_TIMES_9x, queue_id,
3406 MAX_DOZE_WAITING_TIMES_9x, queue_id, 3389 skb_queue_len(&ring->queue));
3407 skb_queue_len(&ring->queue)));
3408 break; 3390 break;
3409 } 3391 }
3410 } 3392 }
3411 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, 3393 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
3412 ("Set rfsleep awaked:%d ms\n", 3394 "Set rfsleep awaked:%d ms\n",
3413 jiffies_to_msecs(jiffies - ppsc->last_awake_jiffies))); 3395 jiffies_to_msecs(jiffies - ppsc->last_awake_jiffies));
3414 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, ("sleep awaked:%d ms " 3396 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
3415 "state_inap:%x\n", jiffies_to_msecs(jiffies - 3397 "sleep awaked:%d ms state_inap:%x\n",
3416 ppsc->last_awake_jiffies), rtlpriv->psc.state_inap)); 3398 jiffies_to_msecs(jiffies -
3399 ppsc->last_awake_jiffies),
3400 rtlpriv->psc.state_inap);
3417 ppsc->last_sleep_jiffies = jiffies; 3401 ppsc->last_sleep_jiffies = jiffies;
3418 _rtl92d_phy_set_rfsleep(hw); 3402 _rtl92d_phy_set_rfsleep(hw);
3419 break; 3403 break;
3420 default: 3404 default:
3421 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 3405 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
3422 ("switch case not process\n")); 3406 "switch case not processed\n");
3423 bresult = false; 3407 bresult = false;
3424 break; 3408 break;
3425 } 3409 }
@@ -3437,17 +3421,17 @@ void rtl92d_phy_config_macphymode(struct ieee80211_hw *hw)
3437 switch (rtlhal->macphymode) { 3421 switch (rtlhal->macphymode) {
3438 case DUALMAC_DUALPHY: 3422 case DUALMAC_DUALPHY:
3439 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 3423 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
3440 ("MacPhyMode: DUALMAC_DUALPHY\n")); 3424 "MacPhyMode: DUALMAC_DUALPHY\n");
3441 rtl_write_byte(rtlpriv, offset, 0xF3); 3425 rtl_write_byte(rtlpriv, offset, 0xF3);
3442 break; 3426 break;
3443 case SINGLEMAC_SINGLEPHY: 3427 case SINGLEMAC_SINGLEPHY:
3444 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 3428 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
3445 ("MacPhyMode: SINGLEMAC_SINGLEPHY\n")); 3429 "MacPhyMode: SINGLEMAC_SINGLEPHY\n");
3446 rtl_write_byte(rtlpriv, offset, 0xF4); 3430 rtl_write_byte(rtlpriv, offset, 0xF4);
3447 break; 3431 break;
3448 case DUALMAC_SINGLEPHY: 3432 case DUALMAC_SINGLEPHY:
3449 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 3433 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
3450 ("MacPhyMode: DUALMAC_SINGLEPHY\n")); 3434 "MacPhyMode: DUALMAC_SINGLEPHY\n");
3451 rtl_write_byte(rtlpriv, offset, 0xF1); 3435 rtl_write_byte(rtlpriv, offset, 0xF1);
3452 break; 3436 break;
3453 } 3437 }
@@ -3578,7 +3562,7 @@ void rtl92d_phy_set_poweron(struct ieee80211_hw *hw)
3578 } 3562 }
3579 } 3563 }
3580 if (i == 200) 3564 if (i == 200)
3581 RT_ASSERT(false, ("Another mac power off over time\n")); 3565 RT_ASSERT(false, "Another mac power off over time\n");
3582 } 3566 }
3583} 3567}
3584 3568
@@ -3615,7 +3599,7 @@ void rtl92d_update_bbrf_configuration(struct ieee80211_hw *hw)
3615 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); 3599 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
3616 u8 rfpath, i; 3600 u8 rfpath, i;
3617 3601
3618 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("==>\n")); 3602 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "==>\n");
3619 /* r_select_5G for path_A/B 0 for 2.4G, 1 for 5G */ 3603 /* r_select_5G for path_A/B 0 for 2.4G, 1 for 5G */
3620 if (rtlhal->current_bandtype == BAND_ON_2_4G) { 3604 if (rtlhal->current_bandtype == BAND_ON_2_4G) {
3621 /* r_select_5G for path_A/B,0x878 */ 3605 /* r_select_5G for path_A/B,0x878 */
@@ -3764,7 +3748,7 @@ void rtl92d_update_bbrf_configuration(struct ieee80211_hw *hw)
3764 } else { 3748 } else {
3765 rtl92d_phy_enable_anotherphy(hw, false); 3749 rtl92d_phy_enable_anotherphy(hw, false);
3766 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 3750 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
3767 ("MAC1 use DBI to update 0x888")); 3751 "MAC1 use DBI to update 0x888\n");
3768 /* 0x888 */ 3752 /* 0x888 */
3769 rtl92de_write_dword_dbi(hw, RFPGA0_ADDALLOCKEN, 3753 rtl92de_write_dword_dbi(hw, RFPGA0_ADDALLOCKEN,
3770 rtl92de_read_dword_dbi(hw, 3754 rtl92de_read_dword_dbi(hw,
@@ -3789,9 +3773,9 @@ void rtl92d_update_bbrf_configuration(struct ieee80211_hw *hw)
3789 BRFREGOFFSETMASK); 3773 BRFREGOFFSETMASK);
3790 } 3774 }
3791 for (i = 0; i < 2; i++) 3775 for (i = 0; i < 2; i++)
3792 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("RF 0x18 = 0x%x\n", 3776 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "RF 0x18 = 0x%x\n",
3793 rtlphy->rfreg_chnlval[i])); 3777 rtlphy->rfreg_chnlval[i]);
3794 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("<==\n")); 3778 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "<==\n");
3795 3779
3796} 3780}
3797 3781
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.h b/drivers/net/wireless/rtlwifi/rtl8192de/phy.h
index a52c824b41e3..f074952bf25c 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/reg.h b/drivers/net/wireless/rtlwifi/rtl8192de/reg.h
index 131acc306fcc..9bc462331078 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/reg.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/reg.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/rf.c b/drivers/net/wireless/rtlwifi/rtl8192de/rf.c
index db27cebaac2c..ff34d2dd39b8 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/rf.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/rf.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -50,8 +50,8 @@ void rtl92d_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, u8 bandwidth)
50 BIT(11), 0x01); 50 BIT(11), 0x01);
51 51
52 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, 52 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD,
53 ("20M RF 0x18 = 0x%x\n", 53 "20M RF 0x18 = 0x%x\n",
54 rtlphy->rfreg_chnlval[rfpath])); 54 rtlphy->rfreg_chnlval[rfpath]);
55 } 55 }
56 56
57 break; 57 break;
@@ -62,13 +62,13 @@ void rtl92d_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, u8 bandwidth)
62 rtl_set_rfreg(hw, rfpath, RF_CHNLBW, BIT(10) | BIT(11), 62 rtl_set_rfreg(hw, rfpath, RF_CHNLBW, BIT(10) | BIT(11),
63 0x00); 63 0x00);
64 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, 64 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD,
65 ("40M RF 0x18 = 0x%x\n", 65 "40M RF 0x18 = 0x%x\n",
66 rtlphy->rfreg_chnlval[rfpath])); 66 rtlphy->rfreg_chnlval[rfpath]);
67 } 67 }
68 break; 68 break;
69 default: 69 default:
70 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 70 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
71 ("unknown bandwidth: %#X\n", bandwidth)); 71 "unknown bandwidth: %#X\n", bandwidth);
72 break; 72 break;
73 } 73 }
74} 74}
@@ -127,23 +127,23 @@ void rtl92d_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw,
127 tmpval = tx_agc[RF90_PATH_A] & 0xff; 127 tmpval = tx_agc[RF90_PATH_A] & 0xff;
128 rtl_set_bbreg(hw, RTXAGC_A_CCK1_MCS32, BMASKBYTE1, tmpval); 128 rtl_set_bbreg(hw, RTXAGC_A_CCK1_MCS32, BMASKBYTE1, tmpval);
129 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 129 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
130 ("CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, 130 "CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n",
131 RTXAGC_A_CCK1_MCS32)); 131 tmpval, RTXAGC_A_CCK1_MCS32);
132 tmpval = tx_agc[RF90_PATH_A] >> 8; 132 tmpval = tx_agc[RF90_PATH_A] >> 8;
133 rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); 133 rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval);
134 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 134 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
135 ("CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, 135 "CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n",
136 RTXAGC_B_CCK11_A_CCK2_11)); 136 tmpval, RTXAGC_B_CCK11_A_CCK2_11);
137 tmpval = tx_agc[RF90_PATH_B] >> 24; 137 tmpval = tx_agc[RF90_PATH_B] >> 24;
138 rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, BMASKBYTE0, tmpval); 138 rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, BMASKBYTE0, tmpval);
139 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 139 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
140 ("CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, 140 "CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n",
141 RTXAGC_B_CCK11_A_CCK2_11)); 141 tmpval, RTXAGC_B_CCK11_A_CCK2_11);
142 tmpval = tx_agc[RF90_PATH_B] & 0x00ffffff; 142 tmpval = tx_agc[RF90_PATH_B] & 0x00ffffff;
143 rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, 0xffffff00, tmpval); 143 rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, 0xffffff00, tmpval);
144 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 144 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
145 ("CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, 145 "CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n",
146 RTXAGC_B_CCK1_55_MCS32)); 146 tmpval, RTXAGC_B_CCK1_55_MCS32);
147} 147}
148 148
149static void _rtl92d_phy_get_power_base(struct ieee80211_hw *hw, 149static void _rtl92d_phy_get_power_base(struct ieee80211_hw *hw,
@@ -165,8 +165,8 @@ static void _rtl92d_phy_get_power_base(struct ieee80211_hw *hw,
165 (powerbase0 << 8) | powerbase0; 165 (powerbase0 << 8) | powerbase0;
166 *(ofdmbase + i) = powerbase0; 166 *(ofdmbase + i) = powerbase0;
167 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 167 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
168 (" [OFDM power base index rf(%c) = 0x%x]\n", 168 " [OFDM power base index rf(%c) = 0x%x]\n",
169 ((i == 0) ? 'A' : 'B'), *(ofdmbase + i))); 169 i == 0 ? 'A' : 'B', *(ofdmbase + i));
170 } 170 }
171 171
172 for (i = 0; i < 2; i++) { 172 for (i = 0; i < 2; i++) {
@@ -179,8 +179,8 @@ static void _rtl92d_phy_get_power_base(struct ieee80211_hw *hw,
179 (powerbase1 << 8) | powerbase1; 179 (powerbase1 << 8) | powerbase1;
180 *(mcsbase + i) = powerbase1; 180 *(mcsbase + i) = powerbase1;
181 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 181 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
182 (" [MCS power base index rf(%c) = 0x%x]\n", 182 " [MCS power base index rf(%c) = 0x%x]\n",
183 ((i == 0) ? 'A' : 'B'), *(mcsbase + i))); 183 i == 0 ? 'A' : 'B', *(mcsbase + i));
184 } 184 }
185} 185}
186 186
@@ -232,9 +232,9 @@ static void _rtl92d_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
232 (rf ? 8 : 0)] + ((index < 2) ? 232 (rf ? 8 : 0)] + ((index < 2) ?
233 powerbase0[rf] : 233 powerbase0[rf] :
234 powerbase1[rf]); 234 powerbase1[rf]);
235 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, ("RTK better " 235 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
236 "performance, writeval(%c) = 0x%x\n", 236 "RTK better performance, writeval(%c) = 0x%x\n",
237 ((rf == 0) ? 'A' : 'B'), writeval)); 237 rf == 0 ? 'A' : 'B', writeval);
238 break; 238 break;
239 case 1: 239 case 1:
240 if (rtlphy->pwrgroup_cnt == 1) 240 if (rtlphy->pwrgroup_cnt == 1)
@@ -253,33 +253,31 @@ static void _rtl92d_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
253 powerbase0[rf] : 253 powerbase0[rf] :
254 powerbase1[rf]); 254 powerbase1[rf]);
255 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 255 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
256 ("Realtek regulatory, " 256 "Realtek regulatory, 20MHz, writeval(%c) = 0x%x\n",
257 "20MHz, writeval(%c) = 0x%x\n", 257 rf == 0 ? 'A' : 'B', writeval);
258 ((rf == 0) ? 'A' : 'B'),
259 writeval));
260 } 258 }
261 break; 259 break;
262 case 2: 260 case 2:
263 writeval = ((index < 2) ? powerbase0[rf] : 261 writeval = ((index < 2) ? powerbase0[rf] :
264 powerbase1[rf]); 262 powerbase1[rf]);
265 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, ("Better regulatory, " 263 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
266 "writeval(%c) = 0x%x\n", 264 "Better regulatory, writeval(%c) = 0x%x\n",
267 ((rf == 0) ? 'A' : 'B'), writeval)); 265 rf == 0 ? 'A' : 'B', writeval);
268 break; 266 break;
269 case 3: 267 case 3:
270 chnlgroup = 0; 268 chnlgroup = 0;
271 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { 269 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) {
272 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 270 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
273 ("customer's limit, 40MHz rf(%c) = " 271 "customer's limit, 40MHz rf(%c) = 0x%x\n",
274 "0x%x\n", ((rf == 0) ? 'A' : 'B'), 272 rf == 0 ? 'A' : 'B',
275 rtlefuse->pwrgroup_ht40[rf] 273 rtlefuse->pwrgroup_ht40[rf]
276 [channel - 1])); 274 [channel - 1]);
277 } else { 275 } else {
278 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 276 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
279 ("customer's limit, 20MHz rf(%c) = " 277 "customer's limit, 20MHz rf(%c) = 0x%x\n",
280 "0x%x\n", ((rf == 0) ? 'A' : 'B'), 278 rf == 0 ? 'A' : 'B',
281 rtlefuse->pwrgroup_ht20[rf] 279 rtlefuse->pwrgroup_ht20[rf]
282 [channel - 1])); 280 [channel - 1]);
283 } 281 }
284 for (i = 0; i < 4; i++) { 282 for (i = 0; i < 4; i++) {
285 pwr_diff_limit[i] = 283 pwr_diff_limit[i] =
@@ -308,13 +306,13 @@ static void _rtl92d_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
308 (pwr_diff_limit[1] << 8) | 306 (pwr_diff_limit[1] << 8) |
309 (pwr_diff_limit[0]); 307 (pwr_diff_limit[0]);
310 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 308 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
311 ("Customer's limit rf(%c) = 0x%x\n", 309 "Customer's limit rf(%c) = 0x%x\n",
312 ((rf == 0) ? 'A' : 'B'), customer_limit)); 310 rf == 0 ? 'A' : 'B', customer_limit);
313 writeval = customer_limit + ((index < 2) ? 311 writeval = customer_limit + ((index < 2) ?
314 powerbase0[rf] : powerbase1[rf]); 312 powerbase0[rf] : powerbase1[rf]);
315 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 313 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
316 ("Customer, writeval rf(%c)= 0x%x\n", 314 "Customer, writeval rf(%c)= 0x%x\n",
317 ((rf == 0) ? 'A' : 'B'), writeval)); 315 rf == 0 ? 'A' : 'B', writeval);
318 break; 316 break;
319 default: 317 default:
320 chnlgroup = 0; 318 chnlgroup = 0;
@@ -323,9 +321,8 @@ static void _rtl92d_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw,
323 (rf ? 8 : 0)] + ((index < 2) ? 321 (rf ? 8 : 0)] + ((index < 2) ?
324 powerbase0[rf] : powerbase1[rf]); 322 powerbase0[rf] : powerbase1[rf]);
325 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 323 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
326 ("RTK better performance, writeval " 324 "RTK better performance, writeval rf(%c) = 0x%x\n",
327 "rf(%c) = 0x%x\n", 325 rf == 0 ? 'A' : 'B', writeval);
328 ((rf == 0) ? 'A' : 'B'), writeval));
329 break; 326 break;
330 } 327 }
331 *(p_outwriteval + rf) = writeval; 328 *(p_outwriteval + rf) = writeval;
@@ -367,7 +364,7 @@ static void _rtl92d_write_ofdm_power_reg(struct ieee80211_hw *hw,
367 regoffset = regoffset_b[index]; 364 regoffset = regoffset_b[index];
368 rtl_set_bbreg(hw, regoffset, BMASKDWORD, writeval); 365 rtl_set_bbreg(hw, regoffset, BMASKDWORD, writeval);
369 RTPRINT(rtlpriv, FPHY, PHY_TXPWR, 366 RTPRINT(rtlpriv, FPHY, PHY_TXPWR,
370 ("Set 0x%x = %08x\n", regoffset, writeval)); 367 "Set 0x%x = %08x\n", regoffset, writeval);
371 if (((get_rf_type(rtlphy) == RF_2T2R) && 368 if (((get_rf_type(rtlphy) == RF_2T2R) &&
372 (regoffset == RTXAGC_A_MCS15_MCS12 || 369 (regoffset == RTXAGC_A_MCS15_MCS12 ||
373 regoffset == RTXAGC_B_MCS15_MCS12)) || 370 regoffset == RTXAGC_B_MCS15_MCS12)) ||
@@ -423,11 +420,11 @@ bool rtl92d_phy_enable_anotherphy(struct ieee80211_hw *hw, bool bmac0)
423 420
424 rtlhal->during_mac0init_radiob = false; 421 rtlhal->during_mac0init_radiob = false;
425 rtlhal->during_mac1init_radioa = false; 422 rtlhal->during_mac1init_radioa = false;
426 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("===>\n")); 423 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "===>\n");
427 /* MAC0 Need PHY1 load radio_b.txt . Driver use DBI to write. */ 424 /* MAC0 Need PHY1 load radio_b.txt . Driver use DBI to write. */
428 u1btmp = rtl_read_byte(rtlpriv, mac_reg); 425 u1btmp = rtl_read_byte(rtlpriv, mac_reg);
429 if (!(u1btmp & mac_on_bit)) { 426 if (!(u1btmp & mac_on_bit)) {
430 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("enable BB & RF\n")); 427 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "enable BB & RF\n");
431 /* Enable BB and RF power */ 428 /* Enable BB and RF power */
432 rtl92de_write_dword_dbi(hw, REG_SYS_ISO_CTRL, 429 rtl92de_write_dword_dbi(hw, REG_SYS_ISO_CTRL,
433 rtl92de_read_dword_dbi(hw, REG_SYS_ISO_CTRL, direct) | 430 rtl92de_read_dword_dbi(hw, REG_SYS_ISO_CTRL, direct) |
@@ -437,7 +434,7 @@ bool rtl92d_phy_enable_anotherphy(struct ieee80211_hw *hw, bool bmac0)
437 * and radio_b.txt has been load. */ 434 * and radio_b.txt has been load. */
438 bresult = false; 435 bresult = false;
439 } 436 }
440 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("<===\n")); 437 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "<===\n");
441 return bresult; 438 return bresult;
442 439
443} 440}
@@ -453,17 +450,17 @@ void rtl92d_phy_powerdown_anotherphy(struct ieee80211_hw *hw, bool bmac0)
453 450
454 rtlhal->during_mac0init_radiob = false; 451 rtlhal->during_mac0init_radiob = false;
455 rtlhal->during_mac1init_radioa = false; 452 rtlhal->during_mac1init_radioa = false;
456 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("====>\n")); 453 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "====>\n");
457 /* check MAC0 enable or not again now, if 454 /* check MAC0 enable or not again now, if
458 * enabled, not power down radio A. */ 455 * enabled, not power down radio A. */
459 u1btmp = rtl_read_byte(rtlpriv, mac_reg); 456 u1btmp = rtl_read_byte(rtlpriv, mac_reg);
460 if (!(u1btmp & mac_on_bit)) { 457 if (!(u1btmp & mac_on_bit)) {
461 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("power down\n")); 458 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "power down\n");
462 /* power down RF radio A according to YuNan's advice. */ 459 /* power down RF radio A according to YuNan's advice. */
463 rtl92de_write_dword_dbi(hw, RFPGA0_XA_LSSIPARAMETER, 460 rtl92de_write_dword_dbi(hw, RFPGA0_XA_LSSIPARAMETER,
464 0x00000000, direct); 461 0x00000000, direct);
465 } 462 }
466 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("<====\n")); 463 RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "<====\n");
467} 464}
468 465
469bool rtl92d_phy_rf6052_config(struct ieee80211_hw *hw) 466bool rtl92d_phy_rf6052_config(struct ieee80211_hw *hw)
@@ -606,7 +603,7 @@ bool rtl92d_phy_rf6052_config(struct ieee80211_hw *hw)
606 } 603 }
607 if (rtstatus != true) { 604 if (rtstatus != true) {
608 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 605 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
609 ("Radio[%d] Fail!!", rfpath)); 606 "Radio[%d] Fail!!", rfpath);
610 goto phy_rf_cfg_fail; 607 goto phy_rf_cfg_fail;
611 } 608 }
612 609
@@ -620,7 +617,7 @@ bool rtl92d_phy_rf6052_config(struct ieee80211_hw *hw)
620 rtl92d_phy_powerdown_anotherphy(hw, false); 617 rtl92d_phy_powerdown_anotherphy(hw, false);
621 else if (need_pwrdown_radiob) 618 else if (need_pwrdown_radiob)
622 rtl92d_phy_powerdown_anotherphy(hw, true); 619 rtl92d_phy_powerdown_anotherphy(hw, true);
623 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("<---\n")); 620 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "<---\n");
624 return rtstatus; 621 return rtstatus;
625 622
626phy_rf_cfg_fail: 623phy_rf_cfg_fail:
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/rf.h b/drivers/net/wireless/rtlwifi/rtl8192de/rf.h
index 74b9cfc39a83..0fe1a48593e8 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/rf.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/rf.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
index 7911c9c87085..4898c502974d 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -27,11 +27,6 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
32#include <linux/vmalloc.h>
33#include <linux/module.h>
34
35#include "../wifi.h" 30#include "../wifi.h"
36#include "../core.h" 31#include "../core.h"
37#include "../pci.h" 32#include "../pci.h"
@@ -44,6 +39,8 @@
44#include "trx.h" 39#include "trx.h"
45#include "led.h" 40#include "led.h"
46 41
42#include <linux/module.h>
43
47static void rtl92d_init_aspm_vars(struct ieee80211_hw *hw) 44static void rtl92d_init_aspm_vars(struct ieee80211_hw *hw)
48{ 45{
49 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 46 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
@@ -94,7 +91,6 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
94 u8 tid; 91 u8 tid;
95 struct rtl_priv *rtlpriv = rtl_priv(hw); 92 struct rtl_priv *rtlpriv = rtl_priv(hw);
96 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 93 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
97 const struct firmware *firmware;
98 static int header_print; 94 static int header_print;
99 95
100 rtlpriv->dm.dm_initialgain_enable = true; 96 rtlpriv->dm.dm_initialgain_enable = true;
@@ -154,9 +150,9 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
154 rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps; 150 rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps;
155 rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps; 151 rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps;
156 if (!rtlpriv->psc.inactiveps) 152 if (!rtlpriv->psc.inactiveps)
157 pr_info("rtl8192ce: Power Save off (module option)\n"); 153 pr_info("Power Save off (module option)\n");
158 if (!rtlpriv->psc.fwctrl_lps) 154 if (!rtlpriv->psc.fwctrl_lps)
159 pr_info("rtl8192ce: FW Power Save off (module option)\n"); 155 pr_info("FW Power Save off (module option)\n");
160 rtlpriv->psc.reg_fwctrl_lps = 3; 156 rtlpriv->psc.reg_fwctrl_lps = 3;
161 rtlpriv->psc.reg_max_lps_awakeintvl = 5; 157 rtlpriv->psc.reg_max_lps_awakeintvl = 5;
162 /* for ASPM, you can close aspm through 158 /* for ASPM, you can close aspm through
@@ -170,41 +166,38 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
170 else if (rtlpriv->psc.reg_fwctrl_lps == 3) 166 else if (rtlpriv->psc.reg_fwctrl_lps == 3)
171 rtlpriv->psc.fwctrl_psmode = FW_PS_DTIM_MODE; 167 rtlpriv->psc.fwctrl_psmode = FW_PS_DTIM_MODE;
172 168
169 /* for early mode */
170 rtlpriv->rtlhal.earlymode_enable = true;
171 for (tid = 0; tid < 8; tid++)
172 skb_queue_head_init(&rtlpriv->mac80211.skb_waitq[tid]);
173
174 /* Only load firmware for first MAC */
175 if (header_print)
176 return 0;
177
173 /* for firmware buf */ 178 /* for firmware buf */
174 rtlpriv->rtlhal.pfirmware = vzalloc(0x8000); 179 rtlpriv->rtlhal.pfirmware = vzalloc(0x8000);
175 if (!rtlpriv->rtlhal.pfirmware) { 180 if (!rtlpriv->rtlhal.pfirmware) {
176 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 181 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
177 ("Can't alloc buffer for fw.\n")); 182 "Can't alloc buffer for fw\n");
178 return 1; 183 return 1;
179 } 184 }
180 185
181 if (!header_print) { 186 rtlpriv->max_fw_size = 0x8000;
182 pr_info("Driver for Realtek RTL8192DE WLAN interface\n"); 187 pr_info("Driver for Realtek RTL8192DE WLAN interface\n");
183 pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name); 188 pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name);
184 header_print++; 189 header_print++;
185 } 190
186 /* request fw */ 191 /* request fw */
187 err = request_firmware(&firmware, rtlpriv->cfg->fw_name, 192 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name,
188 rtlpriv->io.dev); 193 rtlpriv->io.dev, GFP_KERNEL, hw,
194 rtl_fw_cb);
189 if (err) { 195 if (err) {
190 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 196 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
191 ("Failed to request firmware!\n")); 197 "Failed to request firmware!\n");
192 return 1;
193 }
194 if (firmware->size > 0x8000) {
195 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
196 ("Firmware is too big!\n"));
197 release_firmware(firmware);
198 return 1; 198 return 1;
199 } 199 }
200 memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size);
201 rtlpriv->rtlhal.fwsize = firmware->size;
202 release_firmware(firmware);
203 200
204 /* for early mode */
205 rtlpriv->rtlhal.earlymode_enable = true;
206 for (tid = 0; tid < 8; tid++)
207 skb_queue_head_init(&rtlpriv->mac80211.skb_waitq[tid]);
208 return 0; 201 return 0;
209} 202}
210 203
@@ -424,7 +417,7 @@ static int __init rtl92de_module_init(void)
424 417
425 ret = pci_register_driver(&rtl92de_driver); 418 ret = pci_register_driver(&rtl92de_driver);
426 if (ret) 419 if (ret)
427 RT_ASSERT(false, (": No device found\n")); 420 RT_ASSERT(false, "No device found\n");
428 return ret; 421 return ret;
429} 422}
430 423
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.h b/drivers/net/wireless/rtlwifi/rtl8192de/sw.h
index c95e47de1346..0e6035b8fd86 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/table.c b/drivers/net/wireless/rtlwifi/rtl8192de/table.c
index bad7f9449ecf..8ea6f528dfa6 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/table.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/table.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/table.h b/drivers/net/wireless/rtlwifi/rtl8192de/table.h
index 93f30ca62d8f..8b724a86117a 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/table.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/table.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
index 3637c0c33525..a7f6126e2f86 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -602,8 +602,8 @@ void rtl92de_tx_fill_desc(struct ieee80211_hw *hw,
602 EM_HDR_LEN); 602 EM_HDR_LEN);
603 if (ptcb_desc->empkt_num) { 603 if (ptcb_desc->empkt_num) {
604 RT_TRACE(rtlpriv, COMP_SEND, DBG_LOUD, 604 RT_TRACE(rtlpriv, COMP_SEND, DBG_LOUD,
605 ("Insert 8 byte.pTcb->EMPktNum:%d\n", 605 "Insert 8 byte.pTcb->EMPktNum:%d\n",
606 ptcb_desc->empkt_num)); 606 ptcb_desc->empkt_num);
607 _rtl92de_insert_emcontent(ptcb_desc, 607 _rtl92de_insert_emcontent(ptcb_desc,
608 (u8 *)(skb->data)); 608 (u8 *)(skb->data));
609 } 609 }
@@ -700,7 +700,7 @@ void rtl92de_tx_fill_desc(struct ieee80211_hw *hw,
700 if (ieee80211_is_data_qos(fc)) { 700 if (ieee80211_is_data_qos(fc)) {
701 if (mac->rdg_en) { 701 if (mac->rdg_en) {
702 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, 702 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
703 ("Enable RDG function.\n")); 703 "Enable RDG function\n");
704 SET_TX_DESC_RDG_ENABLE(pdesc, 1); 704 SET_TX_DESC_RDG_ENABLE(pdesc, 1);
705 SET_TX_DESC_HTC(pdesc, 1); 705 SET_TX_DESC_HTC(pdesc, 1);
706 } 706 }
@@ -726,7 +726,7 @@ void rtl92de_tx_fill_desc(struct ieee80211_hw *hw,
726 SET_TX_DESC_PKT_ID(pdesc, 8); 726 SET_TX_DESC_PKT_ID(pdesc, 8);
727 } 727 }
728 SET_TX_DESC_MORE_FRAG(pdesc, (lastseg ? 0 : 1)); 728 SET_TX_DESC_MORE_FRAG(pdesc, (lastseg ? 0 : 1));
729 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, ("\n")); 729 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "\n");
730} 730}
731 731
732void rtl92de_tx_fill_cmddesc(struct ieee80211_hw *hw, 732void rtl92de_tx_fill_cmddesc(struct ieee80211_hw *hw,
@@ -776,7 +776,7 @@ void rtl92de_tx_fill_cmddesc(struct ieee80211_hw *hw,
776 } 776 }
777 777
778 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, 778 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD,
779 "H2C Tx Cmd Content\n", pdesc, TX_DESC_SIZE); 779 "H2C Tx Cmd Content", pdesc, TX_DESC_SIZE);
780 wmb(); 780 wmb();
781 SET_TX_DESC_OWN(pdesc, 1); 781 SET_TX_DESC_OWN(pdesc, 1);
782} 782}
@@ -793,8 +793,8 @@ void rtl92de_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val)
793 SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *) val); 793 SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *) val);
794 break; 794 break;
795 default: 795 default:
796 RT_ASSERT(false, ("ERR txdesc :%d" 796 RT_ASSERT(false, "ERR txdesc :%d not process\n",
797 " not process\n", desc_name)); 797 desc_name);
798 break; 798 break;
799 } 799 }
800 } else { 800 } else {
@@ -813,8 +813,8 @@ void rtl92de_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val)
813 SET_RX_DESC_EOR(pdesc, 1); 813 SET_RX_DESC_EOR(pdesc, 1);
814 break; 814 break;
815 default: 815 default:
816 RT_ASSERT(false, ("ERR rxdesc :%d " 816 RT_ASSERT(false, "ERR rxdesc :%d not process\n",
817 "not process\n", desc_name)); 817 desc_name);
818 break; 818 break;
819 } 819 }
820 } 820 }
@@ -833,8 +833,8 @@ u32 rtl92de_get_desc(u8 *p_desc, bool istx, u8 desc_name)
833 ret = GET_TX_DESC_TX_BUFFER_ADDRESS(p_desc); 833 ret = GET_TX_DESC_TX_BUFFER_ADDRESS(p_desc);
834 break; 834 break;
835 default: 835 default:
836 RT_ASSERT(false, ("ERR txdesc :%d " 836 RT_ASSERT(false, "ERR txdesc :%d not process\n",
837 "not process\n", desc_name)); 837 desc_name);
838 break; 838 break;
839 } 839 }
840 } else { 840 } else {
@@ -847,8 +847,8 @@ u32 rtl92de_get_desc(u8 *p_desc, bool istx, u8 desc_name)
847 ret = GET_RX_DESC_PKT_LEN(pdesc); 847 ret = GET_RX_DESC_PKT_LEN(pdesc);
848 break; 848 break;
849 default: 849 default:
850 RT_ASSERT(false, ("ERR rxdesc :%d " 850 RT_ASSERT(false, "ERR rxdesc :%d not process\n",
851 "not process\n", desc_name)); 851 desc_name);
852 break; 852 break;
853 } 853 }
854 } 854 }
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.h b/drivers/net/wireless/rtlwifi/rtl8192de/trx.h
index 4d55d0b6816d..0dc736c2723b 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/def.h b/drivers/net/wireless/rtlwifi/rtl8192se/def.h
index c6c044816d39..d1b0a1e14971 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/def.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
index 4203a8531ca0..fbabae17259e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -170,9 +170,9 @@ static void _rtl92s_dm_txpowertracking_callback_thermalmeter(
170 thermalvalue = (u8)rtl_get_rfreg(hw, RF90_PATH_A, RF_T_METER, 0x1f); 170 thermalvalue = (u8)rtl_get_rfreg(hw, RF90_PATH_A, RF_T_METER, 0x1f);
171 171
172 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, 172 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
173 ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x " 173 "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermal meter 0x%x\n",
174 "eeprom_thermalmeter 0x%x\n", thermalvalue, 174 thermalvalue,
175 rtlpriv->dm.thermalvalue, rtlefuse->eeprom_thermalmeter)); 175 rtlpriv->dm.thermalvalue, rtlefuse->eeprom_thermalmeter);
176 176
177 if (thermalvalue) { 177 if (thermalvalue) {
178 rtlpriv->dm.thermalvalue = thermalvalue; 178 rtlpriv->dm.thermalvalue = thermalvalue;
@@ -282,11 +282,11 @@ static void _rtl92s_dm_refresh_rateadaptive_mask(struct ieee80211_hw *hw)
282 } 282 }
283 283
284 if (ra->pre_ratr_state != ra->ratr_state) { 284 if (ra->pre_ratr_state != ra->ratr_state) {
285 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, ("RSSI = %ld " 285 RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
286 "RSSI_LEVEL = %d PreState = %d, CurState = %d\n", 286 "RSSI = %ld RSSI_LEVEL = %d PreState = %d, CurState = %d\n",
287 rtlpriv->dm.undecorated_smoothed_pwdb, 287 rtlpriv->dm.undecorated_smoothed_pwdb,
288 ra->ratr_state, 288 ra->ratr_state,
289 ra->pre_ratr_state, ra->ratr_state)); 289 ra->pre_ratr_state, ra->ratr_state);
290 290
291 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 291 rtlpriv->cfg->ops->update_rate_tbl(hw, sta,
292 ra->ratr_state); 292 ra->ratr_state);
@@ -586,7 +586,7 @@ static void _rtl92s_dm_dynamic_txpower(struct ieee80211_hw *hw)
586 if ((mac->link_state < MAC80211_LINKED) && 586 if ((mac->link_state < MAC80211_LINKED) &&
587 (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) { 587 (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) {
588 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, 588 RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
589 ("Not connected to any\n")); 589 "Not connected to any\n");
590 590
591 rtlpriv->dm.dynamic_txhighpower_lvl = TX_HIGHPWR_LEVEL_NORMAL; 591 rtlpriv->dm.dynamic_txhighpower_lvl = TX_HIGHPWR_LEVEL_NORMAL;
592 592
@@ -599,22 +599,22 @@ static void _rtl92s_dm_dynamic_txpower(struct ieee80211_hw *hw)
599 undecorated_smoothed_pwdb = 599 undecorated_smoothed_pwdb =
600 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; 600 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb;
601 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 601 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
602 ("AP Client PWDB = 0x%lx\n", 602 "AP Client PWDB = 0x%lx\n",
603 undecorated_smoothed_pwdb)); 603 undecorated_smoothed_pwdb);
604 } else { 604 } else {
605 undecorated_smoothed_pwdb = 605 undecorated_smoothed_pwdb =
606 rtlpriv->dm.undecorated_smoothed_pwdb; 606 rtlpriv->dm.undecorated_smoothed_pwdb;
607 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 607 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
608 ("STA Default Port PWDB = 0x%lx\n", 608 "STA Default Port PWDB = 0x%lx\n",
609 undecorated_smoothed_pwdb)); 609 undecorated_smoothed_pwdb);
610 } 610 }
611 } else { 611 } else {
612 undecorated_smoothed_pwdb = 612 undecorated_smoothed_pwdb =
613 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; 613 rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb;
614 614
615 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 615 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
616 ("AP Ext Port PWDB = 0x%lx\n", 616 "AP Ext Port PWDB = 0x%lx\n",
617 undecorated_smoothed_pwdb)); 617 undecorated_smoothed_pwdb);
618 } 618 }
619 619
620 txpwr_threshold_lv2 = TX_POWER_NEAR_FIELD_THRESH_LVL2; 620 txpwr_threshold_lv2 = TX_POWER_NEAR_FIELD_THRESH_LVL2;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
index 9051a556acc4..e1b19a641765 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c
index 3fda6b1dcf46..0d8bf5657008 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -66,7 +66,7 @@ static bool _rtl92s_firmware_enable_cpu(struct ieee80211_hw *hw)
66 cpustatus = rtl_read_byte(rtlpriv, TCR); 66 cpustatus = rtl_read_byte(rtlpriv, TCR);
67 if (cpustatus & IMEM_RDY) { 67 if (cpustatus & IMEM_RDY) {
68 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 68 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
69 ("IMEM Ready after CPU has refilled.\n")); 69 "IMEM Ready after CPU has refilled\n");
70 break; 70 break;
71 } 71 }
72 72
@@ -120,9 +120,8 @@ static u8 _rtl92s_firmware_header_map_rftype(struct ieee80211_hw *hw)
120 return 0x22; 120 return 0x22;
121 break; 121 break;
122 default: 122 default:
123 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, 123 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "Unknown RF type(%x)\n",
124 ("Unknown RF type(%x)\n", 124 rtlphy->rf_type);
125 rtlphy->rf_type));
126 break; 125 break;
127 } 126 }
128 return 0x22; 127 return 0x22;
@@ -177,7 +176,7 @@ static bool _rtl92s_firmware_downloadcode(struct ieee80211_hw *hw,
177 176
178 if (buffer_len >= MAX_FIRMWARE_CODE_SIZE) { 177 if (buffer_len >= MAX_FIRMWARE_CODE_SIZE) {
179 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 178 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
180 ("Size over FIRMWARE_CODE_SIZE!\n")); 179 "Size over FIRMWARE_CODE_SIZE!\n");
181 180
182 return false; 181 return false;
183 } 182 }
@@ -231,8 +230,8 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw,
231 short pollingcnt = 1000; 230 short pollingcnt = 1000;
232 bool rtstatus = true; 231 bool rtstatus = true;
233 232
234 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("LoadStaus(%d)\n", 233 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
235 loadfw_status)); 234 "LoadStaus(%d)\n", loadfw_status);
236 235
237 firmware->fwstatus = (enum fw_status)loadfw_status; 236 firmware->fwstatus = (enum fw_status)loadfw_status;
238 237
@@ -248,8 +247,8 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw,
248 247
249 if (!(cpustatus & IMEM_CHK_RPT) || (pollingcnt <= 0)) { 248 if (!(cpustatus & IMEM_CHK_RPT) || (pollingcnt <= 0)) {
250 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 249 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
251 ("FW_STATUS_LOAD_IMEM" 250 "FW_STATUS_LOAD_IMEM FAIL CPU, Status=%x\n",
252 " FAIL CPU, Status=%x\r\n", cpustatus)); 251 cpustatus);
253 goto status_check_fail; 252 goto status_check_fail;
254 } 253 }
255 break; 254 break;
@@ -266,8 +265,8 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw,
266 265
267 if (!(cpustatus & EMEM_CHK_RPT) || (pollingcnt <= 0)) { 266 if (!(cpustatus & EMEM_CHK_RPT) || (pollingcnt <= 0)) {
268 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 267 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
269 ("FW_STATUS_LOAD_EMEM" 268 "FW_STATUS_LOAD_EMEM FAIL CPU, Status=%x\n",
270 " FAIL CPU, Status=%x\r\n", cpustatus)); 269 cpustatus);
271 goto status_check_fail; 270 goto status_check_fail;
272 } 271 }
273 272
@@ -275,7 +274,7 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw,
275 rtstatus = _rtl92s_firmware_enable_cpu(hw); 274 rtstatus = _rtl92s_firmware_enable_cpu(hw);
276 if (rtstatus != true) { 275 if (rtstatus != true) {
277 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 276 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
278 ("Enable CPU fail!\n")); 277 "Enable CPU fail!\n");
279 goto status_check_fail; 278 goto status_check_fail;
280 } 279 }
281 break; 280 break;
@@ -291,14 +290,14 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw,
291 290
292 if (!(cpustatus & DMEM_CODE_DONE) || (pollingcnt <= 0)) { 291 if (!(cpustatus & DMEM_CODE_DONE) || (pollingcnt <= 0)) {
293 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 292 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
294 ("Polling DMEM code done" 293 "Polling DMEM code done fail ! cpustatus(%#x)\n",
295 " fail ! cpustatus(%#x)\n", cpustatus)); 294 cpustatus);
296 goto status_check_fail; 295 goto status_check_fail;
297 } 296 }
298 297
299 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 298 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
300 ("DMEM code download success," 299 "DMEM code download success, cpustatus(%#x)\n",
301 " cpustatus(%#x)\n", cpustatus)); 300 cpustatus);
302 301
303 /* Prevent Delay too much and being scheduled out */ 302 /* Prevent Delay too much and being scheduled out */
304 /* Polling Load Firmware ready */ 303 /* Polling Load Firmware ready */
@@ -311,14 +310,14 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw,
311 } while (pollingcnt--); 310 } while (pollingcnt--);
312 311
313 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 312 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
314 ("Polling Load Firmware ready," 313 "Polling Load Firmware ready, cpustatus(%x)\n",
315 " cpustatus(%x)\n", cpustatus)); 314 cpustatus);
316 315
317 if (((cpustatus & LOAD_FW_READY) != LOAD_FW_READY) || 316 if (((cpustatus & LOAD_FW_READY) != LOAD_FW_READY) ||
318 (pollingcnt <= 0)) { 317 (pollingcnt <= 0)) {
319 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 318 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
320 ("Polling Load Firmware" 319 "Polling Load Firmware ready fail ! cpustatus(%x)\n",
321 " ready fail ! cpustatus(%x)\n", cpustatus)); 320 cpustatus);
322 goto status_check_fail; 321 goto status_check_fail;
323 } 322 }
324 323
@@ -332,7 +331,7 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw,
332 RCR_APP_ICV | RCR_APP_MIC)); 331 RCR_APP_ICV | RCR_APP_MIC));
333 332
334 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 333 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
335 ("Current RCR settings(%#x)\n", tmpu4b)); 334 "Current RCR settings(%#x)\n", tmpu4b);
336 335
337 /* Set to normal mode. */ 336 /* Set to normal mode. */
338 rtl_write_byte(rtlpriv, LBKMD_SEL, LBK_NORMAL); 337 rtl_write_byte(rtlpriv, LBKMD_SEL, LBK_NORMAL);
@@ -340,14 +339,15 @@ static bool _rtl92s_firmware_checkready(struct ieee80211_hw *hw,
340 339
341 default: 340 default:
342 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, 341 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG,
343 ("Unknown status check!\n")); 342 "Unknown status check!\n");
344 rtstatus = false; 343 rtstatus = false;
345 break; 344 break;
346 } 345 }
347 346
348status_check_fail: 347status_check_fail:
349 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("loadfw_status(%d), " 348 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
350 "rtstatus(%x)\n", loadfw_status, rtstatus)); 349 "loadfw_status(%d), rtstatus(%x)\n",
350 loadfw_status, rtstatus);
351 return rtstatus; 351 return rtstatus;
352} 352}
353 353
@@ -364,7 +364,7 @@ int rtl92s_download_fw(struct ieee80211_hw *hw)
364 u8 fwstatus = FW_STATUS_INIT; 364 u8 fwstatus = FW_STATUS_INIT;
365 bool rtstatus = true; 365 bool rtstatus = true;
366 366
367 if (!rtlhal->pfirmware) 367 if (rtlpriv->max_fw_size == 0 || !rtlhal->pfirmware)
368 return 1; 368 return 1;
369 369
370 firmware = (struct rt_firmware *)rtlhal->pfirmware; 370 firmware = (struct rt_firmware *)rtlhal->pfirmware;
@@ -378,17 +378,17 @@ int rtl92s_download_fw(struct ieee80211_hw *hw)
378 firmware->firmwareversion = byte(pfwheader->version, 0); 378 firmware->firmwareversion = byte(pfwheader->version, 0);
379 firmware->pfwheader->fwpriv.hci_sel = 1;/* pcie */ 379 firmware->pfwheader->fwpriv.hci_sel = 1;/* pcie */
380 380
381 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("signature:%x, version:" 381 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
382 "%x, size:%x," 382 "signature:%x, version:%x, size:%x, imemsize:%x, sram size:%x\n",
383 "imemsize:%x, sram size:%x\n", pfwheader->signature, 383 pfwheader->signature,
384 pfwheader->version, pfwheader->dmem_size, 384 pfwheader->version, pfwheader->dmem_size,
385 pfwheader->img_imem_size, pfwheader->img_sram_size)); 385 pfwheader->img_imem_size, pfwheader->img_sram_size);
386 386
387 /* 2. Retrieve IMEM image. */ 387 /* 2. Retrieve IMEM image. */
388 if ((pfwheader->img_imem_size == 0) || (pfwheader->img_imem_size > 388 if ((pfwheader->img_imem_size == 0) || (pfwheader->img_imem_size >
389 sizeof(firmware->fw_imem))) { 389 sizeof(firmware->fw_imem))) {
390 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 390 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
391 ("memory for data image is less than IMEM required\n")); 391 "memory for data image is less than IMEM required\n");
392 goto fail; 392 goto fail;
393 } else { 393 } else {
394 puc_mappedfile += fwhdr_size; 394 puc_mappedfile += fwhdr_size;
@@ -401,7 +401,7 @@ int rtl92s_download_fw(struct ieee80211_hw *hw)
401 /* 3. Retriecve EMEM image. */ 401 /* 3. Retriecve EMEM image. */
402 if (pfwheader->img_sram_size > sizeof(firmware->fw_emem)) { 402 if (pfwheader->img_sram_size > sizeof(firmware->fw_emem)) {
403 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 403 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
404 ("memory for data image is less than EMEM required\n")); 404 "memory for data image is less than EMEM required\n");
405 goto fail; 405 goto fail;
406 } else { 406 } else {
407 puc_mappedfile += firmware->fw_imem_len; 407 puc_mappedfile += firmware->fw_imem_len;
@@ -436,7 +436,7 @@ int rtl92s_download_fw(struct ieee80211_hw *hw)
436 break; 436 break;
437 default: 437 default:
438 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 438 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
439 ("Unexpected Download step!!\n")); 439 "Unexpected Download step!!\n");
440 goto fail; 440 goto fail;
441 break; 441 break;
442 } 442 }
@@ -446,14 +446,14 @@ int rtl92s_download_fw(struct ieee80211_hw *hw)
446 ul_filelength); 446 ul_filelength);
447 447
448 if (rtstatus != true) { 448 if (rtstatus != true) {
449 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("fail!\n")); 449 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "fail!\n");
450 goto fail; 450 goto fail;
451 } 451 }
452 452
453 /* <3> Check whether load FW process is ready */ 453 /* <3> Check whether load FW process is ready */
454 rtstatus = _rtl92s_firmware_checkready(hw, fwstatus); 454 rtstatus = _rtl92s_firmware_checkready(hw, fwstatus);
455 if (rtstatus != true) { 455 if (rtstatus != true) {
456 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("fail!\n")); 456 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "fail!\n");
457 goto fail; 457 goto fail;
458 } 458 }
459 459
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/fw.h b/drivers/net/wireless/rtlwifi/rtl8192se/fw.h
index 74cc503efe8a..babe85d4b694 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/fw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/fw.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
index c474486e3911..22098c2f38f1 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -27,8 +27,6 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
32#include "../wifi.h" 30#include "../wifi.h"
33#include "../efuse.h" 31#include "../efuse.h"
34#include "../base.h" 32#include "../base.h"
@@ -80,8 +78,8 @@ void rtl92se_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
80 break; 78 break;
81 } 79 }
82 default: { 80 default: {
83 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 81 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
84 ("switch case not process\n")); 82 "switch case not processed\n");
85 break; 83 break;
86 } 84 }
87 } 85 }
@@ -140,7 +138,7 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
140 u8 e_aci; 138 u8 e_aci;
141 139
142 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 140 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
143 ("HW_VAR_SLOT_TIME %x\n", val[0])); 141 "HW_VAR_SLOT_TIME %x\n", val[0]);
144 142
145 rtl_write_byte(rtlpriv, SLOT_TIME, val[0]); 143 rtl_write_byte(rtlpriv, SLOT_TIME, val[0]);
146 144
@@ -185,8 +183,8 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
185 *val = min_spacing_to_set; 183 *val = min_spacing_to_set;
186 184
187 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 185 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
188 ("Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", 186 "Set HW_VAR_AMPDU_MIN_SPACE: %#x\n",
189 mac->min_space_cfg)); 187 mac->min_space_cfg);
190 188
191 rtl_write_byte(rtlpriv, AMPDU_MIN_SPACE, 189 rtl_write_byte(rtlpriv, AMPDU_MIN_SPACE,
192 mac->min_space_cfg); 190 mac->min_space_cfg);
@@ -201,8 +199,8 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
201 mac->min_space_cfg |= (density_to_set << 3); 199 mac->min_space_cfg |= (density_to_set << 3);
202 200
203 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 201 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
204 ("Set HW_VAR_SHORTGI_DENSITY: %#x\n", 202 "Set HW_VAR_SHORTGI_DENSITY: %#x\n",
205 mac->min_space_cfg)); 203 mac->min_space_cfg);
206 204
207 rtl_write_byte(rtlpriv, AMPDU_MIN_SPACE, 205 rtl_write_byte(rtlpriv, AMPDU_MIN_SPACE,
208 mac->min_space_cfg); 206 mac->min_space_cfg);
@@ -244,8 +242,8 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
244 rtl_write_byte(rtlpriv, AGGLEN_LMT_H, regtoset); 242 rtl_write_byte(rtlpriv, AGGLEN_LMT_H, regtoset);
245 243
246 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, 244 RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
247 ("Set HW_VAR_AMPDU_FACTOR: %#x\n", 245 "Set HW_VAR_AMPDU_FACTOR: %#x\n",
248 factor_toset)); 246 factor_toset);
249 } 247 }
250 break; 248 break;
251 } 249 }
@@ -282,8 +280,8 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
282 break; 280 break;
283 default: 281 default:
284 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 282 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
285 ("HW_VAR_ACM_CTRL acm set " 283 "HW_VAR_ACM_CTRL acm set failed: eACI is %d\n",
286 "failed: eACI is %d\n", acm)); 284 acm);
287 break; 285 break;
288 } 286 }
289 } else { 287 } else {
@@ -299,13 +297,13 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
299 break; 297 break;
300 default: 298 default:
301 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 299 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
302 ("switch case not process\n")); 300 "switch case not processed\n");
303 break; 301 break;
304 } 302 }
305 } 303 }
306 304
307 RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE, 305 RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE,
308 ("HW_VAR_ACM_CTRL Write 0x%X\n", acm_ctrl)); 306 "HW_VAR_ACM_CTRL Write 0x%X\n", acm_ctrl);
309 rtl_write_byte(rtlpriv, AcmHwCtrl, acm_ctrl); 307 rtl_write_byte(rtlpriv, AcmHwCtrl, acm_ctrl);
310 break; 308 break;
311 } 309 }
@@ -404,7 +402,7 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
404 } 402 }
405 default: 403 default:
406 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 404 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
407 ("switch case not process\n")); 405 "switch case not processed\n");
408 break; 406 break;
409 } 407 }
410 408
@@ -415,14 +413,14 @@ void rtl92se_enable_hw_security_config(struct ieee80211_hw *hw)
415 struct rtl_priv *rtlpriv = rtl_priv(hw); 413 struct rtl_priv *rtlpriv = rtl_priv(hw);
416 u8 sec_reg_value = 0x0; 414 u8 sec_reg_value = 0x0;
417 415
418 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("PairwiseEncAlgorithm = %d " 416 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
419 "GroupEncAlgorithm = %d\n", 417 "PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n",
420 rtlpriv->sec.pairwise_enc_algorithm, 418 rtlpriv->sec.pairwise_enc_algorithm,
421 rtlpriv->sec.group_enc_algorithm)); 419 rtlpriv->sec.group_enc_algorithm);
422 420
423 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { 421 if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
424 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 422 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
425 ("not open hw encryption\n")); 423 "not open hw encryption\n");
426 return; 424 return;
427 } 425 }
428 426
@@ -433,8 +431,8 @@ void rtl92se_enable_hw_security_config(struct ieee80211_hw *hw)
433 sec_reg_value |= SCR_RXUSEDK; 431 sec_reg_value |= SCR_RXUSEDK;
434 } 432 }
435 433
436 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, ("The SECR-value %x\n", 434 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, "The SECR-value %x\n",
437 sec_reg_value)); 435 sec_reg_value);
438 436
439 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value); 437 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value);
440 438
@@ -718,8 +716,8 @@ static void _rtl92se_macconfig_before_fwdownload(struct ieee80211_hw *hw)
718 716
719 if (pollingcnt <= 0) { 717 if (pollingcnt <= 0) {
720 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 718 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
721 ("Polling TXDMA_INIT_VALUE " 719 "Polling TXDMA_INIT_VALUE timeout!! Current TCR(%#x)\n",
722 "timeout!! Current TCR(%#x)\n", tmpu1b)); 720 tmpu1b);
723 tmpu1b = rtl_read_byte(rtlpriv, CMDR); 721 tmpu1b = rtl_read_byte(rtlpriv, CMDR);
724 rtl_write_byte(rtlpriv, CMDR, tmpu1b & (~TXDMA_EN)); 722 rtl_write_byte(rtlpriv, CMDR, tmpu1b & (~TXDMA_EN));
725 udelay(2); 723 udelay(2);
@@ -870,10 +868,10 @@ static void _rtl92se_macconfig_after_fwdownload(struct ieee80211_hw *hw)
870 868
871 /* Change Program timing */ 869 /* Change Program timing */
872 rtl_write_byte(rtlpriv, REG_EFUSE_CTRL + 3, 0x72); 870 rtl_write_byte(rtlpriv, REG_EFUSE_CTRL + 3, 0x72);
873 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("EFUSE CONFIG OK\n")); 871 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "EFUSE CONFIG OK\n");
874 } 872 }
875 873
876 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("OK\n")); 874 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "OK\n");
877 875
878} 876}
879 877
@@ -951,12 +949,9 @@ int rtl92se_hw_init(struct ieee80211_hw *hw)
951 rtstatus = rtl92s_download_fw(hw); 949 rtstatus = rtl92s_download_fw(hw);
952 if (!rtstatus) { 950 if (!rtstatus) {
953 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 951 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
954 ("Failed to download FW. " 952 "Failed to download FW. Init HW without FW now... "
955 "Init HW without FW now.., Please copy FW into" 953 "Please copy FW into /lib/firmware/rtlwifi\n");
956 "/lib/firmware/rtlwifi\n")); 954 return 1;
957 rtlhal->fw_ready = false;
958 } else {
959 rtlhal->fw_ready = true;
960 } 955 }
961 956
962 /* After FW download, we have to reset MAC register */ 957 /* After FW download, we have to reset MAC register */
@@ -968,7 +963,7 @@ int rtl92se_hw_init(struct ieee80211_hw *hw)
968 963
969 /* 3. Initialize MAC/PHY Config by MACPHY_reg.txt */ 964 /* 3. Initialize MAC/PHY Config by MACPHY_reg.txt */
970 if (rtl92s_phy_mac_config(hw) != true) { 965 if (rtl92s_phy_mac_config(hw) != true) {
971 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("MAC Config failed\n")); 966 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "MAC Config failed\n");
972 return rtstatus; 967 return rtstatus;
973 } 968 }
974 969
@@ -978,7 +973,7 @@ int rtl92se_hw_init(struct ieee80211_hw *hw)
978 973
979 /* 4. Initialize BB After MAC Config PHY_reg.txt, AGC_Tab.txt */ 974 /* 4. Initialize BB After MAC Config PHY_reg.txt, AGC_Tab.txt */
980 if (rtl92s_phy_bb_config(hw) != true) { 975 if (rtl92s_phy_bb_config(hw) != true) {
981 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, ("BB Config failed\n")); 976 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, "BB Config failed\n");
982 return rtstatus; 977 return rtstatus;
983 } 978 }
984 979
@@ -1014,7 +1009,7 @@ int rtl92se_hw_init(struct ieee80211_hw *hw)
1014 rtl_write_byte(rtlpriv, RF_CTRL, 0x07); 1009 rtl_write_byte(rtlpriv, RF_CTRL, 0x07);
1015 1010
1016 if (rtl92s_phy_rf_config(hw) != true) { 1011 if (rtl92s_phy_rf_config(hw) != true) {
1017 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("RF Config failed\n")); 1012 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "RF Config failed\n");
1018 return rtstatus; 1013 return rtstatus;
1019 } 1014 }
1020 1015
@@ -1129,26 +1124,26 @@ static int _rtl92se_set_media_status(struct ieee80211_hw *hw,
1129 case NL80211_IFTYPE_UNSPECIFIED: 1124 case NL80211_IFTYPE_UNSPECIFIED:
1130 bt_msr |= (MSR_LINK_NONE << MSR_LINK_SHIFT); 1125 bt_msr |= (MSR_LINK_NONE << MSR_LINK_SHIFT);
1131 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1126 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1132 ("Set Network type to NO LINK!\n")); 1127 "Set Network type to NO LINK!\n");
1133 break; 1128 break;
1134 case NL80211_IFTYPE_ADHOC: 1129 case NL80211_IFTYPE_ADHOC:
1135 bt_msr |= (MSR_LINK_ADHOC << MSR_LINK_SHIFT); 1130 bt_msr |= (MSR_LINK_ADHOC << MSR_LINK_SHIFT);
1136 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1131 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1137 ("Set Network type to Ad Hoc!\n")); 1132 "Set Network type to Ad Hoc!\n");
1138 break; 1133 break;
1139 case NL80211_IFTYPE_STATION: 1134 case NL80211_IFTYPE_STATION:
1140 bt_msr |= (MSR_LINK_MANAGED << MSR_LINK_SHIFT); 1135 bt_msr |= (MSR_LINK_MANAGED << MSR_LINK_SHIFT);
1141 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1136 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1142 ("Set Network type to STA!\n")); 1137 "Set Network type to STA!\n");
1143 break; 1138 break;
1144 case NL80211_IFTYPE_AP: 1139 case NL80211_IFTYPE_AP:
1145 bt_msr |= (MSR_LINK_MASTER << MSR_LINK_SHIFT); 1140 bt_msr |= (MSR_LINK_MASTER << MSR_LINK_SHIFT);
1146 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, 1141 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
1147 ("Set Network type to AP!\n")); 1142 "Set Network type to AP!\n");
1148 break; 1143 break;
1149 default: 1144 default:
1150 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1145 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1151 ("Network type %d not support!\n", type)); 1146 "Network type %d not supported!\n", type);
1152 return 1; 1147 return 1;
1153 break; 1148 break;
1154 1149
@@ -1202,7 +1197,7 @@ void rtl92se_set_qos(struct ieee80211_hw *hw, int aci)
1202 rtl_write_dword(rtlpriv, EDCAPARA_VO, 0x2f3222); 1197 rtl_write_dword(rtlpriv, EDCAPARA_VO, 0x2f3222);
1203 break; 1198 break;
1204 default: 1199 default:
1205 RT_ASSERT(false, ("invalid aci: %d !\n", aci)); 1200 RT_ASSERT(false, "invalid aci: %d !\n", aci);
1206 break; 1201 break;
1207 } 1202 }
1208} 1203}
@@ -1219,9 +1214,14 @@ void rtl92se_enable_interrupt(struct ieee80211_hw *hw)
1219 1214
1220void rtl92se_disable_interrupt(struct ieee80211_hw *hw) 1215void rtl92se_disable_interrupt(struct ieee80211_hw *hw)
1221{ 1216{
1222 struct rtl_priv *rtlpriv = rtl_priv(hw); 1217 struct rtl_priv *rtlpriv;
1223 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1218 struct rtl_pci *rtlpci;
1224 1219
1220 rtlpriv = rtl_priv(hw);
1221 /* if firmware not available, no interrupts */
1222 if (!rtlpriv || !rtlpriv->max_fw_size)
1223 return;
1224 rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1225 rtl_write_dword(rtlpriv, INTA_MASK, 0); 1225 rtl_write_dword(rtlpriv, INTA_MASK, 0);
1226 rtl_write_dword(rtlpriv, INTA_MASK + 4, 0); 1226 rtl_write_dword(rtlpriv, INTA_MASK + 4, 0);
1227 1227
@@ -1583,8 +1583,8 @@ void rtl92se_update_interrupt_mask(struct ieee80211_hw *hw,
1583 struct rtl_priv *rtlpriv = rtl_priv(hw); 1583 struct rtl_priv *rtlpriv = rtl_priv(hw);
1584 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1584 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1585 1585
1586 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, 1586 RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, "add_msr:%x, rm_msr:%x\n",
1587 ("add_msr:%x, rm_msr:%x\n", add_msr, rm_msr)); 1587 add_msr, rm_msr);
1588 1588
1589 if (add_msr) 1589 if (add_msr)
1590 rtlpci->irq_mask[0] |= add_msr; 1590 rtlpci->irq_mask[0] |= add_msr;
@@ -1627,7 +1627,7 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
1627 1627
1628 if (rtlefuse->epromtype == EEPROM_93C46) { 1628 if (rtlefuse->epromtype == EEPROM_93C46) {
1629 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1629 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1630 ("RTL819X Not boot from eeprom, check it !!")); 1630 "RTL819X Not boot from eeprom, check it !!\n");
1631 } else if (rtlefuse->epromtype == EEPROM_BOOT_EFUSE) { 1631 } else if (rtlefuse->epromtype == EEPROM_BOOT_EFUSE) {
1632 rtl_efuse_shadow_map_update(hw); 1632 rtl_efuse_shadow_map_update(hw);
1633 1633
@@ -1636,16 +1636,16 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
1636 HWSET_MAX_SIZE_92S); 1636 HWSET_MAX_SIZE_92S);
1637 } 1637 }
1638 1638
1639 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, ("MAP\n"), 1639 RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP",
1640 hwinfo, HWSET_MAX_SIZE_92S); 1640 hwinfo, HWSET_MAX_SIZE_92S);
1641 1641
1642 eeprom_id = *((u16 *)&hwinfo[0]); 1642 eeprom_id = *((u16 *)&hwinfo[0]);
1643 if (eeprom_id != RTL8190_EEPROM_ID) { 1643 if (eeprom_id != RTL8190_EEPROM_ID) {
1644 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 1644 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
1645 ("EEPROM ID(%#x) is invalid!!\n", eeprom_id)); 1645 "EEPROM ID(%#x) is invalid!!\n", eeprom_id);
1646 rtlefuse->autoload_failflag = true; 1646 rtlefuse->autoload_failflag = true;
1647 } else { 1647 } else {
1648 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); 1648 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
1649 rtlefuse->autoload_failflag = false; 1649 rtlefuse->autoload_failflag = false;
1650 } 1650 }
1651 1651
@@ -1663,15 +1663,15 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
1663 rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION]; 1663 rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION];
1664 1664
1665 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1665 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1666 ("EEPROMId = 0x%4x\n", eeprom_id)); 1666 "EEPROMId = 0x%4x\n", eeprom_id);
1667 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1667 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1668 ("EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid)); 1668 "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid);
1669 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1669 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1670 ("EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did)); 1670 "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did);
1671 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1671 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1672 ("EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid)); 1672 "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid);
1673 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1673 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1674 ("EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid)); 1674 "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid);
1675 1675
1676 for (i = 0; i < 6; i += 2) { 1676 for (i = 0; i < 6; i += 2) {
1677 usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i]; 1677 usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i];
@@ -1681,8 +1681,7 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
1681 for (i = 0; i < 6; i++) 1681 for (i = 0; i < 6; i++)
1682 rtl_write_byte(rtlpriv, MACIDR0 + i, rtlefuse->dev_addr[i]); 1682 rtl_write_byte(rtlpriv, MACIDR0 + i, rtlefuse->dev_addr[i]);
1683 1683
1684 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 1684 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%pM\n", rtlefuse->dev_addr);
1685 ("%pM\n", rtlefuse->dev_addr));
1686 1685
1687 /* Get Tx Power Level by Channel */ 1686 /* Get Tx Power Level by Channel */
1688 /* Read Tx power of Channel 1 ~ 14 from EEPROM. */ 1687 /* Read Tx power of Channel 1 ~ 14 from EEPROM. */
@@ -1707,23 +1706,24 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
1707 for (rf_path = 0; rf_path < 2; rf_path++) 1706 for (rf_path = 0; rf_path < 2; rf_path++)
1708 for (i = 0; i < 3; i++) 1707 for (i = 0; i < 3; i++)
1709 RTPRINT(rtlpriv, FINIT, INIT_EEPROM, 1708 RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
1710 ("RF(%d) EEPROM CCK Area(%d) = 0x%x\n", rf_path, 1709 "RF(%d) EEPROM CCK Area(%d) = 0x%x\n",
1711 i, rtlefuse->eeprom_chnlarea_txpwr_cck 1710 rf_path, i,
1712 [rf_path][i])); 1711 rtlefuse->eeprom_chnlarea_txpwr_cck
1712 [rf_path][i]);
1713 for (rf_path = 0; rf_path < 2; rf_path++) 1713 for (rf_path = 0; rf_path < 2; rf_path++)
1714 for (i = 0; i < 3; i++) 1714 for (i = 0; i < 3; i++)
1715 RTPRINT(rtlpriv, FINIT, INIT_EEPROM, 1715 RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
1716 ("RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n", 1716 "RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n",
1717 rf_path, i, 1717 rf_path, i,
1718 rtlefuse->eeprom_chnlarea_txpwr_ht40_1s 1718 rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
1719 [rf_path][i])); 1719 [rf_path][i]);
1720 for (rf_path = 0; rf_path < 2; rf_path++) 1720 for (rf_path = 0; rf_path < 2; rf_path++)
1721 for (i = 0; i < 3; i++) 1721 for (i = 0; i < 3; i++)
1722 RTPRINT(rtlpriv, FINIT, INIT_EEPROM, 1722 RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
1723 ("RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n", 1723 "RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n",
1724 rf_path, i, 1724 rf_path, i,
1725 rtlefuse->eeprom_chnlarea_txpwr_ht40_2sdiif 1725 rtlefuse->eeprom_chnlarea_txpwr_ht40_2sdiif
1726 [rf_path][i])); 1726 [rf_path][i]);
1727 1727
1728 for (rf_path = 0; rf_path < 2; rf_path++) { 1728 for (rf_path = 0; rf_path < 2; rf_path++) {
1729 1729
@@ -1754,11 +1754,11 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
1754 1754
1755 for (i = 0; i < 14; i++) { 1755 for (i = 0; i < 14; i++) {
1756 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1756 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1757 ("RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = " 1757 "RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = [0x%x / 0x%x / 0x%x]\n",
1758 "[0x%x / 0x%x / 0x%x]\n", rf_path, i, 1758 rf_path, i,
1759 rtlefuse->txpwrlevel_cck[rf_path][i], 1759 rtlefuse->txpwrlevel_cck[rf_path][i],
1760 rtlefuse->txpwrlevel_ht40_1s[rf_path][i], 1760 rtlefuse->txpwrlevel_ht40_1s[rf_path][i],
1761 rtlefuse->txpwrlevel_ht40_2s[rf_path][i])); 1761 rtlefuse->txpwrlevel_ht40_2s[rf_path][i]);
1762 } 1762 }
1763 } 1763 }
1764 1764
@@ -1791,13 +1791,13 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
1791 0xf0) >> 4); 1791 0xf0) >> 4);
1792 1792
1793 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1793 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1794 ("RF-%d pwrgroup_ht20[%d] = 0x%x\n", 1794 "RF-%d pwrgroup_ht20[%d] = 0x%x\n",
1795 rf_path, i, 1795 rf_path, i,
1796 rtlefuse->pwrgroup_ht20[rf_path][i])); 1796 rtlefuse->pwrgroup_ht20[rf_path][i]);
1797 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1797 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1798 ("RF-%d pwrgroup_ht40[%d] = 0x%x\n", 1798 "RF-%d pwrgroup_ht40[%d] = 0x%x\n",
1799 rf_path, i, 1799 rf_path, i,
1800 rtlefuse->pwrgroup_ht40[rf_path][i])); 1800 rtlefuse->pwrgroup_ht40[rf_path][i]);
1801 } 1801 }
1802 } 1802 }
1803 1803
@@ -1852,27 +1852,27 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
1852 (hwinfo[EEPROM_REGULATORY] & 0x1); 1852 (hwinfo[EEPROM_REGULATORY] & 0x1);
1853 } 1853 }
1854 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1854 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1855 ("eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory)); 1855 "eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory);
1856 1856
1857 for (i = 0; i < 14; i++) 1857 for (i = 0; i < 14; i++)
1858 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1858 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1859 ("RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", i, 1859 "RF-A Ht20 to HT40 Diff[%d] = 0x%x\n",
1860 rtlefuse->txpwr_ht20diff[RF90_PATH_A][i])); 1860 i, rtlefuse->txpwr_ht20diff[RF90_PATH_A][i]);
1861 for (i = 0; i < 14; i++) 1861 for (i = 0; i < 14; i++)
1862 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1862 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1863 ("RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", i, 1863 "RF-A Legacy to Ht40 Diff[%d] = 0x%x\n",
1864 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i])); 1864 i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i]);
1865 for (i = 0; i < 14; i++) 1865 for (i = 0; i < 14; i++)
1866 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1866 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1867 ("RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", i, 1867 "RF-B Ht20 to HT40 Diff[%d] = 0x%x\n",
1868 rtlefuse->txpwr_ht20diff[RF90_PATH_B][i])); 1868 i, rtlefuse->txpwr_ht20diff[RF90_PATH_B][i]);
1869 for (i = 0; i < 14; i++) 1869 for (i = 0; i < 14; i++)
1870 RTPRINT(rtlpriv, FINIT, INIT_TxPower, 1870 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1871 ("RF-B Legacy to HT40 Diff[%d] = 0x%x\n", i, 1871 "RF-B Legacy to HT40 Diff[%d] = 0x%x\n",
1872 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i])); 1872 i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i]);
1873 1873
1874 RTPRINT(rtlpriv, FINIT, INIT_TxPower, ("TxPwrSafetyFlag = %d\n", 1874 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1875 rtlefuse->txpwr_safetyflag)); 1875 "TxPwrSafetyFlag = %d\n", rtlefuse->txpwr_safetyflag);
1876 1876
1877 /* Read RF-indication and Tx Power gain 1877 /* Read RF-indication and Tx Power gain
1878 * index diff of legacy to HT OFDM rate. */ 1878 * index diff of legacy to HT OFDM rate. */
@@ -1881,8 +1881,8 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
1881 rtlefuse->legacy_httxpowerdiff = 1881 rtlefuse->legacy_httxpowerdiff =
1882 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][0]; 1882 rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][0];
1883 1883
1884 RTPRINT(rtlpriv, FINIT, INIT_TxPower, ("TxPowerDiff = %#x\n", 1884 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1885 rtlefuse->eeprom_txpowerdiff)); 1885 "TxPowerDiff = %#x\n", rtlefuse->eeprom_txpowerdiff);
1886 1886
1887 /* Get TSSI value for each path. */ 1887 /* Get TSSI value for each path. */
1888 usvalue = *(u16 *)&hwinfo[EEPROM_TSSI_A]; 1888 usvalue = *(u16 *)&hwinfo[EEPROM_TSSI_A];
@@ -1890,16 +1890,16 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
1890 usvalue = *(u8 *)&hwinfo[EEPROM_TSSI_B]; 1890 usvalue = *(u8 *)&hwinfo[EEPROM_TSSI_B];
1891 rtlefuse->eeprom_tssi[RF90_PATH_B] = (u8)(usvalue & 0xff); 1891 rtlefuse->eeprom_tssi[RF90_PATH_B] = (u8)(usvalue & 0xff);
1892 1892
1893 RTPRINT(rtlpriv, FINIT, INIT_TxPower, ("TSSI_A = 0x%x, TSSI_B = 0x%x\n", 1893 RTPRINT(rtlpriv, FINIT, INIT_TxPower, "TSSI_A = 0x%x, TSSI_B = 0x%x\n",
1894 rtlefuse->eeprom_tssi[RF90_PATH_A], 1894 rtlefuse->eeprom_tssi[RF90_PATH_A],
1895 rtlefuse->eeprom_tssi[RF90_PATH_B])); 1895 rtlefuse->eeprom_tssi[RF90_PATH_B]);
1896 1896
1897 /* Read antenna tx power offset of B/C/D to A from EEPROM */ 1897 /* Read antenna tx power offset of B/C/D to A from EEPROM */
1898 /* and read ThermalMeter from EEPROM */ 1898 /* and read ThermalMeter from EEPROM */
1899 tempval = *(u8 *)&hwinfo[EEPROM_THERMALMETER]; 1899 tempval = *(u8 *)&hwinfo[EEPROM_THERMALMETER];
1900 rtlefuse->eeprom_thermalmeter = tempval; 1900 rtlefuse->eeprom_thermalmeter = tempval;
1901 RTPRINT(rtlpriv, FINIT, INIT_TxPower, ("thermalmeter = 0x%x\n", 1901 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1902 rtlefuse->eeprom_thermalmeter)); 1902 "thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter);
1903 1903
1904 /* ThermalMeter, BIT(0)~3 for RFIC1, BIT(4)~7 for RFIC2 */ 1904 /* ThermalMeter, BIT(0)~3 for RFIC1, BIT(4)~7 for RFIC2 */
1905 rtlefuse->thermalmeter[0] = (rtlefuse->eeprom_thermalmeter & 0x1f); 1905 rtlefuse->thermalmeter[0] = (rtlefuse->eeprom_thermalmeter & 0x1f);
@@ -1915,8 +1915,8 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
1915 /* Version ID, Channel plan */ 1915 /* Version ID, Channel plan */
1916 rtlefuse->eeprom_channelplan = *(u8 *)&hwinfo[EEPROM_CHANNELPLAN]; 1916 rtlefuse->eeprom_channelplan = *(u8 *)&hwinfo[EEPROM_CHANNELPLAN];
1917 rtlefuse->txpwr_fromeprom = true; 1917 rtlefuse->txpwr_fromeprom = true;
1918 RTPRINT(rtlpriv, FINIT, INIT_TxPower, ("EEPROM ChannelPlan = 0x%4x\n", 1918 RTPRINT(rtlpriv, FINIT, INIT_TxPower,
1919 rtlefuse->eeprom_channelplan)); 1919 "EEPROM ChannelPlan = 0x%4x\n", rtlefuse->eeprom_channelplan);
1920 1920
1921 /* Read Customer ID or Board Type!!! */ 1921 /* Read Customer ID or Board Type!!! */
1922 tempval = *(u8 *)&hwinfo[EEPROM_BOARDTYPE]; 1922 tempval = *(u8 *)&hwinfo[EEPROM_BOARDTYPE];
@@ -1937,14 +1937,14 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw)
1937 if (!(tempval & BIT(0))) { 1937 if (!(tempval & BIT(0))) {
1938 rtlefuse->b1x1_recvcombine = true; 1938 rtlefuse->b1x1_recvcombine = true;
1939 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1939 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1940 ("RF_TYPE=1T2R but only 1SS\n")); 1940 "RF_TYPE=1T2R but only 1SS\n");
1941 } 1941 }
1942 } 1942 }
1943 rtlefuse->b1ss_support = rtlefuse->b1x1_recvcombine; 1943 rtlefuse->b1ss_support = rtlefuse->b1x1_recvcombine;
1944 rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMID]; 1944 rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMID];
1945 1945
1946 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("EEPROM Customer ID: 0x%2x", 1946 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "EEPROM Customer ID: 0x%2x",
1947 rtlefuse->eeprom_oemid)); 1947 rtlefuse->eeprom_oemid);
1948 1948
1949 /* set channel paln to world wide 13 */ 1949 /* set channel paln to world wide 13 */
1950 rtlefuse->channel_plan = COUNTRY_CODE_WORLD_WIDE_13; 1950 rtlefuse->channel_plan = COUNTRY_CODE_WORLD_WIDE_13;
@@ -1959,19 +1959,19 @@ void rtl92se_read_eeprom_info(struct ieee80211_hw *hw)
1959 tmp_u1b = rtl_read_byte(rtlpriv, EPROM_CMD); 1959 tmp_u1b = rtl_read_byte(rtlpriv, EPROM_CMD);
1960 1960
1961 if (tmp_u1b & BIT(4)) { 1961 if (tmp_u1b & BIT(4)) {
1962 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EEPROM\n")); 1962 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EEPROM\n");
1963 rtlefuse->epromtype = EEPROM_93C46; 1963 rtlefuse->epromtype = EEPROM_93C46;
1964 } else { 1964 } else {
1965 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EFUSE\n")); 1965 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EFUSE\n");
1966 rtlefuse->epromtype = EEPROM_BOOT_EFUSE; 1966 rtlefuse->epromtype = EEPROM_BOOT_EFUSE;
1967 } 1967 }
1968 1968
1969 if (tmp_u1b & BIT(5)) { 1969 if (tmp_u1b & BIT(5)) {
1970 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); 1970 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
1971 rtlefuse->autoload_failflag = false; 1971 rtlefuse->autoload_failflag = false;
1972 _rtl92se_read_adapter_info(hw); 1972 _rtl92se_read_adapter_info(hw);
1973 } else { 1973 } else {
1974 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Autoload ERR!!\n")); 1974 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Autoload ERR!!\n");
1975 rtlefuse->autoload_failflag = true; 1975 rtlefuse->autoload_failflag = true;
1976 } 1976 }
1977} 1977}
@@ -2071,8 +2071,8 @@ static void rtl92se_update_hal_rate_table(struct ieee80211_hw *hw,
2071 else 2071 else
2072 rtl92s_phy_set_fw_cmd(hw, FW_CMD_RA_REFRESH_BG); 2072 rtl92s_phy_set_fw_cmd(hw, FW_CMD_RA_REFRESH_BG);
2073 2073
2074 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, 2074 RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, "%x\n",
2075 ("%x\n", rtl_read_dword(rtlpriv, ARFR0))); 2075 rtl_read_dword(rtlpriv, ARFR0));
2076} 2076}
2077 2077
2078static void rtl92se_update_hal_rate_mask(struct ieee80211_hw *hw, 2078static void rtl92se_update_hal_rate_mask(struct ieee80211_hw *hw,
@@ -2224,8 +2224,8 @@ static void rtl92se_update_hal_rate_mask(struct ieee80211_hw *hw,
2224 2224
2225 mask |= (bmulticast ? 1 : 0) << 9 | (macid & 0x1f) << 4 | (band & 0xf); 2225 mask |= (bmulticast ? 1 : 0) << 9 | (macid & 0x1f) << 4 | (band & 0xf);
2226 2226
2227 RT_TRACE(rtlpriv, COMP_RATR, DBG_TRACE, ("mask = %x, bitmap = %x\n", 2227 RT_TRACE(rtlpriv, COMP_RATR, DBG_TRACE, "mask = %x, bitmap = %x\n",
2228 mask, ratr_bitmap)); 2228 mask, ratr_bitmap);
2229 rtl_write_dword(rtlpriv, 0x2c4, ratr_bitmap); 2229 rtl_write_dword(rtlpriv, 0x2c4, ratr_bitmap);
2230 rtl_write_dword(rtlpriv, WFM5, (FW_RA_UPDATE_MASK | (mask << 8))); 2230 rtl_write_dword(rtlpriv, WFM5, (FW_RA_UPDATE_MASK | (mask << 8)));
2231 2231
@@ -2301,14 +2301,14 @@ bool rtl92se_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid)
2301 2301
2302 if ((ppsc->hwradiooff) && (rfpwr_toset == ERFON)) { 2302 if ((ppsc->hwradiooff) && (rfpwr_toset == ERFON)) {
2303 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 2303 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
2304 ("RFKILL-HW Radio ON, RF ON\n")); 2304 "RFKILL-HW Radio ON, RF ON\n");
2305 2305
2306 rfpwr_toset = ERFON; 2306 rfpwr_toset = ERFON;
2307 ppsc->hwradiooff = false; 2307 ppsc->hwradiooff = false;
2308 actuallyset = true; 2308 actuallyset = true;
2309 } else if ((ppsc->hwradiooff == false) && (rfpwr_toset == ERFOFF)) { 2309 } else if ((ppsc->hwradiooff == false) && (rfpwr_toset == ERFOFF)) {
2310 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 2310 RT_TRACE(rtlpriv, COMP_RF,
2311 ("RFKILL-HW Radio OFF, RF OFF\n")); 2311 DBG_DMESG, "RFKILL-HW Radio OFF, RF OFF\n");
2312 2312
2313 rfpwr_toset = ERFOFF; 2313 rfpwr_toset = ERFOFF;
2314 ppsc->hwradiooff = true; 2314 ppsc->hwradiooff = true;
@@ -2372,7 +2372,7 @@ void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr,
2372 u8 cam_offset = 0; 2372 u8 cam_offset = 0;
2373 u8 clear_number = 5; 2373 u8 clear_number = 5;
2374 2374
2375 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("clear_all\n")); 2375 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "clear_all\n");
2376 2376
2377 for (idx = 0; idx < clear_number; idx++) { 2377 for (idx = 0; idx < clear_number; idx++) {
2378 rtl_cam_mark_invalid(hw, cam_offset + idx); 2378 rtl_cam_mark_invalid(hw, cam_offset + idx);
@@ -2401,7 +2401,7 @@ void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr,
2401 break; 2401 break;
2402 default: 2402 default:
2403 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 2403 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2404 ("switch case not process\n")); 2404 "switch case not processed\n");
2405 enc_algo = CAM_TKIP; 2405 enc_algo = CAM_TKIP;
2406 break; 2406 break;
2407 } 2407 }
@@ -2419,9 +2419,8 @@ void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr,
2419 p_macaddr); 2419 p_macaddr);
2420 if (entry_id >= TOTAL_CAM_ENTRY) { 2420 if (entry_id >= TOTAL_CAM_ENTRY) {
2421 RT_TRACE(rtlpriv, 2421 RT_TRACE(rtlpriv,
2422 COMP_SEC, DBG_EMERG, 2422 COMP_SEC, DBG_EMERG,
2423 ("Can not find free hw" 2423 "Can not find free hw security cam entry\n");
2424 " security cam entry\n"));
2425 return; 2424 return;
2426 } 2425 }
2427 } else { 2426 } else {
@@ -2435,30 +2434,31 @@ void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr,
2435 2434
2436 if (rtlpriv->sec.key_len[key_index] == 0) { 2435 if (rtlpriv->sec.key_len[key_index] == 0) {
2437 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2436 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2438 ("delete one entry, entry_id is %d\n", 2437 "delete one entry, entry_id is %d\n",
2439 entry_id)); 2438 entry_id);
2440 if (mac->opmode == NL80211_IFTYPE_AP) 2439 if (mac->opmode == NL80211_IFTYPE_AP)
2441 rtl_cam_del_entry(hw, p_macaddr); 2440 rtl_cam_del_entry(hw, p_macaddr);
2442 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id); 2441 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id);
2443 } else { 2442 } else {
2444 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 2443 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
2445 ("The insert KEY length is %d\n", 2444 "The insert KEY length is %d\n",
2446 rtlpriv->sec.key_len[PAIRWISE_KEYIDX])); 2445 rtlpriv->sec.key_len[PAIRWISE_KEYIDX]);
2447 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, 2446 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
2448 ("The insert KEY is %x %x\n", 2447 "The insert KEY is %x %x\n",
2449 rtlpriv->sec.key_buf[0][0], 2448 rtlpriv->sec.key_buf[0][0],
2450 rtlpriv->sec.key_buf[0][1])); 2449 rtlpriv->sec.key_buf[0][1]);
2451 2450
2452 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2451 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2453 ("add one entry\n")); 2452 "add one entry\n");
2454 if (is_pairwise) { 2453 if (is_pairwise) {
2455 RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD, 2454 RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD,
2456 "Pairwiase Key content :", 2455 "Pairwise Key content",
2457 rtlpriv->sec.pairwise_key, 2456 rtlpriv->sec.pairwise_key,
2458 rtlpriv->sec.key_len[PAIRWISE_KEYIDX]); 2457 rtlpriv->sec.
2458 key_len[PAIRWISE_KEYIDX]);
2459 2459
2460 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2460 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2461 ("set Pairwiase key\n")); 2461 "set Pairwise key\n");
2462 2462
2463 rtl_cam_add_one_entry(hw, macaddr, key_index, 2463 rtl_cam_add_one_entry(hw, macaddr, key_index,
2464 entry_id, enc_algo, 2464 entry_id, enc_algo,
@@ -2466,7 +2466,7 @@ void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr,
2466 rtlpriv->sec.key_buf[key_index]); 2466 rtlpriv->sec.key_buf[key_index]);
2467 } else { 2467 } else {
2468 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2468 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2469 ("set group key\n")); 2469 "set group key\n");
2470 2470
2471 if (mac->opmode == NL80211_IFTYPE_ADHOC) { 2471 if (mac->opmode == NL80211_IFTYPE_ADHOC) {
2472 rtl_cam_add_one_entry(hw, 2472 rtl_cam_add_one_entry(hw,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.h b/drivers/net/wireless/rtlwifi/rtl8192se/hw.h
index 6160a9bfe98a..1886c2644a26 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/led.c b/drivers/net/wireless/rtlwifi/rtl8192se/led.c
index e3fe7c90ebf4..44949b5cbb87 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/led.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/led.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -52,8 +52,8 @@ void rtl92se_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
52 u8 ledcfg; 52 u8 ledcfg;
53 struct rtl_priv *rtlpriv = rtl_priv(hw); 53 struct rtl_priv *rtlpriv = rtl_priv(hw);
54 54
55 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, 55 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n",
56 ("LedAddr:%X ledpin=%d\n", LEDCFG, pled->ledpin)); 56 LEDCFG, pled->ledpin);
57 57
58 ledcfg = rtl_read_byte(rtlpriv, LEDCFG); 58 ledcfg = rtl_read_byte(rtlpriv, LEDCFG);
59 59
@@ -68,7 +68,7 @@ void rtl92se_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
68 break; 68 break;
69 default: 69 default:
70 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 70 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
71 ("switch case not process\n")); 71 "switch case not processed\n");
72 break; 72 break;
73 } 73 }
74 pled->ledon = true; 74 pled->ledon = true;
@@ -76,12 +76,15 @@ void rtl92se_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled)
76 76
77void rtl92se_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) 77void rtl92se_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
78{ 78{
79 struct rtl_priv *rtlpriv = rtl_priv(hw); 79 struct rtl_priv *rtlpriv;
80 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); 80 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
81 u8 ledcfg; 81 u8 ledcfg;
82 82
83 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, 83 rtlpriv = rtl_priv(hw);
84 ("LedAddr:%X ledpin=%d\n", LEDCFG, pled->ledpin)); 84 if (!rtlpriv || rtlpriv->max_fw_size)
85 return;
86 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "LedAddr:%X ledpin=%d\n",
87 LEDCFG, pled->ledpin);
85 88
86 ledcfg = rtl_read_byte(rtlpriv, LEDCFG); 89 ledcfg = rtl_read_byte(rtlpriv, LEDCFG);
87 90
@@ -101,7 +104,7 @@ void rtl92se_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled)
101 break; 104 break;
102 default: 105 default:
103 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 106 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
104 ("switch case not process\n")); 107 "switch case not processed\n");
105 break; 108 break;
106 } 109 }
107 pled->ledon = false; 110 pled->ledon = false;
@@ -141,8 +144,7 @@ void rtl92se_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction)
141 ledaction == LED_CTL_POWER_ON)) { 144 ledaction == LED_CTL_POWER_ON)) {
142 return; 145 return;
143 } 146 }
144 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, ("ledaction %d,\n", 147 RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "ledaction %d\n", ledaction);
145 ledaction));
146 148
147 _rtl92se_sw_led_control(hw, ledaction); 149 _rtl92se_sw_led_control(hw, ledaction);
148} 150}
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/led.h b/drivers/net/wireless/rtlwifi/rtl8192se/led.h
index 8cce3870af3c..2182dbeb5f32 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/led.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/led.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
index f10ac1ad9087..05b4e2790e99 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -27,8 +27,6 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
32#include "../wifi.h" 30#include "../wifi.h"
33#include "../pci.h" 31#include "../pci.h"
34#include "../ps.h" 32#include "../ps.h"
@@ -58,16 +56,15 @@ u32 rtl92s_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
58 struct rtl_priv *rtlpriv = rtl_priv(hw); 56 struct rtl_priv *rtlpriv = rtl_priv(hw);
59 u32 returnvalue = 0, originalvalue, bitshift; 57 u32 returnvalue = 0, originalvalue, bitshift;
60 58
61 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)\n", 59 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "regaddr(%#x), bitmask(%#x)\n",
62 regaddr, bitmask)); 60 regaddr, bitmask);
63 61
64 originalvalue = rtl_read_dword(rtlpriv, regaddr); 62 originalvalue = rtl_read_dword(rtlpriv, regaddr);
65 bitshift = _rtl92s_phy_calculate_bit_shift(bitmask); 63 bitshift = _rtl92s_phy_calculate_bit_shift(bitmask);
66 returnvalue = (originalvalue & bitmask) >> bitshift; 64 returnvalue = (originalvalue & bitmask) >> bitshift;
67 65
68 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, 66 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "BBR MASK=0x%x Addr[0x%x]=0x%x\n",
69 ("BBR MASK=0x%x Addr[0x%x]=0x%x\n", 67 bitmask, regaddr, originalvalue);
70 bitmask, regaddr, originalvalue));
71 68
72 return returnvalue; 69 return returnvalue;
73 70
@@ -79,8 +76,9 @@ void rtl92s_phy_set_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask,
79 struct rtl_priv *rtlpriv = rtl_priv(hw); 76 struct rtl_priv *rtlpriv = rtl_priv(hw);
80 u32 originalvalue, bitshift; 77 u32 originalvalue, bitshift;
81 78
82 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," 79 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
83 " data(%#x)\n", regaddr, bitmask, data)); 80 "regaddr(%#x), bitmask(%#x), data(%#x)\n",
81 regaddr, bitmask, data);
84 82
85 if (bitmask != MASKDWORD) { 83 if (bitmask != MASKDWORD) {
86 originalvalue = rtl_read_dword(rtlpriv, regaddr); 84 originalvalue = rtl_read_dword(rtlpriv, regaddr);
@@ -90,8 +88,9 @@ void rtl92s_phy_set_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask,
90 88
91 rtl_write_dword(rtlpriv, regaddr, data); 89 rtl_write_dword(rtlpriv, regaddr, data);
92 90
93 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," 91 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
94 " data(%#x)\n", regaddr, bitmask, data)); 92 "regaddr(%#x), bitmask(%#x), data(%#x)\n",
93 regaddr, bitmask, data);
95 94
96} 95}
97 96
@@ -149,8 +148,8 @@ static u32 _rtl92s_phy_rf_serial_read(struct ieee80211_hw *hw,
149 retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readback, 148 retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readback,
150 BLSSI_READBACK_DATA); 149 BLSSI_READBACK_DATA);
151 150
152 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFR-%d Addr[0x%x]=0x%x\n", 151 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "RFR-%d Addr[0x%x]=0x%x\n",
153 rfpath, pphyreg->rflssi_readback, retvalue)); 152 rfpath, pphyreg->rflssi_readback, retvalue);
154 153
155 return retvalue; 154 return retvalue;
156 155
@@ -172,8 +171,8 @@ static void _rtl92s_phy_rf_serial_write(struct ieee80211_hw *hw,
172 data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff; 171 data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff;
173 rtl_set_bbreg(hw, pphyreg->rf3wire_offset, MASKDWORD, data_and_addr); 172 rtl_set_bbreg(hw, pphyreg->rf3wire_offset, MASKDWORD, data_and_addr);
174 173
175 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFW-%d Addr[0x%x]=0x%x\n", 174 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, "RFW-%d Addr[0x%x]=0x%x\n",
176 rfpath, pphyreg->rf3wire_offset, data_and_addr)); 175 rfpath, pphyreg->rf3wire_offset, data_and_addr);
177} 176}
178 177
179 178
@@ -183,8 +182,9 @@ u32 rtl92s_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
183 struct rtl_priv *rtlpriv = rtl_priv(hw); 182 struct rtl_priv *rtlpriv = rtl_priv(hw);
184 u32 original_value, readback_value, bitshift; 183 u32 original_value, readback_value, bitshift;
185 184
186 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), rfpath(%#x), " 185 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
187 "bitmask(%#x)\n", regaddr, rfpath, bitmask)); 186 "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
187 regaddr, rfpath, bitmask);
188 188
189 spin_lock(&rtlpriv->locks.rf_lock); 189 spin_lock(&rtlpriv->locks.rf_lock);
190 190
@@ -195,9 +195,9 @@ u32 rtl92s_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
195 195
196 spin_unlock(&rtlpriv->locks.rf_lock); 196 spin_unlock(&rtlpriv->locks.rf_lock);
197 197
198 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), rfpath(%#x), " 198 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
199 "bitmask(%#x), original_value(%#x)\n", regaddr, rfpath, 199 "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n",
200 bitmask, original_value)); 200 regaddr, rfpath, bitmask, original_value);
201 201
202 return readback_value; 202 return readback_value;
203} 203}
@@ -212,8 +212,9 @@ void rtl92s_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
212 if (!((rtlphy->rf_pathmap >> rfpath) & 0x1)) 212 if (!((rtlphy->rf_pathmap >> rfpath) & 0x1))
213 return; 213 return;
214 214
215 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," 215 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
216 " data(%#x), rfpath(%#x)\n", regaddr, bitmask, data, rfpath)); 216 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
217 regaddr, bitmask, data, rfpath);
217 218
218 spin_lock(&rtlpriv->locks.rf_lock); 219 spin_lock(&rtlpriv->locks.rf_lock);
219 220
@@ -228,8 +229,9 @@ void rtl92s_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
228 229
229 spin_unlock(&rtlpriv->locks.rf_lock); 230 spin_unlock(&rtlpriv->locks.rf_lock);
230 231
231 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x), " 232 RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
232 "data(%#x), rfpath(%#x)\n", regaddr, bitmask, data, rfpath)); 233 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
234 regaddr, bitmask, data, rfpath);
233 235
234} 236}
235 237
@@ -249,7 +251,7 @@ void rtl92s_phy_scan_operation_backup(struct ieee80211_hw *hw,
249 break; 251 break;
250 default: 252 default:
251 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 253 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
252 ("Unknown operation.\n")); 254 "Unknown operation\n");
253 break; 255 break;
254 } 256 }
255 } 257 }
@@ -264,9 +266,9 @@ void rtl92s_phy_set_bw_mode(struct ieee80211_hw *hw,
264 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 266 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
265 u8 reg_bw_opmode; 267 u8 reg_bw_opmode;
266 268
267 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("Switch to %s bandwidth\n", 269 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "Switch to %s bandwidth\n",
268 rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? 270 rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ?
269 "20MHz" : "40MHz")); 271 "20MHz" : "40MHz");
270 272
271 if (rtlphy->set_bwmode_inprogress) 273 if (rtlphy->set_bwmode_inprogress)
272 return; 274 return;
@@ -290,8 +292,7 @@ void rtl92s_phy_set_bw_mode(struct ieee80211_hw *hw,
290 break; 292 break;
291 default: 293 default:
292 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 294 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
293 ("unknown bandwidth: %#X\n", 295 "unknown bandwidth: %#X\n", rtlphy->current_chan_bw);
294 rtlphy->current_chan_bw));
295 break; 296 break;
296 } 297 }
297 298
@@ -316,13 +317,13 @@ void rtl92s_phy_set_bw_mode(struct ieee80211_hw *hw,
316 break; 317 break;
317 default: 318 default:
318 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 319 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
319 ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); 320 "unknown bandwidth: %#X\n", rtlphy->current_chan_bw);
320 break; 321 break;
321 } 322 }
322 323
323 rtl92s_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw); 324 rtl92s_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw);
324 rtlphy->set_bwmode_inprogress = false; 325 rtlphy->set_bwmode_inprogress = false;
325 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); 326 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n");
326} 327}
327 328
328static bool _rtl92s_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable, 329static bool _rtl92s_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable,
@@ -332,7 +333,7 @@ static bool _rtl92s_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable,
332 struct swchnlcmd *pcmd; 333 struct swchnlcmd *pcmd;
333 334
334 if (cmdtable == NULL) { 335 if (cmdtable == NULL) {
335 RT_ASSERT(false, ("cmdtable cannot be NULL.\n")); 336 RT_ASSERT(false, "cmdtable cannot be NULL\n");
336 return false; 337 return false;
337 } 338 }
338 339
@@ -377,7 +378,7 @@ static bool _rtl92s_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
377 rfdependcmdcnt = 0; 378 rfdependcmdcnt = 0;
378 379
379 RT_ASSERT((channel >= 1 && channel <= 14), 380 RT_ASSERT((channel >= 1 && channel <= 14),
380 ("illegal channel for Zebra: %d\n", channel)); 381 "invalid channel for Zebra: %d\n", channel);
381 382
382 _rtl92s_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++, 383 _rtl92s_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++,
383 MAX_RFDEPENDCMD_CNT, CMDID_RF_WRITEREG, 384 MAX_RFDEPENDCMD_CNT, CMDID_RF_WRITEREG,
@@ -438,7 +439,7 @@ static bool _rtl92s_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
438 break; 439 break;
439 default: 440 default:
440 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 441 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
441 ("switch case not process\n")); 442 "switch case not processed\n");
442 break; 443 break;
443 } 444 }
444 445
@@ -458,9 +459,8 @@ u8 rtl92s_phy_sw_chnl(struct ieee80211_hw *hw)
458 u32 delay; 459 u32 delay;
459 bool ret; 460 bool ret;
460 461
461 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, 462 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "switch to channel%d\n",
462 ("switch to channel%d\n", 463 rtlphy->current_channel);
463 rtlphy->current_channel));
464 464
465 if (rtlphy->sw_chnl_inprogress) 465 if (rtlphy->sw_chnl_inprogress)
466 return 0; 466 return 0;
@@ -496,7 +496,7 @@ u8 rtl92s_phy_sw_chnl(struct ieee80211_hw *hw)
496 496
497 rtlphy->sw_chnl_inprogress = false; 497 rtlphy->sw_chnl_inprogress = false;
498 498
499 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); 499 RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, "<==\n");
500 500
501 return 1; 501 return 1;
502} 502}
@@ -556,7 +556,7 @@ bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw *hw,
556 do { 556 do {
557 InitializeCount++; 557 InitializeCount++;
558 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 558 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
559 ("IPS Set eRf nic enable\n")); 559 "IPS Set eRf nic enable\n");
560 rtstatus = rtl_ps_enable_nic(hw); 560 rtstatus = rtl_ps_enable_nic(hw);
561 } while ((rtstatus != true) && 561 } while ((rtstatus != true) &&
562 (InitializeCount < 10)); 562 (InitializeCount < 10));
@@ -565,11 +565,11 @@ bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw *hw,
565 RT_RF_OFF_LEVL_HALT_NIC); 565 RT_RF_OFF_LEVL_HALT_NIC);
566 } else { 566 } else {
567 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, 567 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
568 ("awake, sleeped:%d ms " 568 "awake, sleeped:%d ms state_inap:%x\n",
569 "state_inap:%x\n", 569 jiffies_to_msecs(jiffies -
570 jiffies_to_msecs(jiffies - 570 ppsc->
571 ppsc->last_sleep_jiffies), 571 last_sleep_jiffies),
572 rtlpriv->psc.state_inap)); 572 rtlpriv->psc.state_inap);
573 ppsc->last_awake_jiffies = jiffies; 573 ppsc->last_awake_jiffies = jiffies;
574 rtl_write_word(rtlpriv, CMDR, 0x37FC); 574 rtl_write_word(rtlpriv, CMDR, 0x37FC);
575 rtl_write_byte(rtlpriv, TXPAUSE, 0x00); 575 rtl_write_byte(rtlpriv, TXPAUSE, 0x00);
@@ -587,7 +587,7 @@ bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw *hw,
587 case ERFOFF:{ 587 case ERFOFF:{
588 if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) { 588 if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) {
589 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, 589 RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
590 ("IPS Set eRf nic disable\n")); 590 "IPS Set eRf nic disable\n");
591 rtl_ps_disable_nic(hw); 591 rtl_ps_disable_nic(hw);
592 RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); 592 RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
593 } else { 593 } else {
@@ -613,11 +613,9 @@ bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw *hw,
613 continue; 613 continue;
614 } else { 614 } else {
615 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 615 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
616 ("eRf Off/Sleep: " 616 "eRf Off/Sleep: %d times TcbBusyQueue[%d] = %d before doze!\n",
617 "%d times TcbBusyQueue[%d] = " 617 i + 1, queue_id,
618 "%d before doze!\n", 618 skb_queue_len(&ring->queue));
619 (i + 1), queue_id,
620 skb_queue_len(&ring->queue)));
621 619
622 udelay(10); 620 udelay(10);
623 i++; 621 i++;
@@ -625,31 +623,30 @@ bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw *hw,
625 623
626 if (i >= MAX_DOZE_WAITING_TIMES_9x) { 624 if (i >= MAX_DOZE_WAITING_TIMES_9x) {
627 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 625 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
628 ("\nERFOFF: %d times" 626 "ERFOFF: %d times TcbBusyQueue[%d] = %d !\n",
629 "TcbBusyQueue[%d] = %d !\n",
630 MAX_DOZE_WAITING_TIMES_9x, 627 MAX_DOZE_WAITING_TIMES_9x,
631 queue_id, 628 queue_id,
632 skb_queue_len(&ring->queue))); 629 skb_queue_len(&ring->queue));
633 break; 630 break;
634 } 631 }
635 } 632 }
636 633
637 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, 634 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
638 ("Set ERFSLEEP awaked:%d ms\n", 635 "Set ERFSLEEP awaked:%d ms\n",
639 jiffies_to_msecs(jiffies - 636 jiffies_to_msecs(jiffies -
640 ppsc->last_awake_jiffies))); 637 ppsc->last_awake_jiffies));
641 638
642 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, 639 RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG,
643 ("sleep awaked:%d ms " 640 "sleep awaked:%d ms state_inap:%x\n",
644 "state_inap:%x\n", jiffies_to_msecs(jiffies - 641 jiffies_to_msecs(jiffies -
645 ppsc->last_awake_jiffies), 642 ppsc->last_awake_jiffies),
646 rtlpriv->psc.state_inap)); 643 rtlpriv->psc.state_inap);
647 ppsc->last_sleep_jiffies = jiffies; 644 ppsc->last_sleep_jiffies = jiffies;
648 _rtl92se_phy_set_rf_sleep(hw); 645 _rtl92se_phy_set_rf_sleep(hw);
649 break; 646 break;
650 default: 647 default:
651 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 648 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
652 ("switch case not process\n")); 649 "switch case not processed\n");
653 bresult = false; 650 bresult = false;
654 break; 651 break;
655 } 652 }
@@ -995,7 +992,7 @@ static bool _rtl92s_phy_bb_config_parafile(struct ieee80211_hw *hw)
995 992
996 if (rtstatus != true) { 993 if (rtstatus != true) {
997 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, 994 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG,
998 ("Write BB Reg Fail!!")); 995 "Write BB Reg Fail!!\n");
999 goto phy_BB8190_Config_ParaFile_Fail; 996 goto phy_BB8190_Config_ParaFile_Fail;
1000 } 997 }
1001 998
@@ -1009,8 +1006,7 @@ static bool _rtl92s_phy_bb_config_parafile(struct ieee80211_hw *hw)
1009 } 1006 }
1010 if (rtstatus != true) { 1007 if (rtstatus != true) {
1011 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, 1008 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG,
1012 ("_rtl92s_phy_bb_config_parafile(): " 1009 "_rtl92s_phy_bb_config_parafile(): BB_PG Reg Fail!!\n");
1013 "BB_PG Reg Fail!!"));
1014 goto phy_BB8190_Config_ParaFile_Fail; 1010 goto phy_BB8190_Config_ParaFile_Fail;
1015 } 1011 }
1016 1012
@@ -1053,7 +1049,7 @@ u8 rtl92s_phy_config_rf(struct ieee80211_hw *hw, enum radio_path rfpath)
1053 radio_b_tblen = RADIOB_ARRAYLENGTH; 1049 radio_b_tblen = RADIOB_ARRAYLENGTH;
1054 } 1050 }
1055 1051
1056 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Radio No %x\n", rfpath)); 1052 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Radio No %x\n", rfpath);
1057 rtstatus = true; 1053 rtstatus = true;
1058 1054
1059 switch (rfpath) { 1055 switch (rfpath) {
@@ -1175,11 +1171,11 @@ bool rtl92s_phy_bb_config(struct ieee80211_hw *hw)
1175 (rtlphy->rf_type == RF_2T2R && rf_num != 2) || 1171 (rtlphy->rf_type == RF_2T2R && rf_num != 2) ||
1176 (rtlphy->rf_type == RF_2T2R_GREEN && rf_num != 2)) { 1172 (rtlphy->rf_type == RF_2T2R_GREEN && rf_num != 2)) {
1177 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, 1173 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG,
1178 ("RF_Type(%x) does not match " 1174 "RF_Type(%x) does not match RF_Num(%x)!!\n",
1179 "RF_Num(%x)!!\n", rtlphy->rf_type, rf_num)); 1175 rtlphy->rf_type, rf_num);
1180 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, 1176 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG,
1181 ("path1 0x%x, path2 0x%x, pathmap " 1177 "path1 0x%x, path2 0x%x, pathmap 0x%x\n",
1182 "0x%x\n", path1, path2, pathmap)); 1178 path1, path2, pathmap);
1183 } 1179 }
1184 1180
1185 return rtstatus; 1181 return rtstatus;
@@ -1214,20 +1210,20 @@ void rtl92s_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw)
1214 ROFDM0_XCAGCCORE1, MASKBYTE0); 1210 ROFDM0_XCAGCCORE1, MASKBYTE0);
1215 rtlphy->default_initialgain[3] = rtl_get_bbreg(hw, 1211 rtlphy->default_initialgain[3] = rtl_get_bbreg(hw,
1216 ROFDM0_XDAGCCORE1, MASKBYTE0); 1212 ROFDM0_XDAGCCORE1, MASKBYTE0);
1217 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Default initial gain " 1213 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1218 "(c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x)\n", 1214 "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x)\n",
1219 rtlphy->default_initialgain[0], 1215 rtlphy->default_initialgain[0],
1220 rtlphy->default_initialgain[1], 1216 rtlphy->default_initialgain[1],
1221 rtlphy->default_initialgain[2], 1217 rtlphy->default_initialgain[2],
1222 rtlphy->default_initialgain[3])); 1218 rtlphy->default_initialgain[3]);
1223 1219
1224 /* read framesync */ 1220 /* read framesync */
1225 rtlphy->framesync = rtl_get_bbreg(hw, ROFDM0_RXDETECTOR3, MASKBYTE0); 1221 rtlphy->framesync = rtl_get_bbreg(hw, ROFDM0_RXDETECTOR3, MASKBYTE0);
1226 rtlphy->framesync_c34 = rtl_get_bbreg(hw, ROFDM0_RXDETECTOR2, 1222 rtlphy->framesync_c34 = rtl_get_bbreg(hw, ROFDM0_RXDETECTOR2,
1227 MASKDWORD); 1223 MASKDWORD);
1228 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1224 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1229 ("Default framesync (0x%x) = 0x%x\n", 1225 "Default framesync (0x%x) = 0x%x\n",
1230 ROFDM0_RXDETECTOR3, rtlphy->framesync)); 1226 ROFDM0_RXDETECTOR3, rtlphy->framesync);
1231 1227
1232} 1228}
1233 1229
@@ -1287,10 +1283,9 @@ void rtl92s_phy_set_txpower(struct ieee80211_hw *hw, u8 channel)
1287 &ofdmpowerLevel[0]); 1283 &ofdmpowerLevel[0]);
1288 1284
1289 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 1285 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
1290 ("Channel-%d, cckPowerLevel (A / B) = " 1286 "Channel-%d, cckPowerLevel (A / B) = 0x%x / 0x%x, ofdmPowerLevel (A / B) = 0x%x / 0x%x\n",
1291 "0x%x / 0x%x, ofdmPowerLevel (A / B) = 0x%x / 0x%x\n", 1287 channel, cckpowerlevel[0], cckpowerlevel[1],
1292 channel, cckpowerlevel[0], cckpowerlevel[1], 1288 ofdmpowerLevel[0], ofdmpowerLevel[1]);
1293 ofdmpowerLevel[0], ofdmpowerLevel[1]));
1294 1289
1295 _rtl92s_phy_ccxpower_indexcheck(hw, channel, &cckpowerlevel[0], 1290 _rtl92s_phy_ccxpower_indexcheck(hw, channel, &cckpowerlevel[0],
1296 &ofdmpowerLevel[0]); 1291 &ofdmpowerLevel[0]);
@@ -1316,7 +1311,7 @@ void rtl92s_phy_chk_fwcmd_iodone(struct ieee80211_hw *hw)
1316 } while (--pollingcnt); 1311 } while (--pollingcnt);
1317 1312
1318 if (pollingcnt == 0) 1313 if (pollingcnt == 0)
1319 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Set FW Cmd fail!!\n")); 1314 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Set FW Cmd fail!!\n");
1320} 1315}
1321 1316
1322 1317
@@ -1345,20 +1340,17 @@ static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw *hw)
1345 1340
1346 switch (rtlhal->current_fwcmd_io) { 1341 switch (rtlhal->current_fwcmd_io) {
1347 case FW_CMD_RA_RESET: 1342 case FW_CMD_RA_RESET:
1348 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, 1343 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_RA_RESET\n");
1349 ("FW_CMD_RA_RESET\n"));
1350 rtl_write_dword(rtlpriv, WFM5, FW_RA_RESET); 1344 rtl_write_dword(rtlpriv, WFM5, FW_RA_RESET);
1351 rtl92s_phy_chk_fwcmd_iodone(hw); 1345 rtl92s_phy_chk_fwcmd_iodone(hw);
1352 break; 1346 break;
1353 case FW_CMD_RA_ACTIVE: 1347 case FW_CMD_RA_ACTIVE:
1354 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, 1348 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_RA_ACTIVE\n");
1355 ("FW_CMD_RA_ACTIVE\n"));
1356 rtl_write_dword(rtlpriv, WFM5, FW_RA_ACTIVE); 1349 rtl_write_dword(rtlpriv, WFM5, FW_RA_ACTIVE);
1357 rtl92s_phy_chk_fwcmd_iodone(hw); 1350 rtl92s_phy_chk_fwcmd_iodone(hw);
1358 break; 1351 break;
1359 case FW_CMD_RA_REFRESH_N: 1352 case FW_CMD_RA_REFRESH_N:
1360 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, 1353 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_RA_REFRESH_N\n");
1361 ("FW_CMD_RA_REFRESH_N\n"));
1362 input = FW_RA_REFRESH; 1354 input = FW_RA_REFRESH;
1363 rtl_write_dword(rtlpriv, WFM5, input); 1355 rtl_write_dword(rtlpriv, WFM5, input);
1364 rtl92s_phy_chk_fwcmd_iodone(hw); 1356 rtl92s_phy_chk_fwcmd_iodone(hw);
@@ -1367,7 +1359,7 @@ static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw *hw)
1367 break; 1359 break;
1368 case FW_CMD_RA_REFRESH_BG: 1360 case FW_CMD_RA_REFRESH_BG:
1369 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, 1361 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG,
1370 ("FW_CMD_RA_REFRESH_BG\n")); 1362 "FW_CMD_RA_REFRESH_BG\n");
1371 rtl_write_dword(rtlpriv, WFM5, FW_RA_REFRESH); 1363 rtl_write_dword(rtlpriv, WFM5, FW_RA_REFRESH);
1372 rtl92s_phy_chk_fwcmd_iodone(hw); 1364 rtl92s_phy_chk_fwcmd_iodone(hw);
1373 rtl_write_dword(rtlpriv, WFM5, FW_RA_DISABLE_RSSI_MASK); 1365 rtl_write_dword(rtlpriv, WFM5, FW_RA_DISABLE_RSSI_MASK);
@@ -1375,21 +1367,20 @@ static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw *hw)
1375 break; 1367 break;
1376 case FW_CMD_RA_REFRESH_N_COMB: 1368 case FW_CMD_RA_REFRESH_N_COMB:
1377 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, 1369 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG,
1378 ("FW_CMD_RA_REFRESH_N_COMB\n")); 1370 "FW_CMD_RA_REFRESH_N_COMB\n");
1379 input = FW_RA_IOT_N_COMB; 1371 input = FW_RA_IOT_N_COMB;
1380 rtl_write_dword(rtlpriv, WFM5, input); 1372 rtl_write_dword(rtlpriv, WFM5, input);
1381 rtl92s_phy_chk_fwcmd_iodone(hw); 1373 rtl92s_phy_chk_fwcmd_iodone(hw);
1382 break; 1374 break;
1383 case FW_CMD_RA_REFRESH_BG_COMB: 1375 case FW_CMD_RA_REFRESH_BG_COMB:
1384 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, 1376 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG,
1385 ("FW_CMD_RA_REFRESH_BG_COMB\n")); 1377 "FW_CMD_RA_REFRESH_BG_COMB\n");
1386 input = FW_RA_IOT_BG_COMB; 1378 input = FW_RA_IOT_BG_COMB;
1387 rtl_write_dword(rtlpriv, WFM5, input); 1379 rtl_write_dword(rtlpriv, WFM5, input);
1388 rtl92s_phy_chk_fwcmd_iodone(hw); 1380 rtl92s_phy_chk_fwcmd_iodone(hw);
1389 break; 1381 break;
1390 case FW_CMD_IQK_ENABLE: 1382 case FW_CMD_IQK_ENABLE:
1391 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, 1383 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_IQK_ENABLE\n");
1392 ("FW_CMD_IQK_ENABLE\n"));
1393 rtl_write_dword(rtlpriv, WFM5, FW_IQK_ENABLE); 1384 rtl_write_dword(rtlpriv, WFM5, FW_IQK_ENABLE);
1394 rtl92s_phy_chk_fwcmd_iodone(hw); 1385 rtl92s_phy_chk_fwcmd_iodone(hw);
1395 break; 1386 break;
@@ -1424,8 +1415,7 @@ static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw *hw)
1424 rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, 0xcd); 1415 rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, 0xcd);
1425 break; 1416 break;
1426 case FW_CMD_LPS_ENTER: 1417 case FW_CMD_LPS_ENTER:
1427 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, 1418 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_LPS_ENTER\n");
1428 ("FW_CMD_LPS_ENTER\n"));
1429 current_aid = rtlpriv->mac80211.assoc_id; 1419 current_aid = rtlpriv->mac80211.assoc_id;
1430 rtl_write_dword(rtlpriv, WFM5, (FW_LPS_ENTER | 1420 rtl_write_dword(rtlpriv, WFM5, (FW_LPS_ENTER |
1431 ((current_aid | 0xc000) << 8))); 1421 ((current_aid | 0xc000) << 8)));
@@ -1434,20 +1424,18 @@ static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw *hw)
1434 * turbo mode until driver leave LPS */ 1424 * turbo mode until driver leave LPS */
1435 break; 1425 break;
1436 case FW_CMD_LPS_LEAVE: 1426 case FW_CMD_LPS_LEAVE:
1437 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, 1427 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_LPS_LEAVE\n");
1438 ("FW_CMD_LPS_LEAVE\n"));
1439 rtl_write_dword(rtlpriv, WFM5, FW_LPS_LEAVE); 1428 rtl_write_dword(rtlpriv, WFM5, FW_LPS_LEAVE);
1440 rtl92s_phy_chk_fwcmd_iodone(hw); 1429 rtl92s_phy_chk_fwcmd_iodone(hw);
1441 break; 1430 break;
1442 case FW_CMD_ADD_A2_ENTRY: 1431 case FW_CMD_ADD_A2_ENTRY:
1443 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, 1432 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_ADD_A2_ENTRY\n");
1444 ("FW_CMD_ADD_A2_ENTRY\n"));
1445 rtl_write_dword(rtlpriv, WFM5, FW_ADD_A2_ENTRY); 1433 rtl_write_dword(rtlpriv, WFM5, FW_ADD_A2_ENTRY);
1446 rtl92s_phy_chk_fwcmd_iodone(hw); 1434 rtl92s_phy_chk_fwcmd_iodone(hw);
1447 break; 1435 break;
1448 case FW_CMD_CTRL_DM_BY_DRIVER: 1436 case FW_CMD_CTRL_DM_BY_DRIVER:
1449 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 1437 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
1450 ("FW_CMD_CTRL_DM_BY_DRIVER\n")); 1438 "FW_CMD_CTRL_DM_BY_DRIVER\n");
1451 rtl_write_dword(rtlpriv, WFM5, FW_CTRL_DM_BY_DRIVER); 1439 rtl_write_dword(rtlpriv, WFM5, FW_CTRL_DM_BY_DRIVER);
1452 rtl92s_phy_chk_fwcmd_iodone(hw); 1440 rtl92s_phy_chk_fwcmd_iodone(hw);
1453 break; 1441 break;
@@ -1472,8 +1460,8 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio)
1472 bool bPostProcessing = false; 1460 bool bPostProcessing = false;
1473 1461
1474 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 1462 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
1475 ("Set FW Cmd(%#x), set_fwcmd_inprogress(%d)\n", 1463 "Set FW Cmd(%#x), set_fwcmd_inprogress(%d)\n",
1476 fw_cmdio, rtlhal->set_fwcmd_inprogress)); 1464 fw_cmdio, rtlhal->set_fwcmd_inprogress);
1477 1465
1478 do { 1466 do {
1479 /* We re-map to combined FW CMD ones if firmware version */ 1467 /* We re-map to combined FW CMD ones if firmware version */
@@ -1501,7 +1489,7 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio)
1501 * DM map table in the future. */ 1489 * DM map table in the future. */
1502 switch (fw_cmdio) { 1490 switch (fw_cmdio) {
1503 case FW_CMD_RA_INIT: 1491 case FW_CMD_RA_INIT:
1504 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("RA init!!\n")); 1492 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "RA init!!\n");
1505 fw_cmdmap |= FW_RA_INIT_CTL; 1493 fw_cmdmap |= FW_RA_INIT_CTL;
1506 FW_CMD_IO_SET(rtlpriv, fw_cmdmap); 1494 FW_CMD_IO_SET(rtlpriv, fw_cmdmap);
1507 /* Clear control flag to sync with FW. */ 1495 /* Clear control flag to sync with FW. */
@@ -1509,7 +1497,7 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio)
1509 break; 1497 break;
1510 case FW_CMD_DIG_DISABLE: 1498 case FW_CMD_DIG_DISABLE:
1511 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 1499 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
1512 ("Set DIG disable!!\n")); 1500 "Set DIG disable!!\n");
1513 fw_cmdmap &= ~FW_DIG_ENABLE_CTL; 1501 fw_cmdmap &= ~FW_DIG_ENABLE_CTL;
1514 FW_CMD_IO_SET(rtlpriv, fw_cmdmap); 1502 FW_CMD_IO_SET(rtlpriv, fw_cmdmap);
1515 break; 1503 break;
@@ -1517,14 +1505,14 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio)
1517 case FW_CMD_DIG_RESUME: 1505 case FW_CMD_DIG_RESUME:
1518 if (!(rtlpriv->dm.dm_flag & HAL_DM_DIG_DISABLE)) { 1506 if (!(rtlpriv->dm.dm_flag & HAL_DM_DIG_DISABLE)) {
1519 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 1507 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
1520 ("Set DIG enable or resume!!\n")); 1508 "Set DIG enable or resume!!\n");
1521 fw_cmdmap |= (FW_DIG_ENABLE_CTL | FW_SS_CTL); 1509 fw_cmdmap |= (FW_DIG_ENABLE_CTL | FW_SS_CTL);
1522 FW_CMD_IO_SET(rtlpriv, fw_cmdmap); 1510 FW_CMD_IO_SET(rtlpriv, fw_cmdmap);
1523 } 1511 }
1524 break; 1512 break;
1525 case FW_CMD_DIG_HALT: 1513 case FW_CMD_DIG_HALT:
1526 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 1514 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
1527 ("Set DIG halt!!\n")); 1515 "Set DIG halt!!\n");
1528 fw_cmdmap &= ~(FW_DIG_ENABLE_CTL | FW_SS_CTL); 1516 fw_cmdmap &= ~(FW_DIG_ENABLE_CTL | FW_SS_CTL);
1529 FW_CMD_IO_SET(rtlpriv, fw_cmdmap); 1517 FW_CMD_IO_SET(rtlpriv, fw_cmdmap);
1530 break; 1518 break;
@@ -1540,9 +1528,8 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio)
1540 (rtlefuse->thermalmeter[0] << 16)); 1528 (rtlefuse->thermalmeter[0] << 16));
1541 1529
1542 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 1530 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
1543 ("Set TxPwr tracking!! " 1531 "Set TxPwr tracking!! FwCmdMap(%#x), FwParam(%#x)\n",
1544 "FwCmdMap(%#x), FwParam(%#x)\n", 1532 fw_cmdmap, fw_param);
1545 fw_cmdmap, fw_param));
1546 1533
1547 FW_CMD_PARA_SET(rtlpriv, fw_param); 1534 FW_CMD_PARA_SET(rtlpriv, fw_param);
1548 FW_CMD_IO_SET(rtlpriv, fw_cmdmap); 1535 FW_CMD_IO_SET(rtlpriv, fw_cmdmap);
@@ -1563,9 +1550,8 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio)
1563 fw_param &= FW_RA_PARAM_CLR; 1550 fw_param &= FW_RA_PARAM_CLR;
1564 1551
1565 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 1552 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
1566 ("[FW CMD] [New Version] " 1553 "[FW CMD] [New Version] Set RA/IOT Comb in n mode!! FwCmdMap(%#x), FwParam(%#x)\n",
1567 "Set RA/IOT Comb in n mode!! FwCmdMap(%#x), " 1554 fw_cmdmap, fw_param);
1568 "FwParam(%#x)\n", fw_cmdmap, fw_param));
1569 1555
1570 FW_CMD_PARA_SET(rtlpriv, fw_param); 1556 FW_CMD_PARA_SET(rtlpriv, fw_param);
1571 FW_CMD_IO_SET(rtlpriv, fw_cmdmap); 1557 FW_CMD_IO_SET(rtlpriv, fw_cmdmap);
@@ -1652,7 +1638,7 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio)
1652 break; 1638 break;
1653 case FW_CMD_PAPE_CONTROL: 1639 case FW_CMD_PAPE_CONTROL:
1654 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 1640 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
1655 ("[FW CMD] Set PAPE Control\n")); 1641 "[FW CMD] Set PAPE Control\n");
1656 fw_cmdmap &= ~FW_PAPE_CTL_BY_SW_HW; 1642 fw_cmdmap &= ~FW_PAPE_CTL_BY_SW_HW;
1657 1643
1658 FW_CMD_IO_SET(rtlpriv, fw_cmdmap); 1644 FW_CMD_IO_SET(rtlpriv, fw_cmdmap);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.h b/drivers/net/wireless/rtlwifi/rtl8192se/phy.h
index 37e504af6446..ac0387770630 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/reg.h b/drivers/net/wireless/rtlwifi/rtl8192se/reg.h
index 11f125c030ce..84d1181795b8 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/reg.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/reg.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c
index 0ad50fe44aa2..ad51906124db 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/rf.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/rf.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -27,8 +27,6 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
32#include "../wifi.h" 30#include "../wifi.h"
33#include "reg.h" 31#include "reg.h"
34#include "def.h" 32#include "def.h"
@@ -123,13 +121,13 @@ static void _rtl92s_get_powerbase(struct ieee80211_hw *hw, u8 *p_pwrlevel,
123 } 121 }
124 122
125 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { 123 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) {
126 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("40MHz finalpwr_idx " 124 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
127 "(A / B) = 0x%x / 0x%x\n", p_final_pwridx[0], 125 "40MHz finalpwr_idx (A / B) = 0x%x / 0x%x\n",
128 p_final_pwridx[1])); 126 p_final_pwridx[0], p_final_pwridx[1]);
129 } else { 127 } else {
130 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("20MHz finalpwr_idx " 128 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
131 "(A / B) = 0x%x / 0x%x\n", p_final_pwridx[0], 129 "20MHz finalpwr_idx (A / B) = 0x%x / 0x%x\n",
132 p_final_pwridx[1])); 130 p_final_pwridx[0], p_final_pwridx[1]);
133 } 131 }
134} 132}
135 133
@@ -153,9 +151,8 @@ static void _rtl92s_set_antennadiff(struct ieee80211_hw *hw,
153 ant_pwr_diff = -8; 151 ant_pwr_diff = -8;
154 152
155 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 153 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
156 ("Antenna Diff from RF-B " 154 "Antenna Diff from RF-B to RF-A = %d (0x%x)\n",
157 "to RF-A = %d (0x%x)\n", ant_pwr_diff, 155 ant_pwr_diff, ant_pwr_diff & 0xf);
158 ant_pwr_diff & 0xf));
159 156
160 ant_pwr_diff &= 0xf; 157 ant_pwr_diff &= 0xf;
161 } 158 }
@@ -172,9 +169,8 @@ static void _rtl92s_set_antennadiff(struct ieee80211_hw *hw,
172 rtl_set_bbreg(hw, RFPGA0_TXGAINSTAGE, (BXBTXAGC | BXCTXAGC | BXDTXAGC), 169 rtl_set_bbreg(hw, RFPGA0_TXGAINSTAGE, (BXBTXAGC | BXCTXAGC | BXDTXAGC),
173 u4reg_val); 170 u4reg_val);
174 171
175 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 172 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "Write BCD-Diff(0x%x) = 0x%x\n",
176 ("Write BCD-Diff(0x%x) = 0x%x\n", 173 RFPGA0_TXGAINSTAGE, u4reg_val);
177 RFPGA0_TXGAINSTAGE, u4reg_val));
178} 174}
179 175
180static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw, 176static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw,
@@ -201,8 +197,7 @@ static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw,
201 ((index < 2) ? pwrbase0 : pwrbase1); 197 ((index < 2) ? pwrbase0 : pwrbase1);
202 198
203 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 199 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
204 ("RTK better performance, " 200 "RTK better performance, writeval = 0x%x\n", writeval);
205 "writeval = 0x%x\n", writeval));
206 break; 201 break;
207 case 1: 202 case 1:
208 /* Realtek regulatory increase power diff defined 203 /* Realtek regulatory increase power diff defined
@@ -211,8 +206,8 @@ static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw,
211 writeval = ((index < 2) ? pwrbase0 : pwrbase1); 206 writeval = ((index < 2) ? pwrbase0 : pwrbase1);
212 207
213 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 208 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
214 ("Realtek regulatory, " 209 "Realtek regulatory, 40MHz, writeval = 0x%x\n",
215 "40MHz, writeval = 0x%x\n", writeval)); 210 writeval);
216 } else { 211 } else {
217 if (rtlphy->pwrgroup_cnt == 1) 212 if (rtlphy->pwrgroup_cnt == 1)
218 chnlgroup = 0; 213 chnlgroup = 0;
@@ -234,16 +229,15 @@ static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw,
234 pwrbase0 : pwrbase1); 229 pwrbase0 : pwrbase1);
235 230
236 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 231 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
237 ("Realtek regulatory, " 232 "Realtek regulatory, 20MHz, writeval = 0x%x\n",
238 "20MHz, writeval = 0x%x\n", writeval)); 233 writeval);
239 } 234 }
240 break; 235 break;
241 case 2: 236 case 2:
242 /* Better regulatory don't increase any power diff */ 237 /* Better regulatory don't increase any power diff */
243 writeval = ((index < 2) ? pwrbase0 : pwrbase1); 238 writeval = ((index < 2) ? pwrbase0 : pwrbase1);
244 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 239 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
245 ("Better regulatory, " 240 "Better regulatory, writeval = 0x%x\n", writeval);
246 "writeval = 0x%x\n", writeval));
247 break; 241 break;
248 case 3: 242 case 3:
249 /* Customer defined power diff. increase power diff 243 /* Customer defined power diff. increase power diff
@@ -252,14 +246,14 @@ static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw,
252 246
253 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { 247 if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) {
254 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 248 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
255 ("customer's limit, 40MHz = 0x%x\n", 249 "customer's limit, 40MHz = 0x%x\n",
256 rtlefuse->pwrgroup_ht40 250 rtlefuse->pwrgroup_ht40
257 [RF90_PATH_A][chnl - 1])); 251 [RF90_PATH_A][chnl - 1]);
258 } else { 252 } else {
259 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 253 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
260 ("customer's limit, 20MHz = 0x%x\n", 254 "customer's limit, 20MHz = 0x%x\n",
261 rtlefuse->pwrgroup_ht20 255 rtlefuse->pwrgroup_ht20
262 [RF90_PATH_A][chnl - 1])); 256 [RF90_PATH_A][chnl - 1]);
263 } 257 }
264 258
265 for (i = 0; i < 4; i++) { 259 for (i = 0; i < 4; i++) {
@@ -293,22 +287,19 @@ static void _rtl92s_get_txpower_writeval_byregulatory(struct ieee80211_hw *hw,
293 (pwrdiff_limit[1] << 8) | 287 (pwrdiff_limit[1] << 8) |
294 (pwrdiff_limit[0]); 288 (pwrdiff_limit[0]);
295 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 289 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
296 ("Customer's limit = 0x%x\n", 290 "Customer's limit = 0x%x\n", customer_limit);
297 customer_limit));
298 291
299 writeval = customer_limit + ((index < 2) ? 292 writeval = customer_limit + ((index < 2) ?
300 pwrbase0 : pwrbase1); 293 pwrbase0 : pwrbase1);
301 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 294 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
302 ("Customer, writeval = " 295 "Customer, writeval = 0x%x\n", writeval);
303 "0x%x\n", writeval));
304 break; 296 break;
305 default: 297 default:
306 chnlgroup = 0; 298 chnlgroup = 0;
307 writeval = rtlphy->mcs_txpwrlevel_origoffset[chnlgroup][index] + 299 writeval = rtlphy->mcs_txpwrlevel_origoffset[chnlgroup][index] +
308 ((index < 2) ? pwrbase0 : pwrbase1); 300 ((index < 2) ? pwrbase0 : pwrbase1);
309 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, 301 RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
310 ("RTK better performance, " 302 "RTK better performance, writeval = 0x%x\n", writeval);
311 "writeval = 0x%x\n", writeval));
312 break; 303 break;
313 } 304 }
314 305
@@ -541,8 +532,7 @@ void rtl92s_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, u8 bandwidth)
541 break; 532 break;
542 default: 533 default:
543 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 534 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
544 ("unknown bandwidth: %#X\n", 535 "unknown bandwidth: %#X\n", bandwidth);
545 bandwidth));
546 break; 536 break;
547 } 537 }
548} 538}
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/rf.h b/drivers/net/wireless/rtlwifi/rtl8192se/rf.h
index 3843baa1a874..8a29eb94ab17 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/rf.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/rf.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
index 78723cf59491..eda30b9d0f15 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -27,14 +27,11 @@
27 * 27 *
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
32#include <linux/vmalloc.h>
33#include <linux/module.h>
34
35#include "../wifi.h" 30#include "../wifi.h"
36#include "../core.h" 31#include "../core.h"
37#include "../pci.h" 32#include "../pci.h"
33#include "../base.h"
34#include "../pci.h"
38#include "reg.h" 35#include "reg.h"
39#include "def.h" 36#include "def.h"
40#include "phy.h" 37#include "phy.h"
@@ -45,6 +42,8 @@
45#include "trx.h" 42#include "trx.h"
46#include "led.h" 43#include "led.h"
47 44
45#include <linux/module.h>
46
48static void rtl92s_init_aspm_vars(struct ieee80211_hw *hw) 47static void rtl92s_init_aspm_vars(struct ieee80211_hw *hw)
49{ 48{
50 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 49 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
@@ -89,12 +88,53 @@ static void rtl92s_init_aspm_vars(struct ieee80211_hw *hw)
89 rtlpci->const_support_pciaspm = 2; 88 rtlpci->const_support_pciaspm = 2;
90} 89}
91 90
91static void rtl92se_fw_cb(const struct firmware *firmware, void *context)
92{
93 struct ieee80211_hw *hw = context;
94 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
95 struct rtl_priv *rtlpriv = rtl_priv(hw);
96 struct rtl_pci *rtlpci = rtl_pcidev(pcipriv);
97 struct rt_firmware *pfirmware = NULL;
98 int err;
99
100 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
101 "Firmware callback routine entered!\n");
102 complete(&rtlpriv->firmware_loading_complete);
103 if (!firmware) {
104 pr_err("Firmware %s not available\n", rtlpriv->cfg->fw_name);
105 rtlpriv->max_fw_size = 0;
106 return;
107 }
108 if (firmware->size > rtlpriv->max_fw_size) {
109 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
110 "Firmware is too big!\n");
111 release_firmware(firmware);
112 return;
113 }
114 pfirmware = (struct rt_firmware *)rtlpriv->rtlhal.pfirmware;
115 memcpy(pfirmware->sz_fw_tmpbuffer, firmware->data, firmware->size);
116 pfirmware->sz_fw_tmpbufferlen = firmware->size;
117 release_firmware(firmware);
118
119 err = ieee80211_register_hw(hw);
120 if (err) {
121 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
122 "Can't register mac80211 hw\n");
123 return;
124 } else {
125 rtlpriv->mac80211.mac80211_registered = 1;
126 }
127 rtlpci->irq_alloc = 1;
128 set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
129
130 /*init rfkill */
131 rtl_init_rfkill(hw);
132}
133
92static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) 134static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
93{ 135{
94 struct rtl_priv *rtlpriv = rtl_priv(hw); 136 struct rtl_priv *rtlpriv = rtl_priv(hw);
95 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 137 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
96 const struct firmware *firmware;
97 struct rt_firmware *pfirmware = NULL;
98 int err = 0; 138 int err = 0;
99 u16 earlyrxthreshold = 7; 139 u16 earlyrxthreshold = 7;
100 140
@@ -168,9 +208,9 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
168 rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps; 208 rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps;
169 rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps; 209 rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps;
170 if (!rtlpriv->psc.inactiveps) 210 if (!rtlpriv->psc.inactiveps)
171 pr_info("rtl8192ce: Power Save off (module option)\n"); 211 pr_info("Power Save off (module option)\n");
172 if (!rtlpriv->psc.fwctrl_lps) 212 if (!rtlpriv->psc.fwctrl_lps)
173 pr_info("rtl8192ce: FW Power Save off (module option)\n"); 213 pr_info("FW Power Save off (module option)\n");
174 rtlpriv->psc.reg_fwctrl_lps = 3; 214 rtlpriv->psc.reg_fwctrl_lps = 3;
175 rtlpriv->psc.reg_max_lps_awakeintvl = 5; 215 rtlpriv->psc.reg_max_lps_awakeintvl = 5;
176 /* for ASPM, you can close aspm through 216 /* for ASPM, you can close aspm through
@@ -186,33 +226,22 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
186 226
187 /* for firmware buf */ 227 /* for firmware buf */
188 rtlpriv->rtlhal.pfirmware = vzalloc(sizeof(struct rt_firmware)); 228 rtlpriv->rtlhal.pfirmware = vzalloc(sizeof(struct rt_firmware));
189 if (!rtlpriv->rtlhal.pfirmware) { 229 if (!rtlpriv->rtlhal.pfirmware)
190 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
191 ("Can't alloc buffer for fw.\n"));
192 return 1; 230 return 1;
193 } 231
232 rtlpriv->max_fw_size = sizeof(struct rt_firmware);
194 233
195 pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n" 234 pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n"
196 "Loading firmware %s\n", rtlpriv->cfg->fw_name); 235 "Loading firmware %s\n", rtlpriv->cfg->fw_name);
197 /* request fw */ 236 /* request fw */
198 err = request_firmware(&firmware, rtlpriv->cfg->fw_name, 237 err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name,
199 rtlpriv->io.dev); 238 rtlpriv->io.dev, GFP_KERNEL, hw,
239 rtl92se_fw_cb);
200 if (err) { 240 if (err) {
201 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 241 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
202 ("Failed to request firmware!\n")); 242 "Failed to request firmware!\n");
203 return 1; 243 return 1;
204 } 244 }
205 if (firmware->size > sizeof(struct rt_firmware)) {
206 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
207 ("Firmware is too big!\n"));
208 release_firmware(firmware);
209 return 1;
210 }
211
212 pfirmware = (struct rt_firmware *)rtlpriv->rtlhal.pfirmware;
213 memcpy(pfirmware->sz_fw_tmpbuffer, firmware->data, firmware->size);
214 pfirmware->sz_fw_tmpbufferlen = firmware->size;
215 release_firmware(firmware);
216 245
217 return err; 246 return err;
218} 247}
@@ -426,7 +455,7 @@ static int __init rtl92se_module_init(void)
426 455
427 ret = pci_register_driver(&rtl92se_driver); 456 ret = pci_register_driver(&rtl92se_driver);
428 if (ret) 457 if (ret)
429 RT_ASSERT(false, (": No device found\n")); 458 RT_ASSERT(false, "No device found\n");
430 459
431 return ret; 460 return ret;
432} 461}
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.h b/drivers/net/wireless/rtlwifi/rtl8192se/sw.h
index fc4eb285a0ac..2eb88862ebe4 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/table.c b/drivers/net/wireless/rtlwifi/rtl8192se/table.c
index 154185b3969d..f1a73f75127e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/table.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/table.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/table.h b/drivers/net/wireless/rtlwifi/rtl8192se/table.h
index b4ed6d951ebb..2feb73b71a4f 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/table.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/table.h
@@ -1,5 +1,5 @@
1/****************************************************************************** 1/******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. 2 * Copyright(c) 2008 - 2012 Realtek Corporation. All rights reserved.
3 * 3 *
4 * This program is distributed in the hope that it will be useful, but WITHOUT 4 * This program is distributed in the hope that it will be useful, but WITHOUT
5 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
index fbebe3ea0a22..2fd3d13b7ced 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -756,7 +756,7 @@ void rtl92se_tx_fill_desc(struct ieee80211_hw *hw,
756 /* DOWRD 8 */ 756 /* DOWRD 8 */
757 SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, cpu_to_le32(mapping)); 757 SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, cpu_to_le32(mapping));
758 758
759 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, ("\n")); 759 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "\n");
760} 760}
761 761
762void rtl92se_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc, 762void rtl92se_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc,
@@ -823,8 +823,8 @@ void rtl92se_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val)
823 SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *) val); 823 SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *) val);
824 break; 824 break;
825 default: 825 default:
826 RT_ASSERT(false, ("ERR txdesc :%d not process\n", 826 RT_ASSERT(false, "ERR txdesc :%d not process\n",
827 desc_name)); 827 desc_name);
828 break; 828 break;
829 } 829 }
830 } else { 830 } else {
@@ -843,8 +843,8 @@ void rtl92se_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val)
843 SET_RX_STATUS_DESC_EOR(pdesc, 1); 843 SET_RX_STATUS_DESC_EOR(pdesc, 1);
844 break; 844 break;
845 default: 845 default:
846 RT_ASSERT(false, ("ERR rxdesc :%d not process\n", 846 RT_ASSERT(false, "ERR rxdesc :%d not process\n",
847 desc_name)); 847 desc_name);
848 break; 848 break;
849 } 849 }
850 } 850 }
@@ -863,8 +863,8 @@ u32 rtl92se_get_desc(u8 *desc, bool istx, u8 desc_name)
863 ret = GET_TX_DESC_TX_BUFFER_ADDRESS(desc); 863 ret = GET_TX_DESC_TX_BUFFER_ADDRESS(desc);
864 break; 864 break;
865 default: 865 default:
866 RT_ASSERT(false, ("ERR txdesc :%d not process\n", 866 RT_ASSERT(false, "ERR txdesc :%d not process\n",
867 desc_name)); 867 desc_name);
868 break; 868 break;
869 } 869 }
870 } else { 870 } else {
@@ -876,8 +876,8 @@ u32 rtl92se_get_desc(u8 *desc, bool istx, u8 desc_name)
876 ret = GET_RX_STATUS_DESC_PKT_LEN(desc); 876 ret = GET_RX_STATUS_DESC_PKT_LEN(desc);
877 break; 877 break;
878 default: 878 default:
879 RT_ASSERT(false, ("ERR rxdesc :%d not process\n", 879 RT_ASSERT(false, "ERR rxdesc :%d not process\n",
880 desc_name)); 880 desc_name);
881 break; 881 break;
882 } 882 }
883 } 883 }
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.h b/drivers/net/wireless/rtlwifi/rtl8192se/trx.h
index 05862c51b861..011e7b0695f2 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index e956fa71d040..ffcf89fe45e4 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2011 Realtek Corporation. All rights reserved. 3 * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -25,16 +25,13 @@
25 * 25 *
26 *****************************************************************************/ 26 *****************************************************************************/
27 27
28#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
29
30#include <linux/usb.h>
31#include <linux/export.h>
32#include "core.h"
33#include "wifi.h" 28#include "wifi.h"
29#include "core.h"
34#include "usb.h" 30#include "usb.h"
35#include "base.h" 31#include "base.h"
36#include "ps.h" 32#include "ps.h"
37#include "rtl8192c/fw_common.h" 33#include "rtl8192c/fw_common.h"
34#include <linux/export.h>
38 35
39#define REALTEK_USB_VENQT_READ 0xC0 36#define REALTEK_USB_VENQT_READ 0xC0
40#define REALTEK_USB_VENQT_WRITE 0x40 37#define REALTEK_USB_VENQT_WRITE 0x40
@@ -276,14 +273,14 @@ static int _rtl_usb_init_tx(struct ieee80211_hw *hw)
276 ? USB_HIGH_SPEED_BULK_SIZE 273 ? USB_HIGH_SPEED_BULK_SIZE
277 : USB_FULL_SPEED_BULK_SIZE; 274 : USB_FULL_SPEED_BULK_SIZE;
278 275
279 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("USB Max Bulk-out Size=%d\n", 276 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "USB Max Bulk-out Size=%d\n",
280 rtlusb->max_bulk_out_size)); 277 rtlusb->max_bulk_out_size);
281 278
282 for (i = 0; i < __RTL_TXQ_NUM; i++) { 279 for (i = 0; i < __RTL_TXQ_NUM; i++) {
283 u32 ep_num = rtlusb->ep_map.ep_mapping[i]; 280 u32 ep_num = rtlusb->ep_map.ep_mapping[i];
284 if (!ep_num) { 281 if (!ep_num) {
285 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 282 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
286 ("Invalid endpoint map setting!\n")); 283 "Invalid endpoint map setting!\n");
287 return -EINVAL; 284 return -EINVAL;
288 } 285 }
289 } 286 }
@@ -345,9 +342,9 @@ static int _rtl_usb_init(struct ieee80211_hw *hw)
345 rtlusb->out_ep_nums++; 342 rtlusb->out_ep_nums++;
346 343
347 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, 344 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
348 ("USB EP(0x%02x), MaxPacketSize=%d ,Interval=%d.\n", 345 "USB EP(0x%02x), MaxPacketSize=%d, Interval=%d\n",
349 pep_desc->bEndpointAddress, pep_desc->wMaxPacketSize, 346 pep_desc->bEndpointAddress, pep_desc->wMaxPacketSize,
350 pep_desc->bInterval)); 347 pep_desc->bInterval);
351 } 348 }
352 if (rtlusb->in_ep_nums < rtlpriv->cfg->usb_interface_cfg->in_ep_num) 349 if (rtlusb->in_ep_nums < rtlpriv->cfg->usb_interface_cfg->in_ep_num)
353 return -EINVAL ; 350 return -EINVAL ;
@@ -414,7 +411,7 @@ static struct sk_buff *_rtl_prep_rx_urb(struct ieee80211_hw *hw,
414 gfp_mask); 411 gfp_mask);
415 if (!skb) { 412 if (!skb) {
416 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, 413 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
417 ("Failed to __dev_alloc_skb!!\n")) 414 "Failed to __dev_alloc_skb!!\n");
418 return ERR_PTR(-ENOMEM); 415 return ERR_PTR(-ENOMEM);
419 } 416 }
420 417
@@ -520,12 +517,14 @@ static void _rtl_usb_rx_process_noagg(struct ieee80211_hw *hw,
520 u8 *pdata; 517 u8 *pdata;
521 518
522 uskb = dev_alloc_skb(skb->len + 128); 519 uskb = dev_alloc_skb(skb->len + 128);
523 memcpy(IEEE80211_SKB_RXCB(uskb), &rx_status, 520 if (uskb) { /* drop packet on allocation failure */
524 sizeof(rx_status)); 521 memcpy(IEEE80211_SKB_RXCB(uskb), &rx_status,
525 pdata = (u8 *)skb_put(uskb, skb->len); 522 sizeof(rx_status));
526 memcpy(pdata, skb->data, skb->len); 523 pdata = (u8 *)skb_put(uskb, skb->len);
524 memcpy(pdata, skb->data, skb->len);
525 ieee80211_rx_irqsafe(hw, uskb);
526 }
527 dev_kfree_skb_any(skb); 527 dev_kfree_skb_any(skb);
528 ieee80211_rx_irqsafe(hw, uskb);
529 } else { 528 } else {
530 dev_kfree_skb_any(skb); 529 dev_kfree_skb_any(skb);
531 } 530 }
@@ -575,7 +574,7 @@ static void _rtl_rx_completed(struct urb *_urb)
575 if (IS_ERR(_skb)) { 574 if (IS_ERR(_skb)) {
576 err = PTR_ERR(_skb); 575 err = PTR_ERR(_skb);
577 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, 576 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
578 ("Can't allocate skb for bulk IN!\n")); 577 "Can't allocate skb for bulk IN!\n");
579 return; 578 return;
580 } 579 }
581 skb = _skb; 580 skb = _skb;
@@ -632,14 +631,14 @@ static int _rtl_usb_receive(struct ieee80211_hw *hw)
632 urb = usb_alloc_urb(0, GFP_KERNEL); 631 urb = usb_alloc_urb(0, GFP_KERNEL);
633 if (!urb) { 632 if (!urb) {
634 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, 633 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
635 ("Failed to alloc URB!!\n")) 634 "Failed to alloc URB!!\n");
636 goto err_out; 635 goto err_out;
637 } 636 }
638 637
639 skb = _rtl_prep_rx_urb(hw, rtlusb, urb, GFP_KERNEL); 638 skb = _rtl_prep_rx_urb(hw, rtlusb, urb, GFP_KERNEL);
640 if (IS_ERR(skb)) { 639 if (IS_ERR(skb)) {
641 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, 640 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
642 ("Failed to prep_rx_urb!!\n")) 641 "Failed to prep_rx_urb!!\n");
643 err = PTR_ERR(skb); 642 err = PTR_ERR(skb);
644 goto err_out; 643 goto err_out;
645 } 644 }
@@ -665,15 +664,17 @@ static int rtl_usb_start(struct ieee80211_hw *hw)
665 struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw)); 664 struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
666 665
667 err = rtlpriv->cfg->ops->hw_init(hw); 666 err = rtlpriv->cfg->ops->hw_init(hw);
668 rtl_init_rx_config(hw); 667 if (!err) {
668 rtl_init_rx_config(hw);
669 669
670 /* Enable software */ 670 /* Enable software */
671 SET_USB_START(rtlusb); 671 SET_USB_START(rtlusb);
672 /* should after adapter start and interrupt enable. */ 672 /* should after adapter start and interrupt enable. */
673 set_hal_start(rtlhal); 673 set_hal_start(rtlhal);
674 674
675 /* Start bulk IN */ 675 /* Start bulk IN */
676 _rtl_usb_receive(hw); 676 _rtl_usb_receive(hw);
677 }
677 678
678 return err; 679 return err;
679} 680}
@@ -745,7 +746,7 @@ static void _rtl_submit_tx_urb(struct ieee80211_hw *hw, struct urb *_urb)
745 struct sk_buff *skb; 746 struct sk_buff *skb;
746 747
747 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, 748 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
748 ("Failed to submit urb.\n")); 749 "Failed to submit urb\n");
749 usb_unanchor_urb(_urb); 750 usb_unanchor_urb(_urb);
750 skb = (struct sk_buff *)_urb->context; 751 skb = (struct sk_buff *)_urb->context;
751 kfree_skb(skb); 752 kfree_skb(skb);
@@ -768,7 +769,7 @@ static int _usb_tx_post(struct ieee80211_hw *hw, struct urb *urb,
768 769
769 if (urb->status) { 770 if (urb->status) {
770 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, 771 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
771 ("Urb has error status 0x%X\n", urb->status)); 772 "Urb has error status 0x%X\n", urb->status);
772 goto out; 773 goto out;
773 } 774 }
774 /* TODO: statistics */ 775 /* TODO: statistics */
@@ -805,7 +806,7 @@ static struct urb *_rtl_usb_tx_urb_setup(struct ieee80211_hw *hw,
805 _urb = usb_alloc_urb(0, GFP_ATOMIC); 806 _urb = usb_alloc_urb(0, GFP_ATOMIC);
806 if (!_urb) { 807 if (!_urb) {
807 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, 808 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
808 ("Can't allocate URB for bulk out!\n")); 809 "Can't allocate URB for bulk out!\n");
809 kfree_skb(skb); 810 kfree_skb(skb);
810 return NULL; 811 return NULL;
811 } 812 }
@@ -830,7 +831,7 @@ static void _rtl_usb_transmit(struct ieee80211_hw *hw, struct sk_buff *skb,
830 WARN_ON(NULL == rtlusb->usb_tx_aggregate_hdl); 831 WARN_ON(NULL == rtlusb->usb_tx_aggregate_hdl);
831 if (unlikely(IS_USB_STOP(rtlusb))) { 832 if (unlikely(IS_USB_STOP(rtlusb))) {
832 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG, 833 RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
833 ("USB device is stopping...\n")); 834 "USB device is stopping...\n");
834 kfree_skb(skb); 835 kfree_skb(skb);
835 return; 836 return;
836 } 837 }
@@ -840,7 +841,7 @@ static void _rtl_usb_transmit(struct ieee80211_hw *hw, struct sk_buff *skb,
840 _urb = _rtl_usb_tx_urb_setup(hw, _skb, ep_num); 841 _urb = _rtl_usb_tx_urb_setup(hw, _skb, ep_num);
841 if (unlikely(!_urb)) { 842 if (unlikely(!_urb)) {
842 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 843 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
843 ("Can't allocate urb. Drop skb!\n")); 844 "Can't allocate urb. Drop skb!\n");
844 return; 845 return;
845 } 846 }
846 urb_list = &rtlusb->tx_pending[ep_num]; 847 urb_list = &rtlusb->tx_pending[ep_num];
@@ -865,7 +866,7 @@ static void _rtl_usb_tx_preprocess(struct ieee80211_hw *hw, struct sk_buff *skb,
865 866
866 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); 867 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
867 if (ieee80211_is_auth(fc)) { 868 if (ieee80211_is_auth(fc)) {
868 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, ("MAC80211_LINKING\n")); 869 RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "MAC80211_LINKING\n");
869 rtl_ips_nic_on(hw); 870 rtl_ips_nic_on(hw);
870 } 871 }
871 872
@@ -946,10 +947,11 @@ int __devinit rtl_usb_probe(struct usb_interface *intf,
946 hw = ieee80211_alloc_hw(sizeof(struct rtl_priv) + 947 hw = ieee80211_alloc_hw(sizeof(struct rtl_priv) +
947 sizeof(struct rtl_usb_priv), &rtl_ops); 948 sizeof(struct rtl_usb_priv), &rtl_ops);
948 if (!hw) { 949 if (!hw) {
949 RT_ASSERT(false, ("%s : ieee80211 alloc failed\n", __func__)); 950 RT_ASSERT(false, "ieee80211 alloc failed\n");
950 return -ENOMEM; 951 return -ENOMEM;
951 } 952 }
952 rtlpriv = hw->priv; 953 rtlpriv = hw->priv;
954 init_completion(&rtlpriv->firmware_loading_complete);
953 SET_IEEE80211_DEV(hw, &intf->dev); 955 SET_IEEE80211_DEV(hw, &intf->dev);
954 udev = interface_to_usbdev(intf); 956 udev = interface_to_usbdev(intf);
955 usb_get_dev(udev); 957 usb_get_dev(udev);
@@ -969,8 +971,7 @@ int __devinit rtl_usb_probe(struct usb_interface *intf,
969 /*like read eeprom and so on */ 971 /*like read eeprom and so on */
970 rtlpriv->cfg->ops->read_eeprom_info(hw); 972 rtlpriv->cfg->ops->read_eeprom_info(hw);
971 if (rtlpriv->cfg->ops->init_sw_vars(hw)) { 973 if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
972 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 974 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't init_sw_vars\n");
973 ("Can't init_sw_vars.\n"));
974 goto error_out; 975 goto error_out;
975 } 976 }
976 rtlpriv->cfg->ops->init_sw_leds(hw); 977 rtlpriv->cfg->ops->init_sw_leds(hw);
@@ -980,28 +981,16 @@ int __devinit rtl_usb_probe(struct usb_interface *intf,
980 err = rtl_init_core(hw); 981 err = rtl_init_core(hw);
981 if (err) { 982 if (err) {
982 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 983 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
983 ("Can't allocate sw for mac80211.\n")); 984 "Can't allocate sw for mac80211\n");
984 goto error_out; 985 goto error_out;
985 } 986 }
986 987
987 /*init rfkill */
988 /* rtl_init_rfkill(hw); */
989
990 err = ieee80211_register_hw(hw);
991 if (err) {
992 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG,
993 ("Can't register mac80211 hw.\n"));
994 goto error_out;
995 } else {
996 rtlpriv->mac80211.mac80211_registered = 1;
997 }
998 set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
999 return 0; 988 return 0;
1000error_out: 989error_out:
1001 rtl_deinit_core(hw); 990 rtl_deinit_core(hw);
1002 _rtl_usb_io_handler_release(hw); 991 _rtl_usb_io_handler_release(hw);
1003 ieee80211_free_hw(hw);
1004 usb_put_dev(udev); 992 usb_put_dev(udev);
993 complete(&rtlpriv->firmware_loading_complete);
1005 return -ENODEV; 994 return -ENODEV;
1006} 995}
1007EXPORT_SYMBOL(rtl_usb_probe); 996EXPORT_SYMBOL(rtl_usb_probe);
@@ -1015,6 +1004,9 @@ void rtl_usb_disconnect(struct usb_interface *intf)
1015 1004
1016 if (unlikely(!rtlpriv)) 1005 if (unlikely(!rtlpriv))
1017 return; 1006 return;
1007
1008 /* just in case driver is removed before firmware callback */
1009 wait_for_completion(&rtlpriv->firmware_loading_complete);
1018 /*ieee80211_unregister_hw will call ops_stop */ 1010 /*ieee80211_unregister_hw will call ops_stop */
1019 if (rtlmac->mac80211_registered == 1) { 1011 if (rtlmac->mac80211_registered == 1) {
1020 ieee80211_unregister_hw(hw); 1012 ieee80211_unregister_hw(hw);
diff --git a/drivers/net/wireless/rtlwifi/usb.h b/drivers/net/wireless/rtlwifi/usb.h
index d2a63fb3e1e6..43846b329153 100644
--- a/drivers/net/wireless/rtlwifi/usb.h
+++ b/drivers/net/wireless/rtlwifi/usb.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2011 Realtek Corporation. All rights reserved. 3 * Copyright(c) 2009-2012 Realtek Corporation. All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -28,7 +28,6 @@
28#ifndef __RTL_USB_H__ 28#ifndef __RTL_USB_H__
29#define __RTL_USB_H__ 29#define __RTL_USB_H__
30 30
31#include <linux/usb.h>
32#include <linux/skbuff.h> 31#include <linux/skbuff.h>
33 32
34#define RTL_RX_DESC_SIZE 24 33#define RTL_RX_DESC_SIZE 24
diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
index cdaf1429fa0b..b591614c3b9b 100644
--- a/drivers/net/wireless/rtlwifi/wifi.h
+++ b/drivers/net/wireless/rtlwifi/wifi.h
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Copyright(c) 2009-2010 Realtek Corporation. 3 * Copyright(c) 2009-2012 Realtek Corporation.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as 6 * under the terms of version 2 of the GNU General Public License as
@@ -30,12 +30,15 @@
30#ifndef __RTL_WIFI_H__ 30#ifndef __RTL_WIFI_H__
31#define __RTL_WIFI_H__ 31#define __RTL_WIFI_H__
32 32
33#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
34
33#include <linux/sched.h> 35#include <linux/sched.h>
34#include <linux/firmware.h> 36#include <linux/firmware.h>
35#include <linux/etherdevice.h> 37#include <linux/etherdevice.h>
36#include <linux/vmalloc.h> 38#include <linux/vmalloc.h>
37#include <linux/usb.h> 39#include <linux/usb.h>
38#include <net/mac80211.h> 40#include <net/mac80211.h>
41#include <linux/completion.h>
39#include "debug.h" 42#include "debug.h"
40 43
41#define RF_CHANGE_BY_INIT 0 44#define RF_CHANGE_BY_INIT 0
@@ -1045,7 +1048,6 @@ struct rtl_hal {
1045 u16 fw_subversion; 1048 u16 fw_subversion;
1046 bool h2c_setinprogress; 1049 bool h2c_setinprogress;
1047 u8 last_hmeboxnum; 1050 u8 last_hmeboxnum;
1048 bool fw_ready;
1049 /*Reserve page start offset except beacon in TxQ. */ 1051 /*Reserve page start offset except beacon in TxQ. */
1050 u8 fw_rsvdpage_startoffset; 1052 u8 fw_rsvdpage_startoffset;
1051 u8 h2c_txcmd_seq; 1053 u8 h2c_txcmd_seq;
@@ -1591,6 +1593,7 @@ struct rtl_debug {
1591}; 1593};
1592 1594
1593struct rtl_priv { 1595struct rtl_priv {
1596 struct completion firmware_loading_complete;
1594 struct rtl_locks locks; 1597 struct rtl_locks locks;
1595 struct rtl_works works; 1598 struct rtl_works works;
1596 struct rtl_mac mac80211; 1599 struct rtl_mac mac80211;
@@ -1612,6 +1615,7 @@ struct rtl_priv {
1612 struct rtl_rate_priv *rate_priv; 1615 struct rtl_rate_priv *rate_priv;
1613 1616
1614 struct rtl_debug dbg; 1617 struct rtl_debug dbg;
1618 int max_fw_size;
1615 1619
1616 /* 1620 /*
1617 *hal_cfg : for diff cards 1621 *hal_cfg : for diff cards
diff --git a/drivers/net/wireless/wl1251/main.c b/drivers/net/wireless/wl1251/main.c
index ba3268ea81fe..41302c7b1ad0 100644
--- a/drivers/net/wireless/wl1251/main.c
+++ b/drivers/net/wireless/wl1251/main.c
@@ -514,6 +514,9 @@ static int wl1251_op_add_interface(struct ieee80211_hw *hw,
514 struct wl1251 *wl = hw->priv; 514 struct wl1251 *wl = hw->priv;
515 int ret = 0; 515 int ret = 0;
516 516
517 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER |
518 IEEE80211_VIF_SUPPORTS_CQM_RSSI;
519
517 wl1251_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM", 520 wl1251_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM",
518 vif->type, vif->addr); 521 vif->type, vif->addr);
519 522
@@ -1338,9 +1341,7 @@ int wl1251_init_ieee80211(struct wl1251 *wl)
1338 1341
1339 wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | 1342 wl->hw->flags = IEEE80211_HW_SIGNAL_DBM |
1340 IEEE80211_HW_SUPPORTS_PS | 1343 IEEE80211_HW_SUPPORTS_PS |
1341 IEEE80211_HW_BEACON_FILTER | 1344 IEEE80211_HW_SUPPORTS_UAPSD;
1342 IEEE80211_HW_SUPPORTS_UAPSD |
1343 IEEE80211_HW_SUPPORTS_CQM_RSSI;
1344 1345
1345 wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | 1346 wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
1346 BIT(NL80211_IFTYPE_ADHOC); 1347 BIT(NL80211_IFTYPE_ADHOC);
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index d5f55a149de5..f8748cedbae1 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -2060,6 +2060,9 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
2060 u8 role_type; 2060 u8 role_type;
2061 bool booted = false; 2061 bool booted = false;
2062 2062
2063 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER |
2064 IEEE80211_VIF_SUPPORTS_CQM_RSSI;
2065
2063 wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM", 2066 wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM",
2064 ieee80211_vif_type_p2p(vif), vif->addr); 2067 ieee80211_vif_type_p2p(vif), vif->addr);
2065 2068
@@ -4898,12 +4901,10 @@ static int wl1271_init_ieee80211(struct wl1271 *wl)
4898 wl->hw->max_listen_interval = wl->conf.conn.max_listen_interval; 4901 wl->hw->max_listen_interval = wl->conf.conn.max_listen_interval;
4899 4902
4900 wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | 4903 wl->hw->flags = IEEE80211_HW_SIGNAL_DBM |
4901 IEEE80211_HW_BEACON_FILTER |
4902 IEEE80211_HW_SUPPORTS_PS | 4904 IEEE80211_HW_SUPPORTS_PS |
4903 IEEE80211_HW_SUPPORTS_UAPSD | 4905 IEEE80211_HW_SUPPORTS_UAPSD |
4904 IEEE80211_HW_HAS_RATE_CONTROL | 4906 IEEE80211_HW_HAS_RATE_CONTROL |
4905 IEEE80211_HW_CONNECTION_MONITOR | 4907 IEEE80211_HW_CONNECTION_MONITOR |
4906 IEEE80211_HW_SUPPORTS_CQM_RSSI |
4907 IEEE80211_HW_REPORTS_TX_ACK_STATUS | 4908 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
4908 IEEE80211_HW_SPECTRUM_MGMT | 4909 IEEE80211_HW_SPECTRUM_MGMT |
4909 IEEE80211_HW_AP_LINK_PS | 4910 IEEE80211_HW_AP_LINK_PS |
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 59effac15f36..2596401308a8 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -1639,10 +1639,8 @@ static int __init netback_init(void)
1639 1639
1640 xen_netbk_group_nr = num_online_cpus(); 1640 xen_netbk_group_nr = num_online_cpus();
1641 xen_netbk = vzalloc(sizeof(struct xen_netbk) * xen_netbk_group_nr); 1641 xen_netbk = vzalloc(sizeof(struct xen_netbk) * xen_netbk_group_nr);
1642 if (!xen_netbk) { 1642 if (!xen_netbk)
1643 printk(KERN_ALERT "%s: out of memory\n", __func__);
1644 return -ENOMEM; 1643 return -ENOMEM;
1645 }
1646 1644
1647 for (group = 0; group < xen_netbk_group_nr; group++) { 1645 for (group = 0; group < xen_netbk_group_nr; group++) {
1648 struct xen_netbk *netbk = &xen_netbk[group]; 1646 struct xen_netbk *netbk = &xen_netbk[group];
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 698b905058dd..b16175032327 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -489,6 +489,7 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
489 int frags = skb_shinfo(skb)->nr_frags; 489 int frags = skb_shinfo(skb)->nr_frags;
490 unsigned int offset = offset_in_page(data); 490 unsigned int offset = offset_in_page(data);
491 unsigned int len = skb_headlen(skb); 491 unsigned int len = skb_headlen(skb);
492 unsigned long flags;
492 493
493 frags += DIV_ROUND_UP(offset + len, PAGE_SIZE); 494 frags += DIV_ROUND_UP(offset + len, PAGE_SIZE);
494 if (unlikely(frags > MAX_SKB_FRAGS + 1)) { 495 if (unlikely(frags > MAX_SKB_FRAGS + 1)) {
@@ -498,12 +499,12 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
498 goto drop; 499 goto drop;
499 } 500 }
500 501
501 spin_lock_irq(&np->tx_lock); 502 spin_lock_irqsave(&np->tx_lock, flags);
502 503
503 if (unlikely(!netif_carrier_ok(dev) || 504 if (unlikely(!netif_carrier_ok(dev) ||
504 (frags > 1 && !xennet_can_sg(dev)) || 505 (frags > 1 && !xennet_can_sg(dev)) ||
505 netif_needs_gso(skb, netif_skb_features(skb)))) { 506 netif_needs_gso(skb, netif_skb_features(skb)))) {
506 spin_unlock_irq(&np->tx_lock); 507 spin_unlock_irqrestore(&np->tx_lock, flags);
507 goto drop; 508 goto drop;
508 } 509 }
509 510
@@ -574,7 +575,7 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
574 if (!netfront_tx_slot_available(np)) 575 if (!netfront_tx_slot_available(np))
575 netif_stop_queue(dev); 576 netif_stop_queue(dev);
576 577
577 spin_unlock_irq(&np->tx_lock); 578 spin_unlock_irqrestore(&np->tx_lock, flags);
578 579
579 return NETDEV_TX_OK; 580 return NETDEV_TX_OK;
580 581
@@ -1228,6 +1229,33 @@ static int xennet_set_features(struct net_device *dev,
1228 return 0; 1229 return 0;
1229} 1230}
1230 1231
1232static irqreturn_t xennet_interrupt(int irq, void *dev_id)
1233{
1234 struct net_device *dev = dev_id;
1235 struct netfront_info *np = netdev_priv(dev);
1236 unsigned long flags;
1237
1238 spin_lock_irqsave(&np->tx_lock, flags);
1239
1240 if (likely(netif_carrier_ok(dev))) {
1241 xennet_tx_buf_gc(dev);
1242 /* Under tx_lock: protects access to rx shared-ring indexes. */
1243 if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
1244 napi_schedule(&np->napi);
1245 }
1246
1247 spin_unlock_irqrestore(&np->tx_lock, flags);
1248
1249 return IRQ_HANDLED;
1250}
1251
1252#ifdef CONFIG_NET_POLL_CONTROLLER
1253static void xennet_poll_controller(struct net_device *dev)
1254{
1255 xennet_interrupt(0, dev);
1256}
1257#endif
1258
1231static const struct net_device_ops xennet_netdev_ops = { 1259static const struct net_device_ops xennet_netdev_ops = {
1232 .ndo_open = xennet_open, 1260 .ndo_open = xennet_open,
1233 .ndo_uninit = xennet_uninit, 1261 .ndo_uninit = xennet_uninit,
@@ -1239,6 +1267,9 @@ static const struct net_device_ops xennet_netdev_ops = {
1239 .ndo_validate_addr = eth_validate_addr, 1267 .ndo_validate_addr = eth_validate_addr,
1240 .ndo_fix_features = xennet_fix_features, 1268 .ndo_fix_features = xennet_fix_features,
1241 .ndo_set_features = xennet_set_features, 1269 .ndo_set_features = xennet_set_features,
1270#ifdef CONFIG_NET_POLL_CONTROLLER
1271 .ndo_poll_controller = xennet_poll_controller,
1272#endif
1242}; 1273};
1243 1274
1244static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev) 1275static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev)
@@ -1248,11 +1279,8 @@ static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev
1248 struct netfront_info *np; 1279 struct netfront_info *np;
1249 1280
1250 netdev = alloc_etherdev(sizeof(struct netfront_info)); 1281 netdev = alloc_etherdev(sizeof(struct netfront_info));
1251 if (!netdev) { 1282 if (!netdev)
1252 printk(KERN_WARNING "%s> alloc_etherdev failed.\n",
1253 __func__);
1254 return ERR_PTR(-ENOMEM); 1283 return ERR_PTR(-ENOMEM);
1255 }
1256 1284
1257 np = netdev_priv(netdev); 1285 np = netdev_priv(netdev);
1258 np->xbdev = dev; 1286 np->xbdev = dev;
@@ -1448,26 +1476,6 @@ static int xen_net_read_mac(struct xenbus_device *dev, u8 mac[])
1448 return 0; 1476 return 0;
1449} 1477}
1450 1478
1451static irqreturn_t xennet_interrupt(int irq, void *dev_id)
1452{
1453 struct net_device *dev = dev_id;
1454 struct netfront_info *np = netdev_priv(dev);
1455 unsigned long flags;
1456
1457 spin_lock_irqsave(&np->tx_lock, flags);
1458
1459 if (likely(netif_carrier_ok(dev))) {
1460 xennet_tx_buf_gc(dev);
1461 /* Under tx_lock: protects access to rx shared-ring indexes. */
1462 if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
1463 napi_schedule(&np->napi);
1464 }
1465
1466 spin_unlock_irqrestore(&np->tx_lock, flags);
1467
1468 return IRQ_HANDLED;
1469}
1470
1471static int setup_netfront(struct xenbus_device *dev, struct netfront_info *info) 1479static int setup_netfront(struct xenbus_device *dev, struct netfront_info *info)
1472{ 1480{
1473 struct xen_netif_tx_sring *txs; 1481 struct xen_netif_tx_sring *txs;
diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
index 06c3642e5bdb..1f74a77d040d 100644
--- a/drivers/nfc/nfcwilink.c
+++ b/drivers/nfc/nfcwilink.c
@@ -28,6 +28,8 @@
28 */ 28 */
29#include <linux/platform_device.h> 29#include <linux/platform_device.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/types.h>
32#include <linux/firmware.h>
31#include <linux/nfc.h> 33#include <linux/nfc.h>
32#include <net/nfc/nci.h> 34#include <net/nfc/nci.h>
33#include <net/nfc/nci_core.h> 35#include <net/nfc/nci_core.h>
@@ -40,11 +42,52 @@
40#define NFCWILINK_OFFSET_LEN_IN_HDR 1 42#define NFCWILINK_OFFSET_LEN_IN_HDR 1
41#define NFCWILINK_LEN_SIZE 2 43#define NFCWILINK_LEN_SIZE 2
42#define NFCWILINK_REGISTER_TIMEOUT 8000 /* 8 sec */ 44#define NFCWILINK_REGISTER_TIMEOUT 8000 /* 8 sec */
45#define NFCWILINK_CMD_TIMEOUT 5000 /* 5 sec */
46
47#define BTS_FILE_NAME_MAX_SIZE 40
48#define BTS_FILE_HDR_MAGIC 0x42535442
49#define BTS_FILE_CMD_MAX_LEN 0xff
50#define BTS_FILE_ACTION_TYPE_SEND_CMD 1
51
52#define NCI_VS_NFCC_INFO_CMD_GID 0x2f
53#define NCI_VS_NFCC_INFO_CMD_OID 0x12
54#define NCI_VS_NFCC_INFO_RSP_GID 0x4f
55#define NCI_VS_NFCC_INFO_RSP_OID 0x12
43 56
44struct nfcwilink_hdr { 57struct nfcwilink_hdr {
45 u8 chnl; 58 __u8 chnl;
46 u8 opcode; 59 __u8 opcode;
47 u16 len; 60 __le16 len;
61} __packed;
62
63struct nci_vs_nfcc_info_cmd {
64 __u8 gid;
65 __u8 oid;
66 __u8 plen;
67} __packed;
68
69struct nci_vs_nfcc_info_rsp {
70 __u8 gid;
71 __u8 oid;
72 __u8 plen;
73 __u8 status;
74 __u8 hw_id;
75 __u8 sw_ver_x;
76 __u8 sw_ver_z;
77 __u8 patch_id;
78} __packed;
79
80struct bts_file_hdr {
81 __le32 magic;
82 __le32 ver;
83 __u8 rfu[24];
84 __u8 actions[0];
85} __packed;
86
87struct bts_file_action {
88 __le16 type;
89 __le16 len;
90 __u8 data[0];
48} __packed; 91} __packed;
49 92
50struct nfcwilink { 93struct nfcwilink {
@@ -54,14 +97,241 @@ struct nfcwilink {
54 97
55 char st_register_cb_status; 98 char st_register_cb_status;
56 long (*st_write) (struct sk_buff *); 99 long (*st_write) (struct sk_buff *);
57 struct completion st_register_completed; 100
101 struct completion completed;
102
103 struct nci_vs_nfcc_info_rsp nfcc_info;
58}; 104};
59 105
60/* NFCWILINK driver flags */ 106/* NFCWILINK driver flags */
61enum { 107enum {
62 NFCWILINK_RUNNING, 108 NFCWILINK_RUNNING,
109 NFCWILINK_FW_DOWNLOAD,
63}; 110};
64 111
112static int nfcwilink_send(struct sk_buff *skb);
113
114static inline struct sk_buff *nfcwilink_skb_alloc(unsigned int len, gfp_t how)
115{
116 struct sk_buff *skb;
117
118 skb = alloc_skb(len + NFCWILINK_HDR_LEN, how);
119 if (skb)
120 skb_reserve(skb, NFCWILINK_HDR_LEN);
121
122 return skb;
123}
124
125static void nfcwilink_fw_download_receive(struct nfcwilink *drv,
126 struct sk_buff *skb)
127{
128 struct nci_vs_nfcc_info_rsp *rsp = (void *)skb->data;
129
130 /* Detect NCI_VS_NFCC_INFO_RSP and store the result */
131 if ((skb->len > 3) && (rsp->gid == NCI_VS_NFCC_INFO_RSP_GID) &&
132 (rsp->oid == NCI_VS_NFCC_INFO_RSP_OID)) {
133 memcpy(&drv->nfcc_info, rsp,
134 sizeof(struct nci_vs_nfcc_info_rsp));
135 }
136
137 kfree_skb(skb);
138
139 complete(&drv->completed);
140}
141
142static int nfcwilink_get_bts_file_name(struct nfcwilink *drv, char *file_name)
143{
144 struct nci_vs_nfcc_info_cmd *cmd;
145 struct sk_buff *skb;
146 unsigned long comp_ret;
147 int rc;
148
149 nfc_dev_dbg(&drv->pdev->dev, "get_bts_file_name entry");
150
151 skb = nfcwilink_skb_alloc(sizeof(struct nci_vs_nfcc_info_cmd),
152 GFP_KERNEL);
153 if (!skb) {
154 nfc_dev_err(&drv->pdev->dev,
155 "no memory for nci_vs_nfcc_info_cmd");
156 return -ENOMEM;
157 }
158
159 skb->dev = (void *)drv->ndev;
160
161 cmd = (struct nci_vs_nfcc_info_cmd *)
162 skb_put(skb, sizeof(struct nci_vs_nfcc_info_cmd));
163 cmd->gid = NCI_VS_NFCC_INFO_CMD_GID;
164 cmd->oid = NCI_VS_NFCC_INFO_CMD_OID;
165 cmd->plen = 0;
166
167 drv->nfcc_info.plen = 0;
168
169 rc = nfcwilink_send(skb);
170 if (rc)
171 return rc;
172
173 comp_ret = wait_for_completion_timeout(&drv->completed,
174 msecs_to_jiffies(NFCWILINK_CMD_TIMEOUT));
175 nfc_dev_dbg(&drv->pdev->dev, "wait_for_completion_timeout returned %ld",
176 comp_ret);
177 if (comp_ret == 0) {
178 nfc_dev_err(&drv->pdev->dev,
179 "timeout on wait_for_completion_timeout");
180 return -ETIMEDOUT;
181 }
182
183 nfc_dev_dbg(&drv->pdev->dev, "nci_vs_nfcc_info_rsp: plen %d, status %d",
184 drv->nfcc_info.plen,
185 drv->nfcc_info.status);
186
187 if ((drv->nfcc_info.plen != 5) || (drv->nfcc_info.status != 0)) {
188 nfc_dev_err(&drv->pdev->dev,
189 "invalid nci_vs_nfcc_info_rsp");
190 return -EINVAL;
191 }
192
193 snprintf(file_name, BTS_FILE_NAME_MAX_SIZE,
194 "TINfcInit_%d.%d.%d.%d.bts",
195 drv->nfcc_info.hw_id,
196 drv->nfcc_info.sw_ver_x,
197 drv->nfcc_info.sw_ver_z,
198 drv->nfcc_info.patch_id);
199
200 nfc_dev_info(&drv->pdev->dev, "nfcwilink FW file name: %s", file_name);
201
202 return 0;
203}
204
205static int nfcwilink_send_bts_cmd(struct nfcwilink *drv, __u8 *data, int len)
206{
207 struct nfcwilink_hdr *hdr = (struct nfcwilink_hdr *)data;
208 struct sk_buff *skb;
209 unsigned long comp_ret;
210 int rc;
211
212 nfc_dev_dbg(&drv->pdev->dev, "send_bts_cmd entry");
213
214 /* verify valid cmd for the NFC channel */
215 if ((len <= sizeof(struct nfcwilink_hdr)) ||
216 (len > BTS_FILE_CMD_MAX_LEN) ||
217 (hdr->chnl != NFCWILINK_CHNL) ||
218 (hdr->opcode != NFCWILINK_OPCODE)) {
219 nfc_dev_err(&drv->pdev->dev,
220 "ignoring invalid bts cmd, len %d, chnl %d, opcode %d",
221 len, hdr->chnl, hdr->opcode);
222 return 0;
223 }
224
225 /* remove the ST header */
226 len -= sizeof(struct nfcwilink_hdr);
227 data += sizeof(struct nfcwilink_hdr);
228
229 skb = nfcwilink_skb_alloc(len, GFP_KERNEL);
230 if (!skb) {
231 nfc_dev_err(&drv->pdev->dev, "no memory for bts cmd");
232 return -ENOMEM;
233 }
234
235 skb->dev = (void *)drv->ndev;
236
237 memcpy(skb_put(skb, len), data, len);
238
239 rc = nfcwilink_send(skb);
240 if (rc)
241 return rc;
242
243 comp_ret = wait_for_completion_timeout(&drv->completed,
244 msecs_to_jiffies(NFCWILINK_CMD_TIMEOUT));
245 nfc_dev_dbg(&drv->pdev->dev, "wait_for_completion_timeout returned %ld",
246 comp_ret);
247 if (comp_ret == 0) {
248 nfc_dev_err(&drv->pdev->dev,
249 "timeout on wait_for_completion_timeout");
250 return -ETIMEDOUT;
251 }
252
253 return 0;
254}
255
256static int nfcwilink_download_fw(struct nfcwilink *drv)
257{
258 unsigned char file_name[BTS_FILE_NAME_MAX_SIZE];
259 const struct firmware *fw;
260 __u16 action_type, action_len;
261 __u8 *ptr;
262 int len, rc;
263
264 nfc_dev_dbg(&drv->pdev->dev, "download_fw entry");
265
266 set_bit(NFCWILINK_FW_DOWNLOAD, &drv->flags);
267
268 rc = nfcwilink_get_bts_file_name(drv, file_name);
269 if (rc)
270 goto exit;
271
272 rc = request_firmware(&fw, file_name, &drv->pdev->dev);
273 if (rc) {
274 nfc_dev_err(&drv->pdev->dev, "request_firmware failed %d", rc);
275
276 /* if the file is not found, don't exit with failure */
277 if (rc == -ENOENT)
278 rc = 0;
279
280 goto exit;
281 }
282
283 len = fw->size;
284 ptr = (__u8 *)fw->data;
285
286 if ((len == 0) || (ptr == NULL)) {
287 nfc_dev_dbg(&drv->pdev->dev,
288 "request_firmware returned size %d", len);
289 goto release_fw;
290 }
291
292 if (__le32_to_cpu(((struct bts_file_hdr *)ptr)->magic) !=
293 BTS_FILE_HDR_MAGIC) {
294 nfc_dev_err(&drv->pdev->dev, "wrong bts magic number");
295 rc = -EINVAL;
296 goto release_fw;
297 }
298
299 /* remove the BTS header */
300 len -= sizeof(struct bts_file_hdr);
301 ptr += sizeof(struct bts_file_hdr);
302
303 while (len > 0) {
304 action_type =
305 __le16_to_cpu(((struct bts_file_action *)ptr)->type);
306 action_len =
307 __le16_to_cpu(((struct bts_file_action *)ptr)->len);
308
309 nfc_dev_dbg(&drv->pdev->dev, "bts_file_action type %d, len %d",
310 action_type, action_len);
311
312 switch (action_type) {
313 case BTS_FILE_ACTION_TYPE_SEND_CMD:
314 rc = nfcwilink_send_bts_cmd(drv,
315 ((struct bts_file_action *)ptr)->data,
316 action_len);
317 if (rc)
318 goto release_fw;
319 break;
320 }
321
322 /* advance to the next action */
323 len -= (sizeof(struct bts_file_action) + action_len);
324 ptr += (sizeof(struct bts_file_action) + action_len);
325 }
326
327release_fw:
328 release_firmware(fw);
329
330exit:
331 clear_bit(NFCWILINK_FW_DOWNLOAD, &drv->flags);
332 return rc;
333}
334
65/* Called by ST when registration is complete */ 335/* Called by ST when registration is complete */
66static void nfcwilink_register_complete(void *priv_data, char data) 336static void nfcwilink_register_complete(void *priv_data, char data)
67{ 337{
@@ -73,7 +343,7 @@ static void nfcwilink_register_complete(void *priv_data, char data)
73 drv->st_register_cb_status = data; 343 drv->st_register_cb_status = data;
74 344
75 /* complete the wait in nfc_st_open() */ 345 /* complete the wait in nfc_st_open() */
76 complete(&drv->st_register_completed); 346 complete(&drv->completed);
77} 347}
78 348
79/* Called by ST when receive data is available */ 349/* Called by ST when receive data is available */
@@ -96,6 +366,11 @@ static long nfcwilink_receive(void *priv_data, struct sk_buff *skb)
96 (apart for the chnl byte, which is not received in the hdr) */ 366 (apart for the chnl byte, which is not received in the hdr) */
97 skb_pull(skb, (NFCWILINK_HDR_LEN-1)); 367 skb_pull(skb, (NFCWILINK_HDR_LEN-1));
98 368
369 if (test_bit(NFCWILINK_FW_DOWNLOAD, &drv->flags)) {
370 nfcwilink_fw_download_receive(drv, skb);
371 return 0;
372 }
373
99 skb->dev = (void *) drv->ndev; 374 skb->dev = (void *) drv->ndev;
100 375
101 /* Forward skb to NCI core layer */ 376 /* Forward skb to NCI core layer */
@@ -136,14 +411,14 @@ static int nfcwilink_open(struct nci_dev *ndev)
136 411
137 nfcwilink_proto.priv_data = drv; 412 nfcwilink_proto.priv_data = drv;
138 413
139 init_completion(&drv->st_register_completed); 414 init_completion(&drv->completed);
140 drv->st_register_cb_status = -EINPROGRESS; 415 drv->st_register_cb_status = -EINPROGRESS;
141 416
142 rc = st_register(&nfcwilink_proto); 417 rc = st_register(&nfcwilink_proto);
143 if (rc < 0) { 418 if (rc < 0) {
144 if (rc == -EINPROGRESS) { 419 if (rc == -EINPROGRESS) {
145 comp_ret = wait_for_completion_timeout( 420 comp_ret = wait_for_completion_timeout(
146 &drv->st_register_completed, 421 &drv->completed,
147 msecs_to_jiffies(NFCWILINK_REGISTER_TIMEOUT)); 422 msecs_to_jiffies(NFCWILINK_REGISTER_TIMEOUT));
148 423
149 nfc_dev_dbg(&drv->pdev->dev, 424 nfc_dev_dbg(&drv->pdev->dev,
@@ -171,6 +446,12 @@ static int nfcwilink_open(struct nci_dev *ndev)
171 BUG_ON(nfcwilink_proto.write == NULL); 446 BUG_ON(nfcwilink_proto.write == NULL);
172 drv->st_write = nfcwilink_proto.write; 447 drv->st_write = nfcwilink_proto.write;
173 448
449 if (nfcwilink_download_fw(drv)) {
450 nfc_dev_err(&drv->pdev->dev, "nfcwilink_download_fw failed %d",
451 rc);
452 /* open should succeed, even if the FW download failed */
453 }
454
174 goto exit; 455 goto exit;
175 456
176clear_exit: 457clear_exit:
@@ -208,11 +489,13 @@ static int nfcwilink_send(struct sk_buff *skb)
208 489
209 nfc_dev_dbg(&drv->pdev->dev, "send entry, len %d", skb->len); 490 nfc_dev_dbg(&drv->pdev->dev, "send entry, len %d", skb->len);
210 491
211 if (!test_bit(NFCWILINK_RUNNING, &drv->flags)) 492 if (!test_bit(NFCWILINK_RUNNING, &drv->flags)) {
212 return -EBUSY; 493 kfree_skb(skb);
494 return -EINVAL;
495 }
213 496
214 /* add the ST hdr to the start of the buffer */ 497 /* add the ST hdr to the start of the buffer */
215 hdr.len = skb->len; 498 hdr.len = cpu_to_le16(skb->len);
216 memcpy(skb_push(skb, NFCWILINK_HDR_LEN), &hdr, NFCWILINK_HDR_LEN); 499 memcpy(skb_push(skb, NFCWILINK_HDR_LEN), &hdr, NFCWILINK_HDR_LEN);
217 500
218 /* Insert skb to shared transport layer's transmit queue. 501 /* Insert skb to shared transport layer's transmit queue.
@@ -239,7 +522,7 @@ static int nfcwilink_probe(struct platform_device *pdev)
239{ 522{
240 static struct nfcwilink *drv; 523 static struct nfcwilink *drv;
241 int rc; 524 int rc;
242 u32 protocols; 525 __u32 protocols;
243 526
244 nfc_dev_dbg(&pdev->dev, "probe entry"); 527 nfc_dev_dbg(&pdev->dev, "probe entry");
245 528
diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h
index 4abc79d3963f..ec7921b5138e 100644
--- a/drivers/s390/net/qeth_core.h
+++ b/drivers/s390/net/qeth_core.h
@@ -906,6 +906,7 @@ void qeth_prepare_ipa_cmd(struct qeth_card *, struct qeth_cmd_buffer *, char);
906struct qeth_cmd_buffer *qeth_wait_for_buffer(struct qeth_channel *); 906struct qeth_cmd_buffer *qeth_wait_for_buffer(struct qeth_channel *);
907int qeth_mdio_read(struct net_device *, int, int); 907int qeth_mdio_read(struct net_device *, int, int);
908int qeth_snmp_command(struct qeth_card *, char __user *); 908int qeth_snmp_command(struct qeth_card *, char __user *);
909int qeth_query_oat_command(struct qeth_card *, char __user *);
909struct qeth_cmd_buffer *qeth_get_adapter_cmd(struct qeth_card *, __u32, __u32); 910struct qeth_cmd_buffer *qeth_get_adapter_cmd(struct qeth_card *, __u32, __u32);
910int qeth_default_setadapterparms_cb(struct qeth_card *, struct qeth_reply *, 911int qeth_default_setadapterparms_cb(struct qeth_card *, struct qeth_reply *,
911 unsigned long); 912 unsigned long);
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 9c3f38da4c01..cbb101828dc3 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -26,6 +26,7 @@
26#include <asm/ebcdic.h> 26#include <asm/ebcdic.h>
27#include <asm/io.h> 27#include <asm/io.h>
28#include <asm/sysinfo.h> 28#include <asm/sysinfo.h>
29#include <asm/compat.h>
29 30
30#include "qeth_core.h" 31#include "qeth_core.h"
31 32
@@ -677,6 +678,7 @@ void qeth_release_buffer(struct qeth_channel *channel,
677 iob->callback = qeth_send_control_data_cb; 678 iob->callback = qeth_send_control_data_cb;
678 iob->rc = 0; 679 iob->rc = 0;
679 spin_unlock_irqrestore(&channel->iob_lock, flags); 680 spin_unlock_irqrestore(&channel->iob_lock, flags);
681 wake_up(&channel->wait_q);
680} 682}
681EXPORT_SYMBOL_GPL(qeth_release_buffer); 683EXPORT_SYMBOL_GPL(qeth_release_buffer);
682 684
@@ -4402,6 +4404,104 @@ int qeth_snmp_command(struct qeth_card *card, char __user *udata)
4402} 4404}
4403EXPORT_SYMBOL_GPL(qeth_snmp_command); 4405EXPORT_SYMBOL_GPL(qeth_snmp_command);
4404 4406
4407static int qeth_setadpparms_query_oat_cb(struct qeth_card *card,
4408 struct qeth_reply *reply, unsigned long data)
4409{
4410 struct qeth_ipa_cmd *cmd;
4411 struct qeth_qoat_priv *priv;
4412 char *resdata;
4413 int resdatalen;
4414
4415 QETH_CARD_TEXT(card, 3, "qoatcb");
4416
4417 cmd = (struct qeth_ipa_cmd *)data;
4418 priv = (struct qeth_qoat_priv *)reply->param;
4419 resdatalen = cmd->data.setadapterparms.hdr.cmdlength;
4420 resdata = (char *)data + 28;
4421
4422 if (resdatalen > (priv->buffer_len - priv->response_len)) {
4423 cmd->hdr.return_code = IPA_RC_FFFF;
4424 return 0;
4425 }
4426
4427 memcpy((priv->buffer + priv->response_len), resdata,
4428 resdatalen);
4429 priv->response_len += resdatalen;
4430
4431 if (cmd->data.setadapterparms.hdr.seq_no <
4432 cmd->data.setadapterparms.hdr.used_total)
4433 return 1;
4434 return 0;
4435}
4436
4437int qeth_query_oat_command(struct qeth_card *card, char __user *udata)
4438{
4439 int rc = 0;
4440 struct qeth_cmd_buffer *iob;
4441 struct qeth_ipa_cmd *cmd;
4442 struct qeth_query_oat *oat_req;
4443 struct qeth_query_oat_data oat_data;
4444 struct qeth_qoat_priv priv;
4445 void __user *tmp;
4446
4447 QETH_CARD_TEXT(card, 3, "qoatcmd");
4448
4449 if (!qeth_adp_supported(card, IPA_SETADP_QUERY_OAT)) {
4450 rc = -EOPNOTSUPP;
4451 goto out;
4452 }
4453
4454 if (copy_from_user(&oat_data, udata,
4455 sizeof(struct qeth_query_oat_data))) {
4456 rc = -EFAULT;
4457 goto out;
4458 }
4459
4460 priv.buffer_len = oat_data.buffer_len;
4461 priv.response_len = 0;
4462 priv.buffer = kzalloc(oat_data.buffer_len, GFP_KERNEL);
4463 if (!priv.buffer) {
4464 rc = -ENOMEM;
4465 goto out;
4466 }
4467
4468 iob = qeth_get_adapter_cmd(card, IPA_SETADP_QUERY_OAT,
4469 sizeof(struct qeth_ipacmd_setadpparms_hdr) +
4470 sizeof(struct qeth_query_oat));
4471 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
4472 oat_req = &cmd->data.setadapterparms.data.query_oat;
4473 oat_req->subcmd_code = oat_data.command;
4474
4475 rc = qeth_send_ipa_cmd(card, iob, qeth_setadpparms_query_oat_cb,
4476 &priv);
4477 if (!rc) {
4478 if (is_compat_task())
4479 tmp = compat_ptr(oat_data.ptr);
4480 else
4481 tmp = (void __user *)(unsigned long)oat_data.ptr;
4482
4483 if (copy_to_user(tmp, priv.buffer,
4484 priv.response_len)) {
4485 rc = -EFAULT;
4486 goto out_free;
4487 }
4488
4489 oat_data.response_len = priv.response_len;
4490
4491 if (copy_to_user(udata, &oat_data,
4492 sizeof(struct qeth_query_oat_data)))
4493 rc = -EFAULT;
4494 } else
4495 if (rc == IPA_RC_FFFF)
4496 rc = -EFAULT;
4497
4498out_free:
4499 kfree(priv.buffer);
4500out:
4501 return rc;
4502}
4503EXPORT_SYMBOL_GPL(qeth_query_oat_command);
4504
4405static inline int qeth_get_qdio_q_format(struct qeth_card *card) 4505static inline int qeth_get_qdio_q_format(struct qeth_card *card)
4406{ 4506{
4407 switch (card->info.type) { 4507 switch (card->info.type) {
diff --git a/drivers/s390/net/qeth_core_mpc.h b/drivers/s390/net/qeth_core_mpc.h
index e5a9d1c03839..578e19a2de6b 100644
--- a/drivers/s390/net/qeth_core_mpc.h
+++ b/drivers/s390/net/qeth_core_mpc.h
@@ -249,6 +249,7 @@ enum qeth_ipa_setadp_cmd {
249 IPA_SETADP_SET_PROMISC_MODE = 0x00000800L, 249 IPA_SETADP_SET_PROMISC_MODE = 0x00000800L,
250 IPA_SETADP_SET_DIAG_ASSIST = 0x00002000L, 250 IPA_SETADP_SET_DIAG_ASSIST = 0x00002000L,
251 IPA_SETADP_SET_ACCESS_CONTROL = 0x00010000L, 251 IPA_SETADP_SET_ACCESS_CONTROL = 0x00010000L,
252 IPA_SETADP_QUERY_OAT = 0x00080000L,
252}; 253};
253enum qeth_ipa_mac_ops { 254enum qeth_ipa_mac_ops {
254 CHANGE_ADDR_READ_MAC = 0, 255 CHANGE_ADDR_READ_MAC = 0,
@@ -398,6 +399,17 @@ struct qeth_set_access_ctrl {
398 __u32 subcmd_code; 399 __u32 subcmd_code;
399} __attribute__((packed)); 400} __attribute__((packed));
400 401
402struct qeth_query_oat {
403 __u32 subcmd_code;
404 __u8 reserved[12];
405} __packed;
406
407struct qeth_qoat_priv {
408 __u32 buffer_len;
409 __u32 response_len;
410 char *buffer;
411};
412
401struct qeth_ipacmd_setadpparms_hdr { 413struct qeth_ipacmd_setadpparms_hdr {
402 __u32 supp_hw_cmds; 414 __u32 supp_hw_cmds;
403 __u32 reserved1; 415 __u32 reserved1;
@@ -417,6 +429,7 @@ struct qeth_ipacmd_setadpparms {
417 struct qeth_change_addr change_addr; 429 struct qeth_change_addr change_addr;
418 struct qeth_snmp_cmd snmp; 430 struct qeth_snmp_cmd snmp;
419 struct qeth_set_access_ctrl set_access_ctrl; 431 struct qeth_set_access_ctrl set_access_ctrl;
432 struct qeth_query_oat query_oat;
420 __u32 mode; 433 __u32 mode;
421 } data; 434 } data;
422} __attribute__ ((packed)); 435} __attribute__ ((packed));
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index c12967133114..e5c9cf15e5c6 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -75,6 +75,9 @@ static int qeth_l2_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
75 mii_data->val_out = qeth_mdio_read(dev, 75 mii_data->val_out = qeth_mdio_read(dev,
76 mii_data->phy_id, mii_data->reg_num); 76 mii_data->phy_id, mii_data->reg_num);
77 break; 77 break;
78 case SIOC_QETH_QUERY_OAT:
79 rc = qeth_query_oat_command(card, rq->ifr_ifru.ifru_data);
80 break;
78 default: 81 default:
79 rc = -EOPNOTSUPP; 82 rc = -EOPNOTSUPP;
80 } 83 }
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 9648e4e68337..73bf8889984b 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -28,6 +28,8 @@
28 28
29#include <net/ip.h> 29#include <net/ip.h>
30#include <net/arp.h> 30#include <net/arp.h>
31#include <net/route.h>
32#include <net/ip6_fib.h>
31#include <net/ip6_checksum.h> 33#include <net/ip6_checksum.h>
32#include <net/iucv/af_iucv.h> 34#include <net/iucv/af_iucv.h>
33 35
@@ -2743,6 +2745,9 @@ static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2743 mii_data->phy_id, 2745 mii_data->phy_id,
2744 mii_data->reg_num); 2746 mii_data->reg_num);
2745 break; 2747 break;
2748 case SIOC_QETH_QUERY_OAT:
2749 rc = qeth_query_oat_command(card, rq->ifr_ifru.ifru_data);
2750 break;
2746 default: 2751 default:
2747 rc = -EOPNOTSUPP; 2752 rc = -EOPNOTSUPP;
2748 } 2753 }
@@ -2832,7 +2837,6 @@ static void qeth_l3_fill_af_iucv_hdr(struct qeth_card *card,
2832static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, 2837static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
2833 struct sk_buff *skb, int ipv, int cast_type) 2838 struct sk_buff *skb, int ipv, int cast_type)
2834{ 2839{
2835 struct neighbour *n = NULL;
2836 struct dst_entry *dst; 2840 struct dst_entry *dst;
2837 2841
2838 memset(hdr, 0, sizeof(struct qeth_hdr)); 2842 memset(hdr, 0, sizeof(struct qeth_hdr));
@@ -2855,33 +2859,29 @@ static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
2855 2859
2856 rcu_read_lock(); 2860 rcu_read_lock();
2857 dst = skb_dst(skb); 2861 dst = skb_dst(skb);
2858 if (dst)
2859 n = dst_get_neighbour_noref(dst);
2860 if (ipv == 4) { 2862 if (ipv == 4) {
2863 struct rtable *rt = (struct rtable *) dst;
2864 __be32 *pkey = &ip_hdr(skb)->daddr;
2865
2866 if (rt->rt_gateway)
2867 pkey = &rt->rt_gateway;
2868
2861 /* IPv4 */ 2869 /* IPv4 */
2862 hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags4(cast_type); 2870 hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags4(cast_type);
2863 memset(hdr->hdr.l3.dest_addr, 0, 12); 2871 memset(hdr->hdr.l3.dest_addr, 0, 12);
2864 if (n) { 2872 *((__be32 *) (&hdr->hdr.l3.dest_addr[12])) = *pkey;
2865 *((u32 *) (&hdr->hdr.l3.dest_addr[12])) =
2866 *((u32 *) n->primary_key);
2867 } else {
2868 /* fill in destination address used in ip header */
2869 *((u32 *) (&hdr->hdr.l3.dest_addr[12])) =
2870 ip_hdr(skb)->daddr;
2871 }
2872 } else if (ipv == 6) { 2873 } else if (ipv == 6) {
2874 struct rt6_info *rt = (struct rt6_info *) dst;
2875 struct in6_addr *pkey = &ipv6_hdr(skb)->daddr;
2876
2877 if (!ipv6_addr_any(&rt->rt6i_gateway))
2878 pkey = &rt->rt6i_gateway;
2879
2873 /* IPv6 */ 2880 /* IPv6 */
2874 hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags6(cast_type); 2881 hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags6(cast_type);
2875 if (card->info.type == QETH_CARD_TYPE_IQD) 2882 if (card->info.type == QETH_CARD_TYPE_IQD)
2876 hdr->hdr.l3.flags &= ~QETH_HDR_PASSTHRU; 2883 hdr->hdr.l3.flags &= ~QETH_HDR_PASSTHRU;
2877 if (n) { 2884 memcpy(hdr->hdr.l3.dest_addr, pkey, 16);
2878 memcpy(hdr->hdr.l3.dest_addr,
2879 n->primary_key, 16);
2880 } else {
2881 /* fill in destination address used in ip header */
2882 memcpy(hdr->hdr.l3.dest_addr,
2883 &ipv6_hdr(skb)->daddr, 16);
2884 }
2885 } else { 2885 } else {
2886 /* passthrough */ 2886 /* passthrough */
2887 if ((skb->dev->type == ARPHRD_IEEE802_TR) && 2887 if ((skb->dev->type == ARPHRD_IEEE802_TR) &&
diff --git a/drivers/ssb/pci.c b/drivers/ssb/pci.c
index 973223f5de8e..befa89eac6f3 100644
--- a/drivers/ssb/pci.c
+++ b/drivers/ssb/pci.c
@@ -523,7 +523,13 @@ static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in)
523static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in) 523static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in)
524{ 524{
525 int i; 525 int i;
526 u16 v; 526 u16 v, o;
527 u16 pwr_info_offset[] = {
528 SSB_SROM8_PWR_INFO_CORE0, SSB_SROM8_PWR_INFO_CORE1,
529 SSB_SROM8_PWR_INFO_CORE2, SSB_SROM8_PWR_INFO_CORE3
530 };
531 BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
532 ARRAY_SIZE(out->core_pwr_info));
527 533
528 /* extract the MAC address */ 534 /* extract the MAC address */
529 for (i = 0; i < 3; i++) { 535 for (i = 0; i < 3; i++) {
@@ -607,6 +613,38 @@ static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in)
607 memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24, 613 memcpy(&out->antenna_gain.ghz5, &out->antenna_gain.ghz24,
608 sizeof(out->antenna_gain.ghz5)); 614 sizeof(out->antenna_gain.ghz5));
609 615
616 /* Extract cores power info info */
617 for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
618 o = pwr_info_offset[i];
619 SPEX(core_pwr_info[i].itssi_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
620 SSB_SPROM8_2G_ITSSI, SSB_SPROM8_2G_ITSSI_SHIFT);
621 SPEX(core_pwr_info[i].maxpwr_2g, o + SSB_SROM8_2G_MAXP_ITSSI,
622 SSB_SPROM8_2G_MAXP, 0);
623
624 SPEX(core_pwr_info[i].pa_2g[0], o + SSB_SROM8_2G_PA_0, ~0, 0);
625 SPEX(core_pwr_info[i].pa_2g[1], o + SSB_SROM8_2G_PA_1, ~0, 0);
626 SPEX(core_pwr_info[i].pa_2g[2], o + SSB_SROM8_2G_PA_2, ~0, 0);
627
628 SPEX(core_pwr_info[i].itssi_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
629 SSB_SPROM8_5G_ITSSI, SSB_SPROM8_5G_ITSSI_SHIFT);
630 SPEX(core_pwr_info[i].maxpwr_5g, o + SSB_SROM8_5G_MAXP_ITSSI,
631 SSB_SPROM8_5G_MAXP, 0);
632 SPEX(core_pwr_info[i].maxpwr_5gh, o + SSB_SPROM8_5GHL_MAXP,
633 SSB_SPROM8_5GH_MAXP, 0);
634 SPEX(core_pwr_info[i].maxpwr_5gl, o + SSB_SPROM8_5GHL_MAXP,
635 SSB_SPROM8_5GL_MAXP, SSB_SPROM8_5GL_MAXP_SHIFT);
636
637 SPEX(core_pwr_info[i].pa_5gl[0], o + SSB_SROM8_5GL_PA_0, ~0, 0);
638 SPEX(core_pwr_info[i].pa_5gl[1], o + SSB_SROM8_5GL_PA_1, ~0, 0);
639 SPEX(core_pwr_info[i].pa_5gl[2], o + SSB_SROM8_5GL_PA_2, ~0, 0);
640 SPEX(core_pwr_info[i].pa_5g[0], o + SSB_SROM8_5G_PA_0, ~0, 0);
641 SPEX(core_pwr_info[i].pa_5g[1], o + SSB_SROM8_5G_PA_1, ~0, 0);
642 SPEX(core_pwr_info[i].pa_5g[2], o + SSB_SROM8_5G_PA_2, ~0, 0);
643 SPEX(core_pwr_info[i].pa_5gh[0], o + SSB_SROM8_5GH_PA_0, ~0, 0);
644 SPEX(core_pwr_info[i].pa_5gh[1], o + SSB_SROM8_5GH_PA_1, ~0, 0);
645 SPEX(core_pwr_info[i].pa_5gh[2], o + SSB_SROM8_5GH_PA_2, ~0, 0);
646 }
647
610 /* Extract FEM info */ 648 /* Extract FEM info */
611 SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G, 649 SPEX(fem.ghz2.tssipos, SSB_SPROM8_FEM2G,
612 SSB_SROM8_FEM_TSSIPOS, SSB_SROM8_FEM_TSSIPOS_SHIFT); 650 SSB_SROM8_FEM_TSSIPOS, SSB_SROM8_FEM_TSSIPOS_SHIFT);
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index a0969fcb72b9..5d2efe7e3f1b 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -92,7 +92,7 @@ void can_bus_off(struct net_device *dev);
92 92
93void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, 93void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
94 unsigned int idx); 94 unsigned int idx);
95void can_get_echo_skb(struct net_device *dev, unsigned int idx); 95unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx);
96void can_free_echo_skb(struct net_device *dev, unsigned int idx); 96void can_free_echo_skb(struct net_device *dev, unsigned int idx);
97 97
98struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf); 98struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf);
diff --git a/include/linux/in.h b/include/linux/in.h
index 01129c0ea87c..e0337f11d92e 100644
--- a/include/linux/in.h
+++ b/include/linux/in.h
@@ -111,6 +111,7 @@ struct in_addr {
111#define MCAST_LEAVE_SOURCE_GROUP 47 111#define MCAST_LEAVE_SOURCE_GROUP 47
112#define MCAST_MSFILTER 48 112#define MCAST_MSFILTER 48
113#define IP_MULTICAST_ALL 49 113#define IP_MULTICAST_ALL 49
114#define IP_UNICAST_IF 50
114 115
115#define MCAST_EXCLUDE 0 116#define MCAST_EXCLUDE 0
116#define MCAST_INCLUDE 1 117#define MCAST_INCLUDE 1
diff --git a/include/linux/in6.h b/include/linux/in6.h
index 097a34b55560..5c83d9e3eb8f 100644
--- a/include/linux/in6.h
+++ b/include/linux/in6.h
@@ -271,6 +271,7 @@ struct in6_flowlabel_req {
271#define IPV6_ORIGDSTADDR 74 271#define IPV6_ORIGDSTADDR 74
272#define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR 272#define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR
273#define IPV6_TRANSPARENT 75 273#define IPV6_TRANSPARENT 75
274#define IPV6_UNICAST_IF 76
274 275
275/* 276/*
276 * Multicast Routing: 277 * Multicast Routing:
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 6318268dcaf5..743a16a41040 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -324,6 +324,7 @@ struct ipv6_pinfo {
324 __unused_2:6; 324 __unused_2:6;
325 __s16 mcast_hops:9; 325 __s16 mcast_hops:9;
326#endif 326#endif
327 int ucast_oif;
327 int mcast_oif; 328 int mcast_oif;
328 329
329 /* pktoption flags */ 330 /* pktoption flags */
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 52e48959cfa1..a390e9d54827 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -237,22 +237,8 @@ struct netlink_notify {
237 int protocol; 237 int protocol;
238}; 238};
239 239
240static __inline__ struct nlmsghdr * 240struct nlmsghdr *
241__nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags) 241__nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags);
242{
243 struct nlmsghdr *nlh;
244 int size = NLMSG_LENGTH(len);
245
246 nlh = (struct nlmsghdr*)skb_put(skb, NLMSG_ALIGN(size));
247 nlh->nlmsg_type = type;
248 nlh->nlmsg_len = size;
249 nlh->nlmsg_flags = flags;
250 nlh->nlmsg_pid = pid;
251 nlh->nlmsg_seq = seq;
252 if (!__builtin_constant_p(size) || NLMSG_ALIGN(size) - size != 0)
253 memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size);
254 return nlh;
255}
256 242
257#define NLMSG_NEW(skb, pid, seq, type, len, flags) \ 243#define NLMSG_NEW(skb, pid, seq, type, len, flags) \
258({ if (unlikely(skb_tailroom(skb) < (int)NLMSG_SPACE(len))) \ 244({ if (unlikely(skb_tailroom(skb) < (int)NLMSG_SPACE(len))) \
diff --git a/include/linux/nfc.h b/include/linux/nfc.h
index 01d4e5d60325..b4999abcb2a2 100644
--- a/include/linux/nfc.h
+++ b/include/linux/nfc.h
@@ -89,6 +89,8 @@ enum nfc_commands {
89 * @NFC_ATTR_TARGET_SEL_RES: NFC-A targets extra information (useful if the 89 * @NFC_ATTR_TARGET_SEL_RES: NFC-A targets extra information (useful if the
90 * target is not NFC-Forum compliant) 90 * target is not NFC-Forum compliant)
91 * @NFC_ATTR_TARGET_NFCID1: NFC-A targets identifier, max 10 bytes 91 * @NFC_ATTR_TARGET_NFCID1: NFC-A targets identifier, max 10 bytes
92 * @NFC_ATTR_TARGET_SENSB_RES: NFC-B targets extra information, max 12 bytes
93 * @NFC_ATTR_TARGET_SENSF_RES: NFC-F targets extra information, max 18 bytes
92 * @NFC_ATTR_COMM_MODE: Passive or active mode 94 * @NFC_ATTR_COMM_MODE: Passive or active mode
93 * @NFC_ATTR_RF_MODE: Initiator or target 95 * @NFC_ATTR_RF_MODE: Initiator or target
94 */ 96 */
@@ -101,6 +103,8 @@ enum nfc_attrs {
101 NFC_ATTR_TARGET_SENS_RES, 103 NFC_ATTR_TARGET_SENS_RES,
102 NFC_ATTR_TARGET_SEL_RES, 104 NFC_ATTR_TARGET_SEL_RES,
103 NFC_ATTR_TARGET_NFCID1, 105 NFC_ATTR_TARGET_NFCID1,
106 NFC_ATTR_TARGET_SENSB_RES,
107 NFC_ATTR_TARGET_SENSF_RES,
104 NFC_ATTR_COMM_MODE, 108 NFC_ATTR_COMM_MODE,
105 NFC_ATTR_RF_MODE, 109 NFC_ATTR_RF_MODE,
106/* private: internal use only */ 110/* private: internal use only */
@@ -109,6 +113,9 @@ enum nfc_attrs {
109#define NFC_ATTR_MAX (__NFC_ATTR_AFTER_LAST - 1) 113#define NFC_ATTR_MAX (__NFC_ATTR_AFTER_LAST - 1)
110 114
111#define NFC_DEVICE_NAME_MAXSIZE 8 115#define NFC_DEVICE_NAME_MAXSIZE 8
116#define NFC_NFCID1_MAXSIZE 10
117#define NFC_SENSB_RES_MAXSIZE 12
118#define NFC_SENSF_RES_MAXSIZE 18
112 119
113/* NFC protocols */ 120/* NFC protocols */
114#define NFC_PROTO_JEWEL 1 121#define NFC_PROTO_JEWEL 1
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index 0f5ff3739820..ad56e21a9f10 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -1475,6 +1475,7 @@ enum nl80211_attrs {
1475#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS 1475#define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS
1476 1476
1477#define NL80211_MAX_SUPP_RATES 32 1477#define NL80211_MAX_SUPP_RATES 32
1478#define NL80211_MAX_SUPP_HT_RATES 77
1478#define NL80211_MAX_SUPP_REG_RULES 32 1479#define NL80211_MAX_SUPP_REG_RULES 32
1479#define NL80211_TKIP_DATA_OFFSET_ENCR_KEY 0 1480#define NL80211_TKIP_DATA_OFFSET_ENCR_KEY 0
1480#define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16 1481#define NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY 16
@@ -2104,6 +2105,9 @@ enum nl80211_mntr_flags {
2104 * TUs) during which a mesh STA can send only one Action frame containing a 2105 * TUs) during which a mesh STA can send only one Action frame containing a
2105 * PERR element. 2106 * PERR element.
2106 * 2107 *
2108 * @NL80211_MESHCONF_FORWARDING: set Mesh STA as forwarding or non-forwarding
2109 * or forwarding entity (default is TRUE - forwarding entity)
2110 *
2107 * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute 2111 * @NL80211_MESHCONF_ATTR_MAX: highest possible mesh configuration attribute
2108 * 2112 *
2109 * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use 2113 * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use
@@ -2128,6 +2132,7 @@ enum nl80211_meshconf_params {
2128 NL80211_MESHCONF_HWMP_RANN_INTERVAL, 2132 NL80211_MESHCONF_HWMP_RANN_INTERVAL,
2129 NL80211_MESHCONF_GATE_ANNOUNCEMENTS, 2133 NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
2130 NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, 2134 NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
2135 NL80211_MESHCONF_FORWARDING,
2131 2136
2132 /* keep last */ 2137 /* keep last */
2133 __NL80211_MESHCONF_ATTR_AFTER_LAST, 2138 __NL80211_MESHCONF_ATTR_AFTER_LAST,
@@ -2401,12 +2406,15 @@ enum nl80211_key_attributes {
2401 * in an array of rates as defined in IEEE 802.11 7.3.2.2 (u8 values with 2406 * in an array of rates as defined in IEEE 802.11 7.3.2.2 (u8 values with
2402 * 1 = 500 kbps) but without the IE length restriction (at most 2407 * 1 = 500 kbps) but without the IE length restriction (at most
2403 * %NL80211_MAX_SUPP_RATES in a single array). 2408 * %NL80211_MAX_SUPP_RATES in a single array).
2409 * @NL80211_TXRATE_MCS: HT (MCS) rates allowed for TX rate selection
2410 * in an array of MCS numbers.
2404 * @__NL80211_TXRATE_AFTER_LAST: internal 2411 * @__NL80211_TXRATE_AFTER_LAST: internal
2405 * @NL80211_TXRATE_MAX: highest TX rate attribute 2412 * @NL80211_TXRATE_MAX: highest TX rate attribute
2406 */ 2413 */
2407enum nl80211_tx_rate_attributes { 2414enum nl80211_tx_rate_attributes {
2408 __NL80211_TXRATE_INVALID, 2415 __NL80211_TXRATE_INVALID,
2409 NL80211_TXRATE_LEGACY, 2416 NL80211_TXRATE_LEGACY,
2417 NL80211_TXRATE_MCS,
2410 2418
2411 /* keep last */ 2419 /* keep last */
2412 __NL80211_TXRATE_AFTER_LAST, 2420 __NL80211_TXRATE_AFTER_LAST,
diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
index 0d5b79365d03..410b33d014d2 100644
--- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h
@@ -127,6 +127,27 @@ struct tc_multiq_qopt {
127 __u16 max_bands; /* Maximum number of queues */ 127 __u16 max_bands; /* Maximum number of queues */
128}; 128};
129 129
130/* PLUG section */
131
132#define TCQ_PLUG_BUFFER 0
133#define TCQ_PLUG_RELEASE_ONE 1
134#define TCQ_PLUG_RELEASE_INDEFINITE 2
135#define TCQ_PLUG_LIMIT 3
136
137struct tc_plug_qopt {
138 /* TCQ_PLUG_BUFFER: Inset a plug into the queue and
139 * buffer any incoming packets
140 * TCQ_PLUG_RELEASE_ONE: Dequeue packets from queue head
141 * to beginning of the next plug.
142 * TCQ_PLUG_RELEASE_INDEFINITE: Dequeue all packets from queue.
143 * Stop buffering packets until the next TCQ_PLUG_BUFFER
144 * command is received (just act as a pass-thru queue).
145 * TCQ_PLUG_LIMIT: Increase/decrease queue size
146 */
147 int action;
148 __u32 limit;
149};
150
130/* TBF section */ 151/* TBF section */
131 152
132struct tc_tbf_qopt { 153struct tc_tbf_qopt {
diff --git a/include/linux/snmp.h b/include/linux/snmp.h
index c1241c428179..8ee8af4e6da9 100644
--- a/include/linux/snmp.h
+++ b/include/linux/snmp.h
@@ -232,6 +232,7 @@ enum
232 LINUX_MIB_TCPTIMEWAITOVERFLOW, /* TCPTimeWaitOverflow */ 232 LINUX_MIB_TCPTIMEWAITOVERFLOW, /* TCPTimeWaitOverflow */
233 LINUX_MIB_TCPREQQFULLDOCOOKIES, /* TCPReqQFullDoCookies */ 233 LINUX_MIB_TCPREQQFULLDOCOOKIES, /* TCPReqQFullDoCookies */
234 LINUX_MIB_TCPREQQFULLDROP, /* TCPReqQFullDrop */ 234 LINUX_MIB_TCPREQQFULLDROP, /* TCPReqQFullDrop */
235 LINUX_MIB_TCPRETRANSFAIL, /* TCPRetransFail */
235 __LINUX_MIB_MAX 236 __LINUX_MIB_MAX
236}; 237};
237 238
diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h
index dcf35b0f303a..bbc2612cb64a 100644
--- a/include/linux/ssb/ssb.h
+++ b/include/linux/ssb/ssb.h
@@ -16,6 +16,12 @@ struct pcmcia_device;
16struct ssb_bus; 16struct ssb_bus;
17struct ssb_driver; 17struct ssb_driver;
18 18
19struct ssb_sprom_core_pwr_info {
20 u8 itssi_2g, itssi_5g;
21 u8 maxpwr_2g, maxpwr_5gl, maxpwr_5g, maxpwr_5gh;
22 u16 pa_2g[3], pa_5gl[3], pa_5g[3], pa_5gh[3];
23};
24
19struct ssb_sprom { 25struct ssb_sprom {
20 u8 revision; 26 u8 revision;
21 u8 il0mac[6]; /* MAC address for 802.11b/g */ 27 u8 il0mac[6]; /* MAC address for 802.11b/g */
@@ -82,6 +88,8 @@ struct ssb_sprom {
82 u16 boardflags2_hi; /* Board flags (bits 48-63) */ 88 u16 boardflags2_hi; /* Board flags (bits 48-63) */
83 /* TODO store board flags in a single u64 */ 89 /* TODO store board flags in a single u64 */
84 90
91 struct ssb_sprom_core_pwr_info core_pwr_info[4];
92
85 /* Antenna gain values for up to 4 antennas 93 /* Antenna gain values for up to 4 antennas
86 * on each band. Values in dBm/4 (Q5.2). Negative gain means the 94 * on each band. Values in dBm/4 (Q5.2). Negative gain means the
87 * loss in the connectors is bigger than the gain. */ 95 * loss in the connectors is bigger than the gain. */
diff --git a/include/linux/ssb/ssb_regs.h b/include/linux/ssb/ssb_regs.h
index c814ae6eeb22..40b1ef8595ee 100644
--- a/include/linux/ssb/ssb_regs.h
+++ b/include/linux/ssb/ssb_regs.h
@@ -449,6 +449,39 @@
449#define SSB_SPROM8_TS_SLP_OPT_CORRX 0x00B6 449#define SSB_SPROM8_TS_SLP_OPT_CORRX 0x00B6
450#define SSB_SPROM8_FOC_HWIQ_IQSWP 0x00B8 450#define SSB_SPROM8_FOC_HWIQ_IQSWP 0x00B8
451#define SSB_SPROM8_PHYCAL_TEMPDELTA 0x00BA 451#define SSB_SPROM8_PHYCAL_TEMPDELTA 0x00BA
452
453/* There are 4 blocks with power info sharing the same layout */
454#define SSB_SROM8_PWR_INFO_CORE0 0x00C0
455#define SSB_SROM8_PWR_INFO_CORE1 0x00E0
456#define SSB_SROM8_PWR_INFO_CORE2 0x0100
457#define SSB_SROM8_PWR_INFO_CORE3 0x0120
458
459#define SSB_SROM8_2G_MAXP_ITSSI 0x00
460#define SSB_SPROM8_2G_MAXP 0x00FF
461#define SSB_SPROM8_2G_ITSSI 0xFF00
462#define SSB_SPROM8_2G_ITSSI_SHIFT 8
463#define SSB_SROM8_2G_PA_0 0x02 /* 2GHz power amp settings */
464#define SSB_SROM8_2G_PA_1 0x04
465#define SSB_SROM8_2G_PA_2 0x06
466#define SSB_SROM8_5G_MAXP_ITSSI 0x08 /* 5GHz ITSSI and 5.3GHz Max Power */
467#define SSB_SPROM8_5G_MAXP 0x00FF
468#define SSB_SPROM8_5G_ITSSI 0xFF00
469#define SSB_SPROM8_5G_ITSSI_SHIFT 8
470#define SSB_SPROM8_5GHL_MAXP 0x0A /* 5.2GHz and 5.8GHz Max Power */
471#define SSB_SPROM8_5GH_MAXP 0x00FF
472#define SSB_SPROM8_5GL_MAXP 0xFF00
473#define SSB_SPROM8_5GL_MAXP_SHIFT 8
474#define SSB_SROM8_5G_PA_0 0x0C /* 5.3GHz power amp settings */
475#define SSB_SROM8_5G_PA_1 0x0E
476#define SSB_SROM8_5G_PA_2 0x10
477#define SSB_SROM8_5GL_PA_0 0x12 /* 5.2GHz power amp settings */
478#define SSB_SROM8_5GL_PA_1 0x14
479#define SSB_SROM8_5GL_PA_2 0x16
480#define SSB_SROM8_5GH_PA_0 0x18 /* 5.8GHz power amp settings */
481#define SSB_SROM8_5GH_PA_1 0x1A
482#define SSB_SROM8_5GH_PA_2 0x1C
483
484/* TODO: Make it deprecated */
452#define SSB_SPROM8_MAXP_BG 0x00C0 /* Max Power 2GHz in path 1 */ 485#define SSB_SPROM8_MAXP_BG 0x00C0 /* Max Power 2GHz in path 1 */
453#define SSB_SPROM8_MAXP_BG_MASK 0x00FF /* Mask for Max Power 2GHz */ 486#define SSB_SPROM8_MAXP_BG_MASK 0x00FF /* Mask for Max Power 2GHz */
454#define SSB_SPROM8_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */ 487#define SSB_SPROM8_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */
@@ -473,6 +506,7 @@
473#define SSB_SPROM8_PA1HIB0 0x00D8 /* 5.8GHz power amp settings */ 506#define SSB_SPROM8_PA1HIB0 0x00D8 /* 5.8GHz power amp settings */
474#define SSB_SPROM8_PA1HIB1 0x00DA 507#define SSB_SPROM8_PA1HIB1 0x00DA
475#define SSB_SPROM8_PA1HIB2 0x00DC 508#define SSB_SPROM8_PA1HIB2 0x00DC
509
476#define SSB_SPROM8_CCK2GPO 0x0140 /* CCK power offset */ 510#define SSB_SPROM8_CCK2GPO 0x0140 /* CCK power offset */
477#define SSB_SPROM8_OFDM2GPO 0x0142 /* 2.4GHz OFDM power offset */ 511#define SSB_SPROM8_OFDM2GPO 0x0142 /* 2.4GHz OFDM power offset */
478#define SSB_SPROM8_OFDM5GPO 0x0146 /* 5.3GHz OFDM power offset */ 512#define SSB_SPROM8_OFDM5GPO 0x0146 /* 5.3GHz OFDM power offset */
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 46a85c9e1f25..115389e9b945 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -463,7 +463,7 @@ struct tcp_sock {
463 const struct tcp_sock_af_ops *af_specific; 463 const struct tcp_sock_af_ops *af_specific;
464 464
465/* TCP MD5 Signature Option information */ 465/* TCP MD5 Signature Option information */
466 struct tcp_md5sig_info *md5sig_info; 466 struct tcp_md5sig_info __rcu *md5sig_info;
467#endif 467#endif
468 468
469 /* When the cookie options are generated and exchanged, then this 469 /* When the cookie options are generated and exchanged, then this
@@ -486,8 +486,7 @@ struct tcp_timewait_sock {
486 u32 tw_ts_recent; 486 u32 tw_ts_recent;
487 long tw_ts_recent_stamp; 487 long tw_ts_recent_stamp;
488#ifdef CONFIG_TCP_MD5SIG 488#ifdef CONFIG_TCP_MD5SIG
489 u16 tw_md5_keylen; 489 struct tcp_md5sig_key *tw_md5_key;
490 u8 tw_md5_key[TCP_MD5SIG_MAXKEYLEN];
491#endif 490#endif
492 /* Few sockets in timewait have cookies; in that case, then this 491 /* Few sockets in timewait have cookies; in that case, then this
493 * object holds a reference to them (tw_cookie_values->kref). 492 * object holds a reference to them (tw_cookie_values->kref).
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index f68dce2d8d88..757a17638b1b 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -160,7 +160,6 @@ extern void addrconf_prefix_rcv(struct net_device *dev,
160extern int ipv6_sock_ac_join(struct sock *sk,int ifindex, const struct in6_addr *addr); 160extern int ipv6_sock_ac_join(struct sock *sk,int ifindex, const struct in6_addr *addr);
161extern int ipv6_sock_ac_drop(struct sock *sk,int ifindex, const struct in6_addr *addr); 161extern int ipv6_sock_ac_drop(struct sock *sk,int ifindex, const struct in6_addr *addr);
162extern void ipv6_sock_ac_close(struct sock *sk); 162extern void ipv6_sock_ac_close(struct sock *sk);
163extern int inet6_ac_check(struct sock *sk, const struct in6_addr *addr, int ifindex);
164 163
165extern int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr); 164extern int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr);
166extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr); 165extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr);
diff --git a/include/net/caif/caif_hsi.h b/include/net/caif/caif_hsi.h
index 8d552519ff67..6db8ecf52aa2 100644
--- a/include/net/caif/caif_hsi.h
+++ b/include/net/caif/caif_hsi.h
@@ -138,6 +138,7 @@ struct cfhsi {
138 u8 *rx_ptr; 138 u8 *rx_ptr;
139 u8 *tx_buf; 139 u8 *tx_buf;
140 u8 *rx_buf; 140 u8 *rx_buf;
141 u8 *rx_flip_buf;
141 spinlock_t lock; 142 spinlock_t lock;
142 int flow_off_sent; 143 int flow_off_sent;
143 u32 q_low_mark; 144 u32 q_low_mark;
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index a067d30ce73e..2964205332f4 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -120,6 +120,7 @@ enum ieee80211_channel_flags {
120 * @band: band this channel belongs to. 120 * @band: band this channel belongs to.
121 * @max_antenna_gain: maximum antenna gain in dBi 121 * @max_antenna_gain: maximum antenna gain in dBi
122 * @max_power: maximum transmission power (in dBm) 122 * @max_power: maximum transmission power (in dBm)
123 * @max_reg_power: maximum regulatory transmission power (in dBm)
123 * @beacon_found: helper to regulatory code to indicate when a beacon 124 * @beacon_found: helper to regulatory code to indicate when a beacon
124 * has been found on this channel. Use regulatory_hint_found_beacon() 125 * has been found on this channel. Use regulatory_hint_found_beacon()
125 * to enable this, this is useful only on 5 GHz band. 126 * to enable this, this is useful only on 5 GHz band.
@@ -133,6 +134,7 @@ struct ieee80211_channel {
133 u32 flags; 134 u32 flags;
134 int max_antenna_gain; 135 int max_antenna_gain;
135 int max_power; 136 int max_power;
137 int max_reg_power;
136 bool beacon_found; 138 bool beacon_found;
137 u32 orig_flags; 139 u32 orig_flags;
138 int orig_mag, orig_mpwr; 140 int orig_mag, orig_mpwr;
@@ -796,6 +798,7 @@ struct mesh_config {
796 * mesh gate, but not necessarily using the gate announcement protocol. 798 * mesh gate, but not necessarily using the gate announcement protocol.
797 * Still keeping the same nomenclature to be in sync with the spec. */ 799 * Still keeping the same nomenclature to be in sync with the spec. */
798 bool dot11MeshGateAnnouncementProtocol; 800 bool dot11MeshGateAnnouncementProtocol;
801 bool dot11MeshForwarding;
799}; 802};
800 803
801/** 804/**
@@ -1229,8 +1232,7 @@ enum wiphy_params_flags {
1229struct cfg80211_bitrate_mask { 1232struct cfg80211_bitrate_mask {
1230 struct { 1233 struct {
1231 u32 legacy; 1234 u32 legacy;
1232 /* TODO: add support for masking MCS rates; e.g.: */ 1235 u8 mcs[IEEE80211_HT_MCS_MASK_LEN];
1233 /* u8 mcs[IEEE80211_HT_MCS_MASK_LEN]; */
1234 } control[IEEE80211_NUM_BANDS]; 1236 } control[IEEE80211_NUM_BANDS];
1235}; 1237};
1236/** 1238/**
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 7db32995ccd3..ccb68880abf5 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -131,35 +131,8 @@ extern void genl_unregister_mc_group(struct genl_family *family,
131extern void genl_notify(struct sk_buff *skb, struct net *net, u32 pid, 131extern void genl_notify(struct sk_buff *skb, struct net *net, u32 pid,
132 u32 group, struct nlmsghdr *nlh, gfp_t flags); 132 u32 group, struct nlmsghdr *nlh, gfp_t flags);
133 133
134/** 134void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq,
135 * genlmsg_put - Add generic netlink header to netlink message 135 struct genl_family *family, int flags, u8 cmd);
136 * @skb: socket buffer holding the message
137 * @pid: netlink pid the message is addressed to
138 * @seq: sequence number (usually the one of the sender)
139 * @family: generic netlink family
140 * @flags netlink message flags
141 * @cmd: generic netlink command
142 *
143 * Returns pointer to user specific header
144 */
145static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq,
146 struct genl_family *family, int flags, u8 cmd)
147{
148 struct nlmsghdr *nlh;
149 struct genlmsghdr *hdr;
150
151 nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN +
152 family->hdrsize, flags);
153 if (nlh == NULL)
154 return NULL;
155
156 hdr = nlmsg_data(nlh);
157 hdr->cmd = cmd;
158 hdr->version = family->version;
159 hdr->reserved = 0;
160
161 return (char *) hdr + GENL_HDRLEN;
162}
163 136
164/** 137/**
165 * genlmsg_nlhdr - Obtain netlink header from user specified header 138 * genlmsg_nlhdr - Obtain netlink header from user specified header
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index e3e405106afe..022f772c0ebe 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -132,6 +132,7 @@ struct rtable;
132 * @tos - TOS 132 * @tos - TOS
133 * @mc_ttl - Multicasting TTL 133 * @mc_ttl - Multicasting TTL
134 * @is_icsk - is this an inet_connection_sock? 134 * @is_icsk - is this an inet_connection_sock?
135 * @uc_index - Unicast outgoing device index
135 * @mc_index - Multicast device index 136 * @mc_index - Multicast device index
136 * @mc_list - Group array 137 * @mc_list - Group array
137 * @cork - info to build ip hdr on each ip frag while socket is corked 138 * @cork - info to build ip hdr on each ip frag while socket is corked
@@ -167,6 +168,7 @@ struct inet_sock {
167 transparent:1, 168 transparent:1,
168 mc_all:1, 169 mc_all:1,
169 nodefrag:1; 170 nodefrag:1;
171 int uc_index;
170 int mc_index; 172 int mc_index;
171 __be32 mc_addr; 173 __be32 mc_addr;
172 struct ip_mc_socklist __rcu *mc_list; 174 struct ip_mc_socklist __rcu *mc_list;
diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
index 0954ec959159..2e1d5ecc2d1b 100644
--- a/include/net/iucv/af_iucv.h
+++ b/include/net/iucv/af_iucv.h
@@ -113,6 +113,7 @@ struct iucv_sock {
113 spinlock_t accept_q_lock; 113 spinlock_t accept_q_lock;
114 struct sock *parent; 114 struct sock *parent;
115 struct iucv_path *path; 115 struct iucv_path *path;
116 struct net_device *hs_dev;
116 struct sk_buff_head send_skb_q; 117 struct sk_buff_head send_skb_q;
117 struct sk_buff_head backlog_skb_q; 118 struct sk_buff_head backlog_skb_q;
118 struct sock_msg_q message_q; 119 struct sock_msg_q message_q;
@@ -131,6 +132,7 @@ struct iucv_sock {
131/* iucv socket options (SOL_IUCV) */ 132/* iucv socket options (SOL_IUCV) */
132#define SO_IPRMDATA_MSG 0x0080 /* send/recv IPRM_DATA msgs */ 133#define SO_IPRMDATA_MSG 0x0080 /* send/recv IPRM_DATA msgs */
133#define SO_MSGLIMIT 0x1000 /* get/set IUCV MSGLIMIT */ 134#define SO_MSGLIMIT 0x1000 /* get/set IUCV MSGLIMIT */
135#define SO_MSGSIZE 0x0800 /* get maximum msgsize */
134 136
135/* iucv related control messages (scm) */ 137/* iucv related control messages (scm) */
136#define SCM_IUCV_TRGCLS 0x0001 /* target class control message */ 138#define SCM_IUCV_TRGCLS 0x0001 /* target class control message */
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index d49928ba5d09..520eb4c5e5a2 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -852,6 +852,21 @@ struct ieee80211_channel_switch {
852}; 852};
853 853
854/** 854/**
855 * enum ieee80211_vif_flags - virtual interface flags
856 *
857 * @IEEE80211_VIF_BEACON_FILTER: the device performs beacon filtering
858 * on this virtual interface to avoid unnecessary CPU wakeups
859 * @IEEE80211_VIF_SUPPORTS_CQM_RSSI: the device can do connection quality
860 * monitoring on this virtual interface -- i.e. it can monitor
861 * connection quality related parameters, such as the RSSI level and
862 * provide notifications if configured trigger levels are reached.
863 */
864enum ieee80211_vif_flags {
865 IEEE80211_VIF_BEACON_FILTER = BIT(0),
866 IEEE80211_VIF_SUPPORTS_CQM_RSSI = BIT(1),
867};
868
869/**
855 * struct ieee80211_vif - per-interface data 870 * struct ieee80211_vif - per-interface data
856 * 871 *
857 * Data in this structure is continually present for driver 872 * Data in this structure is continually present for driver
@@ -863,6 +878,10 @@ struct ieee80211_channel_switch {
863 * @addr: address of this interface 878 * @addr: address of this interface
864 * @p2p: indicates whether this AP or STA interface is a p2p 879 * @p2p: indicates whether this AP or STA interface is a p2p
865 * interface, i.e. a GO or p2p-sta respectively 880 * interface, i.e. a GO or p2p-sta respectively
881 * @driver_flags: flags/capabilities the driver has for this interface,
882 * these need to be set (or cleared) when the interface is added
883 * or, if supported by the driver, the interface type is changed
884 * at runtime, mac80211 will never touch this field
866 * @drv_priv: data area for driver use, will always be aligned to 885 * @drv_priv: data area for driver use, will always be aligned to
867 * sizeof(void *). 886 * sizeof(void *).
868 */ 887 */
@@ -871,6 +890,7 @@ struct ieee80211_vif {
871 struct ieee80211_bss_conf bss_conf; 890 struct ieee80211_bss_conf bss_conf;
872 u8 addr[ETH_ALEN]; 891 u8 addr[ETH_ALEN];
873 bool p2p; 892 bool p2p;
893 u32 driver_flags;
874 /* must be last */ 894 /* must be last */
875 u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); 895 u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
876}; 896};
@@ -1079,10 +1099,6 @@ enum sta_notify_cmd {
1079 * @IEEE80211_HW_MFP_CAPABLE: 1099 * @IEEE80211_HW_MFP_CAPABLE:
1080 * Hardware supports management frame protection (MFP, IEEE 802.11w). 1100 * Hardware supports management frame protection (MFP, IEEE 802.11w).
1081 * 1101 *
1082 * @IEEE80211_HW_BEACON_FILTER:
1083 * Hardware supports dropping of irrelevant beacon frames to
1084 * avoid waking up cpu.
1085 *
1086 * @IEEE80211_HW_SUPPORTS_STATIC_SMPS: 1102 * @IEEE80211_HW_SUPPORTS_STATIC_SMPS:
1087 * Hardware supports static spatial multiplexing powersave, 1103 * Hardware supports static spatial multiplexing powersave,
1088 * ie. can turn off all but one chain even on HT connections 1104 * ie. can turn off all but one chain even on HT connections
@@ -1108,11 +1124,6 @@ enum sta_notify_cmd {
1108 * When this flag is set, signaling beacon-loss will cause an immediate 1124 * When this flag is set, signaling beacon-loss will cause an immediate
1109 * change to disassociated state. 1125 * change to disassociated state.
1110 * 1126 *
1111 * @IEEE80211_HW_SUPPORTS_CQM_RSSI:
1112 * Hardware can do connection quality monitoring - i.e. it can monitor
1113 * connection quality related parameters, such as the RSSI level and
1114 * provide notifications if configured trigger levels are reached.
1115 *
1116 * @IEEE80211_HW_NEED_DTIM_PERIOD: 1127 * @IEEE80211_HW_NEED_DTIM_PERIOD:
1117 * This device needs to know the DTIM period for the BSS before 1128 * This device needs to know the DTIM period for the BSS before
1118 * associating. 1129 * associating.
@@ -1150,13 +1161,13 @@ enum ieee80211_hw_flags {
1150 IEEE80211_HW_PS_NULLFUNC_STACK = 1<<11, 1161 IEEE80211_HW_PS_NULLFUNC_STACK = 1<<11,
1151 IEEE80211_HW_SUPPORTS_DYNAMIC_PS = 1<<12, 1162 IEEE80211_HW_SUPPORTS_DYNAMIC_PS = 1<<12,
1152 IEEE80211_HW_MFP_CAPABLE = 1<<13, 1163 IEEE80211_HW_MFP_CAPABLE = 1<<13,
1153 IEEE80211_HW_BEACON_FILTER = 1<<14, 1164 /* reuse bit 14 */
1154 IEEE80211_HW_SUPPORTS_STATIC_SMPS = 1<<15, 1165 IEEE80211_HW_SUPPORTS_STATIC_SMPS = 1<<15,
1155 IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS = 1<<16, 1166 IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS = 1<<16,
1156 IEEE80211_HW_SUPPORTS_UAPSD = 1<<17, 1167 IEEE80211_HW_SUPPORTS_UAPSD = 1<<17,
1157 IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18, 1168 IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18,
1158 IEEE80211_HW_CONNECTION_MONITOR = 1<<19, 1169 IEEE80211_HW_CONNECTION_MONITOR = 1<<19,
1159 IEEE80211_HW_SUPPORTS_CQM_RSSI = 1<<20, 1170 /* reuse bit 20 */
1160 IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21, 1171 IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21,
1161 IEEE80211_HW_AP_LINK_PS = 1<<22, 1172 IEEE80211_HW_AP_LINK_PS = 1<<22,
1162 IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23, 1173 IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23,
@@ -1446,8 +1457,8 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb);
1446 * way the host will only receive beacons where some relevant information 1457 * way the host will only receive beacons where some relevant information
1447 * (for example ERP protection or WMM settings) have changed. 1458 * (for example ERP protection or WMM settings) have changed.
1448 * 1459 *
1449 * Beacon filter support is advertised with the %IEEE80211_HW_BEACON_FILTER 1460 * Beacon filter support is advertised with the %IEEE80211_VIF_BEACON_FILTER
1450 * hardware capability. The driver needs to enable beacon filter support 1461 * interface capability. The driver needs to enable beacon filter support
1451 * whenever power save is enabled, that is %IEEE80211_CONF_PS is set. When 1462 * whenever power save is enabled, that is %IEEE80211_CONF_PS is set. When
1452 * power save is enabled, the stack will not check for beacon loss and the 1463 * power save is enabled, the stack will not check for beacon loss and the
1453 * driver needs to notify about loss of beacons with ieee80211_beacon_loss(). 1464 * driver needs to notify about loss of beacons with ieee80211_beacon_loss().
@@ -3316,7 +3327,7 @@ struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw,
3316 * 3327 *
3317 * @vif: &struct ieee80211_vif pointer from the add_interface callback. 3328 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
3318 * 3329 *
3319 * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER and 3330 * When beacon filtering is enabled with %IEEE80211_VIF_BEACON_FILTER and
3320 * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the 3331 * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the
3321 * hardware is not receiving beacons with this function. 3332 * hardware is not receiving beacons with this function.
3322 */ 3333 */
@@ -3327,7 +3338,7 @@ void ieee80211_beacon_loss(struct ieee80211_vif *vif);
3327 * 3338 *
3328 * @vif: &struct ieee80211_vif pointer from the add_interface callback. 3339 * @vif: &struct ieee80211_vif pointer from the add_interface callback.
3329 * 3340 *
3330 * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER, and 3341 * When beacon filtering is enabled with %IEEE80211_VIF_BEACON_FILTER, and
3331 * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver 3342 * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver
3332 * needs to inform if the connection to the AP has been lost. 3343 * needs to inform if the connection to the AP has been lost.
3333 * 3344 *
@@ -3397,7 +3408,7 @@ void ieee80211_enable_dyn_ps(struct ieee80211_vif *vif);
3397 * @rssi_event: the RSSI trigger event type 3408 * @rssi_event: the RSSI trigger event type
3398 * @gfp: context flags 3409 * @gfp: context flags
3399 * 3410 *
3400 * When the %IEEE80211_HW_SUPPORTS_CQM_RSSI is set, and a connection quality 3411 * When the %IEEE80211_VIF_SUPPORTS_CQM_RSSI is set, and a connection quality
3401 * monitoring is configured with an rssi threshold, the driver will inform 3412 * monitoring is configured with an rssi threshold, the driver will inform
3402 * whenever the rssi level reaches the threshold. 3413 * whenever the rssi level reaches the threshold.
3403 */ 3414 */
@@ -3540,6 +3551,7 @@ struct ieee80211_tx_rate_control {
3540 bool rts, short_preamble; 3551 bool rts, short_preamble;
3541 u8 max_rate_idx; 3552 u8 max_rate_idx;
3542 u32 rate_idx_mask; 3553 u32 rate_idx_mask;
3554 u8 rate_idx_mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
3543 bool bss; 3555 bool bss;
3544}; 3556};
3545 3557
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index e3133c23980e..6f9c25a76cd1 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -133,7 +133,6 @@ extern void ndisc_send_rs(struct net_device *dev,
133 const struct in6_addr *daddr); 133 const struct in6_addr *daddr);
134 134
135extern void ndisc_send_redirect(struct sk_buff *skb, 135extern void ndisc_send_redirect(struct sk_buff *skb,
136 struct neighbour *neigh,
137 const struct in6_addr *target); 136 const struct in6_addr *target);
138 137
139extern int ndisc_mc_map(const struct in6_addr *addr, char *buf, 138extern int ndisc_mc_map(const struct in6_addr *addr, char *buf,
diff --git a/include/net/netlink.h b/include/net/netlink.h
index cb1f3504687f..f394fe5d7641 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -441,41 +441,6 @@ static inline int nlmsg_report(const struct nlmsghdr *nlh)
441 nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \ 441 nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \
442 nlmsg_attrlen(nlh, hdrlen), rem) 442 nlmsg_attrlen(nlh, hdrlen), rem)
443 443
444#if 0
445/* FIXME: Enable once all users have been converted */
446
447/**
448 * __nlmsg_put - Add a new netlink message to an skb
449 * @skb: socket buffer to store message in
450 * @pid: netlink process id
451 * @seq: sequence number of message
452 * @type: message type
453 * @payload: length of message payload
454 * @flags: message flags
455 *
456 * The caller is responsible to ensure that the skb provides enough
457 * tailroom for both the netlink header and payload.
458 */
459static inline struct nlmsghdr *__nlmsg_put(struct sk_buff *skb, u32 pid,
460 u32 seq, int type, int payload,
461 int flags)
462{
463 struct nlmsghdr *nlh;
464
465 nlh = (struct nlmsghdr *) skb_put(skb, nlmsg_total_size(payload));
466 nlh->nlmsg_type = type;
467 nlh->nlmsg_len = nlmsg_msg_size(payload);
468 nlh->nlmsg_flags = flags;
469 nlh->nlmsg_pid = pid;
470 nlh->nlmsg_seq = seq;
471
472 memset((unsigned char *) nlmsg_data(nlh) + payload, 0,
473 nlmsg_padlen(payload));
474
475 return nlh;
476}
477#endif
478
479/** 444/**
480 * nlmsg_put - Add a new netlink message to an skb 445 * nlmsg_put - Add a new netlink message to an skb
481 * @skb: socket buffer to store message in 446 * @skb: socket buffer to store message in
diff --git a/include/net/nfc/nci.h b/include/net/nfc/nci.h
index 2be95e2626c0..276094b91d7c 100644
--- a/include/net/nfc/nci.h
+++ b/include/net/nfc/nci.h
@@ -116,6 +116,11 @@
116#define NCI_DISC_MAP_MODE_POLL 0x01 116#define NCI_DISC_MAP_MODE_POLL 0x01
117#define NCI_DISC_MAP_MODE_LISTEN 0x02 117#define NCI_DISC_MAP_MODE_LISTEN 0x02
118 118
119/* NCI Discover Notification Type */
120#define NCI_DISCOVER_NTF_TYPE_LAST 0x00
121#define NCI_DISCOVER_NTF_TYPE_LAST_NFCC 0x01
122#define NCI_DISCOVER_NTF_TYPE_MORE 0x02
123
119/* NCI Deactivation Type */ 124/* NCI Deactivation Type */
120#define NCI_DEACTIVATE_TYPE_IDLE_MODE 0x00 125#define NCI_DEACTIVATE_TYPE_IDLE_MODE 0x00
121#define NCI_DEACTIVATE_TYPE_SLEEP_MODE 0x01 126#define NCI_DEACTIVATE_TYPE_SLEEP_MODE 0x01
@@ -207,6 +212,13 @@ struct nci_rf_disc_cmd {
207 struct disc_config disc_configs[NCI_MAX_NUM_RF_CONFIGS]; 212 struct disc_config disc_configs[NCI_MAX_NUM_RF_CONFIGS];
208} __packed; 213} __packed;
209 214
215#define NCI_OP_RF_DISCOVER_SELECT_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x04)
216struct nci_rf_discover_select_cmd {
217 __u8 rf_discovery_id;
218 __u8 rf_protocol;
219 __u8 rf_interface;
220} __packed;
221
210#define NCI_OP_RF_DEACTIVATE_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x06) 222#define NCI_OP_RF_DEACTIVATE_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x06)
211struct nci_rf_deactivate_cmd { 223struct nci_rf_deactivate_cmd {
212 __u8 type; 224 __u8 type;
@@ -244,6 +256,8 @@ struct nci_core_init_rsp_2 {
244 256
245#define NCI_OP_RF_DISCOVER_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x03) 257#define NCI_OP_RF_DISCOVER_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x03)
246 258
259#define NCI_OP_RF_DISCOVER_SELECT_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x04)
260
247#define NCI_OP_RF_DEACTIVATE_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x06) 261#define NCI_OP_RF_DEACTIVATE_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x06)
248 262
249/* --------------------------- */ 263/* --------------------------- */
@@ -260,13 +274,15 @@ struct nci_core_conn_credit_ntf {
260 struct conn_credit_entry conn_entries[NCI_MAX_NUM_CONN]; 274 struct conn_credit_entry conn_entries[NCI_MAX_NUM_CONN];
261} __packed; 275} __packed;
262 276
277#define NCI_OP_CORE_GENERIC_ERROR_NTF nci_opcode_pack(NCI_GID_CORE, 0x07)
278
263#define NCI_OP_CORE_INTF_ERROR_NTF nci_opcode_pack(NCI_GID_CORE, 0x08) 279#define NCI_OP_CORE_INTF_ERROR_NTF nci_opcode_pack(NCI_GID_CORE, 0x08)
264struct nci_core_intf_error_ntf { 280struct nci_core_intf_error_ntf {
265 __u8 status; 281 __u8 status;
266 __u8 conn_id; 282 __u8 conn_id;
267} __packed; 283} __packed;
268 284
269#define NCI_OP_RF_INTF_ACTIVATED_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x05) 285#define NCI_OP_RF_DISCOVER_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x03)
270struct rf_tech_specific_params_nfca_poll { 286struct rf_tech_specific_params_nfca_poll {
271 __u16 sens_res; 287 __u16 sens_res;
272 __u8 nfcid1_len; /* 0, 4, 7, or 10 Bytes */ 288 __u8 nfcid1_len; /* 0, 4, 7, or 10 Bytes */
@@ -275,11 +291,43 @@ struct rf_tech_specific_params_nfca_poll {
275 __u8 sel_res; 291 __u8 sel_res;
276} __packed; 292} __packed;
277 293
294struct rf_tech_specific_params_nfcb_poll {
295 __u8 sensb_res_len;
296 __u8 sensb_res[12]; /* 11 or 12 Bytes */
297} __packed;
298
299struct rf_tech_specific_params_nfcf_poll {
300 __u8 bit_rate;
301 __u8 sensf_res_len;
302 __u8 sensf_res[18]; /* 16 or 18 Bytes */
303} __packed;
304
305struct nci_rf_discover_ntf {
306 __u8 rf_discovery_id;
307 __u8 rf_protocol;
308 __u8 rf_tech_and_mode;
309 __u8 rf_tech_specific_params_len;
310
311 union {
312 struct rf_tech_specific_params_nfca_poll nfca_poll;
313 struct rf_tech_specific_params_nfcb_poll nfcb_poll;
314 struct rf_tech_specific_params_nfcf_poll nfcf_poll;
315 } rf_tech_specific_params;
316
317 __u8 ntf_type;
318} __packed;
319
320#define NCI_OP_RF_INTF_ACTIVATED_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x05)
278struct activation_params_nfca_poll_iso_dep { 321struct activation_params_nfca_poll_iso_dep {
279 __u8 rats_res_len; 322 __u8 rats_res_len;
280 __u8 rats_res[20]; 323 __u8 rats_res[20];
281}; 324};
282 325
326struct activation_params_nfcb_poll_iso_dep {
327 __u8 attrib_res_len;
328 __u8 attrib_res[50];
329};
330
283struct nci_rf_intf_activated_ntf { 331struct nci_rf_intf_activated_ntf {
284 __u8 rf_discovery_id; 332 __u8 rf_discovery_id;
285 __u8 rf_interface; 333 __u8 rf_interface;
@@ -291,6 +339,8 @@ struct nci_rf_intf_activated_ntf {
291 339
292 union { 340 union {
293 struct rf_tech_specific_params_nfca_poll nfca_poll; 341 struct rf_tech_specific_params_nfca_poll nfca_poll;
342 struct rf_tech_specific_params_nfcb_poll nfcb_poll;
343 struct rf_tech_specific_params_nfcf_poll nfcf_poll;
294 } rf_tech_specific_params; 344 } rf_tech_specific_params;
295 345
296 __u8 data_exch_rf_tech_and_mode; 346 __u8 data_exch_rf_tech_and_mode;
@@ -300,6 +350,7 @@ struct nci_rf_intf_activated_ntf {
300 350
301 union { 351 union {
302 struct activation_params_nfca_poll_iso_dep nfca_poll_iso_dep; 352 struct activation_params_nfca_poll_iso_dep nfca_poll_iso_dep;
353 struct activation_params_nfcb_poll_iso_dep nfcb_poll_iso_dep;
303 } activation_params; 354 } activation_params;
304 355
305} __packed; 356} __packed;
diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h
index bccd89e9d4c2..86fee8b5c65c 100644
--- a/include/net/nfc/nci_core.h
+++ b/include/net/nfc/nci_core.h
@@ -34,21 +34,31 @@
34#include <net/nfc/nfc.h> 34#include <net/nfc/nfc.h>
35#include <net/nfc/nci.h> 35#include <net/nfc/nci.h>
36 36
37/* NCI device state */ 37/* NCI device flags */
38enum { 38enum nci_flag {
39 NCI_INIT, 39 NCI_INIT,
40 NCI_UP, 40 NCI_UP,
41 NCI_DATA_EXCHANGE,
42 NCI_DATA_EXCHANGE_TO,
43};
44
45/* NCI device states */
46enum nci_state {
47 NCI_IDLE,
41 NCI_DISCOVERY, 48 NCI_DISCOVERY,
49 NCI_W4_ALL_DISCOVERIES,
50 NCI_W4_HOST_SELECT,
42 NCI_POLL_ACTIVE, 51 NCI_POLL_ACTIVE,
43 NCI_DATA_EXCHANGE,
44}; 52};
45 53
46/* NCI timeouts */ 54/* NCI timeouts */
47#define NCI_RESET_TIMEOUT 5000 55#define NCI_RESET_TIMEOUT 5000
48#define NCI_INIT_TIMEOUT 5000 56#define NCI_INIT_TIMEOUT 5000
49#define NCI_RF_DISC_TIMEOUT 5000 57#define NCI_RF_DISC_TIMEOUT 5000
50#define NCI_RF_DEACTIVATE_TIMEOUT 5000 58#define NCI_RF_DISC_SELECT_TIMEOUT 5000
59#define NCI_RF_DEACTIVATE_TIMEOUT 30000
51#define NCI_CMD_TIMEOUT 5000 60#define NCI_CMD_TIMEOUT 5000
61#define NCI_DATA_TIMEOUT 700
52 62
53struct nci_dev; 63struct nci_dev;
54 64
@@ -59,6 +69,7 @@ struct nci_ops {
59}; 69};
60 70
61#define NCI_MAX_SUPPORTED_RF_INTERFACES 4 71#define NCI_MAX_SUPPORTED_RF_INTERFACES 4
72#define NCI_MAX_DISCOVERED_TARGETS 10
62 73
63/* NCI Core structures */ 74/* NCI Core structures */
64struct nci_dev { 75struct nci_dev {
@@ -68,12 +79,14 @@ struct nci_dev {
68 int tx_headroom; 79 int tx_headroom;
69 int tx_tailroom; 80 int tx_tailroom;
70 81
82 atomic_t state;
71 unsigned long flags; 83 unsigned long flags;
72 84
73 atomic_t cmd_cnt; 85 atomic_t cmd_cnt;
74 atomic_t credits_cnt; 86 atomic_t credits_cnt;
75 87
76 struct timer_list cmd_timer; 88 struct timer_list cmd_timer;
89 struct timer_list data_timer;
77 90
78 struct workqueue_struct *cmd_wq; 91 struct workqueue_struct *cmd_wq;
79 struct work_struct cmd_work; 92 struct work_struct cmd_work;
@@ -96,9 +109,11 @@ struct nci_dev {
96 void *driver_data; 109 void *driver_data;
97 110
98 __u32 poll_prots; 111 __u32 poll_prots;
99 __u32 target_available_prots;
100 __u32 target_active_prot; 112 __u32 target_active_prot;
101 113
114 struct nfc_target targets[NCI_MAX_DISCOVERED_TARGETS];
115 int n_targets;
116
102 /* received during NCI_OP_CORE_RESET_RSP */ 117 /* received during NCI_OP_CORE_RESET_RSP */
103 __u8 nci_ver; 118 __u8 nci_ver;
104 119
@@ -169,6 +184,7 @@ int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload);
169int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb); 184int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb);
170void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb, 185void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb,
171 int err); 186 int err);
187void nci_clear_target_list(struct nci_dev *ndev);
172 188
173/* ----- NCI requests ----- */ 189/* ----- NCI requests ----- */
174#define NCI_REQ_DONE 0 190#define NCI_REQ_DONE 0
diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h
index 8696b773a695..d253278e5a96 100644
--- a/include/net/nfc/nfc.h
+++ b/include/net/nfc/nfc.h
@@ -24,6 +24,7 @@
24#ifndef __NET_NFC_H 24#ifndef __NET_NFC_H
25#define __NET_NFC_H 25#define __NET_NFC_H
26 26
27#include <linux/nfc.h>
27#include <linux/device.h> 28#include <linux/device.h>
28#include <linux/skbuff.h> 29#include <linux/skbuff.h>
29 30
@@ -65,7 +66,6 @@ struct nfc_ops {
65 66
66#define NFC_TARGET_IDX_ANY -1 67#define NFC_TARGET_IDX_ANY -1
67#define NFC_MAX_GT_LEN 48 68#define NFC_MAX_GT_LEN 48
68#define NFC_MAX_NFCID1_LEN 10
69 69
70struct nfc_target { 70struct nfc_target {
71 u32 idx; 71 u32 idx;
@@ -73,7 +73,11 @@ struct nfc_target {
73 u16 sens_res; 73 u16 sens_res;
74 u8 sel_res; 74 u8 sel_res;
75 u8 nfcid1_len; 75 u8 nfcid1_len;
76 u8 nfcid1[NFC_MAX_NFCID1_LEN]; 76 u8 nfcid1[NFC_NFCID1_MAXSIZE];
77 u8 sensb_res_len;
78 u8 sensb_res[NFC_SENSB_RES_MAXSIZE];
79 u8 sensf_res_len;
80 u8 sensf_res[NFC_SENSF_RES_MAXSIZE];
77}; 81};
78 82
79struct nfc_genl_data { 83struct nfc_genl_data {
@@ -83,7 +87,6 @@ struct nfc_genl_data {
83 87
84struct nfc_dev { 88struct nfc_dev {
85 unsigned idx; 89 unsigned idx;
86 unsigned target_idx;
87 struct nfc_target *targets; 90 struct nfc_target *targets;
88 int n_targets; 91 int n_targets;
89 int targets_generation; 92 int targets_generation;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 42c29bfbcee3..6b2acfce4cfd 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1138,35 +1138,27 @@ static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp)
1138/* MD5 Signature */ 1138/* MD5 Signature */
1139struct crypto_hash; 1139struct crypto_hash;
1140 1140
1141union tcp_md5_addr {
1142 struct in_addr a4;
1143#if IS_ENABLED(CONFIG_IPV6)
1144 struct in6_addr a6;
1145#endif
1146};
1147
1141/* - key database */ 1148/* - key database */
1142struct tcp_md5sig_key { 1149struct tcp_md5sig_key {
1143 u8 *key; 1150 struct hlist_node node;
1144 u8 keylen; 1151 u8 keylen;
1145}; 1152 u8 family; /* AF_INET or AF_INET6 */
1146 1153 union tcp_md5_addr addr;
1147struct tcp4_md5sig_key { 1154 u8 key[TCP_MD5SIG_MAXKEYLEN];
1148 struct tcp_md5sig_key base; 1155 struct rcu_head rcu;
1149 __be32 addr;
1150};
1151
1152struct tcp6_md5sig_key {
1153 struct tcp_md5sig_key base;
1154#if 0
1155 u32 scope_id; /* XXX */
1156#endif
1157 struct in6_addr addr;
1158}; 1156};
1159 1157
1160/* - sock block */ 1158/* - sock block */
1161struct tcp_md5sig_info { 1159struct tcp_md5sig_info {
1162 struct tcp4_md5sig_key *keys4; 1160 struct hlist_head head;
1163#if IS_ENABLED(CONFIG_IPV6) 1161 struct rcu_head rcu;
1164 struct tcp6_md5sig_key *keys6;
1165 u32 entries6;
1166 u32 alloced6;
1167#endif
1168 u32 entries4;
1169 u32 alloced4;
1170}; 1162};
1171 1163
1172/* - pseudo header */ 1164/* - pseudo header */
@@ -1203,19 +1195,25 @@ extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key,
1203 const struct sock *sk, 1195 const struct sock *sk,
1204 const struct request_sock *req, 1196 const struct request_sock *req,
1205 const struct sk_buff *skb); 1197 const struct sk_buff *skb);
1206extern struct tcp_md5sig_key * tcp_v4_md5_lookup(struct sock *sk, 1198extern int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
1207 struct sock *addr_sk); 1199 int family, const u8 *newkey,
1208extern int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, u8 *newkey, 1200 u8 newkeylen, gfp_t gfp);
1209 u8 newkeylen); 1201extern int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr,
1210extern int tcp_v4_md5_do_del(struct sock *sk, __be32 addr); 1202 int family);
1203extern struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk,
1204 struct sock *addr_sk);
1211 1205
1212#ifdef CONFIG_TCP_MD5SIG 1206#ifdef CONFIG_TCP_MD5SIG
1213#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_keylen ? \ 1207extern struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
1214 &(struct tcp_md5sig_key) { \ 1208 const union tcp_md5_addr *addr, int family);
1215 .key = (twsk)->tw_md5_key, \ 1209#define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_key)
1216 .keylen = (twsk)->tw_md5_keylen, \
1217 } : NULL)
1218#else 1210#else
1211static inline struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
1212 const union tcp_md5_addr *addr,
1213 int family)
1214{
1215 return NULL;
1216}
1219#define tcp_twsk_md5_key(twsk) NULL 1217#define tcp_twsk_md5_key(twsk) NULL
1220#endif 1218#endif
1221 1219
@@ -1470,10 +1468,6 @@ struct tcp_sock_af_ops {
1470 const struct sock *sk, 1468 const struct sock *sk,
1471 const struct request_sock *req, 1469 const struct request_sock *req,
1472 const struct sk_buff *skb); 1470 const struct sk_buff *skb);
1473 int (*md5_add) (struct sock *sk,
1474 struct sock *addr_sk,
1475 u8 *newkey,
1476 u8 len);
1477 int (*md5_parse) (struct sock *sk, 1471 int (*md5_parse) (struct sock *sk,
1478 char __user *optval, 1472 char __user *optval,
1479 int optlen); 1473 int optlen);
diff --git a/net/atm/clip.c b/net/atm/clip.c
index c12c2582457c..ef95a30306fa 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -328,6 +328,8 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb,
328 struct atmarp_entry *entry; 328 struct atmarp_entry *entry;
329 struct neighbour *n; 329 struct neighbour *n;
330 struct atm_vcc *vcc; 330 struct atm_vcc *vcc;
331 struct rtable *rt;
332 __be32 *daddr;
331 int old; 333 int old;
332 unsigned long flags; 334 unsigned long flags;
333 335
@@ -338,7 +340,12 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb,
338 dev->stats.tx_dropped++; 340 dev->stats.tx_dropped++;
339 return NETDEV_TX_OK; 341 return NETDEV_TX_OK;
340 } 342 }
341 n = dst_get_neighbour_noref(dst); 343 rt = (struct rtable *) dst;
344 if (rt->rt_gateway)
345 daddr = &rt->rt_gateway;
346 else
347 daddr = &ip_hdr(skb)->daddr;
348 n = dst_neigh_lookup(dst, daddr);
342 if (!n) { 349 if (!n) {
343 pr_err("NO NEIGHBOUR !\n"); 350 pr_err("NO NEIGHBOUR !\n");
344 dev_kfree_skb(skb); 351 dev_kfree_skb(skb);
@@ -358,7 +365,7 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb,
358 dev_kfree_skb(skb); 365 dev_kfree_skb(skb);
359 dev->stats.tx_dropped++; 366 dev->stats.tx_dropped++;
360 } 367 }
361 return NETDEV_TX_OK; 368 goto out_release_neigh;
362 } 369 }
363 pr_debug("neigh %p, vccs %p\n", entry, entry->vccs); 370 pr_debug("neigh %p, vccs %p\n", entry, entry->vccs);
364 ATM_SKB(skb)->vcc = vcc = entry->vccs->vcc; 371 ATM_SKB(skb)->vcc = vcc = entry->vccs->vcc;
@@ -377,14 +384,14 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb,
377 old = xchg(&entry->vccs->xoff, 1); /* assume XOFF ... */ 384 old = xchg(&entry->vccs->xoff, 1); /* assume XOFF ... */
378 if (old) { 385 if (old) {
379 pr_warning("XOFF->XOFF transition\n"); 386 pr_warning("XOFF->XOFF transition\n");
380 return NETDEV_TX_OK; 387 goto out_release_neigh;
381 } 388 }
382 dev->stats.tx_packets++; 389 dev->stats.tx_packets++;
383 dev->stats.tx_bytes += skb->len; 390 dev->stats.tx_bytes += skb->len;
384 vcc->send(vcc, skb); 391 vcc->send(vcc, skb);
385 if (atm_may_send(vcc, 0)) { 392 if (atm_may_send(vcc, 0)) {
386 entry->vccs->xoff = 0; 393 entry->vccs->xoff = 0;
387 return NETDEV_TX_OK; 394 goto out_release_neigh;
388 } 395 }
389 spin_lock_irqsave(&clip_priv->xoff_lock, flags); 396 spin_lock_irqsave(&clip_priv->xoff_lock, flags);
390 netif_stop_queue(dev); /* XOFF -> throttle immediately */ 397 netif_stop_queue(dev); /* XOFF -> throttle immediately */
@@ -396,6 +403,8 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb,
396 of the brief netif_stop_queue. If this isn't true or if it 403 of the brief netif_stop_queue. If this isn't true or if it
397 changes, use netif_wake_queue instead. */ 404 changes, use netif_wake_queue instead. */
398 spin_unlock_irqrestore(&clip_priv->xoff_lock, flags); 405 spin_unlock_irqrestore(&clip_priv->xoff_lock, flags);
406out_release_neigh:
407 neigh_release(n);
399 return NETDEV_TX_OK; 408 return NETDEV_TX_OK;
400} 409}
401 410
diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
index 82c57069415f..aa6f716524fd 100644
--- a/net/caif/caif_dev.c
+++ b/net/caif/caif_dev.c
@@ -162,7 +162,6 @@ void caif_flow_cb(struct sk_buff *skb)
162static int transmit(struct cflayer *layer, struct cfpkt *pkt) 162static int transmit(struct cflayer *layer, struct cfpkt *pkt)
163{ 163{
164 int err, high = 0, qlen = 0; 164 int err, high = 0, qlen = 0;
165 struct caif_dev_common *caifdev;
166 struct caif_device_entry *caifd = 165 struct caif_device_entry *caifd =
167 container_of(layer, struct caif_device_entry, layer); 166 container_of(layer, struct caif_device_entry, layer);
168 struct sk_buff *skb; 167 struct sk_buff *skb;
@@ -174,7 +173,6 @@ static int transmit(struct cflayer *layer, struct cfpkt *pkt)
174 skb->dev = caifd->netdev; 173 skb->dev = caifd->netdev;
175 skb_reset_network_header(skb); 174 skb_reset_network_header(skb);
176 skb->protocol = htons(ETH_P_CAIF); 175 skb->protocol = htons(ETH_P_CAIF);
177 caifdev = netdev_priv(caifd->netdev);
178 176
179 /* Check if we need to handle xoff */ 177 /* Check if we need to handle xoff */
180 if (likely(caifd->netdev->tx_queue_len == 0)) 178 if (likely(caifd->netdev->tx_queue_len == 0))
diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
index a97d97a3a512..5016fa57b623 100644
--- a/net/caif/caif_socket.c
+++ b/net/caif/caif_socket.c
@@ -43,34 +43,9 @@ enum caif_states {
43#define TX_FLOW_ON_BIT 1 43#define TX_FLOW_ON_BIT 1
44#define RX_FLOW_ON_BIT 2 44#define RX_FLOW_ON_BIT 2
45 45
46static struct dentry *debugfsdir;
47
48#ifdef CONFIG_DEBUG_FS
49struct debug_fs_counter {
50 atomic_t caif_nr_socks;
51 atomic_t caif_sock_create;
52 atomic_t num_connect_req;
53 atomic_t num_connect_resp;
54 atomic_t num_connect_fail_resp;
55 atomic_t num_disconnect;
56 atomic_t num_remote_shutdown_ind;
57 atomic_t num_tx_flow_off_ind;
58 atomic_t num_tx_flow_on_ind;
59 atomic_t num_rx_flow_off;
60 atomic_t num_rx_flow_on;
61};
62static struct debug_fs_counter cnt;
63#define dbfs_atomic_inc(v) atomic_inc_return(v)
64#define dbfs_atomic_dec(v) atomic_dec_return(v)
65#else
66#define dbfs_atomic_inc(v) 0
67#define dbfs_atomic_dec(v) 0
68#endif
69
70struct caifsock { 46struct caifsock {
71 struct sock sk; /* must be first member */ 47 struct sock sk; /* must be first member */
72 struct cflayer layer; 48 struct cflayer layer;
73 char name[CAIF_LAYER_NAME_SZ]; /* Used for debugging */
74 u32 flow_state; 49 u32 flow_state;
75 struct caif_connect_request conn_req; 50 struct caif_connect_request conn_req;
76 struct mutex readlock; 51 struct mutex readlock;
@@ -161,7 +136,6 @@ static int caif_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
161 atomic_read(&cf_sk->sk.sk_rmem_alloc), 136 atomic_read(&cf_sk->sk.sk_rmem_alloc),
162 sk_rcvbuf_lowwater(cf_sk)); 137 sk_rcvbuf_lowwater(cf_sk));
163 set_rx_flow_off(cf_sk); 138 set_rx_flow_off(cf_sk);
164 dbfs_atomic_inc(&cnt.num_rx_flow_off);
165 caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_OFF_REQ); 139 caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_OFF_REQ);
166 } 140 }
167 141
@@ -172,7 +146,6 @@ static int caif_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
172 set_rx_flow_off(cf_sk); 146 set_rx_flow_off(cf_sk);
173 if (net_ratelimit()) 147 if (net_ratelimit())
174 pr_debug("sending flow OFF due to rmem_schedule\n"); 148 pr_debug("sending flow OFF due to rmem_schedule\n");
175 dbfs_atomic_inc(&cnt.num_rx_flow_off);
176 caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_OFF_REQ); 149 caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_OFF_REQ);
177 } 150 }
178 skb->dev = NULL; 151 skb->dev = NULL;
@@ -233,14 +206,12 @@ static void caif_ctrl_cb(struct cflayer *layr,
233 switch (flow) { 206 switch (flow) {
234 case CAIF_CTRLCMD_FLOW_ON_IND: 207 case CAIF_CTRLCMD_FLOW_ON_IND:
235 /* OK from modem to start sending again */ 208 /* OK from modem to start sending again */
236 dbfs_atomic_inc(&cnt.num_tx_flow_on_ind);
237 set_tx_flow_on(cf_sk); 209 set_tx_flow_on(cf_sk);
238 cf_sk->sk.sk_state_change(&cf_sk->sk); 210 cf_sk->sk.sk_state_change(&cf_sk->sk);
239 break; 211 break;
240 212
241 case CAIF_CTRLCMD_FLOW_OFF_IND: 213 case CAIF_CTRLCMD_FLOW_OFF_IND:
242 /* Modem asks us to shut up */ 214 /* Modem asks us to shut up */
243 dbfs_atomic_inc(&cnt.num_tx_flow_off_ind);
244 set_tx_flow_off(cf_sk); 215 set_tx_flow_off(cf_sk);
245 cf_sk->sk.sk_state_change(&cf_sk->sk); 216 cf_sk->sk.sk_state_change(&cf_sk->sk);
246 break; 217 break;
@@ -249,7 +220,6 @@ static void caif_ctrl_cb(struct cflayer *layr,
249 /* We're now connected */ 220 /* We're now connected */
250 caif_client_register_refcnt(&cf_sk->layer, 221 caif_client_register_refcnt(&cf_sk->layer,
251 cfsk_hold, cfsk_put); 222 cfsk_hold, cfsk_put);
252 dbfs_atomic_inc(&cnt.num_connect_resp);
253 cf_sk->sk.sk_state = CAIF_CONNECTED; 223 cf_sk->sk.sk_state = CAIF_CONNECTED;
254 set_tx_flow_on(cf_sk); 224 set_tx_flow_on(cf_sk);
255 cf_sk->sk.sk_state_change(&cf_sk->sk); 225 cf_sk->sk.sk_state_change(&cf_sk->sk);
@@ -263,7 +233,6 @@ static void caif_ctrl_cb(struct cflayer *layr,
263 233
264 case CAIF_CTRLCMD_INIT_FAIL_RSP: 234 case CAIF_CTRLCMD_INIT_FAIL_RSP:
265 /* Connect request failed */ 235 /* Connect request failed */
266 dbfs_atomic_inc(&cnt.num_connect_fail_resp);
267 cf_sk->sk.sk_err = ECONNREFUSED; 236 cf_sk->sk.sk_err = ECONNREFUSED;
268 cf_sk->sk.sk_state = CAIF_DISCONNECTED; 237 cf_sk->sk.sk_state = CAIF_DISCONNECTED;
269 cf_sk->sk.sk_shutdown = SHUTDOWN_MASK; 238 cf_sk->sk.sk_shutdown = SHUTDOWN_MASK;
@@ -277,7 +246,6 @@ static void caif_ctrl_cb(struct cflayer *layr,
277 246
278 case CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND: 247 case CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND:
279 /* Modem has closed this connection, or device is down. */ 248 /* Modem has closed this connection, or device is down. */
280 dbfs_atomic_inc(&cnt.num_remote_shutdown_ind);
281 cf_sk->sk.sk_shutdown = SHUTDOWN_MASK; 249 cf_sk->sk.sk_shutdown = SHUTDOWN_MASK;
282 cf_sk->sk.sk_err = ECONNRESET; 250 cf_sk->sk.sk_err = ECONNRESET;
283 set_rx_flow_on(cf_sk); 251 set_rx_flow_on(cf_sk);
@@ -297,7 +265,6 @@ static void caif_check_flow_release(struct sock *sk)
297 return; 265 return;
298 266
299 if (atomic_read(&sk->sk_rmem_alloc) <= sk_rcvbuf_lowwater(cf_sk)) { 267 if (atomic_read(&sk->sk_rmem_alloc) <= sk_rcvbuf_lowwater(cf_sk)) {
300 dbfs_atomic_inc(&cnt.num_rx_flow_on);
301 set_rx_flow_on(cf_sk); 268 set_rx_flow_on(cf_sk);
302 caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_ON_REQ); 269 caif_flow_ctrl(sk, CAIF_MODEMCMD_FLOW_ON_REQ);
303 } 270 }
@@ -856,7 +823,6 @@ static int caif_connect(struct socket *sock, struct sockaddr *uaddr,
856 /*ifindex = id of the interface.*/ 823 /*ifindex = id of the interface.*/
857 cf_sk->conn_req.ifindex = cf_sk->sk.sk_bound_dev_if; 824 cf_sk->conn_req.ifindex = cf_sk->sk.sk_bound_dev_if;
858 825
859 dbfs_atomic_inc(&cnt.num_connect_req);
860 cf_sk->layer.receive = caif_sktrecv_cb; 826 cf_sk->layer.receive = caif_sktrecv_cb;
861 827
862 err = caif_connect_client(sock_net(sk), &cf_sk->conn_req, 828 err = caif_connect_client(sock_net(sk), &cf_sk->conn_req,
@@ -945,8 +911,6 @@ static int caif_release(struct socket *sock)
945 spin_unlock_bh(&sk->sk_receive_queue.lock); 911 spin_unlock_bh(&sk->sk_receive_queue.lock);
946 sock->sk = NULL; 912 sock->sk = NULL;
947 913
948 dbfs_atomic_inc(&cnt.num_disconnect);
949
950 WARN_ON(IS_ERR(cf_sk->debugfs_socket_dir)); 914 WARN_ON(IS_ERR(cf_sk->debugfs_socket_dir));
951 if (cf_sk->debugfs_socket_dir != NULL) 915 if (cf_sk->debugfs_socket_dir != NULL)
952 debugfs_remove_recursive(cf_sk->debugfs_socket_dir); 916 debugfs_remove_recursive(cf_sk->debugfs_socket_dir);
@@ -1054,14 +1018,12 @@ static void caif_sock_destructor(struct sock *sk)
1054 return; 1018 return;
1055 } 1019 }
1056 sk_stream_kill_queues(&cf_sk->sk); 1020 sk_stream_kill_queues(&cf_sk->sk);
1057 dbfs_atomic_dec(&cnt.caif_nr_socks);
1058 caif_free_client(&cf_sk->layer); 1021 caif_free_client(&cf_sk->layer);
1059} 1022}
1060 1023
1061static int caif_create(struct net *net, struct socket *sock, int protocol, 1024static int caif_create(struct net *net, struct socket *sock, int protocol,
1062 int kern) 1025 int kern)
1063{ 1026{
1064 int num;
1065 struct sock *sk = NULL; 1027 struct sock *sk = NULL;
1066 struct caifsock *cf_sk = NULL; 1028 struct caifsock *cf_sk = NULL;
1067 static struct proto prot = {.name = "PF_CAIF", 1029 static struct proto prot = {.name = "PF_CAIF",
@@ -1122,34 +1084,6 @@ static int caif_create(struct net *net, struct socket *sock, int protocol,
1122 cf_sk->sk.sk_priority = CAIF_PRIO_NORMAL; 1084 cf_sk->sk.sk_priority = CAIF_PRIO_NORMAL;
1123 cf_sk->conn_req.link_selector = CAIF_LINK_LOW_LATENCY; 1085 cf_sk->conn_req.link_selector = CAIF_LINK_LOW_LATENCY;
1124 cf_sk->conn_req.protocol = protocol; 1086 cf_sk->conn_req.protocol = protocol;
1125 /* Increase the number of sockets created. */
1126 dbfs_atomic_inc(&cnt.caif_nr_socks);
1127 num = dbfs_atomic_inc(&cnt.caif_sock_create);
1128#ifdef CONFIG_DEBUG_FS
1129 if (!IS_ERR(debugfsdir)) {
1130
1131 /* Fill in some information concerning the misc socket. */
1132 snprintf(cf_sk->name, sizeof(cf_sk->name), "cfsk%d", num);
1133
1134 cf_sk->debugfs_socket_dir =
1135 debugfs_create_dir(cf_sk->name, debugfsdir);
1136
1137 debugfs_create_u32("sk_state", S_IRUSR | S_IWUSR,
1138 cf_sk->debugfs_socket_dir,
1139 (u32 *) &cf_sk->sk.sk_state);
1140 debugfs_create_u32("flow_state", S_IRUSR | S_IWUSR,
1141 cf_sk->debugfs_socket_dir, &cf_sk->flow_state);
1142 debugfs_create_u32("sk_rmem_alloc", S_IRUSR | S_IWUSR,
1143 cf_sk->debugfs_socket_dir,
1144 (u32 *) &cf_sk->sk.sk_rmem_alloc);
1145 debugfs_create_u32("sk_wmem_alloc", S_IRUSR | S_IWUSR,
1146 cf_sk->debugfs_socket_dir,
1147 (u32 *) &cf_sk->sk.sk_wmem_alloc);
1148 debugfs_create_u32("identity", S_IRUSR | S_IWUSR,
1149 cf_sk->debugfs_socket_dir,
1150 (u32 *) &cf_sk->layer.id);
1151 }
1152#endif
1153 release_sock(&cf_sk->sk); 1087 release_sock(&cf_sk->sk);
1154 return 0; 1088 return 0;
1155} 1089}
@@ -1161,7 +1095,7 @@ static struct net_proto_family caif_family_ops = {
1161 .owner = THIS_MODULE, 1095 .owner = THIS_MODULE,
1162}; 1096};
1163 1097
1164static int af_caif_init(void) 1098static int __init caif_sktinit_module(void)
1165{ 1099{
1166 int err = sock_register(&caif_family_ops); 1100 int err = sock_register(&caif_family_ops);
1167 if (!err) 1101 if (!err)
@@ -1169,54 +1103,9 @@ static int af_caif_init(void)
1169 return 0; 1103 return 0;
1170} 1104}
1171 1105
1172static int __init caif_sktinit_module(void)
1173{
1174#ifdef CONFIG_DEBUG_FS
1175 debugfsdir = debugfs_create_dir("caif_sk", NULL);
1176 if (!IS_ERR(debugfsdir)) {
1177 debugfs_create_u32("num_sockets", S_IRUSR | S_IWUSR,
1178 debugfsdir,
1179 (u32 *) &cnt.caif_nr_socks);
1180 debugfs_create_u32("num_create", S_IRUSR | S_IWUSR,
1181 debugfsdir,
1182 (u32 *) &cnt.caif_sock_create);
1183 debugfs_create_u32("num_connect_req", S_IRUSR | S_IWUSR,
1184 debugfsdir,
1185 (u32 *) &cnt.num_connect_req);
1186 debugfs_create_u32("num_connect_resp", S_IRUSR | S_IWUSR,
1187 debugfsdir,
1188 (u32 *) &cnt.num_connect_resp);
1189 debugfs_create_u32("num_connect_fail_resp", S_IRUSR | S_IWUSR,
1190 debugfsdir,
1191 (u32 *) &cnt.num_connect_fail_resp);
1192 debugfs_create_u32("num_disconnect", S_IRUSR | S_IWUSR,
1193 debugfsdir,
1194 (u32 *) &cnt.num_disconnect);
1195 debugfs_create_u32("num_remote_shutdown_ind",
1196 S_IRUSR | S_IWUSR, debugfsdir,
1197 (u32 *) &cnt.num_remote_shutdown_ind);
1198 debugfs_create_u32("num_tx_flow_off_ind", S_IRUSR | S_IWUSR,
1199 debugfsdir,
1200 (u32 *) &cnt.num_tx_flow_off_ind);
1201 debugfs_create_u32("num_tx_flow_on_ind", S_IRUSR | S_IWUSR,
1202 debugfsdir,
1203 (u32 *) &cnt.num_tx_flow_on_ind);
1204 debugfs_create_u32("num_rx_flow_off", S_IRUSR | S_IWUSR,
1205 debugfsdir,
1206 (u32 *) &cnt.num_rx_flow_off);
1207 debugfs_create_u32("num_rx_flow_on", S_IRUSR | S_IWUSR,
1208 debugfsdir,
1209 (u32 *) &cnt.num_rx_flow_on);
1210 }
1211#endif
1212 return af_caif_init();
1213}
1214
1215static void __exit caif_sktexit_module(void) 1106static void __exit caif_sktexit_module(void)
1216{ 1107{
1217 sock_unregister(PF_CAIF); 1108 sock_unregister(PF_CAIF);
1218 if (debugfsdir != NULL)
1219 debugfs_remove_recursive(debugfsdir);
1220} 1109}
1221module_init(caif_sktinit_module); 1110module_init(caif_sktinit_module);
1222module_exit(caif_sktexit_module); 1111module_exit(caif_sktexit_module);
diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
index 865690948bbc..e866234d0e5a 100644
--- a/net/caif/chnl_net.c
+++ b/net/caif/chnl_net.c
@@ -72,14 +72,12 @@ static void robust_list_del(struct list_head *delete_node)
72static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt) 72static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt)
73{ 73{
74 struct sk_buff *skb; 74 struct sk_buff *skb;
75 struct chnl_net *priv = container_of(layr, struct chnl_net, chnl); 75 struct chnl_net *priv;
76 int pktlen; 76 int pktlen;
77 int err = 0;
78 const u8 *ip_version; 77 const u8 *ip_version;
79 u8 buf; 78 u8 buf;
80 79
81 priv = container_of(layr, struct chnl_net, chnl); 80 priv = container_of(layr, struct chnl_net, chnl);
82
83 if (!priv) 81 if (!priv)
84 return -EINVAL; 82 return -EINVAL;
85 83
@@ -95,8 +93,7 @@ static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt)
95 93
96 /* check the version of IP */ 94 /* check the version of IP */
97 ip_version = skb_header_pointer(skb, 0, 1, &buf); 95 ip_version = skb_header_pointer(skb, 0, 1, &buf);
98 if (!ip_version) 96
99 return -EINVAL;
100 switch (*ip_version >> 4) { 97 switch (*ip_version >> 4) {
101 case 4: 98 case 4:
102 skb->protocol = htons(ETH_P_IP); 99 skb->protocol = htons(ETH_P_IP);
@@ -105,6 +102,7 @@ static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt)
105 skb->protocol = htons(ETH_P_IPV6); 102 skb->protocol = htons(ETH_P_IPV6);
106 break; 103 break;
107 default: 104 default:
105 priv->netdev->stats.rx_errors++;
108 return -EINVAL; 106 return -EINVAL;
109 } 107 }
110 108
@@ -123,7 +121,7 @@ static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt)
123 priv->netdev->stats.rx_packets++; 121 priv->netdev->stats.rx_packets++;
124 priv->netdev->stats.rx_bytes += pktlen; 122 priv->netdev->stats.rx_bytes += pktlen;
125 123
126 return err; 124 return 0;
127} 125}
128 126
129static int delete_device(struct chnl_net *dev) 127static int delete_device(struct chnl_net *dev)
@@ -221,11 +219,13 @@ static int chnl_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
221 219
222 if (skb->len > priv->netdev->mtu) { 220 if (skb->len > priv->netdev->mtu) {
223 pr_warn("Size of skb exceeded MTU\n"); 221 pr_warn("Size of skb exceeded MTU\n");
222 dev->stats.tx_errors++;
224 return -ENOSPC; 223 return -ENOSPC;
225 } 224 }
226 225
227 if (!priv->flowenabled) { 226 if (!priv->flowenabled) {
228 pr_debug("dropping packets flow off\n"); 227 pr_debug("dropping packets flow off\n");
228 dev->stats.tx_dropped++;
229 return NETDEV_TX_BUSY; 229 return NETDEV_TX_BUSY;
230 } 230 }
231 231
@@ -240,8 +240,7 @@ static int chnl_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
240 /* Send the packet down the stack. */ 240 /* Send the packet down the stack. */
241 result = priv->chnl.dn->transmit(priv->chnl.dn, pkt); 241 result = priv->chnl.dn->transmit(priv->chnl.dn, pkt);
242 if (result) { 242 if (result) {
243 if (result == -EAGAIN) 243 dev->stats.tx_dropped++;
244 result = NETDEV_TX_BUSY;
245 return result; 244 return result;
246 } 245 }
247 246
diff --git a/net/core/dev.c b/net/core/dev.c
index 6ca32f6b3105..763a0eda7158 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -446,7 +446,7 @@ void __dev_remove_pack(struct packet_type *pt)
446 } 446 }
447 } 447 }
448 448
449 printk(KERN_WARNING "dev_remove_pack: %p not found.\n", pt); 449 pr_warn("dev_remove_pack: %p not found\n", pt);
450out: 450out:
451 spin_unlock(&ptype_lock); 451 spin_unlock(&ptype_lock);
452} 452}
@@ -1039,8 +1039,7 @@ rollback:
1039 memcpy(dev->name, oldname, IFNAMSIZ); 1039 memcpy(dev->name, oldname, IFNAMSIZ);
1040 goto rollback; 1040 goto rollback;
1041 } else { 1041 } else {
1042 printk(KERN_ERR 1042 pr_err("%s: name change rollback failed: %d\n",
1043 "%s: name change rollback failed: %d.\n",
1044 dev->name, ret); 1043 dev->name, ret);
1045 } 1044 }
1046 } 1045 }
@@ -1139,9 +1138,8 @@ void dev_load(struct net *net, const char *name)
1139 no_module = request_module("netdev-%s", name); 1138 no_module = request_module("netdev-%s", name);
1140 if (no_module && capable(CAP_SYS_MODULE)) { 1139 if (no_module && capable(CAP_SYS_MODULE)) {
1141 if (!request_module("%s", name)) 1140 if (!request_module("%s", name))
1142 pr_err("Loading kernel module for a network device " 1141 pr_err("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
1143"with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s " 1142 name);
1144"instead\n", name);
1145 } 1143 }
1146} 1144}
1147EXPORT_SYMBOL(dev_load); 1145EXPORT_SYMBOL(dev_load);
@@ -1655,10 +1653,9 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
1655 if (skb_network_header(skb2) < skb2->data || 1653 if (skb_network_header(skb2) < skb2->data ||
1656 skb2->network_header > skb2->tail) { 1654 skb2->network_header > skb2->tail) {
1657 if (net_ratelimit()) 1655 if (net_ratelimit())
1658 printk(KERN_CRIT "protocol %04x is " 1656 pr_crit("protocol %04x is buggy, dev %s\n",
1659 "buggy, dev %s\n", 1657 ntohs(skb2->protocol),
1660 ntohs(skb2->protocol), 1658 dev->name);
1661 dev->name);
1662 skb_reset_network_header(skb2); 1659 skb_reset_network_header(skb2);
1663 } 1660 }
1664 1661
@@ -1691,9 +1688,7 @@ static void netif_setup_tc(struct net_device *dev, unsigned int txq)
1691 1688
1692 /* If TC0 is invalidated disable TC mapping */ 1689 /* If TC0 is invalidated disable TC mapping */
1693 if (tc->offset + tc->count > txq) { 1690 if (tc->offset + tc->count > txq) {
1694 pr_warning("Number of in use tx queues changed " 1691 pr_warn("Number of in use tx queues changed invalidating tc mappings. Priority traffic classification disabled!\n");
1695 "invalidating tc mappings. Priority "
1696 "traffic classification disabled!\n");
1697 dev->num_tc = 0; 1692 dev->num_tc = 0;
1698 return; 1693 return;
1699 } 1694 }
@@ -1704,11 +1699,8 @@ static void netif_setup_tc(struct net_device *dev, unsigned int txq)
1704 1699
1705 tc = &dev->tc_to_txq[q]; 1700 tc = &dev->tc_to_txq[q];
1706 if (tc->offset + tc->count > txq) { 1701 if (tc->offset + tc->count > txq) {
1707 pr_warning("Number of in use tx queues " 1702 pr_warn("Number of in use tx queues changed. Priority %i to tc mapping %i is no longer valid. Setting map to 0\n",
1708 "changed. Priority %i to tc " 1703 i, q);
1709 "mapping %i is no longer valid "
1710 "setting map to 0\n",
1711 i, q);
1712 netdev_set_prio_tc_map(dev, i, 0); 1704 netdev_set_prio_tc_map(dev, i, 0);
1713 } 1705 }
1714 } 1706 }
@@ -2014,8 +2006,7 @@ EXPORT_SYMBOL(skb_gso_segment);
2014void netdev_rx_csum_fault(struct net_device *dev) 2006void netdev_rx_csum_fault(struct net_device *dev)
2015{ 2007{
2016 if (net_ratelimit()) { 2008 if (net_ratelimit()) {
2017 printk(KERN_ERR "%s: hw csum failure.\n", 2009 pr_err("%s: hw csum failure\n", dev ? dev->name : "<unknown>");
2018 dev ? dev->name : "<unknown>");
2019 dump_stack(); 2010 dump_stack();
2020 } 2011 }
2021} 2012}
@@ -2332,9 +2323,9 @@ static inline u16 dev_cap_txqueue(struct net_device *dev, u16 queue_index)
2332{ 2323{
2333 if (unlikely(queue_index >= dev->real_num_tx_queues)) { 2324 if (unlikely(queue_index >= dev->real_num_tx_queues)) {
2334 if (net_ratelimit()) { 2325 if (net_ratelimit()) {
2335 pr_warning("%s selects TX queue %d, but " 2326 pr_warn("%s selects TX queue %d, but real number of TX queues is %d\n",
2336 "real number of TX queues is %d\n", 2327 dev->name, queue_index,
2337 dev->name, queue_index, dev->real_num_tx_queues); 2328 dev->real_num_tx_queues);
2338 } 2329 }
2339 return 0; 2330 return 0;
2340 } 2331 }
@@ -2578,16 +2569,16 @@ int dev_queue_xmit(struct sk_buff *skb)
2578 } 2569 }
2579 HARD_TX_UNLOCK(dev, txq); 2570 HARD_TX_UNLOCK(dev, txq);
2580 if (net_ratelimit()) 2571 if (net_ratelimit())
2581 printk(KERN_CRIT "Virtual device %s asks to " 2572 pr_crit("Virtual device %s asks to queue packet!\n",
2582 "queue packet!\n", dev->name); 2573 dev->name);
2583 } else { 2574 } else {
2584 /* Recursion is detected! It is possible, 2575 /* Recursion is detected! It is possible,
2585 * unfortunately 2576 * unfortunately
2586 */ 2577 */
2587recursion_alert: 2578recursion_alert:
2588 if (net_ratelimit()) 2579 if (net_ratelimit())
2589 printk(KERN_CRIT "Dead loop on virtual device " 2580 pr_crit("Dead loop on virtual device %s, fix it urgently!\n",
2590 "%s, fix it urgently!\n", dev->name); 2581 dev->name);
2591 } 2582 }
2592 } 2583 }
2593 2584
@@ -3069,8 +3060,8 @@ static int ing_filter(struct sk_buff *skb, struct netdev_queue *rxq)
3069 3060
3070 if (unlikely(MAX_RED_LOOP < ttl++)) { 3061 if (unlikely(MAX_RED_LOOP < ttl++)) {
3071 if (net_ratelimit()) 3062 if (net_ratelimit())
3072 pr_warning( "Redir loop detected Dropping packet (%d->%d)\n", 3063 pr_warn("Redir loop detected Dropping packet (%d->%d)\n",
3073 skb->skb_iif, dev->ifindex); 3064 skb->skb_iif, dev->ifindex);
3074 return TC_ACT_SHOT; 3065 return TC_ACT_SHOT;
3075 } 3066 }
3076 3067
@@ -4497,16 +4488,15 @@ static int __dev_set_promiscuity(struct net_device *dev, int inc)
4497 dev->flags &= ~IFF_PROMISC; 4488 dev->flags &= ~IFF_PROMISC;
4498 else { 4489 else {
4499 dev->promiscuity -= inc; 4490 dev->promiscuity -= inc;
4500 printk(KERN_WARNING "%s: promiscuity touches roof, " 4491 pr_warn("%s: promiscuity touches roof, set promiscuity failed. promiscuity feature of device might be broken.\n",
4501 "set promiscuity failed, promiscuity feature " 4492 dev->name);
4502 "of device might be broken.\n", dev->name);
4503 return -EOVERFLOW; 4493 return -EOVERFLOW;
4504 } 4494 }
4505 } 4495 }
4506 if (dev->flags != old_flags) { 4496 if (dev->flags != old_flags) {
4507 printk(KERN_INFO "device %s %s promiscuous mode\n", 4497 pr_info("device %s %s promiscuous mode\n",
4508 dev->name, (dev->flags & IFF_PROMISC) ? "entered" : 4498 dev->name,
4509 "left"); 4499 dev->flags & IFF_PROMISC ? "entered" : "left");
4510 if (audit_enabled) { 4500 if (audit_enabled) {
4511 current_uid_gid(&uid, &gid); 4501 current_uid_gid(&uid, &gid);
4512 audit_log(current->audit_context, GFP_ATOMIC, 4502 audit_log(current->audit_context, GFP_ATOMIC,
@@ -4579,9 +4569,8 @@ int dev_set_allmulti(struct net_device *dev, int inc)
4579 dev->flags &= ~IFF_ALLMULTI; 4569 dev->flags &= ~IFF_ALLMULTI;
4580 else { 4570 else {
4581 dev->allmulti -= inc; 4571 dev->allmulti -= inc;
4582 printk(KERN_WARNING "%s: allmulti touches roof, " 4572 pr_warn("%s: allmulti touches roof, set allmulti failed. allmulti feature of device might be broken.\n",
4583 "set allmulti failed, allmulti feature of " 4573 dev->name);
4584 "device might be broken.\n", dev->name);
4585 return -EOVERFLOW; 4574 return -EOVERFLOW;
4586 } 4575 }
4587 } 4576 }
@@ -5238,8 +5227,8 @@ static void rollback_registered_many(struct list_head *head)
5238 * devices and proceed with the remaining. 5227 * devices and proceed with the remaining.
5239 */ 5228 */
5240 if (dev->reg_state == NETREG_UNINITIALIZED) { 5229 if (dev->reg_state == NETREG_UNINITIALIZED) {
5241 pr_debug("unregister_netdevice: device %s/%p never " 5230 pr_debug("unregister_netdevice: device %s/%p never was registered\n",
5242 "was registered\n", dev->name, dev); 5231 dev->name, dev);
5243 5232
5244 WARN_ON(1); 5233 WARN_ON(1);
5245 list_del(&dev->unreg_list); 5234 list_del(&dev->unreg_list);
@@ -5471,7 +5460,7 @@ static int netif_alloc_rx_queues(struct net_device *dev)
5471 5460
5472 rx = kcalloc(count, sizeof(struct netdev_rx_queue), GFP_KERNEL); 5461 rx = kcalloc(count, sizeof(struct netdev_rx_queue), GFP_KERNEL);
5473 if (!rx) { 5462 if (!rx) {
5474 pr_err("netdev: Unable to allocate %u rx queues.\n", count); 5463 pr_err("netdev: Unable to allocate %u rx queues\n", count);
5475 return -ENOMEM; 5464 return -ENOMEM;
5476 } 5465 }
5477 dev->_rx = rx; 5466 dev->_rx = rx;
@@ -5505,8 +5494,7 @@ static int netif_alloc_netdev_queues(struct net_device *dev)
5505 5494
5506 tx = kcalloc(count, sizeof(struct netdev_queue), GFP_KERNEL); 5495 tx = kcalloc(count, sizeof(struct netdev_queue), GFP_KERNEL);
5507 if (!tx) { 5496 if (!tx) {
5508 pr_err("netdev: Unable to allocate %u tx queues.\n", 5497 pr_err("netdev: Unable to allocate %u tx queues\n", count);
5509 count);
5510 return -ENOMEM; 5498 return -ENOMEM;
5511 } 5499 }
5512 dev->_tx = tx; 5500 dev->_tx = tx;
@@ -5765,10 +5753,8 @@ static void netdev_wait_allrefs(struct net_device *dev)
5765 refcnt = netdev_refcnt_read(dev); 5753 refcnt = netdev_refcnt_read(dev);
5766 5754
5767 if (time_after(jiffies, warning_time + 10 * HZ)) { 5755 if (time_after(jiffies, warning_time + 10 * HZ)) {
5768 printk(KERN_EMERG "unregister_netdevice: " 5756 pr_emerg("unregister_netdevice: waiting for %s to become free. Usage count = %d\n",
5769 "waiting for %s to become free. Usage " 5757 dev->name, refcnt);
5770 "count = %d\n",
5771 dev->name, refcnt);
5772 warning_time = jiffies; 5758 warning_time = jiffies;
5773 } 5759 }
5774 } 5760 }
@@ -5819,7 +5805,7 @@ void netdev_run_todo(void)
5819 list_del(&dev->todo_list); 5805 list_del(&dev->todo_list);
5820 5806
5821 if (unlikely(dev->reg_state != NETREG_UNREGISTERING)) { 5807 if (unlikely(dev->reg_state != NETREG_UNREGISTERING)) {
5822 printk(KERN_ERR "network todo '%s' but state %d\n", 5808 pr_err("network todo '%s' but state %d\n",
5823 dev->name, dev->reg_state); 5809 dev->name, dev->reg_state);
5824 dump_stack(); 5810 dump_stack();
5825 continue; 5811 continue;
@@ -5935,15 +5921,13 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
5935 BUG_ON(strlen(name) >= sizeof(dev->name)); 5921 BUG_ON(strlen(name) >= sizeof(dev->name));
5936 5922
5937 if (txqs < 1) { 5923 if (txqs < 1) {
5938 pr_err("alloc_netdev: Unable to allocate device " 5924 pr_err("alloc_netdev: Unable to allocate device with zero queues\n");
5939 "with zero queues.\n");
5940 return NULL; 5925 return NULL;
5941 } 5926 }
5942 5927
5943#ifdef CONFIG_RPS 5928#ifdef CONFIG_RPS
5944 if (rxqs < 1) { 5929 if (rxqs < 1) {
5945 pr_err("alloc_netdev: Unable to allocate device " 5930 pr_err("alloc_netdev: Unable to allocate device with zero RX queues\n");
5946 "with zero RX queues.\n");
5947 return NULL; 5931 return NULL;
5948 } 5932 }
5949#endif 5933#endif
@@ -5959,7 +5943,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
5959 5943
5960 p = kzalloc(alloc_size, GFP_KERNEL); 5944 p = kzalloc(alloc_size, GFP_KERNEL);
5961 if (!p) { 5945 if (!p) {
5962 printk(KERN_ERR "alloc_netdev: Unable to allocate device.\n"); 5946 pr_err("alloc_netdev: Unable to allocate device\n");
5963 return NULL; 5947 return NULL;
5964 } 5948 }
5965 5949
@@ -6492,8 +6476,8 @@ static void __net_exit default_device_exit(struct net *net)
6492 snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex); 6476 snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex);
6493 err = dev_change_net_namespace(dev, &init_net, fb_name); 6477 err = dev_change_net_namespace(dev, &init_net, fb_name);
6494 if (err) { 6478 if (err) {
6495 printk(KERN_EMERG "%s: failed to move %s to init_net: %d\n", 6479 pr_emerg("%s: failed to move %s to init_net: %d\n",
6496 __func__, dev->name, err); 6480 __func__, dev->name, err);
6497 BUG(); 6481 BUG();
6498 } 6482 }
6499 } 6483 }
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index e287346e0934..f98ec444133a 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -2165,6 +2165,35 @@ nla_put_failure:
2165 return -EMSGSIZE; 2165 return -EMSGSIZE;
2166} 2166}
2167 2167
2168static int pneigh_fill_info(struct sk_buff *skb, struct pneigh_entry *pn,
2169 u32 pid, u32 seq, int type, unsigned int flags,
2170 struct neigh_table *tbl)
2171{
2172 struct nlmsghdr *nlh;
2173 struct ndmsg *ndm;
2174
2175 nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ndm), flags);
2176 if (nlh == NULL)
2177 return -EMSGSIZE;
2178
2179 ndm = nlmsg_data(nlh);
2180 ndm->ndm_family = tbl->family;
2181 ndm->ndm_pad1 = 0;
2182 ndm->ndm_pad2 = 0;
2183 ndm->ndm_flags = pn->flags | NTF_PROXY;
2184 ndm->ndm_type = NDA_DST;
2185 ndm->ndm_ifindex = pn->dev->ifindex;
2186 ndm->ndm_state = NUD_NONE;
2187
2188 NLA_PUT(skb, NDA_DST, tbl->key_len, pn->key);
2189
2190 return nlmsg_end(skb, nlh);
2191
2192nla_put_failure:
2193 nlmsg_cancel(skb, nlh);
2194 return -EMSGSIZE;
2195}
2196
2168static void neigh_update_notify(struct neighbour *neigh) 2197static void neigh_update_notify(struct neighbour *neigh)
2169{ 2198{
2170 call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh); 2199 call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh);
@@ -2214,23 +2243,78 @@ out:
2214 return rc; 2243 return rc;
2215} 2244}
2216 2245
2246static int pneigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
2247 struct netlink_callback *cb)
2248{
2249 struct pneigh_entry *n;
2250 struct net *net = sock_net(skb->sk);
2251 int rc, h, s_h = cb->args[3];
2252 int idx, s_idx = idx = cb->args[4];
2253
2254 read_lock_bh(&tbl->lock);
2255
2256 for (h = 0; h <= PNEIGH_HASHMASK; h++) {
2257 if (h < s_h)
2258 continue;
2259 if (h > s_h)
2260 s_idx = 0;
2261 for (n = tbl->phash_buckets[h], idx = 0; n; n = n->next) {
2262 if (dev_net(n->dev) != net)
2263 continue;
2264 if (idx < s_idx)
2265 goto next;
2266 if (pneigh_fill_info(skb, n, NETLINK_CB(cb->skb).pid,
2267 cb->nlh->nlmsg_seq,
2268 RTM_NEWNEIGH,
2269 NLM_F_MULTI, tbl) <= 0) {
2270 read_unlock_bh(&tbl->lock);
2271 rc = -1;
2272 goto out;
2273 }
2274 next:
2275 idx++;
2276 }
2277 }
2278
2279 read_unlock_bh(&tbl->lock);
2280 rc = skb->len;
2281out:
2282 cb->args[3] = h;
2283 cb->args[4] = idx;
2284 return rc;
2285
2286}
2287
2217static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb) 2288static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
2218{ 2289{
2219 struct neigh_table *tbl; 2290 struct neigh_table *tbl;
2220 int t, family, s_t; 2291 int t, family, s_t;
2292 int proxy = 0;
2293 int err = 0;
2221 2294
2222 read_lock(&neigh_tbl_lock); 2295 read_lock(&neigh_tbl_lock);
2223 family = ((struct rtgenmsg *) nlmsg_data(cb->nlh))->rtgen_family; 2296 family = ((struct rtgenmsg *) nlmsg_data(cb->nlh))->rtgen_family;
2297
2298 /* check for full ndmsg structure presence, family member is
2299 * the same for both structures
2300 */
2301 if (nlmsg_len(cb->nlh) >= sizeof(struct ndmsg) &&
2302 ((struct ndmsg *) nlmsg_data(cb->nlh))->ndm_flags == NTF_PROXY)
2303 proxy = 1;
2304
2224 s_t = cb->args[0]; 2305 s_t = cb->args[0];
2225 2306
2226 for (tbl = neigh_tables, t = 0; tbl; tbl = tbl->next, t++) { 2307 for (tbl = neigh_tables, t = 0; tbl && (err >= 0);
2308 tbl = tbl->next, t++) {
2227 if (t < s_t || (family && tbl->family != family)) 2309 if (t < s_t || (family && tbl->family != family))
2228 continue; 2310 continue;
2229 if (t > s_t) 2311 if (t > s_t)
2230 memset(&cb->args[1], 0, sizeof(cb->args) - 2312 memset(&cb->args[1], 0, sizeof(cb->args) -
2231 sizeof(cb->args[0])); 2313 sizeof(cb->args[0]));
2232 if (neigh_dump_table(tbl, skb, cb) < 0) 2314 if (proxy)
2233 break; 2315 err = pneigh_dump_table(tbl, skb, cb);
2316 else
2317 err = neigh_dump_table(tbl, skb, cb);
2234 } 2318 }
2235 read_unlock(&neigh_tbl_lock); 2319 read_unlock(&neigh_tbl_lock);
2236 2320
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 556b08298669..4ce473ea5dc0 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -9,6 +9,8 @@
9 * Copyright (C) 2002 Red Hat, Inc. 9 * Copyright (C) 2002 Red Hat, Inc.
10 */ 10 */
11 11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#include <linux/moduleparam.h> 14#include <linux/moduleparam.h>
13#include <linux/netdevice.h> 15#include <linux/netdevice.h>
14#include <linux/etherdevice.h> 16#include <linux/etherdevice.h>
@@ -45,9 +47,11 @@ static atomic_t trapped;
45#define NETPOLL_RX_ENABLED 1 47#define NETPOLL_RX_ENABLED 1
46#define NETPOLL_RX_DROP 2 48#define NETPOLL_RX_DROP 2
47 49
48#define MAX_SKB_SIZE \ 50#define MAX_SKB_SIZE \
49 (MAX_UDP_CHUNK + sizeof(struct udphdr) + \ 51 (sizeof(struct ethhdr) + \
50 sizeof(struct iphdr) + sizeof(struct ethhdr)) 52 sizeof(struct iphdr) + \
53 sizeof(struct udphdr) + \
54 MAX_UDP_CHUNK)
51 55
52static void zap_completion_queue(void); 56static void zap_completion_queue(void);
53static void arp_reply(struct sk_buff *skb); 57static void arp_reply(struct sk_buff *skb);
@@ -55,6 +59,13 @@ static void arp_reply(struct sk_buff *skb);
55static unsigned int carrier_timeout = 4; 59static unsigned int carrier_timeout = 4;
56module_param(carrier_timeout, uint, 0644); 60module_param(carrier_timeout, uint, 0644);
57 61
62#define np_info(np, fmt, ...) \
63 pr_info("%s: " fmt, np->name, ##__VA_ARGS__)
64#define np_err(np, fmt, ...) \
65 pr_err("%s: " fmt, np->name, ##__VA_ARGS__)
66#define np_notice(np, fmt, ...) \
67 pr_notice("%s: " fmt, np->name, ##__VA_ARGS__)
68
58static void queue_process(struct work_struct *work) 69static void queue_process(struct work_struct *work)
59{ 70{
60 struct netpoll_info *npinfo = 71 struct netpoll_info *npinfo =
@@ -627,18 +638,12 @@ out:
627 638
628void netpoll_print_options(struct netpoll *np) 639void netpoll_print_options(struct netpoll *np)
629{ 640{
630 printk(KERN_INFO "%s: local port %d\n", 641 np_info(np, "local port %d\n", np->local_port);
631 np->name, np->local_port); 642 np_info(np, "local IP %pI4\n", &np->local_ip);
632 printk(KERN_INFO "%s: local IP %pI4\n", 643 np_info(np, "interface '%s'\n", np->dev_name);
633 np->name, &np->local_ip); 644 np_info(np, "remote port %d\n", np->remote_port);
634 printk(KERN_INFO "%s: interface '%s'\n", 645 np_info(np, "remote IP %pI4\n", &np->remote_ip);
635 np->name, np->dev_name); 646 np_info(np, "remote ethernet address %pM\n", np->remote_mac);
636 printk(KERN_INFO "%s: remote port %d\n",
637 np->name, np->remote_port);
638 printk(KERN_INFO "%s: remote IP %pI4\n",
639 np->name, &np->remote_ip);
640 printk(KERN_INFO "%s: remote ethernet address %pM\n",
641 np->name, np->remote_mac);
642} 647}
643EXPORT_SYMBOL(netpoll_print_options); 648EXPORT_SYMBOL(netpoll_print_options);
644 649
@@ -680,8 +685,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
680 goto parse_failed; 685 goto parse_failed;
681 *delim = 0; 686 *delim = 0;
682 if (*cur == ' ' || *cur == '\t') 687 if (*cur == ' ' || *cur == '\t')
683 printk(KERN_INFO "%s: warning: whitespace" 688 np_info(np, "warning: whitespace is not allowed\n");
684 "is not allowed\n", np->name);
685 np->remote_port = simple_strtol(cur, NULL, 10); 689 np->remote_port = simple_strtol(cur, NULL, 10);
686 cur = delim; 690 cur = delim;
687 } 691 }
@@ -705,8 +709,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
705 return 0; 709 return 0;
706 710
707 parse_failed: 711 parse_failed:
708 printk(KERN_INFO "%s: couldn't parse config at '%s'!\n", 712 np_info(np, "couldn't parse config at '%s'!\n", cur);
709 np->name, cur);
710 return -1; 713 return -1;
711} 714}
712EXPORT_SYMBOL(netpoll_parse_options); 715EXPORT_SYMBOL(netpoll_parse_options);
@@ -721,8 +724,8 @@ int __netpoll_setup(struct netpoll *np)
721 724
722 if ((ndev->priv_flags & IFF_DISABLE_NETPOLL) || 725 if ((ndev->priv_flags & IFF_DISABLE_NETPOLL) ||
723 !ndev->netdev_ops->ndo_poll_controller) { 726 !ndev->netdev_ops->ndo_poll_controller) {
724 printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n", 727 np_err(np, "%s doesn't support polling, aborting\n",
725 np->name, np->dev_name); 728 np->dev_name);
726 err = -ENOTSUPP; 729 err = -ENOTSUPP;
727 goto out; 730 goto out;
728 } 731 }
@@ -785,14 +788,12 @@ int netpoll_setup(struct netpoll *np)
785 if (np->dev_name) 788 if (np->dev_name)
786 ndev = dev_get_by_name(&init_net, np->dev_name); 789 ndev = dev_get_by_name(&init_net, np->dev_name);
787 if (!ndev) { 790 if (!ndev) {
788 printk(KERN_ERR "%s: %s doesn't exist, aborting.\n", 791 np_err(np, "%s doesn't exist, aborting\n", np->dev_name);
789 np->name, np->dev_name);
790 return -ENODEV; 792 return -ENODEV;
791 } 793 }
792 794
793 if (ndev->master) { 795 if (ndev->master) {
794 printk(KERN_ERR "%s: %s is a slave device, aborting.\n", 796 np_err(np, "%s is a slave device, aborting\n", np->dev_name);
795 np->name, np->dev_name);
796 err = -EBUSY; 797 err = -EBUSY;
797 goto put; 798 goto put;
798 } 799 }
@@ -800,16 +801,14 @@ int netpoll_setup(struct netpoll *np)
800 if (!netif_running(ndev)) { 801 if (!netif_running(ndev)) {
801 unsigned long atmost, atleast; 802 unsigned long atmost, atleast;
802 803
803 printk(KERN_INFO "%s: device %s not up yet, forcing it\n", 804 np_info(np, "device %s not up yet, forcing it\n", np->dev_name);
804 np->name, np->dev_name);
805 805
806 rtnl_lock(); 806 rtnl_lock();
807 err = dev_open(ndev); 807 err = dev_open(ndev);
808 rtnl_unlock(); 808 rtnl_unlock();
809 809
810 if (err) { 810 if (err) {
811 printk(KERN_ERR "%s: failed to open %s\n", 811 np_err(np, "failed to open %s\n", ndev->name);
812 np->name, ndev->name);
813 goto put; 812 goto put;
814 } 813 }
815 814
@@ -817,9 +816,7 @@ int netpoll_setup(struct netpoll *np)
817 atmost = jiffies + carrier_timeout * HZ; 816 atmost = jiffies + carrier_timeout * HZ;
818 while (!netif_carrier_ok(ndev)) { 817 while (!netif_carrier_ok(ndev)) {
819 if (time_after(jiffies, atmost)) { 818 if (time_after(jiffies, atmost)) {
820 printk(KERN_NOTICE 819 np_notice(np, "timeout waiting for carrier\n");
821 "%s: timeout waiting for carrier\n",
822 np->name);
823 break; 820 break;
824 } 821 }
825 msleep(1); 822 msleep(1);
@@ -831,9 +828,7 @@ int netpoll_setup(struct netpoll *np)
831 */ 828 */
832 829
833 if (time_before(jiffies, atleast)) { 830 if (time_before(jiffies, atleast)) {
834 printk(KERN_NOTICE "%s: carrier detect appears" 831 np_notice(np, "carrier detect appears untrustworthy, waiting 4 seconds\n");
835 " untrustworthy, waiting 4 seconds\n",
836 np->name);
837 msleep(4000); 832 msleep(4000);
838 } 833 }
839 } 834 }
@@ -844,15 +839,15 @@ int netpoll_setup(struct netpoll *np)
844 839
845 if (!in_dev || !in_dev->ifa_list) { 840 if (!in_dev || !in_dev->ifa_list) {
846 rcu_read_unlock(); 841 rcu_read_unlock();
847 printk(KERN_ERR "%s: no IP address for %s, aborting\n", 842 np_err(np, "no IP address for %s, aborting\n",
848 np->name, np->dev_name); 843 np->dev_name);
849 err = -EDESTADDRREQ; 844 err = -EDESTADDRREQ;
850 goto put; 845 goto put;
851 } 846 }
852 847
853 np->local_ip = in_dev->ifa_list->ifa_local; 848 np->local_ip = in_dev->ifa_list->ifa_local;
854 rcu_read_unlock(); 849 rcu_read_unlock();
855 printk(KERN_INFO "%s: local IP %pI4\n", np->name, &np->local_ip); 850 np_info(np, "local IP %pI4\n", &np->local_ip);
856 } 851 }
857 852
858 np->dev = ndev; 853 np->dev = ndev;
diff --git a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c
index befe426491ba..ee7013f24fca 100644
--- a/net/decnet/dn_neigh.c
+++ b/net/decnet/dn_neigh.c
@@ -205,17 +205,23 @@ static int dn_neigh_output_packet(struct sk_buff *skb)
205 struct neighbour *neigh = dst_get_neighbour_noref(dst); 205 struct neighbour *neigh = dst_get_neighbour_noref(dst);
206 struct net_device *dev = neigh->dev; 206 struct net_device *dev = neigh->dev;
207 char mac_addr[ETH_ALEN]; 207 char mac_addr[ETH_ALEN];
208 unsigned int seq;
209 int err;
208 210
209 dn_dn2eth(mac_addr, rt->rt_local_src); 211 dn_dn2eth(mac_addr, rt->rt_local_src);
210 if (dev_hard_header(skb, dev, ntohs(skb->protocol), neigh->ha, 212 do {
211 mac_addr, skb->len) >= 0) 213 seq = read_seqbegin(&neigh->ha_lock);
212 return dev_queue_xmit(skb); 214 err = dev_hard_header(skb, dev, ntohs(skb->protocol),
213 215 neigh->ha, mac_addr, skb->len);
214 if (net_ratelimit()) 216 } while (read_seqretry(&neigh->ha_lock, seq));
215 printk(KERN_DEBUG "dn_neigh_output_packet: oops, can't send packet\n"); 217
216 218 if (err >= 0)
217 kfree_skb(skb); 219 err = dev_queue_xmit(skb);
218 return -EINVAL; 220 else {
221 kfree_skb(skb);
222 err = -EINVAL;
223 }
224 return err;
219} 225}
220 226
221static int dn_long_output(struct neighbour *neigh, struct sk_buff *skb) 227static int dn_long_output(struct neighbour *neigh, struct sk_buff *skb)
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index f31ce72dca65..80a3de4906d3 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -724,11 +724,10 @@ static int dn_output(struct sk_buff *skb)
724 struct dn_route *rt = (struct dn_route *)dst; 724 struct dn_route *rt = (struct dn_route *)dst;
725 struct net_device *dev = dst->dev; 725 struct net_device *dev = dst->dev;
726 struct dn_skb_cb *cb = DN_SKB_CB(skb); 726 struct dn_skb_cb *cb = DN_SKB_CB(skb);
727 struct neighbour *neigh;
728 727
729 int err = -EINVAL; 728 int err = -EINVAL;
730 729
731 if ((neigh = dst_get_neighbour_noref(dst)) == NULL) 730 if (dst_get_neighbour_noref(dst) == NULL)
732 goto error; 731 goto error;
733 732
734 skb->dev = dev; 733 skb->dev = dev;
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 6b3ca5ba4450..0286d78c589c 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -730,15 +730,16 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
730 730
731 if (skb->protocol == htons(ETH_P_IP)) { 731 if (skb->protocol == htons(ETH_P_IP)) {
732 rt = skb_rtable(skb); 732 rt = skb_rtable(skb);
733 if ((dst = rt->rt_gateway) == 0) 733 dst = rt->rt_gateway;
734 goto tx_error_icmp;
735 } 734 }
736#if IS_ENABLED(CONFIG_IPV6) 735#if IS_ENABLED(CONFIG_IPV6)
737 else if (skb->protocol == htons(ETH_P_IPV6)) { 736 else if (skb->protocol == htons(ETH_P_IPV6)) {
738 struct neighbour *neigh = dst_get_neighbour_noref(skb_dst(skb));
739 const struct in6_addr *addr6; 737 const struct in6_addr *addr6;
738 struct neighbour *neigh;
739 bool do_tx_error_icmp;
740 int addr_type; 740 int addr_type;
741 741
742 neigh = dst_neigh_lookup(skb_dst(skb), &ipv6_hdr(skb)->daddr);
742 if (neigh == NULL) 743 if (neigh == NULL)
743 goto tx_error; 744 goto tx_error;
744 745
@@ -751,9 +752,14 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
751 } 752 }
752 753
753 if ((addr_type & IPV6_ADDR_COMPATv4) == 0) 754 if ((addr_type & IPV6_ADDR_COMPATv4) == 0)
755 do_tx_error_icmp = true;
756 else {
757 do_tx_error_icmp = false;
758 dst = addr6->s6_addr32[3];
759 }
760 neigh_release(neigh);
761 if (do_tx_error_icmp)
754 goto tx_error_icmp; 762 goto tx_error_icmp;
755
756 dst = addr6->s6_addr32[3];
757 } 763 }
758#endif 764#endif
759 else 765 else
@@ -914,9 +920,10 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
914 __IPTUNNEL_XMIT(tstats, &dev->stats); 920 __IPTUNNEL_XMIT(tstats, &dev->stats);
915 return NETDEV_TX_OK; 921 return NETDEV_TX_OK;
916 922
923#if IS_ENABLED(CONFIG_IPV6)
917tx_error_icmp: 924tx_error_icmp:
918 dst_link_failure(skb); 925 dst_link_failure(skb);
919 926#endif
920tx_error: 927tx_error:
921 dev->stats.tx_errors++; 928 dev->stats.tx_errors++;
922 dev_kfree_skb(skb); 929 dev_kfree_skb(skb);
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 8aa87c19fa00..9125529dab95 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -469,6 +469,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
469 (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) | 469 (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) |
470 (1<<IP_PASSSEC) | (1<<IP_TRANSPARENT) | 470 (1<<IP_PASSSEC) | (1<<IP_TRANSPARENT) |
471 (1<<IP_MINTTL) | (1<<IP_NODEFRAG))) || 471 (1<<IP_MINTTL) | (1<<IP_NODEFRAG))) ||
472 optname == IP_UNICAST_IF ||
472 optname == IP_MULTICAST_TTL || 473 optname == IP_MULTICAST_TTL ||
473 optname == IP_MULTICAST_ALL || 474 optname == IP_MULTICAST_ALL ||
474 optname == IP_MULTICAST_LOOP || 475 optname == IP_MULTICAST_LOOP ||
@@ -628,6 +629,35 @@ static int do_ip_setsockopt(struct sock *sk, int level,
628 goto e_inval; 629 goto e_inval;
629 inet->mc_loop = !!val; 630 inet->mc_loop = !!val;
630 break; 631 break;
632 case IP_UNICAST_IF:
633 {
634 struct net_device *dev = NULL;
635 int ifindex;
636
637 if (optlen != sizeof(int))
638 goto e_inval;
639
640 ifindex = (__force int)ntohl((__force __be32)val);
641 if (ifindex == 0) {
642 inet->uc_index = 0;
643 err = 0;
644 break;
645 }
646
647 dev = dev_get_by_index(sock_net(sk), ifindex);
648 err = -EADDRNOTAVAIL;
649 if (!dev)
650 break;
651 dev_put(dev);
652
653 err = -EINVAL;
654 if (sk->sk_bound_dev_if)
655 break;
656
657 inet->uc_index = ifindex;
658 err = 0;
659 break;
660 }
631 case IP_MULTICAST_IF: 661 case IP_MULTICAST_IF:
632 { 662 {
633 struct ip_mreqn mreq; 663 struct ip_mreqn mreq;
@@ -1178,6 +1208,9 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
1178 case IP_MULTICAST_LOOP: 1208 case IP_MULTICAST_LOOP:
1179 val = inet->mc_loop; 1209 val = inet->mc_loop;
1180 break; 1210 break;
1211 case IP_UNICAST_IF:
1212 val = (__force int)htonl((__u32) inet->uc_index);
1213 break;
1181 case IP_MULTICAST_IF: 1214 case IP_MULTICAST_IF:
1182 { 1215 {
1183 struct in_addr addr; 1216 struct in_addr addr;
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 22a199315309..f84ebff5cdb0 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -454,8 +454,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
454 dev->stats.tx_fifo_errors++; 454 dev->stats.tx_fifo_errors++;
455 goto tx_error; 455 goto tx_error;
456 } 456 }
457 if ((dst = rt->rt_gateway) == 0) 457 dst = rt->rt_gateway;
458 goto tx_error_icmp;
459 } 458 }
460 459
461 rt = ip_route_output_ports(dev_net(dev), &fl4, NULL, 460 rt = ip_route_output_ports(dev_net(dev), &fl4, NULL,
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index aea5a199c37a..cfc82cf339f6 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -556,7 +556,8 @@ static int ping_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
556 ipc.oif = inet->mc_index; 556 ipc.oif = inet->mc_index;
557 if (!saddr) 557 if (!saddr)
558 saddr = inet->mc_addr; 558 saddr = inet->mc_addr;
559 } 559 } else if (!ipc.oif)
560 ipc.oif = inet->uc_index;
560 561
561 flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos, 562 flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos,
562 RT_SCOPE_UNIVERSE, sk->sk_protocol, 563 RT_SCOPE_UNIVERSE, sk->sk_protocol,
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index 6afc807ee2ad..02d61079f08b 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -256,6 +256,7 @@ static const struct snmp_mib snmp4_net_list[] = {
256 SNMP_MIB_ITEM("TCPTimeWaitOverflow", LINUX_MIB_TCPTIMEWAITOVERFLOW), 256 SNMP_MIB_ITEM("TCPTimeWaitOverflow", LINUX_MIB_TCPTIMEWAITOVERFLOW),
257 SNMP_MIB_ITEM("TCPReqQFullDoCookies", LINUX_MIB_TCPREQQFULLDOCOOKIES), 257 SNMP_MIB_ITEM("TCPReqQFullDoCookies", LINUX_MIB_TCPREQQFULLDOCOOKIES),
258 SNMP_MIB_ITEM("TCPReqQFullDrop", LINUX_MIB_TCPREQQFULLDROP), 258 SNMP_MIB_ITEM("TCPReqQFullDrop", LINUX_MIB_TCPREQQFULLDROP),
259 SNMP_MIB_ITEM("TCPRetransFail", LINUX_MIB_TCPRETRANSFAIL),
259 SNMP_MIB_SENTINEL 260 SNMP_MIB_SENTINEL
260}; 261};
261 262
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 3ccda5ae8a27..ab466305b629 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -563,7 +563,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
563 ipc.oif = inet->mc_index; 563 ipc.oif = inet->mc_index;
564 if (!saddr) 564 if (!saddr)
565 saddr = inet->mc_addr; 565 saddr = inet->mc_addr;
566 } 566 } else if (!ipc.oif)
567 ipc.oif = inet->uc_index;
567 568
568 flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos, 569 flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos,
569 RT_SCOPE_UNIVERSE, 570 RT_SCOPE_UNIVERSE,
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index bcacf54e5418..4eeb8ce856e2 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1117,10 +1117,15 @@ static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst, const vo
1117 static const __be32 inaddr_any = 0; 1117 static const __be32 inaddr_any = 0;
1118 struct net_device *dev = dst->dev; 1118 struct net_device *dev = dst->dev;
1119 const __be32 *pkey = daddr; 1119 const __be32 *pkey = daddr;
1120 const struct rtable *rt;
1120 struct neighbour *n; 1121 struct neighbour *n;
1121 1122
1123 rt = (const struct rtable *) dst;
1124
1122 if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) 1125 if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT))
1123 pkey = &inaddr_any; 1126 pkey = &inaddr_any;
1127 else if (rt->rt_gateway)
1128 pkey = (const __be32 *) &rt->rt_gateway;
1124 1129
1125 n = __ipv4_neigh_lookup(&arp_tbl, dev, *(__force u32 *)pkey); 1130 n = __ipv4_neigh_lookup(&arp_tbl, dev, *(__force u32 *)pkey);
1126 if (n) 1131 if (n)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 94d683a61cba..4d6f81c818dc 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -90,16 +90,8 @@ EXPORT_SYMBOL(sysctl_tcp_low_latency);
90 90
91 91
92#ifdef CONFIG_TCP_MD5SIG 92#ifdef CONFIG_TCP_MD5SIG
93static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, 93static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
94 __be32 addr);
95static int tcp_v4_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key,
96 __be32 daddr, __be32 saddr, const struct tcphdr *th); 94 __be32 daddr, __be32 saddr, const struct tcphdr *th);
97#else
98static inline
99struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr)
100{
101 return NULL;
102}
103#endif 95#endif
104 96
105struct inet_hashinfo tcp_hashinfo; 97struct inet_hashinfo tcp_hashinfo;
@@ -601,6 +593,10 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
601 struct ip_reply_arg arg; 593 struct ip_reply_arg arg;
602#ifdef CONFIG_TCP_MD5SIG 594#ifdef CONFIG_TCP_MD5SIG
603 struct tcp_md5sig_key *key; 595 struct tcp_md5sig_key *key;
596 const __u8 *hash_location = NULL;
597 unsigned char newhash[16];
598 int genhash;
599 struct sock *sk1 = NULL;
604#endif 600#endif
605 struct net *net; 601 struct net *net;
606 602
@@ -631,7 +627,36 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
631 arg.iov[0].iov_len = sizeof(rep.th); 627 arg.iov[0].iov_len = sizeof(rep.th);
632 628
633#ifdef CONFIG_TCP_MD5SIG 629#ifdef CONFIG_TCP_MD5SIG
634 key = sk ? tcp_v4_md5_do_lookup(sk, ip_hdr(skb)->saddr) : NULL; 630 hash_location = tcp_parse_md5sig_option(th);
631 if (!sk && hash_location) {
632 /*
633 * active side is lost. Try to find listening socket through
634 * source port, and then find md5 key through listening socket.
635 * we are not loose security here:
636 * Incoming packet is checked with md5 hash with finding key,
637 * no RST generated if md5 hash doesn't match.
638 */
639 sk1 = __inet_lookup_listener(dev_net(skb_dst(skb)->dev),
640 &tcp_hashinfo, ip_hdr(skb)->daddr,
641 ntohs(th->source), inet_iif(skb));
642 /* don't send rst if it can't find key */
643 if (!sk1)
644 return;
645 rcu_read_lock();
646 key = tcp_md5_do_lookup(sk1, (union tcp_md5_addr *)
647 &ip_hdr(skb)->saddr, AF_INET);
648 if (!key)
649 goto release_sk1;
650
651 genhash = tcp_v4_md5_hash_skb(newhash, key, NULL, NULL, skb);
652 if (genhash || memcmp(hash_location, newhash, 16) != 0)
653 goto release_sk1;
654 } else {
655 key = sk ? tcp_md5_do_lookup(sk, (union tcp_md5_addr *)
656 &ip_hdr(skb)->saddr,
657 AF_INET) : NULL;
658 }
659
635 if (key) { 660 if (key) {
636 rep.opt[0] = htonl((TCPOPT_NOP << 24) | 661 rep.opt[0] = htonl((TCPOPT_NOP << 24) |
637 (TCPOPT_NOP << 16) | 662 (TCPOPT_NOP << 16) |
@@ -664,6 +689,14 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
664 689
665 TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS); 690 TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS);
666 TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS); 691 TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS);
692
693#ifdef CONFIG_TCP_MD5SIG
694release_sk1:
695 if (sk1) {
696 rcu_read_unlock();
697 sock_put(sk1);
698 }
699#endif
667} 700}
668 701
669/* The code following below sending ACKs in SYN-RECV and TIME-WAIT states 702/* The code following below sending ACKs in SYN-RECV and TIME-WAIT states
@@ -764,7 +797,8 @@ static void tcp_v4_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
764 tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, 797 tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd,
765 req->ts_recent, 798 req->ts_recent,
766 0, 799 0,
767 tcp_v4_md5_do_lookup(sk, ip_hdr(skb)->daddr), 800 tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&ip_hdr(skb)->daddr,
801 AF_INET),
768 inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0, 802 inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0,
769 ip_hdr(skb)->tos); 803 ip_hdr(skb)->tos);
770} 804}
@@ -881,153 +915,137 @@ static struct ip_options_rcu *tcp_v4_save_options(struct sock *sk,
881 */ 915 */
882 916
883/* Find the Key structure for an address. */ 917/* Find the Key structure for an address. */
884static struct tcp_md5sig_key * 918struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk,
885 tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr) 919 const union tcp_md5_addr *addr,
920 int family)
886{ 921{
887 struct tcp_sock *tp = tcp_sk(sk); 922 struct tcp_sock *tp = tcp_sk(sk);
888 int i; 923 struct tcp_md5sig_key *key;
889 924 struct hlist_node *pos;
890 if (!tp->md5sig_info || !tp->md5sig_info->entries4) 925 unsigned int size = sizeof(struct in_addr);
926 struct tcp_md5sig_info *md5sig;
927
928 /* caller either holds rcu_read_lock() or socket lock */
929 md5sig = rcu_dereference_check(tp->md5sig_info,
930 sock_owned_by_user(sk));
931 if (!md5sig)
891 return NULL; 932 return NULL;
892 for (i = 0; i < tp->md5sig_info->entries4; i++) { 933#if IS_ENABLED(CONFIG_IPV6)
893 if (tp->md5sig_info->keys4[i].addr == addr) 934 if (family == AF_INET6)
894 return &tp->md5sig_info->keys4[i].base; 935 size = sizeof(struct in6_addr);
936#endif
937 hlist_for_each_entry_rcu(key, pos, &md5sig->head, node) {
938 if (key->family != family)
939 continue;
940 if (!memcmp(&key->addr, addr, size))
941 return key;
895 } 942 }
896 return NULL; 943 return NULL;
897} 944}
945EXPORT_SYMBOL(tcp_md5_do_lookup);
898 946
899struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, 947struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk,
900 struct sock *addr_sk) 948 struct sock *addr_sk)
901{ 949{
902 return tcp_v4_md5_do_lookup(sk, inet_sk(addr_sk)->inet_daddr); 950 union tcp_md5_addr *addr;
951
952 addr = (union tcp_md5_addr *)&inet_sk(addr_sk)->inet_daddr;
953 return tcp_md5_do_lookup(sk, addr, AF_INET);
903} 954}
904EXPORT_SYMBOL(tcp_v4_md5_lookup); 955EXPORT_SYMBOL(tcp_v4_md5_lookup);
905 956
906static struct tcp_md5sig_key *tcp_v4_reqsk_md5_lookup(struct sock *sk, 957static struct tcp_md5sig_key *tcp_v4_reqsk_md5_lookup(struct sock *sk,
907 struct request_sock *req) 958 struct request_sock *req)
908{ 959{
909 return tcp_v4_md5_do_lookup(sk, inet_rsk(req)->rmt_addr); 960 union tcp_md5_addr *addr;
961
962 addr = (union tcp_md5_addr *)&inet_rsk(req)->rmt_addr;
963 return tcp_md5_do_lookup(sk, addr, AF_INET);
910} 964}
911 965
912/* This can be called on a newly created socket, from other files */ 966/* This can be called on a newly created socket, from other files */
913int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, 967int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
914 u8 *newkey, u8 newkeylen) 968 int family, const u8 *newkey, u8 newkeylen, gfp_t gfp)
915{ 969{
916 /* Add Key to the list */ 970 /* Add Key to the list */
917 struct tcp_md5sig_key *key; 971 struct tcp_md5sig_key *key;
918 struct tcp_sock *tp = tcp_sk(sk); 972 struct tcp_sock *tp = tcp_sk(sk);
919 struct tcp4_md5sig_key *keys; 973 struct tcp_md5sig_info *md5sig;
920 974
921 key = tcp_v4_md5_do_lookup(sk, addr); 975 key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&addr, AF_INET);
922 if (key) { 976 if (key) {
923 /* Pre-existing entry - just update that one. */ 977 /* Pre-existing entry - just update that one. */
924 kfree(key->key); 978 memcpy(key->key, newkey, newkeylen);
925 key->key = newkey;
926 key->keylen = newkeylen; 979 key->keylen = newkeylen;
927 } else { 980 return 0;
928 struct tcp_md5sig_info *md5sig; 981 }
929
930 if (!tp->md5sig_info) {
931 tp->md5sig_info = kzalloc(sizeof(*tp->md5sig_info),
932 GFP_ATOMIC);
933 if (!tp->md5sig_info) {
934 kfree(newkey);
935 return -ENOMEM;
936 }
937 sk_nocaps_add(sk, NETIF_F_GSO_MASK);
938 }
939 982
940 md5sig = tp->md5sig_info; 983 md5sig = rcu_dereference_protected(tp->md5sig_info,
941 if (md5sig->entries4 == 0 && 984 sock_owned_by_user(sk));
942 tcp_alloc_md5sig_pool(sk) == NULL) { 985 if (!md5sig) {
943 kfree(newkey); 986 md5sig = kmalloc(sizeof(*md5sig), gfp);
987 if (!md5sig)
944 return -ENOMEM; 988 return -ENOMEM;
945 }
946
947 if (md5sig->alloced4 == md5sig->entries4) {
948 keys = kmalloc((sizeof(*keys) *
949 (md5sig->entries4 + 1)), GFP_ATOMIC);
950 if (!keys) {
951 kfree(newkey);
952 if (md5sig->entries4 == 0)
953 tcp_free_md5sig_pool();
954 return -ENOMEM;
955 }
956 989
957 if (md5sig->entries4) 990 sk_nocaps_add(sk, NETIF_F_GSO_MASK);
958 memcpy(keys, md5sig->keys4, 991 INIT_HLIST_HEAD(&md5sig->head);
959 sizeof(*keys) * md5sig->entries4); 992 rcu_assign_pointer(tp->md5sig_info, md5sig);
993 }
960 994
961 /* Free old key list, and reference new one */ 995 key = sock_kmalloc(sk, sizeof(*key), gfp);
962 kfree(md5sig->keys4); 996 if (!key)
963 md5sig->keys4 = keys; 997 return -ENOMEM;
964 md5sig->alloced4++; 998 if (hlist_empty(&md5sig->head) && !tcp_alloc_md5sig_pool(sk)) {
965 } 999 sock_kfree_s(sk, key, sizeof(*key));
966 md5sig->entries4++; 1000 return -ENOMEM;
967 md5sig->keys4[md5sig->entries4 - 1].addr = addr;
968 md5sig->keys4[md5sig->entries4 - 1].base.key = newkey;
969 md5sig->keys4[md5sig->entries4 - 1].base.keylen = newkeylen;
970 } 1001 }
971 return 0;
972}
973EXPORT_SYMBOL(tcp_v4_md5_do_add);
974 1002
975static int tcp_v4_md5_add_func(struct sock *sk, struct sock *addr_sk, 1003 memcpy(key->key, newkey, newkeylen);
976 u8 *newkey, u8 newkeylen) 1004 key->keylen = newkeylen;
977{ 1005 key->family = family;
978 return tcp_v4_md5_do_add(sk, inet_sk(addr_sk)->inet_daddr, 1006 memcpy(&key->addr, addr,
979 newkey, newkeylen); 1007 (family == AF_INET6) ? sizeof(struct in6_addr) :
1008 sizeof(struct in_addr));
1009 hlist_add_head_rcu(&key->node, &md5sig->head);
1010 return 0;
980} 1011}
1012EXPORT_SYMBOL(tcp_md5_do_add);
981 1013
982int tcp_v4_md5_do_del(struct sock *sk, __be32 addr) 1014int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, int family)
983{ 1015{
984 struct tcp_sock *tp = tcp_sk(sk); 1016 struct tcp_sock *tp = tcp_sk(sk);
985 int i; 1017 struct tcp_md5sig_key *key;
986 1018 struct tcp_md5sig_info *md5sig;
987 for (i = 0; i < tp->md5sig_info->entries4; i++) { 1019
988 if (tp->md5sig_info->keys4[i].addr == addr) { 1020 key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&addr, AF_INET);
989 /* Free the key */ 1021 if (!key)
990 kfree(tp->md5sig_info->keys4[i].base.key); 1022 return -ENOENT;
991 tp->md5sig_info->entries4--; 1023 hlist_del_rcu(&key->node);
992 1024 atomic_sub(sizeof(*key), &sk->sk_omem_alloc);
993 if (tp->md5sig_info->entries4 == 0) { 1025 kfree_rcu(key, rcu);
994 kfree(tp->md5sig_info->keys4); 1026 md5sig = rcu_dereference_protected(tp->md5sig_info,
995 tp->md5sig_info->keys4 = NULL; 1027 sock_owned_by_user(sk));
996 tp->md5sig_info->alloced4 = 0; 1028 if (hlist_empty(&md5sig->head))
997 tcp_free_md5sig_pool(); 1029 tcp_free_md5sig_pool();
998 } else if (tp->md5sig_info->entries4 != i) { 1030 return 0;
999 /* Need to do some manipulation */
1000 memmove(&tp->md5sig_info->keys4[i],
1001 &tp->md5sig_info->keys4[i+1],
1002 (tp->md5sig_info->entries4 - i) *
1003 sizeof(struct tcp4_md5sig_key));
1004 }
1005 return 0;
1006 }
1007 }
1008 return -ENOENT;
1009} 1031}
1010EXPORT_SYMBOL(tcp_v4_md5_do_del); 1032EXPORT_SYMBOL(tcp_md5_do_del);
1011 1033
1012static void tcp_v4_clear_md5_list(struct sock *sk) 1034void tcp_clear_md5_list(struct sock *sk)
1013{ 1035{
1014 struct tcp_sock *tp = tcp_sk(sk); 1036 struct tcp_sock *tp = tcp_sk(sk);
1037 struct tcp_md5sig_key *key;
1038 struct hlist_node *pos, *n;
1039 struct tcp_md5sig_info *md5sig;
1015 1040
1016 /* Free each key, then the set of key keys, 1041 md5sig = rcu_dereference_protected(tp->md5sig_info, 1);
1017 * the crypto element, and then decrement our 1042
1018 * hold on the last resort crypto. 1043 if (!hlist_empty(&md5sig->head))
1019 */
1020 if (tp->md5sig_info->entries4) {
1021 int i;
1022 for (i = 0; i < tp->md5sig_info->entries4; i++)
1023 kfree(tp->md5sig_info->keys4[i].base.key);
1024 tp->md5sig_info->entries4 = 0;
1025 tcp_free_md5sig_pool(); 1044 tcp_free_md5sig_pool();
1026 } 1045 hlist_for_each_entry_safe(key, pos, n, &md5sig->head, node) {
1027 if (tp->md5sig_info->keys4) { 1046 hlist_del_rcu(&key->node);
1028 kfree(tp->md5sig_info->keys4); 1047 atomic_sub(sizeof(*key), &sk->sk_omem_alloc);
1029 tp->md5sig_info->keys4 = NULL; 1048 kfree_rcu(key, rcu);
1030 tp->md5sig_info->alloced4 = 0;
1031 } 1049 }
1032} 1050}
1033 1051
@@ -1036,7 +1054,6 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, char __user *optval,
1036{ 1054{
1037 struct tcp_md5sig cmd; 1055 struct tcp_md5sig cmd;
1038 struct sockaddr_in *sin = (struct sockaddr_in *)&cmd.tcpm_addr; 1056 struct sockaddr_in *sin = (struct sockaddr_in *)&cmd.tcpm_addr;
1039 u8 *newkey;
1040 1057
1041 if (optlen < sizeof(cmd)) 1058 if (optlen < sizeof(cmd))
1042 return -EINVAL; 1059 return -EINVAL;
@@ -1047,32 +1064,16 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, char __user *optval,
1047 if (sin->sin_family != AF_INET) 1064 if (sin->sin_family != AF_INET)
1048 return -EINVAL; 1065 return -EINVAL;
1049 1066
1050 if (!cmd.tcpm_key || !cmd.tcpm_keylen) { 1067 if (!cmd.tcpm_key || !cmd.tcpm_keylen)
1051 if (!tcp_sk(sk)->md5sig_info) 1068 return tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin->sin_addr.s_addr,
1052 return -ENOENT; 1069 AF_INET);
1053 return tcp_v4_md5_do_del(sk, sin->sin_addr.s_addr);
1054 }
1055 1070
1056 if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN) 1071 if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN)
1057 return -EINVAL; 1072 return -EINVAL;
1058 1073
1059 if (!tcp_sk(sk)->md5sig_info) { 1074 return tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin->sin_addr.s_addr,
1060 struct tcp_sock *tp = tcp_sk(sk); 1075 AF_INET, cmd.tcpm_key, cmd.tcpm_keylen,
1061 struct tcp_md5sig_info *p; 1076 GFP_KERNEL);
1062
1063 p = kzalloc(sizeof(*p), sk->sk_allocation);
1064 if (!p)
1065 return -EINVAL;
1066
1067 tp->md5sig_info = p;
1068 sk_nocaps_add(sk, NETIF_F_GSO_MASK);
1069 }
1070
1071 newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, sk->sk_allocation);
1072 if (!newkey)
1073 return -ENOMEM;
1074 return tcp_v4_md5_do_add(sk, sin->sin_addr.s_addr,
1075 newkey, cmd.tcpm_keylen);
1076} 1077}
1077 1078
1078static int tcp_v4_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp, 1079static int tcp_v4_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp,
@@ -1098,7 +1099,7 @@ static int tcp_v4_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp,
1098 return crypto_hash_update(&hp->md5_desc, &sg, sizeof(*bp)); 1099 return crypto_hash_update(&hp->md5_desc, &sg, sizeof(*bp));
1099} 1100}
1100 1101
1101static int tcp_v4_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key, 1102static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
1102 __be32 daddr, __be32 saddr, const struct tcphdr *th) 1103 __be32 daddr, __be32 saddr, const struct tcphdr *th)
1103{ 1104{
1104 struct tcp_md5sig_pool *hp; 1105 struct tcp_md5sig_pool *hp;
@@ -1198,7 +1199,8 @@ static int tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
1198 int genhash; 1199 int genhash;
1199 unsigned char newhash[16]; 1200 unsigned char newhash[16];
1200 1201
1201 hash_expected = tcp_v4_md5_do_lookup(sk, iph->saddr); 1202 hash_expected = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&iph->saddr,
1203 AF_INET);
1202 hash_location = tcp_parse_md5sig_option(th); 1204 hash_location = tcp_parse_md5sig_option(th);
1203 1205
1204 /* We've parsed the options - do we have a hash? */ 1206 /* We've parsed the options - do we have a hash? */
@@ -1486,7 +1488,8 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1486 1488
1487#ifdef CONFIG_TCP_MD5SIG 1489#ifdef CONFIG_TCP_MD5SIG
1488 /* Copy over the MD5 key from the original socket */ 1490 /* Copy over the MD5 key from the original socket */
1489 key = tcp_v4_md5_do_lookup(sk, newinet->inet_daddr); 1491 key = tcp_md5_do_lookup(sk, (union tcp_md5_addr *)&newinet->inet_daddr,
1492 AF_INET);
1490 if (key != NULL) { 1493 if (key != NULL) {
1491 /* 1494 /*
1492 * We're using one, so create a matching key 1495 * We're using one, so create a matching key
@@ -1494,10 +1497,8 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1494 * memory, then we end up not copying the key 1497 * memory, then we end up not copying the key
1495 * across. Shucks. 1498 * across. Shucks.
1496 */ 1499 */
1497 char *newkey = kmemdup(key->key, key->keylen, GFP_ATOMIC); 1500 tcp_md5_do_add(newsk, (union tcp_md5_addr *)&newinet->inet_daddr,
1498 if (newkey != NULL) 1501 AF_INET, key->key, key->keylen, GFP_ATOMIC);
1499 tcp_v4_md5_do_add(newsk, newinet->inet_daddr,
1500 newkey, key->keylen);
1501 sk_nocaps_add(newsk, NETIF_F_GSO_MASK); 1502 sk_nocaps_add(newsk, NETIF_F_GSO_MASK);
1502 } 1503 }
1503#endif 1504#endif
@@ -1858,7 +1859,6 @@ EXPORT_SYMBOL(ipv4_specific);
1858static const struct tcp_sock_af_ops tcp_sock_ipv4_specific = { 1859static const struct tcp_sock_af_ops tcp_sock_ipv4_specific = {
1859 .md5_lookup = tcp_v4_md5_lookup, 1860 .md5_lookup = tcp_v4_md5_lookup,
1860 .calc_md5_hash = tcp_v4_md5_hash_skb, 1861 .calc_md5_hash = tcp_v4_md5_hash_skb,
1861 .md5_add = tcp_v4_md5_add_func,
1862 .md5_parse = tcp_v4_parse_md5_keys, 1862 .md5_parse = tcp_v4_parse_md5_keys,
1863}; 1863};
1864#endif 1864#endif
@@ -1947,8 +1947,8 @@ void tcp_v4_destroy_sock(struct sock *sk)
1947#ifdef CONFIG_TCP_MD5SIG 1947#ifdef CONFIG_TCP_MD5SIG
1948 /* Clean up the MD5 key list, if any */ 1948 /* Clean up the MD5 key list, if any */
1949 if (tp->md5sig_info) { 1949 if (tp->md5sig_info) {
1950 tcp_v4_clear_md5_list(sk); 1950 tcp_clear_md5_list(sk);
1951 kfree(tp->md5sig_info); 1951 kfree_rcu(tp->md5sig_info, rcu);
1952 tp->md5sig_info = NULL; 1952 tp->md5sig_info = NULL;
1953 } 1953 }
1954#endif 1954#endif
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 550e755747e0..3cabafb5cdd1 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -359,13 +359,11 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
359 */ 359 */
360 do { 360 do {
361 struct tcp_md5sig_key *key; 361 struct tcp_md5sig_key *key;
362 memset(tcptw->tw_md5_key, 0, sizeof(tcptw->tw_md5_key)); 362 tcptw->tw_md5_key = NULL;
363 tcptw->tw_md5_keylen = 0;
364 key = tp->af_specific->md5_lookup(sk, sk); 363 key = tp->af_specific->md5_lookup(sk, sk);
365 if (key != NULL) { 364 if (key != NULL) {
366 memcpy(&tcptw->tw_md5_key, key->key, key->keylen); 365 tcptw->tw_md5_key = kmemdup(key, sizeof(*key), GFP_ATOMIC);
367 tcptw->tw_md5_keylen = key->keylen; 366 if (tcptw->tw_md5_key && tcp_alloc_md5sig_pool(sk) == NULL)
368 if (tcp_alloc_md5sig_pool(sk) == NULL)
369 BUG(); 367 BUG();
370 } 368 }
371 } while (0); 369 } while (0);
@@ -405,8 +403,10 @@ void tcp_twsk_destructor(struct sock *sk)
405{ 403{
406#ifdef CONFIG_TCP_MD5SIG 404#ifdef CONFIG_TCP_MD5SIG
407 struct tcp_timewait_sock *twsk = tcp_twsk(sk); 405 struct tcp_timewait_sock *twsk = tcp_twsk(sk);
408 if (twsk->tw_md5_keylen) 406 if (twsk->tw_md5_key) {
409 tcp_free_md5sig_pool(); 407 tcp_free_md5sig_pool();
408 kfree_rcu(twsk->tw_md5_key, rcu);
409 }
410#endif 410#endif
411} 411}
412EXPORT_SYMBOL_GPL(tcp_twsk_destructor); 412EXPORT_SYMBOL_GPL(tcp_twsk_destructor);
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 4ff3b6dc74fc..364784a91939 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2306,8 +2306,10 @@ begin_fwd:
2306 if (sacked & (TCPCB_SACKED_ACKED|TCPCB_SACKED_RETRANS)) 2306 if (sacked & (TCPCB_SACKED_ACKED|TCPCB_SACKED_RETRANS))
2307 continue; 2307 continue;
2308 2308
2309 if (tcp_retransmit_skb(sk, skb)) 2309 if (tcp_retransmit_skb(sk, skb)) {
2310 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPRETRANSFAIL);
2310 return; 2311 return;
2312 }
2311 NET_INC_STATS_BH(sock_net(sk), mib_idx); 2313 NET_INC_STATS_BH(sock_net(sk), mib_idx);
2312 2314
2313 if (inet_csk(sk)->icsk_ca_state == TCP_CA_Recovery) 2315 if (inet_csk(sk)->icsk_ca_state == TCP_CA_Recovery)
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 5d075b5f70fc..cd99f1a0f59f 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -917,7 +917,8 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
917 if (!saddr) 917 if (!saddr)
918 saddr = inet->mc_addr; 918 saddr = inet->mc_addr;
919 connected = 0; 919 connected = 0;
920 } 920 } else if (!ipc.oif)
921 ipc.oif = inet->uc_index;
921 922
922 if (connected) 923 if (connected)
923 rt = (struct rtable *)sk_dst_check(sk, 0); 924 rt = (struct rtable *)sk_dst_check(sk, 0);
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
index 59402b4637f9..db00d27ffb16 100644
--- a/net/ipv6/anycast.c
+++ b/net/ipv6/anycast.c
@@ -211,35 +211,6 @@ void ipv6_sock_ac_close(struct sock *sk)
211 rcu_read_unlock(); 211 rcu_read_unlock();
212} 212}
213 213
214#if 0
215/* The function is not used, which is funny. Apparently, author
216 * supposed to use it to filter out datagrams inside udp/raw but forgot.
217 *
218 * It is OK, anycasts are not special comparing to delivery to unicasts.
219 */
220
221int inet6_ac_check(struct sock *sk, struct in6_addr *addr, int ifindex)
222{
223 struct ipv6_ac_socklist *pac;
224 struct ipv6_pinfo *np = inet6_sk(sk);
225 int found;
226
227 found = 0;
228 read_lock(&ipv6_sk_ac_lock);
229 for (pac=np->ipv6_ac_list; pac; pac=pac->acl_next) {
230 if (ifindex && pac->acl_ifindex != ifindex)
231 continue;
232 found = ipv6_addr_equal(&pac->acl_addr, addr);
233 if (found)
234 break;
235 }
236 read_unlock(&ipv6_sk_ac_lock);
237
238 return found;
239}
240
241#endif
242
243static void aca_put(struct ifacaddr6 *ac) 214static void aca_put(struct ifacaddr6 *ac)
244{ 215{
245 if (atomic_dec_and_test(&ac->aca_refcnt)) { 216 if (atomic_dec_and_test(&ac->aca_refcnt)) {
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 01d46bff63c3..af88934e4d79 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -468,6 +468,8 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
468 468
469 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) 469 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr))
470 fl6.flowi6_oif = np->mcast_oif; 470 fl6.flowi6_oif = np->mcast_oif;
471 else if (!fl6.flowi6_oif)
472 fl6.flowi6_oif = np->ucast_oif;
471 473
472 dst = icmpv6_route_lookup(net, skb, sk, &fl6); 474 dst = icmpv6_route_lookup(net, skb, sk, &fl6);
473 if (IS_ERR(dst)) 475 if (IS_ERR(dst))
@@ -553,6 +555,8 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
553 555
554 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) 556 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr))
555 fl6.flowi6_oif = np->mcast_oif; 557 fl6.flowi6_oif = np->mcast_oif;
558 else if (!fl6.flowi6_oif)
559 fl6.flowi6_oif = np->ucast_oif;
556 560
557 err = ip6_dst_lookup(sk, &dst, &fl6); 561 err = ip6_dst_lookup(sk, &dst, &fl6);
558 if (err) 562 if (err)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index b82bcde53f7a..5b27fbcae346 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1552,11 +1552,20 @@ static int fib6_age(struct rt6_info *rt, void *arg)
1552 time_after_eq(now, rt->dst.lastuse + gc_args.timeout)) { 1552 time_after_eq(now, rt->dst.lastuse + gc_args.timeout)) {
1553 RT6_TRACE("aging clone %p\n", rt); 1553 RT6_TRACE("aging clone %p\n", rt);
1554 return -1; 1554 return -1;
1555 } else if ((rt->rt6i_flags & RTF_GATEWAY) && 1555 } else if (rt->rt6i_flags & RTF_GATEWAY) {
1556 (!(dst_get_neighbour_noref_raw(&rt->dst)->flags & NTF_ROUTER))) { 1556 struct neighbour *neigh;
1557 RT6_TRACE("purging route %p via non-router but gateway\n", 1557 __u8 neigh_flags = 0;
1558 rt); 1558
1559 return -1; 1559 neigh = dst_neigh_lookup(&rt->dst, &rt->rt6i_gateway);
1560 if (neigh) {
1561 neigh_flags = neigh->flags;
1562 neigh_release(neigh);
1563 }
1564 if (neigh_flags & NTF_ROUTER) {
1565 RT6_TRACE("purging route %p via non-router but gateway\n",
1566 rt);
1567 return -1;
1568 }
1560 } 1569 }
1561 gc_args.more++; 1570 gc_args.more++;
1562 } 1571 }
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index d97e07183ce9..7a98fc2a5d97 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -388,7 +388,6 @@ int ip6_forward(struct sk_buff *skb)
388 struct ipv6hdr *hdr = ipv6_hdr(skb); 388 struct ipv6hdr *hdr = ipv6_hdr(skb);
389 struct inet6_skb_parm *opt = IP6CB(skb); 389 struct inet6_skb_parm *opt = IP6CB(skb);
390 struct net *net = dev_net(dst->dev); 390 struct net *net = dev_net(dst->dev);
391 struct neighbour *n;
392 u32 mtu; 391 u32 mtu;
393 392
394 if (net->ipv6.devconf_all->forwarding == 0) 393 if (net->ipv6.devconf_all->forwarding == 0)
@@ -463,8 +462,7 @@ int ip6_forward(struct sk_buff *skb)
463 send redirects to source routed frames. 462 send redirects to source routed frames.
464 We don't send redirects to frames decapsulated from IPsec. 463 We don't send redirects to frames decapsulated from IPsec.
465 */ 464 */
466 n = dst_get_neighbour_noref(dst); 465 if (skb->dev == dst->dev && opt->srcrt == 0 && !skb_sec_path(skb)) {
467 if (skb->dev == dst->dev && n && opt->srcrt == 0 && !skb_sec_path(skb)) {
468 struct in6_addr *target = NULL; 466 struct in6_addr *target = NULL;
469 struct rt6_info *rt; 467 struct rt6_info *rt;
470 468
@@ -474,8 +472,8 @@ int ip6_forward(struct sk_buff *skb)
474 */ 472 */
475 473
476 rt = (struct rt6_info *) dst; 474 rt = (struct rt6_info *) dst;
477 if ((rt->rt6i_flags & RTF_GATEWAY)) 475 if (rt->rt6i_flags & RTF_GATEWAY)
478 target = (struct in6_addr*)&n->primary_key; 476 target = &rt->rt6i_gateway;
479 else 477 else
480 target = &hdr->daddr; 478 target = &hdr->daddr;
481 479
@@ -486,7 +484,7 @@ int ip6_forward(struct sk_buff *skb)
486 and by source (inside ndisc_send_redirect) 484 and by source (inside ndisc_send_redirect)
487 */ 485 */
488 if (inet_peer_xrlim_allow(rt->rt6i_peer, 1*HZ)) 486 if (inet_peer_xrlim_allow(rt->rt6i_peer, 1*HZ))
489 ndisc_send_redirect(skb, n, target); 487 ndisc_send_redirect(skb, target);
490 } else { 488 } else {
491 int addrtype = ipv6_addr_type(&hdr->saddr); 489 int addrtype = ipv6_addr_type(&hdr->saddr);
492 490
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 18a2719003c3..6d6b65fdaa1a 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -516,6 +516,36 @@ done:
516 retv = 0; 516 retv = 0;
517 break; 517 break;
518 518
519 case IPV6_UNICAST_IF:
520 {
521 struct net_device *dev = NULL;
522 int ifindex;
523
524 if (optlen != sizeof(int))
525 goto e_inval;
526
527 ifindex = (__force int)ntohl((__force __be32)val);
528 if (ifindex == 0) {
529 np->ucast_oif = 0;
530 retv = 0;
531 break;
532 }
533
534 dev = dev_get_by_index(net, ifindex);
535 retv = -EADDRNOTAVAIL;
536 if (!dev)
537 break;
538 dev_put(dev);
539
540 retv = -EINVAL;
541 if (sk->sk_bound_dev_if)
542 break;
543
544 np->ucast_oif = ifindex;
545 retv = 0;
546 break;
547 }
548
519 case IPV6_MULTICAST_IF: 549 case IPV6_MULTICAST_IF:
520 if (sk->sk_type == SOCK_STREAM) 550 if (sk->sk_type == SOCK_STREAM)
521 break; 551 break;
@@ -1160,6 +1190,10 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
1160 val = np->mcast_oif; 1190 val = np->mcast_oif;
1161 break; 1191 break;
1162 1192
1193 case IPV6_UNICAST_IF:
1194 val = (__force int)htonl((__u32) np->ucast_oif);
1195 break;
1196
1163 case IPV6_MTU_DISCOVER: 1197 case IPV6_MTU_DISCOVER:
1164 val = np->pmtudisc; 1198 val = np->pmtudisc;
1165 break; 1199 break;
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d8f02ef88e59..8d817018c188 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1223,11 +1223,17 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1223 1223
1224 rt = rt6_get_dflt_router(&ipv6_hdr(skb)->saddr, skb->dev); 1224 rt = rt6_get_dflt_router(&ipv6_hdr(skb)->saddr, skb->dev);
1225 1225
1226 if (rt) 1226 if (rt) {
1227 neigh = dst_get_neighbour_noref(&rt->dst); 1227 neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr);
1228 1228 if (!neigh) {
1229 ND_PRINTK0(KERN_ERR
1230 "ICMPv6 RA: %s() got default router without neighbour.\n",
1231 __func__);
1232 dst_release(&rt->dst);
1233 return;
1234 }
1235 }
1229 if (rt && lifetime == 0) { 1236 if (rt && lifetime == 0) {
1230 neigh_clone(neigh);
1231 ip6_del_rt(rt); 1237 ip6_del_rt(rt);
1232 rt = NULL; 1238 rt = NULL;
1233 } 1239 }
@@ -1244,7 +1250,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1244 return; 1250 return;
1245 } 1251 }
1246 1252
1247 neigh = dst_get_neighbour_noref(&rt->dst); 1253 neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr);
1248 if (neigh == NULL) { 1254 if (neigh == NULL) {
1249 ND_PRINTK0(KERN_ERR 1255 ND_PRINTK0(KERN_ERR
1250 "ICMPv6 RA: %s() got default router without neighbour.\n", 1256 "ICMPv6 RA: %s() got default router without neighbour.\n",
@@ -1411,7 +1417,7 @@ skip_routeinfo:
1411out: 1417out:
1412 if (rt) 1418 if (rt)
1413 dst_release(&rt->dst); 1419 dst_release(&rt->dst);
1414 else if (neigh) 1420 if (neigh)
1415 neigh_release(neigh); 1421 neigh_release(neigh);
1416} 1422}
1417 1423
@@ -1506,8 +1512,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
1506 } 1512 }
1507} 1513}
1508 1514
1509void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh, 1515void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
1510 const struct in6_addr *target)
1511{ 1516{
1512 struct net_device *dev = skb->dev; 1517 struct net_device *dev = skb->dev;
1513 struct net *net = dev_net(dev); 1518 struct net *net = dev_net(dev);
@@ -1565,6 +1570,13 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1565 goto release; 1570 goto release;
1566 1571
1567 if (dev->addr_len) { 1572 if (dev->addr_len) {
1573 struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target);
1574 if (!neigh) {
1575 ND_PRINTK2(KERN_WARNING
1576 "ICMPv6 Redirect: no neigh for target address\n");
1577 goto release;
1578 }
1579
1568 read_lock_bh(&neigh->lock); 1580 read_lock_bh(&neigh->lock);
1569 if (neigh->nud_state & NUD_VALID) { 1581 if (neigh->nud_state & NUD_VALID) {
1570 memcpy(ha_buf, neigh->ha, dev->addr_len); 1582 memcpy(ha_buf, neigh->ha, dev->addr_len);
@@ -1573,6 +1585,8 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1573 len += ndisc_opt_addr_space(dev); 1585 len += ndisc_opt_addr_space(dev);
1574 } else 1586 } else
1575 read_unlock_bh(&neigh->lock); 1587 read_unlock_bh(&neigh->lock);
1588
1589 neigh_release(neigh);
1576 } 1590 }
1577 1591
1578 rd_len = min_t(unsigned int, 1592 rd_len = min_t(unsigned int,
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index d02f7e4dd611..5bddea778840 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -856,6 +856,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
856 856
857 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) 857 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr))
858 fl6.flowi6_oif = np->mcast_oif; 858 fl6.flowi6_oif = np->mcast_oif;
859 else if (!fl6.flowi6_oif)
860 fl6.flowi6_oif = np->ucast_oif;
859 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); 861 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
860 862
861 dst = ip6_dst_lookup_flow(sk, &fl6, final_p, true); 863 dst = ip6_dst_lookup_flow(sk, &fl6, final_p, true);
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index b69fae76a6f1..9447bd69873a 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -336,12 +336,11 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
336 } 336 }
337 337
338found: 338found:
339 /* RFC5722, Section 4: 339 /* RFC5722, Section 4, amended by Errata ID : 3089
340 * When reassembling an IPv6 datagram, if 340 * When reassembling an IPv6 datagram, if
341 * one or more its constituent fragments is determined to be an 341 * one or more its constituent fragments is determined to be an
342 * overlapping fragment, the entire datagram (and any constituent 342 * overlapping fragment, the entire datagram (and any constituent
343 * fragments, including those not yet received) MUST be silently 343 * fragments) MUST be silently discarded.
344 * discarded.
345 */ 344 */
346 345
347 /* Check for overlap with preceding fragment. */ 346 /* Check for overlap with preceding fragment. */
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 8c2e3ab58f2a..92be12bb8d23 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -121,9 +121,22 @@ static u32 *ipv6_cow_metrics(struct dst_entry *dst, unsigned long old)
121 return p; 121 return p;
122} 122}
123 123
124static inline const void *choose_neigh_daddr(struct rt6_info *rt, const void *daddr)
125{
126 struct in6_addr *p = &rt->rt6i_gateway;
127
128 if (!ipv6_addr_any(p))
129 return (const void *) p;
130 return daddr;
131}
132
124static struct neighbour *ip6_neigh_lookup(const struct dst_entry *dst, const void *daddr) 133static struct neighbour *ip6_neigh_lookup(const struct dst_entry *dst, const void *daddr)
125{ 134{
126 struct neighbour *n = __ipv6_neigh_lookup(&nd_tbl, dst->dev, daddr); 135 struct rt6_info *rt = (struct rt6_info *) dst;
136 struct neighbour *n;
137
138 daddr = choose_neigh_daddr(rt, daddr);
139 n = __ipv6_neigh_lookup(&nd_tbl, dst->dev, daddr);
127 if (n) 140 if (n)
128 return n; 141 return n;
129 return neigh_create(&nd_tbl, daddr, dst->dev); 142 return neigh_create(&nd_tbl, daddr, dst->dev);
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 133768e52912..c4ffd1743528 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -680,9 +680,10 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
680 /* ISATAP (RFC4214) - must come before 6to4 */ 680 /* ISATAP (RFC4214) - must come before 6to4 */
681 if (dev->priv_flags & IFF_ISATAP) { 681 if (dev->priv_flags & IFF_ISATAP) {
682 struct neighbour *neigh = NULL; 682 struct neighbour *neigh = NULL;
683 bool do_tx_error = false;
683 684
684 if (skb_dst(skb)) 685 if (skb_dst(skb))
685 neigh = dst_get_neighbour_noref(skb_dst(skb)); 686 neigh = dst_neigh_lookup(skb_dst(skb), &iph6->daddr);
686 687
687 if (neigh == NULL) { 688 if (neigh == NULL) {
688 if (net_ratelimit()) 689 if (net_ratelimit())
@@ -697,6 +698,10 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
697 ipv6_addr_is_isatap(addr6)) 698 ipv6_addr_is_isatap(addr6))
698 dst = addr6->s6_addr32[3]; 699 dst = addr6->s6_addr32[3];
699 else 700 else
701 do_tx_error = true;
702
703 neigh_release(neigh);
704 if (do_tx_error)
700 goto tx_error; 705 goto tx_error;
701 } 706 }
702 707
@@ -705,9 +710,10 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
705 710
706 if (!dst) { 711 if (!dst) {
707 struct neighbour *neigh = NULL; 712 struct neighbour *neigh = NULL;
713 bool do_tx_error = false;
708 714
709 if (skb_dst(skb)) 715 if (skb_dst(skb))
710 neigh = dst_get_neighbour_noref(skb_dst(skb)); 716 neigh = dst_neigh_lookup(skb_dst(skb), &iph6->daddr);
711 717
712 if (neigh == NULL) { 718 if (neigh == NULL) {
713 if (net_ratelimit()) 719 if (net_ratelimit())
@@ -723,10 +729,14 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
723 addr_type = ipv6_addr_type(addr6); 729 addr_type = ipv6_addr_type(addr6);
724 } 730 }
725 731
726 if ((addr_type & IPV6_ADDR_COMPATv4) == 0) 732 if ((addr_type & IPV6_ADDR_COMPATv4) != 0)
727 goto tx_error_icmp; 733 dst = addr6->s6_addr32[3];
734 else
735 do_tx_error = true;
728 736
729 dst = addr6->s6_addr32[3]; 737 neigh_release(neigh);
738 if (do_tx_error)
739 goto tx_error;
730 } 740 }
731 741
732 rt = ip_route_output_ports(dev_net(dev), &fl4, NULL, 742 rt = ip_route_output_ports(dev_net(dev), &fl4, NULL,
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 3edd05ae4388..d16414cb3421 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -540,19 +540,7 @@ static void tcp_v6_reqsk_destructor(struct request_sock *req)
540static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(struct sock *sk, 540static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(struct sock *sk,
541 const struct in6_addr *addr) 541 const struct in6_addr *addr)
542{ 542{
543 struct tcp_sock *tp = tcp_sk(sk); 543 return tcp_md5_do_lookup(sk, (union tcp_md5_addr *)addr, AF_INET6);
544 int i;
545
546 BUG_ON(tp == NULL);
547
548 if (!tp->md5sig_info || !tp->md5sig_info->entries6)
549 return NULL;
550
551 for (i = 0; i < tp->md5sig_info->entries6; i++) {
552 if (ipv6_addr_equal(&tp->md5sig_info->keys6[i].addr, addr))
553 return &tp->md5sig_info->keys6[i].base;
554 }
555 return NULL;
556} 544}
557 545
558static struct tcp_md5sig_key *tcp_v6_md5_lookup(struct sock *sk, 546static struct tcp_md5sig_key *tcp_v6_md5_lookup(struct sock *sk,
@@ -567,136 +555,11 @@ static struct tcp_md5sig_key *tcp_v6_reqsk_md5_lookup(struct sock *sk,
567 return tcp_v6_md5_do_lookup(sk, &inet6_rsk(req)->rmt_addr); 555 return tcp_v6_md5_do_lookup(sk, &inet6_rsk(req)->rmt_addr);
568} 556}
569 557
570static int tcp_v6_md5_do_add(struct sock *sk, const struct in6_addr *peer,
571 char *newkey, u8 newkeylen)
572{
573 /* Add key to the list */
574 struct tcp_md5sig_key *key;
575 struct tcp_sock *tp = tcp_sk(sk);
576 struct tcp6_md5sig_key *keys;
577
578 key = tcp_v6_md5_do_lookup(sk, peer);
579 if (key) {
580 /* modify existing entry - just update that one */
581 kfree(key->key);
582 key->key = newkey;
583 key->keylen = newkeylen;
584 } else {
585 /* reallocate new list if current one is full. */
586 if (!tp->md5sig_info) {
587 tp->md5sig_info = kzalloc(sizeof(*tp->md5sig_info), GFP_ATOMIC);
588 if (!tp->md5sig_info) {
589 kfree(newkey);
590 return -ENOMEM;
591 }
592 sk_nocaps_add(sk, NETIF_F_GSO_MASK);
593 }
594 if (tp->md5sig_info->entries6 == 0 &&
595 tcp_alloc_md5sig_pool(sk) == NULL) {
596 kfree(newkey);
597 return -ENOMEM;
598 }
599 if (tp->md5sig_info->alloced6 == tp->md5sig_info->entries6) {
600 keys = kmalloc((sizeof (tp->md5sig_info->keys6[0]) *
601 (tp->md5sig_info->entries6 + 1)), GFP_ATOMIC);
602
603 if (!keys) {
604 kfree(newkey);
605 if (tp->md5sig_info->entries6 == 0)
606 tcp_free_md5sig_pool();
607 return -ENOMEM;
608 }
609
610 if (tp->md5sig_info->entries6)
611 memmove(keys, tp->md5sig_info->keys6,
612 (sizeof (tp->md5sig_info->keys6[0]) *
613 tp->md5sig_info->entries6));
614
615 kfree(tp->md5sig_info->keys6);
616 tp->md5sig_info->keys6 = keys;
617 tp->md5sig_info->alloced6++;
618 }
619
620 tp->md5sig_info->keys6[tp->md5sig_info->entries6].addr = *peer;
621 tp->md5sig_info->keys6[tp->md5sig_info->entries6].base.key = newkey;
622 tp->md5sig_info->keys6[tp->md5sig_info->entries6].base.keylen = newkeylen;
623
624 tp->md5sig_info->entries6++;
625 }
626 return 0;
627}
628
629static int tcp_v6_md5_add_func(struct sock *sk, struct sock *addr_sk,
630 u8 *newkey, __u8 newkeylen)
631{
632 return tcp_v6_md5_do_add(sk, &inet6_sk(addr_sk)->daddr,
633 newkey, newkeylen);
634}
635
636static int tcp_v6_md5_do_del(struct sock *sk, const struct in6_addr *peer)
637{
638 struct tcp_sock *tp = tcp_sk(sk);
639 int i;
640
641 for (i = 0; i < tp->md5sig_info->entries6; i++) {
642 if (ipv6_addr_equal(&tp->md5sig_info->keys6[i].addr, peer)) {
643 /* Free the key */
644 kfree(tp->md5sig_info->keys6[i].base.key);
645 tp->md5sig_info->entries6--;
646
647 if (tp->md5sig_info->entries6 == 0) {
648 kfree(tp->md5sig_info->keys6);
649 tp->md5sig_info->keys6 = NULL;
650 tp->md5sig_info->alloced6 = 0;
651 tcp_free_md5sig_pool();
652 } else {
653 /* shrink the database */
654 if (tp->md5sig_info->entries6 != i)
655 memmove(&tp->md5sig_info->keys6[i],
656 &tp->md5sig_info->keys6[i+1],
657 (tp->md5sig_info->entries6 - i)
658 * sizeof (tp->md5sig_info->keys6[0]));
659 }
660 return 0;
661 }
662 }
663 return -ENOENT;
664}
665
666static void tcp_v6_clear_md5_list (struct sock *sk)
667{
668 struct tcp_sock *tp = tcp_sk(sk);
669 int i;
670
671 if (tp->md5sig_info->entries6) {
672 for (i = 0; i < tp->md5sig_info->entries6; i++)
673 kfree(tp->md5sig_info->keys6[i].base.key);
674 tp->md5sig_info->entries6 = 0;
675 tcp_free_md5sig_pool();
676 }
677
678 kfree(tp->md5sig_info->keys6);
679 tp->md5sig_info->keys6 = NULL;
680 tp->md5sig_info->alloced6 = 0;
681
682 if (tp->md5sig_info->entries4) {
683 for (i = 0; i < tp->md5sig_info->entries4; i++)
684 kfree(tp->md5sig_info->keys4[i].base.key);
685 tp->md5sig_info->entries4 = 0;
686 tcp_free_md5sig_pool();
687 }
688
689 kfree(tp->md5sig_info->keys4);
690 tp->md5sig_info->keys4 = NULL;
691 tp->md5sig_info->alloced4 = 0;
692}
693
694static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval, 558static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval,
695 int optlen) 559 int optlen)
696{ 560{
697 struct tcp_md5sig cmd; 561 struct tcp_md5sig cmd;
698 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&cmd.tcpm_addr; 562 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&cmd.tcpm_addr;
699 u8 *newkey;
700 563
701 if (optlen < sizeof(cmd)) 564 if (optlen < sizeof(cmd))
702 return -EINVAL; 565 return -EINVAL;
@@ -708,36 +571,22 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval,
708 return -EINVAL; 571 return -EINVAL;
709 572
710 if (!cmd.tcpm_keylen) { 573 if (!cmd.tcpm_keylen) {
711 if (!tcp_sk(sk)->md5sig_info)
712 return -ENOENT;
713 if (ipv6_addr_v4mapped(&sin6->sin6_addr)) 574 if (ipv6_addr_v4mapped(&sin6->sin6_addr))
714 return tcp_v4_md5_do_del(sk, sin6->sin6_addr.s6_addr32[3]); 575 return tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin6->sin6_addr.s6_addr32[3],
715 return tcp_v6_md5_do_del(sk, &sin6->sin6_addr); 576 AF_INET);
577 return tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin6->sin6_addr,
578 AF_INET6);
716 } 579 }
717 580
718 if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN) 581 if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN)
719 return -EINVAL; 582 return -EINVAL;
720 583
721 if (!tcp_sk(sk)->md5sig_info) { 584 if (ipv6_addr_v4mapped(&sin6->sin6_addr))
722 struct tcp_sock *tp = tcp_sk(sk); 585 return tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin6->sin6_addr.s6_addr32[3],
723 struct tcp_md5sig_info *p; 586 AF_INET, cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);
724
725 p = kzalloc(sizeof(struct tcp_md5sig_info), GFP_KERNEL);
726 if (!p)
727 return -ENOMEM;
728 587
729 tp->md5sig_info = p; 588 return tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin6->sin6_addr,
730 sk_nocaps_add(sk, NETIF_F_GSO_MASK); 589 AF_INET6, cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);
731 }
732
733 newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);
734 if (!newkey)
735 return -ENOMEM;
736 if (ipv6_addr_v4mapped(&sin6->sin6_addr)) {
737 return tcp_v4_md5_do_add(sk, sin6->sin6_addr.s6_addr32[3],
738 newkey, cmd.tcpm_keylen);
739 }
740 return tcp_v6_md5_do_add(sk, &sin6->sin6_addr, newkey, cmd.tcpm_keylen);
741} 590}
742 591
743static int tcp_v6_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp, 592static int tcp_v6_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp,
@@ -1074,6 +923,13 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
1074 const struct tcphdr *th = tcp_hdr(skb); 923 const struct tcphdr *th = tcp_hdr(skb);
1075 u32 seq = 0, ack_seq = 0; 924 u32 seq = 0, ack_seq = 0;
1076 struct tcp_md5sig_key *key = NULL; 925 struct tcp_md5sig_key *key = NULL;
926#ifdef CONFIG_TCP_MD5SIG
927 const __u8 *hash_location = NULL;
928 struct ipv6hdr *ipv6h = ipv6_hdr(skb);
929 unsigned char newhash[16];
930 int genhash;
931 struct sock *sk1 = NULL;
932#endif
1077 933
1078 if (th->rst) 934 if (th->rst)
1079 return; 935 return;
@@ -1082,8 +938,32 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
1082 return; 938 return;
1083 939
1084#ifdef CONFIG_TCP_MD5SIG 940#ifdef CONFIG_TCP_MD5SIG
1085 if (sk) 941 hash_location = tcp_parse_md5sig_option(th);
1086 key = tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->saddr); 942 if (!sk && hash_location) {
943 /*
944 * active side is lost. Try to find listening socket through
945 * source port, and then find md5 key through listening socket.
946 * we are not loose security here:
947 * Incoming packet is checked with md5 hash with finding key,
948 * no RST generated if md5 hash doesn't match.
949 */
950 sk1 = inet6_lookup_listener(dev_net(skb_dst(skb)->dev),
951 &tcp_hashinfo, &ipv6h->daddr,
952 ntohs(th->source), inet6_iif(skb));
953 if (!sk1)
954 return;
955
956 rcu_read_lock();
957 key = tcp_v6_md5_do_lookup(sk1, &ipv6h->saddr);
958 if (!key)
959 goto release_sk1;
960
961 genhash = tcp_v6_md5_hash_skb(newhash, key, NULL, NULL, skb);
962 if (genhash || memcmp(hash_location, newhash, 16) != 0)
963 goto release_sk1;
964 } else {
965 key = sk ? tcp_v6_md5_do_lookup(sk, &ipv6h->saddr) : NULL;
966 }
1087#endif 967#endif
1088 968
1089 if (th->ack) 969 if (th->ack)
@@ -1093,6 +973,14 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
1093 (th->doff << 2); 973 (th->doff << 2);
1094 974
1095 tcp_v6_send_response(skb, seq, ack_seq, 0, 0, key, 1, 0); 975 tcp_v6_send_response(skb, seq, ack_seq, 0, 0, key, 1, 0);
976
977#ifdef CONFIG_TCP_MD5SIG
978release_sk1:
979 if (sk1) {
980 rcu_read_unlock();
981 sock_put(sk1);
982 }
983#endif
1096} 984}
1097 985
1098static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 ts, 986static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 ts,
@@ -1510,10 +1398,8 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1510 * memory, then we end up not copying the key 1398 * memory, then we end up not copying the key
1511 * across. Shucks. 1399 * across. Shucks.
1512 */ 1400 */
1513 char *newkey = kmemdup(key->key, key->keylen, GFP_ATOMIC); 1401 tcp_md5_do_add(newsk, (union tcp_md5_addr *)&newnp->daddr,
1514 if (newkey != NULL) 1402 AF_INET6, key->key, key->keylen, GFP_ATOMIC);
1515 tcp_v6_md5_do_add(newsk, &newnp->daddr,
1516 newkey, key->keylen);
1517 } 1403 }
1518#endif 1404#endif
1519 1405
@@ -1898,7 +1784,6 @@ static const struct inet_connection_sock_af_ops ipv6_specific = {
1898static const struct tcp_sock_af_ops tcp_sock_ipv6_specific = { 1784static const struct tcp_sock_af_ops tcp_sock_ipv6_specific = {
1899 .md5_lookup = tcp_v6_md5_lookup, 1785 .md5_lookup = tcp_v6_md5_lookup,
1900 .calc_md5_hash = tcp_v6_md5_hash_skb, 1786 .calc_md5_hash = tcp_v6_md5_hash_skb,
1901 .md5_add = tcp_v6_md5_add_func,
1902 .md5_parse = tcp_v6_parse_md5_keys, 1787 .md5_parse = tcp_v6_parse_md5_keys,
1903}; 1788};
1904#endif 1789#endif
@@ -1930,7 +1815,6 @@ static const struct inet_connection_sock_af_ops ipv6_mapped = {
1930static const struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific = { 1815static const struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific = {
1931 .md5_lookup = tcp_v4_md5_lookup, 1816 .md5_lookup = tcp_v4_md5_lookup,
1932 .calc_md5_hash = tcp_v4_md5_hash_skb, 1817 .calc_md5_hash = tcp_v4_md5_hash_skb,
1933 .md5_add = tcp_v6_md5_add_func,
1934 .md5_parse = tcp_v6_parse_md5_keys, 1818 .md5_parse = tcp_v6_parse_md5_keys,
1935}; 1819};
1936#endif 1820#endif
@@ -2004,11 +1888,6 @@ static int tcp_v6_init_sock(struct sock *sk)
2004 1888
2005static void tcp_v6_destroy_sock(struct sock *sk) 1889static void tcp_v6_destroy_sock(struct sock *sk)
2006{ 1890{
2007#ifdef CONFIG_TCP_MD5SIG
2008 /* Clean up the MD5 key list */
2009 if (tcp_sk(sk)->md5sig_info)
2010 tcp_v6_clear_md5_list(sk);
2011#endif
2012 tcp_v4_destroy_sock(sk); 1891 tcp_v4_destroy_sock(sk);
2013 inet6_destroy_sock(sk); 1892 inet6_destroy_sock(sk);
2014} 1893}
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 4f96b5c63685..8aebf8f90436 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1130,7 +1130,8 @@ do_udp_sendmsg:
1130 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) { 1130 if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr)) {
1131 fl6.flowi6_oif = np->mcast_oif; 1131 fl6.flowi6_oif = np->mcast_oif;
1132 connected = 0; 1132 connected = 0;
1133 } 1133 } else if (!fl6.flowi6_oif)
1134 fl6.flowi6_oif = np->ucast_oif;
1134 1135
1135 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); 1136 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
1136 1137
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
index 4eeff89c1aaa..8755a3079d0f 100644
--- a/net/ipv6/xfrm6_output.c
+++ b/net/ipv6/xfrm6_output.c
@@ -146,7 +146,7 @@ static int __xfrm6_output(struct sk_buff *skb)
146 return -EMSGSIZE; 146 return -EMSGSIZE;
147 } 147 }
148 148
149 if ((x && x->props.mode == XFRM_MODE_TUNNEL) && 149 if (x->props.mode == XFRM_MODE_TUNNEL &&
150 ((skb->len > mtu && !skb_is_gso(skb)) || 150 ((skb->len > mtu && !skb_is_gso(skb)) ||
151 dst_allfrag(skb_dst(skb)))) { 151 dst_allfrag(skb_dst(skb)))) {
152 return ip6_fragment(skb, x->outer_mode->afinfo->output_finish); 152 return ip6_fragment(skb, x->outer_mode->afinfo->output_finish);
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index d5c5b8fd1d01..98d1f0ba7fe9 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -90,6 +90,7 @@ do { \
90 90
91static void iucv_sock_kill(struct sock *sk); 91static void iucv_sock_kill(struct sock *sk);
92static void iucv_sock_close(struct sock *sk); 92static void iucv_sock_close(struct sock *sk);
93static void iucv_sever_path(struct sock *, int);
93 94
94static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev, 95static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev,
95 struct packet_type *pt, struct net_device *orig_dev); 96 struct packet_type *pt, struct net_device *orig_dev);
@@ -130,17 +131,6 @@ static inline void low_nmcpy(unsigned char *dst, char *src)
130 memcpy(&dst[8], src, 8); 131 memcpy(&dst[8], src, 8);
131} 132}
132 133
133static void iucv_skb_queue_purge(struct sk_buff_head *list)
134{
135 struct sk_buff *skb;
136
137 while ((skb = skb_dequeue(list)) != NULL) {
138 if (skb->dev)
139 dev_put(skb->dev);
140 kfree_skb(skb);
141 }
142}
143
144static int afiucv_pm_prepare(struct device *dev) 134static int afiucv_pm_prepare(struct device *dev)
145{ 135{
146#ifdef CONFIG_PM_DEBUG 136#ifdef CONFIG_PM_DEBUG
@@ -175,17 +165,13 @@ static int afiucv_pm_freeze(struct device *dev)
175 read_lock(&iucv_sk_list.lock); 165 read_lock(&iucv_sk_list.lock);
176 sk_for_each(sk, node, &iucv_sk_list.head) { 166 sk_for_each(sk, node, &iucv_sk_list.head) {
177 iucv = iucv_sk(sk); 167 iucv = iucv_sk(sk);
178 iucv_skb_queue_purge(&iucv->send_skb_q); 168 skb_queue_purge(&iucv->send_skb_q);
179 skb_queue_purge(&iucv->backlog_skb_q); 169 skb_queue_purge(&iucv->backlog_skb_q);
180 switch (sk->sk_state) { 170 switch (sk->sk_state) {
181 case IUCV_DISCONN: 171 case IUCV_DISCONN:
182 case IUCV_CLOSING: 172 case IUCV_CLOSING:
183 case IUCV_CONNECTED: 173 case IUCV_CONNECTED:
184 if (iucv->path) { 174 iucv_sever_path(sk, 0);
185 err = pr_iucv->path_sever(iucv->path, NULL);
186 iucv_path_free(iucv->path);
187 iucv->path = NULL;
188 }
189 break; 175 break;
190 case IUCV_OPEN: 176 case IUCV_OPEN:
191 case IUCV_BOUND: 177 case IUCV_BOUND:
@@ -194,6 +180,8 @@ static int afiucv_pm_freeze(struct device *dev)
194 default: 180 default:
195 break; 181 break;
196 } 182 }
183 skb_queue_purge(&iucv->send_skb_q);
184 skb_queue_purge(&iucv->backlog_skb_q);
197 } 185 }
198 read_unlock(&iucv_sk_list.lock); 186 read_unlock(&iucv_sk_list.lock);
199 return err; 187 return err;
@@ -338,7 +326,6 @@ static void iucv_sock_wake_msglim(struct sock *sk)
338static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock, 326static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock,
339 struct sk_buff *skb, u8 flags) 327 struct sk_buff *skb, u8 flags)
340{ 328{
341 struct net *net = sock_net(sock);
342 struct iucv_sock *iucv = iucv_sk(sock); 329 struct iucv_sock *iucv = iucv_sk(sock);
343 struct af_iucv_trans_hdr *phs_hdr; 330 struct af_iucv_trans_hdr *phs_hdr;
344 struct sk_buff *nskb; 331 struct sk_buff *nskb;
@@ -375,10 +362,10 @@ static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock,
375 if (imsg) 362 if (imsg)
376 memcpy(&phs_hdr->iucv_hdr, imsg, sizeof(struct iucv_message)); 363 memcpy(&phs_hdr->iucv_hdr, imsg, sizeof(struct iucv_message));
377 364
378 skb->dev = dev_get_by_index(net, sock->sk_bound_dev_if); 365 skb->dev = iucv->hs_dev;
379 if (!skb->dev) 366 if (!skb->dev)
380 return -ENODEV; 367 return -ENODEV;
381 if (!(skb->dev->flags & IFF_UP)) 368 if (!(skb->dev->flags & IFF_UP) || !netif_carrier_ok(skb->dev))
382 return -ENETDOWN; 369 return -ENETDOWN;
383 if (skb->len > skb->dev->mtu) { 370 if (skb->len > skb->dev->mtu) {
384 if (sock->sk_type == SOCK_SEQPACKET) 371 if (sock->sk_type == SOCK_SEQPACKET)
@@ -393,15 +380,14 @@ static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock,
393 return -ENOMEM; 380 return -ENOMEM;
394 skb_queue_tail(&iucv->send_skb_q, nskb); 381 skb_queue_tail(&iucv->send_skb_q, nskb);
395 err = dev_queue_xmit(skb); 382 err = dev_queue_xmit(skb);
396 if (err) { 383 if (net_xmit_eval(err)) {
397 skb_unlink(nskb, &iucv->send_skb_q); 384 skb_unlink(nskb, &iucv->send_skb_q);
398 dev_put(nskb->dev);
399 kfree_skb(nskb); 385 kfree_skb(nskb);
400 } else { 386 } else {
401 atomic_sub(confirm_recv, &iucv->msg_recv); 387 atomic_sub(confirm_recv, &iucv->msg_recv);
402 WARN_ON(atomic_read(&iucv->msg_recv) < 0); 388 WARN_ON(atomic_read(&iucv->msg_recv) < 0);
403 } 389 }
404 return err; 390 return net_xmit_eval(err);
405} 391}
406 392
407static struct sock *__iucv_get_sock_by_name(char *nm) 393static struct sock *__iucv_get_sock_by_name(char *nm)
@@ -447,13 +433,33 @@ static void iucv_sock_kill(struct sock *sk)
447 sock_put(sk); 433 sock_put(sk);
448} 434}
449 435
436/* Terminate an IUCV path */
437static void iucv_sever_path(struct sock *sk, int with_user_data)
438{
439 unsigned char user_data[16];
440 struct iucv_sock *iucv = iucv_sk(sk);
441 struct iucv_path *path = iucv->path;
442
443 if (iucv->path) {
444 iucv->path = NULL;
445 if (with_user_data) {
446 low_nmcpy(user_data, iucv->src_name);
447 high_nmcpy(user_data, iucv->dst_name);
448 ASCEBC(user_data, sizeof(user_data));
449 pr_iucv->path_sever(path, user_data);
450 } else
451 pr_iucv->path_sever(path, NULL);
452 iucv_path_free(path);
453 }
454}
455
450/* Close an IUCV socket */ 456/* Close an IUCV socket */
451static void iucv_sock_close(struct sock *sk) 457static void iucv_sock_close(struct sock *sk)
452{ 458{
453 unsigned char user_data[16];
454 struct iucv_sock *iucv = iucv_sk(sk); 459 struct iucv_sock *iucv = iucv_sk(sk);
455 unsigned long timeo; 460 unsigned long timeo;
456 int err, blen; 461 int err = 0;
462 int blen;
457 struct sk_buff *skb; 463 struct sk_buff *skb;
458 464
459 lock_sock(sk); 465 lock_sock(sk);
@@ -480,7 +486,7 @@ static void iucv_sock_close(struct sock *sk)
480 sk->sk_state = IUCV_CLOSING; 486 sk->sk_state = IUCV_CLOSING;
481 sk->sk_state_change(sk); 487 sk->sk_state_change(sk);
482 488
483 if (!skb_queue_empty(&iucv->send_skb_q)) { 489 if (!err && !skb_queue_empty(&iucv->send_skb_q)) {
484 if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) 490 if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime)
485 timeo = sk->sk_lingertime; 491 timeo = sk->sk_lingertime;
486 else 492 else
@@ -494,25 +500,20 @@ static void iucv_sock_close(struct sock *sk)
494 sk->sk_state = IUCV_CLOSED; 500 sk->sk_state = IUCV_CLOSED;
495 sk->sk_state_change(sk); 501 sk->sk_state_change(sk);
496 502
497 if (iucv->path) {
498 low_nmcpy(user_data, iucv->src_name);
499 high_nmcpy(user_data, iucv->dst_name);
500 ASCEBC(user_data, sizeof(user_data));
501 pr_iucv->path_sever(iucv->path, user_data);
502 iucv_path_free(iucv->path);
503 iucv->path = NULL;
504 }
505
506 sk->sk_err = ECONNRESET; 503 sk->sk_err = ECONNRESET;
507 sk->sk_state_change(sk); 504 sk->sk_state_change(sk);
508 505
509 iucv_skb_queue_purge(&iucv->send_skb_q); 506 skb_queue_purge(&iucv->send_skb_q);
510 skb_queue_purge(&iucv->backlog_skb_q); 507 skb_queue_purge(&iucv->backlog_skb_q);
511 break;
512 508
513 default: 509 default: /* fall through */
514 /* nothing to do here */ 510 iucv_sever_path(sk, 1);
515 break; 511 }
512
513 if (iucv->hs_dev) {
514 dev_put(iucv->hs_dev);
515 iucv->hs_dev = NULL;
516 sk->sk_bound_dev_if = 0;
516 } 517 }
517 518
518 /* mark socket for deletion by iucv_sock_kill() */ 519 /* mark socket for deletion by iucv_sock_kill() */
@@ -706,7 +707,6 @@ static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr,
706 goto done_unlock; 707 goto done_unlock;
707 708
708 /* Bind the socket */ 709 /* Bind the socket */
709
710 if (pr_iucv) 710 if (pr_iucv)
711 if (!memcmp(sa->siucv_user_id, iucv_userid, 8)) 711 if (!memcmp(sa->siucv_user_id, iucv_userid, 8))
712 goto vm_bind; /* VM IUCV transport */ 712 goto vm_bind; /* VM IUCV transport */
@@ -720,6 +720,8 @@ static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr,
720 memcpy(iucv->src_name, sa->siucv_name, 8); 720 memcpy(iucv->src_name, sa->siucv_name, 8);
721 memcpy(iucv->src_user_id, sa->siucv_user_id, 8); 721 memcpy(iucv->src_user_id, sa->siucv_user_id, 8);
722 sk->sk_bound_dev_if = dev->ifindex; 722 sk->sk_bound_dev_if = dev->ifindex;
723 iucv->hs_dev = dev;
724 dev_hold(dev);
723 sk->sk_state = IUCV_BOUND; 725 sk->sk_state = IUCV_BOUND;
724 iucv->transport = AF_IUCV_TRANS_HIPER; 726 iucv->transport = AF_IUCV_TRANS_HIPER;
725 if (!iucv->msglimit) 727 if (!iucv->msglimit)
@@ -894,11 +896,8 @@ static int iucv_sock_connect(struct socket *sock, struct sockaddr *addr,
894 if (sk->sk_state == IUCV_DISCONN || sk->sk_state == IUCV_CLOSED) 896 if (sk->sk_state == IUCV_DISCONN || sk->sk_state == IUCV_CLOSED)
895 err = -ECONNREFUSED; 897 err = -ECONNREFUSED;
896 898
897 if (err && iucv->transport == AF_IUCV_TRANS_IUCV) { 899 if (err && iucv->transport == AF_IUCV_TRANS_IUCV)
898 pr_iucv->path_sever(iucv->path, NULL); 900 iucv_sever_path(sk, 0);
899 iucv_path_free(iucv->path);
900 iucv->path = NULL;
901 }
902 901
903done: 902done:
904 release_sock(sk); 903 release_sock(sk);
@@ -1124,8 +1123,10 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
1124 noblock, &err); 1123 noblock, &err);
1125 else 1124 else
1126 skb = sock_alloc_send_skb(sk, len, noblock, &err); 1125 skb = sock_alloc_send_skb(sk, len, noblock, &err);
1127 if (!skb) 1126 if (!skb) {
1127 err = -ENOMEM;
1128 goto out; 1128 goto out;
1129 }
1129 if (iucv->transport == AF_IUCV_TRANS_HIPER) 1130 if (iucv->transport == AF_IUCV_TRANS_HIPER)
1130 skb_reserve(skb, sizeof(struct af_iucv_trans_hdr) + ETH_HLEN); 1131 skb_reserve(skb, sizeof(struct af_iucv_trans_hdr) + ETH_HLEN);
1131 if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) { 1132 if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
@@ -1148,6 +1149,7 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
1148 /* increment and save iucv message tag for msg_completion cbk */ 1149 /* increment and save iucv message tag for msg_completion cbk */
1149 txmsg.tag = iucv->send_tag++; 1150 txmsg.tag = iucv->send_tag++;
1150 memcpy(CB_TAG(skb), &txmsg.tag, CB_TAG_LEN); 1151 memcpy(CB_TAG(skb), &txmsg.tag, CB_TAG_LEN);
1152
1151 if (iucv->transport == AF_IUCV_TRANS_HIPER) { 1153 if (iucv->transport == AF_IUCV_TRANS_HIPER) {
1152 atomic_inc(&iucv->msg_sent); 1154 atomic_inc(&iucv->msg_sent);
1153 err = afiucv_hs_send(&txmsg, sk, skb, 0); 1155 err = afiucv_hs_send(&txmsg, sk, skb, 0);
@@ -1202,8 +1204,6 @@ release:
1202 return len; 1204 return len;
1203 1205
1204fail: 1206fail:
1205 if (skb->dev)
1206 dev_put(skb->dev);
1207 kfree_skb(skb); 1207 kfree_skb(skb);
1208out: 1208out:
1209 release_sock(sk); 1209 release_sock(sk);
@@ -1396,7 +1396,14 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
1396 } 1396 }
1397 1397
1398 kfree_skb(skb); 1398 kfree_skb(skb);
1399 atomic_inc(&iucv->msg_recv); 1399 if (iucv->transport == AF_IUCV_TRANS_HIPER) {
1400 atomic_inc(&iucv->msg_recv);
1401 if (atomic_read(&iucv->msg_recv) > iucv->msglimit) {
1402 WARN_ON(1);
1403 iucv_sock_close(sk);
1404 return -EFAULT;
1405 }
1406 }
1400 1407
1401 /* Queue backlog skbs */ 1408 /* Queue backlog skbs */
1402 spin_lock_bh(&iucv->message_q.lock); 1409 spin_lock_bh(&iucv->message_q.lock);
@@ -1486,7 +1493,7 @@ unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
1486 if (sk->sk_state == IUCV_DISCONN) 1493 if (sk->sk_state == IUCV_DISCONN)
1487 mask |= POLLIN; 1494 mask |= POLLIN;
1488 1495
1489 if (sock_writeable(sk)) 1496 if (sock_writeable(sk) && iucv_below_msglim(sk))
1490 mask |= POLLOUT | POLLWRNORM | POLLWRBAND; 1497 mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
1491 else 1498 else
1492 set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 1499 set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
@@ -1565,13 +1572,6 @@ static int iucv_sock_release(struct socket *sock)
1565 1572
1566 iucv_sock_close(sk); 1573 iucv_sock_close(sk);
1567 1574
1568 /* Unregister with IUCV base support */
1569 if (iucv_sk(sk)->path) {
1570 pr_iucv->path_sever(iucv_sk(sk)->path, NULL);
1571 iucv_path_free(iucv_sk(sk)->path);
1572 iucv_sk(sk)->path = NULL;
1573 }
1574
1575 sock_orphan(sk); 1575 sock_orphan(sk);
1576 iucv_sock_kill(sk); 1576 iucv_sock_kill(sk);
1577 return err; 1577 return err;
@@ -1633,7 +1633,8 @@ static int iucv_sock_getsockopt(struct socket *sock, int level, int optname,
1633{ 1633{
1634 struct sock *sk = sock->sk; 1634 struct sock *sk = sock->sk;
1635 struct iucv_sock *iucv = iucv_sk(sk); 1635 struct iucv_sock *iucv = iucv_sk(sk);
1636 int val, len; 1636 unsigned int val;
1637 int len;
1637 1638
1638 if (level != SOL_IUCV) 1639 if (level != SOL_IUCV)
1639 return -ENOPROTOOPT; 1640 return -ENOPROTOOPT;
@@ -1656,6 +1657,13 @@ static int iucv_sock_getsockopt(struct socket *sock, int level, int optname,
1656 : iucv->msglimit; /* default */ 1657 : iucv->msglimit; /* default */
1657 release_sock(sk); 1658 release_sock(sk);
1658 break; 1659 break;
1660 case SO_MSGSIZE:
1661 if (sk->sk_state == IUCV_OPEN)
1662 return -EBADFD;
1663 val = (iucv->hs_dev) ? iucv->hs_dev->mtu -
1664 sizeof(struct af_iucv_trans_hdr) - ETH_HLEN :
1665 0x7fffffff;
1666 break;
1659 default: 1667 default:
1660 return -ENOPROTOOPT; 1668 return -ENOPROTOOPT;
1661 } 1669 }
@@ -1750,8 +1758,7 @@ static int iucv_callback_connreq(struct iucv_path *path,
1750 path->msglim = iucv->msglimit; 1758 path->msglim = iucv->msglimit;
1751 err = pr_iucv->path_accept(path, &af_iucv_handler, nuser_data, nsk); 1759 err = pr_iucv->path_accept(path, &af_iucv_handler, nuser_data, nsk);
1752 if (err) { 1760 if (err) {
1753 err = pr_iucv->path_sever(path, user_data); 1761 iucv_sever_path(nsk, 1);
1754 iucv_path_free(path);
1755 iucv_sock_kill(nsk); 1762 iucv_sock_kill(nsk);
1756 goto fail; 1763 goto fail;
1757 } 1764 }
@@ -1828,6 +1835,7 @@ static void iucv_callback_txdone(struct iucv_path *path,
1828 struct sk_buff *list_skb = list->next; 1835 struct sk_buff *list_skb = list->next;
1829 unsigned long flags; 1836 unsigned long flags;
1830 1837
1838 bh_lock_sock(sk);
1831 if (!skb_queue_empty(list)) { 1839 if (!skb_queue_empty(list)) {
1832 spin_lock_irqsave(&list->lock, flags); 1840 spin_lock_irqsave(&list->lock, flags);
1833 1841
@@ -1849,7 +1857,6 @@ static void iucv_callback_txdone(struct iucv_path *path,
1849 iucv_sock_wake_msglim(sk); 1857 iucv_sock_wake_msglim(sk);
1850 } 1858 }
1851 } 1859 }
1852 BUG_ON(!this);
1853 1860
1854 if (sk->sk_state == IUCV_CLOSING) { 1861 if (sk->sk_state == IUCV_CLOSING) {
1855 if (skb_queue_empty(&iucv_sk(sk)->send_skb_q)) { 1862 if (skb_queue_empty(&iucv_sk(sk)->send_skb_q)) {
@@ -1857,6 +1864,7 @@ static void iucv_callback_txdone(struct iucv_path *path,
1857 sk->sk_state_change(sk); 1864 sk->sk_state_change(sk);
1858 } 1865 }
1859 } 1866 }
1867 bh_unlock_sock(sk);
1860 1868
1861} 1869}
1862 1870
@@ -1864,9 +1872,15 @@ static void iucv_callback_connrej(struct iucv_path *path, u8 ipuser[16])
1864{ 1872{
1865 struct sock *sk = path->private; 1873 struct sock *sk = path->private;
1866 1874
1875 if (sk->sk_state == IUCV_CLOSED)
1876 return;
1877
1878 bh_lock_sock(sk);
1879 iucv_sever_path(sk, 1);
1867 sk->sk_state = IUCV_DISCONN; 1880 sk->sk_state = IUCV_DISCONN;
1868 1881
1869 sk->sk_state_change(sk); 1882 sk->sk_state_change(sk);
1883 bh_unlock_sock(sk);
1870} 1884}
1871 1885
1872/* called if the other communication side shuts down its RECV direction; 1886/* called if the other communication side shuts down its RECV direction;
@@ -1954,6 +1968,8 @@ static int afiucv_hs_callback_syn(struct sock *sk, struct sk_buff *skb)
1954 memcpy(niucv->src_name, iucv->src_name, 8); 1968 memcpy(niucv->src_name, iucv->src_name, 8);
1955 memcpy(niucv->src_user_id, iucv->src_user_id, 8); 1969 memcpy(niucv->src_user_id, iucv->src_user_id, 8);
1956 nsk->sk_bound_dev_if = sk->sk_bound_dev_if; 1970 nsk->sk_bound_dev_if = sk->sk_bound_dev_if;
1971 niucv->hs_dev = iucv->hs_dev;
1972 dev_hold(niucv->hs_dev);
1957 afiucv_swap_src_dest(skb); 1973 afiucv_swap_src_dest(skb);
1958 trans_hdr->flags = AF_IUCV_FLAG_SYN | AF_IUCV_FLAG_ACK; 1974 trans_hdr->flags = AF_IUCV_FLAG_SYN | AF_IUCV_FLAG_ACK;
1959 trans_hdr->window = niucv->msglimit; 1975 trans_hdr->window = niucv->msglimit;
@@ -2022,12 +2038,15 @@ static int afiucv_hs_callback_fin(struct sock *sk, struct sk_buff *skb)
2022 struct iucv_sock *iucv = iucv_sk(sk); 2038 struct iucv_sock *iucv = iucv_sk(sk);
2023 2039
2024 /* other end of connection closed */ 2040 /* other end of connection closed */
2025 if (iucv) { 2041 if (!iucv)
2026 bh_lock_sock(sk); 2042 goto out;
2043 bh_lock_sock(sk);
2044 if (sk->sk_state == IUCV_CONNECTED) {
2027 sk->sk_state = IUCV_DISCONN; 2045 sk->sk_state = IUCV_DISCONN;
2028 sk->sk_state_change(sk); 2046 sk->sk_state_change(sk);
2029 bh_unlock_sock(sk);
2030 } 2047 }
2048 bh_unlock_sock(sk);
2049out:
2031 kfree_skb(skb); 2050 kfree_skb(skb);
2032 return NET_RX_SUCCESS; 2051 return NET_RX_SUCCESS;
2033} 2052}
@@ -2172,11 +2191,11 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev,
2172 break; 2191 break;
2173 case (AF_IUCV_FLAG_WIN): 2192 case (AF_IUCV_FLAG_WIN):
2174 err = afiucv_hs_callback_win(sk, skb); 2193 err = afiucv_hs_callback_win(sk, skb);
2175 if (skb->len > sizeof(struct af_iucv_trans_hdr)) 2194 if (skb->len == sizeof(struct af_iucv_trans_hdr)) {
2176 err = afiucv_hs_callback_rx(sk, skb); 2195 kfree_skb(skb);
2177 else 2196 break;
2178 kfree(skb); 2197 }
2179 break; 2198 /* fall through */
2180 case 0: 2199 case 0:
2181 /* plain data frame */ 2200 /* plain data frame */
2182 memcpy(CB_TRGCLS(skb), &trans_hdr->iucv_hdr.class, 2201 memcpy(CB_TRGCLS(skb), &trans_hdr->iucv_hdr.class,
@@ -2202,65 +2221,64 @@ static void afiucv_hs_callback_txnotify(struct sk_buff *skb,
2202 struct iucv_sock *iucv = NULL; 2221 struct iucv_sock *iucv = NULL;
2203 struct sk_buff_head *list; 2222 struct sk_buff_head *list;
2204 struct sk_buff *list_skb; 2223 struct sk_buff *list_skb;
2205 struct sk_buff *this = NULL; 2224 struct sk_buff *nskb;
2206 unsigned long flags; 2225 unsigned long flags;
2207 struct hlist_node *node; 2226 struct hlist_node *node;
2208 2227
2209 read_lock(&iucv_sk_list.lock); 2228 read_lock_irqsave(&iucv_sk_list.lock, flags);
2210 sk_for_each(sk, node, &iucv_sk_list.head) 2229 sk_for_each(sk, node, &iucv_sk_list.head)
2211 if (sk == isk) { 2230 if (sk == isk) {
2212 iucv = iucv_sk(sk); 2231 iucv = iucv_sk(sk);
2213 break; 2232 break;
2214 } 2233 }
2215 read_unlock(&iucv_sk_list.lock); 2234 read_unlock_irqrestore(&iucv_sk_list.lock, flags);
2216 2235
2217 if (!iucv) 2236 if (!iucv || sock_flag(sk, SOCK_ZAPPED))
2218 return; 2237 return;
2219 2238
2220 bh_lock_sock(sk);
2221 list = &iucv->send_skb_q; 2239 list = &iucv->send_skb_q;
2222 list_skb = list->next; 2240 spin_lock_irqsave(&list->lock, flags);
2223 if (skb_queue_empty(list)) 2241 if (skb_queue_empty(list))
2224 goto out_unlock; 2242 goto out_unlock;
2225 2243 list_skb = list->next;
2226 spin_lock_irqsave(&list->lock, flags); 2244 nskb = list_skb->next;
2227 while (list_skb != (struct sk_buff *)list) { 2245 while (list_skb != (struct sk_buff *)list) {
2228 if (skb_shinfo(list_skb) == skb_shinfo(skb)) { 2246 if (skb_shinfo(list_skb) == skb_shinfo(skb)) {
2229 this = list_skb;
2230 switch (n) { 2247 switch (n) {
2231 case TX_NOTIFY_OK: 2248 case TX_NOTIFY_OK:
2232 __skb_unlink(this, list); 2249 __skb_unlink(list_skb, list);
2250 kfree_skb(list_skb);
2233 iucv_sock_wake_msglim(sk); 2251 iucv_sock_wake_msglim(sk);
2234 dev_put(this->dev);
2235 kfree_skb(this);
2236 break; 2252 break;
2237 case TX_NOTIFY_PENDING: 2253 case TX_NOTIFY_PENDING:
2238 atomic_inc(&iucv->pendings); 2254 atomic_inc(&iucv->pendings);
2239 break; 2255 break;
2240 case TX_NOTIFY_DELAYED_OK: 2256 case TX_NOTIFY_DELAYED_OK:
2241 __skb_unlink(this, list); 2257 __skb_unlink(list_skb, list);
2242 atomic_dec(&iucv->pendings); 2258 atomic_dec(&iucv->pendings);
2243 if (atomic_read(&iucv->pendings) <= 0) 2259 if (atomic_read(&iucv->pendings) <= 0)
2244 iucv_sock_wake_msglim(sk); 2260 iucv_sock_wake_msglim(sk);
2245 dev_put(this->dev); 2261 kfree_skb(list_skb);
2246 kfree_skb(this);
2247 break; 2262 break;
2248 case TX_NOTIFY_UNREACHABLE: 2263 case TX_NOTIFY_UNREACHABLE:
2249 case TX_NOTIFY_DELAYED_UNREACHABLE: 2264 case TX_NOTIFY_DELAYED_UNREACHABLE:
2250 case TX_NOTIFY_TPQFULL: /* not yet used */ 2265 case TX_NOTIFY_TPQFULL: /* not yet used */
2251 case TX_NOTIFY_GENERALERROR: 2266 case TX_NOTIFY_GENERALERROR:
2252 case TX_NOTIFY_DELAYED_GENERALERROR: 2267 case TX_NOTIFY_DELAYED_GENERALERROR:
2253 __skb_unlink(this, list); 2268 __skb_unlink(list_skb, list);
2254 dev_put(this->dev); 2269 kfree_skb(list_skb);
2255 kfree_skb(this); 2270 if (sk->sk_state == IUCV_CONNECTED) {
2256 sk->sk_state = IUCV_DISCONN; 2271 sk->sk_state = IUCV_DISCONN;
2257 sk->sk_state_change(sk); 2272 sk->sk_state_change(sk);
2273 }
2258 break; 2274 break;
2259 } 2275 }
2260 break; 2276 break;
2261 } 2277 }
2262 list_skb = list_skb->next; 2278 list_skb = nskb;
2279 nskb = nskb->next;
2263 } 2280 }
2281out_unlock:
2264 spin_unlock_irqrestore(&list->lock, flags); 2282 spin_unlock_irqrestore(&list->lock, flags);
2265 2283
2266 if (sk->sk_state == IUCV_CLOSING) { 2284 if (sk->sk_state == IUCV_CLOSING) {
@@ -2270,8 +2288,6 @@ static void afiucv_hs_callback_txnotify(struct sk_buff *skb,
2270 } 2288 }
2271 } 2289 }
2272 2290
2273out_unlock:
2274 bh_unlock_sock(sk);
2275} 2291}
2276static const struct proto_ops iucv_sock_ops = { 2292static const struct proto_ops iucv_sock_ops = {
2277 .family = PF_IUCV, 2293 .family = PF_IUCV,
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 296620d6ca0c..d15ba0d0de94 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -776,12 +776,10 @@ static int sta_apply_parameters(struct ieee80211_local *local,
776 776
777 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED) && 777 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
778 !test_sta_flag(sta, WLAN_STA_AUTH)) { 778 !test_sta_flag(sta, WLAN_STA_AUTH)) {
779 ret = sta_info_move_state_checked(sta, 779 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
780 IEEE80211_STA_AUTH);
781 if (ret) 780 if (ret)
782 return ret; 781 return ret;
783 ret = sta_info_move_state_checked(sta, 782 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
784 IEEE80211_STA_ASSOC);
785 if (ret) 783 if (ret)
786 return ret; 784 return ret;
787 } 785 }
@@ -789,11 +787,9 @@ static int sta_apply_parameters(struct ieee80211_local *local,
789 787
790 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { 788 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
791 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) 789 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
792 ret = sta_info_move_state_checked(sta, 790 ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
793 IEEE80211_STA_AUTHORIZED);
794 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) 791 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
795 ret = sta_info_move_state_checked(sta, 792 ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
796 IEEE80211_STA_ASSOC);
797 if (ret) 793 if (ret)
798 return ret; 794 return ret;
799 } 795 }
@@ -805,12 +801,10 @@ static int sta_apply_parameters(struct ieee80211_local *local,
805 801
806 if (!(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) && 802 if (!(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
807 test_sta_flag(sta, WLAN_STA_AUTH)) { 803 test_sta_flag(sta, WLAN_STA_AUTH)) {
808 ret = sta_info_move_state_checked(sta, 804 ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
809 IEEE80211_STA_AUTH);
810 if (ret) 805 if (ret)
811 return ret; 806 return ret;
812 ret = sta_info_move_state_checked(sta, 807 ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
813 IEEE80211_STA_NONE);
814 if (ret) 808 if (ret)
815 return ret; 809 return ret;
816 } 810 }
@@ -944,8 +938,8 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
944 if (!sta) 938 if (!sta)
945 return -ENOMEM; 939 return -ENOMEM;
946 940
947 sta_info_move_state(sta, IEEE80211_STA_AUTH); 941 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
948 sta_info_move_state(sta, IEEE80211_STA_ASSOC); 942 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
949 943
950 err = sta_apply_parameters(local, sta, params); 944 err = sta_apply_parameters(local, sta, params);
951 if (err) { 945 if (err) {
@@ -1001,6 +995,7 @@ static int ieee80211_change_station(struct wiphy *wiphy,
1001 struct ieee80211_local *local = wiphy_priv(wiphy); 995 struct ieee80211_local *local = wiphy_priv(wiphy);
1002 struct sta_info *sta; 996 struct sta_info *sta;
1003 struct ieee80211_sub_if_data *vlansdata; 997 struct ieee80211_sub_if_data *vlansdata;
998 int err;
1004 999
1005 mutex_lock(&local->sta_mtx); 1000 mutex_lock(&local->sta_mtx);
1006 1001
@@ -1040,7 +1035,11 @@ static int ieee80211_change_station(struct wiphy *wiphy,
1040 ieee80211_send_layer2_update(sta); 1035 ieee80211_send_layer2_update(sta);
1041 } 1036 }
1042 1037
1043 sta_apply_parameters(local, sta, params); 1038 err = sta_apply_parameters(local, sta, params);
1039 if (err) {
1040 mutex_unlock(&local->sta_mtx);
1041 return err;
1042 }
1044 1043
1045 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && params->supported_rates) 1044 if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && params->supported_rates)
1046 rate_control_rate_init(sta); 1045 rate_control_rate_init(sta);
@@ -1341,6 +1340,8 @@ static int ieee80211_update_mesh_config(struct wiphy *wiphy,
1341 conf->dot11MeshHWMPRannInterval = 1340 conf->dot11MeshHWMPRannInterval =
1342 nconf->dot11MeshHWMPRannInterval; 1341 nconf->dot11MeshHWMPRannInterval;
1343 } 1342 }
1343 if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
1344 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
1344 return 0; 1345 return 0;
1345} 1346}
1346 1347
@@ -1868,7 +1869,6 @@ static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
1868 s32 rssi_thold, u32 rssi_hyst) 1869 s32 rssi_thold, u32 rssi_hyst)
1869{ 1870{
1870 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1871 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1871 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1872 struct ieee80211_vif *vif = &sdata->vif; 1872 struct ieee80211_vif *vif = &sdata->vif;
1873 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; 1873 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
1874 1874
@@ -1879,14 +1879,9 @@ static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
1879 bss_conf->cqm_rssi_thold = rssi_thold; 1879 bss_conf->cqm_rssi_thold = rssi_thold;
1880 bss_conf->cqm_rssi_hyst = rssi_hyst; 1880 bss_conf->cqm_rssi_hyst = rssi_hyst;
1881 1881
1882 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI)) {
1883 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1884 return -EOPNOTSUPP;
1885 return 0;
1886 }
1887
1888 /* tell the driver upon association, unless already associated */ 1882 /* tell the driver upon association, unless already associated */
1889 if (sdata->u.mgd.associated) 1883 if (sdata->u.mgd.associated &&
1884 sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
1890 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM); 1885 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
1891 1886
1892 return 0; 1887 return 0;
@@ -1907,8 +1902,11 @@ static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
1907 return ret; 1902 return ret;
1908 } 1903 }
1909 1904
1910 for (i = 0; i < IEEE80211_NUM_BANDS; i++) 1905 for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
1911 sdata->rc_rateidx_mask[i] = mask->control[i].legacy; 1906 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
1907 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
1908 sizeof(mask->control[i].mcs));
1909 }
1912 1910
1913 return 0; 1911 return 0;
1914} 1912}
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index 889c3e93e0f4..d1f7abddb182 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -20,23 +20,29 @@ __ieee80211_get_channel_mode(struct ieee80211_local *local,
20 if (!ieee80211_sdata_running(sdata)) 20 if (!ieee80211_sdata_running(sdata))
21 continue; 21 continue;
22 22
23 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) 23 switch (sdata->vif.type) {
24 case NL80211_IFTYPE_MONITOR:
24 continue; 25 continue;
25 26 case NL80211_IFTYPE_STATION:
26 if (sdata->vif.type == NL80211_IFTYPE_STATION && 27 if (!sdata->u.mgd.associated)
27 !sdata->u.mgd.associated) 28 continue;
28 continue; 29 break;
29 30 case NL80211_IFTYPE_ADHOC:
30 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
31 if (!sdata->u.ibss.ssid_len) 31 if (!sdata->u.ibss.ssid_len)
32 continue; 32 continue;
33 if (!sdata->u.ibss.fixed_channel) 33 if (!sdata->u.ibss.fixed_channel)
34 return CHAN_MODE_HOPPING; 34 return CHAN_MODE_HOPPING;
35 } 35 break;
36 36 case NL80211_IFTYPE_AP_VLAN:
37 if (sdata->vif.type == NL80211_IFTYPE_AP && 37 /* will also have _AP interface */
38 !sdata->u.ap.beacon)
39 continue; 38 continue;
39 case NL80211_IFTYPE_AP:
40 if (!sdata->u.ap.beacon)
41 continue;
42 break;
43 default:
44 break;
45 }
40 46
41 return CHAN_MODE_FIXED; 47 return CHAN_MODE_FIXED;
42 } 48 }
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index 90baea53e7c5..affe64be9092 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -247,8 +247,6 @@ static ssize_t hwflags_read(struct file *file, char __user *user_buf,
247 sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_DYNAMIC_PS\n"); 247 sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_DYNAMIC_PS\n");
248 if (local->hw.flags & IEEE80211_HW_MFP_CAPABLE) 248 if (local->hw.flags & IEEE80211_HW_MFP_CAPABLE)
249 sf += snprintf(buf + sf, mxln - sf, "MFP_CAPABLE\n"); 249 sf += snprintf(buf + sf, mxln - sf, "MFP_CAPABLE\n");
250 if (local->hw.flags & IEEE80211_HW_BEACON_FILTER)
251 sf += snprintf(buf + sf, mxln - sf, "BEACON_FILTER\n");
252 if (local->hw.flags & IEEE80211_HW_SUPPORTS_STATIC_SMPS) 250 if (local->hw.flags & IEEE80211_HW_SUPPORTS_STATIC_SMPS)
253 sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_STATIC_SMPS\n"); 251 sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_STATIC_SMPS\n");
254 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS) 252 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS)
@@ -259,8 +257,6 @@ static ssize_t hwflags_read(struct file *file, char __user *user_buf,
259 sf += snprintf(buf + sf, mxln - sf, "REPORTS_TX_ACK_STATUS\n"); 257 sf += snprintf(buf + sf, mxln - sf, "REPORTS_TX_ACK_STATUS\n");
260 if (local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR) 258 if (local->hw.flags & IEEE80211_HW_CONNECTION_MONITOR)
261 sf += snprintf(buf + sf, mxln - sf, "CONNECTION_MONITOR\n"); 259 sf += snprintf(buf + sf, mxln - sf, "CONNECTION_MONITOR\n");
262 if (local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI)
263 sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_CQM_RSSI\n");
264 if (local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK) 260 if (local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK)
265 sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_PER_STA_GTK\n"); 261 sf += snprintf(buf + sf, mxln - sf, "SUPPORTS_PER_STA_GTK\n");
266 if (local->hw.flags & IEEE80211_HW_AP_LINK_PS) 262 if (local->hw.flags & IEEE80211_HW_AP_LINK_PS)
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index 176c08ffb13c..510ed1dab3c7 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -87,6 +87,21 @@ static ssize_t ieee80211_if_fmt_##name( \
87#define IEEE80211_IF_FMT_SIZE(name, field) \ 87#define IEEE80211_IF_FMT_SIZE(name, field) \
88 IEEE80211_IF_FMT(name, field, "%zd\n") 88 IEEE80211_IF_FMT(name, field, "%zd\n")
89 89
90#define IEEE80211_IF_FMT_HEXARRAY(name, field) \
91static ssize_t ieee80211_if_fmt_##name( \
92 const struct ieee80211_sub_if_data *sdata, \
93 char *buf, int buflen) \
94{ \
95 char *p = buf; \
96 int i; \
97 for (i = 0; i < sizeof(sdata->field); i++) { \
98 p += scnprintf(p, buflen + buf - p, "%.2x ", \
99 sdata->field[i]); \
100 } \
101 p += scnprintf(p, buflen + buf - p, "\n"); \
102 return p - buf; \
103}
104
90#define IEEE80211_IF_FMT_ATOMIC(name, field) \ 105#define IEEE80211_IF_FMT_ATOMIC(name, field) \
91static ssize_t ieee80211_if_fmt_##name( \ 106static ssize_t ieee80211_if_fmt_##name( \
92 const struct ieee80211_sub_if_data *sdata, \ 107 const struct ieee80211_sub_if_data *sdata, \
@@ -148,6 +163,11 @@ IEEE80211_IF_FILE(rc_rateidx_mask_2ghz, rc_rateidx_mask[IEEE80211_BAND_2GHZ],
148 HEX); 163 HEX);
149IEEE80211_IF_FILE(rc_rateidx_mask_5ghz, rc_rateidx_mask[IEEE80211_BAND_5GHZ], 164IEEE80211_IF_FILE(rc_rateidx_mask_5ghz, rc_rateidx_mask[IEEE80211_BAND_5GHZ],
150 HEX); 165 HEX);
166IEEE80211_IF_FILE(rc_rateidx_mcs_mask_2ghz,
167 rc_rateidx_mcs_mask[IEEE80211_BAND_2GHZ], HEXARRAY);
168IEEE80211_IF_FILE(rc_rateidx_mcs_mask_5ghz,
169 rc_rateidx_mcs_mask[IEEE80211_BAND_5GHZ], HEXARRAY);
170
151IEEE80211_IF_FILE(flags, flags, HEX); 171IEEE80211_IF_FILE(flags, flags, HEX);
152IEEE80211_IF_FILE(state, state, LHEX); 172IEEE80211_IF_FILE(state, state, LHEX);
153IEEE80211_IF_FILE(channel_type, vif.bss_conf.channel_type, DEC); 173IEEE80211_IF_FILE(channel_type, vif.bss_conf.channel_type, DEC);
@@ -422,6 +442,7 @@ IEEE80211_IF_FILE(dot11MeshGateAnnouncementProtocol,
422 u.mesh.mshcfg.dot11MeshGateAnnouncementProtocol, DEC); 442 u.mesh.mshcfg.dot11MeshGateAnnouncementProtocol, DEC);
423IEEE80211_IF_FILE(dot11MeshHWMPRannInterval, 443IEEE80211_IF_FILE(dot11MeshHWMPRannInterval,
424 u.mesh.mshcfg.dot11MeshHWMPRannInterval, DEC); 444 u.mesh.mshcfg.dot11MeshHWMPRannInterval, DEC);
445IEEE80211_IF_FILE(dot11MeshForwarding, u.mesh.mshcfg.dot11MeshForwarding, DEC);
425#endif 446#endif
426 447
427 448
@@ -441,6 +462,8 @@ static void add_sta_files(struct ieee80211_sub_if_data *sdata)
441 DEBUGFS_ADD(channel_type); 462 DEBUGFS_ADD(channel_type);
442 DEBUGFS_ADD(rc_rateidx_mask_2ghz); 463 DEBUGFS_ADD(rc_rateidx_mask_2ghz);
443 DEBUGFS_ADD(rc_rateidx_mask_5ghz); 464 DEBUGFS_ADD(rc_rateidx_mask_5ghz);
465 DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz);
466 DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz);
444 467
445 DEBUGFS_ADD(bssid); 468 DEBUGFS_ADD(bssid);
446 DEBUGFS_ADD(aid); 469 DEBUGFS_ADD(aid);
@@ -458,6 +481,8 @@ static void add_ap_files(struct ieee80211_sub_if_data *sdata)
458 DEBUGFS_ADD(channel_type); 481 DEBUGFS_ADD(channel_type);
459 DEBUGFS_ADD(rc_rateidx_mask_2ghz); 482 DEBUGFS_ADD(rc_rateidx_mask_2ghz);
460 DEBUGFS_ADD(rc_rateidx_mask_5ghz); 483 DEBUGFS_ADD(rc_rateidx_mask_5ghz);
484 DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz);
485 DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz);
461 486
462 DEBUGFS_ADD(num_sta_authorized); 487 DEBUGFS_ADD(num_sta_authorized);
463 DEBUGFS_ADD(num_sta_ps); 488 DEBUGFS_ADD(num_sta_ps);
@@ -468,6 +493,12 @@ static void add_ap_files(struct ieee80211_sub_if_data *sdata)
468 493
469static void add_ibss_files(struct ieee80211_sub_if_data *sdata) 494static void add_ibss_files(struct ieee80211_sub_if_data *sdata)
470{ 495{
496 DEBUGFS_ADD(channel_type);
497 DEBUGFS_ADD(rc_rateidx_mask_2ghz);
498 DEBUGFS_ADD(rc_rateidx_mask_5ghz);
499 DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz);
500 DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz);
501
471 DEBUGFS_ADD_MODE(tsf, 0600); 502 DEBUGFS_ADD_MODE(tsf, 0600);
472} 503}
473 504
@@ -479,6 +510,8 @@ static void add_wds_files(struct ieee80211_sub_if_data *sdata)
479 DEBUGFS_ADD(channel_type); 510 DEBUGFS_ADD(channel_type);
480 DEBUGFS_ADD(rc_rateidx_mask_2ghz); 511 DEBUGFS_ADD(rc_rateidx_mask_2ghz);
481 DEBUGFS_ADD(rc_rateidx_mask_5ghz); 512 DEBUGFS_ADD(rc_rateidx_mask_5ghz);
513 DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz);
514 DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz);
482 515
483 DEBUGFS_ADD(peer); 516 DEBUGFS_ADD(peer);
484} 517}
@@ -491,6 +524,8 @@ static void add_vlan_files(struct ieee80211_sub_if_data *sdata)
491 DEBUGFS_ADD(channel_type); 524 DEBUGFS_ADD(channel_type);
492 DEBUGFS_ADD(rc_rateidx_mask_2ghz); 525 DEBUGFS_ADD(rc_rateidx_mask_2ghz);
493 DEBUGFS_ADD(rc_rateidx_mask_5ghz); 526 DEBUGFS_ADD(rc_rateidx_mask_5ghz);
527 DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz);
528 DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz);
494} 529}
495 530
496static void add_monitor_files(struct ieee80211_sub_if_data *sdata) 531static void add_monitor_files(struct ieee80211_sub_if_data *sdata)
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index 2406b3e7393f..c8383712fdec 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -63,14 +63,15 @@ static ssize_t sta_flags_read(struct file *file, char __user *userbuf,
63 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : "" 63 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
64 64
65 int res = scnprintf(buf, sizeof(buf), 65 int res = scnprintf(buf, sizeof(buf),
66 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", 66 "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
67 TEST(AUTH), TEST(ASSOC), TEST(PS_STA), 67 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
68 TEST(PS_DRIVER), TEST(AUTHORIZED), 68 TEST(PS_DRIVER), TEST(AUTHORIZED),
69 TEST(SHORT_PREAMBLE), 69 TEST(SHORT_PREAMBLE),
70 TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT), 70 TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
71 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL), 71 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
72 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER), 72 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
73 TEST(TDLS_PEER_AUTH)); 73 TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
74 TEST(INSERTED));
74#undef TEST 75#undef TEST
75 return simple_read_from_buffer(userbuf, count, ppos, buf, res); 76 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
76} 77}
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index a4643969a13b..7b3a0b0aa246 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -36,31 +36,6 @@
36#define IEEE80211_IBSS_MAX_STA_ENTRIES 128 36#define IEEE80211_IBSS_MAX_STA_ENTRIES 128
37 37
38 38
39static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata,
40 struct ieee80211_mgmt *mgmt,
41 size_t len)
42{
43 u16 auth_alg, auth_transaction;
44
45 lockdep_assert_held(&sdata->u.ibss.mtx);
46
47 if (len < 24 + 6)
48 return;
49
50 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg);
51 auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction);
52
53 /*
54 * IEEE 802.11 standard does not require authentication in IBSS
55 * networks and most implementations do not seem to use it.
56 * However, try to reply to authentication attempts if someone
57 * has actually implemented this.
58 */
59 if (auth_alg == WLAN_AUTH_OPEN && auth_transaction == 1)
60 ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, NULL, 0,
61 sdata->u.ibss.bssid, NULL, 0, 0);
62}
63
64static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, 39static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
65 const u8 *bssid, const int beacon_int, 40 const u8 *bssid, const int beacon_int,
66 struct ieee80211_channel *chan, 41 struct ieee80211_channel *chan,
@@ -276,7 +251,8 @@ static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
276 cbss->tsf); 251 cbss->tsf);
277} 252}
278 253
279static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta) 254static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta,
255 bool auth)
280 __acquires(RCU) 256 __acquires(RCU)
281{ 257{
282 struct ieee80211_sub_if_data *sdata = sta->sdata; 258 struct ieee80211_sub_if_data *sdata = sta->sdata;
@@ -290,22 +266,31 @@ static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta)
290 addr, sdata->name); 266 addr, sdata->name);
291#endif 267#endif
292 268
293 sta_info_move_state(sta, IEEE80211_STA_AUTH); 269 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
294 sta_info_move_state(sta, IEEE80211_STA_ASSOC); 270 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
295 sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); 271 sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
296 272
297 rate_control_rate_init(sta); 273 rate_control_rate_init(sta);
298 274
299 /* If it fails, maybe we raced another insertion? */ 275 /* If it fails, maybe we raced another insertion? */
300 if (sta_info_insert_rcu(sta)) 276 if (sta_info_insert_rcu(sta))
301 return sta_info_get(sdata, addr); 277 return sta_info_get(sdata, addr);
278 if (auth) {
279#ifdef CONFIG_MAC80211_IBSS_DEBUG
280 printk(KERN_DEBUG "TX Auth SA=%pM DA=%pM BSSID=%pM"
281 "(auth_transaction=1)\n", sdata->vif.addr,
282 sdata->u.ibss.bssid, addr);
283#endif
284 ieee80211_send_auth(sdata, 1, WLAN_AUTH_OPEN, NULL, 0,
285 addr, sdata->u.ibss.bssid, NULL, 0, 0);
286 }
302 return sta; 287 return sta;
303} 288}
304 289
305static struct sta_info * 290static struct sta_info *
306ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, 291ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
307 const u8 *bssid, const u8 *addr, 292 const u8 *bssid, const u8 *addr,
308 u32 supp_rates) 293 u32 supp_rates, bool auth)
309 __acquires(RCU) 294 __acquires(RCU)
310{ 295{
311 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 296 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
@@ -347,7 +332,42 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
347 sta->sta.supp_rates[band] = supp_rates | 332 sta->sta.supp_rates[band] = supp_rates |
348 ieee80211_mandatory_rates(local, band); 333 ieee80211_mandatory_rates(local, band);
349 334
350 return ieee80211_ibss_finish_sta(sta); 335 return ieee80211_ibss_finish_sta(sta, auth);
336}
337
338static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata,
339 struct ieee80211_mgmt *mgmt,
340 size_t len)
341{
342 u16 auth_alg, auth_transaction;
343
344 lockdep_assert_held(&sdata->u.ibss.mtx);
345
346 if (len < 24 + 6)
347 return;
348
349 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg);
350 auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction);
351
352 if (auth_alg != WLAN_AUTH_OPEN || auth_transaction != 1)
353 return;
354#ifdef CONFIG_MAC80211_IBSS_DEBUG
355 printk(KERN_DEBUG "%s: RX Auth SA=%pM DA=%pM BSSID=%pM."
356 "(auth_transaction=%d)\n",
357 sdata->name, mgmt->sa, mgmt->da, mgmt->bssid, auth_transaction);
358#endif
359 sta_info_destroy_addr(sdata, mgmt->sa);
360 ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, 0, false);
361 rcu_read_unlock();
362
363 /*
364 * IEEE 802.11 standard does not require authentication in IBSS
365 * networks and most implementations do not seem to use it.
366 * However, try to reply to authentication attempts if someone
367 * has actually implemented this.
368 */
369 ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, NULL, 0,
370 mgmt->sa, sdata->u.ibss.bssid, NULL, 0, 0);
351} 371}
352 372
353static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, 373static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
@@ -412,7 +432,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
412 } else { 432 } else {
413 rcu_read_unlock(); 433 rcu_read_unlock();
414 sta = ieee80211_ibss_add_sta(sdata, mgmt->bssid, 434 sta = ieee80211_ibss_add_sta(sdata, mgmt->bssid,
415 mgmt->sa, supp_rates); 435 mgmt->sa, supp_rates, true);
416 } 436 }
417 } 437 }
418 438
@@ -540,7 +560,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
540 ieee80211_sta_join_ibss(sdata, bss); 560 ieee80211_sta_join_ibss(sdata, bss);
541 supp_rates = ieee80211_sta_get_rates(local, elems, band); 561 supp_rates = ieee80211_sta_get_rates(local, elems, band);
542 ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, 562 ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa,
543 supp_rates); 563 supp_rates, true);
544 rcu_read_unlock(); 564 rcu_read_unlock();
545 } 565 }
546 566
@@ -643,8 +663,7 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata)
643 "IBSS networks with same SSID (merge)\n", sdata->name); 663 "IBSS networks with same SSID (merge)\n", sdata->name);
644 664
645 ieee80211_request_internal_scan(sdata, 665 ieee80211_request_internal_scan(sdata,
646 ifibss->ssid, ifibss->ssid_len, 666 ifibss->ssid, ifibss->ssid_len, NULL);
647 ifibss->fixed_channel ? ifibss->channel : NULL);
648} 667}
649 668
650static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) 669static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata)
@@ -855,9 +874,6 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
855 size_t baselen; 874 size_t baselen;
856 struct ieee802_11_elems elems; 875 struct ieee802_11_elems elems;
857 876
858 if (memcmp(mgmt->da, sdata->vif.addr, ETH_ALEN))
859 return; /* ignore ProbeResp to foreign address */
860
861 baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; 877 baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
862 if (baselen > len) 878 if (baselen > len)
863 return; 879 return;
@@ -945,7 +961,7 @@ void ieee80211_ibss_work(struct ieee80211_sub_if_data *sdata)
945 list_del(&sta->list); 961 list_del(&sta->list);
946 spin_unlock_bh(&ifibss->incomplete_lock); 962 spin_unlock_bh(&ifibss->incomplete_lock);
947 963
948 ieee80211_ibss_finish_sta(sta); 964 ieee80211_ibss_finish_sta(sta, true);
949 rcu_read_unlock(); 965 rcu_read_unlock();
950 spin_lock_bh(&ifibss->incomplete_lock); 966 spin_lock_bh(&ifibss->incomplete_lock);
951 } 967 }
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 2f0642d9e154..d47e8c110b16 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -646,6 +646,7 @@ struct ieee80211_sub_if_data {
646 646
647 /* bitmap of allowed (non-MCS) rate indexes for rate control */ 647 /* bitmap of allowed (non-MCS) rate indexes for rate control */
648 u32 rc_rateidx_mask[IEEE80211_NUM_BANDS]; 648 u32 rc_rateidx_mask[IEEE80211_NUM_BANDS];
649 u8 rc_rateidx_mcs_mask[IEEE80211_NUM_BANDS][IEEE80211_HT_MCS_MASK_LEN];
649 650
650 union { 651 union {
651 struct ieee80211_if_ap ap; 652 struct ieee80211_if_ap ap;
@@ -1396,7 +1397,7 @@ void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local,
1396void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, 1397void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
1397 u16 transaction, u16 auth_alg, 1398 u16 transaction, u16 auth_alg,
1398 u8 *extra, size_t extra_len, const u8 *bssid, 1399 u8 *extra, size_t extra_len, const u8 *bssid,
1399 const u8 *key, u8 key_len, u8 key_idx); 1400 const u8 *da, const u8 *key, u8 key_len, u8 key_idx);
1400int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer, 1401int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
1401 const u8 *ie, size_t ie_len, 1402 const u8 *ie, size_t ie_len,
1402 enum ieee80211_band band, u32 rate_mask, 1403 enum ieee80211_band band, u32 rate_mask,
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 01a21c2f6ab3..2efd595b2f7a 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -318,9 +318,9 @@ static int ieee80211_do_open(struct net_device *dev, bool coming_up)
318 goto err_del_interface; 318 goto err_del_interface;
319 } 319 }
320 320
321 sta_info_move_state(sta, IEEE80211_STA_AUTH); 321 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
322 sta_info_move_state(sta, IEEE80211_STA_ASSOC); 322 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
323 sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); 323 sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
324 324
325 res = sta_info_insert(sta); 325 res = sta_info_insert(sta);
326 if (res) { 326 if (res) {
@@ -1181,6 +1181,13 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
1181 sband = local->hw.wiphy->bands[i]; 1181 sband = local->hw.wiphy->bands[i];
1182 sdata->rc_rateidx_mask[i] = 1182 sdata->rc_rateidx_mask[i] =
1183 sband ? (1 << sband->n_bitrates) - 1 : 0; 1183 sband ? (1 << sband->n_bitrates) - 1 : 0;
1184 if (sband)
1185 memcpy(sdata->rc_rateidx_mcs_mask[i],
1186 sband->ht_cap.mcs.rx_mask,
1187 sizeof(sdata->rc_rateidx_mcs_mask[i]));
1188 else
1189 memset(sdata->rc_rateidx_mcs_mask[i], 0,
1190 sizeof(sdata->rc_rateidx_mcs_mask[i]));
1184 } 1191 }
1185 1192
1186 /* setup type-dependent data */ 1193 /* setup type-dependent data */
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 0a0d94ad9b08..6192caadfab9 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -155,7 +155,8 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
155 power = chan->max_power; 155 power = chan->max_power;
156 else 156 else
157 power = local->power_constr_level ? 157 power = local->power_constr_level ?
158 (chan->max_power - local->power_constr_level) : 158 min(chan->max_power,
159 (chan->max_reg_power - local->power_constr_level)) :
159 chan->max_power; 160 chan->max_power;
160 161
161 if (local->user_power_level >= 0) 162 if (local->user_power_level >= 0)
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 54df1b2bafd2..c27dec904963 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -575,7 +575,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
575 ifmsh->mshstats.dropped_frames_ttl++; 575 ifmsh->mshstats.dropped_frames_ttl++;
576 } 576 }
577 577
578 if (forward) { 578 if (forward && ifmsh->mshcfg.dot11MeshForwarding) {
579 u32 preq_id; 579 u32 preq_id;
580 u8 hopcount, flags; 580 u8 hopcount, flags;
581 581
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index a17251730b9e..8806e5ef8ffe 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -96,9 +96,9 @@ static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata,
96 if (!sta) 96 if (!sta)
97 return NULL; 97 return NULL;
98 98
99 sta_info_move_state(sta, IEEE80211_STA_AUTH); 99 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
100 sta_info_move_state(sta, IEEE80211_STA_ASSOC); 100 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
101 sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); 101 sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
102 102
103 set_sta_flag(sta, WLAN_STA_WME); 103 set_sta_flag(sta, WLAN_STA_WME);
104 104
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 295be92f7c77..49fd1acd5d15 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -127,7 +127,7 @@ static void run_again(struct ieee80211_if_managed *ifmgd,
127 127
128void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata) 128void ieee80211_sta_reset_beacon_monitor(struct ieee80211_sub_if_data *sdata)
129{ 129{
130 if (sdata->local->hw.flags & IEEE80211_HW_BEACON_FILTER) 130 if (sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)
131 return; 131 return;
132 132
133 mod_timer(&sdata->u.mgd.bcn_mon_timer, 133 mod_timer(&sdata->u.mgd.bcn_mon_timer,
@@ -547,7 +547,7 @@ static void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
547 if (pwr_constr_elem_len != 1) 547 if (pwr_constr_elem_len != 1)
548 return; 548 return;
549 549
550 if ((*pwr_constr_elem <= conf->channel->max_power) && 550 if ((*pwr_constr_elem <= conf->channel->max_reg_power) &&
551 (*pwr_constr_elem != sdata->local->power_constr_level)) { 551 (*pwr_constr_elem != sdata->local->power_constr_level)) {
552 sdata->local->power_constr_level = *pwr_constr_elem; 552 sdata->local->power_constr_level = *pwr_constr_elem;
553 ieee80211_hw_config(sdata->local, 0); 553 ieee80211_hw_config(sdata->local, 0);
@@ -1043,7 +1043,7 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
1043 bss_info_changed |= BSS_CHANGED_BSSID; 1043 bss_info_changed |= BSS_CHANGED_BSSID;
1044 1044
1045 /* Tell the driver to monitor connection quality (if supported) */ 1045 /* Tell the driver to monitor connection quality (if supported) */
1046 if ((local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI) && 1046 if (sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI &&
1047 bss_conf->cqm_rssi_thold) 1047 bss_conf->cqm_rssi_thold)
1048 bss_info_changed |= BSS_CHANGED_CQM; 1048 bss_info_changed |= BSS_CHANGED_CQM;
1049 1049
@@ -1587,10 +1587,19 @@ static bool ieee80211_assoc_success(struct ieee80211_work *wk,
1587 return false; 1587 return false;
1588 } 1588 }
1589 1589
1590 sta_info_move_state(sta, IEEE80211_STA_AUTH); 1590 err = sta_info_move_state(sta, IEEE80211_STA_AUTH);
1591 sta_info_move_state(sta, IEEE80211_STA_ASSOC); 1591 if (!err)
1592 if (!(ifmgd->flags & IEEE80211_STA_CONTROL_PORT)) 1592 err = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
1593 sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); 1593 if (!err && !(ifmgd->flags & IEEE80211_STA_CONTROL_PORT))
1594 err = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
1595 if (err) {
1596 printk(KERN_DEBUG
1597 "%s: failed to move station %pM to desired state\n",
1598 sdata->name, sta->sta.addr);
1599 WARN_ON(__sta_info_destroy(sta));
1600 mutex_unlock(&sdata->local->sta_mtx);
1601 return false;
1602 }
1594 1603
1595 rates = 0; 1604 rates = 0;
1596 basic_rates = 0; 1605 basic_rates = 0;
@@ -1882,7 +1891,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
1882 1891
1883 if (bss_conf->cqm_rssi_thold && 1892 if (bss_conf->cqm_rssi_thold &&
1884 ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT && 1893 ifmgd->count_beacon_signal >= IEEE80211_SIGNAL_AVE_MIN_COUNT &&
1885 !(local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI)) { 1894 !(sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)) {
1886 int sig = ifmgd->ave_beacon_signal / 16; 1895 int sig = ifmgd->ave_beacon_signal / 16;
1887 int last_event = ifmgd->last_cqm_event_signal; 1896 int last_event = ifmgd->last_cqm_event_signal;
1888 int thold = bss_conf->cqm_rssi_thold; 1897 int thold = bss_conf->cqm_rssi_thold;
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 5a5a7767d541..3fef26d8898a 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -159,7 +159,6 @@ static struct rate_control_ref *rate_control_alloc(const char *name,
159 ref = kmalloc(sizeof(struct rate_control_ref), GFP_KERNEL); 159 ref = kmalloc(sizeof(struct rate_control_ref), GFP_KERNEL);
160 if (!ref) 160 if (!ref)
161 goto fail_ref; 161 goto fail_ref;
162 kref_init(&ref->kref);
163 ref->local = local; 162 ref->local = local;
164 ref->ops = ieee80211_rate_control_ops_get(name); 163 ref->ops = ieee80211_rate_control_ops_get(name);
165 if (!ref->ops) 164 if (!ref->ops)
@@ -184,11 +183,8 @@ fail_ref:
184 return NULL; 183 return NULL;
185} 184}
186 185
187static void rate_control_release(struct kref *kref) 186static void rate_control_free(struct rate_control_ref *ctrl_ref)
188{ 187{
189 struct rate_control_ref *ctrl_ref;
190
191 ctrl_ref = container_of(kref, struct rate_control_ref, kref);
192 ctrl_ref->ops->free(ctrl_ref->priv); 188 ctrl_ref->ops->free(ctrl_ref->priv);
193 189
194#ifdef CONFIG_MAC80211_DEBUGFS 190#ifdef CONFIG_MAC80211_DEBUGFS
@@ -293,8 +289,8 @@ bool rate_control_send_low(struct ieee80211_sta *sta,
293} 289}
294EXPORT_SYMBOL(rate_control_send_low); 290EXPORT_SYMBOL(rate_control_send_low);
295 291
296static void rate_idx_match_mask(struct ieee80211_tx_rate *rate, 292static bool rate_idx_match_legacy_mask(struct ieee80211_tx_rate *rate,
297 int n_bitrates, u32 mask) 293 int n_bitrates, u32 mask)
298{ 294{
299 int j; 295 int j;
300 296
@@ -303,7 +299,7 @@ static void rate_idx_match_mask(struct ieee80211_tx_rate *rate,
303 if (mask & (1 << j)) { 299 if (mask & (1 << j)) {
304 /* Okay, found a suitable rate. Use it. */ 300 /* Okay, found a suitable rate. Use it. */
305 rate->idx = j; 301 rate->idx = j;
306 return; 302 return true;
307 } 303 }
308 } 304 }
309 305
@@ -312,6 +308,112 @@ static void rate_idx_match_mask(struct ieee80211_tx_rate *rate,
312 if (mask & (1 << j)) { 308 if (mask & (1 << j)) {
313 /* Okay, found a suitable rate. Use it. */ 309 /* Okay, found a suitable rate. Use it. */
314 rate->idx = j; 310 rate->idx = j;
311 return true;
312 }
313 }
314 return false;
315}
316
317static bool rate_idx_match_mcs_mask(struct ieee80211_tx_rate *rate,
318 u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN])
319{
320 int i, j;
321 int ridx, rbit;
322
323 ridx = rate->idx / 8;
324 rbit = rate->idx % 8;
325
326 /* sanity check */
327 if (ridx < 0 || ridx > IEEE80211_HT_MCS_MASK_LEN)
328 return false;
329
330 /* See whether the selected rate or anything below it is allowed. */
331 for (i = ridx; i >= 0; i--) {
332 for (j = rbit; j >= 0; j--)
333 if (mcs_mask[i] & BIT(j)) {
334 rate->idx = i * 8 + j;
335 return true;
336 }
337 rbit = 7;
338 }
339
340 /* Try to find a higher rate that would be allowed */
341 ridx = (rate->idx + 1) / 8;
342 rbit = (rate->idx + 1) % 8;
343
344 for (i = ridx; i < IEEE80211_HT_MCS_MASK_LEN; i++) {
345 for (j = rbit; j < 8; j++)
346 if (mcs_mask[i] & BIT(j)) {
347 rate->idx = i * 8 + j;
348 return true;
349 }
350 rbit = 0;
351 }
352 return false;
353}
354
355
356
357static void rate_idx_match_mask(struct ieee80211_tx_rate *rate,
358 struct ieee80211_tx_rate_control *txrc,
359 u32 mask,
360 u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN])
361{
362 struct ieee80211_tx_rate alt_rate;
363
364 /* handle HT rates */
365 if (rate->flags & IEEE80211_TX_RC_MCS) {
366 if (rate_idx_match_mcs_mask(rate, mcs_mask))
367 return;
368
369 /* also try the legacy rates. */
370 alt_rate.idx = 0;
371 /* keep protection flags */
372 alt_rate.flags = rate->flags &
373 (IEEE80211_TX_RC_USE_RTS_CTS |
374 IEEE80211_TX_RC_USE_CTS_PROTECT |
375 IEEE80211_TX_RC_USE_SHORT_PREAMBLE);
376 alt_rate.count = rate->count;
377 if (rate_idx_match_legacy_mask(&alt_rate,
378 txrc->sband->n_bitrates,
379 mask)) {
380 *rate = alt_rate;
381 return;
382 }
383 } else {
384 struct sk_buff *skb = txrc->skb;
385 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
386 __le16 fc;
387
388 /* handle legacy rates */
389 if (rate_idx_match_legacy_mask(rate, txrc->sband->n_bitrates,
390 mask))
391 return;
392
393 /* if HT BSS, and we handle a data frame, also try HT rates */
394 if (txrc->bss_conf->channel_type == NL80211_CHAN_NO_HT)
395 return;
396
397 fc = hdr->frame_control;
398 if (!ieee80211_is_data(fc))
399 return;
400
401 alt_rate.idx = 0;
402 /* keep protection flags */
403 alt_rate.flags = rate->flags &
404 (IEEE80211_TX_RC_USE_RTS_CTS |
405 IEEE80211_TX_RC_USE_CTS_PROTECT |
406 IEEE80211_TX_RC_USE_SHORT_PREAMBLE);
407 alt_rate.count = rate->count;
408
409 alt_rate.flags |= IEEE80211_TX_RC_MCS;
410
411 if ((txrc->bss_conf->channel_type == NL80211_CHAN_HT40MINUS) ||
412 (txrc->bss_conf->channel_type == NL80211_CHAN_HT40PLUS))
413 alt_rate.flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
414
415 if (rate_idx_match_mcs_mask(&alt_rate, mcs_mask)) {
416 *rate = alt_rate;
315 return; 417 return;
316 } 418 }
317 } 419 }
@@ -335,6 +437,7 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
335 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); 437 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
336 int i; 438 int i;
337 u32 mask; 439 u32 mask;
440 u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN];
338 441
339 if (sta) { 442 if (sta) {
340 ista = &sta->sta; 443 ista = &sta->sta;
@@ -358,10 +461,14 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
358 * the common case. 461 * the common case.
359 */ 462 */
360 mask = sdata->rc_rateidx_mask[info->band]; 463 mask = sdata->rc_rateidx_mask[info->band];
464 memcpy(mcs_mask, sdata->rc_rateidx_mcs_mask[info->band],
465 sizeof(mcs_mask));
361 if (mask != (1 << txrc->sband->n_bitrates) - 1) { 466 if (mask != (1 << txrc->sband->n_bitrates) - 1) {
362 if (sta) { 467 if (sta) {
363 /* Filter out rates that the STA does not support */ 468 /* Filter out rates that the STA does not support */
364 mask &= sta->sta.supp_rates[info->band]; 469 mask &= sta->sta.supp_rates[info->band];
470 for (i = 0; i < sizeof(mcs_mask); i++)
471 mcs_mask[i] &= sta->sta.ht_cap.mcs.rx_mask[i];
365 } 472 }
366 /* 473 /*
367 * Make sure the rate index selected for each TX rate is 474 * Make sure the rate index selected for each TX rate is
@@ -372,32 +479,18 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
372 /* Skip invalid rates */ 479 /* Skip invalid rates */
373 if (info->control.rates[i].idx < 0) 480 if (info->control.rates[i].idx < 0)
374 break; 481 break;
375 /* Rate masking supports only legacy rates for now */ 482 rate_idx_match_mask(&info->control.rates[i], txrc,
376 if (info->control.rates[i].flags & IEEE80211_TX_RC_MCS) 483 mask, mcs_mask);
377 continue;
378 rate_idx_match_mask(&info->control.rates[i],
379 txrc->sband->n_bitrates, mask);
380 } 484 }
381 } 485 }
382 486
383 BUG_ON(info->control.rates[0].idx < 0); 487 BUG_ON(info->control.rates[0].idx < 0);
384} 488}
385 489
386struct rate_control_ref *rate_control_get(struct rate_control_ref *ref)
387{
388 kref_get(&ref->kref);
389 return ref;
390}
391
392void rate_control_put(struct rate_control_ref *ref)
393{
394 kref_put(&ref->kref, rate_control_release);
395}
396
397int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local, 490int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
398 const char *name) 491 const char *name)
399{ 492{
400 struct rate_control_ref *ref, *old; 493 struct rate_control_ref *ref;
401 494
402 ASSERT_RTNL(); 495 ASSERT_RTNL();
403 496
@@ -417,12 +510,8 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
417 return -ENOENT; 510 return -ENOENT;
418 } 511 }
419 512
420 old = local->rate_ctrl; 513 WARN_ON(local->rate_ctrl);
421 local->rate_ctrl = ref; 514 local->rate_ctrl = ref;
422 if (old) {
423 rate_control_put(old);
424 sta_info_flush(local, NULL);
425 }
426 515
427 wiphy_debug(local->hw.wiphy, "Selected rate control algorithm '%s'\n", 516 wiphy_debug(local->hw.wiphy, "Selected rate control algorithm '%s'\n",
428 ref->ops->name); 517 ref->ops->name);
@@ -440,6 +529,6 @@ void rate_control_deinitialize(struct ieee80211_local *local)
440 return; 529 return;
441 530
442 local->rate_ctrl = NULL; 531 local->rate_ctrl = NULL;
443 rate_control_put(ref); 532 rate_control_free(ref);
444} 533}
445 534
diff --git a/net/mac80211/rate.h b/net/mac80211/rate.h
index 168427b0ffdc..8268457bd143 100644
--- a/net/mac80211/rate.h
+++ b/net/mac80211/rate.h
@@ -14,7 +14,6 @@
14#include <linux/netdevice.h> 14#include <linux/netdevice.h>
15#include <linux/skbuff.h> 15#include <linux/skbuff.h>
16#include <linux/types.h> 16#include <linux/types.h>
17#include <linux/kref.h>
18#include <net/mac80211.h> 17#include <net/mac80211.h>
19#include "ieee80211_i.h" 18#include "ieee80211_i.h"
20#include "sta_info.h" 19#include "sta_info.h"
@@ -23,14 +22,11 @@ struct rate_control_ref {
23 struct ieee80211_local *local; 22 struct ieee80211_local *local;
24 struct rate_control_ops *ops; 23 struct rate_control_ops *ops;
25 void *priv; 24 void *priv;
26 struct kref kref;
27}; 25};
28 26
29void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, 27void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
30 struct sta_info *sta, 28 struct sta_info *sta,
31 struct ieee80211_tx_rate_control *txrc); 29 struct ieee80211_tx_rate_control *txrc);
32struct rate_control_ref *rate_control_get(struct rate_control_ref *ref);
33void rate_control_put(struct rate_control_ref *ref);
34 30
35static inline void rate_control_tx_status(struct ieee80211_local *local, 31static inline void rate_control_tx_status(struct ieee80211_local *local,
36 struct ieee80211_supported_band *sband, 32 struct ieee80211_supported_band *sband,
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 5a5e504a8ffb..b5ee0847a7e1 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1145,19 +1145,15 @@ static void ap_sta_ps_start(struct sta_info *sta)
1145 1145
1146static void ap_sta_ps_end(struct sta_info *sta) 1146static void ap_sta_ps_end(struct sta_info *sta)
1147{ 1147{
1148 struct ieee80211_sub_if_data *sdata = sta->sdata;
1149
1150 atomic_dec(&sdata->bss->num_sta_ps);
1151
1152#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 1148#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
1153 printk(KERN_DEBUG "%s: STA %pM aid %d exits power save mode\n", 1149 printk(KERN_DEBUG "%s: STA %pM aid %d exits power save mode\n",
1154 sdata->name, sta->sta.addr, sta->sta.aid); 1150 sta->sdata->name, sta->sta.addr, sta->sta.aid);
1155#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 1151#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
1156 1152
1157 if (test_sta_flag(sta, WLAN_STA_PS_DRIVER)) { 1153 if (test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
1158#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 1154#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
1159 printk(KERN_DEBUG "%s: STA %pM aid %d driver-ps-blocked\n", 1155 printk(KERN_DEBUG "%s: STA %pM aid %d driver-ps-blocked\n",
1160 sdata->name, sta->sta.addr, sta->sta.aid); 1156 sta->sdata->name, sta->sta.addr, sta->sta.aid);
1161#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */ 1157#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
1162 return; 1158 return;
1163 } 1159 }
@@ -2180,9 +2176,6 @@ ieee80211_rx_h_mgmt_check(struct ieee80211_rx_data *rx)
2180 if (rx->sdata->vif.type == NL80211_IFTYPE_AP && 2176 if (rx->sdata->vif.type == NL80211_IFTYPE_AP &&
2181 ieee80211_is_beacon(mgmt->frame_control) && 2177 ieee80211_is_beacon(mgmt->frame_control) &&
2182 !(rx->flags & IEEE80211_RX_BEACON_REPORTED)) { 2178 !(rx->flags & IEEE80211_RX_BEACON_REPORTED)) {
2183 struct ieee80211_rx_status *status;
2184
2185 status = IEEE80211_SKB_RXCB(rx->skb);
2186 cfg80211_report_obss_beacon(rx->local->hw.wiphy, 2179 cfg80211_report_obss_beacon(rx->local->hw.wiphy,
2187 rx->skb->data, rx->skb->len, 2180 rx->skb->data, rx->skb->len,
2188 status->freq, GFP_ATOMIC); 2181 status->freq, GFP_ATOMIC);
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index ff11f6bf8266..fa0823892b2d 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -208,10 +208,8 @@ struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata,
208 */ 208 */
209void sta_info_free(struct ieee80211_local *local, struct sta_info *sta) 209void sta_info_free(struct ieee80211_local *local, struct sta_info *sta)
210{ 210{
211 if (sta->rate_ctrl) { 211 if (sta->rate_ctrl)
212 rate_control_free_sta(sta); 212 rate_control_free_sta(sta);
213 rate_control_put(sta->rate_ctrl);
214 }
215 213
216#ifdef CONFIG_MAC80211_VERBOSE_DEBUG 214#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
217 wiphy_debug(local->hw.wiphy, "Destroyed STA %pM\n", sta->sta.addr); 215 wiphy_debug(local->hw.wiphy, "Destroyed STA %pM\n", sta->sta.addr);
@@ -264,13 +262,11 @@ static int sta_prepare_rate_control(struct ieee80211_local *local,
264 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) 262 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL)
265 return 0; 263 return 0;
266 264
267 sta->rate_ctrl = rate_control_get(local->rate_ctrl); 265 sta->rate_ctrl = local->rate_ctrl;
268 sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, 266 sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl,
269 &sta->sta, gfp); 267 &sta->sta, gfp);
270 if (!sta->rate_ctrl_priv) { 268 if (!sta->rate_ctrl_priv)
271 rate_control_put(sta->rate_ctrl);
272 return -ENOMEM; 269 return -ENOMEM;
273 }
274 270
275 return 0; 271 return 0;
276} 272}
@@ -407,6 +403,8 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU)
407 sta_info_hash_add(local, sta); 403 sta_info_hash_add(local, sta);
408 404
409 list_add(&sta->list, &local->sta_list); 405 list_add(&sta->list, &local->sta_list);
406
407 set_sta_flag(sta, WLAN_STA_INSERTED);
410 } else { 408 } else {
411 sta->dummy = false; 409 sta->dummy = false;
412 } 410 }
@@ -711,7 +709,7 @@ static bool sta_info_cleanup_expire_buffered(struct ieee80211_local *local,
711 return have_buffered; 709 return have_buffered;
712} 710}
713 711
714static int __must_check __sta_info_destroy(struct sta_info *sta) 712int __must_check __sta_info_destroy(struct sta_info *sta)
715{ 713{
716 struct ieee80211_local *local; 714 struct ieee80211_local *local;
717 struct ieee80211_sub_if_data *sdata; 715 struct ieee80211_sub_if_data *sdata;
@@ -726,6 +724,8 @@ static int __must_check __sta_info_destroy(struct sta_info *sta)
726 local = sta->local; 724 local = sta->local;
727 sdata = sta->sdata; 725 sdata = sta->sdata;
728 726
727 lockdep_assert_held(&local->sta_mtx);
728
729 /* 729 /*
730 * Before removing the station from the driver and 730 * Before removing the station from the driver and
731 * rate control, it might still start new aggregation 731 * rate control, it might still start new aggregation
@@ -750,25 +750,19 @@ static int __must_check __sta_info_destroy(struct sta_info *sta)
750 750
751 sta->dead = true; 751 sta->dead = true;
752 752
753 if (test_sta_flag(sta, WLAN_STA_PS_STA) ||
754 test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
755 BUG_ON(!sdata->bss);
756
757 clear_sta_flag(sta, WLAN_STA_PS_STA);
758 clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
759
760 atomic_dec(&sdata->bss->num_sta_ps);
761 sta_info_recalc_tim(sta);
762 }
763
764 local->num_sta--; 753 local->num_sta--;
765 local->sta_generation++; 754 local->sta_generation++;
766 755
767 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 756 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
768 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); 757 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
769 758
770 while (sta->sta_state > IEEE80211_STA_NONE) 759 while (sta->sta_state > IEEE80211_STA_NONE) {
771 sta_info_move_state(sta, sta->sta_state - 1); 760 int err = sta_info_move_state(sta, sta->sta_state - 1);
761 if (err) {
762 WARN_ON_ONCE(1);
763 break;
764 }
765 }
772 766
773 if (sta->uploaded) { 767 if (sta->uploaded) {
774 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 768 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
@@ -787,6 +781,15 @@ static int __must_check __sta_info_destroy(struct sta_info *sta)
787 */ 781 */
788 synchronize_rcu(); 782 synchronize_rcu();
789 783
784 if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
785 BUG_ON(!sdata->bss);
786
787 clear_sta_flag(sta, WLAN_STA_PS_STA);
788
789 atomic_dec(&sdata->bss->num_sta_ps);
790 sta_info_recalc_tim(sta);
791 }
792
790 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 793 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
791 local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]); 794 local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]);
792 __skb_queue_purge(&sta->ps_tx_buf[ac]); 795 __skb_queue_purge(&sta->ps_tx_buf[ac]);
@@ -815,35 +818,20 @@ static int __must_check __sta_info_destroy(struct sta_info *sta)
815 } 818 }
816#endif 819#endif
817 820
818 /* There could be some memory leaks because of ampdu tx pending queue 821 /*
819 * not being freed before destroying the station info. 822 * Destroy aggregation state here. It would be nice to wait for the
820 * 823 * driver to finish aggregation stop and then clean up, but for now
821 * Make sure that such queues are purged before freeing the station 824 * drivers have to handle aggregation stop being requested, followed
822 * info. 825 * directly by station destruction.
823 * TODO: We have to somehow postpone the full destruction
824 * until the aggregation stop completes. Refer
825 * http://thread.gmane.org/gmane.linux.kernel.wireless.general/81936
826 */ 826 */
827
828 mutex_lock(&sta->ampdu_mlme.mtx);
829
830 for (i = 0; i < STA_TID_NUM; i++) { 827 for (i = 0; i < STA_TID_NUM; i++) {
831 tid_tx = rcu_dereference_protected_tid_tx(sta, i); 828 tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]);
832 if (!tid_tx) 829 if (!tid_tx)
833 continue; 830 continue;
834 if (skb_queue_len(&tid_tx->pending)) { 831 __skb_queue_purge(&tid_tx->pending);
835#ifdef CONFIG_MAC80211_HT_DEBUG 832 kfree(tid_tx);
836 wiphy_debug(local->hw.wiphy, "TX A-MPDU purging %d "
837 "packets for tid=%d\n",
838 skb_queue_len(&tid_tx->pending), i);
839#endif /* CONFIG_MAC80211_HT_DEBUG */
840 __skb_queue_purge(&tid_tx->pending);
841 }
842 kfree_rcu(tid_tx, rcu_head);
843 } 833 }
844 834
845 mutex_unlock(&sta->ampdu_mlme.mtx);
846
847 sta_info_free(local, sta); 835 sta_info_free(local, sta);
848 836
849 return 0; 837 return 0;
@@ -1009,9 +997,11 @@ EXPORT_SYMBOL(ieee80211_find_sta);
1009static void clear_sta_ps_flags(void *_sta) 997static void clear_sta_ps_flags(void *_sta)
1010{ 998{
1011 struct sta_info *sta = _sta; 999 struct sta_info *sta = _sta;
1000 struct ieee80211_sub_if_data *sdata = sta->sdata;
1012 1001
1013 clear_sta_flag(sta, WLAN_STA_PS_DRIVER); 1002 clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
1014 clear_sta_flag(sta, WLAN_STA_PS_STA); 1003 if (test_and_clear_sta_flag(sta, WLAN_STA_PS_STA))
1004 atomic_dec(&sdata->bss->num_sta_ps);
1015} 1005}
1016 1006
1017/* powersave support code */ 1007/* powersave support code */
@@ -1410,8 +1400,8 @@ void ieee80211_sta_set_buffered(struct ieee80211_sta *pubsta,
1410} 1400}
1411EXPORT_SYMBOL(ieee80211_sta_set_buffered); 1401EXPORT_SYMBOL(ieee80211_sta_set_buffered);
1412 1402
1413int sta_info_move_state_checked(struct sta_info *sta, 1403int sta_info_move_state(struct sta_info *sta,
1414 enum ieee80211_sta_state new_state) 1404 enum ieee80211_sta_state new_state)
1415{ 1405{
1416 might_sleep(); 1406 might_sleep();
1417 1407
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 6f77f12dc3fc..381de37d2478 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -52,6 +52,7 @@
52 * @WLAN_STA_SP: Station is in a service period, so don't try to 52 * @WLAN_STA_SP: Station is in a service period, so don't try to
53 * reply to other uAPSD trigger frames or PS-Poll. 53 * reply to other uAPSD trigger frames or PS-Poll.
54 * @WLAN_STA_4ADDR_EVENT: 4-addr event was already sent for this frame. 54 * @WLAN_STA_4ADDR_EVENT: 4-addr event was already sent for this frame.
55 * @WLAN_STA_INSERTED: This station is inserted into the hash table.
55 */ 56 */
56enum ieee80211_sta_info_flags { 57enum ieee80211_sta_info_flags {
57 WLAN_STA_AUTH, 58 WLAN_STA_AUTH,
@@ -71,6 +72,7 @@ enum ieee80211_sta_info_flags {
71 WLAN_STA_UAPSD, 72 WLAN_STA_UAPSD,
72 WLAN_STA_SP, 73 WLAN_STA_SP,
73 WLAN_STA_4ADDR_EVENT, 74 WLAN_STA_4ADDR_EVENT,
75 WLAN_STA_INSERTED,
74}; 76};
75 77
76enum ieee80211_sta_state { 78enum ieee80211_sta_state {
@@ -427,13 +429,17 @@ static inline int test_and_set_sta_flag(struct sta_info *sta,
427 return test_and_set_bit(flag, &sta->_flags); 429 return test_and_set_bit(flag, &sta->_flags);
428} 430}
429 431
430int sta_info_move_state_checked(struct sta_info *sta, 432int sta_info_move_state(struct sta_info *sta,
431 enum ieee80211_sta_state new_state); 433 enum ieee80211_sta_state new_state);
432 434
433static inline void sta_info_move_state(struct sta_info *sta, 435static inline void sta_info_pre_move_state(struct sta_info *sta,
434 enum ieee80211_sta_state new_state) 436 enum ieee80211_sta_state new_state)
435{ 437{
436 int ret = sta_info_move_state_checked(sta, new_state); 438 int ret;
439
440 WARN_ON_ONCE(test_sta_flag(sta, WLAN_STA_INSERTED));
441
442 ret = sta_info_move_state(sta, new_state);
437 WARN_ON_ONCE(ret); 443 WARN_ON_ONCE(ret);
438} 444}
439 445
@@ -544,6 +550,7 @@ int sta_info_insert(struct sta_info *sta);
544int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU); 550int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU);
545int sta_info_reinsert(struct sta_info *sta); 551int sta_info_reinsert(struct sta_info *sta);
546 552
553int __must_check __sta_info_destroy(struct sta_info *sta);
547int sta_info_destroy_addr(struct ieee80211_sub_if_data *sdata, 554int sta_info_destroy_addr(struct ieee80211_sub_if_data *sdata,
548 const u8 *addr); 555 const u8 *addr);
549int sta_info_destroy_addr_bss(struct ieee80211_sub_if_data *sdata, 556int sta_info_destroy_addr_bss(struct ieee80211_sub_if_data *sdata,
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index 30c265c98f73..d67f0b967f8a 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -350,7 +350,6 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
350 bool send_to_cooked; 350 bool send_to_cooked;
351 bool acked; 351 bool acked;
352 struct ieee80211_bar *bar; 352 struct ieee80211_bar *bar;
353 u16 tid;
354 int rtap_len; 353 int rtap_len;
355 354
356 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { 355 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
@@ -412,7 +411,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
412 } 411 }
413 412
414 if (!acked && ieee80211_is_back_req(fc)) { 413 if (!acked && ieee80211_is_back_req(fc)) {
415 u16 control; 414 u16 tid, control;
416 415
417 /* 416 /*
418 * BAR failed, store the last SSN and retry sending 417 * BAR failed, store the last SSN and retry sending
@@ -516,7 +515,8 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
516 515
517 if (ieee80211_is_nullfunc(hdr->frame_control) || 516 if (ieee80211_is_nullfunc(hdr->frame_control) ||
518 ieee80211_is_qos_nullfunc(hdr->frame_control)) { 517 ieee80211_is_qos_nullfunc(hdr->frame_control)) {
519 bool acked = info->flags & IEEE80211_TX_STAT_ACK; 518 acked = info->flags & IEEE80211_TX_STAT_ACK;
519
520 cfg80211_probe_status(skb->dev, hdr->addr1, 520 cfg80211_probe_status(skb->dev, hdr->addr1,
521 cookie, acked, GFP_ATOMIC); 521 cookie, acked, GFP_ATOMIC);
522 } else { 522 } else {
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index e05667cd5e76..1be0ca2b5936 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -635,6 +635,9 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
635 txrc.max_rate_idx = -1; 635 txrc.max_rate_idx = -1;
636 else 636 else
637 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1; 637 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
638 memcpy(txrc.rate_idx_mcs_mask,
639 tx->sdata->rc_rateidx_mcs_mask[tx->channel->band],
640 sizeof(txrc.rate_idx_mcs_mask));
638 txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP || 641 txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP ||
639 tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT || 642 tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
640 tx->sdata->vif.type == NL80211_IFTYPE_ADHOC); 643 tx->sdata->vif.type == NL80211_IFTYPE_ADHOC);
@@ -2431,6 +2434,8 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw,
2431 txrc.max_rate_idx = -1; 2434 txrc.max_rate_idx = -1;
2432 else 2435 else
2433 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1; 2436 txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
2437 memcpy(txrc.rate_idx_mcs_mask, sdata->rc_rateidx_mcs_mask[band],
2438 sizeof(txrc.rate_idx_mcs_mask));
2434 txrc.bss = true; 2439 txrc.bss = true;
2435 rate_control_get_rate(sdata, NULL, &txrc); 2440 rate_control_get_rate(sdata, NULL, &txrc);
2436 2441
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 9919892575f4..d82d886d0867 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -862,8 +862,8 @@ u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
862 862
863void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, 863void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
864 u16 transaction, u16 auth_alg, 864 u16 transaction, u16 auth_alg,
865 u8 *extra, size_t extra_len, const u8 *bssid, 865 u8 *extra, size_t extra_len, const u8 *da,
866 const u8 *key, u8 key_len, u8 key_idx) 866 const u8 *bssid, const u8 *key, u8 key_len, u8 key_idx)
867{ 867{
868 struct ieee80211_local *local = sdata->local; 868 struct ieee80211_local *local = sdata->local;
869 struct sk_buff *skb; 869 struct sk_buff *skb;
@@ -881,7 +881,7 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
881 memset(mgmt, 0, 24 + 6); 881 memset(mgmt, 0, 24 + 6);
882 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 882 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
883 IEEE80211_STYPE_AUTH); 883 IEEE80211_STYPE_AUTH);
884 memcpy(mgmt->da, bssid, ETH_ALEN); 884 memcpy(mgmt->da, da, ETH_ALEN);
885 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); 885 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
886 memcpy(mgmt->bssid, bssid, ETH_ALEN); 886 memcpy(mgmt->bssid, bssid, ETH_ALEN);
887 mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg); 887 mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg);
@@ -1272,6 +1272,21 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1272 ieee80211_recalc_ps(local, -1); 1272 ieee80211_recalc_ps(local, -1);
1273 1273
1274 /* 1274 /*
1275 * The sta might be in psm against the ap (e.g. because
1276 * this was the state before a hw restart), so we
1277 * explicitly send a null packet in order to make sure
1278 * it'll sync against the ap (and get out of psm).
1279 */
1280 if (!(local->hw.conf.flags & IEEE80211_CONF_PS)) {
1281 list_for_each_entry(sdata, &local->interfaces, list) {
1282 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1283 continue;
1284
1285 ieee80211_send_nullfunc(local, sdata, 0);
1286 }
1287 }
1288
1289 /*
1275 * Clear the WLAN_STA_BLOCK_BA flag so new aggregation 1290 * Clear the WLAN_STA_BLOCK_BA flag so new aggregation
1276 * sessions can be established after a resume. 1291 * sessions can be established after a resume.
1277 * 1292 *
diff --git a/net/mac80211/work.c b/net/mac80211/work.c
index c6dd01a05291..0a1a176fbe91 100644
--- a/net/mac80211/work.c
+++ b/net/mac80211/work.c
@@ -480,7 +480,8 @@ ieee80211_authenticate(struct ieee80211_work *wk)
480 sdata->name, wk->filter_ta, wk->probe_auth.tries); 480 sdata->name, wk->filter_ta, wk->probe_auth.tries);
481 481
482 ieee80211_send_auth(sdata, 1, wk->probe_auth.algorithm, wk->ie, 482 ieee80211_send_auth(sdata, 1, wk->probe_auth.algorithm, wk->ie,
483 wk->ie_len, wk->filter_ta, NULL, 0, 0); 483 wk->ie_len, wk->filter_ta, wk->filter_ta, NULL, 0,
484 0);
484 wk->probe_auth.transaction = 2; 485 wk->probe_auth.transaction = 2;
485 486
486 wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; 487 wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
@@ -598,7 +599,7 @@ static void ieee80211_auth_challenge(struct ieee80211_work *wk,
598 return; 599 return;
599 ieee80211_send_auth(sdata, 3, wk->probe_auth.algorithm, 600 ieee80211_send_auth(sdata, 3, wk->probe_auth.algorithm,
600 elems.challenge - 2, elems.challenge_len + 2, 601 elems.challenge - 2, elems.challenge_len + 2,
601 wk->filter_ta, wk->probe_auth.key, 602 wk->filter_ta, wk->filter_ta, wk->probe_auth.key,
602 wk->probe_auth.key_len, wk->probe_auth.key_idx); 603 wk->probe_auth.key_len, wk->probe_auth.key_idx);
603 wk->probe_auth.transaction = 4; 604 wk->probe_auth.transaction = 4;
604} 605}
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 629b06182f3f..4d751e3d4b4b 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1645,6 +1645,24 @@ static void netlink_destroy_callback(struct netlink_callback *cb)
1645 kfree(cb); 1645 kfree(cb);
1646} 1646}
1647 1647
1648struct nlmsghdr *
1649__nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
1650{
1651 struct nlmsghdr *nlh;
1652 int size = NLMSG_LENGTH(len);
1653
1654 nlh = (struct nlmsghdr*)skb_put(skb, NLMSG_ALIGN(size));
1655 nlh->nlmsg_type = type;
1656 nlh->nlmsg_len = size;
1657 nlh->nlmsg_flags = flags;
1658 nlh->nlmsg_pid = pid;
1659 nlh->nlmsg_seq = seq;
1660 if (!__builtin_constant_p(size) || NLMSG_ALIGN(size) - size != 0)
1661 memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size);
1662 return nlh;
1663}
1664EXPORT_SYMBOL(__nlmsg_put);
1665
1648/* 1666/*
1649 * It looks a bit ugly. 1667 * It looks a bit ugly.
1650 * It would be better to create kernel thread. 1668 * It would be better to create kernel thread.
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index c29d2568c9e0..a1154717219e 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -498,6 +498,37 @@ int genl_unregister_family(struct genl_family *family)
498} 498}
499EXPORT_SYMBOL(genl_unregister_family); 499EXPORT_SYMBOL(genl_unregister_family);
500 500
501/**
502 * genlmsg_put - Add generic netlink header to netlink message
503 * @skb: socket buffer holding the message
504 * @pid: netlink pid the message is addressed to
505 * @seq: sequence number (usually the one of the sender)
506 * @family: generic netlink family
507 * @flags netlink message flags
508 * @cmd: generic netlink command
509 *
510 * Returns pointer to user specific header
511 */
512void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq,
513 struct genl_family *family, int flags, u8 cmd)
514{
515 struct nlmsghdr *nlh;
516 struct genlmsghdr *hdr;
517
518 nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN +
519 family->hdrsize, flags);
520 if (nlh == NULL)
521 return NULL;
522
523 hdr = nlmsg_data(nlh);
524 hdr->cmd = cmd;
525 hdr->version = family->version;
526 hdr->reserved = 0;
527
528 return (char *) hdr + GENL_HDRLEN;
529}
530EXPORT_SYMBOL(genlmsg_put);
531
501static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) 532static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
502{ 533{
503 struct genl_ops *ops; 534 struct genl_ops *ops;
diff --git a/net/nfc/core.c b/net/nfc/core.c
index 3ddf6e698df0..6089aca67b14 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -431,15 +431,10 @@ EXPORT_SYMBOL(nfc_alloc_recv_skb);
431int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets, 431int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets,
432 int n_targets) 432 int n_targets)
433{ 433{
434 int i;
435
436 pr_debug("dev_name=%s n_targets=%d\n", dev_name(&dev->dev), n_targets); 434 pr_debug("dev_name=%s n_targets=%d\n", dev_name(&dev->dev), n_targets);
437 435
438 dev->polling = false; 436 dev->polling = false;
439 437
440 for (i = 0; i < n_targets; i++)
441 targets[i].idx = dev->target_idx++;
442
443 spin_lock_bh(&dev->targets_lock); 438 spin_lock_bh(&dev->targets_lock);
444 439
445 dev->targets_generation++; 440 dev->targets_generation++;
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 7650139a1a05..a47e90c7d9d1 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -216,6 +216,39 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt)
216 &cmd); 216 &cmd);
217} 217}
218 218
219struct nci_rf_discover_select_param {
220 __u8 rf_discovery_id;
221 __u8 rf_protocol;
222};
223
224static void nci_rf_discover_select_req(struct nci_dev *ndev, unsigned long opt)
225{
226 struct nci_rf_discover_select_param *param =
227 (struct nci_rf_discover_select_param *)opt;
228 struct nci_rf_discover_select_cmd cmd;
229
230 cmd.rf_discovery_id = param->rf_discovery_id;
231 cmd.rf_protocol = param->rf_protocol;
232
233 switch (cmd.rf_protocol) {
234 case NCI_RF_PROTOCOL_ISO_DEP:
235 cmd.rf_interface = NCI_RF_INTERFACE_ISO_DEP;
236 break;
237
238 case NCI_RF_PROTOCOL_NFC_DEP:
239 cmd.rf_interface = NCI_RF_INTERFACE_NFC_DEP;
240 break;
241
242 default:
243 cmd.rf_interface = NCI_RF_INTERFACE_FRAME;
244 break;
245 }
246
247 nci_send_cmd(ndev, NCI_OP_RF_DISCOVER_SELECT_CMD,
248 sizeof(struct nci_rf_discover_select_cmd),
249 &cmd);
250}
251
219static void nci_rf_deactivate_req(struct nci_dev *ndev, unsigned long opt) 252static void nci_rf_deactivate_req(struct nci_dev *ndev, unsigned long opt)
220{ 253{
221 struct nci_rf_deactivate_cmd cmd; 254 struct nci_rf_deactivate_cmd cmd;
@@ -264,6 +297,8 @@ static int nci_open_device(struct nci_dev *ndev)
264 297
265 if (!rc) { 298 if (!rc) {
266 set_bit(NCI_UP, &ndev->flags); 299 set_bit(NCI_UP, &ndev->flags);
300 nci_clear_target_list(ndev);
301 atomic_set(&ndev->state, NCI_IDLE);
267 } else { 302 } else {
268 /* Init failed, cleanup */ 303 /* Init failed, cleanup */
269 skb_queue_purge(&ndev->cmd_q); 304 skb_queue_purge(&ndev->cmd_q);
@@ -286,6 +321,7 @@ static int nci_close_device(struct nci_dev *ndev)
286 321
287 if (!test_and_clear_bit(NCI_UP, &ndev->flags)) { 322 if (!test_and_clear_bit(NCI_UP, &ndev->flags)) {
288 del_timer_sync(&ndev->cmd_timer); 323 del_timer_sync(&ndev->cmd_timer);
324 del_timer_sync(&ndev->data_timer);
289 mutex_unlock(&ndev->req_lock); 325 mutex_unlock(&ndev->req_lock);
290 return 0; 326 return 0;
291 } 327 }
@@ -331,6 +367,15 @@ static void nci_cmd_timer(unsigned long arg)
331 queue_work(ndev->cmd_wq, &ndev->cmd_work); 367 queue_work(ndev->cmd_wq, &ndev->cmd_work);
332} 368}
333 369
370/* NCI data exchange timer function */
371static void nci_data_timer(unsigned long arg)
372{
373 struct nci_dev *ndev = (void *) arg;
374
375 set_bit(NCI_DATA_EXCHANGE_TO, &ndev->flags);
376 queue_work(ndev->rx_wq, &ndev->rx_work);
377}
378
334static int nci_dev_up(struct nfc_dev *nfc_dev) 379static int nci_dev_up(struct nfc_dev *nfc_dev)
335{ 380{
336 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 381 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
@@ -350,7 +395,8 @@ static int nci_start_poll(struct nfc_dev *nfc_dev, __u32 protocols)
350 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 395 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
351 int rc; 396 int rc;
352 397
353 if (test_bit(NCI_DISCOVERY, &ndev->flags)) { 398 if ((atomic_read(&ndev->state) == NCI_DISCOVERY) ||
399 (atomic_read(&ndev->state) == NCI_W4_ALL_DISCOVERIES)) {
354 pr_err("unable to start poll, since poll is already active\n"); 400 pr_err("unable to start poll, since poll is already active\n");
355 return -EBUSY; 401 return -EBUSY;
356 } 402 }
@@ -360,8 +406,9 @@ static int nci_start_poll(struct nfc_dev *nfc_dev, __u32 protocols)
360 return -EBUSY; 406 return -EBUSY;
361 } 407 }
362 408
363 if (test_bit(NCI_POLL_ACTIVE, &ndev->flags)) { 409 if ((atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) ||
364 pr_debug("target is active, implicitly deactivate...\n"); 410 (atomic_read(&ndev->state) == NCI_POLL_ACTIVE)) {
411 pr_debug("target active or w4 select, implicitly deactivate\n");
365 412
366 rc = nci_request(ndev, nci_rf_deactivate_req, 0, 413 rc = nci_request(ndev, nci_rf_deactivate_req, 0,
367 msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); 414 msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
@@ -382,7 +429,8 @@ static void nci_stop_poll(struct nfc_dev *nfc_dev)
382{ 429{
383 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 430 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
384 431
385 if (!test_bit(NCI_DISCOVERY, &ndev->flags)) { 432 if ((atomic_read(&ndev->state) != NCI_DISCOVERY) &&
433 (atomic_read(&ndev->state) != NCI_W4_ALL_DISCOVERIES)) {
386 pr_err("unable to stop poll, since poll is not active\n"); 434 pr_err("unable to stop poll, since poll is not active\n");
387 return; 435 return;
388 } 436 }
@@ -395,10 +443,15 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx,
395 __u32 protocol) 443 __u32 protocol)
396{ 444{
397 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); 445 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
446 struct nci_rf_discover_select_param param;
447 struct nfc_target *target = NULL;
448 int i;
449 int rc = 0;
398 450
399 pr_debug("target_idx %d, protocol 0x%x\n", target_idx, protocol); 451 pr_debug("target_idx %d, protocol 0x%x\n", target_idx, protocol);
400 452
401 if (!test_bit(NCI_POLL_ACTIVE, &ndev->flags)) { 453 if ((atomic_read(&ndev->state) != NCI_W4_HOST_SELECT) &&
454 (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) {
402 pr_err("there is no available target to activate\n"); 455 pr_err("there is no available target to activate\n");
403 return -EINVAL; 456 return -EINVAL;
404 } 457 }
@@ -408,16 +461,47 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx,
408 return -EBUSY; 461 return -EBUSY;
409 } 462 }
410 463
411 if (!(ndev->target_available_prots & (1 << protocol))) { 464 for (i = 0; i < ndev->n_targets; i++) {
465 if (ndev->targets[i].idx == target_idx) {
466 target = &ndev->targets[i];
467 break;
468 }
469 }
470
471 if (!target) {
472 pr_err("unable to find the selected target\n");
473 return -EINVAL;
474 }
475
476 if (!(target->supported_protocols & (1 << protocol))) {
412 pr_err("target does not support the requested protocol 0x%x\n", 477 pr_err("target does not support the requested protocol 0x%x\n",
413 protocol); 478 protocol);
414 return -EINVAL; 479 return -EINVAL;
415 } 480 }
416 481
417 ndev->target_active_prot = protocol; 482 if (atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) {
418 ndev->target_available_prots = 0; 483 param.rf_discovery_id = target->idx;
419 484
420 return 0; 485 if (protocol == NFC_PROTO_JEWEL)
486 param.rf_protocol = NCI_RF_PROTOCOL_T1T;
487 else if (protocol == NFC_PROTO_MIFARE)
488 param.rf_protocol = NCI_RF_PROTOCOL_T2T;
489 else if (protocol == NFC_PROTO_FELICA)
490 param.rf_protocol = NCI_RF_PROTOCOL_T3T;
491 else if (protocol == NFC_PROTO_ISO14443)
492 param.rf_protocol = NCI_RF_PROTOCOL_ISO_DEP;
493 else
494 param.rf_protocol = NCI_RF_PROTOCOL_NFC_DEP;
495
496 rc = nci_request(ndev, nci_rf_discover_select_req,
497 (unsigned long)&param,
498 msecs_to_jiffies(NCI_RF_DISC_SELECT_TIMEOUT));
499 }
500
501 if (!rc)
502 ndev->target_active_prot = protocol;
503
504 return rc;
421} 505}
422 506
423static void nci_deactivate_target(struct nfc_dev *nfc_dev, __u32 target_idx) 507static void nci_deactivate_target(struct nfc_dev *nfc_dev, __u32 target_idx)
@@ -433,7 +517,7 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev, __u32 target_idx)
433 517
434 ndev->target_active_prot = 0; 518 ndev->target_active_prot = 0;
435 519
436 if (test_bit(NCI_POLL_ACTIVE, &ndev->flags)) { 520 if (atomic_read(&ndev->state) == NCI_POLL_ACTIVE) {
437 nci_request(ndev, nci_rf_deactivate_req, 0, 521 nci_request(ndev, nci_rf_deactivate_req, 0,
438 msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT)); 522 msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
439 } 523 }
@@ -585,6 +669,8 @@ int nci_register_device(struct nci_dev *ndev)
585 669
586 setup_timer(&ndev->cmd_timer, nci_cmd_timer, 670 setup_timer(&ndev->cmd_timer, nci_cmd_timer,
587 (unsigned long) ndev); 671 (unsigned long) ndev);
672 setup_timer(&ndev->data_timer, nci_data_timer,
673 (unsigned long) ndev);
588 674
589 mutex_init(&ndev->req_lock); 675 mutex_init(&ndev->req_lock);
590 676
@@ -722,6 +808,9 @@ static void nci_tx_work(struct work_struct *work)
722 nci_plen(skb->data)); 808 nci_plen(skb->data));
723 809
724 nci_send_frame(skb); 810 nci_send_frame(skb);
811
812 mod_timer(&ndev->data_timer,
813 jiffies + msecs_to_jiffies(NCI_DATA_TIMEOUT));
725 } 814 }
726} 815}
727 816
@@ -753,6 +842,15 @@ static void nci_rx_work(struct work_struct *work)
753 break; 842 break;
754 } 843 }
755 } 844 }
845
846 /* check if a data exchange timout has occurred */
847 if (test_bit(NCI_DATA_EXCHANGE_TO, &ndev->flags)) {
848 /* complete the data exchange transaction, if exists */
849 if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags))
850 nci_data_exchange_complete(ndev, NULL, -ETIMEDOUT);
851
852 clear_bit(NCI_DATA_EXCHANGE_TO, &ndev->flags);
853 }
756} 854}
757 855
758/* ----- NCI TX CMD worker thread ----- */ 856/* ----- NCI TX CMD worker thread ----- */
diff --git a/net/nfc/nci/data.c b/net/nfc/nci/data.c
index e5756b30e602..7880ae924d5e 100644
--- a/net/nfc/nci/data.c
+++ b/net/nfc/nci/data.c
@@ -44,6 +44,10 @@ void nci_data_exchange_complete(struct nci_dev *ndev,
44 44
45 pr_debug("len %d, err %d\n", skb ? skb->len : 0, err); 45 pr_debug("len %d, err %d\n", skb ? skb->len : 0, err);
46 46
47 /* data exchange is complete, stop the data timer */
48 del_timer_sync(&ndev->data_timer);
49 clear_bit(NCI_DATA_EXCHANGE_TO, &ndev->flags);
50
47 if (cb) { 51 if (cb) {
48 ndev->data_exchange_cb = NULL; 52 ndev->data_exchange_cb = NULL;
49 ndev->data_exchange_cb_context = 0; 53 ndev->data_exchange_cb_context = 0;
diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c
index b16a8dc2afbe..03e7b4626a3e 100644
--- a/net/nfc/nci/ntf.c
+++ b/net/nfc/nci/ntf.c
@@ -71,6 +71,20 @@ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev,
71 queue_work(ndev->tx_wq, &ndev->tx_work); 71 queue_work(ndev->tx_wq, &ndev->tx_work);
72} 72}
73 73
74static void nci_core_generic_error_ntf_packet(struct nci_dev *ndev,
75 struct sk_buff *skb)
76{
77 __u8 status = skb->data[0];
78
79 pr_debug("status 0x%x\n", status);
80
81 if (atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) {
82 /* Activation failed, so complete the request
83 (the state remains the same) */
84 nci_req_complete(ndev, status);
85 }
86}
87
74static void nci_core_conn_intf_error_ntf_packet(struct nci_dev *ndev, 88static void nci_core_conn_intf_error_ntf_packet(struct nci_dev *ndev,
75 struct sk_buff *skb) 89 struct sk_buff *skb)
76{ 90{
@@ -86,12 +100,9 @@ static void nci_core_conn_intf_error_ntf_packet(struct nci_dev *ndev,
86} 100}
87 101
88static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev, 102static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev,
89 struct nci_rf_intf_activated_ntf *ntf, __u8 *data) 103 struct rf_tech_specific_params_nfca_poll *nfca_poll,
104 __u8 *data)
90{ 105{
91 struct rf_tech_specific_params_nfca_poll *nfca_poll;
92
93 nfca_poll = &ntf->rf_tech_specific_params.nfca_poll;
94
95 nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data)); 106 nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data));
96 data += 2; 107 data += 2;
97 108
@@ -115,15 +126,213 @@ static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev,
115 return data; 126 return data;
116} 127}
117 128
129static __u8 *nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev,
130 struct rf_tech_specific_params_nfcb_poll *nfcb_poll,
131 __u8 *data)
132{
133 nfcb_poll->sensb_res_len = *data++;
134
135 pr_debug("sensb_res_len %d\n", nfcb_poll->sensb_res_len);
136
137 memcpy(nfcb_poll->sensb_res, data, nfcb_poll->sensb_res_len);
138 data += nfcb_poll->sensb_res_len;
139
140 return data;
141}
142
143static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev,
144 struct rf_tech_specific_params_nfcf_poll *nfcf_poll,
145 __u8 *data)
146{
147 nfcf_poll->bit_rate = *data++;
148 nfcf_poll->sensf_res_len = *data++;
149
150 pr_debug("bit_rate %d, sensf_res_len %d\n",
151 nfcf_poll->bit_rate, nfcf_poll->sensf_res_len);
152
153 memcpy(nfcf_poll->sensf_res, data, nfcf_poll->sensf_res_len);
154 data += nfcf_poll->sensf_res_len;
155
156 return data;
157}
158
159static int nci_add_new_protocol(struct nci_dev *ndev,
160 struct nfc_target *target,
161 __u8 rf_protocol,
162 __u8 rf_tech_and_mode,
163 void *params)
164{
165 struct rf_tech_specific_params_nfca_poll *nfca_poll;
166 struct rf_tech_specific_params_nfcb_poll *nfcb_poll;
167 struct rf_tech_specific_params_nfcf_poll *nfcf_poll;
168 __u32 protocol;
169
170 if (rf_protocol == NCI_RF_PROTOCOL_T2T)
171 protocol = NFC_PROTO_MIFARE_MASK;
172 else if (rf_protocol == NCI_RF_PROTOCOL_ISO_DEP)
173 protocol = NFC_PROTO_ISO14443_MASK;
174 else if (rf_protocol == NCI_RF_PROTOCOL_T3T)
175 protocol = NFC_PROTO_FELICA_MASK;
176 else
177 protocol = 0;
178
179 if (!(protocol & ndev->poll_prots)) {
180 pr_err("the target found does not have the desired protocol\n");
181 return -EPROTO;
182 }
183
184 if (rf_tech_and_mode == NCI_NFC_A_PASSIVE_POLL_MODE) {
185 nfca_poll = (struct rf_tech_specific_params_nfca_poll *)params;
186
187 target->sens_res = nfca_poll->sens_res;
188 target->sel_res = nfca_poll->sel_res;
189 target->nfcid1_len = nfca_poll->nfcid1_len;
190 if (target->nfcid1_len > 0) {
191 memcpy(target->nfcid1, nfca_poll->nfcid1,
192 target->nfcid1_len);
193 }
194 } else if (rf_tech_and_mode == NCI_NFC_B_PASSIVE_POLL_MODE) {
195 nfcb_poll = (struct rf_tech_specific_params_nfcb_poll *)params;
196
197 target->sensb_res_len = nfcb_poll->sensb_res_len;
198 if (target->sensb_res_len > 0) {
199 memcpy(target->sensb_res, nfcb_poll->sensb_res,
200 target->sensb_res_len);
201 }
202 } else if (rf_tech_and_mode == NCI_NFC_F_PASSIVE_POLL_MODE) {
203 nfcf_poll = (struct rf_tech_specific_params_nfcf_poll *)params;
204
205 target->sensf_res_len = nfcf_poll->sensf_res_len;
206 if (target->sensf_res_len > 0) {
207 memcpy(target->sensf_res, nfcf_poll->sensf_res,
208 target->sensf_res_len);
209 }
210 } else {
211 pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode);
212 return -EPROTO;
213 }
214
215 target->supported_protocols |= protocol;
216
217 pr_debug("protocol 0x%x\n", protocol);
218
219 return 0;
220}
221
222static void nci_add_new_target(struct nci_dev *ndev,
223 struct nci_rf_discover_ntf *ntf)
224{
225 struct nfc_target *target;
226 int i, rc;
227
228 for (i = 0; i < ndev->n_targets; i++) {
229 target = &ndev->targets[i];
230 if (target->idx == ntf->rf_discovery_id) {
231 /* This target already exists, add the new protocol */
232 nci_add_new_protocol(ndev, target, ntf->rf_protocol,
233 ntf->rf_tech_and_mode,
234 &ntf->rf_tech_specific_params);
235 return;
236 }
237 }
238
239 /* This is a new target, check if we've enough room */
240 if (ndev->n_targets == NCI_MAX_DISCOVERED_TARGETS) {
241 pr_debug("not enough room, ignoring new target...\n");
242 return;
243 }
244
245 target = &ndev->targets[ndev->n_targets];
246
247 rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol,
248 ntf->rf_tech_and_mode,
249 &ntf->rf_tech_specific_params);
250 if (!rc) {
251 target->idx = ntf->rf_discovery_id;
252 ndev->n_targets++;
253
254 pr_debug("target_idx %d, n_targets %d\n", target->idx,
255 ndev->n_targets);
256 }
257}
258
259void nci_clear_target_list(struct nci_dev *ndev)
260{
261 memset(ndev->targets, 0,
262 (sizeof(struct nfc_target)*NCI_MAX_DISCOVERED_TARGETS));
263
264 ndev->n_targets = 0;
265}
266
267static void nci_rf_discover_ntf_packet(struct nci_dev *ndev,
268 struct sk_buff *skb)
269{
270 struct nci_rf_discover_ntf ntf;
271 __u8 *data = skb->data;
272 bool add_target = true;
273
274 ntf.rf_discovery_id = *data++;
275 ntf.rf_protocol = *data++;
276 ntf.rf_tech_and_mode = *data++;
277 ntf.rf_tech_specific_params_len = *data++;
278
279 pr_debug("rf_discovery_id %d\n", ntf.rf_discovery_id);
280 pr_debug("rf_protocol 0x%x\n", ntf.rf_protocol);
281 pr_debug("rf_tech_and_mode 0x%x\n", ntf.rf_tech_and_mode);
282 pr_debug("rf_tech_specific_params_len %d\n",
283 ntf.rf_tech_specific_params_len);
284
285 if (ntf.rf_tech_specific_params_len > 0) {
286 switch (ntf.rf_tech_and_mode) {
287 case NCI_NFC_A_PASSIVE_POLL_MODE:
288 data = nci_extract_rf_params_nfca_passive_poll(ndev,
289 &(ntf.rf_tech_specific_params.nfca_poll), data);
290 break;
291
292 case NCI_NFC_B_PASSIVE_POLL_MODE:
293 data = nci_extract_rf_params_nfcb_passive_poll(ndev,
294 &(ntf.rf_tech_specific_params.nfcb_poll), data);
295 break;
296
297 case NCI_NFC_F_PASSIVE_POLL_MODE:
298 data = nci_extract_rf_params_nfcf_passive_poll(ndev,
299 &(ntf.rf_tech_specific_params.nfcf_poll), data);
300 break;
301
302 default:
303 pr_err("unsupported rf_tech_and_mode 0x%x\n",
304 ntf.rf_tech_and_mode);
305 data += ntf.rf_tech_specific_params_len;
306 add_target = false;
307 }
308 }
309
310 ntf.ntf_type = *data++;
311 pr_debug("ntf_type %d\n", ntf.ntf_type);
312
313 if (add_target == true)
314 nci_add_new_target(ndev, &ntf);
315
316 if (ntf.ntf_type == NCI_DISCOVER_NTF_TYPE_MORE) {
317 atomic_set(&ndev->state, NCI_W4_ALL_DISCOVERIES);
318 } else {
319 atomic_set(&ndev->state, NCI_W4_HOST_SELECT);
320 nfc_targets_found(ndev->nfc_dev, ndev->targets,
321 ndev->n_targets);
322 }
323}
324
118static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev, 325static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev,
119 struct nci_rf_intf_activated_ntf *ntf, __u8 *data) 326 struct nci_rf_intf_activated_ntf *ntf, __u8 *data)
120{ 327{
121 struct activation_params_nfca_poll_iso_dep *nfca_poll; 328 struct activation_params_nfca_poll_iso_dep *nfca_poll;
329 struct activation_params_nfcb_poll_iso_dep *nfcb_poll;
122 330
123 switch (ntf->activation_rf_tech_and_mode) { 331 switch (ntf->activation_rf_tech_and_mode) {
124 case NCI_NFC_A_PASSIVE_POLL_MODE: 332 case NCI_NFC_A_PASSIVE_POLL_MODE:
125 nfca_poll = &ntf->activation_params.nfca_poll_iso_dep; 333 nfca_poll = &ntf->activation_params.nfca_poll_iso_dep;
126 nfca_poll->rats_res_len = *data++; 334 nfca_poll->rats_res_len = *data++;
335 pr_debug("rats_res_len %d\n", nfca_poll->rats_res_len);
127 if (nfca_poll->rats_res_len > 0) { 336 if (nfca_poll->rats_res_len > 0) {
128 memcpy(nfca_poll->rats_res, 337 memcpy(nfca_poll->rats_res,
129 data, 338 data,
@@ -131,52 +340,47 @@ static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev,
131 } 340 }
132 break; 341 break;
133 342
343 case NCI_NFC_B_PASSIVE_POLL_MODE:
344 nfcb_poll = &ntf->activation_params.nfcb_poll_iso_dep;
345 nfcb_poll->attrib_res_len = *data++;
346 pr_debug("attrib_res_len %d\n",
347 nfcb_poll->attrib_res_len);
348 if (nfcb_poll->attrib_res_len > 0) {
349 memcpy(nfcb_poll->attrib_res,
350 data,
351 nfcb_poll->attrib_res_len);
352 }
353 break;
354
134 default: 355 default:
135 pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", 356 pr_err("unsupported activation_rf_tech_and_mode 0x%x\n",
136 ntf->activation_rf_tech_and_mode); 357 ntf->activation_rf_tech_and_mode);
137 return -EPROTO; 358 return NCI_STATUS_RF_PROTOCOL_ERROR;
138 } 359 }
139 360
140 return 0; 361 return NCI_STATUS_OK;
141} 362}
142 363
143static void nci_target_found(struct nci_dev *ndev, 364static void nci_target_auto_activated(struct nci_dev *ndev,
144 struct nci_rf_intf_activated_ntf *ntf) 365 struct nci_rf_intf_activated_ntf *ntf)
145{ 366{
146 struct nfc_target nfc_tgt; 367 struct nfc_target *target;
368 int rc;
147 369
148 if (ntf->rf_protocol == NCI_RF_PROTOCOL_T2T) /* T2T MifareUL */ 370 target = &ndev->targets[ndev->n_targets];
149 nfc_tgt.supported_protocols = NFC_PROTO_MIFARE_MASK;
150 else if (ntf->rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) /* 4A */
151 nfc_tgt.supported_protocols = NFC_PROTO_ISO14443_MASK;
152 else
153 nfc_tgt.supported_protocols = 0;
154
155 nfc_tgt.sens_res = ntf->rf_tech_specific_params.nfca_poll.sens_res;
156 nfc_tgt.sel_res = ntf->rf_tech_specific_params.nfca_poll.sel_res;
157 nfc_tgt.nfcid1_len = ntf->rf_tech_specific_params.nfca_poll.nfcid1_len;
158 if (nfc_tgt.nfcid1_len > 0) {
159 memcpy(nfc_tgt.nfcid1,
160 ntf->rf_tech_specific_params.nfca_poll.nfcid1,
161 nfc_tgt.nfcid1_len);
162 }
163 371
164 if (!(nfc_tgt.supported_protocols & ndev->poll_prots)) { 372 rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol,
165 pr_debug("the target found does not have the desired protocol\n"); 373 ntf->activation_rf_tech_and_mode,
374 &ntf->rf_tech_specific_params);
375 if (rc)
166 return; 376 return;
167 }
168 377
169 pr_debug("new target found, supported_protocols 0x%x\n", 378 target->idx = ntf->rf_discovery_id;
170 nfc_tgt.supported_protocols); 379 ndev->n_targets++;
171 380
172 ndev->target_available_prots = nfc_tgt.supported_protocols; 381 pr_debug("target_idx %d, n_targets %d\n", target->idx, ndev->n_targets);
173 ndev->max_data_pkt_payload_size = ntf->max_data_pkt_payload_size;
174 ndev->initial_num_credits = ntf->initial_num_credits;
175 382
176 /* set the available credits to initial value */ 383 nfc_targets_found(ndev->nfc_dev, ndev->targets, ndev->n_targets);
177 atomic_set(&ndev->credits_cnt, ndev->initial_num_credits);
178
179 nfc_targets_found(ndev->nfc_dev, &nfc_tgt, 1);
180} 384}
181 385
182static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, 386static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
@@ -184,10 +388,7 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
184{ 388{
185 struct nci_rf_intf_activated_ntf ntf; 389 struct nci_rf_intf_activated_ntf ntf;
186 __u8 *data = skb->data; 390 __u8 *data = skb->data;
187 int err = 0; 391 int err = NCI_STATUS_OK;
188
189 clear_bit(NCI_DISCOVERY, &ndev->flags);
190 set_bit(NCI_POLL_ACTIVE, &ndev->flags);
191 392
192 ntf.rf_discovery_id = *data++; 393 ntf.rf_discovery_id = *data++;
193 ntf.rf_interface = *data++; 394 ntf.rf_interface = *data++;
@@ -212,13 +413,24 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
212 switch (ntf.activation_rf_tech_and_mode) { 413 switch (ntf.activation_rf_tech_and_mode) {
213 case NCI_NFC_A_PASSIVE_POLL_MODE: 414 case NCI_NFC_A_PASSIVE_POLL_MODE:
214 data = nci_extract_rf_params_nfca_passive_poll(ndev, 415 data = nci_extract_rf_params_nfca_passive_poll(ndev,
215 &ntf, data); 416 &(ntf.rf_tech_specific_params.nfca_poll), data);
417 break;
418
419 case NCI_NFC_B_PASSIVE_POLL_MODE:
420 data = nci_extract_rf_params_nfcb_passive_poll(ndev,
421 &(ntf.rf_tech_specific_params.nfcb_poll), data);
422 break;
423
424 case NCI_NFC_F_PASSIVE_POLL_MODE:
425 data = nci_extract_rf_params_nfcf_passive_poll(ndev,
426 &(ntf.rf_tech_specific_params.nfcf_poll), data);
216 break; 427 break;
217 428
218 default: 429 default:
219 pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", 430 pr_err("unsupported activation_rf_tech_and_mode 0x%x\n",
220 ntf.activation_rf_tech_and_mode); 431 ntf.activation_rf_tech_and_mode);
221 return; 432 err = NCI_STATUS_RF_PROTOCOL_ERROR;
433 goto exit;
222 } 434 }
223 } 435 }
224 436
@@ -250,12 +462,30 @@ static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
250 default: 462 default:
251 pr_err("unsupported rf_interface 0x%x\n", 463 pr_err("unsupported rf_interface 0x%x\n",
252 ntf.rf_interface); 464 ntf.rf_interface);
253 return; 465 err = NCI_STATUS_RF_PROTOCOL_ERROR;
466 break;
254 } 467 }
255 } 468 }
256 469
257 if (!err) 470exit:
258 nci_target_found(ndev, &ntf); 471 if (err == NCI_STATUS_OK) {
472 ndev->max_data_pkt_payload_size = ntf.max_data_pkt_payload_size;
473 ndev->initial_num_credits = ntf.initial_num_credits;
474
475 /* set the available credits to initial value */
476 atomic_set(&ndev->credits_cnt, ndev->initial_num_credits);
477 }
478
479 if (atomic_read(&ndev->state) == NCI_DISCOVERY) {
480 /* A single target was found and activated automatically */
481 atomic_set(&ndev->state, NCI_POLL_ACTIVE);
482 if (err == NCI_STATUS_OK)
483 nci_target_auto_activated(ndev, &ntf);
484 } else { /* ndev->state == NCI_W4_HOST_SELECT */
485 /* A selected target was activated, so complete the request */
486 atomic_set(&ndev->state, NCI_POLL_ACTIVE);
487 nci_req_complete(ndev, err);
488 }
259} 489}
260 490
261static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, 491static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev,
@@ -265,9 +495,6 @@ static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev,
265 495
266 pr_debug("entry, type 0x%x, reason 0x%x\n", ntf->type, ntf->reason); 496 pr_debug("entry, type 0x%x, reason 0x%x\n", ntf->type, ntf->reason);
267 497
268 clear_bit(NCI_POLL_ACTIVE, &ndev->flags);
269 ndev->target_active_prot = 0;
270
271 /* drop tx data queue */ 498 /* drop tx data queue */
272 skb_queue_purge(&ndev->tx_q); 499 skb_queue_purge(&ndev->tx_q);
273 500
@@ -280,6 +507,10 @@ static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev,
280 /* complete the data exchange transaction, if exists */ 507 /* complete the data exchange transaction, if exists */
281 if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags)) 508 if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags))
282 nci_data_exchange_complete(ndev, NULL, -EIO); 509 nci_data_exchange_complete(ndev, NULL, -EIO);
510
511 nci_clear_target_list(ndev);
512 atomic_set(&ndev->state, NCI_IDLE);
513 nci_req_complete(ndev, NCI_STATUS_OK);
283} 514}
284 515
285void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb) 516void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb)
@@ -300,10 +531,18 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb)
300 nci_core_conn_credits_ntf_packet(ndev, skb); 531 nci_core_conn_credits_ntf_packet(ndev, skb);
301 break; 532 break;
302 533
534 case NCI_OP_CORE_GENERIC_ERROR_NTF:
535 nci_core_generic_error_ntf_packet(ndev, skb);
536 break;
537
303 case NCI_OP_CORE_INTF_ERROR_NTF: 538 case NCI_OP_CORE_INTF_ERROR_NTF:
304 nci_core_conn_intf_error_ntf_packet(ndev, skb); 539 nci_core_conn_intf_error_ntf_packet(ndev, skb);
305 break; 540 break;
306 541
542 case NCI_OP_RF_DISCOVER_NTF:
543 nci_rf_discover_ntf_packet(ndev, skb);
544 break;
545
307 case NCI_OP_RF_INTF_ACTIVATED_NTF: 546 case NCI_OP_RF_INTF_ACTIVATED_NTF:
308 nci_rf_intf_activated_ntf_packet(ndev, skb); 547 nci_rf_intf_activated_ntf_packet(ndev, skb);
309 break; 548 break;
diff --git a/net/nfc/nci/rsp.c b/net/nfc/nci/rsp.c
index 2840ae2f3615..aa63b1e99188 100644
--- a/net/nfc/nci/rsp.c
+++ b/net/nfc/nci/rsp.c
@@ -137,11 +137,23 @@ static void nci_rf_disc_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
137 pr_debug("status 0x%x\n", status); 137 pr_debug("status 0x%x\n", status);
138 138
139 if (status == NCI_STATUS_OK) 139 if (status == NCI_STATUS_OK)
140 set_bit(NCI_DISCOVERY, &ndev->flags); 140 atomic_set(&ndev->state, NCI_DISCOVERY);
141 141
142 nci_req_complete(ndev, status); 142 nci_req_complete(ndev, status);
143} 143}
144 144
145static void nci_rf_disc_select_rsp_packet(struct nci_dev *ndev,
146 struct sk_buff *skb)
147{
148 __u8 status = skb->data[0];
149
150 pr_debug("status 0x%x\n", status);
151
152 /* Complete the request on intf_activated_ntf or generic_error_ntf */
153 if (status != NCI_STATUS_OK)
154 nci_req_complete(ndev, status);
155}
156
145static void nci_rf_deactivate_rsp_packet(struct nci_dev *ndev, 157static void nci_rf_deactivate_rsp_packet(struct nci_dev *ndev,
146 struct sk_buff *skb) 158 struct sk_buff *skb)
147{ 159{
@@ -149,9 +161,13 @@ static void nci_rf_deactivate_rsp_packet(struct nci_dev *ndev,
149 161
150 pr_debug("status 0x%x\n", status); 162 pr_debug("status 0x%x\n", status);
151 163
152 clear_bit(NCI_DISCOVERY, &ndev->flags); 164 /* If target was active, complete the request only in deactivate_ntf */
153 165 if ((status != NCI_STATUS_OK) ||
154 nci_req_complete(ndev, status); 166 (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) {
167 nci_clear_target_list(ndev);
168 atomic_set(&ndev->state, NCI_IDLE);
169 nci_req_complete(ndev, status);
170 }
155} 171}
156 172
157void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb) 173void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
@@ -187,6 +203,10 @@ void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
187 nci_rf_disc_rsp_packet(ndev, skb); 203 nci_rf_disc_rsp_packet(ndev, skb);
188 break; 204 break;
189 205
206 case NCI_OP_RF_DISCOVER_SELECT_RSP:
207 nci_rf_disc_select_rsp_packet(ndev, skb);
208 break;
209
190 case NCI_OP_RF_DEACTIVATE_RSP: 210 case NCI_OP_RF_DEACTIVATE_RSP:
191 nci_rf_deactivate_rsp_packet(ndev, skb); 211 nci_rf_deactivate_rsp_packet(ndev, skb);
192 break; 212 break;
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 6989dfa28ee2..07f0348aabf5 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -70,6 +70,12 @@ static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target,
70 if (target->nfcid1_len > 0) 70 if (target->nfcid1_len > 0)
71 NLA_PUT(msg, NFC_ATTR_TARGET_NFCID1, target->nfcid1_len, 71 NLA_PUT(msg, NFC_ATTR_TARGET_NFCID1, target->nfcid1_len,
72 target->nfcid1); 72 target->nfcid1);
73 if (target->sensb_res_len > 0)
74 NLA_PUT(msg, NFC_ATTR_TARGET_SENSB_RES, target->sensb_res_len,
75 target->sensb_res);
76 if (target->sensf_res_len > 0)
77 NLA_PUT(msg, NFC_ATTR_TARGET_SENSF_RES, target->sensf_res_len,
78 target->sensf_res);
73 79
74 return genlmsg_end(msg, hdr); 80 return genlmsg_end(msg, hdr);
75 81
diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
index 2e2f8c6a61fe..5325439b0c60 100644
--- a/net/nfc/rawsock.c
+++ b/net/nfc/rawsock.c
@@ -92,18 +92,6 @@ static int rawsock_connect(struct socket *sock, struct sockaddr *_addr,
92 goto error; 92 goto error;
93 } 93 }
94 94
95 if (addr->target_idx > dev->target_idx - 1 ||
96 addr->target_idx < dev->target_idx - dev->n_targets) {
97 rc = -EINVAL;
98 goto error;
99 }
100
101 if (addr->target_idx > dev->target_idx - 1 ||
102 addr->target_idx < dev->target_idx - dev->n_targets) {
103 rc = -EINVAL;
104 goto error;
105 }
106
107 rc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol); 95 rc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol);
108 if (rc) 96 if (rc)
109 goto put_dev; 97 goto put_dev;
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index 2590e91b3289..75b58f81d53d 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -260,6 +260,32 @@ config NET_SCH_INGRESS
260 To compile this code as a module, choose M here: the 260 To compile this code as a module, choose M here: the
261 module will be called sch_ingress. 261 module will be called sch_ingress.
262 262
263config NET_SCH_PLUG
264 tristate "Plug network traffic until release (PLUG)"
265 ---help---
266
267 This queuing discipline allows userspace to plug/unplug a network
268 output queue, using the netlink interface. When it receives an
269 enqueue command it inserts a plug into the outbound queue that
270 causes following packets to enqueue until a dequeue command arrives
271 over netlink, causing the plug to be removed and resuming the normal
272 packet flow.
273
274 This module also provides a generic "network output buffering"
275 functionality (aka output commit), wherein upon arrival of a dequeue
276 command, only packets up to the first plug are released for delivery.
277 The Remus HA project uses this module to enable speculative execution
278 of virtual machines by allowing the generated network output to be rolled
279 back if needed.
280
281 For more information, please refer to http://wiki.xensource.com/xenwiki/Remus
282
283 Say Y here if you are using this kernel for Xen dom0 and
284 want to protect Xen guests with Remus.
285
286 To compile this code as a module, choose M here: the
287 module will be called sch_plug.
288
263comment "Classification" 289comment "Classification"
264 290
265config NET_CLS 291config NET_CLS
diff --git a/net/sched/Makefile b/net/sched/Makefile
index dc5889c0a15a..8cdf4e2b51d3 100644
--- a/net/sched/Makefile
+++ b/net/sched/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_NET_SCH_MULTIQ) += sch_multiq.o
33obj-$(CONFIG_NET_SCH_ATM) += sch_atm.o 33obj-$(CONFIG_NET_SCH_ATM) += sch_atm.o
34obj-$(CONFIG_NET_SCH_NETEM) += sch_netem.o 34obj-$(CONFIG_NET_SCH_NETEM) += sch_netem.o
35obj-$(CONFIG_NET_SCH_DRR) += sch_drr.o 35obj-$(CONFIG_NET_SCH_DRR) += sch_drr.o
36obj-$(CONFIG_NET_SCH_PLUG) += sch_plug.o
36obj-$(CONFIG_NET_SCH_MQPRIO) += sch_mqprio.o 37obj-$(CONFIG_NET_SCH_MQPRIO) += sch_mqprio.o
37obj-$(CONFIG_NET_SCH_CHOKE) += sch_choke.o 38obj-$(CONFIG_NET_SCH_CHOKE) += sch_choke.o
38obj-$(CONFIG_NET_SCH_QFQ) += sch_qfq.o 39obj-$(CONFIG_NET_SCH_QFQ) += sch_qfq.o
diff --git a/net/sched/sch_plug.c b/net/sched/sch_plug.c
new file mode 100644
index 000000000000..ba7b737e4055
--- /dev/null
+++ b/net/sched/sch_plug.c
@@ -0,0 +1,233 @@
1/*
2 * sch_plug.c Queue traffic until an explicit release command
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * There are two ways to use this qdisc:
10 * 1. A simple "instantaneous" plug/unplug operation, by issuing an alternating
11 * sequence of TCQ_PLUG_BUFFER & TCQ_PLUG_RELEASE_INDEFINITE commands.
12 *
13 * 2. For network output buffering (a.k.a output commit) functionality.
14 * Output commit property is commonly used by applications using checkpoint
15 * based fault-tolerance to ensure that the checkpoint from which a system
16 * is being restored is consistent w.r.t outside world.
17 *
18 * Consider for e.g. Remus - a Virtual Machine checkpointing system,
19 * wherein a VM is checkpointed, say every 50ms. The checkpoint is replicated
20 * asynchronously to the backup host, while the VM continues executing the
21 * next epoch speculatively.
22 *
23 * The following is a typical sequence of output buffer operations:
24 * 1.At epoch i, start_buffer(i)
25 * 2. At end of epoch i (i.e. after 50ms):
26 * 2.1 Stop VM and take checkpoint(i).
27 * 2.2 start_buffer(i+1) and Resume VM
28 * 3. While speculatively executing epoch(i+1), asynchronously replicate
29 * checkpoint(i) to backup host.
30 * 4. When checkpoint_ack(i) is received from backup, release_buffer(i)
31 * Thus, this Qdisc would receive the following sequence of commands:
32 * TCQ_PLUG_BUFFER (epoch i)
33 * .. TCQ_PLUG_BUFFER (epoch i+1)
34 * ....TCQ_PLUG_RELEASE_ONE (epoch i)
35 * ......TCQ_PLUG_BUFFER (epoch i+2)
36 * ........
37 */
38
39#include <linux/module.h>
40#include <linux/types.h>
41#include <linux/kernel.h>
42#include <linux/errno.h>
43#include <linux/netdevice.h>
44#include <linux/skbuff.h>
45#include <net/pkt_sched.h>
46
47/*
48 * State of the queue, when used for network output buffering:
49 *
50 * plug(i+1) plug(i) head
51 * ------------------+--------------------+---------------->
52 * | |
53 * | |
54 * pkts_current_epoch| pkts_last_epoch |pkts_to_release
55 * ----------------->|<--------+--------->|+--------------->
56 * v v
57 *
58 */
59
60struct plug_sched_data {
61 /* If true, the dequeue function releases all packets
62 * from head to end of the queue. The queue turns into
63 * a pass-through queue for newly arriving packets.
64 */
65 bool unplug_indefinite;
66
67 /* Queue Limit in bytes */
68 u32 limit;
69
70 /* Number of packets (output) from the current speculatively
71 * executing epoch.
72 */
73 u32 pkts_current_epoch;
74
75 /* Number of packets corresponding to the recently finished
76 * epoch. These will be released when we receive a
77 * TCQ_PLUG_RELEASE_ONE command. This command is typically
78 * issued after committing a checkpoint at the target.
79 */
80 u32 pkts_last_epoch;
81
82 /*
83 * Number of packets from the head of the queue, that can
84 * be released (committed checkpoint).
85 */
86 u32 pkts_to_release;
87};
88
89static int plug_enqueue(struct sk_buff *skb, struct Qdisc *sch)
90{
91 struct plug_sched_data *q = qdisc_priv(sch);
92
93 if (likely(sch->qstats.backlog + skb->len <= q->limit)) {
94 if (!q->unplug_indefinite)
95 q->pkts_current_epoch++;
96 return qdisc_enqueue_tail(skb, sch);
97 }
98
99 return qdisc_reshape_fail(skb, sch);
100}
101
102static struct sk_buff *plug_dequeue(struct Qdisc *sch)
103{
104 struct plug_sched_data *q = qdisc_priv(sch);
105
106 if (qdisc_is_throttled(sch))
107 return NULL;
108
109 if (!q->unplug_indefinite) {
110 if (!q->pkts_to_release) {
111 /* No more packets to dequeue. Block the queue
112 * and wait for the next release command.
113 */
114 qdisc_throttled(sch);
115 return NULL;
116 }
117 q->pkts_to_release--;
118 }
119
120 return qdisc_dequeue_head(sch);
121}
122
123static int plug_init(struct Qdisc *sch, struct nlattr *opt)
124{
125 struct plug_sched_data *q = qdisc_priv(sch);
126
127 q->pkts_current_epoch = 0;
128 q->pkts_last_epoch = 0;
129 q->pkts_to_release = 0;
130 q->unplug_indefinite = false;
131
132 if (opt == NULL) {
133 /* We will set a default limit of 100 pkts (~150kB)
134 * in case tx_queue_len is not available. The
135 * default value is completely arbitrary.
136 */
137 u32 pkt_limit = qdisc_dev(sch)->tx_queue_len ? : 100;
138 q->limit = pkt_limit * psched_mtu(qdisc_dev(sch));
139 } else {
140 struct tc_plug_qopt *ctl = nla_data(opt);
141
142 if (nla_len(opt) < sizeof(*ctl))
143 return -EINVAL;
144
145 q->limit = ctl->limit;
146 }
147
148 qdisc_throttled(sch);
149 return 0;
150}
151
152/* Receives 4 types of messages:
153 * TCQ_PLUG_BUFFER: Inset a plug into the queue and
154 * buffer any incoming packets
155 * TCQ_PLUG_RELEASE_ONE: Dequeue packets from queue head
156 * to beginning of the next plug.
157 * TCQ_PLUG_RELEASE_INDEFINITE: Dequeue all packets from queue.
158 * Stop buffering packets until the next TCQ_PLUG_BUFFER
159 * command is received (just act as a pass-thru queue).
160 * TCQ_PLUG_LIMIT: Increase/decrease queue size
161 */
162static int plug_change(struct Qdisc *sch, struct nlattr *opt)
163{
164 struct plug_sched_data *q = qdisc_priv(sch);
165 struct tc_plug_qopt *msg;
166
167 if (opt == NULL)
168 return -EINVAL;
169
170 msg = nla_data(opt);
171 if (nla_len(opt) < sizeof(*msg))
172 return -EINVAL;
173
174 switch (msg->action) {
175 case TCQ_PLUG_BUFFER:
176 /* Save size of the current buffer */
177 q->pkts_last_epoch = q->pkts_current_epoch;
178 q->pkts_current_epoch = 0;
179 if (q->unplug_indefinite)
180 qdisc_throttled(sch);
181 q->unplug_indefinite = false;
182 break;
183 case TCQ_PLUG_RELEASE_ONE:
184 /* Add packets from the last complete buffer to the
185 * packets to be released set.
186 */
187 q->pkts_to_release += q->pkts_last_epoch;
188 q->pkts_last_epoch = 0;
189 qdisc_unthrottled(sch);
190 netif_schedule_queue(sch->dev_queue);
191 break;
192 case TCQ_PLUG_RELEASE_INDEFINITE:
193 q->unplug_indefinite = true;
194 q->pkts_to_release = 0;
195 q->pkts_last_epoch = 0;
196 q->pkts_current_epoch = 0;
197 qdisc_unthrottled(sch);
198 netif_schedule_queue(sch->dev_queue);
199 break;
200 case TCQ_PLUG_LIMIT:
201 /* Limit is supplied in bytes */
202 q->limit = msg->limit;
203 break;
204 default:
205 return -EINVAL;
206 }
207
208 return 0;
209}
210
211struct Qdisc_ops plug_qdisc_ops = {
212 .id = "plug",
213 .priv_size = sizeof(struct plug_sched_data),
214 .enqueue = plug_enqueue,
215 .dequeue = plug_dequeue,
216 .peek = qdisc_peek_head,
217 .init = plug_init,
218 .change = plug_change,
219 .owner = THIS_MODULE,
220};
221
222static int __init plug_module_init(void)
223{
224 return register_qdisc(&plug_qdisc_ops);
225}
226
227static void __exit plug_module_exit(void)
228{
229 unregister_qdisc(&plug_qdisc_ops);
230}
231module_init(plug_module_init)
232module_exit(plug_module_exit)
233MODULE_LICENSE("GPL");
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 8eb87b11d100..41ecf313073c 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -157,39 +157,14 @@ u32 tipc_bclink_get_last_sent(void)
157 return bcl->fsm_msg_cnt; 157 return bcl->fsm_msg_cnt;
158} 158}
159 159
160/** 160static void bclink_update_last_sent(struct tipc_node *node, u32 seqno)
161 * bclink_set_gap - set gap according to contents of current deferred pkt queue
162 *
163 * Called with 'node' locked, bc_lock unlocked
164 */
165
166static void bclink_set_gap(struct tipc_node *n_ptr)
167{
168 struct sk_buff *buf = n_ptr->bclink.deferred_head;
169
170 n_ptr->bclink.gap_after = n_ptr->bclink.gap_to =
171 mod(n_ptr->bclink.last_in);
172 if (unlikely(buf != NULL))
173 n_ptr->bclink.gap_to = mod(buf_seqno(buf) - 1);
174}
175
176/**
177 * bclink_ack_allowed - test if ACK or NACK message can be sent at this moment
178 *
179 * This mechanism endeavours to prevent all nodes in network from trying
180 * to ACK or NACK at the same time.
181 *
182 * Note: TIPC uses a different trigger to distribute ACKs than it does to
183 * distribute NACKs, but tries to use the same spacing (divide by 16).
184 */
185
186static int bclink_ack_allowed(u32 n)
187{ 161{
188 return (n % TIPC_MIN_LINK_WIN) == tipc_own_tag; 162 node->bclink.last_sent = less_eq(node->bclink.last_sent, seqno) ?
163 seqno : node->bclink.last_sent;
189} 164}
190 165
191 166
192/** 167/*
193 * tipc_bclink_retransmit_to - get most recent node to request retransmission 168 * tipc_bclink_retransmit_to - get most recent node to request retransmission
194 * 169 *
195 * Called with bc_lock locked 170 * Called with bc_lock locked
@@ -300,140 +275,94 @@ exit:
300 spin_unlock_bh(&bc_lock); 275 spin_unlock_bh(&bc_lock);
301} 276}
302 277
303/** 278/*
304 * bclink_send_ack - unicast an ACK msg 279 * tipc_bclink_update_link_state - update broadcast link state
305 * 280 *
306 * tipc_net_lock and node lock set 281 * tipc_net_lock and node lock set
307 */ 282 */
308 283
309static void bclink_send_ack(struct tipc_node *n_ptr) 284void tipc_bclink_update_link_state(struct tipc_node *n_ptr, u32 last_sent)
310{ 285{
311 struct tipc_link *l_ptr = n_ptr->active_links[n_ptr->addr & 1]; 286 struct sk_buff *buf;
312 287
313 if (l_ptr != NULL) 288 /* Ignore "stale" link state info */
314 tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0);
315}
316 289
317/** 290 if (less_eq(last_sent, n_ptr->bclink.last_in))
318 * bclink_send_nack- broadcast a NACK msg 291 return;
319 *
320 * tipc_net_lock and node lock set
321 */
322 292
323static void bclink_send_nack(struct tipc_node *n_ptr) 293 /* Update link synchronization state; quit if in sync */
324{ 294
325 struct sk_buff *buf; 295 bclink_update_last_sent(n_ptr, last_sent);
326 struct tipc_msg *msg; 296
297 if (n_ptr->bclink.last_sent == n_ptr->bclink.last_in)
298 return;
299
300 /* Update out-of-sync state; quit if loss is still unconfirmed */
301
302 if ((++n_ptr->bclink.oos_state) == 1) {
303 if (n_ptr->bclink.deferred_size < (TIPC_MIN_LINK_WIN / 2))
304 return;
305 n_ptr->bclink.oos_state++;
306 }
327 307
328 if (!less(n_ptr->bclink.gap_after, n_ptr->bclink.gap_to)) 308 /* Don't NACK if one has been recently sent (or seen) */
309
310 if (n_ptr->bclink.oos_state & 0x1)
329 return; 311 return;
330 312
313 /* Send NACK */
314
331 buf = tipc_buf_acquire(INT_H_SIZE); 315 buf = tipc_buf_acquire(INT_H_SIZE);
332 if (buf) { 316 if (buf) {
333 msg = buf_msg(buf); 317 struct tipc_msg *msg = buf_msg(buf);
318
334 tipc_msg_init(msg, BCAST_PROTOCOL, STATE_MSG, 319 tipc_msg_init(msg, BCAST_PROTOCOL, STATE_MSG,
335 INT_H_SIZE, n_ptr->addr); 320 INT_H_SIZE, n_ptr->addr);
336 msg_set_non_seq(msg, 1); 321 msg_set_non_seq(msg, 1);
337 msg_set_mc_netid(msg, tipc_net_id); 322 msg_set_mc_netid(msg, tipc_net_id);
338 msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in)); 323 msg_set_bcast_ack(msg, n_ptr->bclink.last_in);
339 msg_set_bcgap_after(msg, n_ptr->bclink.gap_after); 324 msg_set_bcgap_after(msg, n_ptr->bclink.last_in);
340 msg_set_bcgap_to(msg, n_ptr->bclink.gap_to); 325 msg_set_bcgap_to(msg, n_ptr->bclink.deferred_head
341 msg_set_bcast_tag(msg, tipc_own_tag); 326 ? buf_seqno(n_ptr->bclink.deferred_head) - 1
327 : n_ptr->bclink.last_sent);
342 328
329 spin_lock_bh(&bc_lock);
343 tipc_bearer_send(&bcbearer->bearer, buf, NULL); 330 tipc_bearer_send(&bcbearer->bearer, buf, NULL);
344 bcl->stats.sent_nacks++; 331 bcl->stats.sent_nacks++;
332 spin_unlock_bh(&bc_lock);
345 buf_discard(buf); 333 buf_discard(buf);
346 334
347 /* 335 n_ptr->bclink.oos_state++;
348 * Ensure we doesn't send another NACK msg to the node
349 * until 16 more deferred messages arrive from it
350 * (i.e. helps prevent all nodes from NACK'ing at same time)
351 */
352
353 n_ptr->bclink.nack_sync = tipc_own_tag;
354 } 336 }
355} 337}
356 338
357/** 339/*
358 * tipc_bclink_check_gap - send a NACK if a sequence gap exists 340 * bclink_peek_nack - monitor retransmission requests sent by other nodes
359 * 341 *
360 * tipc_net_lock and node lock set 342 * Delay any upcoming NACK by this node if another node has already
361 */ 343 * requested the first message this node is going to ask for.
362
363void tipc_bclink_check_gap(struct tipc_node *n_ptr, u32 last_sent)
364{
365 if (!n_ptr->bclink.supported ||
366 less_eq(last_sent, mod(n_ptr->bclink.last_in)))
367 return;
368
369 bclink_set_gap(n_ptr);
370 if (n_ptr->bclink.gap_after == n_ptr->bclink.gap_to)
371 n_ptr->bclink.gap_to = last_sent;
372 bclink_send_nack(n_ptr);
373}
374
375/**
376 * tipc_bclink_peek_nack - process a NACK msg meant for another node
377 * 344 *
378 * Only tipc_net_lock set. 345 * Only tipc_net_lock set.
379 */ 346 */
380 347
381static void tipc_bclink_peek_nack(u32 dest, u32 sender_tag, u32 gap_after, u32 gap_to) 348static void bclink_peek_nack(struct tipc_msg *msg)
382{ 349{
383 struct tipc_node *n_ptr = tipc_node_find(dest); 350 struct tipc_node *n_ptr = tipc_node_find(msg_destnode(msg));
384 u32 my_after, my_to;
385 351
386 if (unlikely(!n_ptr || !tipc_node_is_up(n_ptr))) 352 if (unlikely(!n_ptr))
387 return; 353 return;
354
388 tipc_node_lock(n_ptr); 355 tipc_node_lock(n_ptr);
389 /*
390 * Modify gap to suppress unnecessary NACKs from this node
391 */
392 my_after = n_ptr->bclink.gap_after;
393 my_to = n_ptr->bclink.gap_to;
394
395 if (less_eq(gap_after, my_after)) {
396 if (less(my_after, gap_to) && less(gap_to, my_to))
397 n_ptr->bclink.gap_after = gap_to;
398 else if (less_eq(my_to, gap_to))
399 n_ptr->bclink.gap_to = n_ptr->bclink.gap_after;
400 } else if (less_eq(gap_after, my_to)) {
401 if (less_eq(my_to, gap_to))
402 n_ptr->bclink.gap_to = gap_after;
403 } else {
404 /*
405 * Expand gap if missing bufs not in deferred queue:
406 */
407 struct sk_buff *buf = n_ptr->bclink.deferred_head;
408 u32 prev = n_ptr->bclink.gap_to;
409 356
410 for (; buf; buf = buf->next) { 357 if (n_ptr->bclink.supported &&
411 u32 seqno = buf_seqno(buf); 358 (n_ptr->bclink.last_in != n_ptr->bclink.last_sent) &&
359 (n_ptr->bclink.last_in == msg_bcgap_after(msg)))
360 n_ptr->bclink.oos_state = 2;
412 361
413 if (mod(seqno - prev) != 1) {
414 buf = NULL;
415 break;
416 }
417 if (seqno == gap_after)
418 break;
419 prev = seqno;
420 }
421 if (buf == NULL)
422 n_ptr->bclink.gap_to = gap_after;
423 }
424 /*
425 * Some nodes may send a complementary NACK now:
426 */
427 if (bclink_ack_allowed(sender_tag + 1)) {
428 if (n_ptr->bclink.gap_to != n_ptr->bclink.gap_after) {
429 bclink_send_nack(n_ptr);
430 bclink_set_gap(n_ptr);
431 }
432 }
433 tipc_node_unlock(n_ptr); 362 tipc_node_unlock(n_ptr);
434} 363}
435 364
436/** 365/*
437 * tipc_bclink_send_msg - broadcast a packet to all nodes in cluster 366 * tipc_bclink_send_msg - broadcast a packet to all nodes in cluster
438 */ 367 */
439 368
@@ -460,7 +389,33 @@ exit:
460 return res; 389 return res;
461} 390}
462 391
463/** 392/*
393 * bclink_accept_pkt - accept an incoming, in-sequence broadcast packet
394 *
395 * Called with both sending node's lock and bc_lock taken.
396 */
397
398static void bclink_accept_pkt(struct tipc_node *node, u32 seqno)
399{
400 bclink_update_last_sent(node, seqno);
401 node->bclink.last_in = seqno;
402 node->bclink.oos_state = 0;
403 bcl->stats.recv_info++;
404
405 /*
406 * Unicast an ACK periodically, ensuring that
407 * all nodes in the cluster don't ACK at the same time
408 */
409
410 if (((seqno - tipc_own_addr) % TIPC_MIN_LINK_WIN) == 0) {
411 tipc_link_send_proto_msg(
412 node->active_links[node->addr & 1],
413 STATE_MSG, 0, 0, 0, 0, 0);
414 bcl->stats.sent_acks++;
415 }
416}
417
418/*
464 * tipc_bclink_recv_pkt - receive a broadcast packet, and deliver upwards 419 * tipc_bclink_recv_pkt - receive a broadcast packet, and deliver upwards
465 * 420 *
466 * tipc_net_lock is read_locked, no other locks set 421 * tipc_net_lock is read_locked, no other locks set
@@ -472,7 +427,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
472 struct tipc_node *node; 427 struct tipc_node *node;
473 u32 next_in; 428 u32 next_in;
474 u32 seqno; 429 u32 seqno;
475 struct sk_buff *deferred; 430 int deferred;
476 431
477 /* Screen out unwanted broadcast messages */ 432 /* Screen out unwanted broadcast messages */
478 433
@@ -487,6 +442,8 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
487 if (unlikely(!node->bclink.supported)) 442 if (unlikely(!node->bclink.supported))
488 goto unlock; 443 goto unlock;
489 444
445 /* Handle broadcast protocol message */
446
490 if (unlikely(msg_user(msg) == BCAST_PROTOCOL)) { 447 if (unlikely(msg_user(msg) == BCAST_PROTOCOL)) {
491 if (msg_type(msg) != STATE_MSG) 448 if (msg_type(msg) != STATE_MSG)
492 goto unlock; 449 goto unlock;
@@ -501,85 +458,114 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
501 spin_unlock_bh(&bc_lock); 458 spin_unlock_bh(&bc_lock);
502 } else { 459 } else {
503 tipc_node_unlock(node); 460 tipc_node_unlock(node);
504 tipc_bclink_peek_nack(msg_destnode(msg), 461 bclink_peek_nack(msg);
505 msg_bcast_tag(msg),
506 msg_bcgap_after(msg),
507 msg_bcgap_to(msg));
508 } 462 }
509 goto exit; 463 goto exit;
510 } 464 }
511 465
512 /* Handle in-sequence broadcast message */ 466 /* Handle in-sequence broadcast message */
513 467
514receive:
515 next_in = mod(node->bclink.last_in + 1);
516 seqno = msg_seqno(msg); 468 seqno = msg_seqno(msg);
469 next_in = mod(node->bclink.last_in + 1);
517 470
518 if (likely(seqno == next_in)) { 471 if (likely(seqno == next_in)) {
519 bcl->stats.recv_info++; 472receive:
520 node->bclink.last_in++; 473 /* Deliver message to destination */
521 bclink_set_gap(node); 474
522 if (unlikely(bclink_ack_allowed(seqno))) {
523 bclink_send_ack(node);
524 bcl->stats.sent_acks++;
525 }
526 if (likely(msg_isdata(msg))) { 475 if (likely(msg_isdata(msg))) {
476 spin_lock_bh(&bc_lock);
477 bclink_accept_pkt(node, seqno);
478 spin_unlock_bh(&bc_lock);
527 tipc_node_unlock(node); 479 tipc_node_unlock(node);
528 if (likely(msg_mcast(msg))) 480 if (likely(msg_mcast(msg)))
529 tipc_port_recv_mcast(buf, NULL); 481 tipc_port_recv_mcast(buf, NULL);
530 else 482 else
531 buf_discard(buf); 483 buf_discard(buf);
532 } else if (msg_user(msg) == MSG_BUNDLER) { 484 } else if (msg_user(msg) == MSG_BUNDLER) {
485 spin_lock_bh(&bc_lock);
486 bclink_accept_pkt(node, seqno);
533 bcl->stats.recv_bundles++; 487 bcl->stats.recv_bundles++;
534 bcl->stats.recv_bundled += msg_msgcnt(msg); 488 bcl->stats.recv_bundled += msg_msgcnt(msg);
489 spin_unlock_bh(&bc_lock);
535 tipc_node_unlock(node); 490 tipc_node_unlock(node);
536 tipc_link_recv_bundle(buf); 491 tipc_link_recv_bundle(buf);
537 } else if (msg_user(msg) == MSG_FRAGMENTER) { 492 } else if (msg_user(msg) == MSG_FRAGMENTER) {
493 int ret = tipc_link_recv_fragment(&node->bclink.defragm,
494 &buf, &msg);
495 if (ret < 0)
496 goto unlock;
497 spin_lock_bh(&bc_lock);
498 bclink_accept_pkt(node, seqno);
538 bcl->stats.recv_fragments++; 499 bcl->stats.recv_fragments++;
539 if (tipc_link_recv_fragment(&node->bclink.defragm, 500 if (ret > 0)
540 &buf, &msg))
541 bcl->stats.recv_fragmented++; 501 bcl->stats.recv_fragmented++;
502 spin_unlock_bh(&bc_lock);
542 tipc_node_unlock(node); 503 tipc_node_unlock(node);
543 tipc_net_route_msg(buf); 504 tipc_net_route_msg(buf);
544 } else if (msg_user(msg) == NAME_DISTRIBUTOR) { 505 } else if (msg_user(msg) == NAME_DISTRIBUTOR) {
506 spin_lock_bh(&bc_lock);
507 bclink_accept_pkt(node, seqno);
508 spin_unlock_bh(&bc_lock);
545 tipc_node_unlock(node); 509 tipc_node_unlock(node);
546 tipc_named_recv(buf); 510 tipc_named_recv(buf);
547 } else { 511 } else {
512 spin_lock_bh(&bc_lock);
513 bclink_accept_pkt(node, seqno);
514 spin_unlock_bh(&bc_lock);
548 tipc_node_unlock(node); 515 tipc_node_unlock(node);
549 buf_discard(buf); 516 buf_discard(buf);
550 } 517 }
551 buf = NULL; 518 buf = NULL;
519
520 /* Determine new synchronization state */
521
552 tipc_node_lock(node); 522 tipc_node_lock(node);
553 deferred = node->bclink.deferred_head; 523 if (unlikely(!tipc_node_is_up(node)))
554 if (deferred && (buf_seqno(deferred) == mod(next_in + 1))) { 524 goto unlock;
555 buf = deferred; 525
556 msg = buf_msg(buf); 526 if (node->bclink.last_in == node->bclink.last_sent)
557 node->bclink.deferred_head = deferred->next; 527 goto unlock;
558 goto receive; 528
559 } 529 if (!node->bclink.deferred_head) {
560 } else if (less(next_in, seqno)) { 530 node->bclink.oos_state = 1;
561 u32 gap_after = node->bclink.gap_after; 531 goto unlock;
562 u32 gap_to = node->bclink.gap_to;
563
564 if (tipc_link_defer_pkt(&node->bclink.deferred_head,
565 &node->bclink.deferred_tail,
566 buf)) {
567 node->bclink.nack_sync++;
568 bcl->stats.deferred_recv++;
569 if (seqno == mod(gap_after + 1))
570 node->bclink.gap_after = seqno;
571 else if (less(gap_after, seqno) && less(seqno, gap_to))
572 node->bclink.gap_to = seqno;
573 } 532 }
533
534 msg = buf_msg(node->bclink.deferred_head);
535 seqno = msg_seqno(msg);
536 next_in = mod(next_in + 1);
537 if (seqno != next_in)
538 goto unlock;
539
540 /* Take in-sequence message from deferred queue & deliver it */
541
542 buf = node->bclink.deferred_head;
543 node->bclink.deferred_head = buf->next;
544 node->bclink.deferred_size--;
545 goto receive;
546 }
547
548 /* Handle out-of-sequence broadcast message */
549
550 if (less(next_in, seqno)) {
551 deferred = tipc_link_defer_pkt(&node->bclink.deferred_head,
552 &node->bclink.deferred_tail,
553 buf);
554 node->bclink.deferred_size += deferred;
555 bclink_update_last_sent(node, seqno);
574 buf = NULL; 556 buf = NULL;
575 if (bclink_ack_allowed(node->bclink.nack_sync)) { 557 } else
576 if (gap_to != gap_after) 558 deferred = 0;
577 bclink_send_nack(node); 559
578 bclink_set_gap(node); 560 spin_lock_bh(&bc_lock);
579 } 561
580 } else { 562 if (deferred)
563 bcl->stats.deferred_recv++;
564 else
581 bcl->stats.duplicates++; 565 bcl->stats.duplicates++;
582 } 566
567 spin_unlock_bh(&bc_lock);
568
583unlock: 569unlock:
584 tipc_node_unlock(node); 570 tipc_node_unlock(node);
585exit: 571exit:
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h
index b009666c60b0..5571394098f9 100644
--- a/net/tipc/bcast.h
+++ b/net/tipc/bcast.h
@@ -96,7 +96,7 @@ int tipc_bclink_send_msg(struct sk_buff *buf);
96void tipc_bclink_recv_pkt(struct sk_buff *buf); 96void tipc_bclink_recv_pkt(struct sk_buff *buf);
97u32 tipc_bclink_get_last_sent(void); 97u32 tipc_bclink_get_last_sent(void);
98u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr); 98u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr);
99void tipc_bclink_check_gap(struct tipc_node *n_ptr, u32 seqno); 99void tipc_bclink_update_link_state(struct tipc_node *n_ptr, u32 last_sent);
100int tipc_bclink_stats(char *stats_buf, const u32 buf_size); 100int tipc_bclink_stats(char *stats_buf, const u32 buf_size);
101int tipc_bclink_reset_stats(void); 101int tipc_bclink_reset_stats(void);
102int tipc_bclink_set_queue_limits(u32 limit); 102int tipc_bclink_set_queue_limits(u32 limit);
diff --git a/net/tipc/link.c b/net/tipc/link.c
index ac1832a66f8a..d8b0a22367b6 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1501,13 +1501,13 @@ static void link_retransmit_failure(struct tipc_link *l_ptr,
1501 tipc_node_lock(n_ptr); 1501 tipc_node_lock(n_ptr);
1502 1502
1503 tipc_addr_string_fill(addr_string, n_ptr->addr); 1503 tipc_addr_string_fill(addr_string, n_ptr->addr);
1504 info("Multicast link info for %s\n", addr_string); 1504 info("Broadcast link info for %s\n", addr_string);
1505 info("Supportable: %d, ", n_ptr->bclink.supportable);
1505 info("Supported: %d, ", n_ptr->bclink.supported); 1506 info("Supported: %d, ", n_ptr->bclink.supported);
1506 info("Acked: %u\n", n_ptr->bclink.acked); 1507 info("Acked: %u\n", n_ptr->bclink.acked);
1507 info("Last in: %u, ", n_ptr->bclink.last_in); 1508 info("Last in: %u, ", n_ptr->bclink.last_in);
1508 info("Gap after: %u, ", n_ptr->bclink.gap_after); 1509 info("Oos state: %u, ", n_ptr->bclink.oos_state);
1509 info("Gap to: %u\n", n_ptr->bclink.gap_to); 1510 info("Last sent: %u\n", n_ptr->bclink.last_sent);
1510 info("Nack sync: %u\n\n", n_ptr->bclink.nack_sync);
1511 1511
1512 tipc_k_signal((Handler)link_reset_all, (unsigned long)n_ptr->addr); 1512 tipc_k_signal((Handler)link_reset_all, (unsigned long)n_ptr->addr);
1513 1513
@@ -1736,7 +1736,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
1736 1736
1737 /* Release acked messages */ 1737 /* Release acked messages */
1738 1738
1739 if (tipc_node_is_up(n_ptr) && n_ptr->bclink.supported) 1739 if (n_ptr->bclink.supported)
1740 tipc_bclink_acknowledge(n_ptr, msg_bcast_ack(msg)); 1740 tipc_bclink_acknowledge(n_ptr, msg_bcast_ack(msg));
1741 1741
1742 crs = l_ptr->first_out; 1742 crs = l_ptr->first_out;
@@ -1774,6 +1774,7 @@ protocol_check:
1774 head = link_insert_deferred_queue(l_ptr, 1774 head = link_insert_deferred_queue(l_ptr,
1775 head); 1775 head);
1776 if (likely(msg_is_dest(msg, tipc_own_addr))) { 1776 if (likely(msg_is_dest(msg, tipc_own_addr))) {
1777 int ret;
1777deliver: 1778deliver:
1778 if (likely(msg_isdata(msg))) { 1779 if (likely(msg_isdata(msg))) {
1779 tipc_node_unlock(n_ptr); 1780 tipc_node_unlock(n_ptr);
@@ -1798,11 +1799,15 @@ deliver:
1798 continue; 1799 continue;
1799 case MSG_FRAGMENTER: 1800 case MSG_FRAGMENTER:
1800 l_ptr->stats.recv_fragments++; 1801 l_ptr->stats.recv_fragments++;
1801 if (tipc_link_recv_fragment(&l_ptr->defragm_buf, 1802 ret = tipc_link_recv_fragment(
1802 &buf, &msg)) { 1803 &l_ptr->defragm_buf,
1804 &buf, &msg);
1805 if (ret == 1) {
1803 l_ptr->stats.recv_fragmented++; 1806 l_ptr->stats.recv_fragmented++;
1804 goto deliver; 1807 goto deliver;
1805 } 1808 }
1809 if (ret == -1)
1810 l_ptr->next_in_no--;
1806 break; 1811 break;
1807 case CHANGEOVER_PROTOCOL: 1812 case CHANGEOVER_PROTOCOL:
1808 type = msg_type(msg); 1813 type = msg_type(msg);
@@ -1853,17 +1858,16 @@ cont:
1853} 1858}
1854 1859
1855/* 1860/*
1856 * link_defer_buf(): Sort a received out-of-sequence packet 1861 * tipc_link_defer_pkt - Add out-of-sequence message to deferred reception queue
1857 * into the deferred reception queue. 1862 *
1858 * Returns the increase of the queue length,i.e. 0 or 1 1863 * Returns increase in queue length (i.e. 0 or 1)
1859 */ 1864 */
1860 1865
1861u32 tipc_link_defer_pkt(struct sk_buff **head, 1866u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail,
1862 struct sk_buff **tail,
1863 struct sk_buff *buf) 1867 struct sk_buff *buf)
1864{ 1868{
1865 struct sk_buff *prev = NULL; 1869 struct sk_buff *queue_buf;
1866 struct sk_buff *crs = *head; 1870 struct sk_buff **prev;
1867 u32 seq_no = buf_seqno(buf); 1871 u32 seq_no = buf_seqno(buf);
1868 1872
1869 buf->next = NULL; 1873 buf->next = NULL;
@@ -1881,31 +1885,30 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
1881 return 1; 1885 return 1;
1882 } 1886 }
1883 1887
1884 /* Scan through queue and sort it in */ 1888 /* Locate insertion point in queue, then insert; discard if duplicate */
1885 do { 1889 prev = head;
1886 struct tipc_msg *msg = buf_msg(crs); 1890 queue_buf = *head;
1891 for (;;) {
1892 u32 curr_seqno = buf_seqno(queue_buf);
1887 1893
1888 if (less(seq_no, msg_seqno(msg))) { 1894 if (seq_no == curr_seqno) {
1889 buf->next = crs; 1895 buf_discard(buf);
1890 if (prev) 1896 return 0;
1891 prev->next = buf;
1892 else
1893 *head = buf;
1894 return 1;
1895 } 1897 }
1896 if (seq_no == msg_seqno(msg)) 1898
1899 if (less(seq_no, curr_seqno))
1897 break; 1900 break;
1898 prev = crs;
1899 crs = crs->next;
1900 } while (crs);
1901 1901
1902 /* Message is a duplicate of an existing message */ 1902 prev = &queue_buf->next;
1903 queue_buf = queue_buf->next;
1904 }
1903 1905
1904 buf_discard(buf); 1906 buf->next = queue_buf;
1905 return 0; 1907 *prev = buf;
1908 return 1;
1906} 1909}
1907 1910
1908/** 1911/*
1909 * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet 1912 * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet
1910 */ 1913 */
1911 1914
@@ -1956,6 +1959,13 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ,
1956 u32 msg_size = sizeof(l_ptr->proto_msg); 1959 u32 msg_size = sizeof(l_ptr->proto_msg);
1957 int r_flag; 1960 int r_flag;
1958 1961
1962 /* Discard any previous message that was deferred due to congestion */
1963
1964 if (l_ptr->proto_msg_queue) {
1965 buf_discard(l_ptr->proto_msg_queue);
1966 l_ptr->proto_msg_queue = NULL;
1967 }
1968
1959 if (link_blocked(l_ptr)) 1969 if (link_blocked(l_ptr))
1960 return; 1970 return;
1961 1971
@@ -1964,9 +1974,11 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ,
1964 if ((l_ptr->owner->block_setup) && (msg_typ != RESET_MSG)) 1974 if ((l_ptr->owner->block_setup) && (msg_typ != RESET_MSG))
1965 return; 1975 return;
1966 1976
1977 /* Create protocol message with "out-of-sequence" sequence number */
1978
1967 msg_set_type(msg, msg_typ); 1979 msg_set_type(msg, msg_typ);
1968 msg_set_net_plane(msg, l_ptr->b_ptr->net_plane); 1980 msg_set_net_plane(msg, l_ptr->b_ptr->net_plane);
1969 msg_set_bcast_ack(msg, mod(l_ptr->owner->bclink.last_in)); 1981 msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in);
1970 msg_set_last_bcast(msg, tipc_bclink_get_last_sent()); 1982 msg_set_last_bcast(msg, tipc_bclink_get_last_sent());
1971 1983
1972 if (msg_typ == STATE_MSG) { 1984 if (msg_typ == STATE_MSG) {
@@ -2020,44 +2032,36 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ,
2020 r_flag = (l_ptr->owner->working_links > tipc_link_is_up(l_ptr)); 2032 r_flag = (l_ptr->owner->working_links > tipc_link_is_up(l_ptr));
2021 msg_set_redundant_link(msg, r_flag); 2033 msg_set_redundant_link(msg, r_flag);
2022 msg_set_linkprio(msg, l_ptr->priority); 2034 msg_set_linkprio(msg, l_ptr->priority);
2023 2035 msg_set_size(msg, msg_size);
2024 /* Ensure sequence number will not fit : */
2025 2036
2026 msg_set_seqno(msg, mod(l_ptr->next_out_no + (0xffff/2))); 2037 msg_set_seqno(msg, mod(l_ptr->next_out_no + (0xffff/2)));
2027 2038
2028 /* Congestion? */
2029
2030 if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) {
2031 if (!l_ptr->proto_msg_queue) {
2032 l_ptr->proto_msg_queue =
2033 tipc_buf_acquire(sizeof(l_ptr->proto_msg));
2034 }
2035 buf = l_ptr->proto_msg_queue;
2036 if (!buf)
2037 return;
2038 skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg));
2039 return;
2040 }
2041
2042 /* Message can be sent */
2043
2044 buf = tipc_buf_acquire(msg_size); 2039 buf = tipc_buf_acquire(msg_size);
2045 if (!buf) 2040 if (!buf)
2046 return; 2041 return;
2047 2042
2048 skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg)); 2043 skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg));
2049 msg_set_size(buf_msg(buf), msg_size);
2050 2044
2051 if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { 2045 /* Defer message if bearer is already congested */
2052 l_ptr->unacked_window = 0; 2046
2053 buf_discard(buf); 2047 if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) {
2048 l_ptr->proto_msg_queue = buf;
2054 return; 2049 return;
2055 } 2050 }
2056 2051
2057 /* New congestion */ 2052 /* Defer message if attempting to send results in bearer congestion */
2058 tipc_bearer_schedule(l_ptr->b_ptr, l_ptr); 2053
2059 l_ptr->proto_msg_queue = buf; 2054 if (!tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
2060 l_ptr->stats.bearer_congs++; 2055 tipc_bearer_schedule(l_ptr->b_ptr, l_ptr);
2056 l_ptr->proto_msg_queue = buf;
2057 l_ptr->stats.bearer_congs++;
2058 return;
2059 }
2060
2061 /* Discard message if it was sent successfully */
2062
2063 l_ptr->unacked_window = 0;
2064 buf_discard(buf);
2061} 2065}
2062 2066
2063/* 2067/*
@@ -2105,6 +2109,8 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf)
2105 l_ptr->owner->block_setup = WAIT_NODE_DOWN; 2109 l_ptr->owner->block_setup = WAIT_NODE_DOWN;
2106 } 2110 }
2107 2111
2112 link_state_event(l_ptr, RESET_MSG);
2113
2108 /* fall thru' */ 2114 /* fall thru' */
2109 case ACTIVATE_MSG: 2115 case ACTIVATE_MSG:
2110 /* Update link settings according other endpoint's values */ 2116 /* Update link settings according other endpoint's values */
@@ -2127,16 +2133,22 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf)
2127 } else { 2133 } else {
2128 l_ptr->max_pkt = l_ptr->max_pkt_target; 2134 l_ptr->max_pkt = l_ptr->max_pkt_target;
2129 } 2135 }
2130 l_ptr->owner->bclink.supported = (max_pkt_info != 0); 2136 l_ptr->owner->bclink.supportable = (max_pkt_info != 0);
2131 2137
2132 link_state_event(l_ptr, msg_type(msg)); 2138 /* Synchronize broadcast link info, if not done previously */
2139
2140 if (!tipc_node_is_up(l_ptr->owner)) {
2141 l_ptr->owner->bclink.last_sent =
2142 l_ptr->owner->bclink.last_in =
2143 msg_last_bcast(msg);
2144 l_ptr->owner->bclink.oos_state = 0;
2145 }
2133 2146
2134 l_ptr->peer_session = msg_session(msg); 2147 l_ptr->peer_session = msg_session(msg);
2135 l_ptr->peer_bearer_id = msg_bearer_id(msg); 2148 l_ptr->peer_bearer_id = msg_bearer_id(msg);
2136 2149
2137 /* Synchronize broadcast sequence numbers */ 2150 if (msg_type(msg) == ACTIVATE_MSG)
2138 if (!tipc_node_redundant_links(l_ptr->owner)) 2151 link_state_event(l_ptr, ACTIVATE_MSG);
2139 l_ptr->owner->bclink.last_in = mod(msg_last_bcast(msg));
2140 break; 2152 break;
2141 case STATE_MSG: 2153 case STATE_MSG:
2142 2154
@@ -2177,7 +2189,9 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf)
2177 2189
2178 /* Protocol message before retransmits, reduce loss risk */ 2190 /* Protocol message before retransmits, reduce loss risk */
2179 2191
2180 tipc_bclink_check_gap(l_ptr->owner, msg_last_bcast(msg)); 2192 if (l_ptr->owner->bclink.supported)
2193 tipc_bclink_update_link_state(l_ptr->owner,
2194 msg_last_bcast(msg));
2181 2195
2182 if (rec_gap || (msg_probe(msg))) { 2196 if (rec_gap || (msg_probe(msg))) {
2183 tipc_link_send_proto_msg(l_ptr, STATE_MSG, 2197 tipc_link_send_proto_msg(l_ptr, STATE_MSG,
@@ -2623,7 +2637,9 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
2623 set_fragm_size(pbuf, fragm_sz); 2637 set_fragm_size(pbuf, fragm_sz);
2624 set_expected_frags(pbuf, exp_fragm_cnt - 1); 2638 set_expected_frags(pbuf, exp_fragm_cnt - 1);
2625 } else { 2639 } else {
2626 warn("Link unable to reassemble fragmented message\n"); 2640 dbg("Link unable to reassemble fragmented message\n");
2641 buf_discard(fbuf);
2642 return -1;
2627 } 2643 }
2628 buf_discard(fbuf); 2644 buf_discard(fbuf);
2629 return 0; 2645 return 0;
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 98ebb37f1808..acecfda82f37 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -239,9 +239,6 @@ exit:
239 * 239 *
240 * Invoked for each publication issued by a newly failed node. 240 * Invoked for each publication issued by a newly failed node.
241 * Removes publication structure from name table & deletes it. 241 * Removes publication structure from name table & deletes it.
242 * In rare cases the link may have come back up again when this
243 * function is called, and we have two items representing the same
244 * publication. Nudge this item's key to distinguish it from the other.
245 */ 242 */
246 243
247static void named_purge_publ(struct publication *publ) 244static void named_purge_publ(struct publication *publ)
@@ -249,7 +246,6 @@ static void named_purge_publ(struct publication *publ)
249 struct publication *p; 246 struct publication *p;
250 247
251 write_lock_bh(&tipc_nametbl_lock); 248 write_lock_bh(&tipc_nametbl_lock);
252 publ->key += 1222345;
253 p = tipc_nametbl_remove_publ(publ->type, publ->lower, 249 p = tipc_nametbl_remove_publ(publ->type, publ->lower,
254 publ->node, publ->ref, publ->key); 250 publ->node, publ->ref, publ->key);
255 if (p) 251 if (p)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 6b226faad89f..7bc45e135fb4 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -49,9 +49,8 @@ LIST_HEAD(tipc_node_list);
49static u32 tipc_num_nodes; 49static u32 tipc_num_nodes;
50 50
51static atomic_t tipc_num_links = ATOMIC_INIT(0); 51static atomic_t tipc_num_links = ATOMIC_INIT(0);
52u32 tipc_own_tag;
53 52
54/** 53/*
55 * tipc_node_find - locate specified node object, if it exists 54 * tipc_node_find - locate specified node object, if it exists
56 */ 55 */
57 56
@@ -306,10 +305,9 @@ static void node_established_contact(struct tipc_node *n_ptr)
306 /* Syncronize broadcast acks */ 305 /* Syncronize broadcast acks */
307 n_ptr->bclink.acked = tipc_bclink_get_last_sent(); 306 n_ptr->bclink.acked = tipc_bclink_get_last_sent();
308 307
309 if (n_ptr->bclink.supported) { 308 if (n_ptr->bclink.supportable) {
310 tipc_bclink_add_node(n_ptr->addr); 309 tipc_bclink_add_node(n_ptr->addr);
311 if (n_ptr->addr < tipc_own_addr) 310 n_ptr->bclink.supported = 1;
312 tipc_own_tag++;
313 } 311 }
314} 312}
315 313
@@ -338,12 +336,12 @@ static void node_lost_contact(struct tipc_node *n_ptr)
338 /* Flush broadcast link info associated with lost node */ 336 /* Flush broadcast link info associated with lost node */
339 337
340 if (n_ptr->bclink.supported) { 338 if (n_ptr->bclink.supported) {
341 n_ptr->bclink.gap_after = n_ptr->bclink.gap_to = 0;
342 while (n_ptr->bclink.deferred_head) { 339 while (n_ptr->bclink.deferred_head) {
343 struct sk_buff *buf = n_ptr->bclink.deferred_head; 340 struct sk_buff *buf = n_ptr->bclink.deferred_head;
344 n_ptr->bclink.deferred_head = buf->next; 341 n_ptr->bclink.deferred_head = buf->next;
345 buf_discard(buf); 342 buf_discard(buf);
346 } 343 }
344 n_ptr->bclink.deferred_size = 0;
347 345
348 if (n_ptr->bclink.defragm) { 346 if (n_ptr->bclink.defragm) {
349 buf_discard(n_ptr->bclink.defragm); 347 buf_discard(n_ptr->bclink.defragm);
@@ -352,8 +350,6 @@ static void node_lost_contact(struct tipc_node *n_ptr)
352 350
353 tipc_bclink_remove_node(n_ptr->addr); 351 tipc_bclink_remove_node(n_ptr->addr);
354 tipc_bclink_acknowledge(n_ptr, INVALID_LINK_SEQ); 352 tipc_bclink_acknowledge(n_ptr, INVALID_LINK_SEQ);
355 if (n_ptr->addr < tipc_own_addr)
356 tipc_own_tag--;
357 353
358 n_ptr->bclink.supported = 0; 354 n_ptr->bclink.supported = 0;
359 } 355 }
@@ -449,7 +445,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
449 445
450 read_lock_bh(&tipc_net_lock); 446 read_lock_bh(&tipc_net_lock);
451 447
452 /* Get space for all unicast links + multicast link */ 448 /* Get space for all unicast links + broadcast link */
453 449
454 payload_size = TLV_SPACE(sizeof(link_info)) * 450 payload_size = TLV_SPACE(sizeof(link_info)) *
455 (atomic_read(&tipc_num_links) + 1); 451 (atomic_read(&tipc_num_links) + 1);
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 0b1c5f8b6996..e1b78a2199c2 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -62,12 +62,13 @@
62 * @link_cnt: number of links to node 62 * @link_cnt: number of links to node
63 * @permit_changeover: non-zero if node has redundant links to this system 63 * @permit_changeover: non-zero if node has redundant links to this system
64 * @bclink: broadcast-related info 64 * @bclink: broadcast-related info
65 * @supportable: non-zero if node supports TIPC b'cast link capability
65 * @supported: non-zero if node supports TIPC b'cast capability 66 * @supported: non-zero if node supports TIPC b'cast capability
66 * @acked: sequence # of last outbound b'cast message acknowledged by node 67 * @acked: sequence # of last outbound b'cast message acknowledged by node
67 * @last_in: sequence # of last in-sequence b'cast message received from node 68 * @last_in: sequence # of last in-sequence b'cast message received from node
68 * @gap_after: sequence # of last message not requiring a NAK request 69 * @last_sent: sequence # of last b'cast message sent by node
69 * @gap_to: sequence # of last message requiring a NAK request 70 * @oos_state: state tracker for handling OOS b'cast messages
70 * @nack_sync: counter that determines when NAK requests should be sent 71 * @deferred_size: number of OOS b'cast messages in deferred queue
71 * @deferred_head: oldest OOS b'cast message received from node 72 * @deferred_head: oldest OOS b'cast message received from node
72 * @deferred_tail: newest OOS b'cast message received from node 73 * @deferred_tail: newest OOS b'cast message received from node
73 * @defragm: list of partially reassembled b'cast message fragments from node 74 * @defragm: list of partially reassembled b'cast message fragments from node
@@ -86,12 +87,13 @@ struct tipc_node {
86 int block_setup; 87 int block_setup;
87 int permit_changeover; 88 int permit_changeover;
88 struct { 89 struct {
89 int supported; 90 u8 supportable;
91 u8 supported;
90 u32 acked; 92 u32 acked;
91 u32 last_in; 93 u32 last_in;
92 u32 gap_after; 94 u32 last_sent;
93 u32 gap_to; 95 u32 oos_state;
94 u32 nack_sync; 96 u32 deferred_size;
95 struct sk_buff *deferred_head; 97 struct sk_buff *deferred_head;
96 struct sk_buff *deferred_tail; 98 struct sk_buff *deferred_tail;
97 struct sk_buff *defragm; 99 struct sk_buff *defragm;
@@ -112,8 +114,6 @@ static inline unsigned int tipc_hashfn(u32 addr)
112 return addr & (NODE_HTABLE_SIZE - 1); 114 return addr & (NODE_HTABLE_SIZE - 1);
113} 115}
114 116
115extern u32 tipc_own_tag;
116
117struct tipc_node *tipc_node_find(u32 addr); 117struct tipc_node *tipc_node_find(u32 addr);
118struct tipc_node *tipc_node_create(u32 addr); 118struct tipc_node *tipc_node_create(u32 addr);
119void tipc_node_delete(struct tipc_node *n_ptr); 119void tipc_node_delete(struct tipc_node *n_ptr);
diff --git a/net/tipc/port.c b/net/tipc/port.c
index d91efc69e6f9..ba3268b8da42 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -400,15 +400,16 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
400 400
401 /* send self-abort message when rejecting on a connected port */ 401 /* send self-abort message when rejecting on a connected port */
402 if (msg_connected(msg)) { 402 if (msg_connected(msg)) {
403 struct sk_buff *abuf = NULL;
404 struct tipc_port *p_ptr = tipc_port_lock(msg_destport(msg)); 403 struct tipc_port *p_ptr = tipc_port_lock(msg_destport(msg));
405 404
406 if (p_ptr) { 405 if (p_ptr) {
406 struct sk_buff *abuf = NULL;
407
407 if (p_ptr->connected) 408 if (p_ptr->connected)
408 abuf = port_build_self_abort_msg(p_ptr, err); 409 abuf = port_build_self_abort_msg(p_ptr, err);
409 tipc_port_unlock(p_ptr); 410 tipc_port_unlock(p_ptr);
411 tipc_net_route_msg(abuf);
410 } 412 }
411 tipc_net_route_msg(abuf);
412 } 413 }
413 414
414 /* send returned message & dispose of rejected message */ 415 /* send returned message & dispose of rejected message */
diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c
index 8c550df13037..9d3e3b6bfcf4 100644
--- a/net/wireless/mesh.c
+++ b/net/wireless/mesh.c
@@ -55,6 +55,7 @@ const struct mesh_config default_mesh_config = {
55 .min_discovery_timeout = MESH_MIN_DISCOVERY_TIMEOUT, 55 .min_discovery_timeout = MESH_MIN_DISCOVERY_TIMEOUT,
56 .dot11MeshHWMPRannInterval = MESH_RANN_INTERVAL, 56 .dot11MeshHWMPRannInterval = MESH_RANN_INTERVAL,
57 .dot11MeshGateAnnouncementProtocol = false, 57 .dot11MeshGateAnnouncementProtocol = false,
58 .dot11MeshForwarding = true,
58}; 59};
59 60
60const struct mesh_setup default_mesh_setup = { 61const struct mesh_setup default_mesh_setup = {
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index afeea32e04ad..c910b0750dc2 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -427,10 +427,9 @@ static int nl80211_parse_key_new(struct nlattr *key, struct key_parse *k)
427 427
428 if (tb[NL80211_KEY_DEFAULT_TYPES]) { 428 if (tb[NL80211_KEY_DEFAULT_TYPES]) {
429 struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES]; 429 struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES];
430 int err = nla_parse_nested(kdt, 430 err = nla_parse_nested(kdt, NUM_NL80211_KEY_DEFAULT_TYPES - 1,
431 NUM_NL80211_KEY_DEFAULT_TYPES - 1, 431 tb[NL80211_KEY_DEFAULT_TYPES],
432 tb[NL80211_KEY_DEFAULT_TYPES], 432 nl80211_key_default_policy);
433 nl80211_key_default_policy);
434 if (err) 433 if (err)
435 return err; 434 return err;
436 435
@@ -3259,6 +3258,8 @@ static int nl80211_get_mesh_config(struct sk_buff *skb,
3259 cur_params.dot11MeshHWMPRannInterval); 3258 cur_params.dot11MeshHWMPRannInterval);
3260 NLA_PUT_U8(msg, NL80211_MESHCONF_GATE_ANNOUNCEMENTS, 3259 NLA_PUT_U8(msg, NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
3261 cur_params.dot11MeshGateAnnouncementProtocol); 3260 cur_params.dot11MeshGateAnnouncementProtocol);
3261 NLA_PUT_U8(msg, NL80211_MESHCONF_FORWARDING,
3262 cur_params.dot11MeshForwarding);
3262 nla_nest_end(msg, pinfoattr); 3263 nla_nest_end(msg, pinfoattr);
3263 genlmsg_end(msg, hdr); 3264 genlmsg_end(msg, hdr);
3264 return genlmsg_reply(msg, info); 3265 return genlmsg_reply(msg, info);
@@ -3290,6 +3291,7 @@ static const struct nla_policy nl80211_meshconf_params_policy[NL80211_MESHCONF_A
3290 [NL80211_MESHCONF_HWMP_ROOTMODE] = { .type = NLA_U8 }, 3291 [NL80211_MESHCONF_HWMP_ROOTMODE] = { .type = NLA_U8 },
3291 [NL80211_MESHCONF_HWMP_RANN_INTERVAL] = { .type = NLA_U16 }, 3292 [NL80211_MESHCONF_HWMP_RANN_INTERVAL] = { .type = NLA_U16 },
3292 [NL80211_MESHCONF_GATE_ANNOUNCEMENTS] = { .type = NLA_U8 }, 3293 [NL80211_MESHCONF_GATE_ANNOUNCEMENTS] = { .type = NLA_U8 },
3294 [NL80211_MESHCONF_FORWARDING] = { .type = NLA_U8 },
3293}; 3295};
3294 3296
3295static const struct nla_policy 3297static const struct nla_policy
@@ -3379,6 +3381,8 @@ do {\
3379 dot11MeshGateAnnouncementProtocol, mask, 3381 dot11MeshGateAnnouncementProtocol, mask,
3380 NL80211_MESHCONF_GATE_ANNOUNCEMENTS, 3382 NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
3381 nla_get_u8); 3383 nla_get_u8);
3384 FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding,
3385 mask, NL80211_MESHCONF_FORWARDING, nla_get_u8);
3382 if (mask_out) 3386 if (mask_out)
3383 *mask_out = mask; 3387 *mask_out = mask;
3384 3388
@@ -4781,7 +4785,6 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
4781 nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]); 4785 nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
4782 struct ieee80211_supported_band *sband = 4786 struct ieee80211_supported_band *sband =
4783 wiphy->bands[ibss.channel->band]; 4787 wiphy->bands[ibss.channel->band];
4784 int err;
4785 4788
4786 err = ieee80211_get_ratemask(sband, rates, n_rates, 4789 err = ieee80211_get_ratemask(sband, rates, n_rates,
4787 &ibss.basic_rates); 4790 &ibss.basic_rates);
@@ -5390,9 +5393,39 @@ static u32 rateset_to_mask(struct ieee80211_supported_band *sband,
5390 return mask; 5393 return mask;
5391} 5394}
5392 5395
5396static bool ht_rateset_to_mask(struct ieee80211_supported_band *sband,
5397 u8 *rates, u8 rates_len,
5398 u8 mcs[IEEE80211_HT_MCS_MASK_LEN])
5399{
5400 u8 i;
5401
5402 memset(mcs, 0, IEEE80211_HT_MCS_MASK_LEN);
5403
5404 for (i = 0; i < rates_len; i++) {
5405 int ridx, rbit;
5406
5407 ridx = rates[i] / 8;
5408 rbit = BIT(rates[i] % 8);
5409
5410 /* check validity */
5411 if ((ridx < 0) || (ridx > IEEE80211_HT_MCS_MASK_LEN))
5412 return false;
5413
5414 /* check availability */
5415 if (sband->ht_cap.mcs.rx_mask[ridx] & rbit)
5416 mcs[ridx] |= rbit;
5417 else
5418 return false;
5419 }
5420
5421 return true;
5422}
5423
5393static const struct nla_policy nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] = { 5424static const struct nla_policy nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] = {
5394 [NL80211_TXRATE_LEGACY] = { .type = NLA_BINARY, 5425 [NL80211_TXRATE_LEGACY] = { .type = NLA_BINARY,
5395 .len = NL80211_MAX_SUPP_RATES }, 5426 .len = NL80211_MAX_SUPP_RATES },
5427 [NL80211_TXRATE_MCS] = { .type = NLA_BINARY,
5428 .len = NL80211_MAX_SUPP_HT_RATES },
5396}; 5429};
5397 5430
5398static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, 5431static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb,
@@ -5418,12 +5451,20 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb,
5418 sband = rdev->wiphy.bands[i]; 5451 sband = rdev->wiphy.bands[i];
5419 mask.control[i].legacy = 5452 mask.control[i].legacy =
5420 sband ? (1 << sband->n_bitrates) - 1 : 0; 5453 sband ? (1 << sband->n_bitrates) - 1 : 0;
5454 if (sband)
5455 memcpy(mask.control[i].mcs,
5456 sband->ht_cap.mcs.rx_mask,
5457 sizeof(mask.control[i].mcs));
5458 else
5459 memset(mask.control[i].mcs, 0,
5460 sizeof(mask.control[i].mcs));
5421 } 5461 }
5422 5462
5423 /* 5463 /*
5424 * The nested attribute uses enum nl80211_band as the index. This maps 5464 * The nested attribute uses enum nl80211_band as the index. This maps
5425 * directly to the enum ieee80211_band values used in cfg80211. 5465 * directly to the enum ieee80211_band values used in cfg80211.
5426 */ 5466 */
5467 BUILD_BUG_ON(NL80211_MAX_SUPP_HT_RATES > IEEE80211_HT_MCS_MASK_LEN * 8);
5427 nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem) 5468 nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem)
5428 { 5469 {
5429 enum ieee80211_band band = nla_type(tx_rates); 5470 enum ieee80211_band band = nla_type(tx_rates);
@@ -5439,7 +5480,28 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb,
5439 sband, 5480 sband,
5440 nla_data(tb[NL80211_TXRATE_LEGACY]), 5481 nla_data(tb[NL80211_TXRATE_LEGACY]),
5441 nla_len(tb[NL80211_TXRATE_LEGACY])); 5482 nla_len(tb[NL80211_TXRATE_LEGACY]));
5442 if (mask.control[band].legacy == 0) 5483 }
5484 if (tb[NL80211_TXRATE_MCS]) {
5485 if (!ht_rateset_to_mask(
5486 sband,
5487 nla_data(tb[NL80211_TXRATE_MCS]),
5488 nla_len(tb[NL80211_TXRATE_MCS]),
5489 mask.control[band].mcs))
5490 return -EINVAL;
5491 }
5492
5493 if (mask.control[band].legacy == 0) {
5494 /* don't allow empty legacy rates if HT
5495 * is not even supported. */
5496 if (!rdev->wiphy.bands[band]->ht_cap.ht_supported)
5497 return -EINVAL;
5498
5499 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++)
5500 if (mask.control[band].mcs[i])
5501 break;
5502
5503 /* legacy and mcs rates may not be both empty */
5504 if (i == IEEE80211_HT_MCS_MASK_LEN)
5443 return -EINVAL; 5505 return -EINVAL;
5444 } 5506 }
5445 } 5507 }
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index f65feaad155f..e9a0ac83b84c 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -882,23 +882,8 @@ static void handle_channel(struct wiphy *wiphy,
882 chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags); 882 chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags);
883 chan->max_antenna_gain = min(chan->orig_mag, 883 chan->max_antenna_gain = min(chan->orig_mag,
884 (int) MBI_TO_DBI(power_rule->max_antenna_gain)); 884 (int) MBI_TO_DBI(power_rule->max_antenna_gain));
885 if (chan->orig_mpwr) { 885 chan->max_reg_power = (int) MBM_TO_DBM(power_rule->max_eirp);
886 /* 886 chan->max_power = min(chan->max_power, chan->max_reg_power);
887 * Devices that have their own custom regulatory domain
888 * but also use WIPHY_FLAG_STRICT_REGULATORY will follow the
889 * passed country IE power settings.
890 */
891 if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE &&
892 wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY &&
893 wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY) {
894 chan->max_power =
895 MBM_TO_DBM(power_rule->max_eirp);
896 } else {
897 chan->max_power = min(chan->orig_mpwr,
898 (int) MBM_TO_DBM(power_rule->max_eirp));
899 }
900 } else
901 chan->max_power = (int) MBM_TO_DBM(power_rule->max_eirp);
902} 887}
903 888
904static void handle_band(struct wiphy *wiphy, 889static void handle_band(struct wiphy *wiphy,